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

Function BuildModel

tensorflow/lite/delegates/gpu/common/model_builder.cc:2424–2466  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2422}
2423
2424Status BuildModel(TfLiteContext* context,
2425 const TfLiteDelegateParams* delegate_params,
2426 GraphFloat32* graph) {
2427 std::vector<std::unique_ptr<TFLiteOperationParser>> operations;
2428 std::vector<int> tflite_nodes;
2429 for (int i = 0; i < delegate_params->nodes_to_replace->size; ++i) {
2430 TfLiteNode* tflite_node = nullptr;
2431 TfLiteRegistration* registration = nullptr;
2432 RETURN_IF_ERROR(GetNodeAndRegistration(
2433 context, delegate_params->nodes_to_replace->data[i], &tflite_node,
2434 &registration));
2435 if (registration->builtin_code == kTfLiteBuiltinDequantize) {
2436 // Ignore Dequantize nodes.
2437 continue;
2438 }
2439 auto op_parser = NewOperationParser(registration);
2440 if (!op_parser) {
2441 return UnimplementedError(
2442 absl::StrCat("Operation ", registration->builtin_code, "(",
2443 registration->custom_name,
2444 ") is not supported by TFLite GPU Delegate."));
2445 }
2446 operations.push_back(std::move(op_parser));
2447 tflite_nodes.push_back(i);
2448 }
2449 std::vector<Value<TensorRef<BHWC>>*> tensor_to_value(context->tensors_size,
2450 nullptr);
2451 for (int i = 0; i < operations.size(); ++i) {
2452 TfLiteNode* tflite_node;
2453 TfLiteRegistration* registration;
2454 RETURN_IF_ERROR(GetNodeAndRegistration(
2455 context, delegate_params->nodes_to_replace->data[tflite_nodes[i]],
2456 &tflite_node, &registration));
2457 ObjectReader reader(graph, context, tflite_node, &tensor_to_value);
2458 const auto status =
2459 operations[i]->Parse(tflite_node, registration, graph, &reader);
2460 if (!status.ok()) {
2461 return InternalError(absl::StrCat(GetOpNameByRegistration(registration),
2462 ": ", status.error_message()));
2463 }
2464 }
2465 return OkStatus();
2466}
2467
2468} // namespace gpu
2469} // namespace tflite

Callers 2

PrepareMethod · 0.85
PrepareMethod · 0.85

Calls 11

GetNodeAndRegistrationFunction · 0.85
NewOperationParserFunction · 0.85
GetOpNameByRegistrationFunction · 0.85
OkStatusFunction · 0.85
UnimplementedErrorFunction · 0.70
InternalErrorFunction · 0.70
StrCatFunction · 0.50
push_backMethod · 0.45
sizeMethod · 0.45
ParseMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected