!17784 [MSLITE] Fix custom operator Model Confusion Exception bug

From: @yyuse
Reviewed-by: @zhang_xue_tong,@hangangqiang
Signed-off-by: @zhang_xue_tong
This commit is contained in:
mindspore-ci-bot 2021-06-07 09:47:23 +08:00 committed by Gitee
commit a4e2ab0487
8 changed files with 9 additions and 4 deletions

View File

@ -103,9 +103,7 @@ table MetaGraph {
allTensors: [Tensor]; // weight + input + output allTensors: [Tensor]; // weight + input + output
subGraph : [SubGraph]; subGraph : [SubGraph];
obfuscate: bool = false; obfuscate: bool = false;
encrypt: bool = false;
obfMetaData: [ubyte]; obfMetaData: [ubyte];
decryptTable: [ubyte];
} }
root_type MetaGraph; root_type MetaGraph;

View File

@ -1158,4 +1158,8 @@ table GenOP {
global: bool; global: bool;
channel_shared: bool; channel_shared: bool;
axes: [long]; axes: [long];
keep_dims: bool;
reduce_mode: ReduceMode;
reduce_to_end: bool;
coeff: float;
} }

View File

@ -1157,4 +1157,8 @@ OP_ATTR_ONLY(round_mode, RoundMode)
OP_ATTR_ONLY(global, bool) OP_ATTR_ONLY(global, bool)
OP_ATTR_ONLY(channel_shared, bool) OP_ATTR_ONLY(channel_shared, bool)
OP_ATTR_ONLY(axes, [long]) OP_ATTR_ONLY(axes, [long])
OP_ATTR_ONLY(keep_dims, bool)
OP_ATTR_ONLY(reduce_mode, ReduceMode)
OP_ATTR_ONLY(reduce_to_end, bool)
OP_ATTR_ONLY(coeff, float)
OP_SCHEMA_DEF_ONLY_END(GenOP) OP_SCHEMA_DEF_ONLY_END(GenOP)

View File

@ -55,13 +55,12 @@ bool IsMetaGraphObfuscated(const T &meta_graph) {
template <typename T = schema::MetaGraph> template <typename T = schema::MetaGraph>
DeObfuscator *GetModelDeObfuscator(const T &meta_graph, Model *model) { DeObfuscator *GetModelDeObfuscator(const T &meta_graph, Model *model) {
auto meta_data = meta_graph.obfMetaData(); auto meta_data = meta_graph.obfMetaData();
auto decrypt_table = meta_graph.decryptTable();
auto *model_deobfuscator = new (std::nothrow) DeObfuscator(); auto *model_deobfuscator = new (std::nothrow) DeObfuscator();
if (model_deobfuscator == nullptr) { if (model_deobfuscator == nullptr) {
MS_LOG(ERROR) << "new model deobfuscator fail!"; MS_LOG(ERROR) << "new model deobfuscator fail!";
return nullptr; return nullptr;
} }
if (!InitModelDeObfuscator(model, model_deobfuscator, meta_data, decrypt_table, meta_graph.nodes()->size())) { if (!InitModelDeObfuscator(model, model_deobfuscator, meta_data, nullptr, meta_graph.nodes()->size())) {
MS_LOG(ERROR) << "init model deobfuscator fail!"; MS_LOG(ERROR) << "init model deobfuscator fail!";
delete model_deobfuscator; delete model_deobfuscator;
return nullptr; return nullptr;