TFLM: Make MicroInterpreter multi-tenant constructor taking MicroOpResolver reference instead of pointer to match the behavior of the original constructor.
The Multi-tenant/recording constructor hasn't been widely adopted so this change would be safe. In case it's not, we should update the reference. Otherwise this discrepancy could be misleading. PiperOrigin-RevId: 317039376 Change-Id: I518591faa709a5e386cbc6aa6bf00f539aa498ca
This commit is contained in:
parent
4654b512e7
commit
050c3008e4
@ -159,7 +159,7 @@ TF_LITE_MICRO_TESTS_BEGIN
|
|||||||
TF_LITE_MICRO_TEST(TestKeywordModelMemoryThreshold) {
|
TF_LITE_MICRO_TEST(TestKeywordModelMemoryThreshold) {
|
||||||
tflite::AllOpsResolver all_ops_resolver;
|
tflite::AllOpsResolver all_ops_resolver;
|
||||||
tflite::RecordingMicroInterpreter interpreter(
|
tflite::RecordingMicroInterpreter interpreter(
|
||||||
tflite::GetModel(g_keyword_scrambled_model_data), &all_ops_resolver,
|
tflite::GetModel(g_keyword_scrambled_model_data), all_ops_resolver,
|
||||||
keyword_model_tensor_arena, kKeywordModelTensorArenaSize,
|
keyword_model_tensor_arena, kKeywordModelTensorArenaSize,
|
||||||
micro_test::reporter);
|
micro_test::reporter);
|
||||||
|
|
||||||
@ -185,7 +185,7 @@ TF_LITE_MICRO_TEST(TestKeywordModelMemoryThreshold) {
|
|||||||
TF_LITE_MICRO_TEST(TestConvModelMemoryThreshold) {
|
TF_LITE_MICRO_TEST(TestConvModelMemoryThreshold) {
|
||||||
tflite::AllOpsResolver all_ops_resolver;
|
tflite::AllOpsResolver all_ops_resolver;
|
||||||
tflite::RecordingMicroInterpreter interpreter(
|
tflite::RecordingMicroInterpreter interpreter(
|
||||||
tflite::GetModel(kTestConvModelData), &all_ops_resolver,
|
tflite::GetModel(kTestConvModelData), all_ops_resolver,
|
||||||
test_conv_tensor_arena, kTestConvModelArenaSize, micro_test::reporter);
|
test_conv_tensor_arena, kTestConvModelArenaSize, micro_test::reporter);
|
||||||
|
|
||||||
interpreter.AllocateTensors();
|
interpreter.AllocateTensors();
|
||||||
|
@ -90,12 +90,12 @@ MicroInterpreter::MicroInterpreter(const Model* model,
|
|||||||
}
|
}
|
||||||
|
|
||||||
MicroInterpreter::MicroInterpreter(const Model* model,
|
MicroInterpreter::MicroInterpreter(const Model* model,
|
||||||
const MicroOpResolver* op_resolver,
|
const MicroOpResolver& op_resolver,
|
||||||
MicroAllocator* allocator,
|
MicroAllocator* allocator,
|
||||||
ErrorReporter* error_reporter,
|
ErrorReporter* error_reporter,
|
||||||
tflite::Profiler* profiler)
|
tflite::Profiler* profiler)
|
||||||
: model_(model),
|
: model_(model),
|
||||||
op_resolver_(*op_resolver),
|
op_resolver_(op_resolver),
|
||||||
error_reporter_(error_reporter),
|
error_reporter_(error_reporter),
|
||||||
allocator_(*allocator),
|
allocator_(*allocator),
|
||||||
tensors_allocated_(false),
|
tensors_allocated_(false),
|
||||||
|
@ -82,7 +82,7 @@ class MicroInterpreter {
|
|||||||
// have allocation handled in more than one interpreter or for recording
|
// have allocation handled in more than one interpreter or for recording
|
||||||
// allocations inside the interpreter. The lifetime of the allocator must be
|
// allocations inside the interpreter. The lifetime of the allocator must be
|
||||||
// as long as that of the interpreter object.
|
// as long as that of the interpreter object.
|
||||||
MicroInterpreter(const Model* model, const MicroOpResolver* op_resolver,
|
MicroInterpreter(const Model* model, const MicroOpResolver& op_resolver,
|
||||||
MicroAllocator* allocator, ErrorReporter* error_reporter,
|
MicroAllocator* allocator, ErrorReporter* error_reporter,
|
||||||
tflite::Profiler* profiler = nullptr);
|
tflite::Profiler* profiler = nullptr);
|
||||||
|
|
||||||
|
@ -292,7 +292,7 @@ TF_LITE_MICRO_TEST(TestIncompleteInitializationAllocationsWithSmallArena) {
|
|||||||
allocator_buffer, allocator_buffer_size, micro_test::reporter);
|
allocator_buffer, allocator_buffer_size, micro_test::reporter);
|
||||||
TF_LITE_MICRO_EXPECT_NE(nullptr, allocator);
|
TF_LITE_MICRO_EXPECT_NE(nullptr, allocator);
|
||||||
|
|
||||||
tflite::MicroInterpreter interpreter(model, &mock_resolver, allocator,
|
tflite::MicroInterpreter interpreter(model, mock_resolver, allocator,
|
||||||
micro_test::reporter);
|
micro_test::reporter);
|
||||||
|
|
||||||
// Interpreter fails because arena is too small:
|
// Interpreter fails because arena is too small:
|
||||||
@ -337,7 +337,7 @@ TF_LITE_MICRO_TEST(TestInterpreterDoesNotAllocateUntilInvoke) {
|
|||||||
allocator_buffer, allocator_buffer_size, micro_test::reporter);
|
allocator_buffer, allocator_buffer_size, micro_test::reporter);
|
||||||
TF_LITE_MICRO_EXPECT_NE(nullptr, allocator);
|
TF_LITE_MICRO_EXPECT_NE(nullptr, allocator);
|
||||||
|
|
||||||
tflite::MicroInterpreter interpreter(model, &mock_resolver, allocator,
|
tflite::MicroInterpreter interpreter(model, mock_resolver, allocator,
|
||||||
micro_test::reporter);
|
micro_test::reporter);
|
||||||
|
|
||||||
// Ensure allocations are zero (ignore tail since some internal structs are
|
// Ensure allocations are zero (ignore tail since some internal structs are
|
||||||
|
@ -35,7 +35,7 @@ namespace tflite {
|
|||||||
class RecordingMicroInterpreter : public MicroInterpreter {
|
class RecordingMicroInterpreter : public MicroInterpreter {
|
||||||
public:
|
public:
|
||||||
RecordingMicroInterpreter(const Model* model,
|
RecordingMicroInterpreter(const Model* model,
|
||||||
const MicroOpResolver* op_resolver,
|
const MicroOpResolver& op_resolver,
|
||||||
uint8_t* tensor_arena, size_t tensor_arena_size,
|
uint8_t* tensor_arena, size_t tensor_arena_size,
|
||||||
ErrorReporter* error_reporter)
|
ErrorReporter* error_reporter)
|
||||||
: MicroInterpreter(model, op_resolver,
|
: MicroInterpreter(model, op_resolver,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user