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

Function Prepare

tensorflow/lite/kernels/reverse.cc:32–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30constexpr int kOutputTensor = 0;
31
32TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {
33 TF_LITE_ENSURE_EQ(context, NumInputs(node), 2);
34 TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);
35
36 const TfLiteTensor* input = GetInput(context, node, kInputTensor);
37 const TfLiteTensor* axis = GetInput(context, node, kAxisTensor);
38 TF_LITE_ENSURE_EQ(context, NumDimensions(axis), 1);
39 TF_LITE_ENSURE(context, NumDimensions(input) >= NumElements(axis));
40
41 if (input->type != kTfLiteInt32 && input->type != kTfLiteFloat32 &&
42 input->type != kTfLiteUInt8 && input->type != kTfLiteInt16 &&
43 input->type != kTfLiteInt64) {
44 context->ReportError(context, "Type '%s' is not supported by reverse.",
45 TfLiteTypeGetName(input->type));
46 return kTfLiteError;
47 }
48
49 if (axis->type != kTfLiteInt32) {
50 context->ReportError(context, "Axis Type '%s' is not supported by reverse.",
51 TfLiteTypeGetName(axis->type));
52 return kTfLiteError;
53 }
54
55 // TODO(renjieliu): support multi-axis case.
56 if (NumElements(axis) > 1) {
57 context->ReportError(context, "Current does not support more than 1 axis.");
58 }
59
60 TfLiteTensor* output = GetOutput(context, node, kOutputTensor);
61 TfLiteIntArray* output_shape = TfLiteIntArrayCopy(input->dims);
62 TF_LITE_ENSURE_EQ(context, output->type, input->type);
63
64 return context->ResizeTensor(context, output, output_shape);
65}
66
67TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
68 const TfLiteTensor* input = GetInput(context, node, kInputTensor);

Callers

nothing calls this directly

Calls 10

NumInputsFunction · 0.85
GetInputFunction · 0.85
NumDimensionsFunction · 0.85
TfLiteTypeGetNameFunction · 0.85
GetOutputFunction · 0.85
TfLiteIntArrayCopyFunction · 0.85
ResizeTensorMethod · 0.80
NumOutputsFunction · 0.70
NumElementsFunction · 0.70
ReportErrorMethod · 0.45

Tested by

no test coverage detected