Browse Source

!7487 [MS][LITE][GPU]optimize op program map key

Merge pull request !7487 from chenzupeng/master-lite
tags/v1.1.0
mindspore-ci-bot Gitee 5 years ago
parent
commit
1af8c8badc
14 changed files with 25 additions and 19 deletions
  1. +9
    -9
      mindspore/lite/src/runtime/kernel/opencl/kernel/activation.cc
  2. +1
    -0
      mindspore/lite/src/runtime/kernel/opencl/kernel/arithmetic.cc
  3. +1
    -0
      mindspore/lite/src/runtime/kernel/opencl/kernel/batch_to_space_nd.cc
  4. +1
    -1
      mindspore/lite/src/runtime/kernel/opencl/kernel/batchnorm.cc
  5. +1
    -1
      mindspore/lite/src/runtime/kernel/opencl/kernel/cast.cc
  6. +1
    -1
      mindspore/lite/src/runtime/kernel/opencl/kernel/concat.cc
  7. +1
    -0
      mindspore/lite/src/runtime/kernel/opencl/kernel/gather.cc
  8. +1
    -1
      mindspore/lite/src/runtime/kernel/opencl/kernel/pad.cc
  9. +3
    -2
      mindspore/lite/src/runtime/kernel/opencl/kernel/reduce.cc
  10. +3
    -2
      mindspore/lite/src/runtime/kernel/opencl/kernel/resize.cc
  11. +1
    -0
      mindspore/lite/src/runtime/kernel/opencl/kernel/scale.cc
  12. +1
    -0
      mindspore/lite/src/runtime/kernel/opencl/kernel/slice.cc
  13. +0
    -2
      mindspore/lite/src/runtime/kernel/opencl/kernel/softmax.cc
  14. +1
    -0
      mindspore/lite/src/runtime/kernel/opencl/kernel/space_to_batch_nd.cc

+ 9
- 9
mindspore/lite/src/runtime/kernel/opencl/kernel/activation.cc View File

@@ -61,12 +61,11 @@ int ActivationOpenClKernel::Init() {
MS_LOG(ERROR) << "Activate fun only support dim=4 or 2, but your dim=" << in_size_;
return RET_ERROR;
}
std::map<int, std::vector<std::string>> Program_Kernel{
{ActivationType_LEAKY_RELU, std::vector<std::string>{"LEAKY_RELU", "LeakyRelu"}},
{ActivationType_RELU, std::vector<std::string>{"RELU", "Relu"}},
{ActivationType_SIGMOID, std::vector<std::string>{"SIGMOID", "Sigmoid"}},
{ActivationType_RELU6, std::vector<std::string>{"RELU6", "Relu6"}},
{ActivationType_TANH, std::vector<std::string>{"TANH", "Tanh"}}};
std::map<int, std::string> Program_Kernel{{ActivationType_LEAKY_RELU, "LeakyRelu"},
{ActivationType_RELU, "Relu"},
{ActivationType_SIGMOID, "Sigmoid"},
{ActivationType_RELU6, "Relu6"},
{ActivationType_TANH, "Tanh"}};
if (Program_Kernel.count(type_) == 0) {
MS_LOG(ERROR) << "schema::ActivationType:" << type_ << "not found";
return RET_ERROR;
@@ -74,9 +73,10 @@ int ActivationOpenClKernel::Init() {

std::string source = activation_source;
std::set<std::string> build_options;
ocl_runtime_->LoadSource(Program_Kernel[type_][0], source);
std::string kernel_name = Program_Kernel[type_][1];
ocl_runtime_->BuildKernel(kernel_, Program_Kernel[type_][0], kernel_name, build_options);
std::string program_name = "Activation";
ocl_runtime_->LoadSource(program_name, source);
std::string kernel_name = Program_Kernel[type_];
ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options);
in_ori_format_ = in_tensors_[0]->GetFormat();
out_ori_format_ = out_tensors_[0]->GetFormat();
in_tensors_[0]->SetFormat(op_format_);


+ 1
- 0
mindspore/lite/src/runtime/kernel/opencl/kernel/arithmetic.cc View File

@@ -313,6 +313,7 @@ int ArithmeticOpenCLKernel::Init() {
out_tensors_[0]->SetFormat(format);
Image2dGetWorkGroupSize();
InitBuffer();
MS_LOG(DEBUG) << kernel_name << " Init Done!";
return RET_OK;
}



+ 1
- 0
mindspore/lite/src/runtime/kernel/opencl/kernel/batch_to_space_nd.cc View File

@@ -71,6 +71,7 @@ int BatchToSpaceNDOpenCLKernel::Init() {
ocl_runtime_->LoadSource(program_name, source);
ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options);
#endif
MS_LOG(DEBUG) << kernel_name << " Init Done!";
return RET_OK;
}
int BatchToSpaceNDOpenCLKernel::InitBuffer() { return RET_OK; }


+ 1
- 1
mindspore/lite/src/runtime/kernel/opencl/kernel/batchnorm.cc View File

