forked from mindspore-Ecosystem/mindspore
Fix the return value is not processed && delete unused header
This commit is contained in:
parent
4fa965b857
commit
7afd0a942c
|
@ -14,16 +14,13 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <set>
|
||||
|
||||
#include "src/runtime/kernel/opencl/kernel/activation.h"
|
||||
#include "schema/model_generated.h"
|
||||
#include "src/kernel_registry.h"
|
||||
#include "include/errorcode.h"
|
||||
#include "nnacl/fp32/common_func_fp32.h"
|
||||
#include "src/runtime/kernel/opencl/cl/activation.cl.inc"
|
||||
|
||||
using mindspore::kernel::KERNEL_ARCH::kGPU;
|
||||
|
@ -69,14 +66,21 @@ int ActivationOpenCLKernel::Prepare() {
|
|||
outShape = GpuTensorInfo(out_tensors_[0]);
|
||||
std::string source = activation_source;
|
||||
std::string program_name = "Activation";
|
||||
ocl_runtime_->LoadSource(program_name, source);
|
||||
if (!ocl_runtime_->LoadSource(program_name, source)) {
|
||||
MS_LOG(ERROR) << "Load source failed.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
std::string kernel_name = GetActTypeString(type_);
|
||||
auto build_options_ext = CreateBuildOptionsExtByDType(this->registry_data_type_);
|
||||
ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
auto ret = ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "Build kernel failed.";
|
||||
return ret;
|
||||
}
|
||||
SetConstArgs();
|
||||
SetGlobalLocal();
|
||||
MS_LOG(DEBUG) << kernel_name << " init Done!";
|
||||
return mindspore::lite::RET_OK;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
void ActivationOpenCLKernel::SetConstArgs() {
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include "src/runtime/kernel/opencl/opencl_kernel.h"
|
||||
#include "nnacl/fp32/activation_fp32.h"
|
||||
|
||||
|
|
|
@ -15,9 +15,6 @@
|
|||
*/
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
#include <utility>
|
||||
#include <functional>
|
||||
#include "src/kernel_registry.h"
|
||||
#include "src/runtime/kernel/opencl/utils.h"
|
||||
|
@ -43,7 +40,7 @@ int ArgMinMaxOpenCLKernel::CheckSpecs() {
|
|||
<< " output data type is " << out_tensors_[0]->data_type();
|
||||
return RET_ERROR;
|
||||
}
|
||||
if (in_tensors_[0]->shape().size() > DIMENSION_4D) {
|
||||
if (in_tensors_[0]->shape().size() < DIMENSION_1D || in_tensors_[0]->shape().size() > DIMENSION_4D) {
|
||||
MS_LOG(ERROR) << "input shape size must be (1-4), actual: " << in_tensors_[0]->shape().size();
|
||||
return RET_ERROR;
|
||||
}
|
||||
|
@ -143,18 +140,18 @@ int ArgMinMaxOpenCLKernel::InitWeights() {
|
|||
|
||||
int ArgMinMaxOpenCLKernel::Prepare() {
|
||||
std::string kernel_name = "argminmax";
|
||||
|
||||
#ifdef PROGRAM_WITH_IL
|
||||
kernel_ = ocl_runtime_->GetKernelFromBinary(kernel_name);
|
||||
#else
|
||||
|
||||
std::string source = argminmax_source;
|
||||
std::string program_name = "argminmax";
|
||||
ocl_runtime_->LoadSource(program_name, source);
|
||||
if (!ocl_runtime_->LoadSource(program_name, source)) {
|
||||
MS_LOG(ERROR) << "Load source failed.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
auto build_options_ext = CreateBuildOptionsExtByDType(this->registry_data_type_);
|
||||
ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
#endif
|
||||
|
||||
auto ret = ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "Build kernel failed.";
|
||||
return ret;
|
||||
}
|
||||
auto *param = reinterpret_cast<ArgMinMaxParameter *>(this->op_parameter_);
|
||||
param->dims_size_ = in_tensors_[0]->shape().size();
|
||||
param->axis_ = (param->axis_ + param->dims_size_) % param->dims_size_;
|
||||
|
|
|
@ -15,16 +15,12 @@
|
|||
*/
|
||||
|
||||
#include "src/runtime/kernel/opencl/kernel/arithmetic.h"
|
||||
#include <set>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "nnacl/fp32/common_func_fp32.h"
|
||||
#include "schema/model_generated.h"
|
||||
#include "src/kernel_registry.h"
|
||||
#include "src/runtime/kernel/opencl/utils.h"
|
||||
#ifndef PROGRAM_WITH_IL
|
||||
#include "src/runtime/kernel/opencl/cl/arithmetic.cl.inc"
|
||||
#endif
|
||||
|
||||
using mindspore::kernel::KERNEL_ARCH::kGPU;
|
||||
using mindspore::lite::KernelRegistrar;
|
||||
|
@ -138,10 +134,6 @@ void ArithmeticOpenCLKernel::SetConstArgs() {
|
|||
}
|
||||
|
||||
int ArithmeticOpenCLKernel::Prepare() {
|
||||
#ifdef PROGRAM_WITH_IL
|
||||
kernel_ = ocl_runtime_->GetKernelFromBinary(kernel_name_);
|
||||
#else
|
||||
|
||||
in0_shape_ = GpuTensorInfo(in_tensors_[0]);
|
||||
in1_shape_ = GpuTensorInfo(in_tensors_[1]);
|
||||
out_shape_ = GpuTensorInfo(out_tensors_[0]);
|
||||
|
@ -189,10 +181,12 @@ int ArithmeticOpenCLKernel::Prepare() {
|
|||
|
||||
std::string program_name = "Arithmetic";
|
||||
std::string source = arithmetic_source;
|
||||
ocl_runtime_->LoadSource(program_name, source);
|
||||
if (!ocl_runtime_->LoadSource(program_name, source)) {
|
||||
MS_LOG(ERROR) << "Load source failed.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
auto build_options_ext = CreateBuildOptionsExtByDType(this->registry_data_type_);
|
||||
int error_code = ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name_, build_options_ext);
|
||||
#endif
|
||||
if (error_code != RET_OK) {
|
||||
return error_code;
|
||||
}
|
||||
|
|
|
@ -87,9 +87,16 @@ int ArithmeticSelfOpenCLKernel::Prepare() {
|
|||
}
|
||||
MS_LOG(DEBUG) << "execute kernel name : " << kernel_name;
|
||||
std::string program_name = "ArithmeticSelf";
|
||||
ocl_runtime_->LoadSource(program_name, arithmeticself_source);
|
||||
if (!ocl_runtime_->LoadSource(program_name, arithmeticself_source)) {
|
||||
MS_LOG(ERROR) << "Load source failed.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
auto build_options_ext = CreateBuildOptionsExtByDType(this->registry_data_type_);
|
||||
ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
auto ret = ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "Build kernel failed.";
|
||||
return ret;
|
||||
}
|
||||
SetGlobalLocal();
|
||||
SetConstArgs();
|
||||
return RET_OK;
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
#include <cstring>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
#include <utility>
|
||||
#include "src/kernel_registry.h"
|
||||
#include "src/runtime/kernel/opencl/kernel/batch_to_space_nd.h"
|
||||
#include "src/runtime/kernel/opencl/cl/batch_to_space_nd.cl.inc"
|
||||
|
@ -85,18 +83,18 @@ void BatchToSpaceNDOpenCLKernel::SetGlobalLocal() {
|
|||
|
||||
int BatchToSpaceNDOpenCLKernel::Prepare() {
|
||||
std::string kernel_name = "batch_to_space_nd_NHWC4";
|
||||
|
||||
#ifdef PROGRAM_WITH_IL
|
||||
kernel_ = ocl_runtime_->GetKernelFromBinary(kernel_name);
|
||||
#else
|
||||
|
||||
std::string source = batch_to_space_nd_source;
|
||||
std::string program_name = "batch_to_space_nd";
|
||||
ocl_runtime_->LoadSource(program_name, source);
|
||||
if (!ocl_runtime_->LoadSource(program_name, source)) {
|
||||
MS_LOG(ERROR) << "Load source failed.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
auto build_options_ext = CreateBuildOptionsExtByDType(this->registry_data_type_);
|
||||
ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
#endif
|
||||
|
||||
auto ret = ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "Build kernel failed.";
|
||||
return ret;
|
||||
}
|
||||
SetGlobalLocal();
|
||||
SetConstArgs();
|
||||
MS_LOG(DEBUG) << kernel_name << " Init Done!";
|
||||
|
|
|
@ -165,11 +165,18 @@ int BatchNormOpenCLKernel::Prepare() {
|
|||
std::string kernel_name = "Batch_normalization_NHWC4";
|
||||
std::string source = batchnorm_source;
|
||||
std::string program_name = "Batch_normalization";
|
||||
ocl_runtime_->LoadSource(program_name, source);
|
||||
if (!ocl_runtime_->LoadSource(program_name, source)) {
|
||||
MS_LOG(ERROR) << "Load source failed.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
auto build_options_ext = CreateBuildOptionsExtByDType(this->registry_data_type_);
|
||||
ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
auto ret = ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "Build kernel failed.";
|
||||
return ret;
|
||||
}
|
||||
MS_LOG(DEBUG) << kernel_name << " Init Done!";
|
||||
int ret = Initweight();
|
||||
ret = Initweight();
|
||||
if (ret) {
|
||||
MS_LOG(ERROR) << "Initweight failed ";
|
||||
return RET_ERROR;
|
||||
|
|
|
@ -14,9 +14,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <cstring>
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "src/kernel_registry.h"
|
||||
|
@ -73,8 +71,15 @@ int CastOpenCLKernel::Prepare() {
|
|||
std::string program_name = "Cast";
|
||||
std::string kernel_name =
|
||||
"Cast_" + dtype_names[in_tensors_.front()->data_type()] + "_to_" + dtype_names[out_tensors_.front()->data_type()];
|
||||
ocl_runtime_->LoadSource(program_name, cast_source);
|
||||
ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name);
|
||||
if (!ocl_runtime_->LoadSource(program_name, cast_source)) {
|
||||
MS_LOG(ERROR) << "Load source failed.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
auto ret = ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name);
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "Build kernel failed.";
|
||||
return ret;
|
||||
}
|
||||
SetConstArgs();
|
||||
SetGlobalLocal();
|
||||
return RET_OK;
|
||||
|
|
|
@ -223,9 +223,16 @@ int ConcatOpenCLKernel::Prepare() {
|
|||
MS_LOG(DEBUG) << "kernel_name=: " << kernel_name;
|
||||
std::string source = concat_source;
|
||||
std::string program_name = "Concat";
|
||||
ocl_runtime_->LoadSource(program_name, source);
|
||||
if (!ocl_runtime_->LoadSource(program_name, source)) {
|
||||
MS_LOG(ERROR) << "Load source failed.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
auto build_options_ext = CreateBuildOptionsExtByDType(this->registry_data_type_);
|
||||
ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
auto ret = ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "Build kernel failed.";
|
||||
return ret;
|
||||
}
|
||||
MS_LOG(DEBUG) << kernel_name << " Init Done!";
|
||||
SetConstArgs();
|
||||
SetGlobalLocal();
|
||||
|
|
|
@ -99,8 +99,14 @@ int Conv2DOpenCLKernel::CheckSpecs() {
|
|||
|
||||
int Conv2DOpenCLKernel::Prepare() {
|
||||
InitAttrs();
|
||||
BuildKernel();
|
||||
InitWeights();
|
||||
auto ret = BuildKernel();
|
||||
if (ret != RET_OK) {
|
||||
return ret;
|
||||
}
|
||||
ret = InitWeights();
|
||||
if (ret != RET_OK) {
|
||||
return ret;
|
||||
}
|
||||
SetGlobalLocal();
|
||||
SetConstArgs();
|
||||
return RET_OK;
|
||||
|
@ -134,7 +140,7 @@ void Conv2DOpenCLKernel::InitAttrs() {
|
|||
TILE_HW_ = UP_DIV(OW_, 4) * UP_DIV(OH_, 4);
|
||||
}
|
||||
|
||||
void Conv2DOpenCLKernel::BuildKernel() {
|
||||
int Conv2DOpenCLKernel::BuildKernel() {
|
||||
SetBlockSize();
|
||||
std::string program_name = "conv2d";
|
||||
std::stringstream kernel_name;
|
||||
|
@ -145,13 +151,21 @@ void Conv2DOpenCLKernel::BuildKernel() {
|
|||
if (KW_ == 1 && KH_ == 1) {
|
||||
kernel_name << "_1x1";
|
||||
}
|
||||
ocl_runtime_->LoadSource(program_name, GetActDefines() + conv2d_source);
|
||||
if (!ocl_runtime_->LoadSource(program_name, GetActDefines() + conv2d_source)) {
|
||||
MS_LOG(ERROR) << "Load source failed.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
auto build_options_ext = CreateBuildOptionsExtByDType(this->registry_data_type_);
|
||||
|
||||
std::string exceed_max_image_width_option =
|
||||
(OW_ * CO_SLICES_ <= ocl_runtime_->GetMaxImage2DWidth()) ? "" : " -DEXCEDD_MAX_IMAGE2D_WIDTH";
|
||||
build_options_ext.push_back(exceed_max_image_width_option);
|
||||
ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name.str(), build_options_ext);
|
||||
auto ret = ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name.str(), build_options_ext);
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "Build kernel failed.";
|
||||
return ret;
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
void Conv2DOpenCLKernel::SetBlockSize() {
|
||||
|
@ -160,6 +174,7 @@ void Conv2DOpenCLKernel::SetBlockSize() {
|
|||
return;
|
||||
}
|
||||
auto task_size = static_cast<float>(batch_size_ * OH_ * OW_ * CO_SLICES_);
|
||||
MS_ASSERT(ocl_runtime_->DeviceComputeUnits());
|
||||
auto task_size_per_cu = task_size / ocl_runtime_->DeviceComputeUnits();
|
||||
bool w_kernel_is_1 =
|
||||
KW_ == 1 && param_->stride_w_ == 1 && param_->dilation_w_ == 1 && param_->pad_l_ == 0 && param_->pad_r_ == 0;
|
||||
|
|
|
@ -77,7 +77,7 @@ class Conv2DOpenCLKernel : public OpenCLKernel {
|
|||
|
||||
protected:
|
||||
void InitAttrs();
|
||||
virtual void BuildKernel();
|
||||
virtual int BuildKernel();
|
||||
virtual void InitFilter();
|
||||
void InitBias();
|
||||
bool use_fp16_{false};
|
||||
|
|
|
@ -19,9 +19,7 @@
|
|||
#include <set>
|
||||
#include "nnacl/fp32/common_func_fp32.h"
|
||||
#include "src/kernel_registry.h"
|
||||
#ifndef PROGRAM_WITH_IL
|
||||
#include "src/runtime/kernel/opencl/cl/conv2d_transpose.cl.inc"
|
||||
#endif
|
||||
#include "src/runtime/kernel/opencl/utils.h"
|
||||
|
||||
using mindspore::kernel::KERNEL_ARCH::kGPU;
|
||||
|
@ -59,23 +57,26 @@ int Conv2dTransposeOpenCLKernel::CheckSpecs() {
|
|||
int Conv2dTransposeOpenCLKernel::Prepare() {
|
||||
std::string kernel_name = "conv2d_transpose";
|
||||
enable_fp16_ = ocl_runtime_->GetFp16Enable();
|
||||
#ifdef PROGRAM_WITH_IL
|
||||
kernel_ = ocl_runtime_->GetKernelFromBinary(kernel_name);
|
||||
#else
|
||||
std::string source = GetActDefines() + conv2d_transpose_source;
|
||||
std::string program_name = "conv2d_transpose";
|
||||
ocl_runtime_->LoadSource(program_name, source);
|
||||
if (!ocl_runtime_->LoadSource(program_name, source)) {
|
||||
MS_LOG(ERROR) << "Load source failed.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
auto build_options_ext = CreateBuildOptionsExtByDType(this->registry_data_type_);
|
||||
ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
#endif
|
||||
auto ret = InitWeights();
|
||||
auto ret = ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "Build kernel failed.";
|
||||
return ret;
|
||||
}
|
||||
ret = InitWeights();
|
||||
if (ret != RET_OK) {
|
||||
return ret;
|
||||
}
|
||||
SetGlobalLocal();
|
||||
SetConstArgs();
|
||||
MS_LOG(DEBUG) << kernel_name << " Init Done!";
|
||||
return mindspore::lite::RET_OK;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
void Conv2dTransposeOpenCLKernel::SetGlobalLocal() {
|
||||
|
@ -235,7 +236,7 @@ int Conv2dTransposeOpenCLKernel::Run() {
|
|||
ocl_runtime_->SetKernelArg(kernel_, arg_cnt++, in_tensors_[0]->data_c());
|
||||
ocl_runtime_->SetKernelArg(kernel_, arg_cnt++, out_tensors_[0]->data_c());
|
||||
ocl_runtime_->RunKernel(kernel_, global_range_, local_range_, nullptr, &event_);
|
||||
return mindspore::lite::RET_OK;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int Conv2dTransposeOpenCLKernel::InferShape() {
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#define MINDSPORE_LITE_SRC_RUNTIME_KERNEL_OPENCL_KERNEL_CONV2D_TRANSPOSE_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "src/inner_kernel.h"
|
||||
#include "nnacl/conv_parameter.h"
|
||||
#include "src/runtime/kernel/opencl/opencl_kernel.h"
|
||||
|
|
|
@ -25,13 +25,8 @@
|
|||
#include "nnacl/fp32/common_func_fp32.h"
|
||||
#include "nnacl/op_base.h"
|
||||
#include "include/errorcode.h"
|
||||
|
||||
#ifndef PROGRAM_WITH_IL
|
||||
|
||||
#include "src/runtime/kernel/opencl/cl/depthwise_conv2d.cl.inc"
|
||||
|
||||
#endif
|
||||
|
||||
using mindspore::kernel::KERNEL_ARCH::kGPU;
|
||||
using mindspore::lite::KernelRegistrar;
|
||||
using mindspore::lite::RET_ERROR;
|
||||
|
@ -78,16 +73,19 @@ int DepthwiseConv2dOpenCLKernel::Prepare() {
|
|||
} else {
|
||||
block_size_.C = block_size_.H = block_size_.W = 1;
|
||||
}
|
||||
#ifdef PROGRAM_WITH_IL
|
||||
kernel_ = ocl_runtime_->GetKernelFromBinary(kernel_name);
|
||||
#else
|
||||
std::string program_name = "DepthwiseConv2d";
|
||||
std::string source = depthwise_conv2d_source;
|
||||
ocl_runtime_->LoadSource(program_name, source);
|
||||
if (!ocl_runtime_->LoadSource(program_name, source)) {
|
||||
MS_LOG(ERROR) << "Load source failed.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
auto build_options_ext = CreateBuildOptionsExtByDType(this->registry_data_type_);
|
||||
ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
#endif
|
||||
auto ret = InitWeights();
|
||||
auto ret = ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "Build kernel failed.";
|
||||
return ret;
|
||||
}
|
||||
ret = InitWeights();
|
||||
if (ret != RET_OK) {
|
||||
return ret;
|
||||
}
|
||||
|
@ -98,7 +96,7 @@ int DepthwiseConv2dOpenCLKernel::Prepare() {
|
|||
SetGlobalLocal();
|
||||
SetConstArgs();
|
||||
MS_LOG(DEBUG) << kernel_name << " Init Done! mem type=" << static_cast<int>(out_mem_type_);
|
||||
return mindspore::lite::RET_OK;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int DepthwiseConv2dOpenCLKernel::InitWeights() {
|
||||
|
@ -162,7 +160,7 @@ int DepthwiseConv2dOpenCLKernel::InitWeights() {
|
|||
return RET_ERROR;
|
||||
}
|
||||
FreeStoredData(stored_weight_);
|
||||
return mindspore::lite::RET_OK;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int DepthwiseConv2dOpenCLKernel::InitBias() {
|
||||
|
@ -204,7 +202,7 @@ int DepthwiseConv2dOpenCLKernel::InitBias() {
|
|||
return RET_ERROR;
|
||||
}
|
||||
FreeStoredData(stored_bias_);
|
||||
return mindspore::lite::RET_OK;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
void DepthwiseConv2dOpenCLKernel::SetConstArgs() {
|
||||
|
@ -291,6 +289,6 @@ int DepthwiseConv2dOpenCLKernel::Run() {
|
|||
ocl_runtime_->SetKernelArg(kernel_, 0, out_tensors_[0]->data_c());
|
||||
ocl_runtime_->SetKernelArg(kernel_, 1, in_tensors_[0]->data_c());
|
||||
ocl_runtime_->RunKernel(kernel_, global_range_, local_range_, nullptr, &event_);
|
||||
return mindspore::lite::RET_OK;
|
||||
return RET_OK;
|
||||
}
|
||||
} // namespace mindspore::kernel
|
||||
|
|
|
@ -15,10 +15,6 @@
|
|||
*/
|
||||
|
||||
#include "src/runtime/kernel/opencl/kernel/fill.h"
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
#include "src/kernel_registry.h"
|
||||
#include "src/runtime/kernel/opencl/utils.h"
|
||||
|
||||
|
|
|
@ -21,9 +21,7 @@
|
|||
#include "src/kernel_registry.h"
|
||||
#include "src/runtime/kernel/opencl/kernel/fullconnection.h"
|
||||
#include "src/runtime/kernel/opencl/utils.h"
|
||||
#ifndef PROGRAM_WITH_IL
|
||||
#include "src/runtime/kernel/opencl/cl/fullconnection.cl.inc"
|
||||
#endif
|
||||
|
||||
using mindspore::kernel::KERNEL_ARCH::kGPU;
|
||||
using mindspore::lite::KernelRegistrar;
|
||||
|
@ -99,16 +97,19 @@ int FullConnectionOpenCLKernel::Prepare() {
|
|||
if (weight_var_) {
|
||||
kernel_name = "FullConnectionWeightVar";
|
||||
}
|
||||
#ifdef PROGRAM_WITH_IL
|
||||
kernel_ = ocl_runtime_->GetKernelFromBinary(kernel_name);
|
||||
#else
|
||||
std::string source = fullconnection_source;
|
||||
std::string program_name = "FullConnection";
|
||||
ocl_runtime_->LoadSource(program_name, GetActDefines() + source);
|
||||
if (!ocl_runtime_->LoadSource(program_name, GetActDefines() + source)) {
|
||||
MS_LOG(ERROR) << "Load source failed.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
auto build_options_ext = CreateBuildOptionsExtByDType(this->registry_data_type_);
|
||||
ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
#endif
|
||||
auto ret = InitWeights();
|
||||
auto ret = ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "Build kernel failed.";
|
||||
return ret;
|
||||
}
|
||||
ret = InitWeights();
|
||||
if (ret != RET_OK) {
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#define MINDSPORE_LITE_SRC_RUNTIME_KERNEL_OPENCL_KERNEL_FULLCONNECTION_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "src/runtime/kernel/opencl/opencl_kernel.h"
|
||||
#include "nnacl/matmul_parameter.h"
|
||||
|
||||
|
|
|
@ -166,14 +166,21 @@ int FusionEltwiseOpenCLKernel::Prepare() {
|
|||
std::string source = Codegen();
|
||||
std::string program_name = "FusionEltwise\n" + source;
|
||||
std::string kernel_name = "FusionEltwise";
|
||||
ocl_runtime_->LoadSource(program_name, source);
|
||||
if (!ocl_runtime_->LoadSource(program_name, source)) {
|
||||
MS_LOG(ERROR) << "Load source failed.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
std::vector<std::string> build_options_ext;
|
||||
if (ocl_runtime_->GetFp16Enable()) {
|
||||
build_options_ext = {" -DWRITE_IMAGE=write_imageh -DREAD_IMAGE=read_imageh "};
|
||||
} else {
|
||||
build_options_ext = {" -DWRITE_IMAGE=write_imagef -DREAD_IMAGE=read_imagef "};
|
||||
}
|
||||
ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
auto ret = ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "Build kernel failed.";
|
||||
return ret;
|
||||
}
|
||||
InitWeights();
|
||||
SetGlobalLocal();
|
||||
SetConstArgs();
|
||||
|
|
|
@ -108,17 +108,20 @@ int GatherOpenCLKernel::Prepare() {
|
|||
if (in_tensors_.at(0)->shape().size() == 1 && axis_ == 0) {
|
||||
axis_ = 3;
|
||||
}
|
||||
#ifdef PROGRAM_WITH_IL
|
||||
kernel_ = ocl_runtime_->GetKernelFromBinary(kernel_name);
|
||||
#else
|
||||
std::string program_name = "gather";
|
||||
ocl_runtime_->LoadSource(program_name, gather_source);
|
||||
if (!ocl_runtime_->LoadSource(program_name, gather_source)) {
|
||||
MS_LOG(ERROR) << "Load source failed.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
auto build_options_ext = CreateBuildOptionsExtByDType(this->registry_data_type_);
|
||||
ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
#endif
|
||||
auto ret = ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "Build kernel failed.";
|
||||
return ret;
|
||||
}
|
||||
if (in_tensors_.at(1)->IsConst()) {
|
||||
intensor1_is_tensor = false;
|
||||
int ret = InitWeights();
|
||||
ret = InitWeights();
|
||||
if (ret != RET_OK) {
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -20,9 +20,7 @@
|
|||
#include "schema/model_generated.h"
|
||||
#include "src/kernel_registry.h"
|
||||
#include "src/runtime/kernel/opencl/utils.h"
|
||||
#ifndef PROGRAM_WITH_IL
|
||||
#include "src/runtime/kernel/opencl/cl/int8/arithmetic.cl.inc"
|
||||
#endif
|
||||
|
||||
using mindspore::kernel::KERNEL_ARCH::kGPU;
|
||||
using mindspore::lite::KernelRegistrar;
|
||||
|
@ -148,10 +146,6 @@ void ArithmeticInt8OpenCLKernel::SetConstArgs() {
|
|||
}
|
||||
|
||||
int ArithmeticInt8OpenCLKernel::Prepare() {
|
||||
#ifdef PROGRAM_WITH_IL
|
||||
kernel_ = ocl_runtime_->GetKernelFromBinary(kernel_name_);
|
||||
#else
|
||||
|
||||
in0_shape_ = GpuTensorInfo(in_tensors_[0]);
|
||||
in1_shape_ = GpuTensorInfo(in_tensors_[1]);
|
||||
out_shape_ = GpuTensorInfo(out_tensors_[0]);
|
||||
|
@ -199,9 +193,11 @@ int ArithmeticInt8OpenCLKernel::Prepare() {
|
|||
|
||||
std::string program_name = "Arithmetic";
|
||||
std::string source = arithmetic_source;
|
||||
ocl_runtime_->LoadSource(program_name, source);
|
||||
if (!ocl_runtime_->LoadSource(program_name, source)) {
|
||||
MS_LOG(ERROR) << "Load source failed.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
int error_code = ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name_);
|
||||
#endif
|
||||
if (error_code != RET_OK) {
|
||||
return error_code;
|
||||
}
|
||||
|
|
|
@ -24,8 +24,6 @@
|
|||
#include "src/runtime/kernel/opencl/opencl_kernel.h"
|
||||
|
||||
namespace mindspore::kernel {
|
||||
extern std::set<schema::PrimitiveType> SupportedOpenCLArithmetics;
|
||||
|
||||
class ArithmeticInt8OpenCLKernel : public OpenCLKernel {
|
||||
public:
|
||||
using OpenCLKernel::OpenCLKernel;
|
||||
|
|
|
@ -169,9 +169,16 @@ int LayerNormOpenCLKernel::Prepare() {
|
|||
std::string kernel_name_mean_var = "ComputeMeanVar";
|
||||
std::string source = layer_norm_source;
|
||||
std::string program_name = "LayerNormalization";
|
||||
ocl_runtime_->LoadSource(program_name, source);
|
||||
if (!ocl_runtime_->LoadSource(program_name, source)) {
|
||||
MS_LOG(ERROR) << "Load source failed.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
auto build_options_ext = CreateBuildOptionsExtByDType(this->registry_data_type_);
|
||||
ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
ret = ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "Build kernel failed.";
|
||||
return ret;
|
||||
}
|
||||
kernel_name_mean_var += "Axis" + std::to_string(normalized_axis_) + "NHWC4";
|
||||
ocl_runtime_->BuildKernel(kernel_mean_var_, program_name, kernel_name_mean_var, build_options_ext);
|
||||
MS_LOG(DEBUG) << kernel_name << " Init Done!";
|
||||
|
|
|
@ -20,10 +20,7 @@
|
|||
#include "src/kernel_registry.h"
|
||||
#include "src/runtime/kernel/opencl/kernel/matmul.h"
|
||||
#include "src/runtime/kernel/opencl/kernel/strassen.h"
|
||||
|
||||
#ifndef PROGRAM_WITH_IL
|
||||
#include "src/runtime/kernel/opencl/cl/matmul.cl.inc"
|
||||
#endif
|
||||
|
||||
using mindspore::kernel::KERNEL_ARCH::kGPU;
|
||||
using mindspore::lite::KernelRegistrar;
|
||||
|
@ -86,16 +83,18 @@ int MatMulOpenCLKernel::Prepare() {
|
|||
}
|
||||
std::map<int, std::string> dims2str = {{2, "_2d"}, {3, "_4d"}, {4, "_4d"}};
|
||||
kernel_name += dims2str[dims];
|
||||
#ifdef PROGRAM_WITH_IL
|
||||
kernel_ = ocl_runtime_->GetKernelFromBinary(kernel_name);
|
||||
#else
|
||||
std::string source = matmul_source;
|
||||
std::string program_name = "MatMul";
|
||||
ocl_runtime_->LoadSource(program_name, source);
|
||||
if (!ocl_runtime_->LoadSource(program_name, source)) {
|
||||
MS_LOG(ERROR) << "Load source failed.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
auto build_options_ext = CreateBuildOptionsExtByDType(this->registry_data_type_);
|
||||
ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
|
||||
#endif
|
||||
auto ret = ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "Build kernel failed.";
|
||||
return ret;
|
||||
}
|
||||
SetConstArgs();
|
||||
SetGlobalLocal();
|
||||
MS_LOG(DEBUG) << kernel_name << " Init Done!";
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#define MINDSPORE_LITE_SRC_RUNTIME_KERNEL_OPENCL_KERNEL_MATMUL_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "src/runtime/kernel/opencl/opencl_kernel.h"
|
||||
#include "src/common/utils.h"
|
||||
#include "nnacl/matmul_parameter.h"
|
||||
|
|
|
@ -14,9 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include "include/errorcode.h"
|
||||
#include "src/kernel_registry.h"
|
||||
#include "src/runtime/kernel/opencl/kernel/one_hot.h"
|
||||
|
@ -49,26 +47,28 @@ int OneHotOpenCLKernel::Prepare() {
|
|||
} else {
|
||||
kernel_name += "Axis" + std::to_string(axis_);
|
||||
}
|
||||
#ifdef PROGRAM_WITH_IL
|
||||
kernel_ = ocl_runtime_->GetKernelFromBinary(kernel_name);
|
||||
#else
|
||||
|
||||
std::string source = one_hot_source;
|
||||
std::string program_name = "OneHot";
|
||||
ocl_runtime_->LoadSource(program_name, source);
|
||||
if (!ocl_runtime_->LoadSource(program_name, source)) {
|
||||
MS_LOG(ERROR) << "Load source failed.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
std::vector<std::string> build_options_ext;
|
||||
if (ocl_runtime_->GetFp16Enable()) {
|
||||
build_options_ext = {" -DWRITE_IMAGE=write_imageh -DREAD_IMAGE=write_imagei "};
|
||||
} else {
|
||||
build_options_ext = {" -DWRITE_IMAGE=write_imagef -DREAD_IMAGE=read_imagei "};
|
||||
}
|
||||
ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
#endif
|
||||
auto ret = ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "Build kernel failed.";
|
||||
return ret;
|
||||
}
|
||||
InitWeights();
|
||||
SetConstArgs();
|
||||
SetGlobalLocal();
|
||||
MS_LOG(DEBUG) << kernel_name << " Init Done!";
|
||||
return mindspore::lite::RET_OK;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int OneHotOpenCLKernel::InitWeights() {
|
||||
|
@ -111,7 +111,7 @@ int OneHotOpenCLKernel::Run() {
|
|||
ocl_runtime_->SetKernelArg(kernel_, 0, in_tensors_[0]->data_c());
|
||||
ocl_runtime_->SetKernelArg(kernel_, 1, out_tensors_[0]->data_c());
|
||||
ocl_runtime_->RunKernel(kernel_, global_range_, local_range_, nullptr, &event_);
|
||||
return mindspore::lite::RET_OK;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
REG_KERNEL(kGPU, kNumberTypeInt32, PrimitiveType_OneHot, OpenCLKernelCreator<OneHotOpenCLKernel>)
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
*/
|
||||
|
||||
#include <string>
|
||||
#include <set>
|
||||
#include <algorithm>
|
||||
#include "src/common/utils.h"
|
||||
#include "src/runtime/kernel/opencl/kernel/pad.h"
|
||||
|
@ -72,9 +71,16 @@ int PadOpenCLKernel::CheckSpecs() {
|
|||
int PadOpenCLKernel::Prepare() {
|
||||
const std::string source = pad_source;
|
||||
const std::string program_name = "Pad";
|
||||
ocl_runtime_->LoadSource(program_name, source);
|
||||
if (!ocl_runtime_->LoadSource(program_name, source)) {
|
||||
MS_LOG(ERROR) << "Load source failed.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
auto build_options_ext = CreateBuildOptionsExtByDType(this->registry_data_type_);
|
||||
ocl_runtime_->BuildKernel(kernel_, program_name, "Pad", build_options_ext);
|
||||
auto ret = ocl_runtime_->BuildKernel(kernel_, program_name, "Pad", build_options_ext);
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "Build kernel failed.";
|
||||
return ret;
|
||||
}
|
||||
SetConstArgs();
|
||||
return RET_OK;
|
||||
}
|
||||
|
|
|
@ -16,13 +16,10 @@
|
|||
|
||||
#include "src/runtime/kernel/opencl/kernel/pooling2d.h"
|
||||
#include <string>
|
||||
#include <set>
|
||||
#include "include/errorcode.h"
|
||||
#include "src/kernel_registry.h"
|
||||
#include "src/runtime/kernel/opencl/utils.h"
|
||||
#ifndef PROGRAM_WITH_IL
|
||||
#include "src/runtime/kernel/opencl/cl/pooling2d.cl.inc"
|
||||
#endif
|
||||
|
||||
using mindspore::kernel::KERNEL_ARCH::kGPU;
|
||||
using mindspore::lite::KernelRegistrar;
|
||||
|
@ -73,22 +70,25 @@ int PoolingOpenCLKernel::Prepare() {
|
|||
MS_LOG(ERROR) << "Unsupported activation type " << parameter_->act_type_;
|
||||
break;
|
||||
}
|
||||
#ifdef PROGRAM_WITH_IL
|
||||
kernel_ = ocl_runtime_->GetKernelFromBinary(kernel_name);
|
||||
#else
|
||||
kernel_name += "_NHWC4";
|
||||
kernel_name += "_IMG";
|
||||
std::string source = pooling2d_source;
|
||||
std::string program_name = "Pooling2d";
|
||||
ocl_runtime_->LoadSource(program_name, source);
|
||||
if (!ocl_runtime_->LoadSource(program_name, source)) {
|
||||
MS_LOG(ERROR) << "Load source failed.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
auto build_options_ext = CreateBuildOptionsExtByDType(this->registry_data_type_);
|
||||
ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
#endif
|
||||
auto ret = ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "Build kernel failed.";
|
||||
return ret;
|
||||
}
|
||||
SetConstArgs();
|
||||
SetGlobalLocal();
|
||||
MS_LOG(DEBUG) << kernel_name << " Init Done!";
|
||||
|
||||
return mindspore::lite::RET_OK;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
void PoolingOpenCLKernel::SetGlobalLocal() {
|
||||
|
@ -122,7 +122,7 @@ int PoolingOpenCLKernel::Run() {
|
|||
ocl_runtime_->SetKernelArg(kernel_, arg_idx++, in_tensors_[0]->data_c());
|
||||
ocl_runtime_->SetKernelArg(kernel_, arg_idx++, out_tensors_[0]->data_c());
|
||||
ocl_runtime_->RunKernel(kernel_, global_range_, local_range_, nullptr, &event_);
|
||||
return mindspore::lite::RET_OK;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
REG_KERNEL(kGPU, kNumberTypeFloat32, PrimitiveType_AvgPoolFusion, OpenCLKernelCreator<PoolingOpenCLKernel>)
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#define MINDSPORE_LITE_SRC_RUNTIME_KERNEL_OPENCL_KERNEL_POOLING_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "src/runtime/kernel/opencl/opencl_kernel.h"
|
||||
#include "nnacl/fp32/pooling_fp32.h"
|
||||
|
||||
|
|
|
@ -118,9 +118,16 @@ int PowerOpenCLKernel::Prepare() {
|
|||
}
|
||||
scale_ = param->scale_;
|
||||
shift_ = param->shift_;
|
||||
ocl_runtime_->LoadSource(program_name, source);
|
||||
if (!ocl_runtime_->LoadSource(program_name, source)) {
|
||||
MS_LOG(ERROR) << "Load source failed.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
auto build_options_ext = CreateBuildOptionsExtByDType(this->registry_data_type_);
|
||||
ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
auto ret = ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "Build kernel failed.";
|
||||
return ret;
|
||||
}
|
||||
MS_LOG(DEBUG) << kernel_name << " Init Done!";
|
||||
SetGlobalLocal();
|
||||
SetConstArgs();
|
||||
|
|
|
@ -128,15 +128,22 @@ int PReluOpenCLKernel::Prepare() {
|
|||
std::string source = prelu_source;
|
||||
std::string program_name = "PRelu";
|
||||
std::string kernel_name = "PRelu_" + std::string(weight_is_scalar ? "scalar" : "vector");
|
||||
ocl_runtime_->LoadSource(program_name, source);
|
||||
if (!ocl_runtime_->LoadSource(program_name, source)) {
|
||||
MS_LOG(ERROR) << "Load source failed.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
auto build_options_ext = CreateBuildOptionsExtByDType(this->registry_data_type_);
|
||||
ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
auto ret = ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "Build kernel failed.";
|
||||
return ret;
|
||||
}
|
||||
InitWeights();
|
||||
MS_LOG(DEBUG) << program_name << " init Done!";
|
||||
MS_LOG(DEBUG) << "kernel_name=: " << kernel_name << " init Done!";
|
||||
SetConstArgs();
|
||||
SetGlobalLocal();
|
||||
return mindspore::lite::RET_OK;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int PReluOpenCLKernel::Run() {
|
||||
|
@ -154,7 +161,7 @@ int PReluOpenCLKernel::Run() {
|
|||
MS_LOG(ERROR) << "Run kernel " << op_parameter_->name_ << " error.";
|
||||
return mindspore::lite::RET_ERROR;
|
||||
}
|
||||
return mindspore::lite::RET_OK;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
REG_KERNEL(kGPU, kNumberTypeFloat32, PrimitiveType_PReLUFusion, OpenCLKernelCreator<PReluOpenCLKernel>)
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
*/
|
||||
|
||||
#include <set>
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include "include/errorcode.h"
|
||||
|
@ -179,22 +178,22 @@ int ReduceOpenCLKernel::Prepare() {
|
|||
kernel_name += "C";
|
||||
}
|
||||
kernel_name += GetReduceTypeStr(reduce_param->mode_);
|
||||
#ifdef PROGRAM_WITH_IL
|
||||
kernel_ = ocl_runtime_->GetKernelFromBinary(kernel_name);
|
||||
#else
|
||||
std::string source = reduce_source;
|
||||
std::string program_name = "Reduce";
|
||||
ocl_runtime_->LoadSource(program_name, source);
|
||||
if (!ocl_runtime_->LoadSource(program_name, source)) {
|
||||
MS_LOG(ERROR) << "Load source failed.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
auto build_options_ext = CreateBuildOptionsExtByDType(this->registry_data_type_);
|
||||
auto ret = ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "Build kernel failed.";
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
SetConstArgs();
|
||||
SetGlobalLocal();
|
||||
MS_LOG(DEBUG) << kernel_name << " Init Done!";
|
||||
return mindspore::lite::RET_OK;
|
||||
return RET_OK;
|
||||
}
|
||||
void ReduceOpenCLKernel::SetConstArgs() {
|
||||
int h = inShape.H;
|
||||
|
@ -239,7 +238,7 @@ int ReduceOpenCLKernel::Run() {
|
|||
ocl_runtime_->SetKernelArg(kernel_, arg_idx++, in_tensors_[0]->data_c());
|
||||
ocl_runtime_->SetKernelArg(kernel_, arg_idx++, out_tensors_[0]->data_c());
|
||||
ocl_runtime_->RunKernel(kernel_, global_range_, local_range_, nullptr, &event_);
|
||||
return mindspore::lite::RET_OK;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
REG_KERNEL(kGPU, kNumberTypeFloat32, PrimitiveType_ReduceFusion, OpenCLKernelCreator<ReduceOpenCLKernel>)
|
||||
|
|
|
@ -73,15 +73,18 @@ void ReshapeOpenCLKernel::SetGlobalLocal() {
|
|||
|
||||
int ReshapeOpenCLKernel::Prepare() {
|
||||
std::string kernel_name = "reshape_NHWC4";
|
||||
#ifdef PROGRAM_WITH_IL
|
||||
kernel_ = ocl_runtime_->GetKernelFromBinary(kernel_name);
|
||||
#else
|
||||
std::string source = reshape_source;
|
||||
std::string program_name = "reshape";
|
||||
auto build_options_ext = CreateBuildOptionsExtByDType(this->registry_data_type_);
|
||||
ocl_runtime_->LoadSource(program_name, source);
|
||||
ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
#endif
|
||||
if (!ocl_runtime_->LoadSource(program_name, source)) {
|
||||
MS_LOG(ERROR) << "Load source failed.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
auto ret = ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "Build kernel failed.";
|
||||
return ret;
|
||||
}
|
||||
|
||||
SetGlobalLocal();
|
||||
SetConstArgs();
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#define MINDSPORE_LITE_SRC_RUNTIME_KERNEL_OPENCL_KERNEL_RESHAPE_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "src/inner_kernel.h"
|
||||
#include "src/runtime/kernel/opencl/opencl_kernel.h"
|
||||
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
*/
|
||||
|
||||
#include "src/runtime/kernel/opencl/kernel/resize.h"
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include "include/errorcode.h"
|
||||
#include "src/kernel_registry.h"
|
||||
|
@ -65,15 +63,18 @@ int ResizeOpenCLKernel::Prepare() {
|
|||
kernel_name += "_nearest_neighbor";
|
||||
}
|
||||
kernel_name += "_NHWC4";
|
||||
#ifdef PROGRAM_WITH_IL
|
||||
kernel_ = ocl_runtime_->GetKernelFromBinary(kernel_name);
|
||||
#else
|
||||
std::string source = resize_source;
|
||||
std::string program_name = "Resize";
|
||||
ocl_runtime_->LoadSource(program_name, source);
|
||||
if (!ocl_runtime_->LoadSource(program_name, source)) {
|
||||
MS_LOG(ERROR) << "Load source failed.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
auto build_options_ext = CreateBuildOptionsExtByDType(this->registry_data_type_);
|
||||
ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
#endif
|
||||
auto ret = ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "Build kernel failed.";
|
||||
return ret;
|
||||
}
|
||||
SetConstArgs();
|
||||
SetGlobalLocal();
|
||||
MS_LOG(DEBUG) << kernel_name << " Init Done!";
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#define MINDSPORE_LITE_SRC_RUNTIME_KERNEL_OPENCL_KERNEL_RESIZE_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "src/inner_kernel.h"
|
||||
#include "src/runtime/kernel/opencl/opencl_kernel.h"
|
||||
#include "nnacl/resize_parameter.h"
|
||||
|
|
|
@ -22,9 +22,7 @@
|
|||
#include "src/kernel_registry.h"
|
||||
#include "nnacl/fp32/common_func_fp32.h"
|
||||
#include "src/runtime/kernel/opencl/utils.h"
|
||||
#ifndef PROGRAM_WITH_IL
|
||||
#include "src/runtime/kernel/opencl/cl/scale.cl.inc"
|
||||
#endif
|
||||
|
||||
using mindspore::kernel::KERNEL_ARCH::kGPU;
|
||||
using mindspore::lite::KernelRegistrar;
|
||||
|
@ -172,10 +170,6 @@ int ScaleOpenCLKernel::Prepare() {
|
|||
weight_vector_flag_ = true;
|
||||
kernel_name = "Scale";
|
||||
}
|
||||
lite::STATUS error_code;
|
||||
#ifdef PROGRAM_WITH_IL
|
||||
kernel_ = ocl_runtime_->GetKernelFromBinary(kernel_name);
|
||||
#else
|
||||
if (out_mem_type_ == MemType::IMG) {
|
||||
kernel_name += "_IMG";
|
||||
} else {
|
||||
|
@ -183,14 +177,16 @@ int ScaleOpenCLKernel::Prepare() {
|
|||
}
|
||||
std::string program_name = "Scale";
|
||||
std::string source = GetActDefines() + scale_source;
|
||||
ocl_runtime_->LoadSource(program_name, source);
|
||||
auto build_options_ext = CreateBuildOptionsExtByDType(this->registry_data_type_);
|
||||
error_code = ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
#endif
|
||||
if (error_code != RET_OK) {
|
||||
return error_code;
|
||||
if (!ocl_runtime_->LoadSource(program_name, source)) {
|
||||
MS_LOG(ERROR) << "Load source failed.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
auto build_options_ext = CreateBuildOptionsExtByDType(this->registry_data_type_);
|
||||
auto ret = ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "Build kernel failed.";
|
||||
return ret;
|
||||
}
|
||||
|
||||
Image2dGetWorkGroupSize();
|
||||
InitWeights();
|
||||
MS_LOG(DEBUG) << kernel_name << " Init Done!";
|
||||
|
|
|
@ -16,14 +16,11 @@
|
|||
|
||||
#include "src/runtime/kernel/opencl/kernel/softmax.h"
|
||||
#include <string>
|
||||
#include <set>
|
||||
#include "include/errorcode.h"
|
||||
#include "src/kernel_registry.h"
|
||||
#include "src/runtime/kernel/opencl/utils.h"
|
||||
#include "nnacl/softmax_parameter.h"
|
||||
#ifndef PROGRAM_WITH_IL
|
||||
#include "src/runtime/kernel/opencl/cl/softmax.cl.inc"
|
||||
#endif
|
||||
|
||||
using mindspore::kernel::KERNEL_ARCH::kGPU;
|
||||
using mindspore::lite::KernelRegistrar;
|
||||
|
@ -78,11 +75,11 @@ int SoftmaxOpenCLKernel::Prepare() {
|
|||
kernel_name += "Axis" + std::to_string(axis_);
|
||||
}
|
||||
kernel_name += "_NHWC4";
|
||||
#ifdef PROGRAM_WITH_IL
|
||||
kernel_ = ocl_runtime->GetKernelFromBinary(kernel_name);
|
||||
#else
|
||||
std::string program_name = "Softmax";
|
||||
ocl_runtime_->LoadSource(program_name, source);
|
||||
if (!ocl_runtime_->LoadSource(program_name, source)) {
|
||||
MS_LOG(ERROR) << "Load source failed.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
std::vector<std::string> build_options_ext;
|
||||
if (this->registry_data_type_ == kNumberTypeFloat32) {
|
||||
build_options_ext = {
|
||||
|
@ -91,8 +88,11 @@ int SoftmaxOpenCLKernel::Prepare() {
|
|||
build_options_ext = {
|
||||
" -DOUT_FLT4=convert_half4 -DWRITE_IMAGEOUT=write_imageh -DWRITE_IMAGE=write_imageh -DREAD_IMAGE=read_imageh "};
|
||||
}
|
||||
ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
#endif
|
||||
auto ret = ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "Build kernel failed.";
|
||||
return ret;
|
||||
}
|
||||
SetConstArgs();
|
||||
SetGlobalLocal();
|
||||
MS_LOG(DEBUG) << kernel_name << " Init Done!";
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#define MINDSPORE_LITE_SRC_RUNTIME_KERNEL_OPENCL_KERNEL_SOFTMAX_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "src/runtime/kernel/opencl/opencl_kernel.h"
|
||||
#include "nnacl/fp32/softmax_fp32.h"
|
||||
|
||||
|
|
|
@ -15,9 +15,6 @@
|
|||
*/
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
#include <utility>
|
||||
#include "src/kernel_registry.h"
|
||||
#include "src/runtime/kernel/opencl/kernel/space_to_batch_nd.h"
|
||||
#include "src/runtime/kernel/opencl/cl/space_to_batch_nd.cl.inc"
|
||||
|
@ -91,18 +88,18 @@ void SpaceToBatchNDOpenCLKernel::SetGlobalLocal() {
|
|||
|
||||
int SpaceToBatchNDOpenCLKernel::Prepare() {
|
||||
std::string kernel_name = "space_to_batch_nd_NHWC4";
|
||||
|
||||
#ifdef PROGRAM_WITH_IL
|
||||
kernel_ = ocl_runtime_->GetKernelFromBinary(kernel_name);
|
||||
#else
|
||||
|
||||
std::string source = space_to_batch_nd_source;
|
||||
std::string program_name = "space_to_batch_nd";
|
||||
ocl_runtime_->LoadSource(program_name, source);
|
||||
if (!ocl_runtime_->LoadSource(program_name, source)) {
|
||||
MS_LOG(ERROR) << "Load source failed.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
auto build_options_ext = CreateBuildOptionsExtByDType(this->registry_data_type_);
|
||||
ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
#endif
|
||||
|
||||
auto ret = ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "Build kernel failed.";
|
||||
return ret;
|
||||
}
|
||||
SetGlobalLocal();
|
||||
SetConstArgs();
|
||||
MS_LOG(DEBUG) << kernel_name << " Init Done!";
|
||||
|
|
|
@ -14,9 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include "include/errorcode.h"
|
||||
#include "src/kernel_registry.h"
|
||||
#include "src/runtime/kernel/opencl/kernel/space_to_depth.h"
|
||||
|
@ -52,20 +50,23 @@ int SpaceToDepthOpenCLKernel::Prepare() {
|
|||
if (in_shape_.C % C4NUM == 0 && out_shape_.C % C4NUM == 0) {
|
||||
kernel_name += "Align";
|
||||
}
|
||||
#ifdef PROGRAM_WITH_IL
|
||||
kernel_ = ocl_runtime_->GetKernelFromBinary(kernel_name);
|
||||
#else
|
||||
std::string source = space_to_depth_source;
|
||||
std::string program_name = "SpaceToDepth";
|
||||
ocl_runtime_->LoadSource(program_name, source);
|
||||
if (!ocl_runtime_->LoadSource(program_name, source)) {
|
||||
MS_LOG(ERROR) << "Load source failed.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
auto build_options_ext = CreateBuildOptionsExtByDType(this->registry_data_type_);
|
||||
|
||||
ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
#endif
|
||||
auto ret = ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "Build kernel failed.";
|
||||
return ret;
|
||||
}
|
||||
SetConstArgs();
|
||||
SetGlobalLocal();
|
||||
MS_LOG(DEBUG) << kernel_name << " Init Done!";
|
||||
return mindspore::lite::RET_OK;
|
||||
return RET_OK;
|
||||
}
|
||||
void SpaceToDepthOpenCLKernel::SetConstArgs() {
|
||||
cl_int4 cl_in_shape = {static_cast<cl_int>(in_shape_.N), static_cast<cl_int>(in_shape_.H),
|
||||
|
@ -97,7 +98,7 @@ int SpaceToDepthOpenCLKernel::Run() {
|
|||
ocl_runtime_->SetKernelArg(kernel_, arg_idx++, in_tensors_[0]->data_c());
|
||||
ocl_runtime_->SetKernelArg(kernel_, arg_idx++, out_tensors_[0]->data_c());
|
||||
ocl_runtime_->RunKernel(kernel_, global_range_, local_range_, nullptr, &event_);
|
||||
return mindspore::lite::RET_OK;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
REG_KERNEL(kGPU, kNumberTypeFloat32, PrimitiveType_SpaceToDepth, OpenCLKernelCreator<SpaceToDepthOpenCLKernel>)
|
||||
|
|
|
@ -147,14 +147,21 @@ int SparseToDenseOpenCLKernel::Prepare() {
|
|||
std::string kernel_name = "SparseToDense" + std::string(weight_scalar_ ? "Scalar" : "Vector");
|
||||
std::string source = sparse_to_dense_source;
|
||||
std::string program_name = "SparseToDense";
|
||||
ocl_runtime_->LoadSource(program_name, source);
|
||||
if (!ocl_runtime_->LoadSource(program_name, source)) {
|
||||
MS_LOG(ERROR) << "Load source failed.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
std::vector<std::string> build_options_ext;
|
||||
if (enable_fp16_) {
|
||||
build_options_ext = {" -DDTYPE=half "};
|
||||
} else {
|
||||
build_options_ext = {" -DDTYPE=float "};
|
||||
}
|
||||
ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
auto ret = ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "Build kernel failed.";
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (in_tensors_.size() > INPUT_TENSOR_SIZE_3) {
|
||||
auto input_tensor3 = in_tensors_[3];
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#include <cstring>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
#include "src/kernel_registry.h"
|
||||
#include "src/runtime/kernel/opencl/cl/split.cl.inc"
|
||||
|
||||
|
@ -140,10 +139,17 @@ int SplitOpenCLKernel::Prepare() {
|
|||
MS_LOG(DEBUG) << "kernel_name=: " << kernel_name;
|
||||
std::string source = split_source;
|
||||
std::string program_name = "split";
|
||||
ocl_runtime_->LoadSource(program_name, source);
|
||||
if (!ocl_runtime_->LoadSource(program_name, source)) {
|
||||
MS_LOG(ERROR) << "Load source failed.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
auto build_options_ext = CreateBuildOptionsExtByDType(this->registry_data_type_);
|
||||
|
||||
ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
auto ret = ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "Build kernel failed.";
|
||||
return ret;
|
||||
}
|
||||
MS_LOG(DEBUG) << kernel_name << " Init Done!";
|
||||
SetConstArgs();
|
||||
SetGlobalLocal();
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#include <cstring>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
#include "src/kernel_registry.h"
|
||||
#include "src/runtime/kernel/opencl/utils.h"
|
||||
#include "src/runtime/kernel/opencl/cl/stack.cl.inc"
|
||||
|
@ -164,10 +163,17 @@ int StackOpenCLKernel::Prepare() {
|
|||
MS_LOG(DEBUG) << "kernel_name=: " << kernel_name;
|
||||
std::string source = stack_source;
|
||||
std::string program_name = "stack";
|
||||
ocl_runtime_->LoadSource(program_name, source);
|
||||
if (!ocl_runtime_->LoadSource(program_name, source)) {
|
||||
MS_LOG(ERROR) << "Load source failed.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
auto build_options_ext = CreateBuildOptionsExtByDType(this->registry_data_type_);
|
||||
|
||||
ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
auto ret = ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "Build kernel failed.";
|
||||
return ret;
|
||||
}
|
||||
SetConstArgs();
|
||||
SetGlobalLocal();
|
||||
|
||||
|
|
|
@ -30,16 +30,23 @@ int StrassenOpenCLKernel::Prepare() {
|
|||
std::string kernel_name = "MatMul_Strassen_NHWC4_2d";
|
||||
std::string source = strassen_source;
|
||||
std::string program_name = "MatMul";
|
||||
ocl_runtime_->LoadSource(program_name, source);
|
||||
if (!ocl_runtime_->LoadSource(program_name, source)) {
|
||||
MS_LOG(ERROR) << "Load source failed.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
auto build_options_ext = CreateBuildOptionsExtByDType(this->registry_data_type_);
|
||||
|
||||
ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
auto ret = ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "Build kernel failed.";
|
||||
return ret;
|
||||
}
|
||||
ocl_runtime_->BuildKernel(kernel_IMG_add_sub_2, program_name, "MatMul_IMG_Add_Sub_2", build_options_ext);
|
||||
ocl_runtime_->BuildKernel(kernel_BUF_add_sub_2, program_name, "MatMul_BUF_Add_Sub_2", build_options_ext);
|
||||
ocl_runtime_->BuildKernel(kernel_back_result, program_name, "Strassen_Back_Result", build_options_ext);
|
||||
ocl_runtime_->BuildKernel(MatMul_StrassenBUFFilled, program_name, "MatMul_BUF_Filled", build_options_ext);
|
||||
ocl_runtime_->BuildKernel(MatMul_StrassenIMGFilled, program_name, "MatMul_IMG_Filled", build_options_ext);
|
||||
auto ret = InitWeights();
|
||||
ret = InitWeights();
|
||||
if (ret != RET_OK) {
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#include <deque>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
#include "src/kernel_registry.h"
|
||||
#include "src/runtime/kernel/opencl/kernel/strided_slice.h"
|
||||
#include "src/runtime/kernel/opencl/utils.h"
|
||||
|
@ -87,10 +86,16 @@ int StridedSliceOpenCLKernel::CheckSpecs() {
|
|||
|
||||
int StridedSliceOpenCLKernel::Prepare() {
|
||||
std::string program_name = "strided_slice";
|
||||
ocl_runtime_->LoadSource(program_name, strided_slice_source);
|
||||
if (!ocl_runtime_->LoadSource(program_name, strided_slice_source)) {
|
||||
MS_LOG(ERROR) << "Load source failed.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
auto build_options_ext = CreateBuildOptionsExtByDType(this->registry_data_type_);
|
||||
|
||||
ocl_runtime_->BuildKernel(kernel_, program_name, "strided_slice", build_options_ext);
|
||||
auto ret = ocl_runtime_->BuildKernel(kernel_, program_name, "strided_slice", build_options_ext);
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "Build kernel failed.";
|
||||
return ret;
|
||||
}
|
||||
SetConstArgs();
|
||||
SetGlobalLocal();
|
||||
return RET_OK;
|
||||
|
|
|
@ -15,10 +15,8 @@
|
|||
*/
|
||||
|
||||
#include "src/runtime/kernel/opencl/kernel/to_format.h"
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include "include/errorcode.h"
|
||||
#include "src/kernel_registry.h"
|
||||
#include "src/runtime/kernel/opencl/cl/to_format.cl.inc"
|
||||
|
@ -74,8 +72,15 @@ int ToFormatOpenCLKernel::Prepare() {
|
|||
|
||||
std::string program_name = "to_format";
|
||||
std::string source = to_format_source;
|
||||
ocl_runtime_->LoadSource(program_name, source);
|
||||
ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name);
|
||||
if (!ocl_runtime_->LoadSource(program_name, source)) {
|
||||
MS_LOG(ERROR) << "Load source failed.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
auto ret = ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name);
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "Build kernel failed.";
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto output = GpuTensorInfo(out_tensor);
|
||||
N_ = output.N;
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#define MINDSPORE_LITE_SRC_RUNTIME_KERNEL_OPENCL_KERNEL_TO_FORMAT_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "src/inner_kernel.h"
|
||||
#include "src/runtime/kernel/opencl/opencl_kernel.h"
|
||||
|
||||
|
|
|
@ -14,14 +14,11 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include "include/errorcode.h"
|
||||
#include "src/kernel_registry.h"
|
||||
#include "src/runtime/kernel/opencl/kernel/transpose.h"
|
||||
#ifndef PROGRAM_WITH_IL
|
||||
#include "src/runtime/kernel/opencl/cl/transpose.cl.inc"
|
||||
#endif
|
||||
#include "src/runtime/kernel/opencl/utils.h"
|
||||
|
||||
using mindspore::kernel::KERNEL_ARCH::kGPU;
|
||||
|
@ -103,20 +100,23 @@ int TransposeOpenCLKernel::Prepare() {
|
|||
}
|
||||
kernel_name += "_NHWC4";
|
||||
|
||||
#ifdef PROGRAM_WITH_IL
|
||||
kernel_ = ocl_runtime_->GetKernelFromBinary(kernel_name);
|
||||
#else
|
||||
std::string source = transpose_source;
|
||||
std::string program_name = "transpose";
|
||||
ocl_runtime_->LoadSource(program_name, source);
|
||||
if (!ocl_runtime_->LoadSource(program_name, source)) {
|
||||
MS_LOG(ERROR) << "Load source failed.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
auto build_options_ext = CreateBuildOptionsExtByDType(this->registry_data_type_);
|
||||
|
||||
ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
#endif
|
||||
auto ret = ocl_runtime_->BuildKernel(kernel_, program_name, kernel_name, build_options_ext);
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "Build kernel failed.";
|
||||
return ret;
|
||||
}
|
||||
SetConstArgs();
|
||||
SetGlobalLocal();
|
||||
MS_LOG(DEBUG) << kernel_name << " Init Done!";
|
||||
return mindspore::lite::RET_OK;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
void TransposeOpenCLKernel::SetConstArgs() {
|
||||
|
@ -164,7 +164,7 @@ int TransposeOpenCLKernel::Run() {
|
|||
ocl_runtime_->SetKernelArg(kernel_, arg_idx++, in_tensors_[0]->data_c());
|
||||
ocl_runtime_->SetKernelArg(kernel_, arg_idx++, out_tensors_[0]->data_c());
|
||||
ocl_runtime_->RunKernel(kernel_, global_range_, local_range_, nullptr, &event_);
|
||||
return mindspore::lite::RET_OK;
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
REG_KERNEL(kGPU, kNumberTypeFloat32, PrimitiveType_Transpose, OpenCLKernelCreator<TransposeOpenCLKernel>)
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#define MINDSPORE_LITE_SRC_RUNTIME_KERNEL_OPENCL_KERNEL_TRANSPOSE_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "src/inner_kernel.h"
|
||||
#include "nnacl/transpose.h"
|
||||
#include "src/runtime/kernel/opencl/opencl_kernel.h"
|
||||
|
|
|
@ -77,15 +77,30 @@ std::vector<float> GenerateWinogradFilter(void *src, TypeId dtype, size_t CO, si
|
|||
#endif
|
||||
} // namespace
|
||||
|
||||
void WinogradOpenCLKernel::BuildKernel() {
|
||||
int WinogradOpenCLKernel::BuildKernel() {
|
||||
std::string program_name = "winograd";
|
||||
ocl_runtime_->LoadSource(program_name, GetActDefines() + winograd_source);
|
||||
if (!ocl_runtime_->LoadSource(program_name, GetActDefines() + winograd_source)) {
|
||||
MS_LOG(ERROR) << "Load source failed.";
|
||||
return RET_ERROR;
|
||||
}
|
||||
auto build_options_ext = CreateBuildOptionsExtByDType(this->registry_data_type_);
|
||||
|
||||
ocl_runtime_->BuildKernel(kernel_4x4to36_, program_name, "Winograd4x4To36", build_options_ext);
|
||||
ocl_runtime_->BuildKernel(kernel_, program_name,
|
||||
filter_type_ == MemType::IMG ? "WinogradConv2D_Img" : "WinogradConv2D", build_options_ext);
|
||||
ocl_runtime_->BuildKernel(kernel_36to4x4_, program_name, "Winograd36To4x4", build_options_ext);
|
||||
auto ret = ocl_runtime_->BuildKernel(kernel_4x4to36_, program_name, "Winograd4x4To36", build_options_ext);
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "Build kernel failed.";
|
||||
return ret;
|
||||
}
|
||||
ret = ocl_runtime_->BuildKernel(
|
||||
kernel_, program_name, filter_type_ == MemType::IMG ? "WinogradConv2D_Img" : "WinogradConv2D", build_options_ext);
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "Build kernel failed.";
|
||||
return ret;
|
||||
}
|
||||
ret = ocl_runtime_->BuildKernel(kernel_36to4x4_, program_name, "Winograd36To4x4", build_options_ext);
|
||||
if (ret != RET_OK) {
|
||||
MS_LOG(ERROR) << "Build kernel failed.";
|
||||
return ret;
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
void WinogradOpenCLKernel::InitFilter() {
|
||||
|
|
|
@ -41,7 +41,7 @@ class WinogradOpenCLKernel : public Conv2DOpenCLKernel {
|
|||
double GetProfilingTimeMs() override;
|
||||
|
||||
private:
|
||||
void BuildKernel() override;
|
||||
int BuildKernel() override;
|
||||
void InitFilter() override;
|
||||
void AllocateMemory();
|
||||
|
||||
|
|
Loading…
Reference in New Issue