!6602 [MSLITE] Remove cast operator which convert data from fp32 to fp16 in MindSpore models.

Merge pull request !6602 from wangshaocong/lite_convert
pull/6602/MERGE
mindspore-ci-bot 4 years ago committed by Gitee
commit 76fb407717

@ -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 split_sizes_[32];
int strides_[20]; int strides_[32];
int split_dim_; int split_dim_;
int n_dims_; int n_dims_;
int split_count_; int split_count_;

@ -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