@@ -72,7 +72,7 @@ int BatchNormOpenCLKernel::Init() {
std::string program_name = "Batch_normalization";
ocl_runtime_->LoadSource(program_name, source);
ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options);
MS_LOG(DEBUG) << kernel_name << " Init Done!";
return RET_OK;
}



+ 1
- 1
mindspore/lite/src/runtime/kernel/opencl/kernel/cast.cc View File

@@ -85,7 +85,7 @@ int CastOpenCLKernel::Init() {
std::string program_name = "cast";
ocl_runtime_->LoadSource(program_name, source);
ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options);
MS_LOG(DEBUG) << kernel_name << " Init Done!";
return RET_OK;
}



+ 1
- 1
mindspore/lite/src/runtime/kernel/opencl/kernel/concat.cc View File

@@ -122,7 +122,7 @@ int ConcatOpenCLKernel::Init() {
std::string program_name = "Concat";
ocl_runtime_->LoadSource(program_name, source);
ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options);
MS_LOG(DEBUG) << kernel_name << " Init Done!";
return RET_OK;
}



+ 1
- 0
mindspore/lite/src/runtime/kernel/opencl/kernel/gather.cc View File

@@ -66,6 +66,7 @@ int GatherOpenCLKernel::Init() {
return RET_ERROR;
}
}
MS_LOG(DEBUG) << kernel_name << " Init Done!";
return RET_OK;
}



+ 1
- 1
mindspore/lite/src/runtime/kernel/opencl/kernel/pad.cc View File

@@ -79,7 +79,7 @@ int PadOpenCLKernel::Init() {

const std::string source = pad_source;
const std::string kernel_name = op_format_ == Format_NHWC4 ? "Pad_NHWC4" : "Pad_NC4HW4";
const std::string &program_name = kernel_name;
const std::string program_name = "Pad";
ocl_runtime_->LoadSource(program_name, source);
ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options);



+ 3
- 2
mindspore/lite/src/runtime/kernel/opencl/kernel/reduce.cc View File

@@ -70,8 +70,9 @@ int ReduceOpenCLKernel::Init() {
#else
std::set<std::string> build_options;
std::string source = reduce_source;
ocl_runtime_->LoadSource(kernel_name, source);
ocl_runtime_->BuildKernel(kernel_, kernel_name, kernel_name, build_options);
std::string program_name = "Reduce";
ocl_runtime_->LoadSource(program_name, source);
ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options);
#endif
in_ori_format_ = in_tensors_[0]->GetFormat();
out_ori_format_ = out_tensors_[0]->GetFormat();


+ 3
- 2
mindspore/lite/src/runtime/kernel/opencl/kernel/resize.cc View File

@@ -60,8 +60,9 @@ int ResizeOpenCLKernel::Init() {
#else
std::set<std::string> build_options;
std::string source = resize_source;
ocl_runtime_->LoadSource(kernel_name, source);
ocl_runtime_->BuildKernel(kernel_, kernel_name, kernel_name, build_options);
std::string program_name = "Resize";
ocl_runtime_->LoadSource(program_name, source);
ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options);
#endif
in_ori_format_ = in_tensors_[0]->GetFormat();
out_ori_format_ = out_tensors_[0]->GetFormat();


+ 1
- 0
mindspore/lite/src/runtime/kernel/opencl/kernel/scale.cc View File

@@ -310,6 +310,7 @@ int ScaleOpenCLKernel::Init() {
out_tensors_[0]->SetFormat(format);
Image2dGetWorkGroupSize();
InitBuffer();
MS_LOG(DEBUG) << kernel_name << " Init Done!";
return RET_OK;
}



+ 1
- 0
mindspore/lite/src/runtime/kernel/opencl/kernel/slice.cc View File

@@ -71,6 +71,7 @@ int SliceOpenCLKernel::Init() {
std::string program_name = "slice";
ocl_runtime_->LoadSource(program_name, source);
ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options);
MS_LOG(DEBUG) << kernel_name << " Init Done!";
return RET_OK;
}



+ 0
- 2
mindspore/lite/src/runtime/kernel/opencl/kernel/softmax.cc View File

@@ -125,11 +125,9 @@ int SoftmaxOpenCLKernel::Init() {
// support 4d tensor
onexone_flag_ = true;
kernel_name += "1x1";
program_name += "1x1";
} else {
onexone_flag_ = false;
kernel_name += "Axis" + std::to_string(axis_);
program_name += "Axis" + std::to_string(axis_);
}
kernel_name += "_" + std::string(EnumNameFormat(op_format_));
#ifdef PROGRAM_WITH_IL


+ 1
- 0
mindspore/lite/src/runtime/kernel/opencl/kernel/space_to_batch_nd.cc View File

@@ -76,6 +76,7 @@ int SpaceToBatchNDOpenCLKernel::Init() {
ocl_runtime_->LoadSource(program_name, source);
ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options);
#endif
MS_LOG(DEBUG) << kernel_name << " Init Done!";
return RET_OK;
}
int SpaceToBatchNDOpenCLKernel::InitBuffer() { return RET_OK; }


Loading…
Cancel
Save