Skip to content

Commit

Permalink
Kernel Util component file list
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthiasHertel80 committed May 7, 2024
1 parent bf10cec commit f303cc6
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
48 changes: 48 additions & 0 deletions tensorflow-build/add/templates/tflite_main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#include "tensorflow/lite/micro/micro_mutable_op_resolver.h"
#include "tensorflow/lite/micro/tflite_bridge/micro_error_reporter.h"
#include "tensorflow/lite/micro/micro_interpreter.h"
#include "tensorflow/lite/schema/schema_generated.h"

// Include your model data. Replace this with the header file for your model.
#include "model.h"

// Define the number of elements in the input tensor
#define INPUT_SIZE 300*300

using MyOpResolver = tflite::MicroMutableOpResolver<10>;

// Replace this with your model's input and output tensor sizes
const int tensor_arena_size = 2 * 1024;
uint8_t tensor_arena[tensor_arena_size] __align(16);

void RunModel(int8_t* input_data) {
tflite::MicroErrorReporter micro_error_reporter;
tflite::ErrorReporter* error_reporter = &micro_error_reporter;

const tflite::Model* model = ::tflite::GetModel(g_model);

MyOpResolver op_resolver;
// Register your model's operations here

tflite::MicroInterpreter interpreter(model, op_resolver, tensor_arena,
tensor_arena_size, error_reporter);

interpreter.AllocateTensors();

TfLiteTensor* input = interpreter.input(0);
// Add checks for input tensor properties here if needed

// Copy image data to model's input tensor
for (int i = 0; i < INPUT_SIZE; ++i) {
input->data.int8[i] = input_data[i];
}

TfLiteStatus invoke_status = interpreter.Invoke();
// Add checks for successful inference here if needed

TfLiteTensor* output = interpreter.output(0);
// Add checks for output tensor properties here if needed

// Process your output value here
// For example, SSD models typically produce an array of bounding boxes
}
1 change: 1 addition & 0 deletions tensorflow-build/kernelutil.lst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tensorflow/lite/micro/recording_micro_allocator.cpp

0 comments on commit f303cc6

Please sign in to comment.