forked from mindspore-Ecosystem/mindspore
fix bug in softmax
This commit is contained in:
parent
f9374fead1
commit
3ec333e851
13
build.sh
13
build.sh
|
@ -482,22 +482,17 @@ gene_ocl_program() {
|
|||
SPIRV_DIR=build/spirv
|
||||
rm -rf ${SPIRV_DIR}
|
||||
mkdir -pv ${SPIRV_DIR}
|
||||
for sub_dir in "${CL_SRC_DIR}"/*
|
||||
do
|
||||
data_type="$(basename ${sub_dir})"
|
||||
if [ ! -d ${CL_SRC_DIR}/${data_type} ]; then
|
||||
continue
|
||||
if [ ! -d ${CL_SRC_DIR} ]; then
|
||||
return
|
||||
fi
|
||||
#echo $(cd "$(dirname $0)"; pwd)
|
||||
for file_path in "${CL_SRC_DIR}/${data_type}"/*
|
||||
for file_path in "${CL_SRC_DIR}"/*
|
||||
do
|
||||
file="$(basename ${file_path})"
|
||||
if [ "${file##*.}" != "cl" ]; then
|
||||
continue
|
||||
fi
|
||||
clang -Xclang -finclude-default-header -cl-std=CL2.0 --target=spir64-unknown-unknown -emit-llvm \
|
||||
-c -O0 -o ${SPIRV_DIR}/${file%.*}.bc ${CL_SRC_DIR}/${data_type}/${file}
|
||||
done
|
||||
-c -O0 -o ${SPIRV_DIR}/${file%.*}.bc ${CL_SRC_DIR}/${file}
|
||||
done
|
||||
|
||||
bcs=`ls ${SPIRV_DIR}/*.bc`
|
||||
|
|
|
@ -33,7 +33,7 @@ using mindspore::schema::PrimitiveType_SoftMax;
|
|||
namespace mindspore::kernel {
|
||||
|
||||
std::vector<float> SoftmaxOpenCLKernel::GetMaskForLastChannel(int channels) {
|
||||
std::vector<float> mask{4, 0.0f};
|
||||
std::vector<float> mask{0.0f, 0.0f, 0.0f, 0.0f};
|
||||
const int reminder = channels % 4 == 0 ? 4 : channels % 4;
|
||||
for (int i = 0; i < reminder; ++i) {
|
||||
mask[i] = 1.0f;
|
||||
|
|
|
@ -109,8 +109,9 @@ void *OpenCLAllocator::Malloc(size_t size, const std::vector<size_t> &img_size)
|
|||
cl::Image2D *image = new (std::nothrow) cl::Image2D(*ocl_runtime->Context(), image_format, *buffer, img_size[0],
|
||||
img_size[1], img_pitch * sizeof(cl_float4), &ret);
|
||||
if (image == nullptr || ret != CL_SUCCESS) {
|
||||
MS_LOG(ERROR) << "Create OpenCL Image2D failed! (ERROR CODE: " << ret << ")";
|
||||
delete buffer;
|
||||
UnLock();
|
||||
MS_LOG(ERROR) << "Create OpenCL Image2D failed! (ERROR CODE: " << ret << ")";
|
||||
return nullptr;
|
||||
}
|
||||
MS_LOG(DEBUG) << "Malloc a new Image2D, width=" << img_size[0] << ", height=" << img_size[1];
|
||||
|
|
Loading…
Reference in New Issue