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

Merge pull request !7487 from chenzupeng/master-lite
This commit is contained in:
mindspore-ci-bot 2020-10-20 10:33:18 +08:00 committed by Gitee
commit 1af8c8badc
14 changed files with 25 additions and 19 deletions

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_);

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;
}

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; }

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;
}

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;
}

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;
}

View File

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

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);

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();

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();

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;
}

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;
}

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

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; }