diff --git a/parser/caffe/caffe_custom_parser_adapter.cc b/parser/caffe/caffe_custom_parser_adapter.cc index 8b18553..d250f38 100644 --- a/parser/caffe/caffe_custom_parser_adapter.cc +++ b/parser/caffe/caffe_custom_parser_adapter.cc @@ -83,7 +83,7 @@ Status CaffeCustomParserAdapter::ParseWeights(const Message *op_src, ge::NodePtr } bool bias_en = false; - bool update_in_turn = (static_cast(op->GetAllInputsSize()) == (layer->bottom_size() + layer->blobs_size())); + bool update_in_turn = (static_cast(op->GetAllInputsSize()) == (layer->bottom_size() + layer->blobs_size())); int start_pos = layer->bottom_size(); for (int i = 0; i < layer->blobs_size(); ++i) { ge::GeTensorPtr weight = ge::parser::MakeShared(); diff --git a/parser/common/proto/tensorflow/graph_library.proto b/parser/common/proto/tensorflow/graph_library.proto new file mode 100644 index 0000000..e393d38 --- /dev/null +++ b/parser/common/proto/tensorflow/graph_library.proto @@ -0,0 +1,14 @@ +syntax = "proto3"; + +package domi.tensorflow; + +import "graph.proto"; + +message GeGraphDef { + string name = 1; + GraphDef graph = 2; +} + +message GraphDefLibrary { + repeated GeGraphDef graph_def = 1; +}; \ No newline at end of file diff --git a/parser/ops/op_imp.cpp b/parser/ops/op_imp.cpp deleted file mode 100644 index 4f8e1de..0000000 --- a/parser/ops/op_imp.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include -#include -#include -#include "debug/ge_log.h" -#include "debug/ge_util.h" - -using namespace std; - -namespace ge { - -GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY graphStatus -BroadCastInfer(const function()>& get_in1_shape, const function()>& get_in2_shape, - const function& outShape)>& set_out_shape) { - auto x1_shape = get_in1_shape(); - auto x2_shape = get_in2_shape(); - vector y_shape; - - if (x1_shape.empty()) { - y_shape = x2_shape; - set_out_shape(y_shape); - return GRAPH_SUCCESS; - } - if (x2_shape.empty()) { - y_shape = x1_shape; - set_out_shape(y_shape); - return GRAPH_SUCCESS; - } - - int len_diff = static_cast(x1_shape.size() - x2_shape.size()); - if (len_diff >= 0) { - for (int i = 0; i < len_diff; i++) { - y_shape.push_back(x1_shape[i]); - } - int x2_shape_size = static_cast(x2_shape.size()); - for (int i = 0; i < x2_shape_size; i++) { - bool shapeFlag = - ((x1_shape[i + len_diff] != x2_shape[i]) && (std::min(x1_shape[i + len_diff], x2_shape[i]) != 1)); - if (shapeFlag) { - GE_LOGE("operands could not be broadcast together"); - return GRAPH_FAILED; - } - y_shape.push_back(std::max(x1_shape[i + len_diff], x2_shape[i])); - } - } else { - for (int i = 0; i < -len_diff; i++) { - y_shape.push_back(x2_shape[i]); - } - int x1_shape_size = static_cast(x1_shape.size()); - for (int i = 0; i < x1_shape_size; i++) { - bool shapeFlag = - ((x1_shape[i] != x2_shape[i - len_diff]) && (std::min(x1_shape[i], x2_shape[i - len_diff]) != 1)); - if (shapeFlag) { - GE_LOGE("operands could not be broadcast together"); - return GRAPH_FAILED; - } - y_shape.push_back(std::max(x1_shape[i], x2_shape[i - len_diff])); - } - } - set_out_shape(y_shape); - return GRAPH_SUCCESS; -} - -} // namespace ge diff --git a/parser/stub/Makefile b/parser/stub/Makefile index 520b292..51b4651 100644 --- a/parser/stub/Makefile +++ b/parser/stub/Makefile @@ -1,6 +1,6 @@ -inc_path := $(shell pwd)/inc/external/ -out_path := $(shell pwd)/out/graph/lib64/stub/ -stub_path := $(shell pwd)/common/graph/stub/ +inc_path := $(shell pwd)/parser/inc/external/ +out_path := $(shell pwd)/out/parser/lib64/stub/ +stub_path := $(shell pwd)/parser/parser/stub/ mkdir_stub := $(shell mkdir -p $(out_path)) -graph_local_stub := $(shell $(HI_PYTHON) $(stub_path)/gen_stubapi.py $(inc_path) $(out_path)) +local_stub := $(shell $(HI_PYTHON) $(stub_path)/gen_stubapi.py $(inc_path) $(out_path)) diff --git a/parser/stub/README b/parser/stub/README new file mode 100644 index 0000000..ca98ce8 --- /dev/null +++ b/parser/stub/README @@ -0,0 +1,4 @@ +################################################################################### +the directory (stub) saves the stub file +gen_stubapi.py is using for retrieving API and generating stub functions +################################################################################### diff --git a/parser/stub/README.md b/parser/stub/README.md new file mode 100644 index 0000000..a085e53 --- /dev/null +++ b/parser/stub/README.md @@ -0,0 +1,44 @@ +# "stub" usage: + +## Description + +- File libge_compiler.so ,libgraph.so are used in IR build application interface. + +# Attention + +- Don't link other library except libge_compiler.so ,libgraph.so, as they may be changed in the future. + +# Usage + +## Compile: compile the application invoking the IR build API. + +Makefile: + +''' + +ATC_INCLUDE_DIR := $(ASCEND_PATH)/atc/include +OPP_INCLUDE_DIR := $(ASCEND_PATH)/opp/op_proto/built-in/inc +LOCAL_MODULE_NAME := ir_build +CC := g++ +CFLAGS := -std=c++11 -g -Wall +SRCS := $(wildcard $(LOCAL_DIR)/main.cpp) +INCLUDES := -I $(ASCEND_OPP_PATH)/op_proto/built-in/inc \ + -I $(ATC_INCLUDE_DIR)/graph \ + -I $(ATC_INCLUDE_DIR)/ge \ + +LIBS := -L ${ASCEND_PATH}/atc/lib64/stub \ + -lgraph \ + -lge_compiler +ir_build: + mkdir -p out + $(CC) $(SRCS) $(INCLUDES) $(LIBS) $(CFLAGS) -o ./out/$(LOCAL_MODULE_NAME) +clean: + rm -rf out + +''' +make + +## Run the application after set the LD_LIBRARY_PATH to include the real path of the library which locates in the directory of atc/lib64 + +export LD_LIBRARY_PATH= $(ASCEND_PATH)/atc/lib64 + - ./ ir_build diff --git a/parser/stub/gen_stubapi.py b/parser/stub/gen_stubapi.py index 3e2c51c..0c5e712 100644 --- a/parser/stub/gen_stubapi.py +++ b/parser/stub/gen_stubapi.py @@ -63,8 +63,9 @@ max_code_len_per_line = 100 determines which header files to generate cc files from when DEBUG on """ -white_list_for_debug = ["tensorflow_parser.h", "caffe_parser.h"] -include_dir_key_words = ["parser"] +white_list_for_debug = ["attr_value.h", "operator.h", "tensor.h", "graph.h", "operator_factory.h", + "ge_ir_build.h", "ge_api.h", "ge_prof.h", "tensorflow_parser.h", "caffe_parser.h"] +include_dir_key_words = ["ge", "graph", "parser"] DEBUG = True @@ -101,7 +102,7 @@ pattern_func = re.compile(r"""(^[\s]*) #leading with space,we will find ([a-zA-Z~_] # void int likely .* [)] #we find ) -(?!.*{) # we do not want the case int abc() const +(?!.*{) # we do not want the case int abc() const { return 1;} .*) (;.*) #we want to find ; and after for we will replace these later \n$