Skip to content

Commit f303cc6

Browse files
Kernel Util component file list
1 parent bf10cec commit f303cc6

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#include "tensorflow/lite/micro/micro_mutable_op_resolver.h"
2+
#include "tensorflow/lite/micro/tflite_bridge/micro_error_reporter.h"
3+
#include "tensorflow/lite/micro/micro_interpreter.h"
4+
#include "tensorflow/lite/schema/schema_generated.h"
5+
6+
// Include your model data. Replace this with the header file for your model.
7+
#include "model.h"
8+
9+
// Define the number of elements in the input tensor
10+
#define INPUT_SIZE 300*300
11+
12+
using MyOpResolver = tflite::MicroMutableOpResolver<10>;
13+
14+
// Replace this with your model's input and output tensor sizes
15+
const int tensor_arena_size = 2 * 1024;
16+
uint8_t tensor_arena[tensor_arena_size] __align(16);
17+
18+
void RunModel(int8_t* input_data) {
19+
tflite::MicroErrorReporter micro_error_reporter;
20+
tflite::ErrorReporter* error_reporter = &micro_error_reporter;
21+
22+
const tflite::Model* model = ::tflite::GetModel(g_model);
23+
24+
MyOpResolver op_resolver;
25+
// Register your model's operations here
26+
27+
tflite::MicroInterpreter interpreter(model, op_resolver, tensor_arena,
28+
tensor_arena_size, error_reporter);
29+
30+
interpreter.AllocateTensors();
31+
32+
TfLiteTensor* input = interpreter.input(0);
33+
// Add checks for input tensor properties here if needed
34+
35+
// Copy image data to model's input tensor
36+
for (int i = 0; i < INPUT_SIZE; ++i) {
37+
input->data.int8[i] = input_data[i];
38+
}
39+
40+
TfLiteStatus invoke_status = interpreter.Invoke();
41+
// Add checks for successful inference here if needed
42+
43+
TfLiteTensor* output = interpreter.output(0);
44+
// Add checks for output tensor properties here if needed
45+
46+
// Process your output value here
47+
// For example, SSD models typically produce an array of bounding boxes
48+
}

tensorflow-build/kernelutil.lst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tensorflow/lite/micro/recording_micro_allocator.cpp

0 commit comments

Comments
 (0)