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

Method ConvertOperations

tensorflow/lite/delegates/gpu/cl/inference_context.cc:181–218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

179}
180
181Status InferenceContext::ConvertOperations(
182 const CreationContext& creation_context, const GraphFloat32& graph,
183 ModelHints hints) {
184 std::vector<Node*> graph_nodes = graph.nodes();
185 for (int i = 0; i < graph_nodes.size(); ++i) {
186 const Node& node = *graph_nodes[i];
187 auto inputs = graph.FindInputs(node.id);
188 auto outputs = graph.FindOutputs(node.id);
189 OperationDef op_def;
190 op_def.precision = precision_;
191 auto data_type = DeduceDataTypeFromPrecision(precision_);
192 for (int j = 0; j < inputs.size(); ++j) {
193 op_def.src_tensors.push_back({data_type, storage_type_});
194 }
195 for (int j = 0; j < outputs.size(); ++j) {
196 op_def.dst_tensors.push_back({data_type, storage_type_});
197 }
198 std::unique_ptr<GPUOperation> gpu_op;
199 RETURN_IF_ERROR(GPUOperationFromNode(creation_context, op_def, hints, graph,
200 node, &gpu_op));
201 CLNode cl_node;
202 cl_node.operations.push_back(std::move(gpu_op));
203 cl_node.ranges.push_back(int2(0, static_cast<int>(inputs.size())));
204 cl_node.inputs.resize(inputs.size());
205 for (int j = 0; j < inputs.size(); ++j) {
206 cl_node.inputs[j] = inputs[j]->id;
207 }
208 cl_node.outputs.resize(outputs.size());
209 for (int j = 0; j < outputs.size(); ++j) {
210 cl_node.outputs[j] = outputs[j]->id;
211 }
212 cl_node.name = node.operation.type + " " + std::to_string(node.id) + " " +
213 std::to_string(i);
214 nodes_.push_back(std::move(cl_node));
215 }
216
217 return OkStatus();
218}
219
220void InferenceContext::Merge() {
221 std::unordered_set<ValueId> ready_tensors;

Callers

nothing calls this directly

Calls 10

GPUOperationFromNodeFunction · 0.85
to_stringFunction · 0.85
OkStatusFunction · 0.85
FindInputsMethod · 0.80
FindOutputsMethod · 0.80
nodesMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected