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

Function Eval

tensorflow/lite/kernels/read_variable.cc:50–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48}
49
50TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
51 Subgraph* subgraph = reinterpret_cast<Subgraph*>(context->impl_);
52
53 const TfLiteTensor* input_variable_id_tensor =
54 GetInput(context, node, kInputVariableId);
55 int variable_id = input_variable_id_tensor->data.i32[0];
56 auto& resource_variables = subgraph->resource_variables();
57
58 const auto& variable_iterator = resource_variables.find(variable_id);
59 if (variable_iterator == resource_variables.end()) {
60 context->ReportError(context, "Variable ID %d is read before initialized.",
61 variable_id);
62 return kTfLiteError;
63 }
64 auto& variable = variable_iterator->second;
65
66 TfLiteTensor* variable_tensor = variable.GetTensor();
67 TfLiteTensor* output = GetOutput(context, node, kOutputValue);
68
69 TF_LITE_ENSURE_EQ(context, variable_tensor->type, output->type);
70 TF_LITE_ENSURE_OK(
71 context, context->ResizeTensor(
72 context, output, TfLiteIntArrayCopy(variable_tensor->dims)));
73 memcpy(output->data.raw, variable_tensor->data.raw, output->bytes);
74
75 return kTfLiteOk;
76}
77
78} // namespace read_variable
79

Callers

nothing calls this directly

Calls 8

GetInputFunction · 0.85
GetOutputFunction · 0.85
TfLiteIntArrayCopyFunction · 0.85
ResizeTensorMethod · 0.80
findMethod · 0.45
endMethod · 0.45
ReportErrorMethod · 0.45
GetTensorMethod · 0.45

Tested by

no test coverage detected