Updated comments and tested benchmarks with TAGS=posix
diff --git a/tensorflow/lite/micro/all_ops_resolver.h b/tensorflow/lite/micro/all_ops_resolver.h
index e8105b9..f39c24e 100644
--- a/tensorflow/lite/micro/all_ops_resolver.h
+++ b/tensorflow/lite/micro/all_ops_resolver.h
@@ -26,7 +26,6 @@
public:
AllOpsResolver();
- private:
TF_LITE_REMOVE_VIRTUAL_DELETE
};
diff --git a/tensorflow/lite/micro/benchmarks/person_detection_benchmark.cc b/tensorflow/lite/micro/benchmarks/person_detection_benchmark.cc
index ad5e2c3..687440a 100644
--- a/tensorflow/lite/micro/benchmarks/person_detection_benchmark.cc
+++ b/tensorflow/lite/micro/benchmarks/person_detection_benchmark.cc
@@ -34,6 +34,7 @@
namespace {
+using PersonDetectionOpResolver = tflite::AllOpsResolver;
using PersonDetectionBenchmarkRunner = MicroBenchmarkRunner<uint8_t>;
constexpr int kRandomSeed = 42;
@@ -43,18 +44,22 @@
constexpr int kTensorArenaSize = 95 * 1024;
alignas(16) uint8_t tensor_arena[kTensorArenaSize];
-uint8_t benchmark_runner_buffer[sizeof(PersonDetectionBenchmarkRunner)]
+uint8_t op_resolver_buffer[sizeof(PersonDetectionOpResolver)];
+uint8_t benchmark_runner_buffer[sizeof(PersonDetectionBenchmarkRunner)];
PersonDetectionBenchmarkRunner* benchmark_runner = nullptr;
// Initialize benchmark runner instance explicitly to avoid global init order
// issues on Sparkfun. Use new since static variables within a method
// are automatically surrounded by locking, which breaks bluepill and stm32f4.
void CreateBenchmarkRunner() {
- // We allocate AllOpsResolver from a global buffer because the object's
- // lifetime must exceed that of the PersonDetectionBenchmarkRunner object.
- benchmark_runner = new (benchmark_runner_buffer) PersonDetectionBenchmarkRunner(
- g_person_detect_model_data, new (op_resolver_buffer) AllOpsResolver(),
- tensor_arena, kTensorArenaSize);
+ // We allocate PersonDetectionOpResolver from a global buffer because the
+ // object's lifetime must exceed that of the PersonDetectionBenchmarkRunner
+ // object.
+ benchmark_runner = new (benchmark_runner_buffer)
+ PersonDetectionBenchmarkRunner(g_person_detect_model_data,
+ new (op_resolver_buffer)
+ PersonDetectionOpResolver(),
+ tensor_arena, kTensorArenaSize);
}
void PersonDetectionTenIterationsWithRandomInput() {
@@ -66,17 +71,17 @@
void PersonDetectionTenIerationsWithPerson() {
// TODO(b/152644476): Add a way to run more than a single deterministic input.
- benchmark_runner.SetInput(g_person_data);
+ benchmark_runner->SetInput(g_person_data);
for (int i = 0; i < 10; i++) {
- benchmark_runner.RunSingleIteration();
+ benchmark_runner->RunSingleIteration();
}
}
void PersonDetectionTenIerationsWithoutPerson() {
// TODO(b/152644476): Add a way to run more than a single deterministic input.
- benchmark_runner.SetInput(g_no_person_data);
+ benchmark_runner->SetInput(g_no_person_data);
for (int i = 0; i < 10; i++) {
- benchmark_runner.RunSingleIteration();
+ benchmark_runner->RunSingleIteration();
}
}
diff --git a/tensorflow/lite/micro/benchmarks/person_detection_experimental_benchmark.cc b/tensorflow/lite/micro/benchmarks/person_detection_experimental_benchmark.cc
index 2912ca8..68850c9 100644
--- a/tensorflow/lite/micro/benchmarks/person_detection_experimental_benchmark.cc
+++ b/tensorflow/lite/micro/benchmarks/person_detection_experimental_benchmark.cc
@@ -34,6 +34,7 @@
namespace {
+using PersonDetectionExperimentalOpResolver = tflite::AllOpsResolver;
using PersonDetectionExperimentalBenchmarkRunner = MicroBenchmarkRunner<int8_t>;
// Create an area of memory to use for input, output, and intermediate arrays.
@@ -41,6 +42,7 @@
constexpr int kTensorArenaSize = 135 * 1024;
alignas(16) uint8_t tensor_arena[kTensorArenaSize];
+uint8_t op_resolver_buffer[sizeof(PersonDetectionExperimentalOpResolver)];
uint8_t
benchmark_runner_buffer[sizeof(PersonDetectionExperimentalBenchmarkRunner)];
PersonDetectionExperimentalBenchmarkRunner* benchmark_runner = nullptr;
@@ -49,11 +51,13 @@
// issues on Sparkfun. Use new since static variables within a method
// are automatically surrounded by locking, which breaks bluepill and stm32f4.
void CreateBenchmarkRunner() {
- // We allocate AllOpsResolver from a global buffer because the object's
- // lifetime must exceed that of the PersonDetectionBenchmarkRunner object.
+ // We allocate PersonDetectionExperimentalOpResolver from a global buffer
+ // because the object's lifetime must exceed that of the
+ // PersonDetectionBenchmarkRunner object.
benchmark_runner =
- new (tensor_arena) PersonDetectionExperimentalBenchmarkRunner(
- g_person_detect_model_data, new (op_resolver_buffer) AllOpsResolver(),
+ new (benchmark_runner_buffer) PersonDetectionExperimentalBenchmarkRunner(
+ g_person_detect_model_data,
+ new (op_resolver_buffer) PersonDetectionExperimentalOpResolver(),
tensor_arena, kTensorArenaSize);
}
diff --git a/tensorflow/lite/micro/micro_mutable_op_resolver.h b/tensorflow/lite/micro/micro_mutable_op_resolver.h
index de1bfd0..def0bbc 100644
--- a/tensorflow/lite/micro/micro_mutable_op_resolver.h
+++ b/tensorflow/lite/micro/micro_mutable_op_resolver.h
@@ -36,6 +36,8 @@
explicit MicroMutableOpResolver(ErrorReporter* error_reporter = nullptr)
: error_reporter_(error_reporter) {}
+ TF_LITE_REMOVE_VIRTUAL_DELETE
+
const TfLiteRegistration* FindOp(tflite::BuiltinOperator op) const override {
if (op == BuiltinOperator_CUSTOM) return nullptr;
@@ -460,7 +462,6 @@
ErrorReporter* error_reporter_;
- TF_LITE_REMOVE_VIRTUAL_DELETE
};
}; // namespace tflite