diff --git a/mindspore/lite/nnacl/reshape_parameter.h b/mindspore/lite/nnacl/reshape_parameter.h index 101ca27329..1e64e8a3f6 100644 --- a/mindspore/lite/nnacl/reshape_parameter.h +++ b/mindspore/lite/nnacl/reshape_parameter.h @@ -29,6 +29,8 @@ typedef struct ReshapeQuantArg { typedef struct ReshapeParameter { // primitive parameter OpParameter op_parameter_; + int shape_dim_; + int shape_[MAX_SHAPE_SIZE]; // other parameter ReshapeQuantArg quant_para_; diff --git a/mindspore/lite/src/ops/populate/pooling_populate.cc b/mindspore/lite/src/ops/populate/pooling_populate.cc index 828d58fbaf..4943ff9275 100644 --- a/mindspore/lite/src/ops/populate/pooling_populate.cc +++ b/mindspore/lite/src/ops/populate/pooling_populate.cc @@ -43,6 +43,18 @@ OpParameter *PopulatePoolingParameter(const mindspore::lite::PrimitiveC *primiti pooling_param->stride_w_ = pooling_primitive->GetStrideW(); pooling_param->stride_h_ = pooling_primitive->GetStrideH(); pooling_param->avg_mode_ = pooling_primitive->GetAvgMode(); + auto pad_mode = pooling_primitive->GetPadMode(); + switch (pad_mode) { + case schema::PadMode_SAME_UPPER: + pooling_param->pad_mode_ = Pad_Same; + break; + case schema::PadMode_VALID: + pooling_param->pad_mode_ = Pad_Valid; + break; + default: + pooling_param->pad_mode_ = Pad_No; + break; + } auto is_global = pooling_primitive->GetGlobal(); pooling_param->global_ = is_global; diff --git a/mindspore/lite/src/ops/populate/reshape_populate.cc b/mindspore/lite/src/ops/populate/reshape_populate.cc index 7008cb63be..556ba8d306 100644 --- a/mindspore/lite/src/ops/populate/reshape_populate.cc +++ b/mindspore/lite/src/ops/populate/reshape_populate.cc @@ -19,6 +19,7 @@ #include "src/common/log_adapter.h" #include "src/tensor.h" #include "nnacl/reshape_parameter.h" +#include "src/ops/reshape.h" namespace mindspore { namespace lite { @@ -31,6 +32,13 @@ OpParameter *PopulateReshapeParameter(const mindspore::lite::PrimitiveC *primiti } memset(reshape_param, 0, sizeof(ReshapeParameter)); reshape_param->op_parameter_.type_ = primitive->Type(); + auto reshape_lite_primitive = (lite::Reshape *)primitive; + auto shape = reshape_lite_primitive->GetShape(); + reshape_param->shape_dim_ = shape.size(); + int i = 0; + for (auto iter = shape.begin(); iter != shape.end(); iter++) { + reshape_param->shape_[i++] = *iter; + } return reinterpret_cast(reshape_param); } diff --git a/mindspore/lite/src/ops/reshape.cc b/mindspore/lite/src/ops/reshape.cc index 67956011bd..85c3e75c0d 100644 --- a/mindspore/lite/src/ops/reshape.cc +++ b/mindspore/lite/src/ops/reshape.cc @@ -176,13 +176,13 @@ int Reshape::InferShape(std::vector inputs_, std::vector out return RET_INFER_INVALID; } - std::vector out_shape; + out_shape_.clear(); if (inputs_.size() == kDoubleNum) { auto shape_tensor = inputs_.at(1); if (shape_tensor->IsConst()) { if (shape_tensor->data_c() == nullptr || (shape_tensor->shape().size() == 1 && shape_tensor->shape()[0] == 0)) { MS_LOG(DEBUG) << "reshape to a scalar."; - output->set_shape(out_shape); + output->set_shape(out_shape_); return RET_OK; } } @@ -194,23 +194,23 @@ int Reshape::InferShape(std::vector inputs_, std::vector out switch (shape_tensor->data_type()) { case kNumberTypeInt8: { auto data = reinterpret_cast(shape_tensor->MutableData()); - CalShape(data, inputs_, &out_shape, shape_size); + CalShape(data, inputs_, &out_shape_, shape_size); } break; case kNumberTypeInt32: { auto data = reinterpret_cast(shape_tensor->MutableData()); - CalShape(data, inputs_, &out_shape, shape_size); + CalShape(data, inputs_, &out_shape_, shape_size); } break; case kNumberTypeInt64: { auto data = reinterpret_cast(shape_tensor->MutableData()); - CalShape(data, inputs_, &out_shape, shape_size); + CalShape(data, inputs_, &out_shape_, shape_size); } break; case kNumberTypeFloat: { auto data = reinterpret_cast(shape_tensor->MutableData()); - CalShape(data, inputs_, &out_shape, shape_size); + CalShape(data, inputs_, &out_shape_, shape_size); } break; case kNumberTypeUInt32: { auto data = reinterpret_cast(shape_tensor->MutableData()); - CalShape(data, inputs_, &out_shape, shape_size); + CalShape(data, inputs_, &out_shape_, shape_size); } break; default: { MS_LOG(ERROR) << "Reshape weight tensor has unsupported dataType: " << shape_tensor->data_type(); @@ -219,18 +219,18 @@ int Reshape::InferShape(std::vector inputs_, std::vector out } } else if (inputs_.size() == kSingleNum) { for (size_t i = 0; i < GetShape().size(); ++i) { - out_shape.push_back(GetShape().at(i)); + out_shape_.push_back(GetShape().at(i)); } } else { MS_LOG(ERROR) << "inputs tensor size invalid."; return RET_INFER_ERR; } - auto ret = CalNewShape(inputs_.front(), &out_shape); + auto ret = CalNewShape(inputs_.front(), &out_shape_); if (ret != RET_OK) { MS_LOG(ERROR) << "CalNewShape error"; return ret; } - output->set_shape(out_shape); + output->set_shape(out_shape_); return RET_OK; } } // namespace lite diff --git a/mindspore/lite/src/ops/reshape.h b/mindspore/lite/src/ops/reshape.h index 0f423236c1..38bdcd7691 100644 --- a/mindspore/lite/src/ops/reshape.h +++ b/mindspore/lite/src/ops/reshape.h @@ -42,9 +42,11 @@ class Reshape : public PrimitiveC { int InferShape(std::vector inputs_, std::vector outputs_) override; int GetFormat() const; std::vector GetShape() const; + std::vector GetOutputShape() { return out_shape_; } private: int CalNewShape(const lite::Tensor *in_tensor, std::vector *out_shape) const; + std::vector out_shape_; }; } // namespace lite } // namespace mindspore diff --git a/mindspore/lite/src/runtime/kernel/npu/activation_npu.cc b/mindspore/lite/src/runtime/kernel/npu/activation_npu.cc index c12ae00244..d22072e0a1 100644 --- a/mindspore/lite/src/runtime/kernel/npu/activation_npu.cc +++ b/mindspore/lite/src/runtime/kernel/npu/activation_npu.cc @@ -15,7 +15,6 @@ */ #include "src/runtime/kernel/npu/activation_npu.h" -#include "include/graph/op/all_ops.h" #include "src/kernel_registry.h" using mindspore::kernel::KERNEL_ARCH::kNPU; @@ -28,7 +27,7 @@ int ActivationNPUKernel::IsSupport(const std::vector &inputs, if (act_param_->type_ != schema::ActivationType_RELU && act_param_->type_ != schema::ActivationType_RELU6 && act_param_->type_ != schema::ActivationType_SIGMOID && act_param_->type_ != schema::ActivationType_TANH && act_param_->type_ != schema::ActivationType_HSIGMOID && act_param_->type_ != schema::ActivationType_LEAKY_RELU) { - MS_LOG(ERROR) << "Unsupport activation type for activation op " << name_ << "when running npu"; + MS_LOG(ERROR) << "Unsupported activation type for activation op " << name_ << "when running npu"; return RET_ERROR; } return RET_OK; @@ -64,7 +63,7 @@ int ActivationNPUKernel::SetNPUInputs(const std::vector &inputs, act_->set_attr_mode(14); break; default: - MS_LOG(ERROR) << "Unsupport activation type for activation op " << name_ << "when running npu"; + MS_LOG(ERROR) << "Unsupported activation type for activation op " << name_ << "when running npu"; return RET_ERROR; } return RET_OK; diff --git a/mindspore/lite/src/runtime/kernel/npu/activation_npu.h b/mindspore/lite/src/runtime/kernel/npu/activation_npu.h index f477b07702..3336e1fce8 100644 --- a/mindspore/lite/src/runtime/kernel/npu/activation_npu.h +++ b/mindspore/lite/src/runtime/kernel/npu/activation_npu.h @@ -18,10 +18,8 @@ #include #include "include/graph/op/all_ops.h" -#include "include/graph/compatible/all_ops.h" #include "src/runtime/kernel/npu/npu_kernel.h" #include "nnacl/fp32/activation_fp32.h" - namespace mindspore::kernel { class ActivationNPUKernel : public NPUKernel { public: diff --git a/mindspore/lite/src/runtime/kernel/npu/arithmetic_npu.cc b/mindspore/lite/src/runtime/kernel/npu/arithmetic_npu.cc index 143bf28cdc..f3e9ed968a 100644 --- a/mindspore/lite/src/runtime/kernel/npu/arithmetic_npu.cc +++ b/mindspore/lite/src/runtime/kernel/npu/arithmetic_npu.cc @@ -16,7 +16,6 @@ #include "src/runtime/kernel/npu/arithmetic_npu.h" #include -#include "include/graph/op/all_ops.h" #include "src/kernel_registry.h" using mindspore::kernel::KERNEL_ARCH::kNPU; diff --git a/mindspore/lite/src/runtime/kernel/npu/arithmetic_npu.h b/mindspore/lite/src/runtime/kernel/npu/arithmetic_npu.h index 48be917d08..35780f9355 100644 --- a/mindspore/lite/src/runtime/kernel/npu/arithmetic_npu.h +++ b/mindspore/lite/src/runtime/kernel/npu/arithmetic_npu.h @@ -17,9 +17,9 @@ #ifndef MINDSPORE_LITE_SRC_RUNTIME_KERNEL_NPU_ARITHMETIC_NPU_H_ #define MINDSPORE_LITE_SRC_RUNTIME_KERNEL_NPU_ARITHMETIC_NPU_H_ #include +#include "include/graph/op/all_ops.h" #include "nnacl/arithmetic.h" #include "src/runtime/kernel/npu/npu_kernel.h" -#include "include/graph/op/all_ops.h" namespace mindspore::kernel { class ArithmeticNPUKernel : public NPUKernel { public: diff --git a/mindspore/lite/src/runtime/kernel/npu/arithmetic_self_npu.cc b/mindspore/lite/src/runtime/kernel/npu/arithmetic_self_npu.cc index 6f1f3014a5..a1c11206a2 100644 --- a/mindspore/lite/src/runtime/kernel/npu/arithmetic_self_npu.cc +++ b/mindspore/lite/src/runtime/kernel/npu/arithmetic_self_npu.cc @@ -16,7 +16,6 @@ #include "src/runtime/kernel/npu/arithmetic_self_npu.h" #include -#include "include/graph/op/all_ops.h" #include "src/kernel_registry.h" using mindspore::kernel::KERNEL_ARCH::kNPU; diff --git a/mindspore/lite/src/runtime/kernel/npu/arithmetic_self_npu.h b/mindspore/lite/src/runtime/kernel/npu/arithmetic_self_npu.h index a4fe79790b..d841dc6f51 100644 --- a/mindspore/lite/src/runtime/kernel/npu/arithmetic_self_npu.h +++ b/mindspore/lite/src/runtime/kernel/npu/arithmetic_self_npu.h @@ -17,8 +17,8 @@ #ifndef MINDSPORE_LITE_SRC_RUNTIME_KERNEL_NPU_ARITHMETICSELF_NPU_H_ #define MINDSPORE_LITE_SRC_RUNTIME_KERNEL_NPU_ARITHMETICSELF_NPU_H_ #include -#include "src/runtime/kernel/npu/npu_kernel.h" #include "include/graph/op/math_defs.h" +#include "src/runtime/kernel/npu/npu_kernel.h" namespace mindspore::kernel { class ArithmeticSelfNPUKernel : public NPUKernel { public: diff --git a/mindspore/lite/src/runtime/kernel/npu/batchnorm_npu.h b/mindspore/lite/src/runtime/kernel/npu/batchnorm_npu.h index ae77b4c55c..9e62207498 100644 --- a/mindspore/lite/src/runtime/kernel/npu/batchnorm_npu.h +++ b/mindspore/lite/src/runtime/kernel/npu/batchnorm_npu.h @@ -17,7 +17,6 @@ #define MINDSPORE_LITE_SRC_RUNTIME_KERNEL_NPU_BATCHNORM_NPU_H_ #include -#include "include/graph/op/all_ops.h" #include "include/graph/compatible/all_ops.h" #include "src/runtime/kernel/npu/npu_kernel.h" #include "nnacl/batchnorm_parameter.h" diff --git a/mindspore/lite/src/runtime/kernel/npu/cast_npu.h b/mindspore/lite/src/runtime/kernel/npu/cast_npu.h index 7dd30cb2c0..fe3acb3a7d 100644 --- a/mindspore/lite/src/runtime/kernel/npu/cast_npu.h +++ b/mindspore/lite/src/runtime/kernel/npu/cast_npu.h @@ -17,9 +17,8 @@ #ifndef MINDSPORE_LITE_SRC_RUNTIME_KERNEL_NPU_CAST_NPU_H_ #define MINDSPORE_LITE_SRC_RUNTIME_KERNEL_NPU_CAST_NPU_H_ #include -#include "src/runtime/kernel/npu/npu_kernel.h" #include "include/graph/op/all_ops.h" - +#include "src/runtime/kernel/npu/npu_kernel.h" namespace mindspore::kernel { class CastNPUKernel : public NPUKernel { public: diff --git a/mindspore/lite/src/runtime/kernel/npu/concat_npu.h b/mindspore/lite/src/runtime/kernel/npu/concat_npu.h index 4a27fba4aa..35ba693a9b 100644 --- a/mindspore/lite/src/runtime/kernel/npu/concat_npu.h +++ b/mindspore/lite/src/runtime/kernel/npu/concat_npu.h @@ -17,10 +17,9 @@ #ifndef MINDSPORE_LITE_SRC_RUNTIME_KERNEL_NPU_CONCAT_NPU_H_ #define MINDSPORE_LITE_SRC_RUNTIME_KERNEL_NPU_CONCAT_NPU_H_ #include +#include "include/graph/op/all_ops.h" #include "nnacl/concat_parameter.h" #include "src/runtime/kernel/npu/npu_kernel.h" -#include "include/graph/op/all_ops.h" - namespace mindspore::kernel { class ConcatNPUKernel : public NPUKernel { public: diff --git a/mindspore/lite/src/runtime/kernel/npu/convolution_base_npu.h b/mindspore/lite/src/runtime/kernel/npu/convolution_base_npu.h index 31cce4fe99..8df99eff7d 100644 --- a/mindspore/lite/src/runtime/kernel/npu/convolution_base_npu.h +++ b/mindspore/lite/src/runtime/kernel/npu/convolution_base_npu.h @@ -18,10 +18,9 @@ #include #include -#include "src/runtime/kernel/npu/npu_kernel.h" #include "include/graph/op/all_ops.h" +#include "src/runtime/kernel/npu/npu_kernel.h" #include "nnacl/conv_parameter.h" - namespace mindspore::kernel { class ConvolutionBaseNPUKernel : public NPUKernel { public: diff --git a/mindspore/lite/src/runtime/kernel/npu/convolution_depthwise_npu.cc b/mindspore/lite/src/runtime/kernel/npu/convolution_depthwise_npu.cc index 206d9aca25..e463e241c4 100644 --- a/mindspore/lite/src/runtime/kernel/npu/convolution_depthwise_npu.cc +++ b/mindspore/lite/src/runtime/kernel/npu/convolution_depthwise_npu.cc @@ -16,8 +16,6 @@ #include "src/runtime/kernel/npu/convolution_depthwise_npu.h" #include "src/kernel_registry.h" -#include "src/runtime/agent/npu/npu_converter_utils.h" - using mindspore::kernel::KERNEL_ARCH::kNPU; using mindspore::lite::KernelRegistrar; using mindspore::schema::PrimitiveType_DepthwiseConv2D; diff --git a/mindspore/lite/src/runtime/kernel/npu/convolution_depthwise_npu.h b/mindspore/lite/src/runtime/kernel/npu/convolution_depthwise_npu.h index fb605b5907..cf2e6e33bb 100644 --- a/mindspore/lite/src/runtime/kernel/npu/convolution_depthwise_npu.h +++ b/mindspore/lite/src/runtime/kernel/npu/convolution_depthwise_npu.h @@ -18,9 +18,7 @@ #include #include "include/graph/op/all_ops.h" -#include "include/graph/compatible/all_ops.h" #include "src/runtime/kernel/npu/convolution_base_npu.h" -#include "src/runtime/kernel/npu/npu_kernel.h" #include "nnacl/conv_parameter.h" namespace mindspore::kernel { diff --git a/mindspore/lite/src/runtime/kernel/npu/convolution_npu.cc b/mindspore/lite/src/runtime/kernel/npu/convolution_npu.cc index 4187f150b5..ca7383c88e 100644 --- a/mindspore/lite/src/runtime/kernel/npu/convolution_npu.cc +++ b/mindspore/lite/src/runtime/kernel/npu/convolution_npu.cc @@ -15,7 +15,6 @@ */ #include "src/runtime/kernel/npu/convolution_npu.h" -#include "src/runtime/agent/npu/npu_converter_utils.h" using mindspore::kernel::KERNEL_ARCH::kNPU; using mindspore::lite::KernelRegistrar; diff --git a/mindspore/lite/src/runtime/kernel/npu/deconvolution_npu.cc b/mindspore/lite/src/runtime/kernel/npu/deconvolution_npu.cc index 3a936f638e..69bda798c7 100644 --- a/mindspore/lite/src/runtime/kernel/npu/deconvolution_npu.cc +++ b/mindspore/lite/src/runtime/kernel/npu/deconvolution_npu.cc @@ -15,8 +15,6 @@ */ #include "src/runtime/kernel/npu/deconvolution_npu.h" -#include "src/runtime/agent/npu/npu_converter_utils.h" - using mindspore::kernel::KERNEL_ARCH::kNPU; using mindspore::lite::KernelRegistrar; using mindspore::schema::PrimitiveType_DeConv2D; diff --git a/mindspore/lite/src/runtime/kernel/npu/eltwise_npu.cc b/mindspore/lite/src/runtime/kernel/npu/eltwise_npu.cc index c5c82793f3..d3b7f230c1 100644 --- a/mindspore/lite/src/runtime/kernel/npu/eltwise_npu.cc +++ b/mindspore/lite/src/runtime/kernel/npu/eltwise_npu.cc @@ -15,7 +15,6 @@ */ #include "src/runtime/kernel/npu/eltwise_npu.h" -#include "include/graph/op/all_ops.h" #include "src/kernel_registry.h" #include "src/runtime/agent/npu/npu_converter_utils.h" diff --git a/mindspore/lite/src/runtime/kernel/npu/eltwise_npu.h b/mindspore/lite/src/runtime/kernel/npu/eltwise_npu.h index ce0a55141b..96893e5d31 100644 --- a/mindspore/lite/src/runtime/kernel/npu/eltwise_npu.h +++ b/mindspore/lite/src/runtime/kernel/npu/eltwise_npu.h @@ -17,9 +17,9 @@ #ifndef MINDSPORE_LITE_SRC_RUNTIME_KERNEL_NPU_ELTWISE_NPU_H_ #define MINDSPORE_LITE_SRC_RUNTIME_KERNEL_NPU_ELTWISE_NPU_H_ #include +#include "include/graph/op/all_ops.h" #include "src/ops/eltwise.h" #include "src/runtime/kernel/npu/npu_kernel.h" -#include "include/graph/op/all_ops.h" namespace mindspore::kernel { class EltwiseNPUKernel : public NPUKernel { public: diff --git a/mindspore/lite/src/runtime/kernel/npu/fullconnection_npu.h b/mindspore/lite/src/runtime/kernel/npu/fullconnection_npu.h index 280504a4db..1edffd7402 100644 --- a/mindspore/lite/src/runtime/kernel/npu/fullconnection_npu.h +++ b/mindspore/lite/src/runtime/kernel/npu/fullconnection_npu.h @@ -17,8 +17,8 @@ #ifndef MINDSPORE_LITE_SRC_RUNTIME_KERNEL_NPU_FULLCONNECTION_NPU_H_ #define MINDSPORE_LITE_SRC_RUNTIME_KERNEL_NPU_FULLCONNECTION_NPU_H_ #include -#include "src/runtime/kernel/npu/convolution_base_npu.h" #include "include/graph/op/all_ops.h" +#include "src/runtime/kernel/npu/convolution_base_npu.h" #include "nnacl/matmul_parameter.h" namespace mindspore::kernel { class FullconnectionNPUKernel : public ConvolutionBaseNPUKernel { diff --git a/mindspore/lite/src/runtime/kernel/npu/gather_npu.cc b/mindspore/lite/src/runtime/kernel/npu/gather_npu.cc index 0a1b8347bf..7bf752d58f 100644 --- a/mindspore/lite/src/runtime/kernel/npu/gather_npu.cc +++ b/mindspore/lite/src/runtime/kernel/npu/gather_npu.cc @@ -16,7 +16,6 @@ #include "src/runtime/kernel/npu/gather_npu.h" #include "src/kernel_registry.h" -#include "src/runtime/agent/npu/npu_converter_utils.h" using mindspore::kernel::KERNEL_ARCH::kNPU; using mindspore::lite::KernelRegistrar; using mindspore::schema::PrimitiveType_Gather; diff --git a/mindspore/lite/src/runtime/kernel/npu/gather_npu.h b/mindspore/lite/src/runtime/kernel/npu/gather_npu.h index c1c7717a8f..dcbc7537dc 100644 --- a/mindspore/lite/src/runtime/kernel/npu/gather_npu.h +++ b/mindspore/lite/src/runtime/kernel/npu/gather_npu.h @@ -17,8 +17,8 @@ #ifndef MINDSPORE_LITE_SRC_RUNTIME_KERNEL_NPU_GATHER_NPU_H_ #define MINDSPORE_LITE_SRC_RUNTIME_KERNEL_NPU_GATHER_NPU_H_ #include -#include "src/runtime/kernel/npu/npu_kernel.h" #include "include/graph/op/all_ops.h" +#include "src/runtime/kernel/npu/npu_kernel.h" #include "nnacl/gather_parameter.h" namespace mindspore::kernel { class GatherNPUKernel : public NPUKernel { diff --git a/mindspore/lite/src/runtime/kernel/npu/instance_norm_npu.h b/mindspore/lite/src/runtime/kernel/npu/instance_norm_npu.h index 48defd501b..26d90132cc 100644 --- a/mindspore/lite/src/runtime/kernel/npu/instance_norm_npu.h +++ b/mindspore/lite/src/runtime/kernel/npu/instance_norm_npu.h @@ -17,9 +17,9 @@ #ifndef MINDSPORE_LITE_SRC_RUNTIME_KERNEL_NPU_INSTANCE_NORM_NPU_H_ #define MINDSPORE_LITE_SRC_RUNTIME_KERNEL_NPU_INSTANCE_NORM_NPU_H_ #include +#include "include/graph/op/all_ops.h" #include "nnacl/instance_norm_parameter.h" #include "src/runtime/kernel/npu/npu_kernel.h" -#include "include/graph/op/all_ops.h" namespace mindspore::kernel { class InstanceNormNPUKernel : public NPUKernel { public: diff --git a/mindspore/lite/src/runtime/kernel/npu/matmul_npu.h b/mindspore/lite/src/runtime/kernel/npu/matmul_npu.h index 02fc31d3a6..1beef6ac54 100644 --- a/mindspore/lite/src/runtime/kernel/npu/matmul_npu.h +++ b/mindspore/lite/src/runtime/kernel/npu/matmul_npu.h @@ -17,10 +17,10 @@ #ifndef MINDSPORE_LITE_SRC_RUNTIME_KERNEL_NPU_MATMUL_NPU_H_ #define MINDSPORE_LITE_SRC_RUNTIME_KERNEL_NPU_MATMUL_NPU_H_ #include +#include "include/graph/op/all_ops.h" #include "nnacl/matmul_parameter.h" #include "src/runtime/kernel/npu/npu_kernel.h" #include "nnacl/softmax_parameter.h" -#include "include/graph/op/all_ops.h" namespace mindspore::kernel { class MatMulNPUKernel : public NPUKernel { public: diff --git a/mindspore/lite/src/runtime/kernel/npu/npu_kernel.h b/mindspore/lite/src/runtime/kernel/npu/npu_kernel.h index 80d8bf772e..aa8f6cfb7c 100644 --- a/mindspore/lite/src/runtime/kernel/npu/npu_kernel.h +++ b/mindspore/lite/src/runtime/kernel/npu/npu_kernel.h @@ -18,9 +18,9 @@ #define MINDSPORE_LITE_SRC_RUNTIME_KERNEL_NPU_KERNEL_NPU_H_ #include +#include "include/graph/graph.h" #include "src/lite_kernel.h" #include "include/errorcode.h" -#include "include/graph/graph.h" #include "src/kernel_registry.h" using mindspore::kernel::LiteKernel; diff --git a/mindspore/lite/src/runtime/kernel/npu/pad_npu.h b/mindspore/lite/src/runtime/kernel/npu/pad_npu.h index fcb71e877c..2310663122 100644 --- a/mindspore/lite/src/runtime/kernel/npu/pad_npu.h +++ b/mindspore/lite/src/runtime/kernel/npu/pad_npu.h @@ -17,10 +17,10 @@ #ifndef MINDSPORE_LITE_SRC_RUNTIME_KERNEL_NPU_PAD_NPU_H_ #define MINDSPORE_LITE_SRC_RUNTIME_KERNEL_NPU_PAD_NPU_H_ #include +#include "include/graph/op/all_ops.h" #include "nnacl/pad_parameter.h" #include "src/ops/pad.h" #include "src/runtime/kernel/npu/npu_kernel.h" -#include "include/graph/op/all_ops.h" namespace mindspore::kernel { class PadNPUKernel : public NPUKernel { public: diff --git a/mindspore/lite/src/runtime/kernel/npu/pooling_npu.cc b/mindspore/lite/src/runtime/kernel/npu/pooling_npu.cc index d3063971d0..12587c15ca 100644 --- a/mindspore/lite/src/runtime/kernel/npu/pooling_npu.cc +++ b/mindspore/lite/src/runtime/kernel/npu/pooling_npu.cc @@ -24,6 +24,10 @@ using mindspore::schema::PrimitiveType_Pooling; namespace mindspore::kernel { int PoolingNPUKernel::IsSupport(const std::vector &inputs, const std::vector &outputs, OpParameter *opParameter) { + if (pooling_param_->pad_l_ > pooling_param_->stride_w_ || pooling_param_->pad_u_ > pooling_param_->stride_h_) { + MS_LOG(ERROR) << "Npu pooling does not support pad > stride."; + return RET_ERROR; + } return RET_OK; } diff --git a/mindspore/lite/src/runtime/kernel/npu/reduce_npu.cc b/mindspore/lite/src/runtime/kernel/npu/reduce_npu.cc index 48460972da..15ff4d7ef7 100644 --- a/mindspore/lite/src/runtime/kernel/npu/reduce_npu.cc +++ b/mindspore/lite/src/runtime/kernel/npu/reduce_npu.cc @@ -17,8 +17,6 @@ #include "src/runtime/kernel/npu/reduce_npu.h" #include #include "src/kernel_registry.h" -#include "include/graph/op/all_ops.h" -#include "src/runtime/agent/npu/npu_converter_utils.h" using mindspore::kernel::KERNEL_ARCH::kNPU; using mindspore::lite::KernelRegistrar; using mindspore::schema::PrimitiveType_Reduce; diff --git a/mindspore/lite/src/runtime/kernel/npu/reduce_npu.h b/mindspore/lite/src/runtime/kernel/npu/reduce_npu.h index 81be544b29..ca8c41e643 100644 --- a/mindspore/lite/src/runtime/kernel/npu/reduce_npu.h +++ b/mindspore/lite/src/runtime/kernel/npu/reduce_npu.h @@ -17,9 +17,9 @@ #ifndef MINDSPORE_LITE_SRC_RUNTIME_KERNEL_NPU_REDUCE_NPU_H_ #define MINDSPORE_LITE_SRC_RUNTIME_KERNEL_NPU_REDUCE_NPU_H_ #include +#include "include/graph/op/all_ops.h" #include "nnacl/reduce_parameter.h" #include "src/runtime/kernel/npu/npu_kernel.h" -#include "include/graph/op/all_ops.h" namespace mindspore::kernel { class ReduceNPUKernel : public NPUKernel { public: diff --git a/mindspore/lite/src/runtime/kernel/npu/reshape_npu.cc b/mindspore/lite/src/runtime/kernel/npu/reshape_npu.cc index 01cc4ea89f..8ad53a3318 100644 --- a/mindspore/lite/src/runtime/kernel/npu/reshape_npu.cc +++ b/mindspore/lite/src/runtime/kernel/npu/reshape_npu.cc @@ -15,9 +15,8 @@ */ #include "src/runtime/kernel/npu/reshape_npu.h" +#include #include "src/kernel_registry.h" -#include "include/graph/op/all_ops.h" -#include "src/runtime/agent/npu/npu_converter_utils.h" using mindspore::kernel::KERNEL_ARCH::kNPU; using mindspore::lite::KernelRegistrar; using mindspore::schema::PrimitiveType_Reshape; @@ -25,6 +24,10 @@ using mindspore::schema::PrimitiveType_Reshape; namespace mindspore::kernel { int ReshapeNPUKernel::IsSupport(const std::vector &inputs, const std::vector &outputs, OpParameter *opParameter) { + if (reshape_param_->shape_dim_ == 0) { + MS_LOG(ERROR) << "Npu reshape op only supports const shape."; + return RET_ERROR; + } return RET_OK; } @@ -37,7 +40,17 @@ int ReshapeNPUKernel::SetNPUInputs(const std::vector &inputs, return RET_ERROR; } op_->set_input_x(*npu_inputs[0]); - op_->set_input_shape(*npu_inputs[1]); + + auto shape_op = new (std::nothrow) hiai::op::Const(name_ + "_shape"); + std::vector shape; + for (int i = 0; i < reshape_param_->shape_dim_; i++) { + shape.push_back(reshape_param_->shape_[i]); + } + ge::TensorDesc shape_tensor_desc(ge::Shape({reshape_param_->shape_dim_}), ge::FORMAT_NCHW, ge::DT_INT32); + ge::TensorPtr ai_shape_tensor = std::make_shared(shape_tensor_desc); + ai_shape_tensor->SetData(reinterpret_cast(shape.data()), reshape_param_->shape_dim_ * sizeof(int32_t)); + shape_op->set_attr_value(ai_shape_tensor); + op_->set_input_shape(*shape_op); return RET_OK; } diff --git a/mindspore/lite/src/runtime/kernel/npu/reshape_npu.h b/mindspore/lite/src/runtime/kernel/npu/reshape_npu.h index f6a199c88d..9c44fa2da4 100644 --- a/mindspore/lite/src/runtime/kernel/npu/reshape_npu.h +++ b/mindspore/lite/src/runtime/kernel/npu/reshape_npu.h @@ -17,16 +17,18 @@ #ifndef MINDSPORE_LITE_SRC_RUNTIME_KERNEL_NPU_RESHAPE_NPU_H_ #define MINDSPORE_LITE_SRC_RUNTIME_KERNEL_NPU_RESHAPE_NPU_H_ #include -#include "nnacl/conv_parameter.h" -#include "src/runtime/kernel/npu/npu_kernel.h" #include "include/graph/op/all_ops.h" +#include "nnacl/reshape_parameter.h" +#include "src/runtime/kernel/npu/npu_kernel.h" namespace mindspore::kernel { class ReshapeNPUKernel : public NPUKernel { public: ReshapeNPUKernel(OpParameter *parameter, const std::vector &inputs, const std::vector &outputs, const lite::InnerContext *ctx, const mindspore::lite::PrimitiveC *primitive) - : NPUKernel(parameter, inputs, outputs, ctx, primitive) {} + : NPUKernel(parameter, inputs, outputs, ctx, primitive) { + reshape_param_ = reinterpret_cast(parameter); + } ~ReshapeNPUKernel() override; int IsSupport(const std::vector &inputs, const std::vector &outputs, @@ -37,6 +39,7 @@ class ReshapeNPUKernel : public NPUKernel { private: hiai::op::Reshape *op_ = nullptr; + ReshapeParameter *reshape_param_; }; } // namespace mindspore::kernel #endif // MINDSPORE_LITE_SRC_RUNTIME_KERNEL_NPU_RESHAPE_NPU_H_ diff --git a/mindspore/lite/src/runtime/kernel/npu/resize_npu.cc b/mindspore/lite/src/runtime/kernel/npu/resize_npu.cc index e3e5b98a5b..29bcd0ac10 100644 --- a/mindspore/lite/src/runtime/kernel/npu/resize_npu.cc +++ b/mindspore/lite/src/runtime/kernel/npu/resize_npu.cc @@ -16,7 +16,6 @@ #include "src/runtime/kernel/npu/resize_npu.h" #include -#include "include/graph/op/all_ops.h" #include "src/kernel_registry.h" #include "src/runtime/agent/npu/npu_converter_utils.h" diff --git a/mindspore/lite/src/runtime/kernel/npu/resize_npu.h b/mindspore/lite/src/runtime/kernel/npu/resize_npu.h index f59e27c498..6c15926932 100644 --- a/mindspore/lite/src/runtime/kernel/npu/resize_npu.h +++ b/mindspore/lite/src/runtime/kernel/npu/resize_npu.h @@ -17,10 +17,10 @@ #ifndef MINDSPORE_LITE_SRC_RUNTIME_KERNEL_NPU_RESIZE_NPU_H_ #define MINDSPORE_LITE_SRC_RUNTIME_KERNEL_NPU_RESIZE_NPU_H_ #include +#include "include/graph/op/all_ops.h" #include "nnacl/resize_parameter.h" #include "src/ops/resize.h" #include "src/runtime/kernel/npu/npu_kernel.h" -#include "include/graph/op/all_ops.h" namespace mindspore::kernel { class ResizeNPUKernel : public NPUKernel { public: diff --git a/mindspore/lite/src/runtime/kernel/npu/scale_npu.h b/mindspore/lite/src/runtime/kernel/npu/scale_npu.h index f230d00e3e..4ecb9169fa 100644 --- a/mindspore/lite/src/runtime/kernel/npu/scale_npu.h +++ b/mindspore/lite/src/runtime/kernel/npu/scale_npu.h @@ -17,9 +17,9 @@ #ifndef MINDSPORE_LITE_SRC_RUNTIME_KERNEL_NPU_SCALE_NPU_H_ #define MINDSPORE_LITE_SRC_RUNTIME_KERNEL_NPU_SCALE_NPU_H_ #include +#include "include/graph/op/nn_defs.h" #include "nnacl/scale.h" #include "src/runtime/kernel/npu/npu_kernel.h" -#include "include/graph/op/nn_defs.h" namespace mindspore::kernel { class ScaleNPUKernel : public NPUKernel { public: diff --git a/mindspore/lite/src/runtime/kernel/npu/shape_npu.cc b/mindspore/lite/src/runtime/kernel/npu/shape_npu.cc index 0b718c5237..a1ed3544b8 100644 --- a/mindspore/lite/src/runtime/kernel/npu/shape_npu.cc +++ b/mindspore/lite/src/runtime/kernel/npu/shape_npu.cc @@ -16,7 +16,6 @@ #include "src/runtime/kernel/npu/shape_npu.h" #include "src/kernel_registry.h" -#include "src/runtime/agent/npu/npu_converter_utils.h" using mindspore::kernel::KERNEL_ARCH::kNPU; using mindspore::lite::KernelRegistrar; using mindspore::schema::PrimitiveType_Shape; diff --git a/mindspore/lite/src/runtime/kernel/npu/shape_npu.h b/mindspore/lite/src/runtime/kernel/npu/shape_npu.h index 13ab23a482..ea18bd363a 100644 --- a/mindspore/lite/src/runtime/kernel/npu/shape_npu.h +++ b/mindspore/lite/src/runtime/kernel/npu/shape_npu.h @@ -17,8 +17,8 @@ #ifndef MINDSPORE_LITE_SRC_RUNTIME_KERNEL_NPU_SHAPE_NPU_H_ #define MINDSPORE_LITE_SRC_RUNTIME_KERNEL_NPU_SHAPE_NPU_H_ #include -#include "src/runtime/kernel/npu/npu_kernel.h" #include "include/graph/op/all_ops.h" +#include "src/runtime/kernel/npu/npu_kernel.h" namespace mindspore::kernel { class ShapeNPUKernel : public NPUKernel { public: diff --git a/mindspore/lite/src/runtime/kernel/npu/slice_npu.cc b/mindspore/lite/src/runtime/kernel/npu/slice_npu.cc index 1d23428116..074e5c6eb0 100644 --- a/mindspore/lite/src/runtime/kernel/npu/slice_npu.cc +++ b/mindspore/lite/src/runtime/kernel/npu/slice_npu.cc @@ -16,7 +16,6 @@ #include "src/runtime/kernel/npu/slice_npu.h" #include "src/kernel_registry.h" -#include "src/runtime/agent/npu/npu_converter_utils.h" using mindspore::kernel::KERNEL_ARCH::kNPU; using mindspore::lite::KernelRegistrar; using mindspore::schema::PrimitiveType_Slice; diff --git a/mindspore/lite/src/runtime/kernel/npu/slice_npu.h b/mindspore/lite/src/runtime/kernel/npu/slice_npu.h index 955cdf3632..ce00d3dff8 100644 --- a/mindspore/lite/src/runtime/kernel/npu/slice_npu.h +++ b/mindspore/lite/src/runtime/kernel/npu/slice_npu.h @@ -17,9 +17,9 @@ #ifndef MINDSPORE_LITE_SRC_RUNTIME_KERNEL_NPU_SLICE_NPU_H_ #define MINDSPORE_LITE_SRC_RUNTIME_KERNEL_NPU_SLICE_NPU_H_ #include +#include "include/graph/op/all_ops.h" #include "src/ops/slice.h" #include "src/runtime/kernel/npu/npu_kernel.h" -#include "include/graph/op/all_ops.h" namespace mindspore::kernel { class SliceNPUKernel : public NPUKernel { public: diff --git a/mindspore/lite/src/runtime/kernel/npu/softmax_npu.cc b/mindspore/lite/src/runtime/kernel/npu/softmax_npu.cc index a502a86109..606429e9bb 100644 --- a/mindspore/lite/src/runtime/kernel/npu/softmax_npu.cc +++ b/mindspore/lite/src/runtime/kernel/npu/softmax_npu.cc @@ -16,7 +16,6 @@ #include "src/runtime/kernel/npu/softmax_npu.h" #include "src/kernel_registry.h" - using mindspore::kernel::KERNEL_ARCH::kNPU; using mindspore::lite::KernelRegistrar; using mindspore::schema::PrimitiveType_SoftMax; diff --git a/mindspore/lite/src/runtime/kernel/npu/softmax_npu.h b/mindspore/lite/src/runtime/kernel/npu/softmax_npu.h index f4d069e7cb..05c865419a 100644 --- a/mindspore/lite/src/runtime/kernel/npu/softmax_npu.h +++ b/mindspore/lite/src/runtime/kernel/npu/softmax_npu.h @@ -17,9 +17,9 @@ #ifndef MINDSPORE_LITE_SRC_RUNTIME_KERNEL_NPU_SOFTMAX_NPU_H_ #define MINDSPORE_LITE_SRC_RUNTIME_KERNEL_NPU_SOFTMAX_NPU_H_ #include +#include "include/graph/op/nn_defs.h" #include "src/runtime/kernel/npu/npu_kernel.h" #include "nnacl/softmax_parameter.h" -#include "include/graph/op/nn_defs.h" namespace mindspore::kernel { class SoftmaxNPUKernel : public NPUKernel { public: diff --git a/mindspore/lite/src/runtime/kernel/npu/split_npu.h b/mindspore/lite/src/runtime/kernel/npu/split_npu.h index 61aa18be61..1ee47a4b05 100644 --- a/mindspore/lite/src/runtime/kernel/npu/split_npu.h +++ b/mindspore/lite/src/runtime/kernel/npu/split_npu.h @@ -17,9 +17,9 @@ #ifndef MINDSPORE_LITE_SRC_RUNTIME_KERNEL_NPU_SPLIT_NPU_H_ #define MINDSPORE_LITE_SRC_RUNTIME_KERNEL_NPU_SPLIT_NPU_H_ #include +#include "include/graph/op/all_ops.h" #include "src/ops/split.h" #include "src/runtime/kernel/npu/npu_kernel.h" -#include "include/graph/op/all_ops.h" namespace mindspore::kernel { class SplitNPUKernel : public NPUKernel { public: diff --git a/mindspore/lite/src/runtime/kernel/npu/squeeze_npu.cc b/mindspore/lite/src/runtime/kernel/npu/squeeze_npu.cc index 27fe65c8a4..a70ed57b2e 100644 --- a/mindspore/lite/src/runtime/kernel/npu/squeeze_npu.cc +++ b/mindspore/lite/src/runtime/kernel/npu/squeeze_npu.cc @@ -16,7 +16,6 @@ #include "src/runtime/kernel/npu/squeeze_npu.h" #include "src/kernel_registry.h" -#include "src/runtime/agent/npu/npu_converter_utils.h" using mindspore::kernel::KERNEL_ARCH::kNPU; using mindspore::lite::KernelRegistrar; using mindspore::schema::PrimitiveType_Squeeze; diff --git a/mindspore/lite/src/runtime/kernel/npu/squeeze_npu.h b/mindspore/lite/src/runtime/kernel/npu/squeeze_npu.h index 8b433a045c..a0788959e5 100644 --- a/mindspore/lite/src/runtime/kernel/npu/squeeze_npu.h +++ b/mindspore/lite/src/runtime/kernel/npu/squeeze_npu.h @@ -17,9 +17,9 @@ #ifndef MINDSPORE_LITE_SRC_RUNTIME_KERNEL_NPU_SQUEEZE_NPU_H_ #define MINDSPORE_LITE_SRC_RUNTIME_KERNEL_NPU_SQUEEZE_NPU_H_ #include +#include "include/graph/op/all_ops.h" #include "src/ops/squeeze.h" #include "src/runtime/kernel/npu/npu_kernel.h" -#include "include/graph/op/all_ops.h" namespace mindspore::kernel { class SqueezeNPUKernel : public NPUKernel { public: diff --git a/mindspore/lite/src/runtime/kernel/npu/strided_slice_npu.cc b/mindspore/lite/src/runtime/kernel/npu/strided_slice_npu.cc index 0bfc52e83a..05fe9555cf 100644 --- a/mindspore/lite/src/runtime/kernel/npu/strided_slice_npu.cc +++ b/mindspore/lite/src/runtime/kernel/npu/strided_slice_npu.cc @@ -16,7 +16,6 @@ #include "src/runtime/kernel/npu/strided_slice_npu.h" #include "src/kernel_registry.h" -#include "src/runtime/agent/npu/npu_converter_utils.h" using mindspore::kernel::KERNEL_ARCH::kNPU; using mindspore::lite::KernelRegistrar; using mindspore::schema::PrimitiveType_StridedSlice; diff --git a/mindspore/lite/src/runtime/kernel/npu/strided_slice_npu.h b/mindspore/lite/src/runtime/kernel/npu/strided_slice_npu.h index 728aab7439..59d52d06db 100644 --- a/mindspore/lite/src/runtime/kernel/npu/strided_slice_npu.h +++ b/mindspore/lite/src/runtime/kernel/npu/strided_slice_npu.h @@ -17,10 +17,10 @@ #ifndef MINDSPORE_LITE_SRC_RUNTIME_KERNEL_NPU_STRIDEDSLICE_NPU_H_ #define MINDSPORE_LITE_SRC_RUNTIME_KERNEL_NPU_STRIDEDSLICE_NPU_H_ #include +#include "include/graph/op/all_ops.h" #include "src/ops/strided_slice.h" #include "nnacl/strided_slice_parameter.h" #include "src/runtime/kernel/npu/npu_kernel.h" -#include "include/graph/op/all_ops.h" namespace mindspore::kernel { class StridedSliceNPUKernel : public NPUKernel { public: diff --git a/mindspore/lite/src/runtime/kernel/npu/transpose_npu.cc b/mindspore/lite/src/runtime/kernel/npu/transpose_npu.cc index 259f1147cc..a1c07d660d 100644 --- a/mindspore/lite/src/runtime/kernel/npu/transpose_npu.cc +++ b/mindspore/lite/src/runtime/kernel/npu/transpose_npu.cc @@ -16,7 +16,6 @@ #include "src/runtime/kernel/npu/transpose_npu.h" #include "src/kernel_registry.h" -#include "src/runtime/agent/npu/npu_converter_utils.h" using mindspore::kernel::KERNEL_ARCH::kNPU; using mindspore::lite::KernelRegistrar; using mindspore::schema::PrimitiveType_Nchw2Nhwc; diff --git a/mindspore/lite/src/runtime/kernel/npu/transpose_npu.h b/mindspore/lite/src/runtime/kernel/npu/transpose_npu.h index d914c50c99..3df2b34097 100644 --- a/mindspore/lite/src/runtime/kernel/npu/transpose_npu.h +++ b/mindspore/lite/src/runtime/kernel/npu/transpose_npu.h @@ -17,9 +17,9 @@ #ifndef MINDSPORE_LITE_SRC_RUNTIME_KERNEL_NPU_TRANSPOSE_NPU_H_ #define MINDSPORE_LITE_SRC_RUNTIME_KERNEL_NPU_TRANSPOSE_NPU_H_ #include +#include "include/graph/op/all_ops.h" #include "nnacl/transpose.h" #include "src/runtime/kernel/npu/npu_kernel.h" -#include "include/graph/op/all_ops.h" namespace mindspore::kernel { class TransposeNPUKernel : public NPUKernel { public: diff --git a/mindspore/lite/src/runtime/kernel/npu/unsqueeze_npu.cc b/mindspore/lite/src/runtime/kernel/npu/unsqueeze_npu.cc index d09071af23..cd9c016679 100644 --- a/mindspore/lite/src/runtime/kernel/npu/unsqueeze_npu.cc +++ b/mindspore/lite/src/runtime/kernel/npu/unsqueeze_npu.cc @@ -17,7 +17,6 @@ #include "src/runtime/kernel/npu/unsqueeze_npu.h" #include #include "src/kernel_registry.h" -#include "src/runtime/agent/npu/npu_converter_utils.h" using mindspore::kernel::KERNEL_ARCH::kNPU; using mindspore::lite::KernelRegistrar; using mindspore::schema::PrimitiveType_Unsqueeze; diff --git a/mindspore/lite/src/runtime/kernel/npu/unsqueeze_npu.h b/mindspore/lite/src/runtime/kernel/npu/unsqueeze_npu.h index 43f9bb723d..28b4641f82 100644 --- a/mindspore/lite/src/runtime/kernel/npu/unsqueeze_npu.h +++ b/mindspore/lite/src/runtime/kernel/npu/unsqueeze_npu.h @@ -17,9 +17,9 @@ #ifndef MINDSPORE_LITE_SRC_RUNTIME_KERNEL_NPU_UNSQUEEZE_NPU_H_ #define MINDSPORE_LITE_SRC_RUNTIME_KERNEL_NPU_UNSQUEEZE_NPU_H_ #include +#include "include/graph/op/all_ops.h" #include "src/ops/unsqueeze.h" #include "src/runtime/kernel/npu/npu_kernel.h" -#include "include/graph/op/all_ops.h" namespace mindspore::kernel { class UnsqueezeNPUKernel : public NPUKernel { public: