!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_;
SplitQuantArg quant_arg_;
int num_split_;
int split_sizes_[20];
int strides_[20];
int split_sizes_[32];
int strides_[32];
int split_dim_;
int n_dims_;
int split_count_;

@ -25,15 +25,29 @@
#include "tools/common/graph_util.h"
#include "include/errorcode.h"
#include "mindspore/lite/schema/inner/model_generated.h"
#include "mindspore/core/ir/dtype/type_id.h"
namespace mindspore {
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) {
MS_ASSERT(graph != nullptr);
bool ifChanged = false;
for (size_t i = 0; i < graph->nodes.size(); i++) {
auto &node = graph->nodes.at(i);
if (node->primitive->value.type == schema::PrimitiveType_TupleGetItem) {
if (IsUnusedNode(*node)) {
ifChanged = true;
auto status = IsolateOneWayNode(graph, i);
if (status != RET_OK) {

Loading…
Cancel
Save