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

Function DelegatePrepare

tensorflow/lite/delegates/gpu/gl_delegate.cc:378–417  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

376}
377
378TfLiteStatus DelegatePrepare(TfLiteContext* context, TfLiteDelegate* delegate) {
379 const TfLiteRegistration kRegistration = {
380 // .init
381 [](TfLiteContext* context, const char* buffer, size_t) -> void* {
382 const auto* params =
383 reinterpret_cast<const TfLiteDelegateParams*>(buffer);
384 auto* gpu_delegate = GetGpuDelegate(params->delegate);
385 // Everything below should happen in prepare function call, but TFLite
386 // for whatever reason forbids that.
387 const auto status = gpu_delegate->Prepare(context, params);
388 if (status.ok()) return gpu_delegate;
389 context->ReportError(context, "TfLiteGpuDelegate Prepare: %s",
390 status.error_message().c_str());
391 return nullptr;
392 },
393 // .free
394 [](TfLiteContext*, void* buffer) -> void {},
395 // .prepare
396 [](TfLiteContext* context, TfLiteNode* node) -> TfLiteStatus {
397 return node->user_data ? kTfLiteOk : kTfLiteError;
398 },
399 // .invoke
400 [](TfLiteContext* context, TfLiteNode* node) -> TfLiteStatus {
401 const auto status = GetGpuDelegate(node)->Invoke(context);
402 if (status.ok()) return kTfLiteOk;
403 context->ReportError(context, "TfLiteGpuDelegate Invoke: %s",
404 status.error_message().c_str());
405 return kTfLiteError;
406 },
407 nullptr, // .profiling_string
408 0, // .builtin_code
409 "TfLiteGpuDelegate", // .custom_name
410 1, // .version
411 };
412 TfLiteIntArray* ops_to_replace = GetOpsToReplace(context);
413 const auto status = context->ReplaceNodeSubsetsWithDelegateKernels(
414 context, kRegistration, ops_to_replace, delegate);
415 TfLiteIntArrayFree(ops_to_replace);
416 return status;
417}
418
419TfLiteStatus DelegateCopyFromBufferHandle(TfLiteContext* context,
420 TfLiteDelegate* delegate,

Callers

nothing calls this directly

Calls 9

GetGpuDelegateFunction · 0.85
GetOpsToReplaceFunction · 0.85
TfLiteIntArrayFreeFunction · 0.85
c_strMethod · 0.80
PrepareMethod · 0.45
okMethod · 0.45
ReportErrorMethod · 0.45
InvokeMethod · 0.45

Tested by

no test coverage detected