Browse Source

sync from yellow zone from 20201020

pull/23/head
taoxiangdong 5 years ago
parent
commit
319217cd97
7 changed files with 71 additions and 71 deletions
  1. +1
    -1
      parser/caffe/caffe_custom_parser_adapter.cc
  2. +14
    -0
      parser/common/proto/tensorflow/graph_library.proto
  3. +0
    -63
      parser/ops/op_imp.cpp
  4. +4
    -4
      parser/stub/Makefile
  5. +4
    -0
      parser/stub/README
  6. +44
    -0
      parser/stub/README.md
  7. +4
    -3
      parser/stub/gen_stubapi.py

+ 1
- 1
parser/caffe/caffe_custom_parser_adapter.cc View File

@@ -83,7 +83,7 @@ Status CaffeCustomParserAdapter::ParseWeights(const Message *op_src, ge::NodePtr
}

bool bias_en = false;
bool update_in_turn = (static_cast<int64_t>(op->GetAllInputsSize()) == (layer->bottom_size() + layer->blobs_size()));
bool update_in_turn = (static_cast<int64_t >(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<ge::GeTensor>();


+ 14
- 0
parser/common/proto/tensorflow/graph_library.proto View File

@@ -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;
};

+ 0
- 63
parser/ops/op_imp.cpp View File

@@ -1,63 +0,0 @@
#include <stdint.h>
#include <functional>
#include <vector>
#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<vector<int64_t>()>& get_in1_shape, const function<vector<int64_t>()>& get_in2_shape,
const function<void(const vector<int64_t>& outShape)>& set_out_shape) {
auto x1_shape = get_in1_shape();
auto x2_shape = get_in2_shape();
vector<int64_t> 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<int>(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<int>(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<int>(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

+ 4
- 4
parser/stub/Makefile View File

@@ -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))

+ 4
- 0
parser/stub/README View File

@@ -0,0 +1,4 @@
###################################################################################
the directory (stub) saves the stub file
gen_stubapi.py is using for retrieving API and generating stub functions
###################################################################################

+ 44
- 0
parser/stub/README.md View File

@@ -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

+ 4
- 3
parser/stub/gen_stubapi.py View File

@@ -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$


Loading…
Cancel
Save