Browse Source

remove dependence of parser

pull/236/head
wjm 5 years ago
parent
commit
f62fd8e4bf
32 changed files with 173 additions and 35 deletions
  1. +3
    -3
      parser/caffe/caffe_parser.cc
  2. +1
    -2
      parser/common/acl_graph_parser_util.cc
  3. +1
    -1
      parser/common/data_op_parser.cc
  4. +0
    -1
      parser/common/data_op_parser.h
  5. +48
    -0
      parser/common/graph_pass.h
  6. +62
    -0
      parser/common/op_types.h
  7. +42
    -0
      parser/common/pass.h
  8. +1
    -0
      parser/common/pass_manager.cc
  9. +1
    -1
      parser/common/pass_manager.h
  10. +0
    -1
      parser/common/proto_file_parser.cc
  11. +0
    -1
      parser/common/proto_file_parser.h
  12. +0
    -1
      parser/common/register_tbe.cc
  13. +1
    -0
      parser/onnx/onnx_data_parser.cc
  14. +0
    -1
      parser/onnx/onnx_op_parser.h
  15. +0
    -1
      parser/tensorflow/graph_insert_trans_op.h
  16. +1
    -2
      parser/tensorflow/graph_optimizer.cc
  17. +1
    -1
      parser/tensorflow/iterator_fusion_pass.h
  18. +1
    -1
      parser/tensorflow/tensorflow_constant_parser.cc
  19. +0
    -2
      parser/tensorflow/tensorflow_fill_parser.cc
  20. +0
    -1
      parser/tensorflow/tensorflow_fusion_op_parser.h
  21. +1
    -1
      parser/tensorflow/tensorflow_fusionop_util.cc
  22. +0
    -1
      parser/tensorflow/tensorflow_identity_parser.cc
  23. +1
    -1
      parser/tensorflow/tensorflow_op_parser.h
  24. +4
    -3
      parser/tensorflow/tensorflow_parser.cc
  25. +0
    -1
      parser/tensorflow/tensorflow_parser.h
  26. +1
    -1
      parser/tensorflow/tensorflow_ref_switch_parser.cc
  27. +1
    -1
      parser/tensorflow/tensorflow_reshape_parser.cc
  28. +1
    -1
      parser/tensorflow/tensorflow_shape_n_parser.cc
  29. +0
    -1
      parser/tensorflow/tensorflow_squeeze_parser.cc
  30. +1
    -1
      parser/tensorflow/tensorflow_util.cc
  31. +0
    -2
      parser/tensorflow/tensorflow_var_is_initialized_op_parser.cc
  32. +0
    -1
      parser/tensorflow/tensorflow_variable_v2_parser.cc

+ 3
- 3
parser/caffe/caffe_parser.cc View File

@@ -271,7 +271,7 @@ Status CaffeModelParser::ParseInput(domi::caffe::NetParameter &proto_message, bo
ErrorManager::GetInstance().ATCReportErrMessage("E11002");
return PARAM_INVALID, "Model has no input.");

