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

Function Eval

tensorflow/lite/kernels/strided_slice.cc:179–251  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177
178template <KernelType kernel_type>
179TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
180 StridedSliceContext op_context(context, node);
181
182 if (IsDynamicTensor(op_context.output)) {
183 TF_LITE_ENSURE_OK(context, ResizeOutputTensor(context, &op_context));
184 }
185
186 std::vector<int32_t> starts;
187 std::vector<int32_t> stops;
188 std::vector<int32_t> strides;
189
190 for (int i = op_context.dims; i < kMaxDim; i++) {
191 starts.emplace_back(0);
192 stops.emplace_back(1);
193 strides.emplace_back(1);
194 }
195
196 for (int idx = 0; idx < op_context.dims; ++idx) {
197 starts.emplace_back(GetTensorData<int32_t>(op_context.begin)[idx]);
198 stops.emplace_back(GetTensorData<int32_t>(op_context.end)[idx]);
199 strides.emplace_back(GetTensorData<int32_t>(op_context.strides)[idx]);
200 }
201
202 int begin_mask = op_context.params->begin_mask << (4 - op_context.dims);
203 int end_mask = op_context.params->end_mask << (4 - op_context.dims);
204 int shrink_axis_mask = op_context.params->shrink_axis_mask
205 << (4 - op_context.dims);
206 TF_LITE_ENSURE_EQ(context, starts.size(), 4);
207 auto op_params = ::tflite::strided_slice::BuildStridedSliceParams(
208 begin_mask, end_mask, shrink_axis_mask, starts, stops, strides);
209
210#define TF_LITE_STRIDED_SLICE(kernel_type, data_type) \
211 kernel_type::StridedSlice(op_params, GetTensorShape(op_context.input), \
212 GetTensorData<data_type>(op_context.input), \
213 GetTensorShape(op_context.output), \
214 GetTensorData<data_type>(op_context.output))
215
216 switch (op_context.input->type) {
217 case kTfLiteFloat32:
218 if (kernel_type == kReference) {
219 TF_LITE_STRIDED_SLICE(reference_ops, float);
220 }
221 break;
222 case kTfLiteInt32:
223 if (kernel_type == kReference) {
224 TF_LITE_STRIDED_SLICE(reference_ops, int32_t);
225 }
226 break;
227 case kTfLiteInt64:
228 if (kernel_type == kReference) {
229 TF_LITE_STRIDED_SLICE(reference_ops, int64_t);
230 }
231 break;
232 case kTfLiteUInt8:
233 if (kernel_type == kReference) {
234 TF_LITE_STRIDED_SLICE(reference_ops, uint8_t);
235 }
236 break;

Callers

nothing calls this directly

Calls 6

IsDynamicTensorFunction · 0.85
ResizeOutputTensorFunction · 0.70
BuildStridedSliceParamsFunction · 0.50
emplace_backMethod · 0.45
sizeMethod · 0.45
ReportErrorMethod · 0.45

Tested by

no test coverage detected