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