GE_CHK_BOOL_TRUE_EXEC_WITH_LOG((input_dim_size / proto_message.input_size() != ge::DIM_DEFAULT_SIZE ||
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG((input_dim_size / proto_message.input_size() != parser::DIM_DEFAULT_SIZE ||
input_dim_size % proto_message.input_size() != 0),
ErrorManager::GetInstance().ATCReportErrMessage(
"E11003", {"input_dim_size", "input_size"},
@@ -291,9 +291,9 @@ Status CaffeModelParser::ParseInput(domi::caffe::NetParameter &proto_message, bo
domi::caffe::BlobShape *shape = input_param->add_shape();
GE_CHECK_NOTNULL(shape);

for (int j = 0; j < ge::DIM_DEFAULT_SIZE; j++) {
for (int j = 0; j < parser::DIM_DEFAULT_SIZE; j++) {
// Can guarantee that it will not cross the border
shape->add_dim(static_cast<int64_t>(proto_message.input_dim(j + i * ge::DIM_DEFAULT_SIZE)));
shape->add_dim(static_cast<int64_t>(proto_message.input_dim(j + i * parser::DIM_DEFAULT_SIZE)));
}
input_data_flag = true;
}


+ 1
- 2
parser/common/acl_graph_parser_util.cc View File

@@ -23,9 +23,7 @@
#include <ctime>
#include <fstream>

#include "common/op/ge_op_utils.h"
#include "common/string_util.h"
#include "common/types.h"
#include "common/util.h"
#include "common/util/error_manager/error_manager.h"
#include "external/ge/ge_api_types.h"
@@ -34,6 +32,7 @@
#include "ge/ge_api_types.h"
#include "google/protobuf/io/coded_stream.h"
#include "google/protobuf/io/zero_copy_stream_impl.h"
#include "graph/debug/ge_attr_define.h"
#include "graph/opsproto_manager.h"
#include "graph/utils/type_utils.h"
#include "omg/parser/parser_inner_ctx.h"


+ 1
- 1
parser/common/data_op_parser.cc View File

@@ -16,10 +16,10 @@

#include "parser/common/data_op_parser.h"
#include <cstdlib>
#include "common/op/ge_op_utils.h"
#include "parser/common/acl_graph_parser_util.h"
#include "omg/parser/parser_inner_ctx.h"
#include "common/util.h"
#include "graph/debug/ge_attr_define.h"
#include "graph/utils/type_utils.h"

namespace {


+ 0
- 1
parser/common/data_op_parser.h View File

@@ -19,7 +19,6 @@

#include <google/protobuf/text_format.h>
#include <vector>
#include "common/op/attr_value_util.h"
#include "framework/omg/parser/parser_types.h"
#include "omg/omg_inner_types.h"
#include "proto/om.pb.h"


+ 48
- 0
parser/common/graph_pass.h View File

@@ -0,0 +1,48 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef PARSER_COMMON_GRAPH_PASS_H_
#define PARSER_COMMON_GRAPH_PASS_H_

#include <string>
#include <vector>

#include "framework/common/debug/ge_log.h"
#include "graph/compute_graph.h"
#include "common/pass.h"

namespace ge {
///
/// @ingroup domi_omg
/// @brief graph pass
/// @author
///
class GraphPass : public Pass<ge::ComputeGraph> {
public:
///
/// run graph pass
/// @param [in] graph graph to be optimized
/// @return SUCCESS optimize successfully
/// @return NOT_CHANGED not optimized
/// @return others optimized failed
/// @author
///
virtual Status Run(ge::ComputeGraphPtr graph) = 0;
virtual Status ClearStatus() { return SUCCESS; };
};
} // namespace ge

#endif // PARSER_COMMON_GRAPH_PASS_H_

+ 62
- 0
parser/common/op_types.h View File

@@ -0,0 +1,62 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef PARSER_COMMON_OP_TYPES_H_
#define PARSER_COMMON_OP_TYPES_H_

#include <set>
#include <string>

namespace ge {
class GE_FUNC_VISIBILITY OpTypeContainer {
public:
static OpTypeContainer *Instance() {
static OpTypeContainer instance;
return &instance;
}
~OpTypeContainer() = default;

void Register(const std::string &op_type) { op_type_list_.insert(op_type); }

bool IsExisting(const std::string &op_type) {
auto iter_find = op_type_list_.find(op_type);
return iter_find != op_type_list_.end();
}

protected:
OpTypeContainer() {}

private:
std::set<std::string> op_type_list_;
};

class GE_FUNC_VISIBILITY OpTypeRegistrar {
public:
explicit OpTypeRegistrar(const std::string &op_type) { OpTypeContainer::Instance()->Register(op_type); }
~OpTypeRegistrar() {}
};

#define REGISTER_OPTYPE_DECLARE(var_name, str_name) \
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY extern const char *var_name;

#define REGISTER_OPTYPE_DEFINE(var_name, str_name) \
const char *var_name = str_name; \
const OpTypeRegistrar g_##var_name##_reg(str_name);

#define IS_OPTYPE_EXISTING(str_name) (OpTypeContainer::Instance()->IsExisting(str_name))
} // namespace ge

#endif // PARSER_COMMON_OP_TYPES_H_

+ 42
- 0
parser/common/pass.h View File

@@ -0,0 +1,42 @@
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef PARSER_COMMON_PASS_H_
#define PARSER_COMMON_PASS_H_

#include <memory>

#include "common/fmk_error_codes.h"

namespace ge {
///
/// @ingroup domi_omg
/// @brief pass
/// @author
///
template <typename T>
class Pass {
public:
virtual ~Pass() {}
///
/// run pass
/// @author
///
virtual Status Run(std::shared_ptr<T>) = 0;
};
} // namespace ge

#endif // PARSER_COMMON_PASS_H_

+ 1
- 0
parser/common/pass_manager.cc View File

@@ -14,6 +14,7 @@
* limitations under the License.
*/

#include "common/util.h"
#include "parser/common/pass_manager.h"
#include "framework/omg/parser/parser_types.h"
#include "parser/common/acl_graph_parser_util.h"


+ 1
- 1
parser/common/pass_manager.h View File

@@ -19,7 +19,7 @@

#include <vector>

#include "inc/graph_pass.h"
#include "common/graph_pass.h"

using std::vector;



+ 0
- 1
parser/common/proto_file_parser.cc View File

@@ -24,7 +24,6 @@
#include <sys/types.h>
#include <unistd.h>
#include "common/string_util.h"
#include "common/types.h"
#include "common/util.h"
#include "parser/common/acl_graph_parser_util.h"
#include "ge/ge_api_types.h"


+ 0
- 1
parser/common/proto_file_parser.h View File

@@ -19,7 +19,6 @@

#include <map>
#include <string>
#include "common/types.h"
#include "ge/ge_api_types.h"

namespace ge {


+ 0
- 1
parser/common/register_tbe.cc View File

@@ -19,7 +19,6 @@
#include <memory>
#include <string>
#include "parser/common/acl_graph_parser_util.h"
#include "common/op/ge_op_utils.h"
#include "common/op_map.h"
#include "common/util.h"
#include "framework/common/debug/ge_log.h"


+ 1
- 0
parser/onnx/onnx_data_parser.cc View File

@@ -17,6 +17,7 @@
#include "onnx_data_parser.h"
#include <unordered_map>
#include "common/util.h"
#include "graph/debug/ge_attr_define.h"
#include "parser/common/op_parser_factory.h"
#include "framework/omg/parser/parser_inner_ctx.h"
#include "parser/onnx/onnx_util.h"


+ 0
- 1
parser/onnx/onnx_op_parser.h View File

@@ -33,7 +33,6 @@

#include <string>
#include <vector>
#include "framework/common/op/attr_value_util.h"
#include "framework/omg/parser/op_parser.h"
#include "graph/ge_tensor.h"
#include "graph/node.h"


+ 0
- 1
parser/tensorflow/graph_insert_trans_op.h View File

@@ -20,7 +20,6 @@
#include <string>
#include <vector>
#include "common/fmk_types.h"
#include "common/op/ge_op_utils.h"
#include "framework/omg/parser/parser_types.h"
#include "graph/compute_graph.h"
#include "graph/node.h"


+ 1
- 2
parser/tensorflow/graph_optimizer.cc View File

@@ -23,10 +23,10 @@
#include "cce/cce.h"
#include "cce/dnn.h"
#include "parser/common/acl_graph_parser_util.h"
#include "common/op/ge_op_utils.h"
#include "common/op_map.h"
#include "common/op_types.h"
#include "common/types_map.h"
#include "common/util.h"
#include "framework/common/debug/ge_log.h"
#include "framework/omg/parser/parser_inner_ctx.h"
#include "framework/omg/parser/parser_types.h"
@@ -69,7 +69,6 @@ using ge::local_framework_op_vec;
using ge::NodePtr;
using ge::OpDesc;
using ge::OpDescPtr;
using ge::OpUtils;
using ge::OutControlAnchorPtr;
using ge::OutDataAnchorPtr;
using ge::TensorUtils;


+ 1
- 1
parser/tensorflow/iterator_fusion_pass.h View File

@@ -17,7 +17,7 @@
#ifndef GE_GRAPH_PASSES_ITERATOR_FUSION_PASS_H_
#define GE_GRAPH_PASSES_ITERATOR_FUSION_PASS_H_

#include "inc/graph_pass.h"
#include "common/graph_pass.h"
#include "register/register_fmk_types.h"

namespace ge {


+ 1
- 1
parser/tensorflow/tensorflow_constant_parser.cc View File

@@ -19,9 +19,9 @@
#include <memory>
#include <vector>
#include "parser/common/acl_graph_parser_util.h"
#include "common/op/ge_op_utils.h"
#include "parser/common/op_def/constant_op.h"
#include "parser/common/op_def/ir_pb_converter.h"
#include "parser/common/util.h"
#include "framework/common/debug/ge_log.h"
#include "graph/ge_tensor.h"
#include "graph/utils/attr_utils.h"


+ 0
- 2
parser/tensorflow/tensorflow_fill_parser.cc View File

@@ -14,8 +14,6 @@
* limitations under the License.
*/

// Copyright (c) <2018>, <Huawei Technologies Co., Ltd>
#include "common/op/attr_value_util.h"
#include "parser/common/op_def/fill_op.h"
#include "parser/tensorflow/tensorflow_parser_register.h"
#include "framework/omg/parser/parser_types.h"


+ 0
- 1
parser/tensorflow/tensorflow_fusion_op_parser.h View File

@@ -18,7 +18,6 @@
#define OMG_PARSER_TENSORFLOW_TENSORFLOW_FUSION_OP_PARSER_H_

#include <vector>
#include "common/op/attr_value_util.h"
#include "graph/ge_tensor.h"
#include "omg/parser/op_parser.h"
#include "parser/tensorflow/tensorflow_fusionop_util.h"


+ 1
- 1
parser/tensorflow/tensorflow_fusionop_util.cc View File

@@ -16,8 +16,8 @@

#include "parser/tensorflow/tensorflow_fusionop_util.h"
#include "common/util/error_manager/error_manager.h"
#include "common/op/ge_op_utils.h"
#include "framework/common/debug/ge_log.h"
#include "parser/common/util.h"
#include "parser/tensorflow/tensorflow_parser.h"
#include "framework/omg/parser/parser_types.h"



+ 0
- 1
parser/tensorflow/tensorflow_identity_parser.cc View File

@@ -14,7 +14,6 @@
* limitations under the License.
*/

#include "common/op/ge_op_utils.h"
#include "common/op_def/ir_pb_converter.h"
#include "parser/common/op_parser_factory.h"
#include "framework/omg/parser/parser_types.h"


+ 1
- 1
parser/tensorflow/tensorflow_op_parser.h View File

@@ -33,8 +33,8 @@

#include <string>
#include <vector>
#include "framework/common/op/attr_value_util.h"
#include "framework/omg/parser/op_parser.h"
#include "graph/debug/ge_attr_define.h"
#include "graph/ge_tensor.h"
#include "graph/node.h"
#include "register/tensor_assign.h"


+ 4
- 3
parser/tensorflow/tensorflow_parser.cc View File

@@ -43,6 +43,7 @@
#include "parser/common/pre_checker.h"
#include "parser/common/thread_pool.h"
#include "parser/common/parser_utils.h"
#include "parser/common/util.h"
#include "parser/tensorflow/tensorflow_custom_parser_adapter.h"
#include "parser/tensorflow/tensorflow_fusion_custom_parser_adapter.h"
#include "parser/tensorflow/tensorflow_fusion_op_parser.h"
@@ -2871,7 +2872,7 @@ Status TensorFlowModelParser::GetFormatTranspose(const NodeDef *transpose_node,
return FAILED);
const TensorProto &tensor = attr_value.tensor();
const TensorShapeProto &tensor_shape = tensor.tensor_shape();
GE_IF_BOOL_EXEC(tensor_shape.dim_size() != 1 || tensor_shape.dim(0).size() != ge::DIM_DEFAULT_SIZE, return SUCCESS);
GE_IF_BOOL_EXEC(tensor_shape.dim_size() != 1 || tensor_shape.dim(0).size() != parser::DIM_DEFAULT_SIZE, return SUCCESS);
GE_IF_BOOL_EXEC(tensor.tensor_content().empty(), return SUCCESS);

vector<int64_t> perm_value;
@@ -2879,12 +2880,12 @@ Status TensorFlowModelParser::GetFormatTranspose(const NodeDef *transpose_node,
GE_IF_BOOL_EXEC(
type == domi::tensorflow::DT_INT32,
const int32_t *data = reinterpret_cast<const int32_t *>(tensor.tensor_content().data());
for (int i = 0; i < ge::DIM_DEFAULT_SIZE; i++) { perm_value.push_back(data[i]); });
for (int i = 0; i < parser::DIM_DEFAULT_SIZE; i++) { perm_value.push_back(data[i]); });

GE_IF_BOOL_EXEC(
type == domi::tensorflow::DT_INT64,
const int64_t *data = reinterpret_cast<const int64_t *>(tensor.tensor_content().data());
for (int i = 0; i < ge::DIM_DEFAULT_SIZE; i++) { perm_value.push_back(data[i]); });
for (int i = 0; i < parser::DIM_DEFAULT_SIZE; i++) { perm_value.push_back(data[i]); });

// 0, 1, 2, 3 present dim num.
vector<int64_t> perm_to_nchw = {0, 3, 1, 2};


+ 0
- 1
parser/tensorflow/tensorflow_parser.h View File

@@ -24,7 +24,6 @@
#include <unordered_map>
#include <utility>
#include <vector>
#include "common/op/ge_op_utils.h"
#include "graph/compute_graph.h"
#include "graph/ge_attr_value.h"
#include "graph/ge_tensor.h"


+ 1
- 1
parser/tensorflow/tensorflow_ref_switch_parser.cc View File

@@ -16,10 +16,10 @@

#include "parser/tensorflow/tensorflow_ref_switch_parser.h"
#include "framework/common/debug/ge_log.h"
#include "framework/common/op/ge_op_utils.h"
#include "parser/common/op_def/ir_pb_converter.h"
#include "parser/common/op_def/ref_switch_op.h"
#include "parser/common/op_parser_factory.h"
#include "parser/common/util.h"

using domi::tensorflow::DataType;
using domi::tensorflow::DT_FLOAT;


+ 1
- 1
parser/tensorflow/tensorflow_reshape_parser.cc View File

@@ -16,9 +16,9 @@

#include "parser/tensorflow/tensorflow_reshape_parser.h"
#include "framework/common/debug/ge_log.h"
#include "framework/common/op/ge_op_utils.h"
#include "graph/utils/type_utils.h"
#include "parser/common/op_parser_factory.h"
#include "parser/common/util.h"
#include "parser/tensorflow/tensorflow_util.h"
#include "parser/common/acl_graph_parser_util.h"
#include "omg/parser/parser_inner_ctx.h"


+ 1
- 1
parser/tensorflow/tensorflow_shape_n_parser.cc View File

@@ -17,9 +17,9 @@
#include "parser/tensorflow/tensorflow_shape_n_parser.h"
#include "parser/common/op_def/ir_pb_converter.h"
#include "framework/common/debug/ge_log.h"
#include "framework/common/op/ge_op_utils.h"
#include "parser/common/op_parser_factory.h"
#include "parser/common/op_def/shape_n_op.h"
#include "parser/common/util.h"

using domi::TENSORFLOW;
using domi::tensorflow::AttrValue;


+ 0
- 1
parser/tensorflow/tensorflow_squeeze_parser.cc View File

@@ -18,7 +18,6 @@
#include <memory>
#include <vector>
#include "framework/common/debug/ge_log.h"
#include "framework/common/op/attr_value_util.h"
#include "common/util.h"
#include "framework/omg/parser/parser_inner_ctx.h"
#include "graph/utils/type_utils.h"


+ 1
- 1
parser/tensorflow/tensorflow_util.cc View File

@@ -20,8 +20,8 @@
#include <iostream>
#include <memory>
#include "common/string_util.h"
#include "common/util.h"
#include "framework/common/debug/ge_log.h"
#include "framework/common/op/ge_op_utils.h"
#include "framework/omg/parser/parser_types.h"
#include "graph/debug/ge_attr_define.h"
#include "graph/ge_tensor.h"


+ 0
- 2
parser/tensorflow/tensorflow_var_is_initialized_op_parser.cc View File

@@ -15,8 +15,6 @@
*/

#include "framework/common/debug/ge_log.h"
//#include "common/util.h"
#include "framework/common/op/ge_op_utils.h"
#include "parser/common/op_def/var_is_initialized_op_op.h"
#include "parser/common/op_parser_factory.h"
#include "parser/tensorflow/tensorflow_op_parser.h"


+ 0
- 1
parser/tensorflow/tensorflow_variable_v2_parser.cc View File

@@ -15,7 +15,6 @@
*/

#include "framework/common/debug/ge_log.h"
#include "framework/common/op/ge_op_utils.h"
#include "graph/compute_graph.h"
#include "graph/ge_attr_value.h"
#include "graph/ge_tensor.h"


Loading…
Cancel
Save