From 2b2344348240e4937fc86fd55bf982e962cf0593 Mon Sep 17 00:00:00 2001 From: yefeng Date: Thu, 22 Oct 2020 14:00:48 +0800 Subject: [PATCH] remove_int8_base --- .../kernel/arm/base/arg_min_max_base.cc | 28 +------- .../kernel/arm/base/batch_to_space_base.cc | 28 -------- .../runtime/kernel/arm/base/concat_base.cc | 26 -------- .../src/runtime/kernel/arm/base/crop_base.cc | 26 -------- .../kernel/arm/base/depth_to_space_base.cc | 28 -------- .../kernel/arm/base/fullconnection_base.cc | 23 ------- .../kernel/arm/base/leaky_relu_base.cc | 27 -------- .../runtime/kernel/arm/base/matmul_base.cc | 37 +---------- .../lite/src/runtime/kernel/arm/base/pad.cc | 24 ------- .../runtime/kernel/arm/base/pooling_base.cc | 27 -------- .../src/runtime/kernel/arm/base/power_base.cc | 27 -------- .../runtime/kernel/arm/base/reduce_base.cc | 35 +--------- .../runtime/kernel/arm/base/reshape_base.cc | 27 -------- .../runtime/kernel/arm/base/resize_base.cc | 28 -------- .../runtime/kernel/arm/base/softmax_base.cc | 27 -------- .../src/runtime/kernel/arm/base/split_base.cc | 27 -------- .../runtime/kernel/arm/base/squeeze_base.cc | 27 -------- .../runtime/kernel/arm/int8/argminmax_int8.cc | 34 ++++++++++ .../kernel/arm/int8/batch_to_space_int8.cc | 33 ++++++++++ .../runtime/kernel/arm/int8/concat_int8.cc | 31 +++++++++ .../src/runtime/kernel/arm/int8/crop_int8.cc | 29 +++++++++ .../kernel/arm/int8/depth_to_space_int8.cc | 33 ++++++++++ .../kernel/arm/int8/fullconnection_int8.cc | 28 ++++++++ .../kernel/arm/int8/leaky_relu_int8.cc | 28 ++++++++ .../runtime/kernel/arm/int8/matmul_int8.cc | 64 +++++++++++++++++++ .../src/runtime/kernel/arm/int8/pad_int8.cc | 26 ++++++++ .../runtime/kernel/arm/int8/pooling_int8.cc | 31 +++++++++ .../src/runtime/kernel/arm/int8/power_int8.cc | 30 +++++++++ .../runtime/kernel/arm/int8/reduce_int8.cc | 37 +++++++++++ .../runtime/kernel/arm/int8/reshape_int8.cc | 30 +++++++++ .../runtime/kernel/arm/int8/resize_int8.cc | 29 +++++++++ .../runtime/kernel/arm/int8/softmax_int8.cc | 31 +++++++++ .../src/runtime/kernel/arm/int8/split_int8.cc | 30 +++++++++ .../runtime/kernel/arm/int8/squeeze_int8.cc | 29 +++++++++ 34 files changed, 556 insertions(+), 469 deletions(-) diff --git a/mindspore/lite/src/runtime/kernel/arm/base/arg_min_max_base.cc b/mindspore/lite/src/runtime/kernel/arm/base/arg_min_max_base.cc index 7ecfe950a7..3289c0642c 100644 --- a/mindspore/lite/src/runtime/kernel/arm/base/arg_min_max_base.cc +++ b/mindspore/lite/src/runtime/kernel/arm/base/arg_min_max_base.cc @@ -16,7 +16,6 @@ #include "src/runtime/kernel/arm/base/arg_min_max_base.h" #include "nnacl/arg_min_max.h" #include "src/runtime/kernel/arm/fp32/argminmax.h" -#include "src/runtime/kernel/arm/int8/argminmax_int8.h" #include "nnacl/arithmetic_common.h" #include "schema/model_generated.h" #include "src/kernel_registry.h" @@ -89,30 +88,6 @@ int ArgMinMaxBaseCPUKernel::Run() { return RET_OK; } -kernel::LiteKernel *CpuArgMinMaxInt8KernelCreator(const std::vector &inputs, - const std::vector &outputs, OpParameter *op_parameter, - const lite::InnerContext *ctx, const kernel::KernelKey &desc, - const mindspore::lite::PrimitiveC *primitive) { - if (op_parameter == nullptr) { - MS_LOG(ERROR) << "Input op_parameter is nullptr!"; - return nullptr; - } - auto kernel = new (std::nothrow) ArgMinMaxInt8CPUKernel(op_parameter, inputs, outputs, ctx, primitive); - if (kernel == nullptr) { - MS_LOG(ERROR) << "new ArgMinMaxInt8CPUKernel fail!"; - return nullptr; - } - - auto ret = kernel->Init(); - if (ret != RET_OK) { - delete kernel; - MS_LOG(ERROR) << "Init kernel failed, name: " << op_parameter->name_ << ", type: " - << schema::EnumNamePrimitiveType(static_cast(op_parameter->type_)); - return nullptr; - } - return kernel; -} - kernel::LiteKernel *CpuArgMinMaxFp32KernelCreator(const std::vector &inputs, const std::vector &outputs, OpParameter *op_parameter, const lite::InnerContext *ctx, const kernel::KernelKey &desc, @@ -139,6 +114,5 @@ kernel::LiteKernel *CpuArgMinMaxFp32KernelCreator(const std::vector &inputs, - const std::vector &outputs, - OpParameter *op_parameter, const lite::InnerContext *ctx, - const kernel::KernelKey &desc, - const mindspore::lite::PrimitiveC *primitive) { - if (op_parameter == nullptr) { - MS_LOG(ERROR) << "Input op_parameter is nullptr!"; - return nullptr; - } - auto *kernel = new (std::nothrow) BatchToSpaceInt8CPUKernel(op_parameter, inputs, outputs, ctx, primitive); - if (kernel == nullptr) { - MS_LOG(ERROR) << "new BatchToSpaceInt8CPUKernel fail!"; - return nullptr; - } - - auto ret = kernel->Init(); - if (ret != RET_OK) { - delete kernel; - MS_LOG(ERROR) << "Init kernel failed, name: " << op_parameter->name_ << ", type: " - << schema::EnumNamePrimitiveType(static_cast(op_parameter->type_)); - return nullptr; - } - return kernel; -} - kernel::LiteKernel *CpuBatchToSpaceFp32KernelCreator(const std::vector &inputs, const std::vector &outputs, OpParameter *op_parameter, const lite::InnerContext *ctx, @@ -104,8 +78,6 @@ kernel::LiteKernel *CpuBatchToSpaceFp32KernelCreator(const std::vector -#include "src/runtime/kernel/arm/int8/concat_int8.h" #include "src/runtime/kernel/arm/fp32/concat.h" #include "nnacl/fp32/concat.h" #include "schema/model_generated.h" @@ -36,30 +35,6 @@ int ConcatBaseCPUKernel::ReSize() { return RET_OK; } -kernel::LiteKernel *CpuConcatInt8KernelCreator(const std::vector &inputs, - const std::vector &outputs, OpParameter *opParameter, - const InnerContext *ctx, const kernel::KernelKey &desc, - const mindspore::lite::PrimitiveC *primitive) { - if (opParameter == nullptr) { - MS_LOG(ERROR) << "Input opParameter is nullptr!"; - return nullptr; - } - MS_ASSERT(desc.type == schema::PrimitiveType_Concat); - auto *kernel = new (std::nothrow) ConcatInt8CPUKernel(opParameter, inputs, outputs, ctx, primitive); - if (kernel == nullptr) { - MS_LOG(ERROR) << "new ConcatCPUKernel fail!"; - return nullptr; - } - auto ret = kernel->Init(); - if (ret != RET_OK) { - delete kernel; - MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " - << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); - return nullptr; - } - return kernel; -} - kernel::LiteKernel *CpuConcatInt32KernelCreator(const std::vector &inputs, const std::vector &outputs, OpParameter *opParameter, const InnerContext *ctx, const kernel::KernelKey &desc, @@ -109,7 +84,6 @@ kernel::LiteKernel *CpuConcatFp32KernelCreator(const std::vector return kernel; } -REG_KERNEL(kCPU, kNumberTypeInt8, PrimitiveType_Concat, CpuConcatInt8KernelCreator) REG_KERNEL(kCPU, kNumberTypeInt32, PrimitiveType_Concat, CpuConcatInt32KernelCreator) REG_KERNEL(kCPU, kNumberTypeFloat32, PrimitiveType_Concat, CpuConcatFp32KernelCreator) } // namespace mindspore::kernel diff --git a/mindspore/lite/src/runtime/kernel/arm/base/crop_base.cc b/mindspore/lite/src/runtime/kernel/arm/base/crop_base.cc index 289f2d4d67..c22573feb1 100644 --- a/mindspore/lite/src/runtime/kernel/arm/base/crop_base.cc +++ b/mindspore/lite/src/runtime/kernel/arm/base/crop_base.cc @@ -15,7 +15,6 @@ */ #include "src/runtime/kernel/arm/base/crop_base.h" #include -#include "src/runtime/kernel/arm/int8/crop_int8.h" #include "src/runtime/kernel/arm/fp32/crop.h" #include "schema/model_generated.h" #include "src/kernel_registry.h" @@ -30,30 +29,6 @@ using mindspore::schema::PrimitiveType_Crop; namespace mindspore::kernel { int CropBaseCPUKernel::Init() { return RET_OK; } -kernel::LiteKernel *CpuCropInt8KernelCreator(const std::vector &inputs, - const std::vector &outputs, OpParameter *opParameter, - const InnerContext *ctx, const kernel::KernelKey &desc, - const mindspore::lite::PrimitiveC *primitive) { - if (opParameter == nullptr) { - MS_LOG(ERROR) << "Input opParameter is nullptr!"; - return nullptr; - } - MS_ASSERT(desc.type == schema::PrimitiveType_Crop); - auto *kernel = new (std::nothrow) CropInt8CPUKernel(opParameter, inputs, outputs, ctx, primitive); - if (kernel == nullptr) { - MS_LOG(ERROR) << "new CropCPUKernel fail!"; - return nullptr; - } - auto ret = kernel->Init(); - if (ret != RET_OK) { - delete kernel; - MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " - << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); - return nullptr; - } - return kernel; -} - int CropBaseCPUKernel::ReSize() { auto *input_tensor = in_tensors_.at(kInputIndex); auto input_shape = input_tensor->shape(); @@ -155,7 +130,6 @@ kernel::LiteKernel *CpuCropFp32KernelCreator(const std::vector & return kernel; } -REG_KERNEL(kCPU, kNumberTypeInt8, PrimitiveType_Crop, CpuCropInt8KernelCreator) REG_KERNEL(kCPU, kNumberTypeInt32, PrimitiveType_Crop, CpuCropInt32KernelCreator) REG_KERNEL(kCPU, kNumberTypeFloat32, PrimitiveType_Crop, CpuCropFp32KernelCreator) } // namespace mindspore::kernel diff --git a/mindspore/lite/src/runtime/kernel/arm/base/depth_to_space_base.cc b/mindspore/lite/src/runtime/kernel/arm/base/depth_to_space_base.cc index b8fd69e2e7..e6501e0843 100644 --- a/mindspore/lite/src/runtime/kernel/arm/base/depth_to_space_base.cc +++ b/mindspore/lite/src/runtime/kernel/arm/base/depth_to_space_base.cc @@ -16,7 +16,6 @@ #include "src/runtime/kernel/arm/base/depth_to_space_base.h" #include "nnacl/depth_to_space.h" #include "src/runtime/kernel/arm/fp32/depth_to_space.h" -#include "src/runtime/kernel/arm/int8/depth_to_space_int8.h" #include "nnacl/arithmetic_common.h" #include "schema/model_generated.h" #include "src/kernel_registry.h" @@ -61,32 +60,6 @@ int DepthToSpaceBaseCPUKernel::ReSize() { return RET_OK; } -kernel::LiteKernel *CpuDepthToSpaceInt8KernelCreator(const std::vector &inputs, - const std::vector &outputs, - OpParameter *op_parameter, const lite::InnerContext *ctx, - const kernel::KernelKey &desc, - const mindspore::lite::PrimitiveC *primitive) { - MS_ASSERT(desc.type == schema::PrimitiveType_DepthToSpace); - if (op_parameter == nullptr) { - MS_LOG(ERROR) << "Input op_parameter is nullptr!"; - return nullptr; - } - auto *kernel = new (std::nothrow) DepthToSpaceInt8CPUKernel(op_parameter, inputs, outputs, ctx, primitive); - if (kernel == nullptr) { - MS_LOG(ERROR) << "new BatchToSpaceInt8CPUKernel fail!"; - return nullptr; - } - - auto ret = kernel->Init(); - if (ret != RET_OK) { - delete kernel; - MS_LOG(ERROR) << "Init kernel failed, name: " << op_parameter->name_ << ", type: " - << schema::EnumNamePrimitiveType(static_cast(op_parameter->type_)); - return nullptr; - } - return kernel; -} - kernel::LiteKernel *CpuDepthToSpaceFp32KernelCreator(const std::vector &inputs, const std::vector &outputs, OpParameter *op_parameter, const lite::InnerContext *ctx, @@ -115,5 +88,4 @@ kernel::LiteKernel *CpuDepthToSpaceFp32KernelCreator(const std::vector &inputs, - const std::vector &outputs, - OpParameter *opParameter, const lite::InnerContext *ctx, - const kernel::KernelKey &desc, - const mindspore::lite::PrimitiveC *primitive) { - MS_ASSERT(opParameter != nullptr); - MS_ASSERT(desc.type == schema::PrimitiveType_Concat); - auto kernel = new (std::nothrow) FullconnectionInt8CPUKernel(opParameter, inputs, outputs, ctx, primitive); - if (!kernel) { - MS_LOG(ERROR) << "kernel is nullptr."; - return nullptr; - } - auto ret = kernel->Init(); - if (ret != RET_OK) { - delete kernel; - MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " - << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); - return nullptr; - } - return kernel; -} kernel::LiteKernel *CpuFullConnectionFp32KernelCreator(const std::vector &inputs, const std::vector &outputs, OpParameter *opParameter, const lite::InnerContext *ctx, @@ -100,6 +78,5 @@ kernel::LiteKernel *CpuFullConnectionFp32KernelCreator(const std::vector -#include "src/runtime/kernel/arm/int8/leaky_relu_int8.h" #include "schema/model_generated.h" #include "src/kernel_registry.h" #include "include/errorcode.h" @@ -29,30 +28,4 @@ using mindspore::schema::PrimitiveType_LeakyReLU; namespace mindspore::kernel { int LeakyReluBaseCPUKernel::Init() { return RET_OK; } -kernel::LiteKernel *CpuLeakyReluInt8KernelCreator(const std::vector &inputs, - const std::vector &outputs, OpParameter *opParameter, - const InnerContext *ctx, const kernel::KernelKey &desc, - const mindspore::lite::PrimitiveC *primitive) { - if (opParameter == nullptr) { - MS_LOG(ERROR) << "Input opParameter is nullptr!"; - return nullptr; - } - - auto *kernel = new (std::nothrow) LeakyReluInt8CPUKernel(opParameter, inputs, outputs, ctx, primitive); - if (kernel == nullptr) { - MS_LOG(ERROR) << "new LeakyReluInt8CPUKernel fail!"; - free(opParameter); - return nullptr; - } - auto ret = kernel->Init(); - if (ret != RET_OK) { - delete kernel; - MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " - << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); - return nullptr; - } - return kernel; -} - -REG_KERNEL(kCPU, kNumberTypeInt8, PrimitiveType_LeakyReLU, CpuLeakyReluInt8KernelCreator) } // namespace mindspore::kernel diff --git a/mindspore/lite/src/runtime/kernel/arm/base/matmul_base.cc b/mindspore/lite/src/runtime/kernel/arm/base/matmul_base.cc index b973626bc7..3b4bae5a0c 100644 --- a/mindspore/lite/src/runtime/kernel/arm/base/matmul_base.cc +++ b/mindspore/lite/src/runtime/kernel/arm/base/matmul_base.cc @@ -15,11 +15,9 @@ */ #include "src/runtime/kernel/arm/base/matmul_base.h" #include "src/runtime/kernel/arm/fp32/matmul.h" -#include "src/runtime/kernel/arm/int8/matmul_int8.h" #include "src/kernel_registry.h" #include "include/errorcode.h" #include "include/context.h" -#include "src/runtime/kernel/arm/base/dequant.h" using mindspore::lite::KernelRegistrar; using mindspore::lite::RET_ERROR; @@ -34,35 +32,14 @@ kernel::LiteKernel *CpuMatmulKernelCreator(const std::vector &in MS_ASSERT(opParameter != nullptr); MS_ASSERT(desc.type == schema::PrimitiveType_Concat); - auto *weight_tensor = inputs.at(kWeightIndex); - auto *restore_data = weight_tensor->data_c(); - auto is_const_quant_weight = - (restore_data != nullptr) && - ((weight_tensor->data_type() == kNumberTypeInt8 || weight_tensor->data_type() == kNumberTypeInt16)); - if (is_const_quant_weight) { - auto *dequant_weight = kernel::DequantUtil::DequantWeight(weight_tensor); - if (dequant_weight == nullptr) { - MS_LOG(ERROR) << "dequant data is nullptr."; - free(opParameter); - return nullptr; - } - weight_tensor->SetData(dequant_weight); - } - auto input_tensor = inputs.at(kInputIndex); auto data_type = input_tensor->data_type(); kernel::LiteKernel *kernel = nullptr; - if (data_type == kNumberTypeInt8) { - kernel = new (std::nothrow) MatmulInt8CPUKernel(opParameter, inputs, outputs, ctx, primitive); - } else { + if (data_type == kNumberTypeFloat32) { kernel = new (std::nothrow) MatmulCPUKernel(opParameter, inputs, outputs, ctx, primitive); } if (kernel == nullptr) { MS_LOG(ERROR) << "kernel is nullptr."; - if (is_const_quant_weight) { - weight_tensor->FreeData(); - weight_tensor->SetData(restore_data); - } free(opParameter); return nullptr; } @@ -71,21 +48,9 @@ kernel::LiteKernel *CpuMatmulKernelCreator(const std::vector &in delete kernel; MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); - if (is_const_quant_weight) { - weight_tensor->FreeData(); - weight_tensor->SetData(restore_data); - } return nullptr; } - - if (is_const_quant_weight) { - weight_tensor->FreeData(); - weight_tensor->SetData(restore_data); - } - return kernel; } - REG_KERNEL(kCPU, kNumberTypeFloat32, PrimitiveType_MatMul, CpuMatmulKernelCreator) -REG_KERNEL(kCPU, kNumberTypeInt8, PrimitiveType_MatMul, CpuMatmulKernelCreator) } // namespace mindspore::kernel diff --git a/mindspore/lite/src/runtime/kernel/arm/base/pad.cc b/mindspore/lite/src/runtime/kernel/arm/base/pad.cc index 4a7de87661..d0b57932dc 100644 --- a/mindspore/lite/src/runtime/kernel/arm/base/pad.cc +++ b/mindspore/lite/src/runtime/kernel/arm/base/pad.cc @@ -15,7 +15,6 @@ */ #include #include "src/runtime/kernel/arm/fp32/pad.h" -#include "src/runtime/kernel/arm/int8/pad_int8.h" #include "schema/model_generated.h" #include "src/kernel_registry.h" #include "include/errorcode.h" @@ -28,28 +27,6 @@ using mindspore::schema::PrimitiveType_Pad; namespace mindspore::kernel { -kernel::LiteKernel *CpuPadInt8KernelCreator(const std::vector &inputs, - const std::vector &outputs, OpParameter *opParameter, - const lite::InnerContext *ctx, const kernel::KernelKey &desc, - const mindspore::lite::PrimitiveC *primitive) { - MS_ASSERT(opParameter != nullptr); - MS_ASSERT(desc.type == schema::PrimitiveType_Pad); - auto *kernel = new (std::nothrow) PadInt8CPUKernel(opParameter, inputs, outputs, ctx, primitive); - if (kernel == nullptr) { - MS_LOG(ERROR) << "new PadCPUKernel failed."; - free(opParameter); - return nullptr; - } - auto ret = kernel->Init(); - if (ret != RET_OK) { - delete kernel; - MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " - << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); - return nullptr; - } - return kernel; -} - kernel::LiteKernel *CpuPadFp32KernelCreator(const std::vector &inputs, const std::vector &outputs, OpParameter *opParameter, const lite::InnerContext *ctx, const kernel::KernelKey &desc, @@ -72,6 +49,5 @@ kernel::LiteKernel *CpuPadFp32KernelCreator(const std::vector &i return kernel; } -REG_KERNEL(kCPU, kNumberTypeInt8, PrimitiveType_Pad, CpuPadInt8KernelCreator) REG_KERNEL(kCPU, kNumberTypeFloat32, PrimitiveType_Pad, CpuPadFp32KernelCreator) } // namespace mindspore::kernel diff --git a/mindspore/lite/src/runtime/kernel/arm/base/pooling_base.cc b/mindspore/lite/src/runtime/kernel/arm/base/pooling_base.cc index 83d426e81b..fe4bce767f 100644 --- a/mindspore/lite/src/runtime/kernel/arm/base/pooling_base.cc +++ b/mindspore/lite/src/runtime/kernel/arm/base/pooling_base.cc @@ -15,7 +15,6 @@ */ #include "src/runtime/kernel/arm/base/pooling_base.h" #include -#include "src/runtime/kernel/arm/int8/pooling_int8.h" #include "src/runtime/kernel/arm/fp32/pooling.h" #include "schema/model_generated.h" #include "src/kernel_registry.h" @@ -103,31 +102,6 @@ int PoolingBaseCPUKernel::ReSize() { return RET_OK; } -kernel::LiteKernel *CpuPoolingInt8KernelCreator(const std::vector &inputs, - const std::vector &outputs, OpParameter *opParameter, - const InnerContext *ctx, const kernel::KernelKey &desc, - const mindspore::lite::PrimitiveC *primitive) { - if (opParameter == nullptr) { - MS_LOG(ERROR) << "Input opParameter is nullptr!"; - return nullptr; - } - MS_ASSERT(desc.type == schema::PrimitiveType_Pooling); - auto *kernel = new (std::nothrow) PoolingInt8CPUKernel(opParameter, inputs, outputs, ctx, primitive); - if (kernel == nullptr) { - MS_LOG(ERROR) << "new PoolingInt8CPUKernel fail!"; - free(opParameter); - return nullptr; - } - auto ret = kernel->Init(); - if (ret != RET_OK) { - delete kernel; - MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " - << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); - return nullptr; - } - return kernel; -} - kernel::LiteKernel *CpuPoolingFp32KernelCreator(const std::vector &inputs, const std::vector &outputs, OpParameter *opParameter, const InnerContext *ctx, const kernel::KernelKey &desc, @@ -153,6 +127,5 @@ kernel::LiteKernel *CpuPoolingFp32KernelCreator(const std::vector -#include "src/runtime/kernel/arm/int8/power_int8.h" #include "src/runtime/kernel/arm/fp32/power.h" #include "schema/model_generated.h" #include "src/kernel_registry.h" @@ -31,31 +30,6 @@ int PowerBaseCPUKernel::Init() { return RET_OK; } int PowerBaseCPUKernel::ReSize() { return RET_OK; } -kernel::LiteKernel *CpuPowerInt8KernelCreator(const std::vector &inputs, - const std::vector &outputs, OpParameter *opParameter, - const lite::InnerContext *ctx, const kernel::KernelKey &desc, - const mindspore::lite::PrimitiveC *primitive) { - if (opParameter == nullptr) { - MS_LOG(ERROR) << "Input opParameter is nullptr!"; - return nullptr; - } - MS_ASSERT(desc.type == schema::PrimitiveType_Power); - auto *kernel = new (std::nothrow) PowerInt8CPUKernel(opParameter, inputs, outputs, ctx, primitive); - if (kernel == nullptr) { - MS_LOG(ERROR) << "new PowerInt8CPUKernel fail!"; - free(opParameter); - return nullptr; - } - auto ret = kernel->Init(); - if (ret != RET_OK) { - delete kernel; - MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " - << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); - return nullptr; - } - return kernel; -} - kernel::LiteKernel *CpuPowerFp32KernelCreator(const std::vector &inputs, const std::vector &outputs, OpParameter *opParameter, const lite::InnerContext *ctx, const kernel::KernelKey &desc, @@ -78,6 +52,5 @@ kernel::LiteKernel *CpuPowerFp32KernelCreator(const std::vector return kernel; } -REG_KERNEL(kCPU, kNumberTypeInt8, PrimitiveType_Power, CpuPowerInt8KernelCreator) REG_KERNEL(kCPU, kNumberTypeFloat32, PrimitiveType_Power, CpuPowerFp32KernelCreator) } // namespace mindspore::kernel diff --git a/mindspore/lite/src/runtime/kernel/arm/base/reduce_base.cc b/mindspore/lite/src/runtime/kernel/arm/base/reduce_base.cc index 05bff4db17..5fe16a4e7b 100644 --- a/mindspore/lite/src/runtime/kernel/arm/base/reduce_base.cc +++ b/mindspore/lite/src/runtime/kernel/arm/base/reduce_base.cc @@ -20,7 +20,6 @@ #include "include/errorcode.h" #include "src/runtime/runtime_api.h" #include "src/runtime/kernel/arm/fp32/reduce.h" -#include "src/runtime/kernel/arm/int8/reduce_int8.h" using mindspore::kernel::KERNEL_ARCH::kCPU; using mindspore::lite::KernelRegistrar; @@ -231,41 +230,9 @@ kernel::LiteKernel *CpuMeanFp32KernelCreator(const std::vector & return kernel; } -kernel::LiteKernel *CpuReduceInt8KernelCreator(const std::vector &inputs, - const std::vector &outputs, OpParameter *opParameter, - const lite::InnerContext *ctx, const kernel::KernelKey &desc, - const mindspore::lite::PrimitiveC *primitive) { - MS_ASSERT(opParameter != nullptr); - MS_ASSERT(desc.type == schema::PrimitiveType_Reduce); - if (opParameter == nullptr) { - MS_LOG(ERROR) << "Reduce opParameter nullptr"; - return nullptr; - } - if (desc.type != schema::PrimitiveType_Reduce) { - MS_LOG(ERROR) << "Reduce op desc.type should be PrimitiveType_Reduce, got " << desc.type; - free(opParameter); - return nullptr; - } - auto *kernel = new (std::nothrow) ReduceInt8CPUKernel(opParameter, inputs, outputs, ctx, primitive); - if (kernel == nullptr) { - MS_LOG(ERROR) << "Reduce new ReduceCPUKernel failed."; - free(opParameter); - return nullptr; - } - auto ret = kernel->Init(); - if (ret != RET_OK) { - MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " - << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); - delete kernel; - return nullptr; - } - return kernel; -} - REG_KERNEL(kCPU, kNumberTypeFloat32, PrimitiveType_Reduce, CpuReduceFp32KernelCreator) REG_KERNEL(kCPU, kNumberTypeInt, PrimitiveType_Reduce, CpuReduceFp32KernelCreator) REG_KERNEL(kCPU, kNumberTypeInt32, PrimitiveType_Reduce, CpuReduceFp32KernelCreator) REG_KERNEL(kCPU, kNumberTypeFloat32, PrimitiveType_Mean, CpuMeanFp32KernelCreator) -REG_KERNEL(kCPU, kNumberTypeInt8, PrimitiveType_Reduce, CpuReduceInt8KernelCreator) -REG_KERNEL(kCPU, kNumberTypeInt8, PrimitiveType_Mean, CpuReduceInt8KernelCreator) + } // namespace mindspore::kernel diff --git a/mindspore/lite/src/runtime/kernel/arm/base/reshape_base.cc b/mindspore/lite/src/runtime/kernel/arm/base/reshape_base.cc index a6e5feb310..d4c6fe91a5 100644 --- a/mindspore/lite/src/runtime/kernel/arm/base/reshape_base.cc +++ b/mindspore/lite/src/runtime/kernel/arm/base/reshape_base.cc @@ -15,7 +15,6 @@ */ #include "src/runtime/kernel/arm/base/reshape_base.h" #include -#include "src/runtime/kernel/arm/int8/reshape_int8.h" #include "src/runtime/kernel/arm/fp32/reshape.h" #include "schema/model_generated.h" #include "src/kernel_registry.h" @@ -30,31 +29,6 @@ using mindspore::schema::PrimitiveType_Reshape; namespace mindspore::kernel { int ReshapeBaseCPUKernel::Init() { return RET_OK; } -kernel::LiteKernel *CpuReshapeInt8KernelCreator(const std::vector &inputs, - const std::vector &outputs, OpParameter *opParameter, - const InnerContext *ctx, const kernel::KernelKey &desc, - const mindspore::lite::PrimitiveC *primitive) { - if (opParameter == nullptr) { - MS_LOG(ERROR) << "Input opParameter is nullptr!"; - return nullptr; - } - MS_ASSERT(desc.type == schema::PrimitiveType_Reshape); - auto *kernel = new (std::nothrow) ReshapeInt8CPUKernel(opParameter, inputs, outputs, ctx, primitive); - if (kernel == nullptr) { - MS_LOG(ERROR) << "new ReshapeInt8CPUKernel fail!"; - free(opParameter); - return nullptr; - } - auto ret = kernel->Init(); - if (ret != RET_OK) { - delete kernel; - MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " - << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); - return nullptr; - } - return kernel; -} - kernel::LiteKernel *CpuReshapeInt32KernelCreator(const std::vector &inputs, const std::vector &outputs, OpParameter *opParameter, const InnerContext *ctx, const kernel::KernelKey &desc, @@ -105,7 +79,6 @@ kernel::LiteKernel *CpuReshapeFp32KernelCreator(const std::vector return kernel; } -kernel::LiteKernel *CpuResizeInt8KernelCreator(const std::vector &inputs, - const std::vector &outputs, OpParameter *opParameter, - const lite::InnerContext *ctx, const kernel::KernelKey &desc, - const mindspore::lite::PrimitiveC *primitive) { - if (opParameter == nullptr) { - MS_LOG(ERROR) << "Input opParameter is nullptr!"; - return nullptr; - } - MS_ASSERT(desc.type == schema::PrimitiveType_Resize); - auto *kernel = new (std::nothrow) ResizeInt8CPUKernel(opParameter, inputs, outputs, ctx, primitive); - if (kernel == nullptr) { - MS_LOG(ERROR) << "new ResizeCPUKernel fail!"; - free(opParameter); - return nullptr; - } - auto ret = kernel->Init(); - if (ret != RET_OK) { - delete kernel; - MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " - << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); - return nullptr; - } - - return kernel; -} - -REG_KERNEL(kCPU, kNumberTypeInt8, PrimitiveType_Resize, CpuResizeInt8KernelCreator) REG_KERNEL(kCPU, kNumberTypeFloat32, PrimitiveType_Resize, CpuResizeFp32KernelCreator) } // namespace mindspore::kernel diff --git a/mindspore/lite/src/runtime/kernel/arm/base/softmax_base.cc b/mindspore/lite/src/runtime/kernel/arm/base/softmax_base.cc index edf8e4a9b0..7346bfa8fb 100644 --- a/mindspore/lite/src/runtime/kernel/arm/base/softmax_base.cc +++ b/mindspore/lite/src/runtime/kernel/arm/base/softmax_base.cc @@ -16,7 +16,6 @@ #include "src/runtime/kernel/arm/base/softmax_base.h" #include -#include "src/runtime/kernel/arm/int8/softmax_int8.h" #include "src/runtime/kernel/arm/fp32/softmax.h" #include "nnacl/fp32/softmax.h" #include "schema/model_generated.h" @@ -56,31 +55,6 @@ int SoftmaxBaseCPUKernel::ReSize() { return RET_OK; } -kernel::LiteKernel *CpuSoftmaxInt8KernelCreator(const std::vector &inputs, - const std::vector &outputs, OpParameter *opParameter, - const lite::InnerContext *ctx, const kernel::KernelKey &desc, - const mindspore::lite::PrimitiveC *primitive) { - if (opParameter == nullptr) { - MS_LOG(ERROR) << "Input opParameter is nullptr!"; - return nullptr; - } - MS_ASSERT(desc.type == schema::PrimitiveType_SoftMax); - auto *kernel = new (std::nothrow) SoftmaxInt8CPUKernel(opParameter, inputs, outputs, ctx, primitive); - if (kernel == nullptr) { - MS_LOG(ERROR) << "new SoftmaxCPUKernel fail!"; - free(opParameter); - return nullptr; - } - auto ret = kernel->Init(); - if (ret != RET_OK) { - delete kernel; - MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " - << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); - return nullptr; - } - return kernel; -} - kernel::LiteKernel *CpuSoftmaxFp32KernelCreator(const std::vector &inputs, const std::vector &outputs, OpParameter *opParameter, const lite::InnerContext *ctx, const kernel::KernelKey &desc, @@ -106,6 +80,5 @@ kernel::LiteKernel *CpuSoftmaxFp32KernelCreator(const std::vector -#include "src/runtime/kernel/arm/int8/split_int8.h" #include "src/runtime/kernel/arm/fp32/split.h" #include "schema/model_generated.h" #include "src/kernel_registry.h" @@ -72,31 +71,6 @@ int SplitBaseCPUKernel::ReSize() { return RET_OK; } -kernel::LiteKernel *CpuSplitInt8KernelCreator(const std::vector &inputs, - const std::vector &outputs, OpParameter *opParameter, - const InnerContext *ctx, const kernel::KernelKey &desc, - const mindspore::lite::PrimitiveC *primitive) { - if (opParameter == nullptr) { - MS_LOG(ERROR) << "Input opParameter is nullptr!"; - return nullptr; - } - MS_ASSERT(desc.type == schema::PrimitiveType_Split); - auto *kernel = new (std::nothrow) SplitInt8CPUKernel(opParameter, inputs, outputs, ctx, primitive); - if (kernel == nullptr) { - MS_LOG(ERROR) << "new SplitCPUKernel fail!"; - free(opParameter); - return nullptr; - } - auto ret = kernel->Init(); - if (ret != RET_OK) { - delete kernel; - MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " - << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); - return nullptr; - } - return kernel; -} - kernel::LiteKernel *CpuSplitInt32KernelCreator(const std::vector &inputs, const std::vector &outputs, OpParameter *opParameter, const InnerContext *ctx, const kernel::KernelKey &desc, @@ -147,7 +121,6 @@ kernel::LiteKernel *CpuSplitFp32KernelCreator(const std::vector return kernel; } -REG_KERNEL(kCPU, kNumberTypeInt8, PrimitiveType_Split, CpuSplitInt8KernelCreator) REG_KERNEL(kCPU, kNumberTypeInt32, PrimitiveType_Split, CpuSplitInt32KernelCreator) REG_KERNEL(kCPU, kNumberTypeFloat32, PrimitiveType_Split, CpuSplitFp32KernelCreator) } // namespace mindspore::kernel diff --git a/mindspore/lite/src/runtime/kernel/arm/base/squeeze_base.cc b/mindspore/lite/src/runtime/kernel/arm/base/squeeze_base.cc index d743aae570..c011b4a415 100644 --- a/mindspore/lite/src/runtime/kernel/arm/base/squeeze_base.cc +++ b/mindspore/lite/src/runtime/kernel/arm/base/squeeze_base.cc @@ -15,7 +15,6 @@ */ #include "src/runtime/kernel/arm/base/squeeze_base.h" #include -#include "src/runtime/kernel/arm/int8/squeeze_int8.h" #include "schema/model_generated.h" #include "src/kernel_registry.h" #include "include/errorcode.h" @@ -29,30 +28,4 @@ using mindspore::schema::PrimitiveType_Squeeze; namespace mindspore::kernel { int SqueezeBaseCPUKernel::Init() { return RET_OK; } -kernel::LiteKernel *CpuSqueezeInt8KernelCreator(const std::vector &inputs, - const std::vector &outputs, OpParameter *opParameter, - const InnerContext *ctx, const kernel::KernelKey &desc, - const mindspore::lite::PrimitiveC *primitive) { - if (opParameter == nullptr) { - MS_LOG(ERROR) << "Input opParameter is nullptr!"; - return nullptr; - } - MS_ASSERT(desc.type == schema::PrimitiveType_Squeeze); - auto *kernel = new (std::nothrow) SqueezeInt8CPUKernel(opParameter, inputs, outputs, ctx, primitive); - if (kernel == nullptr) { - MS_LOG(ERROR) << "new SqueezeCPUKernel fail!"; - free(opParameter); - return nullptr; - } - auto ret = kernel->Init(); - if (ret != RET_OK) { - delete kernel; - MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " - << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); - return nullptr; - } - return kernel; -} - -REG_KERNEL(kCPU, kNumberTypeInt8, PrimitiveType_Squeeze, CpuSqueezeInt8KernelCreator) } // namespace mindspore::kernel diff --git a/mindspore/lite/src/runtime/kernel/arm/int8/argminmax_int8.cc b/mindspore/lite/src/runtime/kernel/arm/int8/argminmax_int8.cc index 3cdb0f1d12..d95b8b4ec3 100644 --- a/mindspore/lite/src/runtime/kernel/arm/int8/argminmax_int8.cc +++ b/mindspore/lite/src/runtime/kernel/arm/int8/argminmax_int8.cc @@ -23,6 +23,12 @@ using mindspore::lite::RET_ERROR; using mindspore::lite::RET_OK; +using mindspore::lite::KernelRegistrar; +using mindspore::lite::RET_FORMAT_ERR; +using mindspore::lite::RET_PARAM_INVALID; +using mindspore::schema::PrimitiveType_ArgMax; +using mindspore::schema::PrimitiveType_ArgMin; + namespace mindspore::kernel { int ArgMinMaxInt8CPUKernel::Init() { auto ret = ArgMinMaxBaseCPUKernel::Init(); @@ -77,4 +83,32 @@ int ArgMinMaxInt8CPUKernel::Run() { } return RET_OK; } + +kernel::LiteKernel *CpuArgMinMaxInt8KernelCreator(const std::vector &inputs, + const std::vector &outputs, OpParameter *op_parameter, + const lite::InnerContext *ctx, const kernel::KernelKey &desc, + const mindspore::lite::PrimitiveC *primitive) { + if (op_parameter == nullptr) { + MS_LOG(ERROR) << "Input op_parameter is nullptr!"; + return nullptr; + } + auto kernel = new (std::nothrow) ArgMinMaxInt8CPUKernel(op_parameter, inputs, outputs, ctx, primitive); + if (kernel == nullptr) { + MS_LOG(ERROR) << "new ArgMinMaxInt8CPUKernel fail!"; + return nullptr; + } + + auto ret = kernel->Init(); + if (ret != RET_OK) { + delete kernel; + MS_LOG(ERROR) << "Init kernel failed, name: " << op_parameter->name_ << ", type: " + << schema::EnumNamePrimitiveType(static_cast(op_parameter->type_)); + return nullptr; + } + return kernel; +} + +REG_KERNEL(kCPU, kNumberTypeInt8, PrimitiveType_ArgMax, CpuArgMinMaxInt8KernelCreator) +REG_KERNEL(kCPU, kNumberTypeInt8, PrimitiveType_ArgMin, CpuArgMinMaxInt8KernelCreator) + } // namespace mindspore::kernel diff --git a/mindspore/lite/src/runtime/kernel/arm/int8/batch_to_space_int8.cc b/mindspore/lite/src/runtime/kernel/arm/int8/batch_to_space_int8.cc index 9338b54877..c6c9c5b6ab 100644 --- a/mindspore/lite/src/runtime/kernel/arm/int8/batch_to_space_int8.cc +++ b/mindspore/lite/src/runtime/kernel/arm/int8/batch_to_space_int8.cc @@ -23,6 +23,12 @@ using mindspore::lite::RET_OK; +using mindspore::lite::KernelRegistrar; +using mindspore::lite::RET_ERROR; +using mindspore::lite::RET_FORMAT_ERR; +using mindspore::schema::PrimitiveType_BatchToSpace; +using mindspore::schema::PrimitiveType_BatchToSpaceND; + namespace mindspore::kernel { int BatchToSpaceInt8CPUKernel::Init() { auto ret = BatchToSpaceBaseCPUKernel::Init(); @@ -75,4 +81,31 @@ int BatchToSpaceInt8CPUKernel::Run() { return RET_OK; } + +kernel::LiteKernel *CpuBatchToSpaceInt8KernelCreator(const std::vector &inputs, + const std::vector &outputs, + OpParameter *op_parameter, const lite::InnerContext *ctx, + const kernel::KernelKey &desc, + const mindspore::lite::PrimitiveC *primitive) { + if (op_parameter == nullptr) { + MS_LOG(ERROR) << "Input op_parameter is nullptr!"; + return nullptr; + } + auto *kernel = new (std::nothrow) BatchToSpaceInt8CPUKernel(op_parameter, inputs, outputs, ctx, primitive); + if (kernel == nullptr) { + MS_LOG(ERROR) << "new BatchToSpaceInt8CPUKernel fail!"; + return nullptr; + } + + auto ret = kernel->Init(); + if (ret != RET_OK) { + delete kernel; + MS_LOG(ERROR) << "Init kernel failed, name: " << op_parameter->name_ << ", type: " + << schema::EnumNamePrimitiveType(static_cast(op_parameter->type_)); + return nullptr; + } + return kernel; +} +REG_KERNEL(kCPU, kNumberTypeInt8, PrimitiveType_BatchToSpace, CpuBatchToSpaceInt8KernelCreator) +REG_KERNEL(kCPU, kNumberTypeInt8, PrimitiveType_BatchToSpaceND, CpuBatchToSpaceInt8KernelCreator) } // namespace mindspore::kernel diff --git a/mindspore/lite/src/runtime/kernel/arm/int8/concat_int8.cc b/mindspore/lite/src/runtime/kernel/arm/int8/concat_int8.cc index 8ea35460aa..c086dacbc6 100644 --- a/mindspore/lite/src/runtime/kernel/arm/int8/concat_int8.cc +++ b/mindspore/lite/src/runtime/kernel/arm/int8/concat_int8.cc @@ -19,11 +19,15 @@ #include "nnacl/int8/concat_int8.h" #include "schema/model_generated.h" #include "include/errorcode.h" +#include "src/kernel_registry.h" using mindspore::kernel::KERNEL_ARCH::kCPU; using mindspore::lite::RET_ERROR; using mindspore::lite::RET_OK; +using mindspore::lite::KernelRegistrar; +using mindspore::schema::PrimitiveType_Concat; + namespace mindspore::kernel { int ConcatInt8CPUKernel::Init() { @@ -136,4 +140,31 @@ int ConcatInt8CPUKernel::DoExecute(int task_id) { Int8Concat(input_data_, output_data_, concat_param_, axis_, real_dst_count, task_id); return lite::RET_OK; } + +kernel::LiteKernel *CpuConcatInt8KernelCreator(const std::vector &inputs, + const std::vector &outputs, OpParameter *opParameter, + const InnerContext *ctx, const kernel::KernelKey &desc, + const mindspore::lite::PrimitiveC *primitive) { + if (opParameter == nullptr) { + MS_LOG(ERROR) << "Input opParameter is nullptr!"; + return nullptr; + } + MS_ASSERT(desc.type == schema::PrimitiveType_Concat); + auto *kernel = new (std::nothrow) ConcatInt8CPUKernel(opParameter, inputs, outputs, ctx, primitive); + if (kernel == nullptr) { + MS_LOG(ERROR) << "new ConcatCPUKernel fail!"; + return nullptr; + } + auto ret = kernel->Init(); + if (ret != RET_OK) { + delete kernel; + MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " + << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + return nullptr; + } + return kernel; +} + +REG_KERNEL(kCPU, kNumberTypeInt8, PrimitiveType_Concat, CpuConcatInt8KernelCreator) + } // namespace mindspore::kernel diff --git a/mindspore/lite/src/runtime/kernel/arm/int8/crop_int8.cc b/mindspore/lite/src/runtime/kernel/arm/int8/crop_int8.cc index e3dcfdc684..663353f2ff 100644 --- a/mindspore/lite/src/runtime/kernel/arm/int8/crop_int8.cc +++ b/mindspore/lite/src/runtime/kernel/arm/int8/crop_int8.cc @@ -19,12 +19,16 @@ #include "nnacl/int8/crop_int8.h" #include "include/errorcode.h" #include "src/runtime/runtime_api.h" +#include "src/kernel_registry.h" using mindspore::kernel::KERNEL_ARCH::kCPU; using mindspore::lite::RET_ERROR; using mindspore::lite::RET_MEMORY_FAILED; using mindspore::lite::RET_OK; +using mindspore::lite::KernelRegistrar; +using mindspore::schema::PrimitiveType_Crop; + namespace mindspore::kernel { int CropInt8CPUKernel::Init() { @@ -84,4 +88,29 @@ int CropInt8CPUKernel::DoExecute(int task_id) { return RET_OK; } +kernel::LiteKernel *CpuCropInt8KernelCreator(const std::vector &inputs, + const std::vector &outputs, OpParameter *opParameter, + const InnerContext *ctx, const kernel::KernelKey &desc, + const mindspore::lite::PrimitiveC *primitive) { + if (opParameter == nullptr) { + MS_LOG(ERROR) << "Input opParameter is nullptr!"; + return nullptr; + } + MS_ASSERT(desc.type == schema::PrimitiveType_Crop); + auto *kernel = new (std::nothrow) CropInt8CPUKernel(opParameter, inputs, outputs, ctx, primitive); + if (kernel == nullptr) { + MS_LOG(ERROR) << "new CropCPUKernel fail!"; + return nullptr; + } + auto ret = kernel->Init(); + if (ret != RET_OK) { + delete kernel; + MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " + << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + return nullptr; + } + return kernel; +} +REG_KERNEL(kCPU, kNumberTypeInt8, PrimitiveType_Crop, CpuCropInt8KernelCreator) + } // namespace mindspore::kernel diff --git a/mindspore/lite/src/runtime/kernel/arm/int8/depth_to_space_int8.cc b/mindspore/lite/src/runtime/kernel/arm/int8/depth_to_space_int8.cc index 8a582f0e4d..48ed6aa614 100644 --- a/mindspore/lite/src/runtime/kernel/arm/int8/depth_to_space_int8.cc +++ b/mindspore/lite/src/runtime/kernel/arm/int8/depth_to_space_int8.cc @@ -24,6 +24,11 @@ using mindspore::lite::RET_ERROR; using mindspore::lite::RET_OK; +using mindspore::lite::KernelRegistrar; +using mindspore::lite::RET_FORMAT_ERR; +using mindspore::lite::RET_PARAM_INVALID; +using mindspore::schema::PrimitiveType_DepthToSpace; + namespace mindspore::kernel { int DepthToSpaceInt8CPUKernel::Init() { auto ret = DepthToSpaceBaseCPUKernel::Init(); @@ -64,4 +69,32 @@ int DepthToSpaceInt8CPUKernel::Run() { } return RET_OK; } + +kernel::LiteKernel *CpuDepthToSpaceInt8KernelCreator(const std::vector &inputs, + const std::vector &outputs, + OpParameter *op_parameter, const lite::InnerContext *ctx, + const kernel::KernelKey &desc, + const mindspore::lite::PrimitiveC *primitive) { + MS_ASSERT(desc.type == schema::PrimitiveType_DepthToSpace); + if (op_parameter == nullptr) { + MS_LOG(ERROR) << "Input op_parameter is nullptr!"; + return nullptr; + } + auto *kernel = new (std::nothrow) DepthToSpaceInt8CPUKernel(op_parameter, inputs, outputs, ctx, primitive); + if (kernel == nullptr) { + MS_LOG(ERROR) << "new BatchToSpaceInt8CPUKernel fail!"; + return nullptr; + } + + auto ret = kernel->Init(); + if (ret != RET_OK) { + delete kernel; + MS_LOG(ERROR) << "Init kernel failed, name: " << op_parameter->name_ << ", type: " + << schema::EnumNamePrimitiveType(static_cast(op_parameter->type_)); + return nullptr; + } + return kernel; +} +REG_KERNEL(kCPU, kNumberTypeInt8, PrimitiveType_DepthToSpace, CpuDepthToSpaceInt8KernelCreator) + } // namespace mindspore::kernel diff --git a/mindspore/lite/src/runtime/kernel/arm/int8/fullconnection_int8.cc b/mindspore/lite/src/runtime/kernel/arm/int8/fullconnection_int8.cc index 563e1183c9..7c727d3d83 100644 --- a/mindspore/lite/src/runtime/kernel/arm/int8/fullconnection_int8.cc +++ b/mindspore/lite/src/runtime/kernel/arm/int8/fullconnection_int8.cc @@ -19,10 +19,16 @@ #include "nnacl/common_func.h" #include "src/runtime/runtime_api.h" #include "include/errorcode.h" +#include "src/kernel_registry.h" using mindspore::lite::RET_MEMORY_FAILED; using mindspore::lite::RET_OK; +using mindspore::lite::KernelRegistrar; +using mindspore::lite::RET_ERROR; +using mindspore::lite::RET_OK; +using mindspore::schema::PrimitiveType_FullConnection; + namespace mindspore::kernel { int FullconnectionInt8CPUKernel::Init() { if (!InferShapeDone()) { @@ -150,5 +156,27 @@ int FullconnectionInt8CPUKernel::Run() { } return RET_OK; } +kernel::LiteKernel *CpuFullConnectionInt8KernelCreator(const std::vector &inputs, + const std::vector &outputs, + OpParameter *opParameter, const lite::InnerContext *ctx, + const kernel::KernelKey &desc, + const mindspore::lite::PrimitiveC *primitive) { + MS_ASSERT(opParameter != nullptr); + MS_ASSERT(desc.type == schema::PrimitiveType_Concat); + auto kernel = new (std::nothrow) FullconnectionInt8CPUKernel(opParameter, inputs, outputs, ctx, primitive); + if (!kernel) { + MS_LOG(ERROR) << "kernel is nullptr."; + return nullptr; + } + auto ret = kernel->Init(); + if (ret != RET_OK) { + delete kernel; + MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " + << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + return nullptr; + } + return kernel; +} +REG_KERNEL(kCPU, kNumberTypeInt8, PrimitiveType_FullConnection, CpuFullConnectionInt8KernelCreator) } // namespace mindspore::kernel diff --git a/mindspore/lite/src/runtime/kernel/arm/int8/leaky_relu_int8.cc b/mindspore/lite/src/runtime/kernel/arm/int8/leaky_relu_int8.cc index 7b33f5c521..521839b8e0 100644 --- a/mindspore/lite/src/runtime/kernel/arm/int8/leaky_relu_int8.cc +++ b/mindspore/lite/src/runtime/kernel/arm/int8/leaky_relu_int8.cc @@ -29,6 +29,9 @@ using mindspore::lite::RET_ERROR; using mindspore::lite::RET_MEMORY_FAILED; using mindspore::lite::RET_OK; +using mindspore::lite::KernelRegistrar; +using mindspore::schema::PrimitiveType_LeakyReLU; + namespace mindspore::kernel { namespace { int LeakyReluInt8Run(void *cdata, int task_id) { @@ -134,5 +137,30 @@ int LeakyReluInt8CPUKernel::DoExecute(int task_id) { } return RET_OK; } +kernel::LiteKernel *CpuLeakyReluInt8KernelCreator(const std::vector &inputs, + const std::vector &outputs, OpParameter *opParameter, + const InnerContext *ctx, const kernel::KernelKey &desc, + const mindspore::lite::PrimitiveC *primitive) { + if (opParameter == nullptr) { + MS_LOG(ERROR) << "Input opParameter is nullptr!"; + return nullptr; + } + + auto *kernel = new (std::nothrow) LeakyReluInt8CPUKernel(opParameter, inputs, outputs, ctx, primitive); + if (kernel == nullptr) { + MS_LOG(ERROR) << "new LeakyReluInt8CPUKernel fail!"; + free(opParameter); + return nullptr; + } + auto ret = kernel->Init(); + if (ret != RET_OK) { + delete kernel; + MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " + << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + return nullptr; + } + return kernel; +} +REG_KERNEL(kCPU, kNumberTypeInt8, PrimitiveType_LeakyReLU, CpuLeakyReluInt8KernelCreator) } // namespace mindspore::kernel diff --git a/mindspore/lite/src/runtime/kernel/arm/int8/matmul_int8.cc b/mindspore/lite/src/runtime/kernel/arm/int8/matmul_int8.cc index 1d4e96f8af..92e70ad84c 100644 --- a/mindspore/lite/src/runtime/kernel/arm/int8/matmul_int8.cc +++ b/mindspore/lite/src/runtime/kernel/arm/int8/matmul_int8.cc @@ -19,10 +19,16 @@ #include "nnacl/common_func.h" #include "src/runtime/runtime_api.h" #include "include/errorcode.h" +#include "src/kernel_registry.h" +#include "src/runtime/kernel/arm/base/dequant.h" using mindspore::lite::RET_MEMORY_FAILED; using mindspore::lite::RET_OK; +using mindspore::lite::KernelRegistrar; +using mindspore::lite::RET_ERROR; +using mindspore::schema::PrimitiveType_MatMul; + namespace mindspore::kernel { MatmulInt8CPUKernel::~MatmulInt8CPUKernel() { FreeTmpBuffer(); } @@ -193,4 +199,62 @@ int MatmulInt8CPUKernel::Run() { } return RET_OK; } +kernel::LiteKernel *CpuMatmulInt8KernelCreator(const std::vector &inputs, + const std::vector &outputs, OpParameter *opParameter, + const lite::InnerContext *ctx, const kernel::KernelKey &desc, + const mindspore::lite::PrimitiveC *primitive) { + MS_ASSERT(opParameter != nullptr); + MS_ASSERT(desc.type == schema::PrimitiveType_Concat); + + auto *weight_tensor = inputs.at(kWeightIndex); + auto *restore_data = weight_tensor->data_c(); + auto is_const_quant_weight = + (restore_data != nullptr) && + ((weight_tensor->data_type() == kNumberTypeInt8 || weight_tensor->data_type() == kNumberTypeInt16)); + if (is_const_quant_weight) { + auto *dequant_weight = kernel::DequantUtil::DequantWeight(weight_tensor); + if (dequant_weight == nullptr) { + MS_LOG(ERROR) << "dequant data is nullptr."; + free(opParameter); + return nullptr; + } + weight_tensor->SetData(dequant_weight); + } + + auto input_tensor = inputs.at(kInputIndex); + auto data_type = input_tensor->data_type(); + kernel::LiteKernel *kernel = nullptr; + if (data_type == kNumberTypeInt8) { + kernel = new (std::nothrow) MatmulInt8CPUKernel(opParameter, inputs, outputs, ctx, primitive); + } + if (kernel == nullptr) { + MS_LOG(ERROR) << "kernel is nullptr."; + if (is_const_quant_weight) { + weight_tensor->FreeData(); + weight_tensor->SetData(restore_data); + } + free(opParameter); + return nullptr; + } + auto ret = kernel->Init(); + if (ret != RET_OK) { + delete kernel; + MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " + << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + if (is_const_quant_weight) { + weight_tensor->FreeData(); + weight_tensor->SetData(restore_data); + } + return nullptr; + } + + if (is_const_quant_weight) { + weight_tensor->FreeData(); + weight_tensor->SetData(restore_data); + } + + return kernel; +} +REG_KERNEL(kCPU, kNumberTypeInt8, PrimitiveType_MatMul, CpuMatmulInt8KernelCreator) + } // namespace mindspore::kernel diff --git a/mindspore/lite/src/runtime/kernel/arm/int8/pad_int8.cc b/mindspore/lite/src/runtime/kernel/arm/int8/pad_int8.cc index 9d58af4030..3a61bf9e2c 100644 --- a/mindspore/lite/src/runtime/kernel/arm/int8/pad_int8.cc +++ b/mindspore/lite/src/runtime/kernel/arm/int8/pad_int8.cc @@ -20,12 +20,15 @@ #include "nnacl/errorcode.h" #include "nnacl/int8/pad.h" #include "src/runtime/runtime_api.h" +#include "src/kernel_registry.h" using mindspore::lite::RET_ERROR; using mindspore::lite::RET_MEMORY_FAILED; using mindspore::lite::RET_NULL_PTR; using mindspore::lite::RET_OK; +using mindspore::lite::KernelRegistrar; +using mindspore::schema::PrimitiveType_Pad; namespace mindspore::kernel { namespace { @@ -273,4 +276,27 @@ int PadInt8CPUKernel::Run() { return RET_OK; } +kernel::LiteKernel *CpuPadInt8KernelCreator(const std::vector &inputs, + const std::vector &outputs, OpParameter *opParameter, + const lite::InnerContext *ctx, const kernel::KernelKey &desc, + const mindspore::lite::PrimitiveC *primitive) { + MS_ASSERT(opParameter != nullptr); + MS_ASSERT(desc.type == schema::PrimitiveType_Pad); + auto *kernel = new (std::nothrow) PadInt8CPUKernel(opParameter, inputs, outputs, ctx, primitive); + if (kernel == nullptr) { + MS_LOG(ERROR) << "new PadCPUKernel failed."; + free(opParameter); + return nullptr; + } + auto ret = kernel->Init(); + if (ret != RET_OK) { + delete kernel; + MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " + << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + return nullptr; + } + return kernel; +} +REG_KERNEL(kCPU, kNumberTypeInt8, PrimitiveType_Pad, CpuPadInt8KernelCreator) + } // namespace mindspore::kernel diff --git a/mindspore/lite/src/runtime/kernel/arm/int8/pooling_int8.cc b/mindspore/lite/src/runtime/kernel/arm/int8/pooling_int8.cc index 0b171ee81f..36f0843e8a 100644 --- a/mindspore/lite/src/runtime/kernel/arm/int8/pooling_int8.cc +++ b/mindspore/lite/src/runtime/kernel/arm/int8/pooling_int8.cc @@ -19,11 +19,16 @@ #include "nnacl/fp32/cast.h" #include "include/errorcode.h" #include "src/runtime/runtime_api.h" +#include "src/kernel_registry.h" using mindspore::kernel::KERNEL_ARCH::kCPU; using mindspore::lite::RET_ERROR; using mindspore::lite::RET_OK; +using mindspore::lite::KernelRegistrar; +using mindspore::lite::RET_MEMORY_FAILED; +using mindspore::schema::PrimitiveType_Pooling; + namespace mindspore::kernel { int PoolingInt8CPUKernel::Init() { auto ret = PoolingBaseCPUKernel::Init(); @@ -95,4 +100,30 @@ int PoolingInt8CPUKernel::Run() { } return RET_OK; } +kernel::LiteKernel *CpuPoolingInt8KernelCreator(const std::vector &inputs, + const std::vector &outputs, OpParameter *opParameter, + const InnerContext *ctx, const kernel::KernelKey &desc, + const mindspore::lite::PrimitiveC *primitive) { + if (opParameter == nullptr) { + MS_LOG(ERROR) << "Input opParameter is nullptr!"; + return nullptr; + } + MS_ASSERT(desc.type == schema::PrimitiveType_Pooling); + auto *kernel = new (std::nothrow) PoolingInt8CPUKernel(opParameter, inputs, outputs, ctx, primitive); + if (kernel == nullptr) { + MS_LOG(ERROR) << "new PoolingInt8CPUKernel fail!"; + free(opParameter); + return nullptr; + } + auto ret = kernel->Init(); + if (ret != RET_OK) { + delete kernel; + MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " + << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + return nullptr; + } + return kernel; +} +REG_KERNEL(kCPU, kNumberTypeInt8, PrimitiveType_Pooling, CpuPoolingInt8KernelCreator) + } // namespace mindspore::kernel diff --git a/mindspore/lite/src/runtime/kernel/arm/int8/power_int8.cc b/mindspore/lite/src/runtime/kernel/arm/int8/power_int8.cc index ce3966a7fe..117d7bc488 100644 --- a/mindspore/lite/src/runtime/kernel/arm/int8/power_int8.cc +++ b/mindspore/lite/src/runtime/kernel/arm/int8/power_int8.cc @@ -19,11 +19,15 @@ #include "nnacl/int8/power_int8.h" #include "include/errorcode.h" #include "src/runtime/runtime_api.h" +#include "src/kernel_registry.h" using mindspore::kernel::KERNEL_ARCH::kCPU; using mindspore::lite::RET_ERROR; using mindspore::lite::RET_OK; +using mindspore::lite::KernelRegistrar; +using mindspore::schema::PrimitiveType_Power; + namespace mindspore::kernel { int PowerInt8CPUKernel::Init() { @@ -104,4 +108,30 @@ int PowerInt8CPUKernel::Run() { } return ret; } +kernel::LiteKernel *CpuPowerInt8KernelCreator(const std::vector &inputs, + const std::vector &outputs, OpParameter *opParameter, + const lite::InnerContext *ctx, const kernel::KernelKey &desc, + const mindspore::lite::PrimitiveC *primitive) { + if (opParameter == nullptr) { + MS_LOG(ERROR) << "Input opParameter is nullptr!"; + return nullptr; + } + MS_ASSERT(desc.type == schema::PrimitiveType_Power); + auto *kernel = new (std::nothrow) PowerInt8CPUKernel(opParameter, inputs, outputs, ctx, primitive); + if (kernel == nullptr) { + MS_LOG(ERROR) << "new PowerInt8CPUKernel fail!"; + free(opParameter); + return nullptr; + } + auto ret = kernel->Init(); + if (ret != RET_OK) { + delete kernel; + MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " + << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + return nullptr; + } + return kernel; +} +REG_KERNEL(kCPU, kNumberTypeInt8, PrimitiveType_Power, CpuPowerInt8KernelCreator) + } // namespace mindspore::kernel diff --git a/mindspore/lite/src/runtime/kernel/arm/int8/reduce_int8.cc b/mindspore/lite/src/runtime/kernel/arm/int8/reduce_int8.cc index 31a34ec03a..92a8fe5db4 100644 --- a/mindspore/lite/src/runtime/kernel/arm/int8/reduce_int8.cc +++ b/mindspore/lite/src/runtime/kernel/arm/int8/reduce_int8.cc @@ -33,6 +33,10 @@ using mindspore::schema::ReduceMode_ReduceProd; using mindspore::schema::ReduceMode_ReduceSum; using mindspore::schema::ReduceMode_ReduceSumSquare; +using mindspore::kernel::KERNEL_ARCH::kCPU; +using mindspore::schema::PrimitiveType_Mean; +using mindspore::schema::PrimitiveType_Reduce; + namespace mindspore::kernel { int ReduceInt8CPUKernel::Init() { auto ret = ReduceBaseCPUKernel::Init(); @@ -309,4 +313,37 @@ int ReduceInt8CPUKernel::CallReduceUnit(int task_id) { } return ret; } +kernel::LiteKernel *CpuReduceInt8KernelCreator(const std::vector &inputs, + const std::vector &outputs, OpParameter *opParameter, + const lite::InnerContext *ctx, const kernel::KernelKey &desc, + const mindspore::lite::PrimitiveC *primitive) { + MS_ASSERT(opParameter != nullptr); + MS_ASSERT(desc.type == schema::PrimitiveType_Reduce); + if (opParameter == nullptr) { + MS_LOG(ERROR) << "Reduce opParameter nullptr"; + return nullptr; + } + if (desc.type != schema::PrimitiveType_Reduce) { + MS_LOG(ERROR) << "Reduce op desc.type should be PrimitiveType_Reduce, got " << desc.type; + free(opParameter); + return nullptr; + } + auto *kernel = new (std::nothrow) ReduceInt8CPUKernel(opParameter, inputs, outputs, ctx, primitive); + if (kernel == nullptr) { + MS_LOG(ERROR) << "Reduce new ReduceCPUKernel failed."; + free(opParameter); + return nullptr; + } + auto ret = kernel->Init(); + if (ret != RET_OK) { + MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " + << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + delete kernel; + return nullptr; + } + return kernel; +} +REG_KERNEL(kCPU, kNumberTypeInt8, PrimitiveType_Reduce, CpuReduceInt8KernelCreator) +REG_KERNEL(kCPU, kNumberTypeInt8, PrimitiveType_Mean, CpuReduceInt8KernelCreator) + } // namespace mindspore::kernel diff --git a/mindspore/lite/src/runtime/kernel/arm/int8/reshape_int8.cc b/mindspore/lite/src/runtime/kernel/arm/int8/reshape_int8.cc index 75efecc8cb..3f6f3ffb49 100644 --- a/mindspore/lite/src/runtime/kernel/arm/int8/reshape_int8.cc +++ b/mindspore/lite/src/runtime/kernel/arm/int8/reshape_int8.cc @@ -19,11 +19,15 @@ #include "nnacl/int8/reshape_int8.h" #include "schema/model_generated.h" #include "include/errorcode.h" +#include "src/kernel_registry.h" using mindspore::kernel::KERNEL_ARCH::kCPU; using mindspore::lite::RET_ERROR; using mindspore::lite::RET_OK; +using mindspore::lite::KernelRegistrar; +using mindspore::schema::PrimitiveType_Reshape; + namespace mindspore::kernel { int ReshapeInt8CPUKernel::Init() { @@ -76,4 +80,30 @@ int ReshapeInt8CPUKernel::DoExecute(int task_id) { Int8Reshape(cur_input0_data, cur_output_data, real_dst_count, reshape_param_->quant_para_); return lite::RET_OK; } +kernel::LiteKernel *CpuReshapeInt8KernelCreator(const std::vector &inputs, + const std::vector &outputs, OpParameter *opParameter, + const InnerContext *ctx, const kernel::KernelKey &desc, + const mindspore::lite::PrimitiveC *primitive) { + if (opParameter == nullptr) { + MS_LOG(ERROR) << "Input opParameter is nullptr!"; + return nullptr; + } + MS_ASSERT(desc.type == schema::PrimitiveType_Reshape); + auto *kernel = new (std::nothrow) ReshapeInt8CPUKernel(opParameter, inputs, outputs, ctx, primitive); + if (kernel == nullptr) { + MS_LOG(ERROR) << "new ReshapeInt8CPUKernel fail!"; + free(opParameter); + return nullptr; + } + auto ret = kernel->Init(); + if (ret != RET_OK) { + delete kernel; + MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " + << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + return nullptr; + } + return kernel; +} +REG_KERNEL(kCPU, kNumberTypeInt8, PrimitiveType_Reshape, CpuReshapeInt8KernelCreator) + } // namespace mindspore::kernel diff --git a/mindspore/lite/src/runtime/kernel/arm/int8/resize_int8.cc b/mindspore/lite/src/runtime/kernel/arm/int8/resize_int8.cc index 675d103e3b..f0ab251a58 100644 --- a/mindspore/lite/src/runtime/kernel/arm/int8/resize_int8.cc +++ b/mindspore/lite/src/runtime/kernel/arm/int8/resize_int8.cc @@ -29,6 +29,8 @@ using mindspore::lite::RET_INVALID_OP_ATTR; using mindspore::lite::RET_NULL_PTR; using mindspore::lite::RET_OK; +using mindspore::lite::KernelRegistrar; + namespace mindspore::kernel { int ResizeInt8CPUKernel::Init() { auto ret = ResizeBaseCPUKernel::Init(); @@ -126,4 +128,31 @@ int ResizeInt8CPUKernel::Run() { } return RET_OK; } +kernel::LiteKernel *CpuResizeInt8KernelCreator(const std::vector &inputs, + const std::vector &outputs, OpParameter *opParameter, + const lite::InnerContext *ctx, const kernel::KernelKey &desc, + const mindspore::lite::PrimitiveC *primitive) { + if (opParameter == nullptr) { + MS_LOG(ERROR) << "Input opParameter is nullptr!"; + return nullptr; + } + MS_ASSERT(desc.type == schema::PrimitiveType_Resize); + auto *kernel = new (std::nothrow) ResizeInt8CPUKernel(opParameter, inputs, outputs, ctx, primitive); + if (kernel == nullptr) { + MS_LOG(ERROR) << "new ResizeCPUKernel fail!"; + free(opParameter); + return nullptr; + } + auto ret = kernel->Init(); + if (ret != RET_OK) { + delete kernel; + MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " + << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + return nullptr; + } + + return kernel; +} +REG_KERNEL(kCPU, kNumberTypeInt8, PrimitiveType_Resize, CpuResizeInt8KernelCreator) + } // namespace mindspore::kernel diff --git a/mindspore/lite/src/runtime/kernel/arm/int8/softmax_int8.cc b/mindspore/lite/src/runtime/kernel/arm/int8/softmax_int8.cc index fa99953900..eaec1fa38f 100644 --- a/mindspore/lite/src/runtime/kernel/arm/int8/softmax_int8.cc +++ b/mindspore/lite/src/runtime/kernel/arm/int8/softmax_int8.cc @@ -20,10 +20,15 @@ #include "schema/model_generated.h" #include "src/runtime/runtime_api.h" #include "include/errorcode.h" +#include "src/kernel_registry.h" using mindspore::lite::RET_ERROR; using mindspore::lite::RET_OK; +using mindspore::lite::KernelRegistrar; +using mindspore::lite::RET_NULL_PTR; +using mindspore::schema::PrimitiveType_SoftMax; + namespace mindspore::kernel { int SoftmaxInt8CPUKernel::Init() { @@ -123,4 +128,30 @@ int SoftmaxInt8CPUKernel::Run() { } return ret; } +kernel::LiteKernel *CpuSoftmaxInt8KernelCreator(const std::vector &inputs, + const std::vector &outputs, OpParameter *opParameter, + const lite::InnerContext *ctx, const kernel::KernelKey &desc, + const mindspore::lite::PrimitiveC *primitive) { + if (opParameter == nullptr) { + MS_LOG(ERROR) << "Input opParameter is nullptr!"; + return nullptr; + } + MS_ASSERT(desc.type == schema::PrimitiveType_SoftMax); + auto *kernel = new (std::nothrow) SoftmaxInt8CPUKernel(opParameter, inputs, outputs, ctx, primitive); + if (kernel == nullptr) { + MS_LOG(ERROR) << "new SoftmaxCPUKernel fail!"; + free(opParameter); + return nullptr; + } + auto ret = kernel->Init(); + if (ret != RET_OK) { + delete kernel; + MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " + << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + return nullptr; + } + return kernel; +} +REG_KERNEL(kCPU, kNumberTypeInt8, PrimitiveType_SoftMax, CpuSoftmaxInt8KernelCreator) + } // namespace mindspore::kernel diff --git a/mindspore/lite/src/runtime/kernel/arm/int8/split_int8.cc b/mindspore/lite/src/runtime/kernel/arm/int8/split_int8.cc index be906a85f8..436222f370 100644 --- a/mindspore/lite/src/runtime/kernel/arm/int8/split_int8.cc +++ b/mindspore/lite/src/runtime/kernel/arm/int8/split_int8.cc @@ -20,11 +20,15 @@ #include "nnacl/int8/split_int8.h" #include "include/errorcode.h" #include "src/runtime/runtime_api.h" +#include "src/kernel_registry.h" using mindspore::kernel::KERNEL_ARCH::kCPU; using mindspore::lite::RET_ERROR; using mindspore::lite::RET_OK; +using mindspore::lite::KernelRegistrar; +using mindspore::schema::PrimitiveType_Split; + namespace mindspore::kernel { int SplitInt8CPUKernel::Init() { @@ -97,4 +101,30 @@ int SplitInt8CPUKernel::Run() { return RET_OK; } +kernel::LiteKernel *CpuSplitInt8KernelCreator(const std::vector &inputs, + const std::vector &outputs, OpParameter *opParameter, + const InnerContext *ctx, const kernel::KernelKey &desc, + const mindspore::lite::PrimitiveC *primitive) { + if (opParameter == nullptr) { + MS_LOG(ERROR) << "Input opParameter is nullptr!"; + return nullptr; + } + MS_ASSERT(desc.type == schema::PrimitiveType_Split); + auto *kernel = new (std::nothrow) SplitInt8CPUKernel(opParameter, inputs, outputs, ctx, primitive); + if (kernel == nullptr) { + MS_LOG(ERROR) << "new SplitCPUKernel fail!"; + free(opParameter); + return nullptr; + } + auto ret = kernel->Init(); + if (ret != RET_OK) { + delete kernel; + MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " + << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + return nullptr; + } + return kernel; +} +REG_KERNEL(kCPU, kNumberTypeInt8, PrimitiveType_Split, CpuSplitInt8KernelCreator) + } // namespace mindspore::kernel diff --git a/mindspore/lite/src/runtime/kernel/arm/int8/squeeze_int8.cc b/mindspore/lite/src/runtime/kernel/arm/int8/squeeze_int8.cc index b13ff764aa..973f856ad2 100644 --- a/mindspore/lite/src/runtime/kernel/arm/int8/squeeze_int8.cc +++ b/mindspore/lite/src/runtime/kernel/arm/int8/squeeze_int8.cc @@ -21,11 +21,15 @@ #include "schema/model_generated.h" #include "src/runtime/runtime_api.h" #include "include/errorcode.h" +#include "src/kernel_registry.h" using mindspore::kernel::KERNEL_ARCH::kCPU; using mindspore::lite::RET_ERROR; using mindspore::lite::RET_OK; +using mindspore::lite::KernelRegistrar; +using mindspore::schema::PrimitiveType_Squeeze; + namespace mindspore::kernel { int SqueezeInt8CPUKernel::Init() { @@ -194,5 +198,30 @@ int SqueezeInt8CPUKernel::DoExecute(int task_id) { Squeeze(&input_data, output_data, task_id, quant_Squeeze_parm_, para_, data_size); return RET_OK; } +kernel::LiteKernel *CpuSqueezeInt8KernelCreator(const std::vector &inputs, + const std::vector &outputs, OpParameter *opParameter, + const InnerContext *ctx, const kernel::KernelKey &desc, + const mindspore::lite::PrimitiveC *primitive) { + if (opParameter == nullptr) { + MS_LOG(ERROR) << "Input opParameter is nullptr!"; + return nullptr; + } + MS_ASSERT(desc.type == schema::PrimitiveType_Squeeze); + auto *kernel = new (std::nothrow) SqueezeInt8CPUKernel(opParameter, inputs, outputs, ctx, primitive); + if (kernel == nullptr) { + MS_LOG(ERROR) << "new SqueezeCPUKernel fail!"; + free(opParameter); + return nullptr; + } + auto ret = kernel->Init(); + if (ret != RET_OK) { + delete kernel; + MS_LOG(ERROR) << "Init kernel failed, name: " << opParameter->name_ << ", type: " + << schema::EnumNamePrimitiveType(static_cast(opParameter->type_)); + return nullptr; + } + return kernel; +} +REG_KERNEL(kCPU, kNumberTypeInt8, PrimitiveType_Squeeze, CpuSqueezeInt8KernelCreator) } // namespace mindspore::kernel