Browse Source

Remove cast operator which converts data from fp32 to fp16 in models generated by MindSpore.

tags/v1.0.0
wsc 5 years ago
parent
commit
07d7665f27
2 changed files with 17 additions and 3 deletions
  1. +2
    -2
      mindspore/lite/nnacl/split_parameter.h
  2. +15
    -1
      mindspore/lite/tools/converter/legacy_optimizer/graph/unused_node_remove_pass.cc

+ 2
- 2
mindspore/lite/nnacl/split_parameter.h View File

@@ -24,8 +24,8 @@ typedef struct SplitParameter {
OpParameter op_parameter_; OpParameter op_parameter_;
SplitQuantArg quant_arg_; SplitQuantArg quant_arg_;
int num_split_; int num_split_;
int split_sizes_[20];
int strides_[20];
int split_sizes_[32];
int strides_[32];
int split_dim_; int split_dim_;
int n_dims_; int n_dims_;
int split_count_; int split_count_;


+ 15
- 1
mindspore/lite/tools/converter/legacy_optimizer/graph/unused_node_remove_pass.cc View File

@@ -25,15 +25,29 @@
#include "tools/common/graph_util.h" #include "tools/common/graph_util.h"
#include "include/errorcode.h" #include "include/errorcode.h"
#include "mindspore/lite/schema/inner/model_generated.h" #include "mindspore/lite/schema/inner/model_generated.h"
#include "mindspore/core/ir/dtype/type_id.h"


namespace mindspore { namespace mindspore {
namespace lite { namespace lite {
bool IsUnusedNode(const CNodeT &node) {
if (node.primitive->value.type == schema::PrimitiveType_TupleGetItem) {
return true;
}
if (node.primitive->value.type == schema::PrimitiveType_Cast) {
auto attr = reinterpret_cast<schema::CastT *>(node.primitive->value.value);
if (attr->srcT == kNumberTypeFloat32 && attr->dstT == kNumberTypeFloat16) {
return true;
}
}
return false;
}

STATUS UnusedNodeRemovePass::Run(schema::MetaGraphT *graph) { STATUS UnusedNodeRemovePass::Run(schema::MetaGraphT *graph) {
MS_ASSERT(graph != nullptr); MS_ASSERT(graph != nullptr);
bool ifChanged = false; bool ifChanged = false;
for (size_t i = 0; i < graph->nodes.size(); i++) { for (size_t i = 0; i < graph->nodes.size(); i++) {
auto &node = graph->nodes.at(i); auto &node = graph->nodes.at(i);
if (node->primitive->value.type == schema::PrimitiveType_TupleGetItem) {
if (IsUnusedNode(*node)) {
ifChanged = true; ifChanged = true;
auto status = IsolateOneWayNode(graph, i); auto status = IsolateOneWayNode(graph, i);
if (status != RET_OK) { if (status != RET_OK) {


Loading…
Cancel
Save