Browse Source

improve code in tolls

pull/8735/head
guohongzilong 5 years ago
parent
commit
a9bf758324
17 changed files with 96 additions and 39 deletions
  1. +0
    -2
      mindspore/lite/tools/anf_importer/anf_importer.cc
  2. +29
    -2
      mindspore/lite/tools/anf_importer/import_from_meta_graphT.cc
  3. +1
    -1
      mindspore/lite/tools/anf_importer/import_from_meta_graphT.h
  4. +43
    -10
      mindspore/lite/tools/anf_importer/import_from_protobuf.cc
  5. +1
    -1
      mindspore/lite/tools/anf_importer/import_from_protobuf.h
  6. +1
    -1
      mindspore/lite/tools/optimizer/fusion/constant_folding_fusion.cc
  7. +0
    -1
      mindspore/lite/tools/optimizer/fusion/conv_activation_fusion.cc
  8. +3
    -3
      mindspore/lite/tools/optimizer/fusion/conv_activation_fusion.h
  9. +5
    -0
      mindspore/lite/tools/optimizer/fusion/conv_bn_fusion.cc
  10. +0
    -1
      mindspore/lite/tools/optimizer/fusion/conv_scale_fusion.cc
  11. +5
    -5
      mindspore/lite/tools/optimizer/fusion/conv_transform_fusion.cc
  12. +0
    -1
      mindspore/lite/tools/optimizer/fusion/conv_tuple_activation_fusion.cc
  13. +3
    -3
      mindspore/lite/tools/optimizer/fusion/conv_tuple_activation_fusion.h
  14. +0
    -1
      mindspore/lite/tools/optimizer/fusion/layer_norm_fusion.h
  15. +1
    -3
      mindspore/lite/tools/optimizer/fusion/pooling_activation_fusion.cc
  16. +3
    -3
      mindspore/lite/tools/optimizer/fusion/pooling_activation_fusion.h
  17. +1
    -1
      mindspore/lite/tools/optimizer/graph/clip_convert_activation_pass.cc

+ 0
- 2
mindspore/lite/tools/anf_importer/anf_importer.cc View File

@@ -15,8 +15,6 @@
*/

#include <utility>
#include <memory>
#include <vector>
#include "tools/anf_importer/anf_importer.h"
#include "schema/model_generated.h"
#include "ir/dtype.h"


+ 29
- 2
mindspore/lite/tools/anf_importer/import_from_meta_graphT.cc View File

@@ -22,7 +22,6 @@
#include "src/param_value_lite.h"
#include "src/common/log_adapter.h"
#include "include/errorcode.h"
#include "tools/common/tensor_util.h"

