From 594037dda0f64e5dd3bd78e83c373001c3bf3a07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=82=85=E9=AA=8F?= Date: Wed, 28 Sep 2022 04:03:50 +0000 Subject: [PATCH 1/2] =?UTF-8?q?!679=20=E6=B8=85=E7=90=86build-check?= =?UTF-8?q?=E5=91=8A=E8=AD=A6=20Merge=20pull=20request=20!679=20from=20?= =?UTF-8?q?=E5=82=85=E9=AA=8F/br=5Fbuild=5Fcheck=5Fwarnnings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/st/testcase/origin_models/conv2d_depthwise_pb_gen.py | 4 ++++ tests/st/testcase/origin_models/onnx_clip_v9.py | 4 ++++ tests/st/testcase/origin_models/onnx_if_const_intput_gen.py | 6 +++++- tests/st/testcase/origin_models/tensor_array_pb_gen.py | 4 ++++ tests/st/testcase/origin_models/test_VarIsInitializedOp_pb_gen.py | 6 +++++- tests/st/testcase/origin_models/test_avgpool3dgrad_pb_gen.py | 6 +++++- tests/st/testcase/origin_models/test_blocklstm_pb.gen.py | 4 ++++ tests/st/testcase/origin_models/test_constant_pb_gen.py | 4 ++++ tests/st/testcase/origin_models/test_conv2d_pb_gen.py | 6 +++++- tests/st/testcase/origin_models/test_enter_pb_gen.py | 6 +++++- tests/st/testcase/origin_models/test_fill_pb_gen.py | 6 +++++- tests/st/testcase/origin_models/test_identity_pb_gen.py | 6 +++++- tests/st/testcase/origin_models/test_merge_pb_gen.py | 4 ++++ tests/st/testcase/origin_models/test_no_op_pb_gen.py | 6 +++++- tests/st/testcase/origin_models/test_reshape_pb_gen.py | 6 +++++- tests/st/testcase/origin_models/test_sequeeze_pb_gen.py | 6 +++++- tests/st/testcase/origin_models/test_shape_n_pb_gen.py | 6 +++++- tests/st/testcase/origin_models/test_switch_pb_gen.py | 6 +++++- tests/st/testcase/origin_models/test_variableV2_pb_gen.py | 6 +++++- .../parser/testcase/onnx_parser_testcase/onnx_model/onnx_clip_v9.py | 4 ++++ .../tensorflow_model/conv2d_depthwise_pb_gen.py | 4 ++++ .../tensorflow_parser_testcase/tensorflow_model/onnx_clip_v9.py | 4 ++++ .../tensorflow_model/tensor_array_pb_gen.py | 4 ++++ .../tensorflow_model/test_VarIsInitializedOp_pb_gen.py | 6 +++++- .../tensorflow_model/test_avgpool3dgrad_pb_gen.py | 6 +++++- .../tensorflow_model/test_blocklstm_pb.gen.py | 4 ++++ .../tensorflow_model/test_constant_pb_gen.py | 4 ++++ .../tensorflow_model/test_conv2d_pb_gen.py | 6 +++++- .../tensorflow_model/test_enter_pb_gen.py | 6 +++++- .../tensorflow_parser_testcase/tensorflow_model/test_fill_pb_gen.py | 6 +++++- .../tensorflow_model/test_identity_pb_gen.py | 6 +++++- .../tensorflow_model/test_merge_pb_gen.py | 4 ++++ .../tensorflow_model/test_no_op_pb_gen.py | 6 +++++- .../tensorflow_model/test_reshape_pb_gen.py | 6 +++++- .../tensorflow_model/test_sequeeze_pb_gen.py | 6 +++++- .../tensorflow_model/test_shape_n_pb_gen.py | 6 +++++- .../tensorflow_model/test_switch_pb_gen.py | 6 +++++- .../tensorflow_model/test_variableV2_pb_gen.py | 6 +++++- 38 files changed, 177 insertions(+), 25 deletions(-) diff --git a/tests/st/testcase/origin_models/conv2d_depthwise_pb_gen.py b/tests/st/testcase/origin_models/conv2d_depthwise_pb_gen.py index 7ac9c2d..92a0362 100644 --- a/tests/st/testcase/origin_models/conv2d_depthwise_pb_gen.py +++ b/tests/st/testcase/origin_models/conv2d_depthwise_pb_gen.py @@ -1,3 +1,7 @@ +#!/usr/bin/env python3 +# -*- coding utf-8 -*- +# Copyright Huawei Technologies Co., Ltd 2019-2022. All rights reserved. + import tensorflow as tf import os diff --git a/tests/st/testcase/origin_models/onnx_clip_v9.py b/tests/st/testcase/origin_models/onnx_clip_v9.py index 476a0aa..45f0152 100644 --- a/tests/st/testcase/origin_models/onnx_clip_v9.py +++ b/tests/st/testcase/origin_models/onnx_clip_v9.py @@ -1,3 +1,7 @@ +#!/usr/bin/env python3 +# -*- coding utf-8 -*- +# Copyright Huawei Technologies Co., Ltd 2019-2022. All rights reserved. + import onnx from onnx import helper from onnx import AttributeProto, TensorProto, GraphProto diff --git a/tests/st/testcase/origin_models/onnx_if_const_intput_gen.py b/tests/st/testcase/origin_models/onnx_if_const_intput_gen.py index 1d2eaa0..c7d9f21 100644 --- a/tests/st/testcase/origin_models/onnx_if_const_intput_gen.py +++ b/tests/st/testcase/origin_models/onnx_if_const_intput_gen.py @@ -1,3 +1,7 @@ +#!/usr/bin/env python3 +# -*- coding utf-8 -*- +# Copyright Huawei Technologies Co., Ltd 2019-2022. All rights reserved. + import os import numpy as np import onnx @@ -42,4 +46,4 @@ def gen_onnx(): print(model_def) if __name__ == "__main__": - gen_onnx() \ No newline at end of file + gen_onnx() diff --git a/tests/st/testcase/origin_models/tensor_array_pb_gen.py b/tests/st/testcase/origin_models/tensor_array_pb_gen.py index c035978..9f918b8 100644 --- a/tests/st/testcase/origin_models/tensor_array_pb_gen.py +++ b/tests/st/testcase/origin_models/tensor_array_pb_gen.py @@ -1,3 +1,7 @@ +#!/usr/bin/env python3 +# -*- coding utf-8 -*- +# Copyright Huawei Technologies Co., Ltd 2019-2022. All rights reserved. + import tensorflow as tf import os from tensorflow.python.framework import graph_util diff --git a/tests/st/testcase/origin_models/test_VarIsInitializedOp_pb_gen.py b/tests/st/testcase/origin_models/test_VarIsInitializedOp_pb_gen.py index 79d86b6..2e60a77 100644 --- a/tests/st/testcase/origin_models/test_VarIsInitializedOp_pb_gen.py +++ b/tests/st/testcase/origin_models/test_VarIsInitializedOp_pb_gen.py @@ -1,3 +1,7 @@ +#!/usr/bin/env python3 +# -*- coding utf-8 -*- +# Copyright Huawei Technologies Co., Ltd 2019-2022. All rights reserved. + import tensorflow as tf import numpy as np @@ -11,4 +15,4 @@ def generate_VarIsInitializedOp_pb(): tf.io.write_graph(sess.graph, logdir="./", name="test_VarIsInitializedOp.pb", as_text=False) if __name__=='__main__': - generate_VarIsInitializedOp_pb() \ No newline at end of file + generate_VarIsInitializedOp_pb() diff --git a/tests/st/testcase/origin_models/test_avgpool3dgrad_pb_gen.py b/tests/st/testcase/origin_models/test_avgpool3dgrad_pb_gen.py index a22f5ba..cf13d62 100644 --- a/tests/st/testcase/origin_models/test_avgpool3dgrad_pb_gen.py +++ b/tests/st/testcase/origin_models/test_avgpool3dgrad_pb_gen.py @@ -1,3 +1,7 @@ +#!/usr/bin/env python3 +# -*- coding utf-8 -*- +# Copyright Huawei Technologies Co., Ltd 2019-2022. All rights reserved. + import tensorflow as tf import os import numpy as np @@ -38,4 +42,4 @@ def generate_case_2(): tf.io.write_graph(sess.graph, logdir="./", name="avgpool3dgrad.pb.txt", as_text=False) if __name__=='__main__': - generate_case_2() \ No newline at end of file + generate_case_2() diff --git a/tests/st/testcase/origin_models/test_blocklstm_pb.gen.py b/tests/st/testcase/origin_models/test_blocklstm_pb.gen.py index b9d2908..b280fdc 100644 --- a/tests/st/testcase/origin_models/test_blocklstm_pb.gen.py +++ b/tests/st/testcase/origin_models/test_blocklstm_pb.gen.py @@ -1,3 +1,7 @@ +#!/usr/bin/env python3 +# -*- coding utf-8 -*- +# Copyright Huawei Technologies Co., Ltd 2019-2022. All rights reserved. + import tensorflow as tf import os diff --git a/tests/st/testcase/origin_models/test_constant_pb_gen.py b/tests/st/testcase/origin_models/test_constant_pb_gen.py index 45921a4..a174025 100644 --- a/tests/st/testcase/origin_models/test_constant_pb_gen.py +++ b/tests/st/testcase/origin_models/test_constant_pb_gen.py @@ -1,3 +1,7 @@ +#!/usr/bin/env python3 +# -*- coding utf-8 -*- +# Copyright Huawei Technologies Co., Ltd 2019-2022. All rights reserved. + import tensorflow as tf import numpy as np from tensorflow.python.framework import graph_util diff --git a/tests/st/testcase/origin_models/test_conv2d_pb_gen.py b/tests/st/testcase/origin_models/test_conv2d_pb_gen.py index defd5f3..ec2c821 100644 --- a/tests/st/testcase/origin_models/test_conv2d_pb_gen.py +++ b/tests/st/testcase/origin_models/test_conv2d_pb_gen.py @@ -1,3 +1,7 @@ +#!/usr/bin/env python3 +# -*- coding utf-8 -*- +# Copyright Huawei Technologies Co., Ltd 2019-2022. All rights reserved. + import tensorflow as tf import os from tensorflow.python.framework import graph_util @@ -23,4 +27,4 @@ def generate_add_pb(): if __name__=='__main__': generate_conv2d_pb() - generate_add_pb() \ No newline at end of file + generate_add_pb() diff --git a/tests/st/testcase/origin_models/test_enter_pb_gen.py b/tests/st/testcase/origin_models/test_enter_pb_gen.py index 291dfd8..2c5ff77 100644 --- a/tests/st/testcase/origin_models/test_enter_pb_gen.py +++ b/tests/st/testcase/origin_models/test_enter_pb_gen.py @@ -1,3 +1,7 @@ +#!/usr/bin/env python3 +# -*- coding utf-8 -*- +# Copyright Huawei Technologies Co., Ltd 2019-2022. All rights reserved. + import tensorflow as tf from tensorflow.python.ops import control_flow_ops @@ -10,4 +14,4 @@ def generate_enter_pb(): tf.io.write_graph(sess.graph, logdir="./", name="test_enter.pb", as_text=False) if __name__=='__main__': - generate_enter_pb() \ No newline at end of file + generate_enter_pb() diff --git a/tests/st/testcase/origin_models/test_fill_pb_gen.py b/tests/st/testcase/origin_models/test_fill_pb_gen.py index d7ed9f1..f49029e 100644 --- a/tests/st/testcase/origin_models/test_fill_pb_gen.py +++ b/tests/st/testcase/origin_models/test_fill_pb_gen.py @@ -1,3 +1,7 @@ +#!/usr/bin/env python3 +# -*- coding utf-8 -*- +# Copyright Huawei Technologies Co., Ltd 2019-2022. All rights reserved. + import tensorflow as tf import numpy as np @@ -9,4 +13,4 @@ def generate_fill_pb(): tf.io.write_graph(sess.graph, logdir="./", name="test_fill.pb", as_text=False) if __name__ == "__main__": - generate_fill_pb() \ No newline at end of file + generate_fill_pb() diff --git a/tests/st/testcase/origin_models/test_identity_pb_gen.py b/tests/st/testcase/origin_models/test_identity_pb_gen.py index 1ff3781..a31562e 100644 --- a/tests/st/testcase/origin_models/test_identity_pb_gen.py +++ b/tests/st/testcase/origin_models/test_identity_pb_gen.py @@ -1,3 +1,7 @@ +#!/usr/bin/env python3 +# -*- coding utf-8 -*- +# Copyright Huawei Technologies Co., Ltd 2019-2022. All rights reserved. + import tensorflow as tf def generate_identity_pb(): @@ -10,4 +14,4 @@ def generate_identity_pb(): tf.io.write_graph(sess.graph, logdir="./", name="test_identity.pb", as_text=False) if __name__=='__main__': - generate_identity_pb() \ No newline at end of file + generate_identity_pb() diff --git a/tests/st/testcase/origin_models/test_merge_pb_gen.py b/tests/st/testcase/origin_models/test_merge_pb_gen.py index 709f81b..c3d76cb 100644 --- a/tests/st/testcase/origin_models/test_merge_pb_gen.py +++ b/tests/st/testcase/origin_models/test_merge_pb_gen.py @@ -1,3 +1,7 @@ +#!/usr/bin/env python3 +# -*- coding utf-8 -*- +# Copyright Huawei Technologies Co., Ltd 2019-2022. All rights reserved. + import tensorflow as tf from tensorflow.python.framework import graph_util import numpy as np diff --git a/tests/st/testcase/origin_models/test_no_op_pb_gen.py b/tests/st/testcase/origin_models/test_no_op_pb_gen.py index 1e4ba29..8695c0f 100644 --- a/tests/st/testcase/origin_models/test_no_op_pb_gen.py +++ b/tests/st/testcase/origin_models/test_no_op_pb_gen.py @@ -1,3 +1,7 @@ +#!/usr/bin/env python3 +# -*- coding utf-8 -*- +# Copyright Huawei Technologies Co., Ltd 2019-2022. All rights reserved. + import tensorflow as tf import numpy as np @@ -11,4 +15,4 @@ def generate_no_op_pb(): tf.io.write_graph(sess.graph, logdir="./", name="test_no_op.pb", as_text=False) if __name__=='__main__': - generate_no_op_pb() \ No newline at end of file + generate_no_op_pb() diff --git a/tests/st/testcase/origin_models/test_reshape_pb_gen.py b/tests/st/testcase/origin_models/test_reshape_pb_gen.py index f65ea67..fbad848 100644 --- a/tests/st/testcase/origin_models/test_reshape_pb_gen.py +++ b/tests/st/testcase/origin_models/test_reshape_pb_gen.py @@ -1,3 +1,7 @@ +#!/usr/bin/env python3 +# -*- coding utf-8 -*- +# Copyright Huawei Technologies Co., Ltd 2019-2022. All rights reserved. + import tensorflow as tf def generate_reshape_pb(): @@ -7,4 +11,4 @@ def generate_reshape_pb(): tf.io.write_graph(sess.graph, logdir="./", name="test_reshape.pb", as_text=False) if __name__ == "__main__": - generate_reshape_pb() \ No newline at end of file + generate_reshape_pb() diff --git a/tests/st/testcase/origin_models/test_sequeeze_pb_gen.py b/tests/st/testcase/origin_models/test_sequeeze_pb_gen.py index b9a4078..9038d23 100644 --- a/tests/st/testcase/origin_models/test_sequeeze_pb_gen.py +++ b/tests/st/testcase/origin_models/test_sequeeze_pb_gen.py @@ -1,3 +1,7 @@ +#!/usr/bin/env python3 +# -*- coding utf-8 -*- +# Copyright Huawei Technologies Co., Ltd 2019-2022. All rights reserved. + import tensorflow as tf import numpy as np @@ -10,4 +14,4 @@ def generate_sequeeze_pb(): tf.io.write_graph(sess.graph, logdir="./", name="test_sequeeze.pb", as_text=False) if __name__ == "__main__": - generate_sequeeze_pb() \ No newline at end of file + generate_sequeeze_pb() diff --git a/tests/st/testcase/origin_models/test_shape_n_pb_gen.py b/tests/st/testcase/origin_models/test_shape_n_pb_gen.py index 2f29597..d7769f8 100644 --- a/tests/st/testcase/origin_models/test_shape_n_pb_gen.py +++ b/tests/st/testcase/origin_models/test_shape_n_pb_gen.py @@ -1,3 +1,7 @@ +#!/usr/bin/env python3 +# -*- coding utf-8 -*- +# Copyright Huawei Technologies Co., Ltd 2019-2022. All rights reserved. + import tensorflow as tf import numpy as np @@ -8,4 +12,4 @@ def generate_shape_n_pb(): tf.io.write_graph(sess.graph, logdir="./", name="test_shape_n.pb", as_text=False) if __name__ == "__main__": - generate_shape_n_pb() \ No newline at end of file + generate_shape_n_pb() diff --git a/tests/st/testcase/origin_models/test_switch_pb_gen.py b/tests/st/testcase/origin_models/test_switch_pb_gen.py index 5b2f87c..6985de0 100644 --- a/tests/st/testcase/origin_models/test_switch_pb_gen.py +++ b/tests/st/testcase/origin_models/test_switch_pb_gen.py @@ -1,3 +1,7 @@ +#!/usr/bin/env python3 +# -*- coding utf-8 -*- +# Copyright Huawei Technologies Co., Ltd 2019-2022. All rights reserved. + import tensorflow as tf from tensorflow.python.ops import control_flow_ops @@ -10,4 +14,4 @@ def generate_switch_pb(): tf.io.write_graph(sess.graph, logdir="./", name="test_switch.pb", as_text=False) if __name__=='__main__': - generate_switch_pb() \ No newline at end of file + generate_switch_pb() diff --git a/tests/st/testcase/origin_models/test_variableV2_pb_gen.py b/tests/st/testcase/origin_models/test_variableV2_pb_gen.py index fa1416c..d68ceb0 100644 --- a/tests/st/testcase/origin_models/test_variableV2_pb_gen.py +++ b/tests/st/testcase/origin_models/test_variableV2_pb_gen.py @@ -1,3 +1,7 @@ +#!/usr/bin/env python3 +# -*- coding utf-8 -*- +# Copyright Huawei Technologies Co., Ltd 2019-2022. All rights reserved. + import tensorflow as tf def generate_VariableV2_pb(): @@ -10,4 +14,4 @@ def generate_VariableV2_pb(): tf.io.write_graph(sess.graph, logdir="./", name="test_VariableV2.pb", as_text=False) if __name__=='__main__': - generate_VariableV2_pb() \ No newline at end of file + generate_VariableV2_pb() diff --git a/tests/ut/parser/testcase/onnx_parser_testcase/onnx_model/onnx_clip_v9.py b/tests/ut/parser/testcase/onnx_parser_testcase/onnx_model/onnx_clip_v9.py index 476a0aa..45f0152 100644 --- a/tests/ut/parser/testcase/onnx_parser_testcase/onnx_model/onnx_clip_v9.py +++ b/tests/ut/parser/testcase/onnx_parser_testcase/onnx_model/onnx_clip_v9.py @@ -1,3 +1,7 @@ +#!/usr/bin/env python3 +# -*- coding utf-8 -*- +# Copyright Huawei Technologies Co., Ltd 2019-2022. All rights reserved. + import onnx from onnx import helper from onnx import AttributeProto, TensorProto, GraphProto diff --git a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/conv2d_depthwise_pb_gen.py b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/conv2d_depthwise_pb_gen.py index 7ac9c2d..92a0362 100644 --- a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/conv2d_depthwise_pb_gen.py +++ b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/conv2d_depthwise_pb_gen.py @@ -1,3 +1,7 @@ +#!/usr/bin/env python3 +# -*- coding utf-8 -*- +# Copyright Huawei Technologies Co., Ltd 2019-2022. All rights reserved. + import tensorflow as tf import os diff --git a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/onnx_clip_v9.py b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/onnx_clip_v9.py index 476a0aa..45f0152 100644 --- a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/onnx_clip_v9.py +++ b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/onnx_clip_v9.py @@ -1,3 +1,7 @@ +#!/usr/bin/env python3 +# -*- coding utf-8 -*- +# Copyright Huawei Technologies Co., Ltd 2019-2022. All rights reserved. + import onnx from onnx import helper from onnx import AttributeProto, TensorProto, GraphProto diff --git a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/tensor_array_pb_gen.py b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/tensor_array_pb_gen.py index c035978..9f918b8 100644 --- a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/tensor_array_pb_gen.py +++ b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/tensor_array_pb_gen.py @@ -1,3 +1,7 @@ +#!/usr/bin/env python3 +# -*- coding utf-8 -*- +# Copyright Huawei Technologies Co., Ltd 2019-2022. All rights reserved. + import tensorflow as tf import os from tensorflow.python.framework import graph_util diff --git a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_VarIsInitializedOp_pb_gen.py b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_VarIsInitializedOp_pb_gen.py index 79d86b6..2e60a77 100644 --- a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_VarIsInitializedOp_pb_gen.py +++ b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_VarIsInitializedOp_pb_gen.py @@ -1,3 +1,7 @@ +#!/usr/bin/env python3 +# -*- coding utf-8 -*- +# Copyright Huawei Technologies Co., Ltd 2019-2022. All rights reserved. + import tensorflow as tf import numpy as np @@ -11,4 +15,4 @@ def generate_VarIsInitializedOp_pb(): tf.io.write_graph(sess.graph, logdir="./", name="test_VarIsInitializedOp.pb", as_text=False) if __name__=='__main__': - generate_VarIsInitializedOp_pb() \ No newline at end of file + generate_VarIsInitializedOp_pb() diff --git a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_avgpool3dgrad_pb_gen.py b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_avgpool3dgrad_pb_gen.py index a22f5ba..cf13d62 100644 --- a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_avgpool3dgrad_pb_gen.py +++ b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_avgpool3dgrad_pb_gen.py @@ -1,3 +1,7 @@ +#!/usr/bin/env python3 +# -*- coding utf-8 -*- +# Copyright Huawei Technologies Co., Ltd 2019-2022. All rights reserved. + import tensorflow as tf import os import numpy as np @@ -38,4 +42,4 @@ def generate_case_2(): tf.io.write_graph(sess.graph, logdir="./", name="avgpool3dgrad.pb.txt", as_text=False) if __name__=='__main__': - generate_case_2() \ No newline at end of file + generate_case_2() diff --git a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_blocklstm_pb.gen.py b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_blocklstm_pb.gen.py index b9d2908..b280fdc 100644 --- a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_blocklstm_pb.gen.py +++ b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_blocklstm_pb.gen.py @@ -1,3 +1,7 @@ +#!/usr/bin/env python3 +# -*- coding utf-8 -*- +# Copyright Huawei Technologies Co., Ltd 2019-2022. All rights reserved. + import tensorflow as tf import os diff --git a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_constant_pb_gen.py b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_constant_pb_gen.py index 45921a4..a174025 100644 --- a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_constant_pb_gen.py +++ b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_constant_pb_gen.py @@ -1,3 +1,7 @@ +#!/usr/bin/env python3 +# -*- coding utf-8 -*- +# Copyright Huawei Technologies Co., Ltd 2019-2022. All rights reserved. + import tensorflow as tf import numpy as np from tensorflow.python.framework import graph_util diff --git a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_conv2d_pb_gen.py b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_conv2d_pb_gen.py index defd5f3..ec2c821 100644 --- a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_conv2d_pb_gen.py +++ b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_conv2d_pb_gen.py @@ -1,3 +1,7 @@ +#!/usr/bin/env python3 +# -*- coding utf-8 -*- +# Copyright Huawei Technologies Co., Ltd 2019-2022. All rights reserved. + import tensorflow as tf import os from tensorflow.python.framework import graph_util @@ -23,4 +27,4 @@ def generate_add_pb(): if __name__=='__main__': generate_conv2d_pb() - generate_add_pb() \ No newline at end of file + generate_add_pb() diff --git a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_enter_pb_gen.py b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_enter_pb_gen.py index 291dfd8..2c5ff77 100644 --- a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_enter_pb_gen.py +++ b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_enter_pb_gen.py @@ -1,3 +1,7 @@ +#!/usr/bin/env python3 +# -*- coding utf-8 -*- +# Copyright Huawei Technologies Co., Ltd 2019-2022. All rights reserved. + import tensorflow as tf from tensorflow.python.ops import control_flow_ops @@ -10,4 +14,4 @@ def generate_enter_pb(): tf.io.write_graph(sess.graph, logdir="./", name="test_enter.pb", as_text=False) if __name__=='__main__': - generate_enter_pb() \ No newline at end of file + generate_enter_pb() diff --git a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_fill_pb_gen.py b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_fill_pb_gen.py index d7ed9f1..f49029e 100644 --- a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_fill_pb_gen.py +++ b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_fill_pb_gen.py @@ -1,3 +1,7 @@ +#!/usr/bin/env python3 +# -*- coding utf-8 -*- +# Copyright Huawei Technologies Co., Ltd 2019-2022. All rights reserved. + import tensorflow as tf import numpy as np @@ -9,4 +13,4 @@ def generate_fill_pb(): tf.io.write_graph(sess.graph, logdir="./", name="test_fill.pb", as_text=False) if __name__ == "__main__": - generate_fill_pb() \ No newline at end of file + generate_fill_pb() diff --git a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_identity_pb_gen.py b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_identity_pb_gen.py index 1ff3781..a31562e 100644 --- a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_identity_pb_gen.py +++ b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_identity_pb_gen.py @@ -1,3 +1,7 @@ +#!/usr/bin/env python3 +# -*- coding utf-8 -*- +# Copyright Huawei Technologies Co., Ltd 2019-2022. All rights reserved. + import tensorflow as tf def generate_identity_pb(): @@ -10,4 +14,4 @@ def generate_identity_pb(): tf.io.write_graph(sess.graph, logdir="./", name="test_identity.pb", as_text=False) if __name__=='__main__': - generate_identity_pb() \ No newline at end of file + generate_identity_pb() diff --git a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_merge_pb_gen.py b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_merge_pb_gen.py index 709f81b..c3d76cb 100644 --- a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_merge_pb_gen.py +++ b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_merge_pb_gen.py @@ -1,3 +1,7 @@ +#!/usr/bin/env python3 +# -*- coding utf-8 -*- +# Copyright Huawei Technologies Co., Ltd 2019-2022. All rights reserved. + import tensorflow as tf from tensorflow.python.framework import graph_util import numpy as np diff --git a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_no_op_pb_gen.py b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_no_op_pb_gen.py index 1e4ba29..8695c0f 100644 --- a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_no_op_pb_gen.py +++ b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_no_op_pb_gen.py @@ -1,3 +1,7 @@ +#!/usr/bin/env python3 +# -*- coding utf-8 -*- +# Copyright Huawei Technologies Co., Ltd 2019-2022. All rights reserved. + import tensorflow as tf import numpy as np @@ -11,4 +15,4 @@ def generate_no_op_pb(): tf.io.write_graph(sess.graph, logdir="./", name="test_no_op.pb", as_text=False) if __name__=='__main__': - generate_no_op_pb() \ No newline at end of file + generate_no_op_pb() diff --git a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_reshape_pb_gen.py b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_reshape_pb_gen.py index f65ea67..fbad848 100644 --- a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_reshape_pb_gen.py +++ b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_reshape_pb_gen.py @@ -1,3 +1,7 @@ +#!/usr/bin/env python3 +# -*- coding utf-8 -*- +# Copyright Huawei Technologies Co., Ltd 2019-2022. All rights reserved. + import tensorflow as tf def generate_reshape_pb(): @@ -7,4 +11,4 @@ def generate_reshape_pb(): tf.io.write_graph(sess.graph, logdir="./", name="test_reshape.pb", as_text=False) if __name__ == "__main__": - generate_reshape_pb() \ No newline at end of file + generate_reshape_pb() diff --git a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_sequeeze_pb_gen.py b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_sequeeze_pb_gen.py index b9a4078..9038d23 100644 --- a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_sequeeze_pb_gen.py +++ b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_sequeeze_pb_gen.py @@ -1,3 +1,7 @@ +#!/usr/bin/env python3 +# -*- coding utf-8 -*- +# Copyright Huawei Technologies Co., Ltd 2019-2022. All rights reserved. + import tensorflow as tf import numpy as np @@ -10,4 +14,4 @@ def generate_sequeeze_pb(): tf.io.write_graph(sess.graph, logdir="./", name="test_sequeeze.pb", as_text=False) if __name__ == "__main__": - generate_sequeeze_pb() \ No newline at end of file + generate_sequeeze_pb() diff --git a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_shape_n_pb_gen.py b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_shape_n_pb_gen.py index 2f29597..d7769f8 100644 --- a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_shape_n_pb_gen.py +++ b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_shape_n_pb_gen.py @@ -1,3 +1,7 @@ +#!/usr/bin/env python3 +# -*- coding utf-8 -*- +# Copyright Huawei Technologies Co., Ltd 2019-2022. All rights reserved. + import tensorflow as tf import numpy as np @@ -8,4 +12,4 @@ def generate_shape_n_pb(): tf.io.write_graph(sess.graph, logdir="./", name="test_shape_n.pb", as_text=False) if __name__ == "__main__": - generate_shape_n_pb() \ No newline at end of file + generate_shape_n_pb() diff --git a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_switch_pb_gen.py b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_switch_pb_gen.py index 5b2f87c..6985de0 100644 --- a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_switch_pb_gen.py +++ b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_switch_pb_gen.py @@ -1,3 +1,7 @@ +#!/usr/bin/env python3 +# -*- coding utf-8 -*- +# Copyright Huawei Technologies Co., Ltd 2019-2022. All rights reserved. + import tensorflow as tf from tensorflow.python.ops import control_flow_ops @@ -10,4 +14,4 @@ def generate_switch_pb(): tf.io.write_graph(sess.graph, logdir="./", name="test_switch.pb", as_text=False) if __name__=='__main__': - generate_switch_pb() \ No newline at end of file + generate_switch_pb() diff --git a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_variableV2_pb_gen.py b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_variableV2_pb_gen.py index fa1416c..d68ceb0 100644 --- a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_variableV2_pb_gen.py +++ b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_model/test_variableV2_pb_gen.py @@ -1,3 +1,7 @@ +#!/usr/bin/env python3 +# -*- coding utf-8 -*- +# Copyright Huawei Technologies Co., Ltd 2019-2022. All rights reserved. + import tensorflow as tf def generate_VariableV2_pb(): @@ -10,4 +14,4 @@ def generate_VariableV2_pb(): tf.io.write_graph(sess.graph, logdir="./", name="test_VariableV2.pb", as_text=False) if __name__=='__main__': - generate_VariableV2_pb() \ No newline at end of file + generate_VariableV2_pb() From 837c70587b0c7808e3ae1af03d6134f5c168cfdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=BC=BA?= Date: Wed, 28 Sep 2022 04:04:37 +0000 Subject: [PATCH 2/2] =?UTF-8?q?!678=20c83=20cleancode=20Merge=20pull=20req?= =?UTF-8?q?uest=20!678=20from=20=E5=88=98=E5=BC=BA/lqc83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inc/external/parser/tensorflow_parser.h | 1 + parser/caffe/caffe_parser.cc | 8 ++-- parser/caffe/caffe_parser.h | 4 +- parser/common/acl_graph_parser_util.cc | 50 +++++++++++----------- parser/common/acl_graph_parser_util.h | 33 +++----------- .../common/auto_mapping_subgraph_io_index_func.h | 2 +- parser/common/convert/pb2json.cc | 2 +- parser/onnx/onnx_parser.cc | 8 ++-- parser/tensorflow/tensorflow_parser.cc | 4 +- tests/st/testcase/test_caffe_parser.cc | 4 +- tests/st/testcase/test_tensorflow_parser.cc | 14 +++--- .../caffe_parser_testcase/caffe_parser_unittest.cc | 8 ++-- .../testcase/common/acl_graph_parser_unittest.cc | 2 +- .../tensorflow_parser_unittest.cc | 14 +++--- 14 files changed, 66 insertions(+), 88 deletions(-) diff --git a/inc/external/parser/tensorflow_parser.h b/inc/external/parser/tensorflow_parser.h index d863e0a..e2ede65 100644 --- a/inc/external/parser/tensorflow_parser.h +++ b/inc/external/parser/tensorflow_parser.h @@ -35,6 +35,7 @@ #include #include #include +#include #include "graph/ascend_string.h" #include "graph/ge_error_codes.h" #include "graph/graph.h" diff --git a/parser/caffe/caffe_parser.cc b/parser/caffe/caffe_parser.cc index 771bfb6..528d549 100644 --- a/parser/caffe/caffe_parser.cc +++ b/parser/caffe/caffe_parser.cc @@ -86,7 +86,7 @@ graphStatus aclgrphParseCaffe(const char *model_file, const char *weights_file, options.insert(std::pair(string(ge::FRAMEWORK_TYPE), to_string(domi::CAFFE))); // load custom plugin so and proto - AclGrphParseUtil acl_graph_parse_util; + AclGraphParseUtil acl_graph_parse_util; domi::Status status = acl_graph_parse_util.AclParserInitialize(options); if (status != domi::SUCCESS) { REPORT_CALL_ERROR("E19999", "AclParserInitialize failed, ret:%d.", status); @@ -144,7 +144,7 @@ graphStatus aclgrphParseCaffe(const char *model_file, const char *weights_file, options.insert(std::pair(string(ge::FRAMEWORK_TYPE), to_string(domi::CAFFE))); // load custom plugin so and proto - AclGrphParseUtil acl_graph_parse_util; + AclGraphParseUtil acl_graph_parse_util; domi::Status status = acl_graph_parse_util.AclParserInitialize(options); if (status != domi::SUCCESS) { REPORT_CALL_ERROR("E19999", "AclParserInitialize failed, ret:%d.", status); @@ -429,7 +429,7 @@ Status CaffeModelParser::ParseNetModelByCustomProto(const char *model_path, cons } Status CaffeModelParser::CustomProtoParse(const char *model_path, const string &custom_proto, - const string &caffe_proto, vector &operators) { + const string &caffe_proto, vector &operators) const { (void)caffe_proto; string custom_proto_path = ge::parser::RealPath(custom_proto.c_str()); if (custom_proto_path.empty()) { @@ -1904,7 +1904,7 @@ Status CaffeWeightsParser::ParseLayerParameter(const google::protobuf::Descripto } Status CaffeWeightsParser::ConvertLayerProto(const google::protobuf::Message &message, - google::protobuf::Message *layer) { + google::protobuf::Message *layer) const { const google::protobuf::Reflection *layer_reflection = message.GetReflection(); CAFFE_CHECK_NULL_AND_REPROT_ERRORMSG(layer_reflection, "Get Reflection failed in google::protobuf::Message"); vector field_desc; diff --git a/parser/caffe/caffe_parser.h b/parser/caffe/caffe_parser.h index 08fed80..dd2747b 100644 --- a/parser/caffe/caffe_parser.h +++ b/parser/caffe/caffe_parser.h @@ -168,7 +168,7 @@ class PARSER_FUNC_VISIBILITY CaffeModelParser : public domi::ModelParser { * @return FAILED parse failed */ Status CustomProtoParse(const char *model_path, const string &custom_proto, const string &caffe_proto, - std::vector &operators); + std::vector &operators) const; /* * @ingroup domi_omg @@ -396,7 +396,7 @@ class PARSER_FUNC_VISIBILITY CaffeWeightsParser : public domi::WeightsParser { Status CheckLayersSize(const google::protobuf::Message &message) const; Status ConvertLayerProto(const google::protobuf::Message &message, - google::protobuf::Message *layer); + google::protobuf::Message *layer) const; Status ParseLayerField(const google::protobuf::Reflection &reflection, const google::protobuf::Message &message, diff --git a/parser/common/acl_graph_parser_util.cc b/parser/common/acl_graph_parser_util.cc index d5f0d20..8a9b1b5 100644 --- a/parser/common/acl_graph_parser_util.cc +++ b/parser/common/acl_graph_parser_util.cc @@ -149,7 +149,7 @@ static Status CheckOutNode(ge::OpDescPtr op_desc, int32_t index) { return domi::SUCCESS; } -domi::Status AclGrphParseUtil::LoadOpsProtoLib() { +domi::Status AclGraphParseUtil::LoadOpsProtoLib() { string opsproto_path; ge::Status ret = ge::TBEPluginLoader::GetOpsProtoPath(opsproto_path); if (ret != ge::SUCCESS) { @@ -170,7 +170,7 @@ domi::Status AclGrphParseUtil::LoadOpsProtoLib() { return SUCCESS; } -void AclGrphParseUtil::SaveCustomCaffeProtoPath() { +void AclGraphParseUtil::SaveCustomCaffeProtoPath() { GELOGD("Enter save custom caffe proto path."); std::string path_base = GetSoPath(); path_base = path_base.substr(0, path_base.rfind('/')); @@ -192,7 +192,7 @@ void AclGrphParseUtil::SaveCustomCaffeProtoPath() { // Initialize PARSER, load custom op plugin // options will be used later for parser decoupling -domi::Status AclGrphParseUtil::AclParserInitialize(const std::map &options) { +domi::Status AclGraphParseUtil::AclParserInitialize(const std::map &options) { GELOGT(TRACE_INIT, "AclParserInitialize start"); // check init status if (parser_initialized) { @@ -240,7 +240,7 @@ domi::Status AclGrphParseUtil::AclParserInitialize(const std::map &adjust_fp16_format_vec, - const string &fp16_nodes_name, size_t index, OpDescPtr &op_desc) { +void AclGraphParseUtil::AddAttrsForInputNodes(const vector &adjust_fp16_format_vec, + const string &fp16_nodes_name, size_t index, OpDescPtr &op_desc) { if (AttrUtils::SetStr(op_desc, ATTR_ATC_USER_DEFINE_DATATYPE, TypeUtils::DataTypeToSerialString(DT_FLOAT16))) { if ((index < adjust_fp16_format_vec.size()) && (adjust_fp16_format_vec[index] == "true")) { GELOGI("This node [%s] should be set NC1HWC0", fp16_nodes_name.c_str()); @@ -368,8 +368,8 @@ void AclGrphParseUtil::AddAttrsForInputNodes(const vector &adjust_fp16_f } } -domi::Status AclGrphParseUtil::ParseAclInputFp16Nodes(const ComputeGraphPtr &graph, const string &input_fp16_nodes, - const string &is_input_adjust_hw_layout) const { +domi::Status AclGraphParseUtil::ParseAclInputFp16Nodes(const ComputeGraphPtr &graph, const string &input_fp16_nodes, + const string &is_input_adjust_hw_layout) const { GE_CHECK_NOTNULL(graph); vector adjust_fp16_format_vec; if (!is_input_adjust_hw_layout.empty()) { @@ -411,7 +411,7 @@ domi::Status AclGrphParseUtil::ParseAclInputFp16Nodes(const ComputeGraphPtr &gra return SUCCESS; } -domi::Status AclGrphParseUtil::SetSpecifyIndexAttrByInputNames(const ComputeGraphPtr &graph, +domi::Status AclGraphParseUtil::SetSpecifyIndexAttrByInputNames(const ComputeGraphPtr &graph, const std::string &input_data_names) const { std::vector input_names = StringUtils::Split(input_data_names, ','); std::unordered_map name_to_index; @@ -446,8 +446,8 @@ domi::Status AclGrphParseUtil::SetSpecifyIndexAttrByInputNames(const ComputeGrap return SUCCESS; } -void AclGrphParseUtil::CreateOutputNodesInfo(std::vector> &output_nodes_info, - std::vector &output_nodes_name) const { +void AclGraphParseUtil::CreateOutputNodesInfo(std::vector> &output_nodes_info, + std::vector &output_nodes_name) const { output_nodes_name.clear(); auto &out_tensor_names = ge::GetParserContext().out_tensor_names; if (out_tensor_names.empty()) { @@ -478,8 +478,8 @@ void AclGrphParseUtil::CreateOutputNodesInfo(std::vector> &output_nodes_info) const { +domi::Status AclGraphParseUtil::GetOutputLeaf(NodePtr node, + std::vector> &output_nodes_info) const { ge::OpDescPtr tmpDescPtr = node->GetOpDesc(); if (tmpDescPtr == nullptr) { REPORT_INNER_ERROR("E19999", "param node has no opdesc."); @@ -508,7 +508,7 @@ domi::Status AclGrphParseUtil::GetOutputLeaf(NodePtr node, return SUCCESS; } -domi::Status AclGrphParseUtil::GetDefaultOutInfo(ge::ComputeGraphPtr &compute_graph, +domi::Status AclGraphParseUtil::GetDefaultOutInfo(ge::ComputeGraphPtr &compute_graph, std::vector> &output_nodes_info) const { std::vector> default_out_nodes = ge::GetParserContext().default_out_nodes; if (!default_out_nodes.empty()) { @@ -531,8 +531,8 @@ domi::Status AclGrphParseUtil::GetDefaultOutInfo(ge::ComputeGraphPtr &compute_gr return domi::SUCCESS; } -domi::Status AclGrphParseUtil::SetOutputNodeInfo(ge::Graph &graph, - const std::map &parser_params) { +domi::Status AclGraphParseUtil::SetOutputNodeInfo(ge::Graph &graph, + const std::map &parser_params) const { (void)parser_params; ge::ComputeGraphPtr compute_graph = ge::GraphUtils::GetComputeGraph(graph); GE_CHECK_NOTNULL(compute_graph); @@ -588,7 +588,7 @@ domi::Status AclGrphParseUtil::SetOutputNodeInfo(ge::Graph &graph, return domi::SUCCESS; } -domi::Status AclGrphParseUtil::CheckOptions(const std::map &parser_params) const { +domi::Status AclGraphParseUtil::CheckOptions(const std::map &parser_params) const { for (auto &ele : parser_params) { const char *key_ascend = ele.first.GetString(); if (key_ascend == nullptr) { @@ -609,8 +609,8 @@ domi::Status AclGrphParseUtil::CheckOptions(const std::map &parser_params, - string &graph_name) { +domi::Status AclGraphParseUtil::ParseParamsBeforeGraph(const std::map &parser_params, + string &graph_name) const { GELOGI("Parse graph user options start."); ge::GetParserContext().input_nodes_format_map.clear(); ge::GetParserContext().output_formats.clear(); @@ -663,8 +663,8 @@ domi::Status AclGrphParseUtil::ParseParamsBeforeGraph(const std::map &parser_params) const { +domi::Status AclGraphParseUtil::ParseParamsAfterGraph(ge::Graph &graph, + const std::map &parser_params) const { // support paragrams: input_fp16_nodes, is_input_adjust_hw_layout, ComputeGraphPtr compute_graph = GraphUtils::GetComputeGraph(graph); GE_CHECK_NOTNULL(compute_graph); @@ -938,12 +938,10 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadProtoFromMem(const cha return ret; } -/// /// @brief get the Original Type of FrameworkOp /// @param [in] node /// @param [out] type /// @return Status -/// Status GetOriginalType(const ge::NodePtr &node, string &type) { GE_CHECK_NOTNULL(node); type = node->GetType(); diff --git a/parser/common/acl_graph_parser_util.h b/parser/common/acl_graph_parser_util.h index 4ff649f..070658e 100644 --- a/parser/common/acl_graph_parser_util.h +++ b/parser/common/acl_graph_parser_util.h @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,16 +34,16 @@ namespace ge { using google::protobuf::Message; -class AclGrphParseUtil { +class AclGraphParseUtil { public: - AclGrphParseUtil() {} - virtual ~AclGrphParseUtil() {} + AclGraphParseUtil() {} + virtual ~AclGraphParseUtil() {} static domi::Status LoadOpsProtoLib(); static void SaveCustomCaffeProtoPath(); domi::Status AclParserInitialize(const std::map &options); - domi::Status SetOutputNodeInfo(ge::Graph &graph, const std::map &parser_params); + domi::Status SetOutputNodeInfo(ge::Graph &graph, const std::map &parser_params) const; domi::Status ParseParamsBeforeGraph(const std::map &parser_params, - std::string &graph_name); + std::string &graph_name) const; domi::Status ParseParamsAfterGraph(ge::Graph &graph, const std::map &parser_params) const; @@ -67,31 +67,23 @@ class AclGrphParseUtil { }; namespace parser { -/// /// @ingroup: domi_common /// @brief: get length of file /// @param [in] input_file: path of file /// @return long: File length. If the file length fails to be obtained, the value -1 is returned. -/// extern long GetFileLength(const std::string &input_file); -/// /// @ingroup domi_common /// @brief Absolute path for obtaining files. /// @param [in] path of input file /// @param [out] Absolute path of a file. If the absolute path cannot be obtained, an empty string is returned -/// std::string RealPath(const char *path); -/// /// @ingroup domi_common /// @brief Obtains the absolute time (timestamp) of the current system. /// @return Timestamp, in microseconds (US) -/// -/// uint64_t GetCurrentTimestamp(); -/// /// @ingroup domi_common /// @brief Reads all data from a binary file. /// @param [in] file_name path of file @@ -99,20 +91,16 @@ uint64_t GetCurrentTimestamp(); /// @param [out] length Output memory size /// @return false fail /// @return true success -/// bool ReadBytesFromBinaryFile(const char *file_name, char **buffer, int &length); -/// /// @ingroup domi_common /// @brief proto file in bianary format /// @param [in] file path of proto file /// @param [out] proto memory for storing the proto file /// @return true success /// @return false fail -/// bool ReadProtoFromBinaryFile(const char *file, Message *proto); -/// /// @ingroup domi_common /// @brief Reads the proto structure from an array. /// @param [in] data proto data to be read @@ -120,42 +108,33 @@ bool ReadProtoFromBinaryFile(const char *file, Message *proto); /// @param [out] proto Memory for storing the proto file /// @return true success /// @return false fail -/// bool ReadProtoFromArray(const void *data, int size, Message *proto); -/// /// @ingroup domi_proto /// @brief Reads the proto file in the text format. /// @param [in] file path of proto file /// @param [out] message Memory for storing the proto file /// @return true success /// @return false fail -/// bool ReadProtoFromText(const char *file, google::protobuf::Message *message); bool ReadProtoFromMem(const char *data, int size, google::protobuf::Message *message); -/// /// @brief get the Original Type of FrameworkOp /// @param [in] node /// @param [out] type /// @return Status -/// domi::Status GetOriginalType(const ge::NodePtr &node, string &type); -/// /// @ingroup domi_common /// @brief Check whether the file path meets the whitelist verification requirements. /// @param [in] filePath file path /// @param [out] result -/// bool ValidateStr(const std::string &filePath, const std::string &mode); -/// /// @ingroup domi_common /// @brief Obtains the current time string. /// @return Time character string in the format: %Y%m%d%H%M%S, eg: 20171011083555 -/// std::string CurrentTimeInStr(); template diff --git a/parser/common/auto_mapping_subgraph_io_index_func.h b/parser/common/auto_mapping_subgraph_io_index_func.h index 802b300..7a1823d 100644 --- a/parser/common/auto_mapping_subgraph_io_index_func.h +++ b/parser/common/auto_mapping_subgraph_io_index_func.h @@ -1,5 +1,5 @@ /** - * Copyright 2019-2021 Huawei Technologies Co., Ltd + * Copyright (c) Huawei Technologies Co., Ltd. 2019~2021. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/parser/common/convert/pb2json.cc b/parser/common/convert/pb2json.cc index 0b3dd2b..974e1e6 100644 --- a/parser/common/convert/pb2json.cc +++ b/parser/common/convert/pb2json.cc @@ -178,7 +178,7 @@ void Pb2Json::RepeatedMessage2Json(const ProtobufMsg &message, const ProtobufFie switch (field->type()) { case ProtobufFieldDescriptor::TYPE_MESSAGE: { const ProtobufMsg &tmp_message = reflection->GetRepeatedMessage(message, field, i); - if (0UL != tmp_message.ByteSizeLong()) { + if (tmp_message.ByteSizeLong() != 0UL) { Message2Json(tmp_message, black_fields, tmp_json, enum2str, depth + 1); } } break; diff --git a/parser/onnx/onnx_parser.cc b/parser/onnx/onnx_parser.cc index 0872b39..bd92de9 100644 --- a/parser/onnx/onnx_parser.cc +++ b/parser/onnx/onnx_parser.cc @@ -52,7 +52,7 @@ const char *kLocation = "location"; } namespace ge { -graphStatus PrepareBeforeParse(AclGrphParseUtil &acl_graph_parse_util, +graphStatus PrepareBeforeParse(AclGraphParseUtil &acl_graph_parse_util, const std::map &parser_params, ge::Graph &graph, std::shared_ptr &model_parser) { GetParserContext().type = domi::ONNX; @@ -82,7 +82,7 @@ graphStatus PrepareBeforeParse(AclGrphParseUtil &acl_graph_parse_util, return ge::SUCCESS; } -graphStatus HandleAfterParse(AclGrphParseUtil &acl_graph_parse_util, +graphStatus HandleAfterParse(AclGraphParseUtil &acl_graph_parse_util, const std::map &parser_params, ge::Graph &graph) { if (acl_graph_parse_util.ParseParamsAfterGraph(graph, parser_params) != ge::SUCCESS) { @@ -104,7 +104,7 @@ graphStatus aclgrphParseONNX(const char *model_file, const std::map &parser_params, ge::Graph &graph) { GE_CHECK_NOTNULL(model_file); // load custom plugin so and proto - AclGrphParseUtil acl_graph_parse_util; + AclGraphParseUtil acl_graph_parse_util; std::shared_ptr model_parser; if (PrepareBeforeParse(acl_graph_parse_util, parser_params, graph, model_parser) != ge::SUCCESS) { @@ -136,7 +136,7 @@ graphStatus aclgrphParseONNXFromMem(const char *buffer, size_t size, const std::map &parser_params, ge::Graph &graph) { GE_CHECK_NOTNULL(buffer); // load custom plugin so and proto - AclGrphParseUtil acl_graph_parse_util; + AclGraphParseUtil acl_graph_parse_util; std::shared_ptr model_parser; if (PrepareBeforeParse(acl_graph_parse_util, parser_params, graph, model_parser) != ge::SUCCESS) { diff --git a/parser/tensorflow/tensorflow_parser.cc b/parser/tensorflow/tensorflow_parser.cc index 5519620..a377157 100644 --- a/parser/tensorflow/tensorflow_parser.cc +++ b/parser/tensorflow/tensorflow_parser.cc @@ -94,7 +94,7 @@ graphStatus aclgrphParseTensorFlow(const char *model_file, ge::Graph &graph) { options.insert(std::pair(string(ge::FRAMEWORK_TYPE), to_string(domi::TENSORFLOW))); // load custom plugin so and proto - AclGrphParseUtil acl_graph_parse_util; + AclGraphParseUtil acl_graph_parse_util; if (acl_graph_parse_util.AclParserInitialize(options) != domi::SUCCESS) { GELOGE(GRAPH_FAILED, "Parser Initialize failed."); return GRAPH_FAILED; @@ -142,7 +142,7 @@ graphStatus aclgrphParseTensorFlow(const char *model_file, const std::map(string(ge::FRAMEWORK_TYPE), to_string(domi::TENSORFLOW))); // load custom plugin so and proto - AclGrphParseUtil acl_graph_parse_util; + AclGraphParseUtil acl_graph_parse_util; domi::Status status = acl_graph_parse_util.AclParserInitialize(options); if (status != domi::SUCCESS) { GELOGE(GRAPH_FAILED, "Parser Initialize failed."); diff --git a/tests/st/testcase/test_caffe_parser.cc b/tests/st/testcase/test_caffe_parser.cc index fe5ecf9..b03a231 100644 --- a/tests/st/testcase/test_caffe_parser.cc +++ b/tests/st/testcase/test_caffe_parser.cc @@ -191,7 +191,7 @@ TEST_F(STestCaffeParser, caffe_parser_user_output_with_default) { ge::Graph graph = ge::GraphUtils::CreateGraphFromComputeGraph(compute_graph); auto ret = model_parser->Parse(model_file.c_str(), graph); ASSERT_EQ(ret, GRAPH_SUCCESS); - AclGrphParseUtil acl_graph_parse_util; + AclGraphParseUtil acl_graph_parse_util; std::map parser_params; auto status = acl_graph_parse_util.SetOutputNodeInfo(graph, parser_params); ASSERT_EQ(status, SUCCESS); @@ -483,7 +483,7 @@ TEST_F(STestCaffeParser, CaffeWeightsParser_CreateCustomOperator_test) TEST_F(STestCaffeParser, CaffeWeightsParser_ParseOutputNodeTopInfo_test) { CaffeModelParser model_parser; - AclGrphParseUtil acl_graph_parse_util; + AclGraphParseUtil acl_graph_parse_util; domi::caffe::NetParameter net; domi::caffe::LayerParameter *lay0 = net.add_layer(); diff --git a/tests/st/testcase/test_tensorflow_parser.cc b/tests/st/testcase/test_tensorflow_parser.cc index 0db72f5..812e0ed 100644 --- a/tests/st/testcase/test_tensorflow_parser.cc +++ b/tests/st/testcase/test_tensorflow_parser.cc @@ -1104,7 +1104,7 @@ TEST_F(STestTensorflowParser, parser_tensorflow_model) { // parser tensorflow model out_node_size is equal to index string graph_name; - AclGrphParseUtil acl_graph_parse_util; + AclGraphParseUtil acl_graph_parse_util; std::map out_nodes_with_node_and_index = { {AscendString(ge::ir_option::OUT_NODES), AscendString("Placeholder:0;Placeholder_1:1")}}; ParerSTestsUtils::ClearParserInnerCtx(); @@ -1356,7 +1356,7 @@ TEST_F(STestTensorflowParser, tensorflow_parserAllGraph_failed) TEST_F(STestTensorflowParser, test_parse_acl_output_nodes) { - AclGrphParseUtil acl_graph_parse_util; + AclGraphParseUtil acl_graph_parse_util; string graph_name; // case 1: Normal with 'node and index' ParerSTestsUtils::ClearParserInnerCtx(); @@ -1523,7 +1523,7 @@ TEST_F(STestTensorflowParser, parse_AddFmkNode) std::string modelFile = caseDir + "/origin_models/tf_add.pb"; ge::Graph graph; string graph_name; - AclGrphParseUtil acl_graph_parse_util; + AclGraphParseUtil acl_graph_parse_util; std::map parser_options = {{AscendString(ge::ir_option::OUT_NODES), AscendString("Placeholder:0;Placeholder_1:0")}}; ParerSTestsUtils::ClearParserInnerCtx(); Status ret = acl_graph_parse_util.ParseParamsBeforeGraph(parser_options, graph_name); @@ -3781,9 +3781,9 @@ TEST_F(STestTensorflowParser, tensorflow_ReadBytesFromBinaryFile_test) EXPECT_EQ(realPath, ""); } -TEST_F(STestTensorflowParser, tensorflow_AclGrphParseUtil_ParseAclInputFp16Nodes_test) +TEST_F(STestTensorflowParser, tensorflow_AclGraphParseUtil_ParseAclInputFp16Nodes_test) { - AclGrphParseUtil parserUtil; + AclGraphParseUtil parserUtil; ge::ComputeGraphPtr graph = std::make_shared(GRAPH_DEFAULT_NAME); std::string input_fp16_nodes = "Add"; std::string is_input_adjust_hw_layout = "is_input_adjust_hw_layout"; @@ -4010,7 +4010,7 @@ TEST_F(STestTensorflowParser, tensorflow_FP16_parser_test) TEST_F(STestTensorflowParser, tensorflow_AclParserInitialize_test) { - AclGrphParseUtil parseUtil; + AclGraphParseUtil parseUtil; std::map options; Status ret = parseUtil.AclParserInitialize(options); EXPECT_EQ(ret, FAILED); @@ -4022,7 +4022,7 @@ TEST_F(STestTensorflowParser, tensorflow_AclParserInitialize_test) TEST_F(STestTensorflowParser, tensorflow_GetOutputLeaf_test) { - AclGrphParseUtil parseUtil; + AclGraphParseUtil parseUtil; ge::ComputeGraphPtr compute_graph = build_graph(true); ge::NodePtr output_nodes_info = compute_graph->FindNode("Relu3"); std::vector> output_nodes = {{output_nodes_info,0}}; diff --git a/tests/ut/parser/testcase/caffe_parser_testcase/caffe_parser_unittest.cc b/tests/ut/parser/testcase/caffe_parser_testcase/caffe_parser_unittest.cc index 53e5cf9..b1a28d1 100755 --- a/tests/ut/parser/testcase/caffe_parser_testcase/caffe_parser_unittest.cc +++ b/tests/ut/parser/testcase/caffe_parser_testcase/caffe_parser_unittest.cc @@ -189,7 +189,7 @@ TEST_F(UtestCaffeParser, caffe_parser_user_output_with_name_and_index) { ge::GetParserContext().user_out_nodes.push_back({"abs", 0}); auto ret = model_parser->Parse(model_file.c_str(), graph); ASSERT_EQ(ret, GRAPH_SUCCESS); - AclGrphParseUtil acl_graph_parse_util; + AclGraphParseUtil acl_graph_parse_util; std::map parser_params; auto status = acl_graph_parse_util.SetOutputNodeInfo(graph, parser_params); ASSERT_EQ(status, SUCCESS); @@ -216,7 +216,7 @@ TEST_F(UtestCaffeParser, caffe_parser_user_output_with_top_name) { ge::GetParserContext().user_out_tensors.push_back("abs_out"); auto ret = model_parser->Parse(model_file.c_str(), graph); ASSERT_EQ(ret, GRAPH_SUCCESS); - AclGrphParseUtil acl_graph_parse_util; + AclGraphParseUtil acl_graph_parse_util; std::map parser_params; auto status = acl_graph_parse_util.SetOutputNodeInfo(graph, parser_params); ASSERT_EQ(status, SUCCESS); @@ -241,7 +241,7 @@ TEST_F(UtestCaffeParser, caffe_parser_user_output_with_default) { ge::Graph graph = ge::GraphUtils::CreateGraphFromComputeGraph(compute_graph); auto ret = model_parser->Parse(model_file.c_str(), graph); ASSERT_EQ(ret, GRAPH_SUCCESS); - AclGrphParseUtil acl_graph_parse_util; + AclGraphParseUtil acl_graph_parse_util; std::map parser_params; auto status = acl_graph_parse_util.SetOutputNodeInfo(graph, parser_params); ASSERT_EQ(status, SUCCESS); @@ -543,7 +543,7 @@ TEST_F(UtestCaffeParser, CaffeWeightsParser_CreateCustomOperator_test) TEST_F(UtestCaffeParser, CaffeWeightsParser_ParseOutputNodeTopInfo_test) { CaffeModelParser model_parser; - AclGrphParseUtil acl_graph_parse_util; + AclGraphParseUtil acl_graph_parse_util; domi::caffe::NetParameter net; domi::caffe::LayerParameter *lay0 = net.add_layer(); diff --git a/tests/ut/parser/testcase/common/acl_graph_parser_unittest.cc b/tests/ut/parser/testcase/common/acl_graph_parser_unittest.cc index 50a787c..e7ef5e8 100755 --- a/tests/ut/parser/testcase/common/acl_graph_parser_unittest.cc +++ b/tests/ut/parser/testcase/common/acl_graph_parser_unittest.cc @@ -53,7 +53,7 @@ class UtestAclGraphParser : public testing::Test { }; TEST_F(UtestAclGraphParser, test_parse_acl_output_nodes) { - AclGrphParseUtil acl_graph_parse_util; + AclGraphParseUtil acl_graph_parse_util; string graph_name; // case 1: Normal with 'node and index' ParerUTestsUtils::ClearParserInnerCtx(); diff --git a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc index 8e4ccab..acfe2c9 100644 --- a/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc +++ b/tests/ut/parser/testcase/tensorflow_parser_testcase/tensorflow_parser_unittest.cc @@ -1106,7 +1106,7 @@ TEST_F(UtestTensorflowParser, parser_tensorflow_model) { // parser tensorflow model out_node_size is equal to index string graph_name; - AclGrphParseUtil acl_graph_parse_util; + AclGraphParseUtil acl_graph_parse_util; std::map out_nodes_with_node_and_index = { {AscendString(ge::ir_option::OUT_NODES), AscendString("Placeholder:0;Placeholder_1:1")}}; ParerUTestsUtils::ClearParserInnerCtx(); @@ -1452,7 +1452,7 @@ TEST_F(UtestTensorflowParser, tensorflow_parserAllGraph_failed) TEST_F(UtestTensorflowParser, test_parse_acl_output_nodes) { - AclGrphParseUtil acl_graph_parse_util; + AclGraphParseUtil acl_graph_parse_util; string graph_name; // case 1: Normal with 'node and index' ParerUTestsUtils::ClearParserInnerCtx(); @@ -1621,7 +1621,7 @@ TEST_F(UtestTensorflowParser, parse_AddFmkNode) std::string modelFile = caseDir + "/tensorflow_model/tf_add.pb"; ge::Graph graph; string graph_name; - AclGrphParseUtil acl_graph_parse_util; + AclGraphParseUtil acl_graph_parse_util; std::map parser_options = {{AscendString(ge::ir_option::OUT_NODES), AscendString("Placeholder:0;Placeholder_1:0")}}; ParerUTestsUtils::ClearParserInnerCtx(); Status ret = acl_graph_parse_util.ParseParamsBeforeGraph(parser_options, graph_name); @@ -3885,9 +3885,9 @@ TEST_F(UtestTensorflowParser, tensorflow_ReadBytesFromBinaryFile_test) EXPECT_EQ(realPath, ""); } -TEST_F(UtestTensorflowParser, tensorflow_AclGrphParseUtil_ParseAclInputFp16Nodes_test) +TEST_F(UtestTensorflowParser, tensorflow_AclGraphParseUtil_ParseAclInputFp16Nodes_test) { - AclGrphParseUtil parserUtil; + AclGraphParseUtil parserUtil; ge::ComputeGraphPtr graph = std::make_shared(GRAPH_DEFAULT_NAME); std::string input_fp16_nodes = "Add"; std::string is_input_adjust_hw_layout = "is_input_adjust_hw_layout"; @@ -4094,7 +4094,7 @@ TEST_F(UtestTensorflowParser, tensorflow_FP16_parser_test) TEST_F(UtestTensorflowParser, tensorflow_AclParserInitialize_test) { - AclGrphParseUtil parseUtil; + AclGraphParseUtil parseUtil; std::map options; Status ret = parseUtil.AclParserInitialize(options); EXPECT_EQ(ret, FAILED); @@ -4106,7 +4106,7 @@ TEST_F(UtestTensorflowParser, tensorflow_AclParserInitialize_test) TEST_F(UtestTensorflowParser, tensorflow_GetOutputLeaf_test) { - AclGrphParseUtil parseUtil; + AclGraphParseUtil parseUtil; ge::ComputeGraphPtr compute_graph = build_graph(true); ge::NodePtr output_nodes_info = compute_graph->FindNode("Relu3"); std::vector> output_nodes = {{output_nodes_info,0}};