forked from mindspore-Ecosystem/mindspore
set out format to nhwc4
This commit is contained in:
parent
fcdad59ce6
commit
b39d524d44
|
@ -82,10 +82,13 @@ int ArithmeticOpenCLKernel::Init() {
|
|||
ocl_runtime->LoadSource(program_name, source);
|
||||
ocl_runtime->BuildKernel(kernel_, program_name, kernel_name, build_options);
|
||||
#endif
|
||||
outputs_[0]->SetFormat(schema::Format_NHWC4);
|
||||
MS_LOG(DEBUG) << kernel_name << " Init Done!";
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ArithmeticOpenCLKernel::Run() {
|
||||
MS_LOG(DEBUG) << this->Name() << " Running!";
|
||||
uint32_t element_num = outputs_[0]->ElementsC4Num();
|
||||
auto ocl_runtime = lite::opencl::OpenCLRuntime::GetInstance();
|
||||
std::vector<size_t> global = {element_num};
|
||||
|
|
|
@ -35,7 +35,7 @@ int ConcatOpenCLKernel::Init() {
|
|||
}
|
||||
|
||||
auto param = reinterpret_cast<ConcatParameter *>(this->opParameter);
|
||||
MS_LOG(INFO) << "concat at axis=: " << param->axis_;
|
||||
MS_LOG(DEBUG) << "concat at axis=: " << param->axis_;
|
||||
if (param->axis_ != 0 && param->axis_ != 3) {
|
||||
MS_LOG(ERROR) << "only support axis=0 or axis=3";
|
||||
}
|
||||
|
@ -55,6 +55,8 @@ int ConcatOpenCLKernel::Init() {
|
|||
ocl_runtime->LoadSource(program_name, source);
|
||||
ocl_runtime->BuildKernel(kernel_, program_name, kernel_name, build_options);
|
||||
#endif
|
||||
outputs_[0]->SetFormat(schema::Format_NHWC4);
|
||||
MS_LOG(DEBUG) << kernel_name << " Init Done!";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -88,6 +90,7 @@ int ConcatOpenCLKernel::Run_axis0() {
|
|||
}
|
||||
|
||||
int ConcatOpenCLKernel::Run() {
|
||||
MS_LOG(DEBUG) << this->Name() << " Running!";
|
||||
auto param = reinterpret_cast<ConcatParameter *>(this->opParameter);
|
||||
if (param->axis_ == 0) {
|
||||
return Run_axis0();
|
||||
|
|
|
@ -69,6 +69,8 @@ int Conv2dTransposeOpenCLKernel::Init() {
|
|||
PadWeight();
|
||||
allocator->UnmapBuffer(padWeight_);
|
||||
allocator->UnmapBuffer(bias_);
|
||||
outputs_[0]->SetFormat(schema::Format_NHWC4);
|
||||
MS_LOG(DEBUG) << kernel_name << " Init Done!";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -120,6 +122,7 @@ void Conv2dTransposeOpenCLKernel::PadWeight() {
|
|||
}
|
||||
|
||||
int Conv2dTransposeOpenCLKernel::Run() {
|
||||
MS_LOG(DEBUG) << this->Name() << " Running!";
|
||||
std::vector<int> shapex = inputs_[0]->shape();
|
||||
int n = shapex[0];
|
||||
if (n > 1) {
|
||||
|
|
|
@ -38,12 +38,8 @@ int ConvolutionOpenCLKernel::Init() {
|
|||
MS_LOG(ERROR) << "ConvolutionOpenCLKernel only support Batch=1!";
|
||||
}
|
||||
|
||||
auto io_NHWC = inputs_[0]->GetFormat() == schema::Format_NHWC && outputs_[0]->GetFormat() == schema::Format_NHWC;
|
||||
auto io_NHWC4 = inputs_[0]->GetFormat() == schema::Format_NHWC4 && outputs_[0]->GetFormat() == schema::Format_NHWC4;
|
||||
if (!io_NHWC && !io_NHWC4) {
|
||||
MS_LOG(ERROR) << "input and output data_format is invalid!";
|
||||
}
|
||||
io_dataformat_ = inputs_[0]->GetFormat();
|
||||
outputs_[0]->SetFormat(schema::Format_NHWC4);
|
||||
io_dataformat_ = outputs_[0]->GetFormat();
|
||||
|
||||
if (inputs_[1]->GetFormat() != schema::Format_KHWC) {
|
||||
MS_LOG(ERROR) << "weight data_format is invalid!";
|
||||
|
@ -62,6 +58,7 @@ int ConvolutionOpenCLKernel::Init() {
|
|||
#endif
|
||||
|
||||
this->InitBuffer();
|
||||
MS_LOG(DEBUG) << kernel_name << " Init Done!";
|
||||
return 0;
|
||||
}
|
||||
int ConvolutionOpenCLKernel::InitBuffer() {
|
||||
|
@ -123,7 +120,7 @@ int ConvolutionOpenCLKernel::InitBuffer() {
|
|||
int ConvolutionOpenCLKernel::ReSize() { return 0; }
|
||||
|
||||
int ConvolutionOpenCLKernel::Run() {
|
||||
MS_LOG(INFO) << "ConvolutionOpenCLKernel::Run()";
|
||||
MS_LOG(DEBUG) << this->Name() << " Running!";
|
||||
auto ocl_runtime = lite::opencl::OpenCLRuntime::GetInstance();
|
||||
|
||||
auto param = reinterpret_cast<ConvParameter *>(opParameter);
|
||||
|
|
|
@ -58,6 +58,7 @@ int DepthwiseConv2dOpenCLKernel::Init() {
|
|||
ocl_runtime->BuildKernel(kernel_, program_name, kernel_name, build_options);
|
||||
#endif
|
||||
this->InitBuffer();
|
||||
MS_LOG(DEBUG) << kernel_name << " Init Done!";
|
||||
return 0;
|
||||
}
|
||||
int DepthwiseConv2dOpenCLKernel::InitBuffer() {
|
||||
|
@ -100,6 +101,7 @@ int DepthwiseConv2dOpenCLKernel::ReSize() {
|
|||
}
|
||||
|
||||
int DepthwiseConv2dOpenCLKernel::Run() {
|
||||
MS_LOG(DEBUG) << this->Name() << " Running!";
|
||||
auto parameter = reinterpret_cast<ConvParameter*>(opParameter);
|
||||
auto ocl_runtime = lite::opencl::OpenCLRuntime::GetInstance();
|
||||
size_t CO4 = UP_DIV(outputs_[0]->Channel(), C4NUM);
|
||||
|
|
|
@ -66,6 +66,8 @@ int MatMulOpenCLKernel::Init() {
|
|||
if (hasBias_) {
|
||||
allocator->UnmapBuffer(bias_);
|
||||
}
|
||||
outputs_[0]->SetFormat(schema::Format_NHWC4);
|
||||
MS_LOG(DEBUG) << kernel_name << " Init Done!";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -100,6 +102,7 @@ void MatMulOpenCLKernel::PadWeight() {
|
|||
}
|
||||
|
||||
int MatMulOpenCLKernel::Run() {
|
||||
MS_LOG(DEBUG) << this->Name() << " Running!";
|
||||
std::vector<int> shapex = inputs_[0]->shape();
|
||||
int n = shapex[0];
|
||||
if (n > 1) {
|
||||
|
|
|
@ -59,8 +59,6 @@ int PoolingOpenCLKernel::Init() {
|
|||
MS_LOG(ERROR) << "Init `Pooling2d` kernel failed!";
|
||||
return RET_INVALID_OP_NAME;
|
||||
}
|
||||
auto in_format = inputs_[0]->GetFormat();
|
||||
outputs_[0]->SetFormat(in_format);
|
||||
auto ocl_runtime = lite::opencl::OpenCLRuntime::GetInstance();
|
||||
|
||||
#ifdef PROGRAM_WITH_IL
|
||||
|
@ -70,6 +68,8 @@ int PoolingOpenCLKernel::Init() {
|
|||
ocl_runtime->LoadSource(program_name, source);
|
||||
ocl_runtime->BuildKernel(kernel_, program_name, kernel_name, build_options);
|
||||
#endif
|
||||
outputs_[0]->SetFormat(schema::Format_NHWC4);
|
||||
MS_LOG(DEBUG) << kernel_name << " Init Done!";
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
|
@ -85,6 +85,7 @@ int PoolingOpenCLKernel::InitBuffer() { return 0; }
|
|||
int PoolingOpenCLKernel::ReSize() { return 0; }
|
||||
|
||||
int PoolingOpenCLKernel::Run() {
|
||||
MS_LOG(DEBUG) << this->Name() << " Running!";
|
||||
auto ocl_runtime = lite::opencl::OpenCLRuntime::GetInstance();
|
||||
|
||||
// attribute
|
||||
|
|
|
@ -46,6 +46,8 @@ int SoftmaxOpenCLKernel::Init() {
|
|||
ocl_runtime->LoadSource(program_name, source);
|
||||
ocl_runtime->BuildKernel(kernel_, program_name, kernel_name, build_options);
|
||||
#endif
|
||||
outputs_[0]->SetFormat(schema::Format_NHWC4);
|
||||
MS_LOG(DEBUG) << kernel_name << " Init Done!";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -53,6 +55,7 @@ int SoftmaxOpenCLKernel::InitBuffer() { return 0; }
|
|||
int SoftmaxOpenCLKernel::ReSize() { return 0; }
|
||||
|
||||
int SoftmaxOpenCLKernel::Run() {
|
||||
MS_LOG(DEBUG) << this->Name() << " Running!";
|
||||
auto ocl_runtime = lite::opencl::OpenCLRuntime::GetInstance();
|
||||
auto allocator = ocl_runtime->GetAllocator();
|
||||
|
||||
|
|
Loading…
Reference in New Issue