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

Function FeedExample

tensorflow/lite/testing/parse_testdata.cc:151–184  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

149}
150
151TfLiteStatus FeedExample(tflite::Interpreter* interpreter,
152 const Example& example) {
153 // Resize inputs to match example & allocate.
154 for (size_t i = 0; i < interpreter->inputs().size(); i++) {
155 int input_index = interpreter->inputs()[i];
156
157 TF_LITE_ENSURE_STATUS(
158 interpreter->ResizeInputTensor(input_index, example.inputs[i].shape));
159 }
160 TF_LITE_ENSURE_STATUS(interpreter->AllocateTensors());
161 // Copy data into tensors.
162 for (size_t i = 0; i < interpreter->inputs().size(); i++) {
163 int input_index = interpreter->inputs()[i];
164 if (float* data = interpreter->typed_tensor<float>(input_index)) {
165 for (size_t idx = 0; idx < example.inputs[i].flat_data.size(); idx++) {
166 data[idx] = example.inputs[i].flat_data[idx];
167 }
168 } else if (int32_t* data =
169 interpreter->typed_tensor<int32_t>(input_index)) {
170 for (size_t idx = 0; idx < example.inputs[i].flat_data.size(); idx++) {
171 data[idx] = example.inputs[i].flat_data[idx];
172 }
173 } else if (int64_t* data =
174 interpreter->typed_tensor<int64_t>(input_index)) {
175 for (size_t idx = 0; idx < example.inputs[i].flat_data.size(); idx++) {
176 data[idx] = example.inputs[i].flat_data[idx];
177 }
178 } else {
179 fprintf(stderr, "input[%zu] was not float or int data\n", i);
180 return kTfLiteError;
181 }
182 }
183 return kTfLiteOk;
184}
185
186TfLiteStatus CheckOutputs(tflite::Interpreter* interpreter,
187 const Example& example) {

Callers

nothing calls this directly

Calls 4

sizeMethod · 0.45
inputsMethod · 0.45
ResizeInputTensorMethod · 0.45
AllocateTensorsMethod · 0.45

Tested by

no test coverage detected