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

Function Prepare

tensorflow/lite/kernels/range.cc:76–110  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74}
75
76TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {
77 TF_LITE_ENSURE_EQ(context, NumInputs(node), 3);
78 TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);
79
80 const TfLiteTensor* start = GetInput(context, node, kStartTensor);
81 const TfLiteTensor* limit = GetInput(context, node, kLimitTensor);
82 const TfLiteTensor* delta = GetInput(context, node, kDeltaTensor);
83 // Make sure all the inputs are scalars.
84 TF_LITE_ENSURE_EQ(context, NumDimensions(start), 0);
85 TF_LITE_ENSURE_EQ(context, NumDimensions(limit), 0);
86 TF_LITE_ENSURE_EQ(context, NumDimensions(delta), 0);
87
88 // Currently only supports int32 and float.
89 // TODO(b/117912892): Support quantization as well.
90 const auto dtype = start->type;
91 if (dtype != kTfLiteFloat32 && dtype != kTfLiteInt32) {
92 context->ReportError(context, "Unknown index output data type: %s",
93 TfLiteTypeGetName(dtype));
94 return kTfLiteError;
95 }
96
97 TF_LITE_ENSURE_EQ(context, limit->type, dtype);
98 TF_LITE_ENSURE_EQ(context, delta->type, dtype);
99
100 TfLiteTensor* output = GetOutput(context, node, kOutputTensor);
101 output->type = dtype;
102
103 if (IsConstantTensor(start) && IsConstantTensor(limit) &&
104 IsConstantTensor(delta)) {
105 return ResizeOutput(context, start, limit, delta, output);
106 }
107
108 SetTensorToDynamic(output);
109 return kTfLiteOk;
110}
111
112template <typename T>
113void EvalImpl(const TfLiteTensor* start, const TfLiteTensor* delta,

Callers

nothing calls this directly

Calls 10

NumInputsFunction · 0.85
GetInputFunction · 0.85
NumDimensionsFunction · 0.85
TfLiteTypeGetNameFunction · 0.85
GetOutputFunction · 0.85
SetTensorToDynamicFunction · 0.85
NumOutputsFunction · 0.70
IsConstantTensorFunction · 0.70
ResizeOutputFunction · 0.70
ReportErrorMethod · 0.45

Tested by

no test coverage detected