MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / Init

Method Init

tensorflow/core/kernels/hexagon/hexagon_control_wrapper.cc:74–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72}
73
74bool HexagonControlWrapper::Init(const RemoteFusedGraphExecuteInfo& info) {
75 soc_interface_SetLogLevel(DBG_LEVEL);
76 if (DBG_USE_SAMPLE_INPUT) {
77 soc_interface_SetDebugFlag(FLAG_ENABLE_PANDA_BINARY_INPUT);
78 }
79 if (info.serialized_executor_parameters().empty()) {
80 std::vector<std::pair<string, Tensor>> inputs;
81 std::vector<string> outputs;
82 RemoteFusedGraphExecuteUtils::BuildRemoteGraphInputsAndOutputsFromProto(
83 info, &inputs, &outputs);
84 Status status = graph_transferer_.LoadGraphFromProto(
85 HexagonOpsDefinitions::getInstance(), info.remote_graph(), inputs,
86 outputs,
87 false // shape_inference_for_unknown_shape
88 );
89 TF_CHECK_OK(status) << status;
90 } else {
91 // If graph transfer info is attached, just import it.
92 graph_transferer_.SetSerializedGraphTransferInfo(
93 info.serialized_executor_parameters());
94 }
95 execute_info_ = &info;
96 bool success = soc_interface_Init();
97 if (!success) {
98 LOG(ERROR) << "Hexagon initialization was failed. See log output.";
99 return false;
100 }
101 std::vector<int> input_sizes;
102 std::vector<int> output_sizes;
103 CHECK_NOTNULL(execute_info_);
104 for (int i = 0; i < execute_info_->graph_input_node_name_size(); ++i) {
105 const string& input = execute_info_->graph_input_node_name(i);
106 LOG(INFO) << "Add input: " << input << ", " << i;
107 CHECK(input_port_map_.emplace(AddPort(input), i).second);
108 const RemoteFusedGraphExecuteInfo::TensorShapeTypeProto& shape_type =
109 execute_info_->default_graph_input_tensor_shape(i);
110 int64 buf_size = DataTypeSize(shape_type.dtype());
111 for (const TensorShapeProto::Dim& dim : shape_type.shape().dim()) {
112 buf_size *= dim.size();
113 }
114 input_sizes.emplace_back(static_cast<int>(buf_size));
115 }
116 for (int i = 0; i < execute_info_->graph_output_node_name_size(); ++i) {
117 const string& output = execute_info_->graph_output_node_name(i);
118 CHECK(output_port_map_.emplace(AddPort(output), i).second);
119 const RemoteFusedGraphExecuteInfo::TensorShapeTypeProto& shape_type =
120 execute_info_->default_graph_output_tensor_shape(i);
121
122 int64 buf_size = DataTypeSize(shape_type.dtype());
123 for (const TensorShapeProto::Dim& dim : shape_type.shape().dim()) {
124 buf_size *= dim.size();
125 }
126 output_sizes.emplace_back(static_cast<int>(buf_size));
127 }
128
129 LOG(INFO) << "Allocate inout buffer";
130 success &= soc_interface_AllocateInOutNodeBuffers(
131 input_sizes.size(), input_sizes.data(), output_sizes.size(),

Callers 1

Calls 15

AddPortFunction · 0.85
DataTypeSizeFunction · 0.85
LoadGraphFromProtoMethod · 0.80
soc_interface_InitFunction · 0.70
emptyMethod · 0.45
emplaceMethod · 0.45
dtypeMethod · 0.45
dimMethod · 0.45

Tested by 1