namespace mindspore::lite {
int AnfImporterFromMetaGraphT::ConverterConstTensor() {
@@ -57,7 +56,11 @@ int AnfImporterFromMetaGraphT::ConverterConstTensor() {
MS_LOG(ERROR) << "new char[] failed";
return RET_MEMORY_FAILED;
}
std::memcpy(tensor_data, tensor->data.data(), size);
auto ret = memcpy_s(tensor_data, size, tensor->data.data(), size);
if (EOK != ret) {
MS_LOG(ERROR) << "memcpy_s error";
return RET_MEMORY_FAILED;
}
param_value->set_tensor_addr(tensor_data);
param_value->set_tensor_size(size);
parameter->set_default_param(param_value);
@@ -145,8 +148,16 @@ int AnfImporterFromMetaGraphT::ConvertAbstract(const std::unique_ptr<schema::CNo
}
auto tuple_get_item_prim = NewValueNode(tuple_get_item_prim_ptr);
auto get_item_value = NewValueNode(MakeValue<int>(i));
if (tuple_get_item_prim == nullptr || get_item_value == nullptr) {
MS_LOG(ERROR) << "NewValueNode is nullptr";
return RET_NULL_PTR;
}
std::vector<AnfNodePtr> inputs{tuple_get_item_prim, dst_cnode, get_item_value};
CNodePtr get_item_cnode = func_graph_->NewCNode(inputs);
if (get_item_cnode == nullptr) {
MS_LOG(ERROR) << "NewCNode is nullptr";
return RET_NULL_PTR;
}
get_item_cnode->set_fullname_with_scope(src_cnode->name + "_getitem_" + std::to_string(i));
AddNode(out_tensor_id, get_item_cnode);
}
@@ -175,6 +186,10 @@ int AnfImporterFromMetaGraphT::ConverterCNode() {
op_inputs.push_back(node);
}
auto new_cnode = func_graph_->NewCNode(op_inputs);
if (new_cnode == nullptr) {
MS_LOG(ERROR) << "NewCNode is nullptr";
return RET_NULL_PTR;
}
new_cnode->set_fullname_with_scope(cNode->name);
auto status = ConvertAbstract(cNode, new_cnode);
if (status != RET_OK) {
@@ -208,6 +223,10 @@ int AnfImporterFromMetaGraphT::AddReturnCNode() {
make_tuple_inputs.emplace_back(cNode);
}
auto make_tuple_cnode = func_graph_->NewCNode(make_tuple_inputs);
if (make_tuple_cnode == nullptr) {
MS_LOG(ERROR) << "NewCNode is nullptr";
return RET_NULL_PTR;
}
make_tuple_cnode->set_fullname_with_scope("return tuple");

std::vector<AnfNodePtr> op_inputs;
@@ -220,6 +239,10 @@ int AnfImporterFromMetaGraphT::AddReturnCNode() {
op_inputs.emplace_back(value_node);
op_inputs.emplace_back(make_tuple_cnode);
auto cnode = func_graph_->NewCNode(op_inputs);
if (cnode == nullptr) {
MS_LOG(ERROR) << "NewCNode is nullptr";
return RET_NULL_PTR;
}
cnode->set_fullname_with_scope("return");
func_graph_->set_return(cnode);
} else {
@@ -237,6 +260,10 @@ int AnfImporterFromMetaGraphT::AddReturnCNode() {
}
op_inputs.emplace_back(cnode);
auto return_cnode = func_graph_->NewCNode(op_inputs);
if (return_cnode == nullptr) {
MS_LOG(ERROR) << "NewCNode is nullptr";
return RET_NULL_PTR;
}
return_cnode->set_fullname_with_scope("return");
func_graph_->set_return(return_cnode);
}


+ 1
- 1
mindspore/lite/tools/anf_importer/import_from_meta_graphT.h View File

@@ -27,7 +27,7 @@
namespace mindspore::lite {
class AnfImporterFromMetaGraphT : public AnfImporter {
public:
explicit AnfImporterFromMetaGraphT(schema::MetaGraphT *meta_graph, FuncGraphPtr func_graph)
AnfImporterFromMetaGraphT(schema::MetaGraphT *meta_graph, FuncGraphPtr func_graph)
: meta_graph_(meta_graph), func_graph_(std::move(func_graph)) {}

~AnfImporterFromMetaGraphT() override = default;


+ 43
- 10
mindspore/lite/tools/anf_importer/import_from_protobuf.cc View File

@@ -15,11 +15,7 @@
*/

#include "tools/anf_importer/import_from_protobuf.h"

#include <fcntl.h>
#include <unistd.h>

#include <fstream>
#include <map>
#include <memory>
#include <stack>
@@ -44,7 +40,6 @@ using int64 = int64_t;
using uint64 = uint64_t;

namespace mindspore::lite {

static constexpr char kConstantValueNode[] = "Constant";

enum ParseForm : int {
@@ -213,7 +208,7 @@ int AnfImporterFromProtobuf::BuildParameterForFuncGraph(const ParameterPtr &node
node->set_name(value_proto.name());
const auto &type_proto = value_proto.type();
if (!type_proto.has_tensor_type()) {
MS_LOG(ERROR) << "onnx TypeProto has no tesor_type! ";
MS_LOG(ERROR) << "onnx TypeProto has no tensor_type! ";
return RET_PARAM_INVALID;
}
const onnx::TypeProto_Tensor &tensor_typeproto = type_proto.tensor_type();
@@ -237,7 +232,7 @@ int AnfImporterFromProtobuf::BuildParameterForFuncGraph(const ParameterPtr &node
node->set_abstract(abstract_tensor);

if (default_para_map_.find(value_proto.name()) != default_para_map_.end()) {
Tensor *tensor_info = new Tensor(kDefaultValueSwitchMap[tensor_typeproto.elem_type()], shape);
Tensor *tensor_info = new (std::nothrow) Tensor(kDefaultValueSwitchMap[tensor_typeproto.elem_type()], shape);
if (tensor_info == nullptr) {
return RET_MEMORY_FAILED;
}
@@ -246,6 +241,7 @@ int AnfImporterFromProtobuf::BuildParameterForFuncGraph(const ParameterPtr &node
std::string initial_data = initialize_proto.raw_data();
auto *tensor_data_buf = reinterpret_cast<uint8_t *>(tensor_info->MutableData());
if (tensor_data_buf == nullptr) {
delete tensor_info;
return RET_MEMORY_FAILED;
}
tensor_info->set_data(nullptr);
@@ -259,6 +255,7 @@ int AnfImporterFromProtobuf::BuildParameterForFuncGraph(const ParameterPtr &node

ParamValueLitePtr param_value = std::make_shared<ParamValueLite>();
if (param_value == nullptr) {
delete tensor_info;
return RET_NULL_PTR;
}
param_value->set_tensor_addr(tensor_data_buf);
@@ -362,22 +359,38 @@ bool AnfImporterFromProtobuf::ObtainCNodeAttrInTensorForm(const PrimitivePtr &pr
tensor::TensorPtr tensor_info = std::make_shared<tensor::Tensor>(kDefaultValueSwitchMap[attr_tensor_type], shape);
auto *tensor_data_buf = reinterpret_cast<uint8_t *>(tensor_info->data_c());
ret = memcpy_s(tensor_data_buf, tensor_info->Size(), tensor_buf.data(), tensor_buf.size());
if (EOK != ret) {
MS_LOG(ERROR) << "memcpy_s error";
return false;
}
prim->set_attr(attr_name, MakeValue(tensor_info));
} else {
if (attr_tensor_type == onnx::TensorProto_DataType_DOUBLE) {
size_t data_size = sizeof(double);
double attr_value = 0.0;
ret = memcpy_s(&attr_value, data_size, tensor_buf.data(), tensor_buf.size());
if (EOK != ret) {
MS_LOG(ERROR) << "memcpy_s error";
return false;
}
prim->set_attr(attr_name, MakeValue<double>(attr_value));
} else if (attr_tensor_type == onnx::TensorProto_DataType_INT64) {
size_t data_size = sizeof(int64_t);
int64_t attr_value = 0;
ret = memcpy_s(&attr_value, data_size, tensor_buf.data(), tensor_buf.size());
if (EOK != ret) {
MS_LOG(ERROR) << "memcpy_s error";
return false;
}
prim->set_attr(attr_name, MakeValue<int64_t>(attr_value));
} else if (attr_tensor_type == onnx::TensorProto_DataType_BOOL) {
size_t data_size = sizeof(bool);
bool attr_value = false;
ret = memcpy_s(&attr_value, data_size, tensor_buf.data(), tensor_buf.size());
if (EOK != ret) {
MS_LOG(ERROR) << "memcpy_s error";
return false;
}
prim->set_attr(attr_name, MakeValue<bool>(attr_value));
}
}
@@ -394,7 +407,7 @@ bool AnfImporterFromProtobuf::GetAttrValueForCNode(const PrimitivePtr &prim, con
return false;
}
const std::string &ref_attr_name = attr_proto.ref_attr_name();
string type;
string type = "";
std::size_t pos(0);
if ((pos = ref_attr_name.find("scalar:")) != std::string::npos) {
type = ref_attr_name.substr(pos, string("scalar:").length() - 1);
@@ -443,6 +456,10 @@ bool AnfImporterFromProtobuf::ObtainValueNodeInTensorForm(const std::string &val
shape.push_back(attr_tensor.dims(i));
}
tensor::TensorPtr tensor_info = std::make_shared<tensor::Tensor>(kDefaultValueSwitchMap[attr_tensor_type], shape);
if (tensor_info == nullptr) {
MS_LOG(ERROR) << "tensor_info is nullptr";
return false;
}
const std::string &tensor_buf = attr_tensor.raw_data();
auto *tensor_data_buf = reinterpret_cast<uint8_t *>(tensor_info->data_c());
auto ret = memcpy_s(tensor_data_buf, tensor_info->Size(), tensor_buf.data(), tensor_buf.size());
@@ -482,7 +499,7 @@ bool AnfImporterFromProtobuf::GetAttrValueForValueNode(const std::string &value_
return false;
}
const std::string &ref_attr_name = attr_proto.ref_attr_name();
string type;
string type = "";
std::size_t pos(0);
if ((pos = ref_attr_name.find("scalar:")) != std::string::npos) {
type = ref_attr_name.substr(pos, string("scalar:").length() - 1);
@@ -658,9 +675,17 @@ bool AnfImporterFromProtobuf::BuildReturnForFuncGraph(const FuncGraphPtr &output
const onnx::ValueInfoProto &output_node = importProto.output(out_size);
const std::string &out_tuple = output_node.name();
inputs.push_back(anfnode_build_map_[out_tuple]);
if (anfnode_build_map_[out_tuple] == nullptr) {
MS_LOG(ERROR) << "AnfNode is nullptr";
return false;
}
elem.push_back(anfnode_build_map_[out_tuple]->abstract());
}
auto maketuple_ptr = outputFuncGraph->NewCNode(inputs);
if (maketuple_ptr == nullptr) {
MS_LOG(ERROR) << "maketuple_ptr is nullptr";
return false;
}
maketuple_ptr->set_abstract(std::make_shared<abstract::AbstractTuple>(elem));
inputs.clear();
auto primReturn = std::make_unique<schema::PrimitiveT>();
@@ -830,6 +855,10 @@ int AnfImporterFromProtobuf::Import(const schema::QuantType &quantType) {
MS_LOG(ERROR) << "Parse configuration info for pb file failed!";
return status;
}
if (onnx_model_ == nullptr) {
MS_LOG(ERROR) << "onnx_model_ is nullptr";
return RET_NULL_PTR;
}
const onnx::GraphProto &graphBuild = onnx_model_->graph();
status = BuildFuncGraph(dstGraph, graphBuild, quantType);
if (status != RET_OK) {
@@ -843,7 +872,11 @@ int AnfImporterFromProtobuf::Import(const schema::QuantType &quantType) {
}

onnx::ModelProto *AnfImporterFromProtobuf::ReadOnnxFromBinary(const std::string &model_path) {
auto onnx_model = new onnx::ModelProto;
auto onnx_model = new (std::nothrow) onnx::ModelProto;
if (onnx_model == nullptr) {
MS_LOG(ERROR) << "new onnx ModelProto failed!";
return nullptr;
}
if (ReadProtoFromBinaryFile((const char *)model_path.c_str(), onnx_model) != RET_OK) {
MS_LOG(ERROR) << "Read onnx model file failed, model path: " << model_path;
return nullptr;


+ 1
- 1
mindspore/lite/tools/anf_importer/import_from_protobuf.h View File

@@ -31,7 +31,7 @@
namespace mindspore::lite {
class AnfImporterFromProtobuf : public AnfImporter {
public:
explicit AnfImporterFromProtobuf(onnx::ModelProto *onnx_model, FuncGraphPtr func_graph)
AnfImporterFromProtobuf(onnx::ModelProto *onnx_model, FuncGraphPtr func_graph)
: onnx_model_(onnx_model), func_graph_(std::move(func_graph)) {}

~AnfImporterFromProtobuf() override = default;


+ 1
- 1
mindspore/lite/tools/optimizer/fusion/constant_folding_fusion.cc View File

@@ -198,7 +198,7 @@ const AnfNodePtr ConstFoldPass::Process(const FuncGraphPtr &func_graph, const An
auto output_nums = GetOutputTensorNum(input_cnode);
std::vector<Tensor *> output_tensors;
for (size_t j = 0; j < output_nums; j++) {
output_tensors.push_back(new Tensor());
output_tensors.push_back(new (std::nothrow) Tensor());
}
auto lite_primitive = GetValueNode<std::shared_ptr<PrimitiveC>>(input_cnode->input(0));
if (lite_primitive == nullptr) {


+ 0
- 1
mindspore/lite/tools/optimizer/fusion/conv_activation_fusion.cc View File

@@ -32,7 +32,6 @@ const BaseRef ConvActivationFusion::DefinePattern() const {
auto prim = new schema::PrimitiveT();
prim->value.type = primitive_type;
auto prim_value = std::make_shared<lite::PrimitiveC>(prim);

return VectorRef({prim_value, conv_var});
}



+ 3
- 3
mindspore/lite/tools/optimizer/fusion/conv_activation_fusion.h View File

@@ -25,9 +25,9 @@ namespace mindspore {
namespace opt {
class ConvActivationFusion : public PatternProcessPass {
public:
explicit ConvActivationFusion(bool multigraph = true, const std::string &name = "conv_activation_fusion",
schema::PrimitiveType primitive = schema::PrimitiveType_LeakyReLU,
schema::ActivationType activation = schema::ActivationType_LEAKY_RELU)
ConvActivationFusion(bool multigraph = true, const std::string &name = "conv_activation_fusion",
schema::PrimitiveType primitive = schema::PrimitiveType_LeakyReLU,
schema::ActivationType activation = schema::ActivationType_LEAKY_RELU)
: PatternProcessPass(name, multigraph), primitive_type(primitive), activation_type(activation) {}
~ConvActivationFusion() override = default;
const BaseRef DefinePattern() const override;


+ 5
- 0
mindspore/lite/tools/optimizer/fusion/conv_bn_fusion.cc View File

@@ -57,6 +57,11 @@ void CalTransale(const AnfNodePtr &bn_scale_node, const AnfNodePtr &bn_var_node,
for (int32_t i = 0; i < kernel_num; i++) {
float tmp = trans_scale[i] + eps;
tmp = pow(tmp, POW_NUM);
if (tmp <= 0.0f) {
MS_LOG(ERROR) << "divisor cannot be 0";
lite::ReturnCode::GetSingleReturnCode()->UpdateReturnCode(lite::RET_ERROR);
return;
}
trans_scale[i] = 1 / tmp;
}
if (bn_scale_node != nullptr) {


+ 0
- 1
mindspore/lite/tools/optimizer/fusion/conv_scale_fusion.cc View File

@@ -42,7 +42,6 @@ const BaseRef ConvScaleFusion::DefinePattern() const {
auto bn_var = std::make_shared<CondVar>(IsScaleNode);
auto weight_var = std::make_shared<CondVar>(IsParamNode);
auto bias_var = std::make_shared<SeqVar>();

return VectorRef({bn_var, conv_var, weight_var, bias_var});
}
const void ConvScaleFusion::InitTransParam(const CNodePtr &scale_node, int kernel_num, float *trans_scale,


+ 5
- 5
mindspore/lite/tools/optimizer/fusion/conv_transform_fusion.cc View File

@@ -86,14 +86,12 @@ const AnfNodePtr ConvTransformFusion::Process(const FuncGraphPtr &func_graph, co
auto trans_scale = new (std::nothrow) float[kernel_nums];
if (trans_scale == nullptr) {
MS_LOG(ERROR) << "tensor_data is nullptr";
delete[] trans_scale;
return nullptr;
}
auto trans_bias = new (std::nothrow) float[kernel_nums];
if (trans_bias == nullptr) {
MS_LOG(ERROR) << "tensor_data is nullptr";
delete[] trans_scale;
delete[] trans_bias;
return nullptr;
}
GenTransParam(transform_node, kernel_nums, trans_scale, trans_bias);
@@ -179,11 +177,10 @@ const void ConvTransformFusion::GenNewConvTensor(const FuncGraphPtr &func_graph,
if (kernel_num <= 0) {
MS_LOG(ERROR) << "kernel num less than 0";
lite::ReturnCode::GetSingleReturnCode()->UpdateReturnCode(lite::RET_INVALID_OP_ATTR);
return;
}
auto kernel_size = weight_tensor->tensor_shape_size() / kernel_num;

CalNewWeightTensor(weight_data, kernel_num, kernel_size, trans_scale);

float *bias_data = nullptr;
// conv has bias,bias_flag true
bool bias_flag = false;
@@ -196,7 +193,6 @@ const void ConvTransformFusion::GenNewConvTensor(const FuncGraphPtr &func_graph,
bias_data = new (std::nothrow) float[kernel_num];
if (bias_data == nullptr) {
MS_LOG(ERROR) << "tensor_data is nullptr";
delete[] bias_data;
return;
}
}
@@ -211,6 +207,10 @@ const void ConvTransformFusion::CalNewWeightTensor(float *weight_data, int kerne
const float *trans_scale) const {
MS_ASSERT(weight_data != nullptr);
auto tmp_weight_data = new (std::nothrow) float[kernel_num * kernel_size];
if (tmp_weight_data == nullptr) {
lite::ReturnCode::GetSingleReturnCode()->UpdateReturnCode(lite::RET_MEMORY_FAILED);
return;
}
MS_ASSERT(new_weight_data != nullptr);
auto data_size = kernel_num * kernel_size * sizeof(float);
if (0 != memset_s(tmp_weight_data, data_size, 0, data_size)) {


+ 0
- 1
mindspore/lite/tools/optimizer/fusion/conv_tuple_activation_fusion.cc View File

@@ -38,7 +38,6 @@ const BaseRef ConvTupleActivationFusion::DefinePattern() const {
auto act_prim = new schema::PrimitiveT();
act_prim->value.type = primitive_type;
auto act_value = std::make_shared<lite::PrimitiveC>(act_prim);

return VectorRef({act_value, tuple_get_item});
}



+ 3
- 3
mindspore/lite/tools/optimizer/fusion/conv_tuple_activation_fusion.h View File

@@ -25,9 +25,9 @@ namespace mindspore {
namespace opt {
class ConvTupleActivationFusion : public PatternProcessPass {
public:
explicit ConvTupleActivationFusion(bool multigraph = true, const std::string &name = "conv_tuple_activation_fusion",
schema::PrimitiveType primitive = schema::PrimitiveType_LeakyReLU,
schema::ActivationType activation = schema::ActivationType_LEAKY_RELU)
ConvTupleActivationFusion(bool multigraph = true, const std::string &name = "conv_tuple_activation_fusion",
schema::PrimitiveType primitive = schema::PrimitiveType_LeakyReLU,
schema::ActivationType activation = schema::ActivationType_LEAKY_RELU)
: PatternProcessPass(name, multigraph), primitive_type(primitive), activation_type(activation) {}
~ConvTupleActivationFusion() override = default;
const BaseRef DefinePattern() const override;


+ 0
- 1
mindspore/lite/tools/optimizer/fusion/layer_norm_fusion.h View File

@@ -48,7 +48,6 @@ class LayerNormFusion : public PatternProcessPass {
VarPtr beta_;
VarPtr epsilon_;
};

} // namespace opt
} // namespace mindspore



+ 1
- 3
mindspore/lite/tools/optimizer/fusion/pooling_activation_fusion.cc View File

@@ -28,14 +28,13 @@ constexpr size_t kActivationInputsLength = 2;
}
const BaseRef PoolingActivationFusion::DefinePattern() const {
auto pooling_var = std::make_shared<CondVar>(IsPoolingNode)();
auto prim = new schema::PrimitiveT();
auto prim = new (std::nothrow) schema::PrimitiveT();
if (prim == nullptr) {
MS_LOG(ERROR) << "new primitiveT failed";
return nullptr;
}
prim->value.type = primitive_type;
auto prim_value = std::make_shared<lite::PrimitiveC>(prim);

return VectorRef({prim_value, pooling_var});
}

@@ -43,7 +42,6 @@ const AnfNodePtr PoolingActivationFusion::Process(const FuncGraphPtr &func_graph
const EquivPtr &) const {
MS_LOG(DEBUG) << "pooling activation pass process:" << schema::EnumNamesPrimitiveType()[primitive_type];
CheckIfFuncGraphIsNull(func_graph);

CheckIfAnfNodeIsNull(node);
auto act_node = node->cast<CNodePtr>();
CheckIfCNodeIsNull(act_node);


+ 3
- 3
mindspore/lite/tools/optimizer/fusion/pooling_activation_fusion.h View File

@@ -25,9 +25,9 @@ namespace mindspore {
namespace opt {
class PoolingActivationFusion : public PatternProcessPass {
public:
explicit PoolingAActivationFusion(bool multigraph = true, const std::string &name = "pooling_activation_fusion",
schema::PrimitiveType primitive = schema::PrimitiveType_LeakyReLU,
schema::ActivationType activation = schema::ActivationType_LEAKY_RELU)
PoolingAActivationFusion(bool multigraph = true, const std::string &name = "pooling_activation_fusion",
schema::PrimitiveType primitive = schema::PrimitiveType_LeakyReLU,
schema::ActivationType activation = schema::ActivationType_LEAKY_RELU)
: PatternProcessPass(name, multigraph), primitive_type(primitive), activation_type(activation) {}
~PoolingAActivationFusion() override = default;
const BaseRef DefinePattern() const override;


+ 1
- 1
mindspore/lite/tools/optimizer/graph/clip_convert_activation_pass.cc View File

@@ -75,7 +75,7 @@ bool ClipConvertActivationPass::Run(const FuncGraphPtr &graph) {
auto primitive = std::make_unique<schema::PrimitiveT>();
MS_ASSERT(primitive != nullptr);
primitive->value.type = schema::PrimitiveType_Activation;
auto prim2 = new schema::ActivationT;
auto prim2 = new (std::nothrow) schema::ActivationT;
MS_ASSERT(prim2 != nullptr);
if (min == 0 && max == 6) {
prim2->type = schema::ActivationType_RELU6;


Loading…
Cancel
Save