| @@ -19,13 +19,16 @@ | |||||
| typedef struct DepthToSpaceParameter { | typedef struct DepthToSpaceParameter { | ||||
| OpParameter op_parameter_; | OpParameter op_parameter_; | ||||
| // primitive parameter | |||||
| int32_t block_size_; | int32_t block_size_; | ||||
| // shape correlative | |||||
| int32_t in_stride_dim0_; | int32_t in_stride_dim0_; | ||||
| int32_t in_stride_dim1_; | int32_t in_stride_dim1_; | ||||
| int32_t in_stride_dim2_; | int32_t in_stride_dim2_; | ||||
| int32_t out_stride_dim0_; | int32_t out_stride_dim0_; | ||||
| int32_t out_stride_dim1_; | int32_t out_stride_dim1_; | ||||
| int32_t out_stride_dim2_; | int32_t out_stride_dim2_; | ||||
| // other parameter | |||||
| uint8_t data_type_size_; | uint8_t data_type_size_; | ||||
| } DepthToSpaceParameter; | } DepthToSpaceParameter; | ||||
| @@ -71,7 +71,7 @@ int Assign::InferShape(std::vector<lite::Tensor *> inputs, std::vector<lite::Ten | |||||
| return RET_ERROR; | return RET_ERROR; | ||||
| } | } | ||||
| if (inputs[0]->ElementsNum() != inputs[1]->ElementsNum()) { | |||||
| if (inputs.at(0)->ElementsNum() != inputs.at(1)->ElementsNum()) { | |||||
| MS_LOG(ERROR) << "error input data size!"; | MS_LOG(ERROR) << "error input data size!"; | ||||
| return RET_ERROR; | return RET_ERROR; | ||||
| } | } | ||||
| @@ -79,8 +79,8 @@ int Assign::InferShape(std::vector<lite::Tensor *> inputs, std::vector<lite::Ten | |||||
| if (!outputs.empty()) { | if (!outputs.empty()) { | ||||
| auto *out = outputs.front(); | auto *out = outputs.front(); | ||||
| MS_ASSERT(out != nullptr); | MS_ASSERT(out != nullptr); | ||||
| out->set_data_type(inputs[0]->data_type()); | |||||
| out->set_format(inputs[0]->format()); | |||||
| out->set_data_type(inputs.at(0)->data_type()); | |||||
| out->set_format(inputs.at(0)->format()); | |||||
| out->set_shape({1}); | out->set_shape({1}); | ||||
| } | } | ||||
| return RET_OK; | return RET_OK; | ||||
| @@ -73,16 +73,16 @@ Registry AssignAddRegistry(schema::PrimitiveType_AssignAdd, AssignAddCreator); | |||||
| #endif | #endif | ||||
| int AssignAdd::InferShape(std::vector<Tensor *> inputs_, std::vector<Tensor *> outputs_) { | int AssignAdd::InferShape(std::vector<Tensor *> inputs_, std::vector<Tensor *> outputs_) { | ||||
| Tensor *x = inputs_[0]; | |||||
| Tensor *y = inputs_[1]; | |||||
| Tensor *out = outputs_[0]; | |||||
| Tensor *x = inputs_.at(0); | |||||
| Tensor *y = inputs_.at(1); | |||||
| Tensor *out = outputs_.at(0); | |||||
| std::vector<int> x_shape = x->shape(); | std::vector<int> x_shape = x->shape(); | ||||
| if (x->data_type() != y->data_type()) { | if (x->data_type() != y->data_type()) { | ||||
| MS_LOG(ERROR) << "no matched shape of x and y"; | MS_LOG(ERROR) << "no matched shape of x and y"; | ||||
| return RET_ERROR; | return RET_ERROR; | ||||
| } | } | ||||
| std::vector<int> output_shape(x_shape.size()); | std::vector<int> output_shape(x_shape.size()); | ||||
| for (int i = 0; i < static_cast<int>(x_shape.size()); i++) { | |||||
| for (size_t i = 0; i < x_shape.size(); i++) { | |||||
| output_shape[i] = x_shape[i]; | output_shape[i] = x_shape[i]; | ||||
| } | } | ||||
| out->set_shape(output_shape); | out->set_shape(output_shape); | ||||
| @@ -100,8 +100,8 @@ PrimitiveC *BinaryCrossEntropyCreator(const schema::Primitive *primitive) { | |||||
| Registry BinaryCrossEntropyRegistry(schema::PrimitiveType_BinaryCrossEntropy, BinaryCrossEntropyCreator); | Registry BinaryCrossEntropyRegistry(schema::PrimitiveType_BinaryCrossEntropy, BinaryCrossEntropyCreator); | ||||
| #endif | #endif | ||||
| int BinaryCrossEntropy::InferShape(std::vector<Tensor *> inputs_, std::vector<Tensor *> outputs_) { | int BinaryCrossEntropy::InferShape(std::vector<Tensor *> inputs_, std::vector<Tensor *> outputs_) { | ||||
| Tensor *x = inputs_[0]; | |||||
| Tensor *out = outputs_[0]; | |||||
| Tensor *x = inputs_.at(0); | |||||
| Tensor *out = outputs_.at(0); | |||||
| out->set_format(x->format()); | out->set_format(x->format()); | ||||
| out->set_data_type(x->data_type()); | out->set_data_type(x->data_type()); | ||||
| int reduction = GetReduction(); | int reduction = GetReduction(); | ||||
| @@ -89,10 +89,10 @@ void ConvertConvWeight(const ParameterPtr ¶m_node) { | |||||
| return; | return; | ||||
| } | } | ||||
| size_t filter_k = weight->tensor_shape()[0]; | |||||
| size_t filter_c = weight->tensor_shape()[1]; | |||||
| size_t filter_h = weight->tensor_shape()[2]; | |||||
| size_t filter_w = weight->tensor_shape()[3]; | |||||
| size_t filter_k = weight->tensor_shape().at(0); | |||||
| size_t filter_c = weight->tensor_shape().at(1); | |||||
| size_t filter_h = weight->tensor_shape().at(2); | |||||
| size_t filter_w = weight->tensor_shape().at(3); | |||||
| T *p1Buff = nullptr; | T *p1Buff = nullptr; | ||||
| T *p2Buff = nullptr; | T *p2Buff = nullptr; | ||||
| for (size_t k = 0; k < filter_k; ++k) { | for (size_t k = 0; k < filter_k; ++k) { | ||||
| @@ -145,26 +145,26 @@ void Conv2D::PopulaterConv2DMultiGroup(const Primitive &prim, schema::PrimitiveT | |||||
| attr->format = schema::Format::Format_NUM_OF_FORMAT; | attr->format = schema::Format::Format_NUM_OF_FORMAT; | ||||
| } | } | ||||
| auto pad_list = CastToInt(prim.GetAttr("pad_list")); | auto pad_list = CastToInt(prim.GetAttr("pad_list")); | ||||
| attr->padUp = pad_list[0]; | |||||
| attr->padDown = pad_list[1]; | |||||
| attr->padLeft = pad_list[2]; | |||||
| attr->padRight = pad_list[3]; | |||||
| attr->padUp = pad_list.at(0); | |||||
| attr->padDown = pad_list.at(1); | |||||
| attr->padLeft = pad_list.at(2); | |||||
| attr->padRight = pad_list.at(3); | |||||
| auto dilation = CastToInt(prim.GetAttr("dilation")); | auto dilation = CastToInt(prim.GetAttr("dilation")); | ||||
| #ifdef SUPPORT_TRAIN | #ifdef SUPPORT_TRAIN | ||||
| attr->dilateH = dilation[2]; | |||||
| attr->dilateW = dilation[3]; | |||||
| attr->dilateH = dilation.at(2); | |||||
| attr->dilateW = dilation.at(3); | |||||
| #else | #else | ||||
| attr->dilateH = dilation[0]; | |||||
| attr->dilateW = dilation[1]; | |||||
| attr->dilateH = dilation.at(0); | |||||
| attr->dilateW = dilation.at(1); | |||||
| #endif | #endif | ||||
| auto kernel_size = CastToInt(prim.GetAttr("kernel_size")); | auto kernel_size = CastToInt(prim.GetAttr("kernel_size")); | ||||
| attr->kernelH = kernel_size[0]; | |||||
| attr->kernelW = kernel_size[1]; | |||||
| attr->kernelH = kernel_size.at(0); | |||||
| attr->kernelW = kernel_size.at(1); | |||||
| auto stride = CastToInt(prim.GetAttr("stride")); | auto stride = CastToInt(prim.GetAttr("stride")); | ||||
| attr->strideH = stride[2]; | |||||
| attr->strideW = stride[3]; | |||||
| attr->strideH = stride.at(2); | |||||
| attr->strideW = stride.at(3); | |||||
| auto pad_mode = GetValue<std::string>(prim.GetAttr("pad_mode")); | auto pad_mode = GetValue<std::string>(prim.GetAttr("pad_mode")); | ||||
| if (pad_mode == "valid") { | if (pad_mode == "valid") { | ||||
| @@ -229,22 +229,22 @@ void Conv2D::PopulaterConv2DSingleGroup(const Primitive &prim, schema::Primitive | |||||
| attr->format = schema::Format::Format_NUM_OF_FORMAT; | attr->format = schema::Format::Format_NUM_OF_FORMAT; | ||||
| } | } | ||||
| auto pad_list = CastToInt(prim.GetAttr("pad_list")); | auto pad_list = CastToInt(prim.GetAttr("pad_list")); | ||||
| attr->padUp = pad_list[0]; | |||||
| attr->padDown = pad_list[1]; | |||||
| attr->padLeft = pad_list[2]; | |||||
| attr->padRight = pad_list[3]; | |||||
| attr->padUp = pad_list.at(0); | |||||
| attr->padDown = pad_list.at(1); | |||||
| attr->padLeft = pad_list.at(2); | |||||
| attr->padRight = pad_list.at(3); | |||||
| auto dilation = CastToInt(prim.GetAttr("dilation")); | auto dilation = CastToInt(prim.GetAttr("dilation")); | ||||
| attr->dilateH = dilation[2]; | |||||
| attr->dilateW = dilation[3]; | |||||
| attr->dilateH = dilation.at(2); | |||||
| attr->dilateW = dilation.at(3); | |||||
| auto kernel_size = CastToInt(prim.GetAttr("kernel_size")); | auto kernel_size = CastToInt(prim.GetAttr("kernel_size")); | ||||
| attr->kernelH = kernel_size[0]; | |||||
| attr->kernelW = kernel_size[1]; | |||||
| attr->kernelH = kernel_size.at(0); | |||||
| attr->kernelW = kernel_size.at(1); | |||||
| auto stride = CastToInt(prim.GetAttr("stride")); | auto stride = CastToInt(prim.GetAttr("stride")); | ||||
| attr->strideH = stride[2]; | |||||
| attr->strideW = stride[3]; | |||||
| attr->strideH = stride.at(2); | |||||
| attr->strideW = stride.at(3); | |||||
| attr->channelOut = CastToInt(prim.GetAttr("out_channel")).front(); | attr->channelOut = CastToInt(prim.GetAttr("out_channel")).front(); | ||||
| @@ -82,10 +82,10 @@ void ConvertConvWeight(const ParameterPtr ¶m_node) { | |||||
| return; | return; | ||||
| } | } | ||||
| size_t filter_k = weight->tensor_shape()[0]; | |||||
| size_t filter_c = weight->tensor_shape()[1]; | |||||
| size_t filter_h = weight->tensor_shape()[2]; | |||||
| size_t filter_w = weight->tensor_shape()[3]; | |||||
| size_t filter_k = weight->tensor_shape().at(0); | |||||
| size_t filter_c = weight->tensor_shape().at(1); | |||||
| size_t filter_h = weight->tensor_shape().at(2); | |||||
| size_t filter_w = weight->tensor_shape().at(3); | |||||
| T *p1Buff = nullptr; | T *p1Buff = nullptr; | ||||
| T *p2Buff = nullptr; | T *p2Buff = nullptr; | ||||
| for (size_t k = 0; k < filter_k; ++k) { | for (size_t k = 0; k < filter_k; ++k) { | ||||
| @@ -137,22 +137,22 @@ void DeConv2D::PopulaterConv2DMultiGroup(const Primitive &prim, schema::Primitiv | |||||
| attr->format = schema::Format::Format_NUM_OF_FORMAT; | attr->format = schema::Format::Format_NUM_OF_FORMAT; | ||||
| } | } | ||||
| auto pad_list = CastToInt(prim.GetAttr("pad_list")); | auto pad_list = CastToInt(prim.GetAttr("pad_list")); | ||||
| attr->padUp = pad_list[0]; | |||||
| attr->padDown = pad_list[1]; | |||||
| attr->padLeft = pad_list[2]; | |||||
| attr->padRight = pad_list[3]; | |||||
| attr->padUp = pad_list.at(0); | |||||
| attr->padDown = pad_list.at(1); | |||||
| attr->padLeft = pad_list.at(2); | |||||
| attr->padRight = pad_list.at(3); | |||||
| auto dilation = CastToInt(prim.GetAttr("dilation")); | auto dilation = CastToInt(prim.GetAttr("dilation")); | ||||
| attr->dilateH = dilation[0]; | |||||
| attr->dilateW = dilation[1]; | |||||
| attr->dilateH = dilation.at(0); | |||||
| attr->dilateW = dilation.at(1); | |||||
| auto kernel_size = CastToInt(prim.GetAttr("kernel_size")); | auto kernel_size = CastToInt(prim.GetAttr("kernel_size")); | ||||
| attr->kernelH = kernel_size[0]; | |||||
| attr->kernelW = kernel_size[1]; | |||||
| attr->kernelH = kernel_size.at(0); | |||||
| attr->kernelW = kernel_size.at(1); | |||||
| auto stride = CastToInt(prim.GetAttr("stride")); | auto stride = CastToInt(prim.GetAttr("stride")); | ||||
| attr->strideH = stride[0]; | |||||
| attr->strideW = stride[1]; | |||||
| attr->strideH = stride.at(0); | |||||
| attr->strideW = stride.at(1); | |||||
| auto pad_mode = GetValue<std::string>(prim.GetAttr("pad_mode")); | auto pad_mode = GetValue<std::string>(prim.GetAttr("pad_mode")); | ||||
| if (pad_mode == "valid") { | if (pad_mode == "valid") { | ||||
| @@ -204,22 +204,22 @@ void DeConv2D::PopulaterDeConv2DSingleGroup(const Primitive &prim, schema::Primi | |||||
| attr->format = schema::Format_NUM_OF_FORMAT; | attr->format = schema::Format_NUM_OF_FORMAT; | ||||
| } | } | ||||
| auto pad_list = CastToInt(prim.GetAttr("pad_list")); | auto pad_list = CastToInt(prim.GetAttr("pad_list")); | ||||
| attr->padUp = pad_list[0]; | |||||
| attr->padDown = pad_list[1]; | |||||
| attr->padLeft = pad_list[2]; | |||||
| attr->padRight = pad_list[3]; | |||||
| attr->padUp = pad_list.at(0); | |||||
| attr->padDown = pad_list.at(1); | |||||
| attr->padLeft = pad_list.at(2); | |||||
| attr->padRight = pad_list.at(3); | |||||
| auto dilation = CastToInt(prim.GetAttr("dilation")); | auto dilation = CastToInt(prim.GetAttr("dilation")); | ||||
| attr->dilateH = dilation[0]; | |||||
| attr->dilateW = dilation[1]; | |||||
| attr->dilateH = dilation.at(0); | |||||
| attr->dilateW = dilation.at(1); | |||||
| auto kernel_size = CastToInt(prim.GetAttr("kernel_size")); | auto kernel_size = CastToInt(prim.GetAttr("kernel_size")); | ||||
| attr->kernelH = kernel_size[0]; | |||||
| attr->kernelW = kernel_size[1]; | |||||
| attr->kernelH = kernel_size.at(0); | |||||
| attr->kernelW = kernel_size.at(1); | |||||
| auto stride = CastToInt(prim.GetAttr("stride")); | auto stride = CastToInt(prim.GetAttr("stride")); | ||||
| attr->strideH = stride[0]; | |||||
| attr->strideW = stride[1]; | |||||
| attr->strideH = stride.at(0); | |||||
| attr->strideW = stride.at(1); | |||||
| attr->channelOut = CastToInt(prim.GetAttr("out_channel")).front(); | attr->channelOut = CastToInt(prim.GetAttr("out_channel")).front(); | ||||
| @@ -87,19 +87,19 @@ int DepthwiseConv2D::UnPackAttr(const Primitive &prim, const std::vector<AnfNode | |||||
| attr->format = schema::Format::Format_NUM_OF_FORMAT; | attr->format = schema::Format::Format_NUM_OF_FORMAT; | ||||
| } | } | ||||
| auto pad_list = CastToInt(prim.GetAttr("pads")); | auto pad_list = CastToInt(prim.GetAttr("pads")); | ||||
| attr->padUp = pad_list[0]; | |||||
| attr->padDown = pad_list[1]; | |||||
| attr->padLeft = pad_list[2]; | |||||
| attr->padRight = pad_list[3]; | |||||
| attr->padUp = pad_list.at(0); | |||||
| attr->padDown = pad_list.at(1); | |||||
| attr->padLeft = pad_list.at(2); | |||||
| attr->padRight = pad_list.at(3); | |||||
| auto dilation = CastToInt(prim.GetAttr("dilation")); | auto dilation = CastToInt(prim.GetAttr("dilation")); | ||||
| attr->dilateH = dilation[0]; | |||||
| attr->dilateW = dilation[1]; | |||||
| attr->dilateH = dilation.at(0); | |||||
| attr->dilateW = dilation.at(1); | |||||
| if (utils::isa<ValueSequeue>(prim.GetAttr("kernel_size"))) { | if (utils::isa<ValueSequeue>(prim.GetAttr("kernel_size"))) { | ||||
| auto kernel_size = CastToInt(prim.GetAttr("kernel_size")); | auto kernel_size = CastToInt(prim.GetAttr("kernel_size")); | ||||
| attr->kernelH = kernel_size[0]; | |||||
| attr->kernelW = kernel_size[1]; | |||||
| attr->kernelH = kernel_size.at(0); | |||||
| attr->kernelW = kernel_size.at(1); | |||||
| } else { | } else { | ||||
| auto kernel_size = CastToInt(prim.GetAttr("kernel_size")).front(); | auto kernel_size = CastToInt(prim.GetAttr("kernel_size")).front(); | ||||
| attr->kernelH = kernel_size; | attr->kernelH = kernel_size; | ||||
| @@ -107,8 +107,8 @@ int DepthwiseConv2D::UnPackAttr(const Primitive &prim, const std::vector<AnfNode | |||||
| } | } | ||||
| auto stride = CastToInt(prim.GetAttr("stride")); | auto stride = CastToInt(prim.GetAttr("stride")); | ||||
| attr->strideH = stride[2]; | |||||
| attr->strideW = stride[3]; | |||||
| attr->strideH = stride.at(2); | |||||
| attr->strideW = stride.at(3); | |||||
| auto pad_mode = GetValue<std::string>(prim.GetAttr("pad_mode")); | auto pad_mode = GetValue<std::string>(prim.GetAttr("pad_mode")); | ||||
| if (pad_mode == "valid") { | if (pad_mode == "valid") { | ||||
| @@ -252,11 +252,11 @@ int DepthwiseConv2D::InferShape(std::vector<lite::Tensor *> inputs_, std::vector | |||||
| std::vector<int> out_shape{input->shape()}; | std::vector<int> out_shape{input->shape()}; | ||||
| out_shape.at(1) = output_h; | out_shape.at(1) = output_h; | ||||
| out_shape.at(2) = output_w; | out_shape.at(2) = output_w; | ||||
| if (GetChannelMultiplier() * input_channel != weight->shape()[0]) { | |||||
| if (GetChannelMultiplier() * input_channel != weight->shape().at(0)) { | |||||
| MS_LOG(ERROR) << "Conv depthwise only support group equals output channel."; | MS_LOG(ERROR) << "Conv depthwise only support group equals output channel."; | ||||
| return 1; | return 1; | ||||
| } | } | ||||
| out_shape.at(3) = weight->shape()[0] * weight->shape()[3]; // in_channel * out_channel | |||||
| out_shape.at(3) = weight->shape().at(0) * weight->shape().at(3); // in_channel * out_channel | |||||
| output->set_shape(out_shape); | output->set_shape(out_shape); | ||||
| return 0; | return 0; | ||||
| @@ -38,7 +38,7 @@ OpParameter *PopulateConstantOfShapeParameter(const mindspore::lite::PrimitiveC | |||||
| if (value.empty() || value.size() > 1) { | if (value.empty() || value.size() > 1) { | ||||
| MS_LOG(ERROR) << "The value of constant of shape is empty or more than 1."; | MS_LOG(ERROR) << "The value of constant of shape is empty or more than 1."; | ||||
| } else { | } else { | ||||
| param->value_ = attr->GetValue()[0]; | |||||
| param->value_ = attr->GetValue().at(0); | |||||
| } | } | ||||
| param->data_type_ = attr->GetDataType(); | param->data_type_ = attr->GetDataType(); | ||||
| return reinterpret_cast<OpParameter *>(param); | return reinterpret_cast<OpParameter *>(param); | ||||
| @@ -304,7 +304,7 @@ int StridedSlice::HandleAxesInputExist(const std::vector<lite::Tensor *> &inputs | |||||
| std::vector<int> axes; | std::vector<int> axes; | ||||
| if (axes_data == nullptr) { | if (axes_data == nullptr) { | ||||
| for (int i = 0; i < begin_ndim; ++i) { | for (int i = 0; i < begin_ndim; ++i) { | ||||
| axes[i] = i; | |||||
| axes.push_back(i); | |||||
| } | } | ||||
| } else { | } else { | ||||
| axes.assign(axes_data, axes_data + begin_ndim); | axes.assign(axes_data, axes_data + begin_ndim); | ||||
| @@ -59,7 +59,7 @@ int ArgMinMaxBaseCPUKernel::ReSize() { | |||||
| MS_LOG(ERROR) << "Invalid topk " << param->topk_; | MS_LOG(ERROR) << "Invalid topk " << param->topk_; | ||||
| return RET_PARAM_INVALID; | return RET_PARAM_INVALID; | ||||
| } | } | ||||
| param->topk_ = MSMIN(param->topk_, in_shape[axis]); | |||||
| param->topk_ = MSMIN(param->topk_, in_shape.at(axis)); | |||||
| ComputeStrides(in_shape.data(), param->in_strides_, in_shape.size()); | ComputeStrides(in_shape.data(), param->in_strides_, in_shape.size()); | ||||
| auto out_shape = out_tensors_.at(0)->shape(); | auto out_shape = out_tensors_.at(0)->shape(); | ||||
| ComputeStrides(out_shape.data(), param->out_strides_, out_shape.size()); | ComputeStrides(out_shape.data(), param->out_strides_, out_shape.size()); | ||||
| @@ -30,7 +30,7 @@ using mindspore::schema::PrimitiveType_BatchToSpaceND; | |||||
| namespace mindspore::kernel { | namespace mindspore::kernel { | ||||
| int BatchToSpaceBaseCPUKernel::Init() { | int BatchToSpaceBaseCPUKernel::Init() { | ||||
| if (in_tensors_[0]->format() != schema::Format::Format_NHWC) { | |||||
| if (in_tensors_.at(0)->format() != schema::Format::Format_NHWC) { | |||||
| MS_LOG(ERROR) << "batch_to_space only support NHWC now!"; | MS_LOG(ERROR) << "batch_to_space only support NHWC now!"; | ||||
| return RET_FORMAT_ERR; | return RET_FORMAT_ERR; | ||||
| } | } | ||||
| @@ -44,7 +44,7 @@ int BatchToSpaceBaseCPUKernel::Init() { | |||||
| } | } | ||||
| int BatchToSpaceBaseCPUKernel::ReSize() { | int BatchToSpaceBaseCPUKernel::ReSize() { | ||||
| auto shape = in_tensors_[0]->shape(); | |||||
| auto shape = in_tensors_.at(0)->shape(); | |||||
| if (shape.size() != 4) { | if (shape.size() != 4) { | ||||
| MS_LOG(ERROR) << "Unsupport shape size: " << shape.size(); | MS_LOG(ERROR) << "Unsupport shape size: " << shape.size(); | ||||
| return RET_ERROR; | return RET_ERROR; | ||||
| @@ -33,7 +33,7 @@ namespace mindspore::kernel { | |||||
| int DepthToSpaceBaseCPUKernel::Init() { return RET_OK; } | int DepthToSpaceBaseCPUKernel::Init() { return RET_OK; } | ||||
| int DepthToSpaceBaseCPUKernel::ReSize() { | int DepthToSpaceBaseCPUKernel::ReSize() { | ||||
| if (in_tensors_[0]->format() != schema::Format::Format_NHWC) { | |||||
| if (in_tensors_.at(0)->format() != schema::Format::Format_NHWC) { | |||||
| MS_LOG(ERROR) << "depth_to_space only support NHWC now!"; | MS_LOG(ERROR) << "depth_to_space only support NHWC now!"; | ||||
| return RET_FORMAT_ERR; | return RET_FORMAT_ERR; | ||||
| } | } | ||||
| @@ -42,18 +42,18 @@ int DepthToSpaceBaseCPUKernel::ReSize() { | |||||
| MS_LOG(ERROR) << "Input block_size should > 0!"; | MS_LOG(ERROR) << "Input block_size should > 0!"; | ||||
| return RET_PARAM_INVALID; | return RET_PARAM_INVALID; | ||||
| } | } | ||||
| auto shape_size = in_tensors_[0]->shape().size(); | |||||
| auto shape_size = in_tensors_.at(0)->shape().size(); | |||||
| if (shape_size != DIMENSION_4D) { | if (shape_size != DIMENSION_4D) { | ||||
| MS_LOG(ERROR) << "Input shape size should be " << DIMENSION_4D; | MS_LOG(ERROR) << "Input shape size should be " << DIMENSION_4D; | ||||
| return RET_PARAM_INVALID; | return RET_PARAM_INVALID; | ||||
| } | } | ||||
| int32_t in_strides[DIMENSION_4D]; | int32_t in_strides[DIMENSION_4D]; | ||||
| ComputeStrides(const_cast<int *>(in_tensors_[0]->shape().data()), in_strides, shape_size); | |||||
| ComputeStrides(const_cast<int *>(in_tensors_.at(0)->shape().data()), in_strides, shape_size); | |||||
| param->in_stride_dim0_ = in_strides[0]; | param->in_stride_dim0_ = in_strides[0]; | ||||
| param->in_stride_dim1_ = in_strides[1]; | param->in_stride_dim1_ = in_strides[1]; | ||||
| param->in_stride_dim2_ = in_strides[2]; | param->in_stride_dim2_ = in_strides[2]; | ||||
| int32_t out_strides[DIMENSION_4D]; | int32_t out_strides[DIMENSION_4D]; | ||||
| ComputeStrides(const_cast<int *>(out_tensors_[0]->shape().data()), out_strides, shape_size); | |||||
| ComputeStrides(const_cast<int *>(out_tensors_.at(0)->shape().data()), out_strides, shape_size); | |||||
| param->out_stride_dim0_ = out_strides[0]; | param->out_stride_dim0_ = out_strides[0]; | ||||
| param->out_stride_dim1_ = out_strides[1]; | param->out_stride_dim1_ = out_strides[1]; | ||||
| param->out_stride_dim2_ = out_strides[2]; | param->out_stride_dim2_ = out_strides[2]; | ||||
| @@ -44,8 +44,8 @@ class DequantUtil { | |||||
| return nullptr; | return nullptr; | ||||
| } | } | ||||
| if (input_tensor->shape().size() == kPerBatch && | if (input_tensor->shape().size() == kPerBatch && | ||||
| input_tensor->quant_params().size() == static_cast<size_t>(input_tensor->shape()[0])) { // per batch matmul | |||||
| auto per_batch_size = input_tensor->shape()[0]; | |||||
| input_tensor->quant_params().size() == static_cast<size_t>(input_tensor->shape().at(0))) { // per batch matmul | |||||
| auto per_batch_size = input_tensor->shape().at(0); | |||||
| auto quant_param = input_tensor->quant_params(); | auto quant_param = input_tensor->quant_params(); | ||||
| for (int i = 0; i < per_batch_size; i++) { | for (int i = 0; i < per_batch_size; i++) { | ||||
| auto param = quant_param.at(i); | auto param = quant_param.at(i); | ||||
| @@ -156,8 +156,8 @@ int DetectionPostProcessBaseCPUKernel::Run() { | |||||
| auto output_scores = reinterpret_cast<float *>(out_tensors_.at(2)->MutableData()); | auto output_scores = reinterpret_cast<float *>(out_tensors_.at(2)->MutableData()); | ||||
| auto output_num = reinterpret_cast<float *>(out_tensors_.at(3)->MutableData()); | auto output_num = reinterpret_cast<float *>(out_tensors_.at(3)->MutableData()); | ||||
| num_boxes_ = in_tensors_.at(0)->shape()[1]; | |||||
| num_classes_with_bg_ = in_tensors_.at(1)->shape()[2]; | |||||
| num_boxes_ = in_tensors_.at(0)->shape().at(1); | |||||
| num_classes_with_bg_ = in_tensors_.at(1)->shape().at(2); | |||||
| params_->decoded_boxes_ = context_->allocator->Malloc(num_boxes_ * 4 * sizeof(float)); | params_->decoded_boxes_ = context_->allocator->Malloc(num_boxes_ * 4 * sizeof(float)); | ||||
| if (params_->decoded_boxes_ == nullptr) { | if (params_->decoded_boxes_ == nullptr) { | ||||
| MS_LOG(ERROR) << "malloc params->decoded_boxes_ failed."; | MS_LOG(ERROR) << "malloc params->decoded_boxes_ failed."; | ||||
| @@ -74,9 +74,9 @@ int ArithmeticCompareFP16CPUKernel::Init() { | |||||
| } | } | ||||
| int ArithmeticCompareFP16CPUKernel::ReSize() { | int ArithmeticCompareFP16CPUKernel::ReSize() { | ||||
| param_->in_elements_num0_ = in_tensors_[0]->ElementsNum(); | |||||
| param_->in_elements_num1_ = in_tensors_[1]->ElementsNum(); | |||||
| param_->out_elements_num_ = out_tensors_[0]->ElementsNum(); | |||||
| param_->in_elements_num0_ = in_tensors_.at(0)->ElementsNum(); | |||||
| param_->in_elements_num1_ = in_tensors_.at(1)->ElementsNum(); | |||||
| param_->out_elements_num_ = out_tensors_.at(0)->ElementsNum(); | |||||
| if (param_->in_elements_num0_ == 1 || param_->in_elements_num1_ == 1) { | if (param_->in_elements_num0_ == 1 || param_->in_elements_num1_ == 1) { | ||||
| param_->broadcasting_ = false; | param_->broadcasting_ = false; | ||||
| @@ -135,9 +135,9 @@ int ArithmeticFP16CPUKernel::PreProcess() { | |||||
| } | } | ||||
| int ArithmeticFP16CPUKernel::ReSize() { | int ArithmeticFP16CPUKernel::ReSize() { | ||||
| param_->in_elements_num0_ = in_tensors_[0]->ElementsNum(); | |||||
| param_->in_elements_num1_ = in_tensors_[1]->ElementsNum(); | |||||
| param_->out_elements_num_ = out_tensors_[0]->ElementsNum(); | |||||
| param_->in_elements_num0_ = in_tensors_.at(0)->ElementsNum(); | |||||
| param_->in_elements_num1_ = in_tensors_.at(1)->ElementsNum(); | |||||
| param_->out_elements_num_ = out_tensors_.at(0)->ElementsNum(); | |||||
| if (param_->in_elements_num0_ == 1 || param_->in_elements_num1_ == 1) { | if (param_->in_elements_num0_ == 1 || param_->in_elements_num1_ == 1) { | ||||
| param_->broadcasting_ = false; | param_->broadcasting_ = false; | ||||
| @@ -44,7 +44,7 @@ ArithmeticSelfFp16Func ArithmeticSelfFp16CPUKernel::GetArithmeticSelfFp16Fun(int | |||||
| {mindspore::schema::PrimitiveType_Ceil, ElementCeilFp16}, | {mindspore::schema::PrimitiveType_Ceil, ElementCeilFp16}, | ||||
| {mindspore::schema::PrimitiveType_Round, ElementRoundFp16}, | {mindspore::schema::PrimitiveType_Round, ElementRoundFp16}, | ||||
| {mindspore::schema::PrimitiveType_Neg, ElementNegativeFp16}}; | {mindspore::schema::PrimitiveType_Neg, ElementNegativeFp16}}; | ||||
| for (size_t i = 0; i < sizeof(type_func_table); i++) { | |||||
| for (size_t i = 0; i < sizeof(type_func_table) / sizeof(TYPE_FUNC_INFO); i++) { | |||||
| if (type_func_table[i].primitive_type_ == primitive_type) { | if (type_func_table[i].primitive_type_ == primitive_type) { | ||||
| return type_func_table[i].func_; | return type_func_table[i].func_; | ||||
| } | } | ||||
| @@ -48,7 +48,7 @@ int CastFp16CPUKernel::Init() { | |||||
| } | } | ||||
| int CastFp16CPUKernel::ReSize() { | int CastFp16CPUKernel::ReSize() { | ||||
| data_num_ = in_tensors_[0]->ElementsNum(); | |||||
| data_num_ = in_tensors_.at(0)->ElementsNum(); | |||||
| if (data_num_ == 0) { | if (data_num_ == 0) { | ||||
| return RET_OK; | return RET_OK; | ||||
| } | } | ||||
| @@ -102,7 +102,7 @@ int ConcatFp16CPUKernel::Run() { | |||||
| std::vector<std::vector<int>> shapes; | std::vector<std::vector<int>> shapes; | ||||
| for (size_t i = 0; i < input_num; ++i) { | for (size_t i = 0; i < input_num; ++i) { | ||||
| const auto in_tensor = in_tensors_[i]; | |||||
| const auto in_tensor = in_tensors_.at(i); | |||||
| if (in_tensor->data_type() == kNumberTypeFloat || in_tensor->data_type() == kNumberTypeFloat32) { | if (in_tensor->data_type() == kNumberTypeFloat || in_tensor->data_type() == kNumberTypeFloat32) { | ||||
| auto in_tensor_data = reinterpret_cast<float *>(in_tensor->MutableData()); | auto in_tensor_data = reinterpret_cast<float *>(in_tensor->MutableData()); | ||||
| Float32ToFloat16(in_tensor_data, fp16_inputs_[i], in_tensor->ElementsNum()); | Float32ToFloat16(in_tensor_data, fp16_inputs_[i], in_tensor->ElementsNum()); | ||||
| @@ -42,7 +42,7 @@ int ConvolutionDepthwiseFp16CPUKernel::InitWeightBias() { | |||||
| // init weight: o, h, w, i; o == group, i == 1 | // init weight: o, h, w, i; o == group, i == 1 | ||||
| ConvolutionBaseFP16CPUKernel::GetExecuteFilter(); | ConvolutionBaseFP16CPUKernel::GetExecuteFilter(); | ||||
| auto weight_tensor = in_tensors_[kWeightIndex]; | |||||
| auto weight_tensor = in_tensors_.at(kWeightIndex); | |||||
| int channel = weight_tensor->Batch(); | int channel = weight_tensor->Batch(); | ||||
| int pack_weight_size = channel * weight_tensor->Height() * weight_tensor->Width(); | int pack_weight_size = channel * weight_tensor->Height() * weight_tensor->Width(); | ||||
| @@ -64,7 +64,7 @@ int ConvolutionDepthwiseSWFp16CPUKernel::InitPackedInputOutput() { | |||||
| int ConvolutionDepthwiseSWFp16CPUKernel::InitWeightBias() { | int ConvolutionDepthwiseSWFp16CPUKernel::InitWeightBias() { | ||||
| // init weight: o, h, w, i; o == group, i == 1 | // init weight: o, h, w, i; o == group, i == 1 | ||||
| auto weight_tensor = in_tensors_[kWeightIndex]; | |||||
| auto weight_tensor = in_tensors_.at(kWeightIndex); | |||||
| int OC8 = UP_DIV(weight_tensor->Batch(), C8NUM); | int OC8 = UP_DIV(weight_tensor->Batch(), C8NUM); | ||||
| auto origin_weight = reinterpret_cast<float *>(weight_tensor->MutableData()); | auto origin_weight = reinterpret_cast<float *>(weight_tensor->MutableData()); | ||||
| int pack_weight_size = C8NUM * OC8 * weight_tensor->Height() * weight_tensor->Width(); | int pack_weight_size = C8NUM * OC8 * weight_tensor->Height() * weight_tensor->Width(); | ||||
| @@ -77,7 +77,7 @@ int DeconvolutionDepthwiseFp16CPUKernel::InitPackedInputOutput() { | |||||
| int DeconvolutionDepthwiseFp16CPUKernel::InitWeightBias() { | int DeconvolutionDepthwiseFp16CPUKernel::InitWeightBias() { | ||||
| // init weight: o, h, w, i; o == group, i == 1 | // init weight: o, h, w, i; o == group, i == 1 | ||||
| auto weight_tensor = in_tensors_[kWeightIndex]; | |||||
| auto weight_tensor = in_tensors_.at(kWeightIndex); | |||||
| int OC8 = UP_DIV(weight_tensor->Batch(), C8NUM); | int OC8 = UP_DIV(weight_tensor->Batch(), C8NUM); | ||||
| auto origin_weight = reinterpret_cast<float *>(weight_tensor->MutableData()); | auto origin_weight = reinterpret_cast<float *>(weight_tensor->MutableData()); | ||||
| int pack_weight_size = C8NUM * OC8 * weight_tensor->Height() * weight_tensor->Width(); | int pack_weight_size = C8NUM * OC8 * weight_tensor->Height() * weight_tensor->Width(); | ||||
| @@ -64,7 +64,7 @@ int DeConvolutionFp16CPUKernel::InitWeightBias() { | |||||
| } | } | ||||
| memset(bias_data_, 0, UP_ROUND(output_channel, C4NUM) * sizeof(float16_t)); | memset(bias_data_, 0, UP_ROUND(output_channel, C4NUM) * sizeof(float16_t)); | ||||
| if (in_tensors_.size() == 3) { | if (in_tensors_.size() == 3) { | ||||
| Float32ToFloat16(reinterpret_cast<float *>(in_tensors_[2]->MutableData()), | |||||
| Float32ToFloat16(reinterpret_cast<float *>(in_tensors_.at(2)->MutableData()), | |||||
| reinterpret_cast<float16_t *>(bias_data_), output_channel); | reinterpret_cast<float16_t *>(bias_data_), output_channel); | ||||
| } | } | ||||
| @@ -75,7 +75,7 @@ int DeConvolutionFp16CPUKernel::InitWeightBias() { | |||||
| return RET_ERROR; | return RET_ERROR; | ||||
| } | } | ||||
| memset(execute_weight_, 0, weight_pack_size); | memset(execute_weight_, 0, weight_pack_size); | ||||
| PackNHWCFp32ToC8HWN8Fp16(reinterpret_cast<float *>(in_tensors_[1]->MutableData()), execute_weight_, input_channel, | |||||
| PackNHWCFp32ToC8HWN8Fp16(reinterpret_cast<float *>(in_tensors_.at(1)->MutableData()), execute_weight_, input_channel, | |||||
| kernel_w * kernel_h, output_channel); | kernel_w * kernel_h, output_channel); | ||||
| return RET_OK; | return RET_OK; | ||||
| } | } | ||||
| @@ -239,7 +239,7 @@ int DeConvWgPostFp16Run(void *cdata, int task_id) { | |||||
| } | } | ||||
| int DeConvWinogradFp16CPUKernel::InitComputeParam() { | int DeConvWinogradFp16CPUKernel::InitComputeParam() { | ||||
| auto weight_tensor = in_tensors_[1]; | |||||
| auto weight_tensor = in_tensors_.at(1); | |||||
| conv_param_->input_channel_ = weight_tensor->Batch(); | conv_param_->input_channel_ = weight_tensor->Batch(); | ||||
| conv_param_->output_channel_ = weight_tensor->Channel(); | conv_param_->output_channel_ = weight_tensor->Channel(); | ||||
| @@ -28,7 +28,6 @@ using mindspore::schema::PrimitiveType_LessEqual; | |||||
| using mindspore::schema::PrimitiveType_NotEqual; | using mindspore::schema::PrimitiveType_NotEqual; | ||||
| namespace mindspore::kernel { | namespace mindspore::kernel { | ||||
| int ArithmeticCompareCPUKernel::BroadcastRun(void *input0, void *input1, void *output, int dim, int out_count, | int ArithmeticCompareCPUKernel::BroadcastRun(void *input0, void *input1, void *output, int dim, int out_count, | ||||
| int out_thread_stride) { | int out_thread_stride) { | ||||
| if (dim > break_pos_) { | if (dim > break_pos_) { | ||||
| @@ -42,7 +42,7 @@ ArithmeticSelfFunc ArithmeticSelfCPUKernel::GetArithmeticSelfFun(int primitive_t | |||||
| {mindspore::schema::PrimitiveType_Ceil, ElementCeil}, | {mindspore::schema::PrimitiveType_Ceil, ElementCeil}, | ||||
| {mindspore::schema::PrimitiveType_Round, ElementRound}, | {mindspore::schema::PrimitiveType_Round, ElementRound}, | ||||
| {mindspore::schema::PrimitiveType_Neg, ElementNegative}}; | {mindspore::schema::PrimitiveType_Neg, ElementNegative}}; | ||||
| for (size_t i = 0; i < sizeof(type_func_table); i++) { | |||||
| for (size_t i = 0; i < sizeof(type_func_table) / sizeof(TYPE_FUNC_INFO); i++) { | |||||
| if (type_func_table[i].primitive_type_ == primitive_type) { | if (type_func_table[i].primitive_type_ == primitive_type) { | ||||
| return type_func_table[i].func_; | return type_func_table[i].func_; | ||||
| } | } | ||||
| @@ -48,7 +48,7 @@ void BatchnormCPUKernel::FreeMeanAndVariance() { | |||||
| } | } | ||||
| void BatchnormCPUKernel::FillParam() { | void BatchnormCPUKernel::FillParam() { | ||||
| auto input_shapes = in_tensors_[0]->shape(); | |||||
| auto input_shapes = in_tensors_.at(0)->shape(); | |||||
| auto n_dim = input_shapes.size(); | auto n_dim = input_shapes.size(); | ||||
| auto param = reinterpret_cast<BatchNormParameter *>(op_parameter_); | auto param = reinterpret_cast<BatchNormParameter *>(op_parameter_); | ||||
| param->channel_ = input_shapes[n_dim - 1]; | param->channel_ = input_shapes[n_dim - 1]; | ||||
| @@ -59,15 +59,15 @@ void BatchnormCPUKernel::FillParam() { | |||||
| } | } | ||||
| int BatchnormCPUKernel::InitConstTensor() { | int BatchnormCPUKernel::InitConstTensor() { | ||||
| mean_ = malloc(in_tensors_[1]->Size()); | |||||
| variance_ = malloc(in_tensors_[2]->Size()); | |||||
| mean_ = malloc(in_tensors_.at(1)->Size()); | |||||
| variance_ = malloc(in_tensors_.at(2)->Size()); | |||||
| if (mean_ == nullptr || variance_ == nullptr) { | if (mean_ == nullptr || variance_ == nullptr) { | ||||
| MS_LOG(ERROR) << "Memory allocation failed"; | MS_LOG(ERROR) << "Memory allocation failed"; | ||||
| FreeMeanAndVariance(); | FreeMeanAndVariance(); | ||||
| return RET_ERROR; | return RET_ERROR; | ||||
| } | } | ||||
| memcpy(mean_, in_tensors_[1]->MutableData(), in_tensors_[1]->Size()); | |||||
| memcpy(variance_, in_tensors_[2]->MutableData(), in_tensors_[2]->Size()); | |||||
| memcpy(mean_, in_tensors_.at(1)->MutableData(), in_tensors_.at(1)->Size()); | |||||
| memcpy(variance_, in_tensors_.at(2)->MutableData(), in_tensors_.at(2)->Size()); | |||||
| return RET_OK; | return RET_OK; | ||||
| } | } | ||||
| @@ -29,9 +29,12 @@ using mindspore::schema::PrimitiveType_BiasAdd; | |||||
| namespace mindspore::kernel { | namespace mindspore::kernel { | ||||
| int BiasCPUKernel::ReSize() { | int BiasCPUKernel::ReSize() { | ||||
| auto dims = in_tensors_[0]->shape(); | |||||
| MS_ASSERT(dims.size() <= 5); | |||||
| auto dims = in_tensors_.at(0)->shape(); | |||||
| bias_param_->ndim_ = dims.size(); | bias_param_->ndim_ = dims.size(); | ||||
| if (bias_param_->ndim_ < 1 || bias_param_->ndim_ > 5) { | |||||
| MS_LOG(ERROR) << "input shape is invalid"; | |||||
| return RET_ERROR; | |||||
| } | |||||
| for (size_t i = 0; i < bias_param_->ndim_; i++) { | for (size_t i = 0; i < bias_param_->ndim_; i++) { | ||||
| bias_param_->in_shape0_[i] = dims[i]; | bias_param_->in_shape0_[i] = dims[i]; | ||||
| bias_param_->in_shape1_[i] = 1; | bias_param_->in_shape1_[i] = 1; | ||||
| @@ -26,13 +26,13 @@ using mindspore::schema::PrimitiveType_BroadcastTo; | |||||
| namespace mindspore::kernel { | namespace mindspore::kernel { | ||||
| int BroadcastToCPUKernel::ReSize() { | int BroadcastToCPUKernel::ReSize() { | ||||
| auto input_shape = in_tensors_[0]->shape(); | |||||
| auto input_shape = in_tensors_.at(0)->shape(); | |||||
| for (size_t i = 0; i < input_shape.size(); ++i) { | for (size_t i = 0; i < input_shape.size(); ++i) { | ||||
| shape_info_.input_shape_[i] = input_shape[i]; | shape_info_.input_shape_[i] = input_shape[i]; | ||||
| } | } | ||||
| shape_info_.input_shape_size_ = static_cast<int>(input_shape.size()); | shape_info_.input_shape_size_ = static_cast<int>(input_shape.size()); | ||||
| auto output_shape = out_tensors_[0]->shape(); | |||||
| auto output_shape = out_tensors_.at(0)->shape(); | |||||
| for (size_t i = 0; i < output_shape.size(); ++i) { | for (size_t i = 0; i < output_shape.size(); ++i) { | ||||
| shape_info_.output_shape_[i] = output_shape[i]; | shape_info_.output_shape_[i] = output_shape[i]; | ||||
| } | } | ||||
| @@ -49,7 +49,7 @@ int CastCPUKernel::Init() { | |||||
| } | } | ||||
| int CastCPUKernel::ReSize() { | int CastCPUKernel::ReSize() { | ||||
| data_num_ = in_tensors_[0]->ElementsNum(); | |||||
| data_num_ = in_tensors_.at(0)->ElementsNum(); | |||||
| if (data_num_ == 0) { | if (data_num_ == 0) { | ||||
| return RET_OK; | return RET_OK; | ||||
| } | } | ||||
| @@ -40,11 +40,14 @@ ConvolutionDepthwiseCPUKernel::~ConvolutionDepthwiseCPUKernel() { | |||||
| int ConvolutionDepthwiseCPUKernel::InitWeightBias() { | int ConvolutionDepthwiseCPUKernel::InitWeightBias() { | ||||
| // init weight: k, h, w, c; k == group == output_channel, c == 1 | // init weight: k, h, w, c; k == group == output_channel, c == 1 | ||||
| auto weight_tensor = in_tensors_[kWeightIndex]; | |||||
| auto weight_tensor = in_tensors_.at(kWeightIndex); | |||||
| auto origin_weight = reinterpret_cast<float *>(weight_tensor->MutableData()); | auto origin_weight = reinterpret_cast<float *>(weight_tensor->MutableData()); | ||||
| int channel = weight_tensor->Batch(); | int channel = weight_tensor->Batch(); | ||||
| int pack_weight_size = weight_tensor->Batch() * weight_tensor->Height() * weight_tensor->Width(); | int pack_weight_size = weight_tensor->Batch() * weight_tensor->Height() * weight_tensor->Width(); | ||||
| if (pack_weight_size >= std::numeric_limits<int>::max() / static_cast<int>(sizeof(float))) { | |||||
| MS_LOG(ERROR) << "pack_weight_size is invalid, pack_weight_size: " << pack_weight_size; | |||||
| return RET_ERROR; | |||||
| } | |||||
| packed_weight_ = reinterpret_cast<float *>(malloc(pack_weight_size * sizeof(float))); | packed_weight_ = reinterpret_cast<float *>(malloc(pack_weight_size * sizeof(float))); | ||||
| if (packed_weight_ == nullptr) { | if (packed_weight_ == nullptr) { | ||||
| MS_LOG(ERROR) << "Malloc buffer failed."; | MS_LOG(ERROR) << "Malloc buffer failed."; | ||||
| @@ -40,7 +40,7 @@ ConvolutionDepthwiseSWCPUKernel::~ConvolutionDepthwiseSWCPUKernel() { | |||||
| int ConvolutionDepthwiseSWCPUKernel::InitWeightBias() { | int ConvolutionDepthwiseSWCPUKernel::InitWeightBias() { | ||||
| // init weight: o, h, w, i; o == group, i == 1 | // init weight: o, h, w, i; o == group, i == 1 | ||||
| auto weight_tensor = in_tensors_[kWeightIndex]; | |||||
| auto weight_tensor = in_tensors_.at(kWeightIndex); | |||||
| auto origin_weight = reinterpret_cast<float *>(weight_tensor->MutableData()); | auto origin_weight = reinterpret_cast<float *>(weight_tensor->MutableData()); | ||||
| int OC4 = UP_DIV(weight_tensor->Batch(), C4NUM); | int OC4 = UP_DIV(weight_tensor->Batch(), C4NUM); | ||||
| int pack_weight_size = C4NUM * OC4 * weight_tensor->Height() * weight_tensor->Width(); | int pack_weight_size = C4NUM * OC4 * weight_tensor->Height() * weight_tensor->Width(); | ||||
| @@ -66,7 +66,7 @@ int ConvolutionDepthwiseSWCPUKernel::InitWeightBias() { | |||||
| memset(bias_data_, 0, malloc_size * sizeof(float)); | memset(bias_data_, 0, malloc_size * sizeof(float)); | ||||
| if (in_tensors_.size() == kInputSize2) { | if (in_tensors_.size() == kInputSize2) { | ||||
| auto bias_tensor = in_tensors_[kBiasIndex]; | |||||
| auto bias_tensor = in_tensors_.at(kBiasIndex); | |||||
| auto ori_bias = reinterpret_cast<float *>(bias_tensor->MutableData()); | auto ori_bias = reinterpret_cast<float *>(bias_tensor->MutableData()); | ||||
| memcpy(bias_data_, ori_bias, bias_tensor->ElementsNum() * sizeof(float)); | memcpy(bias_data_, ori_bias, bias_tensor->ElementsNum() * sizeof(float)); | ||||
| } | } | ||||
| @@ -54,7 +54,7 @@ int DeconvolutionDepthwiseCPUKernel::InitSlideParam() { | |||||
| int DeconvolutionDepthwiseCPUKernel::InitWeightBias() { | int DeconvolutionDepthwiseCPUKernel::InitWeightBias() { | ||||
| // init weight: o, h, w, i; o == group, i == 1 | // init weight: o, h, w, i; o == group, i == 1 | ||||
| auto weight_tensor = in_tensors_[kWeightIndex]; | |||||
| auto weight_tensor = in_tensors_.at(kWeightIndex); | |||||
| auto origin_weight = reinterpret_cast<float *>(weight_tensor->MutableData()); | auto origin_weight = reinterpret_cast<float *>(weight_tensor->MutableData()); | ||||
| int OC4 = UP_DIV(weight_tensor->Batch(), C4NUM); | int OC4 = UP_DIV(weight_tensor->Batch(), C4NUM); | ||||
| int pack_weight_size = C4NUM * OC4 * weight_tensor->Height() * weight_tensor->Width(); | int pack_weight_size = C4NUM * OC4 * weight_tensor->Height() * weight_tensor->Width(); | ||||
| @@ -63,7 +63,7 @@ int DeConvolutionCPUKernel::InitWeightBias() { | |||||
| } | } | ||||
| memset(bias_data_, 0, UP_ROUND(output_channel, C4NUM) * sizeof(float)); | memset(bias_data_, 0, UP_ROUND(output_channel, C4NUM) * sizeof(float)); | ||||
| if (in_tensors_.size() == 3) { | if (in_tensors_.size() == 3) { | ||||
| memcpy(bias_data_, in_tensors_[2]->MutableData(), output_channel * sizeof(float)); | |||||
| memcpy(bias_data_, in_tensors_.at(2)->MutableData(), output_channel * sizeof(float)); | |||||
| } | } | ||||
| size_t weight_pack_size = input_channel * kernel_w_ * kernel_h_ * UP_ROUND(output_channel, C8NUM) * sizeof(float); | size_t weight_pack_size = input_channel * kernel_w_ * kernel_h_ * UP_ROUND(output_channel, C8NUM) * sizeof(float); | ||||
| @@ -73,7 +73,7 @@ int DeConvolutionCPUKernel::InitWeightBias() { | |||||
| return RET_ERROR; | return RET_ERROR; | ||||
| } | } | ||||
| memset(weight_ptr_, 0, weight_pack_size); | memset(weight_ptr_, 0, weight_pack_size); | ||||
| PackNHWCToC8HWN8Fp32(reinterpret_cast<float *>(in_tensors_[1]->MutableData()), weight_ptr_, input_channel, | |||||
| PackNHWCToC8HWN8Fp32(reinterpret_cast<float *>(in_tensors_.at(1)->MutableData()), weight_ptr_, input_channel, | |||||
| kernel_w_ * kernel_h_, output_channel); | kernel_w_ * kernel_h_, output_channel); | ||||
| return RET_OK; | return RET_OK; | ||||
| } | } | ||||
| @@ -56,7 +56,10 @@ int GatherNdCPUKernel::ReSize() { | |||||
| for (int i = 0; i < indices_rank - 1; ++i) { | for (int i = 0; i < indices_rank - 1; ++i) { | ||||
| count_ *= indices_shape[i]; | count_ *= indices_shape[i]; | ||||
| } | } | ||||
| if (count_ >= std::numeric_limits<int>::max() / static_cast<int>(sizeof(int))) { | |||||
| MS_LOG(ERROR) << "count_ is invalid, count_: " << count_; | |||||
| return RET_ERROR; | |||||
| } | |||||
| in_offset_ = reinterpret_cast<int *>(malloc(count_ * sizeof(int))); | in_offset_ = reinterpret_cast<int *>(malloc(count_ * sizeof(int))); | ||||
| if (in_offset_ == nullptr) { | if (in_offset_ == nullptr) { | ||||
| MS_LOG(ERROR) << "GatherNd Malloc in_offset_ error!"; | MS_LOG(ERROR) << "GatherNd Malloc in_offset_ error!"; | ||||
| @@ -113,6 +113,10 @@ int GatherCPUKernel::Run() { | |||||
| int GatherCPUKernel::AssignIndicesData(bool isIndicesInt32, int indices_num, lite::Tensor *indices_tensor) { | int GatherCPUKernel::AssignIndicesData(bool isIndicesInt32, int indices_num, lite::Tensor *indices_tensor) { | ||||
| if (!isIndicesInt32) { | if (!isIndicesInt32) { | ||||
| if (indices_num >= std::numeric_limits<int>::max() / static_cast<int>(sizeof(int))) { | |||||
| MS_LOG(ERROR) << "Input indices_num is invalid, indices_num: " << indices_num; | |||||
| return RET_ERROR; | |||||
| } | |||||
| indices_data_ = reinterpret_cast<int32_t *>(context_->allocator->Malloc(sizeof(int32_t) * indices_num)); | indices_data_ = reinterpret_cast<int32_t *>(context_->allocator->Malloc(sizeof(int32_t) * indices_num)); | ||||
| if (indices_data_ == nullptr) { | if (indices_data_ == nullptr) { | ||||
| MS_LOG(ERROR) << "Memory allocation failed"; | MS_LOG(ERROR) << "Memory allocation failed"; | ||||
| @@ -91,14 +91,18 @@ int SparseToDenseRun(void *cdata, int task_id) { | |||||
| int SparseToDenseCPUKernel::GenerateIndices() { | int SparseToDenseCPUKernel::GenerateIndices() { | ||||
| auto input0 = in_tensors_.at(0); | auto input0 = in_tensors_.at(0); | ||||
| index_dim = input0->shape().size(); | |||||
| index_num = input0->shape()[0]; | index_num = input0->shape()[0]; | ||||
| int *sparse_indices = reinterpret_cast<int *>(input0->MutableData()); | |||||
| if (index_num >= std::numeric_limits<int>::max() / static_cast<int>(sizeof(int *))) { | |||||
| MS_LOG(ERROR) << "Input dim is invalid, dim: " << index_num; | |||||
| return RET_ERROR; | |||||
| } | |||||
| sparse_indices_vect = reinterpret_cast<int **>(ctx_->allocator->Malloc(sizeof(int *) * index_num)); | sparse_indices_vect = reinterpret_cast<int **>(ctx_->allocator->Malloc(sizeof(int *) * index_num)); | ||||
| if (sparse_indices_vect == nullptr) { | if (sparse_indices_vect == nullptr) { | ||||
| MS_LOG(ERROR) << "Null pointer reference: sparse_indices_vect."; | MS_LOG(ERROR) << "Null pointer reference: sparse_indices_vect."; | ||||
| return RET_ERROR; | return RET_ERROR; | ||||
| } | } | ||||
| index_dim = input0->shape().size(); | |||||
| int *sparse_indices = reinterpret_cast<int *>(input0->MutableData()); | |||||
| switch (index_dim) { | switch (index_dim) { | ||||
| case 0: | case 0: | ||||
| case 1: { | case 1: { | ||||
| @@ -42,10 +42,10 @@ BatchnormInt8CPUKernel::~BatchnormInt8CPUKernel() { | |||||
| } | } | ||||
| int BatchnormInt8CPUKernel::InitConstTensor() { | int BatchnormInt8CPUKernel::InitConstTensor() { | ||||
| auto input = in_tensors_[0]; | |||||
| auto mean = in_tensors_[1]; | |||||
| auto variance = in_tensors_[2]; | |||||
| auto output = out_tensors_[0]; | |||||
| auto input = in_tensors_.at(0); | |||||
| auto mean = in_tensors_.at(1); | |||||
| auto variance = in_tensors_.at(2); | |||||
| auto output = out_tensors_.at(0); | |||||
| auto mean_ptr = reinterpret_cast<int8_t *>(mean->MutableData()); | auto mean_ptr = reinterpret_cast<int8_t *>(mean->MutableData()); | ||||
| auto var_ptr = reinterpret_cast<int8_t *>(variance->MutableData()); | auto var_ptr = reinterpret_cast<int8_t *>(variance->MutableData()); | ||||
| @@ -81,12 +81,12 @@ int BatchnormInt8CPUKernel::InitConstTensor() { | |||||
| } | } | ||||
| int BatchnormInt8CPUKernel::InitFusedConstTensor() { | int BatchnormInt8CPUKernel::InitFusedConstTensor() { | ||||
| auto input = in_tensors_[0]; | |||||
| auto scale = in_tensors_[1]; | |||||
| auto offset = in_tensors_[2]; | |||||
| auto mean = in_tensors_[3]; | |||||
| auto variance = in_tensors_[4]; | |||||
| auto output = out_tensors_[0]; | |||||
| auto input = in_tensors_.at(0); | |||||
| auto scale = in_tensors_.at(1); | |||||
| auto offset = in_tensors_.at(2); | |||||
| auto mean = in_tensors_.at(3); | |||||
| auto variance = in_tensors_.at(4); | |||||
| auto output = out_tensors_.at(0); | |||||
| auto scale_ptr = reinterpret_cast<int8_t *>(scale->MutableData()); | auto scale_ptr = reinterpret_cast<int8_t *>(scale->MutableData()); | ||||
| auto offset_ptr = reinterpret_cast<int8_t *>(offset->MutableData()); | auto offset_ptr = reinterpret_cast<int8_t *>(offset->MutableData()); | ||||
| @@ -133,7 +133,7 @@ int BatchnormInt8CPUKernel::InitFusedConstTensor() { | |||||
| } | } | ||||
| int BatchnormInt8CPUKernel::Init() { | int BatchnormInt8CPUKernel::Init() { | ||||
| auto input_shapes = in_tensors_[0]->shape(); | |||||
| auto input_shapes = in_tensors_.at(0)->shape(); | |||||
| auto n_dim = input_shapes.size(); | auto n_dim = input_shapes.size(); | ||||
| batchnorm_param_->channel_ = input_shapes[n_dim - 1]; | batchnorm_param_->channel_ = input_shapes[n_dim - 1]; | ||||
| batchnorm_param_->units_ = 1; | batchnorm_param_->units_ = 1; | ||||
| @@ -161,7 +161,7 @@ int BatchnormInt8CPUKernel::Init() { | |||||
| } | } | ||||
| int BatchnormInt8CPUKernel::ReSize() { | int BatchnormInt8CPUKernel::ReSize() { | ||||
| auto input_shapes = in_tensors_[0]->shape(); | |||||
| auto input_shapes = in_tensors_.at(0)->shape(); | |||||
| batchnorm_param_->unit_ = 1; | batchnorm_param_->unit_ = 1; | ||||
| for (size_t i = 0; i < input_shapes.size() - 1; i++) { | for (size_t i = 0; i < input_shapes.size() - 1; i++) { | ||||
| batchnorm_param_->unit_ *= input_shapes[i]; | batchnorm_param_->unit_ *= input_shapes[i]; | ||||
| @@ -21,6 +21,7 @@ | |||||
| #include "include/errorcode.h" | #include "include/errorcode.h" | ||||
| using mindspore::lite::KernelRegistrar; | using mindspore::lite::KernelRegistrar; | ||||
| using mindspore::lite::RET_ERROR; | |||||
| using mindspore::lite::RET_OK; | using mindspore::lite::RET_OK; | ||||
| using mindspore::schema::PrimitiveType_BiasAdd; | using mindspore::schema::PrimitiveType_BiasAdd; | ||||
| @@ -34,14 +35,18 @@ int BiasAddInt8CPUKernel::Init() { | |||||
| int BiasAddInt8CPUKernel::ReSize() { | int BiasAddInt8CPUKernel::ReSize() { | ||||
| auto bias_param = reinterpret_cast<ArithmeticParameter *>(op_parameter_); | auto bias_param = reinterpret_cast<ArithmeticParameter *>(op_parameter_); | ||||
| auto dims = in_tensors_[0]->shape(); | |||||
| auto dims = in_tensors_.at(0)->shape(); | |||||
| bias_param->ndim_ = dims.size(); | bias_param->ndim_ = dims.size(); | ||||
| if (bias_param->ndim_ < 1 || bias_param->ndim_ > 5) { | |||||
| MS_LOG(ERROR) << "input shape is invalid"; | |||||
| return RET_ERROR; | |||||
| } | |||||
| for (size_t i = 0; i < bias_param->ndim_; i++) { | for (size_t i = 0; i < bias_param->ndim_; i++) { | ||||
| bias_param->in_shape0_[i] = dims[i]; | bias_param->in_shape0_[i] = dims[i]; | ||||
| bias_param->in_shape1_[i] = 1; | bias_param->in_shape1_[i] = 1; | ||||
| bias_param->out_shape_[i] = dims[i]; | bias_param->out_shape_[i] = dims[i]; | ||||
| } | } | ||||
| bias_param->in_shape1_[3] = dims[3]; | |||||
| bias_param->in_shape1_[bias_param->ndim_ - 1] = dims[bias_param->ndim_ - 1]; | |||||
| return RET_OK; | return RET_OK; | ||||
| } | } | ||||
| @@ -239,7 +239,7 @@ int Convolution1x1Int8CPUKernel::InitWeightBias() { | |||||
| } | } | ||||
| memset(bias_data_, 0, size * sizeof(int32_t)); | memset(bias_data_, 0, size * sizeof(int32_t)); | ||||
| if (in_tensors_.size() == 3) { | if (in_tensors_.size() == 3) { | ||||
| memcpy(bias_data_, in_tensors_[kBiasIndex]->data_c(), output_channel * sizeof(int32_t)); | |||||
| memcpy(bias_data_, in_tensors_.at(kBiasIndex)->data_c(), output_channel * sizeof(int32_t)); | |||||
| } | } | ||||
| InitBiasByzp(filter_tensor->data_c(), input_channel, output_channel, size); | InitBiasByzp(filter_tensor->data_c(), input_channel, output_channel, size); | ||||
| @@ -271,7 +271,7 @@ int Convolution1x1Int8CPUKernel::InitWeightBiasArm32() { | |||||
| } | } | ||||
| memset(bias_data_, 0, col2 * sizeof(int32_t)); | memset(bias_data_, 0, col2 * sizeof(int32_t)); | ||||
| if (in_tensors_.size() == 3) { | if (in_tensors_.size() == 3) { | ||||
| memcpy(bias_data_, in_tensors_[kBiasIndex]->data_c(), output_channel * sizeof(int32_t)); | |||||
| memcpy(bias_data_, in_tensors_.at(kBiasIndex)->data_c(), output_channel * sizeof(int32_t)); | |||||
| } | } | ||||
| InitBiasByzp(filter_tensor->MutableData(), input_channel, output_channel, col2); | InitBiasByzp(filter_tensor->MutableData(), input_channel, output_channel, col2); | ||||
| @@ -42,7 +42,7 @@ ConvolutionDepthwise3x3Int8CPUKernel::~ConvolutionDepthwise3x3Int8CPUKernel() { | |||||
| int ConvolutionDepthwise3x3Int8CPUKernel::InitWeightBias() { | int ConvolutionDepthwise3x3Int8CPUKernel::InitWeightBias() { | ||||
| // init weight, int8 -> int16 | // init weight, int8 -> int16 | ||||
| auto weight_tensor = in_tensors_[kWeightIndex]; | |||||
| auto weight_tensor = in_tensors_.at(kWeightIndex); | |||||
| auto origin_weight = reinterpret_cast<int8_t *>(weight_tensor->MutableData()); | auto origin_weight = reinterpret_cast<int8_t *>(weight_tensor->MutableData()); | ||||
| int channel = weight_tensor->Batch(); | int channel = weight_tensor->Batch(); | ||||
| if (channel % 8 != 0) { | if (channel % 8 != 0) { | ||||
| @@ -40,7 +40,7 @@ ConvolutionDepthwiseInt8CPUKernel::~ConvolutionDepthwiseInt8CPUKernel() { | |||||
| int ConvolutionDepthwiseInt8CPUKernel::InitWeightBias() { | int ConvolutionDepthwiseInt8CPUKernel::InitWeightBias() { | ||||
| // init weight, int8 -> int16 | // init weight, int8 -> int16 | ||||
| auto weight_tensor = in_tensors_[kWeightIndex]; | |||||
| auto weight_tensor = in_tensors_.at(kWeightIndex); | |||||
| auto origin_weight = reinterpret_cast<int8_t *>(weight_tensor->MutableData()); | auto origin_weight = reinterpret_cast<int8_t *>(weight_tensor->MutableData()); | ||||
| int channel = weight_tensor->Batch(); | int channel = weight_tensor->Batch(); | ||||
| int pack_weight_size = channel * weight_tensor->Height() * weight_tensor->Width(); | int pack_weight_size = channel * weight_tensor->Height() * weight_tensor->Width(); | ||||
| @@ -171,7 +171,8 @@ kernel::LiteKernel *CpuConvDwInt8KernelCreator(const std::vector<lite::Tensor *> | |||||
| MS_ASSERT(opParameter != nullptr); | MS_ASSERT(opParameter != nullptr); | ||||
| MS_ASSERT(desc.type == schema::PrimitiveType_DepthwiseConv2D); | MS_ASSERT(desc.type == schema::PrimitiveType_DepthwiseConv2D); | ||||
| kernel::LiteKernel *kernel = nullptr; | kernel::LiteKernel *kernel = nullptr; | ||||
| auto act_quant_size = MSMAX(inputs[kInputIndex]->quant_params().size(), outputs[kOutputIndex]->quant_params().size()); | |||||
| auto act_quant_size = | |||||
| MSMAX(inputs.at(kInputIndex)->quant_params().size(), outputs.at(kOutputIndex)->quant_params().size()); | |||||
| if (act_quant_size == 1) { // per tensor | if (act_quant_size == 1) { // per tensor | ||||
| auto conv_param = reinterpret_cast<ConvParameter *>(opParameter); | auto conv_param = reinterpret_cast<ConvParameter *>(opParameter); | ||||
| if (primitive != nullptr && primitive->infer_flag()) { | if (primitive != nullptr && primitive->infer_flag()) { | ||||
| @@ -44,7 +44,7 @@ ConvolutionDepthwiseSWInt8CPUKernel::~ConvolutionDepthwiseSWInt8CPUKernel() { | |||||
| int ConvolutionDepthwiseSWInt8CPUKernel::InitWeightBias() { | int ConvolutionDepthwiseSWInt8CPUKernel::InitWeightBias() { | ||||
| // init weight, int8 -> int16 | // init weight, int8 -> int16 | ||||
| // o, h, w, i -> o/8, h, w, i, 8; o == group, i == 1 | // o, h, w, i -> o/8, h, w, i, 8; o == group, i == 1 | ||||
| auto weight_tensor = in_tensors_[kWeightIndex]; | |||||
| auto weight_tensor = in_tensors_.at(kWeightIndex); | |||||
| auto origin_weight = reinterpret_cast<int8_t *>(weight_tensor->MutableData()); | auto origin_weight = reinterpret_cast<int8_t *>(weight_tensor->MutableData()); | ||||
| int OC8 = UP_DIV(weight_tensor->Batch(), C8NUM); | int OC8 = UP_DIV(weight_tensor->Batch(), C8NUM); | ||||
| int pack_weight_size = C8NUM * OC8 * weight_tensor->Height() * weight_tensor->Width(); | int pack_weight_size = C8NUM * OC8 * weight_tensor->Height() * weight_tensor->Width(); | ||||
| @@ -43,7 +43,7 @@ DeconvolutionDepthwiseInt8CPUKernel::~DeconvolutionDepthwiseInt8CPUKernel() { | |||||
| int DeconvolutionDepthwiseInt8CPUKernel::InitWeightBias() { | int DeconvolutionDepthwiseInt8CPUKernel::InitWeightBias() { | ||||
| // init weight: int8 -> int16 | // init weight: int8 -> int16 | ||||
| // o, h, w, i -> o/8, h, w, i, 8; o == group, i == 1 | // o, h, w, i -> o/8, h, w, i, 8; o == group, i == 1 | ||||
| auto weight_tensor = in_tensors_[kWeightIndex]; | |||||
| auto weight_tensor = in_tensors_.at(kWeightIndex); | |||||
| auto origin_weight = reinterpret_cast<int8_t *>(weight_tensor->MutableData()); | auto origin_weight = reinterpret_cast<int8_t *>(weight_tensor->MutableData()); | ||||
| int OC4 = UP_DIV(weight_tensor->Batch(), C4NUM); | int OC4 = UP_DIV(weight_tensor->Batch(), C4NUM); | ||||
| int pack_weight_size = C4NUM * OC4 * weight_tensor->Height() * weight_tensor->Width(); | int pack_weight_size = C4NUM * OC4 * weight_tensor->Height() * weight_tensor->Width(); | ||||
| @@ -132,7 +132,7 @@ int DeConvInt8CPUKernel::InitBiasWeight() { | |||||
| } | } | ||||
| memset(bias_data_, 0, size); | memset(bias_data_, 0, size); | ||||
| if (in_tensors_.size() == 3) { | if (in_tensors_.size() == 3) { | ||||
| memcpy(bias_data_, in_tensors_[0]->MutableData(), conv_param_->output_channel_ * sizeof(int32_t)); | |||||
| memcpy(bias_data_, in_tensors_.at(0)->MutableData(), conv_param_->output_channel_ * sizeof(int32_t)); | |||||
| } | } | ||||
| size = UP_ROUND(conv_param_->output_channel_, C4NUM) * UP_ROUND(conv_param_->input_channel_, C16NUM) * | size = UP_ROUND(conv_param_->output_channel_, C4NUM) * UP_ROUND(conv_param_->input_channel_, C16NUM) * | ||||
| @@ -143,7 +143,7 @@ int DeConvInt8CPUKernel::InitBiasWeight() { | |||||
| return RET_ERROR; | return RET_ERROR; | ||||
| } | } | ||||
| memset(weight_ptr_, 0, size); | memset(weight_ptr_, 0, size); | ||||
| DeConvWeightTransInt8(reinterpret_cast<int8_t *>(in_tensors_[1]->MutableData()), weight_ptr_, | |||||
| DeConvWeightTransInt8(reinterpret_cast<int8_t *>(in_tensors_.at(1)->MutableData()), weight_ptr_, | |||||
| conv_param_->input_channel_, conv_param_->output_channel_, | conv_param_->input_channel_, conv_param_->output_channel_, | ||||
| conv_param_->kernel_h_ * conv_param_->kernel_w_, support_optimize_); | conv_param_->kernel_h_ * conv_param_->kernel_w_, support_optimize_); | ||||
| @@ -64,7 +64,10 @@ int GatherNdInt8CPUKernel::ReSize() { | |||||
| for (int i = 0; i < indices_rank - 1; ++i) { | for (int i = 0; i < indices_rank - 1; ++i) { | ||||
| count_ *= indices_shape[i]; | count_ *= indices_shape[i]; | ||||
| } | } | ||||
| if (count_ >= std::numeric_limits<int>::max() / static_cast<int>(sizeof(int))) { | |||||
| MS_LOG(ERROR) << "count_ is invalid, count_: " << count_; | |||||
| return RET_ERROR; | |||||
| } | |||||
| in_offset_ = reinterpret_cast<int *>(malloc(count_ * sizeof(int))); | in_offset_ = reinterpret_cast<int *>(malloc(count_ * sizeof(int))); | ||||
| if (in_offset_ == nullptr) { | if (in_offset_ == nullptr) { | ||||
| MS_LOG(ERROR) << "GatherNdInt8 Malloc in_offset_ error!"; | MS_LOG(ERROR) << "GatherNdInt8 Malloc in_offset_ error!"; | ||||
| @@ -164,8 +164,8 @@ STATUS OnnxConvParser::Parse(const onnx::GraphProto &onnx_graph, const onnx::Nod | |||||
| } | } | ||||
| dims.insert(dims.begin(), iter->ints().begin(), iter->ints().end()); | dims.insert(dims.begin(), iter->ints().begin(), iter->ints().end()); | ||||
| } | } | ||||
| attr->channelOut = dims[0]; | |||||
| attr->channelIn = dims[3] * attr->group; | |||||
| attr->channelOut = dims.at(0); | |||||
| attr->channelIn = dims.at(3) * attr->group; | |||||
| } | } | ||||
| attr->hasBias = onnx_node.input().size() == 3; | attr->hasBias = onnx_node.input().size() == 3; | ||||
| if (onnx_node.op_type() == "ConvRelu" || onnx_node.op_type() == "Int8ConvRelu") { | if (onnx_node.op_type() == "ConvRelu" || onnx_node.op_type() == "Int8ConvRelu") { | ||||