diff --git a/mindspore/lite/src/common/anf_exporter/anf_exporter.cc b/mindspore/lite/src/common/anf_exporter/anf_exporter.cc index e375bcaf4ae36ce31c9b050b76a84efd0cca04a9..1e36068b3ca2b5cc55694944cdf61a6bbc7babbe 100644 --- a/mindspore/lite/src/common/anf_exporter/anf_exporter.cc +++ b/mindspore/lite/src/common/anf_exporter/anf_exporter.cc @@ -241,6 +241,9 @@ void AnfExporter::SetOpInputNode(const CNodePtr &cnode, schema::MetaGraphT *meta nodeIdMap[valueNode->fullname_with_scope()] = meta_graph->allTensors.size(); fbNode->inputIndex.emplace_back(meta_graph->allTensors.size()); meta_graph->allTensors.emplace_back(std::move(paramTensor)); + } else if (value->isa()) { + MS_LOG(INFO) << "Value type is ValueSequence."; + break; } else { MS_LOG(ERROR) << "Not support value type , need add support."; } diff --git a/mindspore/lite/src/common/anf_exporter/anf_populater/anf_reducemean_populater.cc b/mindspore/lite/src/common/anf_exporter/anf_populater/anf_reducemean_populater.cc index e7f5f71ff492f1ecf9cafa8f3c36b01ea9243274..8ec0a93cfeb152508cb4676d28fdd0e406c7e347 100644 --- a/mindspore/lite/src/common/anf_exporter/anf_populater/anf_reducemean_populater.cc +++ b/mindspore/lite/src/common/anf_exporter/anf_populater/anf_reducemean_populater.cc @@ -21,6 +21,10 @@ #include "ir/primitive.h" namespace mindspore::lite { +namespace { + constexpr int kReduceInputNum = 3; + constexpr int kReduceInputIndex = 2; +} int mindspore::lite::AnfReduceMeanPopulater::Parse(CNodePtr cnodePtr, schema::CNodeT *node, std::vector *outputs) { auto p = GetCNodePrimitive(cnodePtr); @@ -28,7 +32,25 @@ int mindspore::lite::AnfReduceMeanPopulater::Parse(CNodePtr cnodePtr, schema::CN attr->mode = schema::ReduceMode_ReduceMean; attr->keepDims = GetValue(p->GetAttr("keep_dims")); - // attr->axes = GetValue>(p->GetAttr("shape")); + if (cnodePtr->inputs().size() == kReduceInputNum) { + auto inputNode = cnodePtr->input(kReduceInputIndex); + MS_ASSERT(inputNode != nullptr); + if (inputNode->isa()) { + auto valueNode = inputNode->cast(); + MS_ASSERT(valueNode != nullptr); + auto value = valueNode->value(); + MS_ASSERT(value != nullptr); + if (value->isa()) { + auto valTuplPtr = dyn_cast(value); + MS_ASSERT(valTuplPtr != nullptr); + for (size_t i = 0; i < valTuplPtr->size(); i++) { + auto elem = dyn_cast((*valTuplPtr)[i]); + MS_ASSERT(elem != nullptr); + attr->axes.emplace_back(elem->value()); + } + } + } + } node->nodeType = schema::NodeType_CNode; node->primitive = std::make_unique();