Skip to content

Commit

Permalink
Add input tensor CRC to Generic Benchmark application.
Browse files Browse the repository at this point in the history
Only use -O3 -LNO:simd with the xtensa decompress.cc target.
  • Loading branch information
ddavis-2015 committed Nov 20, 2024
1 parent 83dafce commit 0a49b2a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,16 @@ void ShowOutputCRC32(tflite::MicroInterpreter* interpreter) {
}
}

void ShowInputCRC32(tflite::MicroInterpreter* interpreter) {
GenCRC32Table();
for (size_t i = 0; i < interpreter->inputs_size(); ++i) {
TfLiteTensor* input = interpreter->input_tensor(i);
uint8_t* input_values = tflite::GetTensorData<uint8_t>(input);
uint32_t crc32_value = ComputeCRC32(input_values, input->bytes);
MicroPrintf("Input CRC32: 0x%X", crc32_value);
}
}

int Benchmark(const uint8_t* model_data, tflite::PrettyPrintType print_type) {
static Profiler profiler;
static Profiler profiler2;
Expand Down Expand Up @@ -225,6 +235,9 @@ int Benchmark(const uint8_t* model_data, tflite::PrettyPrintType print_type) {
uint32_t seed = kRandomSeed;
while (true) {
SetRandomInput(seed++, interpreter);
ShowInputCRC32(&interpreter);
MicroPrintf(""); // null MicroPrintf serves as a newline.

TfLiteStatus status = interpreter.Invoke();
if ((status != kTfLiteOk) && (static_cast<int>(status) != kTfLiteAbort)) {
MicroPrintf("Model interpreter invocation failed: %d\n", status);
Expand Down
4 changes: 0 additions & 4 deletions tensorflow/lite/micro/tools/make/ext_libs/xtensa.inc
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ else ifeq ($(TARGET_ARCH), hifi5)
CCFLAGS += $(PLATFORM_FLAGS)
CXXFLAGS += $(PLATFORM_FLAGS)

# override KERNEL_OPTIMIZATION_LEVEL to enable higher performance
# Xtensa intrinsics.
KERNEL_OPTIMIZATION_LEVEL := -O3 -LNO:simd

NNLIB_PATH := $(MAKEFILE_DIR)/downloads/xa_nnlib_hifi5
NDSPLIB_PATH := $(MAKEFILE_DIR)/downloads/ndsplib-hifi5

Expand Down
6 changes: 6 additions & 0 deletions tensorflow/lite/micro/tools/make/targets/xtensa_makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,10 @@ ifeq ($(OPTIMIZED_KERNEL_DIR), xtensa)
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/lstm_eval.cc \
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/lstm_eval_hifi.cc \
$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/unidirectional_sequence_lstm.cc

# override KERNEL_OPTIMIZATION_LEVEL to enable higher performance
# Xtensa intrinsics.
$(KERNEL_OBJDIR)$(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/decompress.o: $(TENSORFLOW_ROOT)tensorflow/lite/micro/kernels/xtensa/decompress.cc
@mkdir -p $(dir $@)
$(CXX) $(CXXFLAGS) -O3 -LNO:simd $(INCLUDES) -c $< -o $@
endif

0 comments on commit 0a49b2a

Please sign in to comment.