...
 
Commits (7)
    https://gitcode.net/xusiwei1236/tflite-micro/-/commit/dbff394123669a3715bc5f465fd32b11de5238e8 Update visibility of recipes:resource_variable_lib and micro/models (#1999) 2023-05-25T20:34:25+00:00 suleshahid 110432064+suleshahid@users.noreply.github.com We need additional visibility into these files for some other tests. BUG=[274635545](<a href="http://b/274635545" rel="nofollow noreferrer noopener" target="_blank">http://b/274635545</a>) https://gitcode.net/xusiwei1236/tflite-micro/-/commit/101d2bb93599a157dda41e499a6a2fb06d98f553 TFLM swapping TfLiteRegistration_V1 struct to a new more embedded friendly ap... 2023-05-26T06:48:51+00:00 TANMAY DAS 16020637+tanmaydas82@users.noreply.github.com TFLM swapping TfLiteRegistration_V1 struct to a new more embedded friendly api in the TFLMRegistration struct (#2001) BUG=<a href="http://b/279811848" rel="nofollow noreferrer noopener" target="_blank">http://b/279811848</a> https://gitcode.net/xusiwei1236/tflite-micro/-/commit/6f24535e37f1d004e095eed70f02ca74ea97c578 Strided Slice test (#2002) 2023-05-26T21:27:26+00:00 Steven Toribio 34755817+turbotoribio@users.noreply.github.com add 6 test ported from TfLite that test fused activation for Strided Slice [google3 cl](<a href="https://critique.corp.google.com/cl/534210019" rel="nofollow noreferrer noopener" target="_blank">https://critique.corp.google.com/cl/534210019</a>) BUG=[b/254658480](<a href="https://b.corp.google.com/254658480" rel="nofollow noreferrer noopener" target="_blank">https://b.corp.google.com/254658480</a>) https://gitcode.net/xusiwei1236/tflite-micro/-/commit/a6e6a22247e22eed67255bfe4a48c837ba010ad0 Remove reference to all ops resolver in micro mutable gen script (#1997) 2023-05-26T22:51:10+00:00 Måns Nilsson mans.nilsson@arm.com BUG=Reference to all ops resolver should be removed https://gitcode.net/xusiwei1236/tflite-micro/-/commit/b79f790c9ed8da1989117267716b75b819150c79 Add risc-v to postmerge action. (#1948) 2023-05-27T00:04:05+00:00 TANMAY DAS 16020637+tanmaydas82@users.noreply.github.com BUG=<a href="http://b/280093506" rel="nofollow noreferrer noopener" target="_blank">http://b/280093506</a> https://gitcode.net/xusiwei1236/tflite-micro/-/commit/51b11ee5258c3644d3716b8bc27e424b2cf9fdfa Refactored hello_world. (#1902) 2023-05-28T04:47:12+00:00 TANMAY DAS 16020637+tanmaydas82@users.noreply.github.com BUG=<a href="http://b/277264885" rel="nofollow noreferrer noopener" target="_blank">http://b/277264885</a>, <a href="http://b/279076022" rel="nofollow noreferrer noopener" target="_blank">http://b/279076022</a>, <a href="http://b/280388095" rel="nofollow noreferrer noopener" target="_blank">http://b/280388095</a> https://gitcode.net/xusiwei1236/tflite-micro/-/commit/148af67d3adce57bd9d5eeafc54a1b8a8eab091f Remove redundant step of creating elf file from hexa test. (#2003) 2023-05-28T05:45:23+00:00 TANMAY DAS 16020637+tanmaydas82@users.noreply.github.com BUG=<a href="http://b/284589445" rel="nofollow noreferrer noopener" target="_blank">http://b/284589445</a>
# YAML schema for GitHub Actions:
# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions
#
# Helpful YAML parser to clarify YAML syntax:
# https://yaml-online-parser.appspot.com/
#
# This file can not be run stand-alone. It is called from tests_post.yml as part of
# the ci automation.
name: Risc-v Postmerge
on:
workflow_call:
inputs:
trigger-sha:
required: true
type: string
secrets:
tflm-bot-token:
required: true
jobs:
riscv_postmerge:
runs-on: ubuntu-latest
name: RISC-V Tests (postmerge)
steps:
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- uses: actions/checkout@v3
with:
ref: ${{ inputs.trigger-sha }}
- name: Install dependencies
run: |
pip3 install Pillow
pip3 install Wave
pip3 install numpy
- name: Test
run: |
cd ../
tflite-micro/tensorflow/lite/micro/tools/ci_build/test_riscv.sh tflite-micro/
\ No newline at end of file
......@@ -11,6 +11,15 @@ on:
- labeled
jobs:
riscv_postmerge:
if: ${{ github.event.pull_request.merged == true ||
contains(github.event.pull_request.labels.*.name, 'ci:run_full') }}
uses: ./.github/workflows/riscv_postmerge.yml
with:
trigger-sha: ${{ github.event.pull_request.head.sha }}
secrets:
tflm-bot-token: ${{ secrets.TFLM_BOT_PACKAGE_READ_TOKEN }}
xtensa_postmerge:
if: ${{ github.event.pull_request.merged == true ||
contains(github.event.pull_request.labels.*.name, 'ci:run_full') }}
......
......@@ -109,6 +109,7 @@ cc_library(
deps = [
":memory_helpers",
":micro_allocator",
":micro_common",
":micro_log",
":micro_profiler",
":micro_resource_variable",
......@@ -147,6 +148,7 @@ cc_library(
":flatbuffer_utils",
":memory_helpers",
":micro_arena_constants",
":micro_common",
":micro_compatibility",
":micro_log",
"//tensorflow/lite/kernels:kernel_util",
......
......@@ -26,15 +26,17 @@ cc_library(
)
cc_test(
name = "evaluate_cc_test",
name = "hello_world_test",
srcs = [
"evaluate_test.cc",
"hello_world_test.cc",
],
deps = [
":model",
"//tensorflow/lite/micro:micro_framework",
"//tensorflow/lite/micro:micro_log",
"//tensorflow/lite/micro:micro_profiler",
"//tensorflow/lite/micro:op_resolvers",
"//tensorflow/lite/micro:recording_allocators",
"//tensorflow/lite/micro/testing:micro_test",
"//tensorflow/lite/schema:schema_fbs",
],
......@@ -61,6 +63,7 @@ py_binary(
srcs = ["evaluate_test.py"],
data = [
"//tensorflow/lite/micro/examples/hello_world/models:hello_world_float.tflite",
"//tensorflow/lite/micro/examples/hello_world/models:hello_world_int8.tflite",
],
python_version = "PY3",
srcs_version = "PY3",
......
HELLO_WORLD_TEST_SRCS := \
$(TENSORFLOW_ROOT)tensorflow/lite/micro/examples/hello_world/evaluate_test.cc
$(TENSORFLOW_ROOT)tensorflow/lite/micro/examples/hello_world/hello_world_test.cc
HELLO_WORLD_SRCS := \
$(TENSORFLOW_ROOT)tensorflow/lite/micro/examples/hello_world/evaluate_test.cc
$(TENSORFLOW_ROOT)tensorflow/lite/micro/examples/hello_world/hello_world_test.cc
HELLO_WORLD_HDRS :=
......@@ -19,7 +19,7 @@ $(GENERATED_SRCS_DIR)$(TENSORFLOW_ROOT)tensorflow/lite/micro/examples/hello_worl
$(GENERATED_SRCS_DIR)$(TENSORFLOW_ROOT)tensorflow/lite/micro/examples/hello_world/models/hello_world_int8_model_data.h
# Tests loading and running the sine model.
$(eval $(call microlite_test,evaluate_cc_test,\
$(eval $(call microlite_test,hello_world_test,\
$(HELLO_WORLD_TEST_SRCS),,$(HELLO_WORLD_GENERATOR_INPUTS)))
# Builds a standalone binary.
......
......@@ -40,14 +40,14 @@ bazel run :evaluate_test
Run the cc test using bazel
```bash
bazel run tensorflow/lite/micro/examples/hello_world:evaluate_cc_test
bazel run tensorflow/lite/micro/examples/hello_world:hello_world_test
```
And to run it using make
```bash
make -f tensorflow/lite/micro/tools/make/Makefile test_evaluate_cc_test
make -f tensorflow/lite/micro/tools/make/Makefile test_hello_world_test
```
The source for the test is [evaluate_test.cc](evaluate_test.cc).
The source for the test is [hello_world_test.cc](hello_world_test.cc).
It's a fairly small amount of code that creates an interpreter, gets a handle to
a model that's been compiled into the program, and then invokes the interpreter
with the model and sample inputs.
......
......@@ -50,13 +50,22 @@ def invoke_tflite_interpreter(input_shape, interpreter, x_value, input_index,
# Generate a list of 1000 random floats in the range of 0 to 2*pi.
def generate_random_input(sample_count=1000):
def generate_random_int8_input(sample_count=1000):
# Generate a uniformly distributed set of random numbers in the range from
# 0 to 2π, which covers a complete sine wave oscillation
np.random.seed(42)
x_values = np.random.uniform(low=0, high=2 * np.pi,
size=sample_count).astype(np.int8)
return x_values
# Generate a list of 1000 random floats in the range of 0 to 2*pi.
def generate_random_float_input(sample_count=1000):
# Generate a uniformly distributed set of random numbers in the range from
# 0 to 2π, which covers a complete sine wave oscillation
np.random.seed(42)
x_values = np.random.uniform(low=0, high=2 * np.pi,
size=sample_count).astype(np.float32)
# Shuffle the values to guarantee they're not in order
np.random.shuffle(x_values)
return x_values
......@@ -110,7 +119,7 @@ def get_tflite_prediction(model_path, x_values):
def main(_):
model_path = os.path.join(_PREFIX_PATH, 'models/hello_world_float.tflite')
x_values = generate_random_input()
x_values = generate_random_float_input()
# Calculate the corresponding sine values
y_true_values = np.sin(x_values).astype(np.float32)
......
......@@ -18,77 +18,39 @@ import numpy as np
from tensorflow.python.framework import test_util
from tensorflow.python.platform import resource_loader
from tensorflow.python.platform import test
from tflite_micro.tensorflow.lite.micro.python.interpreter.src import tflm_runtime
from tflite_micro.tensorflow.lite.micro.python.interpreter.src import \
tflm_runtime
from tflite_micro.tensorflow.lite.micro.examples.hello_world import evaluate
PREFIX_PATH = resource_loader.get_path_to_datafile('')
class HelloWorldQuantModelTest(test_util.TensorFlowTestCase):
class HelloWorldFloatModelTest(test_util.TensorFlowTestCase):
model_path = os.path.join(PREFIX_PATH, 'models/hello_world_float.tflite')
input_shape = (1, 1)
output_shape = (1, 1)
# Create the tflm interpreter
tflm_interpreter = tflm_runtime.Interpreter.from_file(model_path)
# Get the metadata like scales and zero_points from the interpreter input/output
# details.
def get_quantization_params(self, interpreter_io_details):
quantize_params = interpreter_io_details.get('quantization_parameters')
scale = quantize_params.get('scales')
zero_point = quantize_params.get('zero_points')
return scale, zero_point
def test_input(self):
input_details = self.tflm_interpreter.get_input_details(0)
input_scale, input_zero_point = self.get_quantization_params(input_details)
self.assertAllEqual(input_details['shape'], self.input_shape)
self.assertEqual(input_details['dtype'], np.float32)
self.assertEqual(len(input_scale), 0)
self.assertEqual(
input_details['quantization_parameters']['quantized_dimension'], 0)
self.assertEqual(input_scale.dtype, np.float32)
self.assertEqual(input_zero_point.dtype, np.int32)
def test_output(self):
output_details = self.tflm_interpreter.get_output_details(0)
output_scale, output_zero_point = self.get_quantization_params(
output_details)
self.assertAllEqual(output_details['shape'], self.output_shape)
self.assertEqual(output_details['dtype'], np.float32)
self.assertEqual(len(output_scale), 0)
self.assertEqual(
output_details['quantization_parameters']['quantized_dimension'], 0)
self.assertEqual(output_scale.dtype, np.float32)
self.assertEqual(output_zero_point.dtype, np.int32)
def test_interpreter_prediction(self):
x_value = np.float32(0.0)
# Calculate the corresponding sine values
y_true = np.sin(x_value).astype(np.float32)
input_shape = np.array(
self.tflm_interpreter.get_input_details(0).get('shape'))
y_pred = evaluate.invoke_tflm_interpreter(
input_shape,
self.tflm_interpreter,
x_value,
input_index=0,
output_index=0,
)
epsilon = 0.05
self.assertNear(
y_true,
y_pred,
epsilon,
'hello_world model prediction is not close enough to numpy.sin value',
)
def test_compare_with_tflite(self):
x_values = evaluate.generate_random_float_input()
tflm_y_predictions = evaluate.get_tflm_prediction(self.model_path,
x_values)
tflite_y_predictions = evaluate.get_tflite_prediction(
self.model_path, x_values)
self.assertAllEqual(tflm_y_predictions, tflite_y_predictions)
class HelloWorldQuantModelTest(test_util.TensorFlowTestCase):
model_path = os.path.join(PREFIX_PATH, 'models/hello_world_int8.tflite')
input_shape = (1, 1)
output_shape = (1, 1)
tflm_interpreter = tflm_runtime.Interpreter.from_file(model_path)
def test_compare_with_tflite(self):
x_values = evaluate.generate_random_input()
x_values = evaluate.generate_random_int8_input()
tflm_y_predictions = evaluate.get_tflm_prediction(self.model_path,
x_values)
......
#!/bin/bash
# Copyright 2020 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
#
# Bash unit tests for the example binary.
set -e
OUTPUT_LOG_FILE=${TEST_TMPDIR}/output_log.txt
${TEST_SRCDIR}/${TEST_WORKSPACE}/tensorflow/lite/micro/examples/hello_world/hello_world 2>&1 | head > ${OUTPUT_LOG_FILE}
if ! grep -q 'x_value:.*y_value:' ${OUTPUT_LOG_FILE}; then
echo "ERROR: Expected logs not found in output '${OUTPUT_LOG_FILE}'"
exit 1
fi
echo
echo "SUCCESS: hello_world_binary_test PASSED"
......@@ -21,6 +21,8 @@ limitations under the License.
#include "tensorflow/lite/micro/micro_interpreter.h"
#include "tensorflow/lite/micro/micro_log.h"
#include "tensorflow/lite/micro/micro_mutable_op_resolver.h"
#include "tensorflow/lite/micro/micro_profiler.h"
#include "tensorflow/lite/micro/recording_micro_interpreter.h"
#include "tensorflow/lite/micro/system_setup.h"
#include "tensorflow/lite/schema/schema_generated.h"
......@@ -33,17 +35,41 @@ TfLiteStatus RegisterOps(HelloWorldOpResolver& op_resolver) {
}
} // namespace
TfLiteStatus ProfileMemoryAndLatency() {
tflite::MicroProfiler profiler;
HelloWorldOpResolver op_resolver;
TF_LITE_ENSURE_STATUS(RegisterOps(op_resolver));
// Arena size just a round number. The exact arena usage can be determined
// using the RecordingMicroInterpreter.
constexpr int kTensorArenaSize = 3000;
uint8_t tensor_arena[kTensorArenaSize];
constexpr int kNumResourceVariables = 24;
tflite::RecordingMicroAllocator* allocator(
tflite::RecordingMicroAllocator::Create(tensor_arena, kTensorArenaSize));
tflite::RecordingMicroInterpreter interpreter(
tflite::GetModel(g_hello_world_float_model_data), op_resolver, allocator,
tflite::MicroResourceVariables::Create(allocator, kNumResourceVariables),
&profiler);
TF_LITE_ENSURE_STATUS(interpreter.AllocateTensors());
TFLITE_CHECK_EQ(interpreter.inputs_size(), 1);
interpreter.input(0)->data.f[0] = 1.f;
TF_LITE_ENSURE_STATUS(interpreter.Invoke());
MicroPrintf(""); // Print an empty new line
profiler.LogTicksPerTagCsv();
MicroPrintf(""); // Print an empty new line
interpreter.GetMicroAllocator().PrintAllocations();
return kTfLiteOk;
}
TfLiteStatus LoadFloatModelAndPerformInference() {
// Map the model into a usable data structure. This doesn't involve any
// copying or parsing, it's a very lightweight operation.
const tflite::Model* model =
::tflite::GetModel(g_hello_world_float_model_data);
if (model->version() != TFLITE_SCHEMA_VERSION) {
MicroPrintf(
"Model provided is schema version %d not equal "
"to supported version %d.\n",
model->version(), TFLITE_SCHEMA_VERSION);
}
TFLITE_CHECK_EQ(model->version(), TFLITE_SCHEMA_VERSION);
HelloWorldOpResolver op_resolver;
TF_LITE_ENSURE_STATUS(RegisterOps(op_resolver));
......@@ -53,44 +79,21 @@ TfLiteStatus LoadFloatModelAndPerformInference() {
constexpr int kTensorArenaSize = 3000;
uint8_t tensor_arena[kTensorArenaSize];
// Build an interpreter to run the model with
tflite::MicroInterpreter interpreter(model, op_resolver, tensor_arena,
kTensorArenaSize);
TF_LITE_ENSURE_STATUS(interpreter.AllocateTensors());
// Allocate memory from the tensor_arena for the model's tensors
if (interpreter.AllocateTensors() != kTfLiteOk) {
MicroPrintf("Allocate tensor failed.");
return kTfLiteError;
}
// Obtain a pointer to the model's input tensor
TfLiteTensor* input = interpreter.input(0);
// Make sure the input has the properties we expect
if (input == nullptr) {
MicroPrintf("Input tensor is null.");
return kTfLiteError;
}
// Obtain a pointer to the output tensor.
TfLiteTensor* output = interpreter.output(0);
// Check if the output is within a small range of the expected output
// Check if the predicted output is within a small range of the
// expected output
float epsilon = 0.05f;
constexpr int kNumTestValues = 4;
float golden_inputs[kNumTestValues] = {0.f, 1.f, 3.f, 5.f};
for (int i = 0; i < kNumTestValues; ++i) {
input->data.f[0] = golden_inputs[i];
interpreter.Invoke();
float y_pred = output->data.f[0];
if (abs(sin(golden_inputs[i]) - y_pred) > epsilon) {
MicroPrintf(
"Difference between predicted and actual y value "
"is significant.");
return kTfLiteError;
}
interpreter.input(0)->data.f[0] = golden_inputs[i];
TF_LITE_ENSURE_STATUS(interpreter.Invoke());
float y_pred = interpreter.output(0)->data.f[0];
TFLITE_CHECK_LE(abs(sin(golden_inputs[i]) - y_pred), epsilon);
}
return kTfLiteOk;
......@@ -101,67 +104,46 @@ TfLiteStatus LoadQuantModelAndPerformInference() {
// copying or parsing, it's a very lightweight operation.
const tflite::Model* model =
::tflite::GetModel(g_hello_world_int8_model_data);
if (model->version() != TFLITE_SCHEMA_VERSION) {
MicroPrintf(
"Model provided is schema version %d not equal "
"to supported version %d.\n",
model->version(), TFLITE_SCHEMA_VERSION);
}
TFLITE_CHECK_EQ(model->version(), TFLITE_SCHEMA_VERSION);
HelloWorldOpResolver op_resolver;
TF_LITE_ENSURE_STATUS(RegisterOps(op_resolver));
// Arena size just a round number. The exact arena usage can be determined
// using the RecordingMicroInterpreter.
constexpr int kTensorArenaSize = 2056;
constexpr int kTensorArenaSize = 3000;
uint8_t tensor_arena[kTensorArenaSize];
// Build an interpreter to run the model with
tflite::MicroInterpreter interpreter(model, op_resolver, tensor_arena,
kTensorArenaSize);
// Allocate memory from the tensor_arena for the model's tensors
if (interpreter.AllocateTensors() != kTfLiteOk) {
MicroPrintf("Allocate tensor failed.");
return kTfLiteError;
}
TF_LITE_ENSURE_STATUS(interpreter.AllocateTensors());
// Obtain a pointer to the model's input tensor
TfLiteTensor* input = interpreter.input(0);
TFLITE_CHECK_NE(input, nullptr);
// Make sure the input has the properties we expect
if (input == nullptr) {
MicroPrintf("Input tensor is null.");
return kTfLiteError;
}
// Get the input quantization parameters
float input_scale = input->params.scale;
int input_zero_point = input->params.zero_point;
// Obtain a pointer to the output tensor.
TfLiteTensor* output = interpreter.output(0);
TFLITE_CHECK_NE(output, nullptr);
// Get the output quantization parameters
float output_scale = output->params.scale;
int output_zero_point = output->params.zero_point;
// Check if the output is within a small range of the expected output
float epsilon = 0.05f;
// Check if the predicted output is within a small range of the
// expected output
float epsilon = 0.05;
constexpr int kNumTestValues = 4;
float golden_inputs[kNumTestValues] = {0.f, 1.f, 3.f, 5.f};
float golden_inputs_float[kNumTestValues] = {0.77, 1.57, 2.3, 3.14};
// The int8 values are calculated using the following formula
// (golden_inputs_float[i] / input->params.scale + input->params.scale)
int8_t golden_inputs_int8[kNumTestValues] = {-96, -63, -34, 0};
for (int i = 0; i < kNumTestValues; ++i) {
input->data.int8[0] = golden_inputs[i] / input_scale + input_zero_point;
interpreter.Invoke();
input->data.int8[0] = golden_inputs_int8[i];
TF_LITE_ENSURE_STATUS(interpreter.Invoke());
float y_pred = (output->data.int8[0] - output_zero_point) * output_scale;
if (abs(sin(golden_inputs[i]) - y_pred) > epsilon) {
MicroPrintf(
"Difference between predicted and actual y value "
"is significant.");
return kTfLiteError;
}
TFLITE_CHECK_LE(abs(sin(golden_inputs_float[i]) - y_pred), epsilon);
}
return kTfLiteOk;
......@@ -169,6 +151,7 @@ TfLiteStatus LoadQuantModelAndPerformInference() {
int main(int argc, char* argv[]) {
tflite::InitializeTarget();
TF_LITE_ENSURE_STATUS(ProfileMemoryAndLatency());
TF_LITE_ENSURE_STATUS(LoadFloatModelAndPerformInference());
TF_LITE_ENSURE_STATUS(LoadQuantModelAndPerformInference());
MicroPrintf("~~~ALL TESTS PASSED~~~\n");
......
......@@ -8,6 +8,7 @@ py_library(
name = "resource_variables_lib",
srcs = ["resource_variables_lib.py"],
srcs_version = "PY3",
visibility = ["//:__subpackages__"],
deps = [
requirement("numpy"),
requirement("tensorflow-cpu"),
......
......@@ -109,11 +109,11 @@ TfLiteStatus Relu6Eval(TfLiteContext* context, TfLiteNode* node) {
} // namespace
TfLiteRegistration_V1 Register_RELU() {
TFLMRegistration Register_RELU() {
return tflite::micro::RegisterOp(ReluInit, ReluPrepare, ReluEval);
}
TfLiteRegistration_V1 Register_RELU6() {
TFLMRegistration Register_RELU6() {
return tflite::micro::RegisterOp(Relu6Init, Relu6Prepare, Relu6Eval);
}
......
......@@ -43,7 +43,7 @@ void TestReluFloat(int* input_dims_data, const float* input_data,
int outputs_array_data[] = {1, 1};
TfLiteIntArray* outputs_array = IntArrayFromInts(outputs_array_data);
const TfLiteRegistration_V1 registration = Register_RELU();
const TFLMRegistration registration = Register_RELU();
micro::KernelRunner runner(registration, tensors, tensors_size, inputs_array,
outputs_array,
/*builtin_data=*/nullptr);
......@@ -76,7 +76,7 @@ void TestRelu6Float(int* input_dims_data, const float* input_data,
int outputs_array_data[] = {1, 1};
TfLiteIntArray* outputs_array = IntArrayFromInts(outputs_array_data);
const TfLiteRegistration_V1 registration = Register_RELU6();
const TFLMRegistration registration = Register_RELU6();
micro::KernelRunner runner(registration, tensors, tensors_size, inputs_array,
outputs_array,
/*builtin_data=*/nullptr);
......@@ -113,7 +113,7 @@ void TestReluInt8(int* input_dims_data, const float* input_data,
int outputs_array_data[] = {1, 1};
TfLiteIntArray* outputs_array = IntArrayFromInts(outputs_array_data);
const TfLiteRegistration_V1 registration = Register_RELU();
const TFLMRegistration registration = Register_RELU();
micro::KernelRunner runner(registration, tensors, tensors_size, inputs_array,
outputs_array,
/*builtin_data=*/nullptr);
......@@ -153,7 +153,7 @@ void TestRelu6Int8(int* input_dims_data, const float* input_data,
int outputs_array_data[] = {1, 1};
TfLiteIntArray* outputs_array = IntArrayFromInts(outputs_array_data);
const TfLiteRegistration_V1 registration = Register_RELU6();
const TFLMRegistration registration = Register_RELU6();
micro::KernelRunner runner(registration, tensors, tensors_size, inputs_array,
outputs_array,
/*builtin_data=*/nullptr);
......
......@@ -193,7 +193,7 @@ TfLiteStatus AddEval(TfLiteContext* context, TfLiteNode* node) {
return kTfLiteOk;
}
TfLiteRegistration_V1 Register_ADD() {
TFLMRegistration Register_ADD() {
return tflite::micro::RegisterOp(AddInit, AddPrepare, AddEval);
}
......
......@@ -20,6 +20,7 @@ limitations under the License.
#include "tensorflow/lite/c/builtin_op_data.h"
#include "tensorflow/lite/c/common.h"
#include "tensorflow/lite/micro/micro_common.h"
namespace tflite {
......@@ -60,17 +61,17 @@ TfLiteStatus CalculateOpDataAdd(TfLiteContext* context, TfLiteAddParams* params,
TfLiteStatus AddPrepare(TfLiteContext* context, TfLiteNode* node);
// Generic must define registration function.
TfLiteRegistration_V1 Register_ADD();
TFLMRegistration Register_ADD();
#if defined(CMSIS_NN)
TfLiteRegistration_V1 Register_ADD_INT8();
TFLMRegistration Register_ADD_INT8();
TfLiteRegistration_V1 Register_ADD_INT16();
TFLMRegistration Register_ADD_INT16();
#else
// Fallback registration
inline TfLiteRegistration_V1 Register_ADD_INT8() { return Register_ADD(); }
inline TFLMRegistration Register_ADD_INT8() { return Register_ADD(); }
inline TfLiteRegistration_V1 Register_ADD_INT16() { return Register_ADD(); }
inline TFLMRegistration Register_ADD_INT16() { return Register_ADD(); }
#endif
} // namespace tflite
......
......@@ -208,7 +208,7 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
} // namespace
TfLiteRegistration_V1 Register_ADD_N() {
TFLMRegistration Register_ADD_N() {
return tflite::micro::RegisterOp(nullptr, Prepare, Eval);
}
......
......@@ -38,7 +38,7 @@ void ExecuteAddN(TfLiteTensor* tensors, int tensors_count) {
int kOutputArrayData[] = {1, tensors_count - 1};
TfLiteIntArray* outputs_array = IntArrayFromInts(kOutputArrayData);
const TfLiteRegistration_V1 registration = tflite::Register_ADD_N();
const TFLMRegistration registration = tflite::Register_ADD_N();
micro::KernelRunner runner(registration, tensors, tensors_count, inputs_array,
outputs_array, nullptr);
......
......@@ -74,7 +74,7 @@ void ValidateAddGoldens(TfLiteTensor* tensors, int tensors_size,
int outputs_array_data[] = {1, 2};
TfLiteIntArray* outputs_array = IntArrayFromInts(outputs_array_data);
const TfLiteRegistration_V1 registration = Register_ADD();
const TFLMRegistration registration = Register_ADD();
micro::KernelRunner runner(registration, tensors, tensors_size, inputs_array,
outputs_array, &builtin_data);
......
......@@ -417,7 +417,7 @@ TfLiteStatus AddEval(TfLiteContext* context, TfLiteNode* node) {
return ret_val;
}
TfLiteRegistration_V1 Register_ADD() {
TFLMRegistration Register_ADD() {
return tflite::micro::RegisterOp(AddInit, AddPrepare, AddEval);
}
......
......@@ -704,7 +704,7 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
} // namespace
TfLiteRegistration_V1 Register_CONV_2D() {
TFLMRegistration Register_CONV_2D() {
return tflite::micro::RegisterOp(Init, Prepare, Eval);
}
......
......@@ -670,7 +670,7 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
} // namespace
TfLiteRegistration_V1 Register_DEPTHWISE_CONV_2D() {
TFLMRegistration Register_DEPTHWISE_CONV_2D() {
return tflite::micro::RegisterOp(Init, Prepare, Eval);
}
......
......@@ -469,7 +469,7 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
return kTfLiteOk;
}
TfLiteRegistration_V1 Register_FULLY_CONNECTED() {
TFLMRegistration Register_FULLY_CONNECTED() {
return tflite::micro::RegisterOp(Init, Prepare, Eval);
}
......
......@@ -408,11 +408,11 @@ TfLiteStatus MaxEval(TfLiteContext* context, TfLiteNode* node) {
} // namespace
TfLiteRegistration_V1 Register_AVERAGE_POOL_2D() {
TFLMRegistration Register_AVERAGE_POOL_2D() {
return tflite::micro::RegisterOp(Init, Prepare, AverageEval);
}
TfLiteRegistration_V1 Register_MAX_POOL_2D() {
TFLMRegistration Register_MAX_POOL_2D() {
return tflite::micro::RegisterOp(Init, Prepare, MaxEval);
}
......
......@@ -107,11 +107,11 @@ TfLiteStatus ArgMaxEval(TfLiteContext* context, TfLiteNode* node) {
} // namespace
TfLiteRegistration_V1 Register_ARG_MAX() {
TFLMRegistration Register_ARG_MAX() {
return tflite::micro::RegisterOp(nullptr, nullptr, ArgMaxEval);
}
TfLiteRegistration_V1 Register_ARG_MIN() {
TFLMRegistration Register_ARG_MIN() {
return tflite::micro::RegisterOp(nullptr, nullptr, ArgMinEval);
}
......
......@@ -31,7 +31,7 @@ void ValidateArgMinMaxGoldens(TfLiteTensor* tensors, int tensors_size,
int outputs_array_data[] = {1, 2};
TfLiteIntArray* outputs_array = IntArrayFromInts(outputs_array_data);
const TfLiteRegistration_V1 registration =
const TFLMRegistration registration =
using_min ? Register_ARG_MIN() : Register_ARG_MAX();
micro::KernelRunner runner(registration, tensors, tensors_size, inputs_array,
outputs_array,
......
......@@ -100,7 +100,7 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
} // namespace.
TfLiteRegistration_V1 Register_ASSIGN_VARIABLE() {
TFLMRegistration Register_ASSIGN_VARIABLE() {
return tflite::micro::RegisterOp(nullptr, Prepare, Eval);
}
......
......@@ -105,7 +105,7 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
} // namespace.
TfLiteRegistration_V1 Register_BATCH_TO_SPACE_ND() {
TFLMRegistration Register_BATCH_TO_SPACE_ND() {
return tflite::micro::RegisterOp(nullptr, Prepare, Eval);
}
......
......@@ -46,7 +46,7 @@ TfLiteStatus ValidateBatchToSpaceNdGoldens(TfLiteTensor* tensors,
int outputs_array_data[] = {1, 3};
TfLiteIntArray* outputs_array = IntArrayFromInts(outputs_array_data);
const TfLiteRegistration_V1 registration = Register_BATCH_TO_SPACE_ND();
const TFLMRegistration registration = Register_BATCH_TO_SPACE_ND();
micro::KernelRunner runner(registration, tensors, tensors_size, inputs_array,
outputs_array, nullptr);
......
......@@ -83,7 +83,7 @@ TfLiteStatus BroadcastArgsEval(TfLiteContext* context, TfLiteNode* node) {
} // namespace
TfLiteRegistration_V1 Register_BROADCAST_ARGS() {
TFLMRegistration Register_BROADCAST_ARGS() {
return tflite::micro::RegisterOp(nullptr, BroadcastArgsPrepare,
BroadcastArgsEval);
}
......
......@@ -39,7 +39,7 @@ tflite::micro::KernelRunner CreateBroadcastArgsTestRunner(
// the test need to place non-transient memories in static variables. This is
// safe because tests are guaranteed to run serially.
// Both below structures are trivially destructible.
static TfLiteRegistration_V1 registration;
static TFLMRegistration registration;
static TfLiteTensor tensors[3];
tensors[0] = CreateTensor(input1_data, IntArrayFromInts(input1_shape));
......
......@@ -107,7 +107,7 @@ TfLiteStatus BroadcastToEval(TfLiteContext* context, TfLiteNode* node) {
micro::GetEvalInput(context, node, kInputTensor);
TfLiteEvalTensor* output = micro::GetEvalOutput(context, node, kOutputTensor);
// BroadcastTo op support upto 5 dims, different from 8 dims in TFLite.
// BroadcastTo op support up to 5 dims, different from 8 dims in TFLite.
reference_ops::BroadcastTo<kMaxDims>(
micro::GetTensorShape(input), input->data.raw,
micro::GetTensorShape(output), output->data.raw, input->type);
......@@ -115,7 +115,7 @@ TfLiteStatus BroadcastToEval(TfLiteContext* context, TfLiteNode* node) {
}
} // namespace
TfLiteRegistration_V1 Register_BROADCAST_TO() {
TFLMRegistration Register_BROADCAST_TO() {
return tflite::micro::RegisterOp(nullptr, BroadcastToPrepare,
BroadcastToEval);
}
......
......@@ -39,7 +39,7 @@ tflite::micro::KernelRunner CreateBroadcastToTestRunner(
// the test need to place non-transient memories in static variables. This is
// safe because tests are guaranteed to run serially.
// Both below structures are trivially destructible.
static TfLiteRegistration_V1 registration;
static TFLMRegistration registration;
static TfLiteTensor tensors[3];
tensors[0] = CreateTensor(input_data, IntArrayFromInts(input_shape));
......@@ -196,7 +196,7 @@ TF_LITE_MICRO_TEST(NoBroadcastingConstTest) {
output_data, expected_output_data);
}
TF_LITE_MICRO_TEST(BroadcastInt64ShpaeTest) {
TF_LITE_MICRO_TEST(BroadcastInt64ShapeTest) {
int dims_shape[] = {1, 4};
int64_t dims_data[] = {1, 1, 2, 2};
......
......@@ -81,7 +81,7 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
} // namespace.
TfLiteRegistration_V1 Register_CALL_ONCE() {
TFLMRegistration Register_CALL_ONCE() {
return tflite::micro::RegisterOp(Init, Prepare, Eval);
}
......
......@@ -35,7 +35,7 @@ void TestCallOnce(const int subgraph0_invoke_count_golden,
TfLiteCallOnceParams params;
params.init_subgraph_index = 1;
const TfLiteRegistration_V1 registration = tflite::Register_CALL_ONCE();
const TFLMRegistration registration = tflite::Register_CALL_ONCE();
micro::KernelRunner runner(registration, nullptr, 0, inputs_array,
outputs_array, &params);
......
......@@ -107,7 +107,7 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
}
} // namespace
TfLiteRegistration_V1 Register_CAST() {
TFLMRegistration Register_CAST() {
return tflite::micro::RegisterOp(nullptr, Prepare, Eval);
}
......
......@@ -42,7 +42,7 @@ void TestCast(int* input_dims_data, const inputT* input_data,
int outputs_array_data[] = {1, 1};
TfLiteIntArray* outputs_array = IntArrayFromInts(outputs_array_data);
const TfLiteRegistration_V1 registration = Register_CAST();
const TFLMRegistration registration = Register_CAST();
micro::KernelRunner runner(registration, tensors, tensors_size, inputs_array,
outputs_array,
/*builtin_data=*/nullptr);
......
......@@ -66,7 +66,7 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
} // namespace
TfLiteRegistration_V1 Register_CEIL() {
TFLMRegistration Register_CEIL() {
return tflite::micro::RegisterOp(nullptr, Prepare, Eval);
}
......
......@@ -41,7 +41,7 @@ void TestCeil(int* input_dims_data, const float* input_data,
int outputs_array_data[] = {1, 1};
TfLiteIntArray* outputs_array = IntArrayFromInts(outputs_array_data);
const TfLiteRegistration_V1 registration = Register_CEIL();
const TFLMRegistration registration = Register_CEIL();
micro::KernelRunner runner(registration, tensors, tensors_size, inputs_array,
outputs_array,
/*builtin_data=*/nullptr);
......
......@@ -251,7 +251,7 @@ TfLiteStatus ConvEval(TfLiteContext* context, TfLiteNode* node) {
}
} // namespace
TfLiteRegistration_V1 Register_CONV_2D() {
TFLMRegistration Register_CONV_2D() {
return tflite::micro::RegisterOp(Init, ConvPrepare, ConvEval);
}
......
......@@ -242,7 +242,7 @@ TfLiteStatus DepthWiseConvEval(TfLiteContext* context, TfLiteNode* node) {
} // namespace
TfLiteRegistration_V1 Register_DEPTHWISE_CONV_2D() {
TFLMRegistration Register_DEPTHWISE_CONV_2D() {
return tflite::micro::RegisterOp(Init, DepthwiseConvPrepare,
DepthWiseConvEval);
}
......
......@@ -243,7 +243,7 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
} // namespace
TfLiteRegistration_V1 Register_FULLY_CONNECTED() {
TFLMRegistration Register_FULLY_CONNECTED() {
return tflite::micro::RegisterOp(Init, Prepare, Eval);
}
......
......@@ -132,7 +132,7 @@ TfLiteStatus LogisticEval(TfLiteContext* context, TfLiteNode* node) {
} // namespace
TfLiteRegistration_V1 Register_LOGISTIC() {
TFLMRegistration Register_LOGISTIC() {
return tflite::micro::RegisterOp(LogisticInit, LogisticPrepare, LogisticEval);
}
} // namespace tflite
......@@ -79,7 +79,7 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
// This Op (QUANTIZE) quantizes the input and produces quantized output.
// AffineQuantize takes scale and zero point and quantizes the float value to
// quantized output, in int8_t or uint8_t format.
TfLiteRegistration_V1 Register_QUANTIZE() {
TFLMRegistration Register_QUANTIZE() {
return tflite::micro::RegisterOp(Init, PrepareQuantizeReference, Eval);
}
......
......@@ -160,7 +160,7 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
}
} // namespace
TfLiteRegistration_V1 Register_SOFTMAX() {
TFLMRegistration Register_SOFTMAX() {
return tflite::micro::RegisterOp(SoftmaxInit, SoftmaxPrepare, Eval);
}
......
......@@ -108,8 +108,8 @@ TfLiteStatus CircularBufferEval(TfLiteContext* context, TfLiteNode* node) {
return kTfLiteOk;
}
TfLiteRegistration_V1* Register_CIRCULAR_BUFFER() {
static TfLiteRegistration_V1 r = tflite::micro::RegisterOp(
TFLMRegistration* Register_CIRCULAR_BUFFER() {
static TFLMRegistration r = tflite::micro::RegisterOp(
CircularBufferInit, CircularBufferPrepare, CircularBufferEval);
return &r;
}
......
......@@ -75,7 +75,7 @@ TF_LITE_MICRO_TEST(OutputTensorLength4) {
TfLiteIntArray* outputs_array =
tflite::testing::IntArrayFromInts(outputs_array_data);
const TfLiteRegistration_V1* registration = tflite::Register_CIRCULAR_BUFFER();
const TFLMRegistration* registration = tflite::Register_CIRCULAR_BUFFER();
tflite::micro::KernelRunner runner = tflite::micro::KernelRunner(
*registration, tensors, tensors_size, inputs_array, outputs_array,
/*builtin_data=*/nullptr);
......@@ -146,7 +146,7 @@ TF_LITE_MICRO_TEST(OutputTensorOnEveryIterationLength4) {
TfLiteIntArray* outputs_array =
tflite::testing::IntArrayFromInts(outputs_array_data);
const TfLiteRegistration_V1* registration = tflite::Register_CIRCULAR_BUFFER();
const TFLMRegistration* registration = tflite::Register_CIRCULAR_BUFFER();
tflite::micro::KernelRunner runner = tflite::micro::KernelRunner(
*registration, tensors, tensors_size, inputs_array, outputs_array,
/*builtin_data=*/nullptr);
......@@ -211,7 +211,7 @@ TF_LITE_MICRO_TEST(OutputTensorLength5) {
TfLiteIntArray* outputs_array =
tflite::testing::IntArrayFromInts(outputs_array_data);
const TfLiteRegistration_V1* registration = tflite::Register_CIRCULAR_BUFFER();
const TFLMRegistration* registration = tflite::Register_CIRCULAR_BUFFER();
tflite::micro::KernelRunner runner = tflite::micro::KernelRunner(
*registration, tensors, tensors_size, inputs_array, outputs_array,
/*builtin_data=*/nullptr);
......
......@@ -396,15 +396,15 @@ TfLiteStatus EvalAddInt16(TfLiteContext* context, TfLiteNode* node) {
return kTfLiteOk;
}
TfLiteRegistration_V1 Register_ADD() {
TFLMRegistration Register_ADD() {
return tflite::micro::RegisterOp(InitAdd, PrepareAdd, EvalAdd);
}
TfLiteRegistration_V1 Register_ADD_INT8() {
TFLMRegistration Register_ADD_INT8() {
return tflite::micro::RegisterOp(InitAdd, PrepareAdd, EvalAddInt8);
}
TfLiteRegistration_V1 Register_ADD_INT16() {
TFLMRegistration Register_ADD_INT16() {
return tflite::micro::RegisterOp(InitAdd, PrepareAdd, EvalAddInt16);
}
......
......@@ -466,15 +466,15 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
} // namespace
TfLiteRegistration_V1 Register_CONV_2D() {
TFLMRegistration Register_CONV_2D() {
return tflite::micro::RegisterOp(Init, Prepare, Eval);
}
TfLiteRegistration_V1 Register_CONV_2D_INT8() {
TFLMRegistration Register_CONV_2D_INT8() {
return tflite::micro::RegisterOp(Init, Prepare, EvalInt8);
}
TfLiteRegistration_V1 Register_CONV_2D_INT16() {
TFLMRegistration Register_CONV_2D_INT16() {
return tflite::micro::RegisterOp(Init, Prepare, EvalInt16x8);
}
......
......@@ -433,15 +433,15 @@ TfLiteStatus EvalInt16x8(TfLiteContext* context, TfLiteNode* node) {
} // namespace
TfLiteRegistration_V1 Register_DEPTHWISE_CONV_2D() {
TFLMRegistration Register_DEPTHWISE_CONV_2D() {
return tflite::micro::RegisterOp(Init, Prepare, Eval);
}
TfLiteRegistration_V1 Register_DEPTHWISE_CONV_2D_INT8() {
TFLMRegistration Register_DEPTHWISE_CONV_2D_INT8() {
return tflite::micro::RegisterOp(Init, Prepare, EvalInt8);
}
TfLiteRegistration_V1 Register_DEPTHWISE_CONV_2D_INT16() {
TFLMRegistration Register_DEPTHWISE_CONV_2D_INT16() {
return tflite::micro::RegisterOp(Init, Prepare, EvalInt16x8);
}
......
......@@ -421,15 +421,15 @@ TfLiteStatus EvalInt16(TfLiteContext* context, TfLiteNode* node) {
} // namespace
TfLiteRegistration_V1 Register_FULLY_CONNECTED() {
TFLMRegistration Register_FULLY_CONNECTED() {
return tflite::micro::RegisterOp(Init, Prepare, Eval);
}
TfLiteRegistration_V1 Register_FULLY_CONNECTED_INT8() {
TFLMRegistration Register_FULLY_CONNECTED_INT8() {
return tflite::micro::RegisterOp(Init, Prepare, EvalInt8);
}
TfLiteRegistration_V1 Register_FULLY_CONNECTED_INT16() {
TFLMRegistration Register_FULLY_CONNECTED_INT16() {
return tflite::micro::RegisterOp(Init, Prepare, EvalInt16);
}
......
......@@ -169,15 +169,15 @@ TfLiteStatus EvalInt16(TfLiteContext* context, TfLiteNode* node) {
return kTfLiteOk;
}
TfLiteRegistration_V1 Register_MUL() {
TFLMRegistration Register_MUL() {
return tflite::micro::RegisterOp(MulInit, MulPrepare, Eval);
}
TfLiteRegistration_V1 Register_MUL_INT8() {
TFLMRegistration Register_MUL_INT8() {
return tflite::micro::RegisterOp(MulInit, MulPrepare, EvalInt8);
}
TfLiteRegistration_V1 Register_MUL_INT16() {
TFLMRegistration Register_MUL_INT16() {
return tflite::micro::RegisterOp(MulInit, MulPrepare, EvalInt16);
}
......
......@@ -319,27 +319,27 @@ TfLiteStatus MaxEvalInt16(TfLiteContext* context, TfLiteNode* node) {
} // namespace
TfLiteRegistration_V1 Register_AVERAGE_POOL_2D_INT8() {
TFLMRegistration Register_AVERAGE_POOL_2D_INT8() {
return tflite::micro::RegisterOp(Init, AveragePrepare, AverageEvalInt8);
}
TfLiteRegistration_V1 Register_AVERAGE_POOL_2D_INT16() {
TFLMRegistration Register_AVERAGE_POOL_2D_INT16() {
return tflite::micro::RegisterOp(Init, AveragePrepare, AverageEvalInt16);
}
TfLiteRegistration_V1 Register_AVERAGE_POOL_2D() {
TFLMRegistration Register_AVERAGE_POOL_2D() {
return tflite::micro::RegisterOp(Init, AveragePrepare, AverageEval);
}
TfLiteRegistration_V1 Register_MAX_POOL_2D_INT8() {
TFLMRegistration Register_MAX_POOL_2D_INT8() {
return tflite::micro::RegisterOp(Init, MaxPrepare, MaxEvalInt8);
}
TfLiteRegistration_V1 Register_MAX_POOL_2D_INT16() {
TFLMRegistration Register_MAX_POOL_2D_INT16() {
return tflite::micro::RegisterOp(Init, MaxPrepare, MaxEvalInt16);
}
TfLiteRegistration_V1 Register_MAX_POOL_2D() {
TFLMRegistration Register_MAX_POOL_2D() {
return tflite::micro::RegisterOp(Init, MaxPrepare, MaxEval);
}
......
......@@ -190,19 +190,19 @@ TfLiteStatus SoftmaxEvalInt16(TfLiteContext* context, TfLiteNode* node) {
} // namespace
TfLiteRegistration_V1 Register_SOFTMAX() {
TFLMRegistration Register_SOFTMAX() {
return tflite::micro::RegisterOp(Init, Prepare, SoftmaxEval);
}
TfLiteRegistration_V1 Register_SOFTMAX_INT8() {
TFLMRegistration Register_SOFTMAX_INT8() {
return tflite::micro::RegisterOp(Init, Prepare, SoftmaxEvalInt8);
}
TfLiteRegistration_V1 Register_SOFTMAX_INT8_INT16() {
TFLMRegistration Register_SOFTMAX_INT8_INT16() {
return tflite::micro::RegisterOp(Init, Prepare, SoftmaxEvalInt8_Int16);
}
TfLiteRegistration_V1 Register_SOFTMAX_INT16() {
TFLMRegistration Register_SOFTMAX_INT16() {
return tflite::micro::RegisterOp(Init, Prepare, SoftmaxEvalInt16);
}
......
......@@ -204,7 +204,7 @@ TfLiteStatus EvalSvdfInt8(TfLiteContext* context, TfLiteNode* node) {
TFLITE_DCHECK((weights_time->type == kTfLiteInt8) ||
(weights_time->type == kTfLiteInt16));
// Because of the TODO mentioned below, the int16 weight data type is not
// split into a seperate registration.
// split into a separate registration.
// TODO(#523): remove 16-bit code when no longer needed.
return EvalIntegerSVDF(context, node, input, weights_feature, weights_time,
bias, params, activation_state, output, data);
......@@ -212,11 +212,11 @@ TfLiteStatus EvalSvdfInt8(TfLiteContext* context, TfLiteNode* node) {
} // namespace
TfLiteRegistration_V1 Register_SVDF() {
TFLMRegistration Register_SVDF() {
return tflite::micro::RegisterOp(Init, PrepareSvdf, EvalSvdf);
}
TfLiteRegistration_V1 Register_SVDF_INT8() {
TFLMRegistration Register_SVDF_INT8() {
return tflite::micro::RegisterOp(Init, PrepareSvdf, EvalSvdfInt8);
}
......
......@@ -668,13 +668,13 @@ TfLiteStatus UnidirectionalSequenceLstmEvalInt8(TfLiteContext* context,
} // namespace
TfLiteRegistration_V1 Register_UNIDIRECTIONAL_SEQUENCE_LSTM() {
TFLMRegistration Register_UNIDIRECTIONAL_SEQUENCE_LSTM() {
return tflite::micro::RegisterOp(UnidirectionalSequenceLstmInit,
UnidirectionalSequenceLstmPrepare,
UnidirectionalSequenceLstmEval);
}
TfLiteRegistration_V1 Register_UNIDIRECTIONAL_SEQUENCE_LSTM_INT8() {
TFLMRegistration Register_UNIDIRECTIONAL_SEQUENCE_LSTM_INT8() {
return tflite::micro::RegisterOp(UnidirectionalSequenceLstmInit,
UnidirectionalSequenceLstmPrepare,
UnidirectionalSequenceLstmEvalInt8);
......
......@@ -579,27 +579,27 @@ TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {
} // namespace
TfLiteRegistration_V1 Register_EQUAL() {
TFLMRegistration Register_EQUAL() {
return tflite::micro::RegisterOp(Init, Prepare, EqualEval);
}
TfLiteRegistration_V1 Register_NOT_EQUAL() {
TFLMRegistration Register_NOT_EQUAL() {
return tflite::micro::RegisterOp(Init, Prepare, NotEqualEval);
}
TfLiteRegistration_V1 Register_GREATER() {
TFLMRegistration Register_GREATER() {
return tflite::micro::RegisterOp(Init, Prepare, GreaterEval);
}
TfLiteRegistration_V1 Register_GREATER_EQUAL() {
TFLMRegistration Register_GREATER_EQUAL() {
return tflite::micro::RegisterOp(Init, Prepare, GreaterEqualEval);
}
TfLiteRegistration_V1 Register_LESS() {
TFLMRegistration Register_LESS() {
return tflite::micro::RegisterOp(Init, Prepare, LessEval);
}
TfLiteRegistration_V1 Register_LESS_EQUAL() {
TFLMRegistration Register_LESS_EQUAL() {
return tflite::micro::RegisterOp(Init, Prepare, LessEqualEval);
}
......
......@@ -29,9 +29,8 @@ constexpr int inputs_size = 2;
constexpr int outputs_size = 1;
constexpr int tensors_size = inputs_size + outputs_size;
void TestComparison(const TfLiteRegistration_V1& registration,
TfLiteTensor* tensors, bool* expected_output_data,
bool* output_data) {
void TestComparison(const TFLMRegistration& registration, TfLiteTensor* tensors,
bool* expected_output_data, bool* output_data) {
const int output_dims_count = ElementCount(*tensors[inputs_size].dims);
int inputs_array_data[] = {2, 0, 1};
......@@ -50,7 +49,7 @@ void TestComparison(const TfLiteRegistration_V1& registration,
}
}
void TestComparisonFloat(const TfLiteRegistration_V1& registration,
void TestComparisonFloat(const TFLMRegistration& registration,
int* input1_dims_data, float* input1_data,
int* input2_dims_data, float* input2_data,
bool* expected_output_data, int* output_dims_data,
......@@ -68,7 +67,7 @@ void TestComparisonFloat(const TfLiteRegistration_V1& registration,
TestComparison(registration, tensors, expected_output_data, output_data);
}
void TestComparisonBool(const TfLiteRegistration_V1& registration,
void TestComparisonBool(const TFLMRegistration& registration,
int* input1_dims_data, bool* input1_data,
int* input2_dims_data, bool* input2_data,
bool* expected_output_data, int* output_dims_data,
......@@ -86,7 +85,7 @@ void TestComparisonBool(const TfLiteRegistration_V1& registration,
TestComparison(registration, tensors, expected_output_data, output_data);
}
void TestComparisonInt(const TfLiteRegistration_V1& registration,
void TestComparisonInt(const TFLMRegistration& registration,
int* input1_dims_data, int32_t* input1_data,
int* input2_dims_data, int32_t* input2_data,
bool* expected_output_data, int* output_dims_data,
......@@ -104,7 +103,7 @@ void TestComparisonInt(const TfLiteRegistration_V1& registration,
TestComparison(registration, tensors, expected_output_data, output_data);
}
void TestComparisonQuantizedInt8(const TfLiteRegistration_V1& registration,
void TestComparisonQuantizedInt8(const TFLMRegistration& registration,
int* input1_dims_data, float* input1_data,
int8_t* input1_quantized, float input1_scale,
int input1_zero_point, int* input2_dims_data,
......
......@@ -251,7 +251,7 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
} // namespace
TfLiteRegistration_V1 Register_CONCATENATION() {
TFLMRegistration Register_CONCATENATION() {
return tflite::micro::RegisterOp(Init, Prepare, Eval);
}
......
......@@ -46,7 +46,7 @@ void TestConcatenateOneInput(int* input1_dims_data, const T* input1_data,
.activation = kTfLiteActNone // Only activation supported in this impl
};
const TfLiteRegistration_V1 registration = Register_CONCATENATION();
const TFLMRegistration registration = Register_CONCATENATION();
micro::KernelRunner runner(registration, tensors, tensors_size, inputs_array,
outputs_array,
reinterpret_cast<void*>(&builtin_data));
......@@ -80,7 +80,7 @@ void TestConcatenateTwoInputs(int* input1_dims_data, const T* input1_data,
.activation = kTfLiteActNone // Only activation supported in this impl
};
const TfLiteRegistration_V1 registration = Register_CONCATENATION();
const TFLMRegistration registration = Register_CONCATENATION();
micro::KernelRunner runner(registration, tensors, tensors_size, inputs_array,
outputs_array,
reinterpret_cast<void*>(&builtin_data));
......@@ -134,7 +134,7 @@ void TestConcatenateQuantizedTwoInputs(
.activation = kTfLiteActNone // Only activation supported in this impl
};
const TfLiteRegistration_V1 registration = Register_CONCATENATION();
const TFLMRegistration registration = Register_CONCATENATION();
micro::KernelRunner runner(registration, tensors, tensors_size, inputs_array,
outputs_array,
reinterpret_cast<void*>(&builtin_data));
......
......@@ -161,7 +161,7 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
} // namespace
TfLiteRegistration_V1 Register_CONV_2D() {
TFLMRegistration Register_CONV_2D() {
return tflite::micro::RegisterOp(Init, ConvPrepare, Eval);
}
......
......@@ -19,8 +19,8 @@ limitations under the License.
#include <cstdint>
#include "tensorflow/lite/c/builtin_op_data.h"
#include "tensorflow/lite/c/common.h"
#include "tensorflow/lite/kernels/internal/types.h"
#include "tensorflow/lite/micro/micro_common.h"
namespace tflite {
......@@ -76,41 +76,37 @@ TfLiteStatus CalculateOpDataConv(TfLiteContext* context, TfLiteNode* node,
TfLiteStatus ConvPrepare(TfLiteContext* context, TfLiteNode* node);
// This is the most generic TfLiteRegistration_V1. The actual supported types
// This is the most generic TFLMRegistration. The actual supported types
// may still be target dependent. The only requirement is that every
// implementation (reference or optimized) must define this function.
TfLiteRegistration_V1 Register_CONV_2D();
TFLMRegistration Register_CONV_2D();
#if defined(XTENSA)
// Returns a TfLiteRegistration_V1 struct for kernel variant that only supports
// Returns a TFLMRegistration struct for kernel variant that only supports
// int8 activations and int8 weights and always calls the reference
// implementation.
TfLiteRegistration_V1 Register_CONV_2D_INT8REF();
TFLMRegistration Register_CONV_2D_INT8REF();
#else
inline TfLiteRegistration_V1 Register_CONV_2D_INT8REF() {
inline TFLMRegistration Register_CONV_2D_INT8REF() {
return Register_CONV_2D();
}
#endif
#if defined(CMSIS_NN)
// Returns a TfLiteRegistration_V1 struct for kernel variant that only supports
// Returns a TFLMRegistration struct for kernel variant that only supports
// int8 activations and int8 weights and uses the latency optimized
// implementations.
TfLiteRegistration_V1 Register_CONV_2D_INT8();
TFLMRegistration Register_CONV_2D_INT8();
// Returns a TfLiteRegistration_V1 struct for kernel variant that only supports
// Returns a TFLMRegistration struct for kernel variant that only supports
// int16 activations and int8 weights and uses the latency optimized
// implementations.
TfLiteRegistration_V1 Register_CONV_2D_INT16();
TFLMRegistration Register_CONV_2D_INT16();
#else
inline TfLiteRegistration_V1 Register_CONV_2D_INT8() {
return Register_CONV_2D();
}
inline TFLMRegistration Register_CONV_2D_INT8() { return Register_CONV_2D(); }
inline TfLiteRegistration_V1 Register_CONV_2D_INT16() {
return Register_CONV_2D();
}
inline TFLMRegistration Register_CONV_2D_INT16() { return Register_CONV_2D(); }
#endif
} // namespace tflite
......
......@@ -28,37 +28,35 @@ namespace testing {
TfLiteStatus InvokeConv(TfLiteTensor* tensors, int tensors_size,
int output_length, TfLiteConvParams* conv_params,
TfLiteRegistration_V1 registration, float* output_data);
TFLMRegistration registration, float* output_data);
TfLiteStatus InvokeConv(TfLiteTensor* tensors, int tensors_size,
int output_length, TfLiteConvParams* conv_params,
TfLiteRegistration_V1 registration,
int8_t* output_data);
TFLMRegistration registration, int8_t* output_data);
TfLiteStatus InvokeConv(TfLiteTensor* tensors, int tensors_size,
int output_length, TfLiteConvParams* conv_params,
TfLiteRegistration_V1 registration,
uint8_t* output_data);
TFLMRegistration registration, uint8_t* output_data);
TfLiteStatus ValidateConvGoldens(TfLiteTensor* tensors, int tensors_size,
const float* expected_output_data,
int output_length,
TfLiteConvParams* conv_params,
TfLiteRegistration_V1 registration,
TFLMRegistration registration,
float* output_data, float tolerance = 1e-5);
TfLiteStatus ValidateConvGoldens(TfLiteTensor* tensors, int tensors_size,
const int8_t* expected_output_data,
int output_length,
TfLiteConvParams* conv_params,
TfLiteRegistration_V1 registration,
TFLMRegistration registration,
int8_t* output_data, float tolerance = 1e-5);
TfLiteStatus ValidateConvGoldens(TfLiteTensor* tensors, int tensors_size,
const uint8_t* expected_output_data,
int output_length,
TfLiteConvParams* conv_params,
TfLiteRegistration_V1 registration,
TFLMRegistration registration,
uint8_t* output_data, float tolerance = 1e-5);
TfLiteStatus TestConvFloat(int* input_dims_data, const float* input_data,
......@@ -67,8 +65,7 @@ TfLiteStatus TestConvFloat(int* input_dims_data, const float* input_data,
int* output_dims_data,
const float* expected_output_data,
TfLiteConvParams* conv_params,
TfLiteRegistration_V1 registration,
float* output_data);
TFLMRegistration registration, float* output_data);
TfLiteStatus TestConvQuantizedPerLayer(
int* input_dims_data, const float* input_data, uint8_t* input_quantized,
......@@ -77,7 +74,7 @@ TfLiteStatus TestConvQuantizedPerLayer(
const float* bias_data, int32_t* bias_quantized, int* output_dims_data,
const float* expected_output_data, uint8_t* expected_output_quantized,
float output_scale, TfLiteConvParams* conv_params,
TfLiteRegistration_V1 registration, uint8_t* output_data);
TFLMRegistration registration, uint8_t* output_data);
TfLiteStatus TestConvQuantizedPerChannel(
int* input_dims_data, const float* input_data, int8_t* input_quantized,
......@@ -87,7 +84,7 @@ TfLiteStatus TestConvQuantizedPerChannel(
float* bias_scales, int* bias_zero_points, int* output_dims_data,
const float* expected_output_data, int8_t* expected_output_data_quantized,
float output_scale, int output_zero_point, TfLiteConvParams* conv_params,
TfLiteRegistration_V1 registration, int8_t* output_data,
TFLMRegistration registration, int8_t* output_data,
TfLiteType tensor_weight_type = kTfLiteNoType);
TfLiteStatus TestConvQuantizedPerChannel(
......@@ -99,7 +96,7 @@ TfLiteStatus TestConvQuantizedPerChannel(
int* bias_zero_points, int* output_dims_data,
const float* expected_output_data, int16_t* expected_output_data_quantized,
float output_scale, int output_zero_point, TfLiteConvParams* conv_params,
TfLiteRegistration_V1 registration, int16_t* output_data);
TFLMRegistration registration, int16_t* output_data);
TfLiteStatus TestConvQuantizedPerChannel(
int* input_dims_data, const float* input_data, int16_t* input_quantized,
......@@ -109,7 +106,7 @@ TfLiteStatus TestConvQuantizedPerChannel(
float* bias_scales, int* bias_zero_points, int* output_dims_data,
const float* expected_output_data, int16_t* expected_output_data_quantized,
float output_scale, int output_zero_point, TfLiteConvParams* conv_params,
TfLiteRegistration_V1 registration, int16_t* output_data);
TFLMRegistration registration, int16_t* output_data);
} // namespace testing
} // namespace tflite
......
......@@ -21,7 +21,7 @@ namespace testing {
template <typename T>
TfLiteStatus InvokeConv(TfLiteTensor* tensors, int tensors_size,
int output_length, TfLiteConvParams* conv_params,
TfLiteRegistration_V1 registration, T* output_data) {
TFLMRegistration registration, T* output_data) {
int inputs_array_data[] = {3, 0, 1, 2};
TfLiteIntArray* inputs_array = IntArrayFromInts(inputs_array_data);
int outputs_array_data[] = {1, 3};
......@@ -43,8 +43,8 @@ TfLiteStatus ValidateConvGoldens(TfLiteTensor* tensors, int tensors_size,
const T* expected_output_data,
int output_length,
TfLiteConvParams* conv_params,
TfLiteRegistration_V1 registration,
T* output_data, float tolerance) {
TFLMRegistration registration, T* output_data,
float tolerance) {
TfLiteStatus status = InvokeConv(tensors, tensors_size, output_length,
conv_params, registration, output_data);
if (status != kTfLiteOk) {
......@@ -59,16 +59,14 @@ TfLiteStatus ValidateConvGoldens(TfLiteTensor* tensors, int tensors_size,
TfLiteStatus InvokeConv(TfLiteTensor* tensors, int tensors_size,
int output_length, TfLiteConvParams* conv_params,
TfLiteRegistration_V1 registration,
float* output_data) {
TFLMRegistration registration, float* output_data) {
return InvokeConv<float>(tensors, tensors_size, output_length, conv_params,
registration, output_data);
}
TfLiteStatus InvokeConv(TfLiteTensor* tensors, int tensors_size,
int output_length, TfLiteConvParams* conv_params,
TfLiteRegistration_V1 registration,
int8_t* output_data) {
TFLMRegistration registration, int8_t* output_data) {
return InvokeConv<int8_t>(tensors, tensors_size, output_length, conv_params,
registration, output_data);
}
......@@ -77,7 +75,7 @@ TfLiteStatus ValidateConvGoldens(TfLiteTensor* tensors, int tensors_size,
const float* expected_output_data,
int output_length,
TfLiteConvParams* conv_params,
TfLiteRegistration_V1 registration,
TFLMRegistration registration,
float* output_data, float tolerance) {
return ValidateConvGoldens<float>(tensors, tensors_size, expected_output_data,
output_length, conv_params, registration,
......@@ -88,7 +86,7 @@ TfLiteStatus ValidateConvGoldens(TfLiteTensor* tensors, int tensors_size,
const int8_t* expected_output_data,
int output_length,
TfLiteConvParams* conv_params,
TfLiteRegistration_V1 registration,
TFLMRegistration registration,
int8_t* output_data, float tolerance) {
return ValidateConvGoldens<int8_t>(
tensors, tensors_size, expected_output_data, output_length, conv_params,
......@@ -101,8 +99,7 @@ TfLiteStatus TestConvFloat(int* input_dims_data, const float* input_data,
int* output_dims_data,
const float* expected_output_data,
TfLiteConvParams* conv_params,
TfLiteRegistration_V1 registration,
float* output_data) {
TFLMRegistration registration, float* output_data) {
TfLiteIntArray* input_dims = IntArrayFromInts(input_dims_data);
TfLiteIntArray* filter_dims = IntArrayFromInts(filter_dims_data);
TfLiteIntArray* bias_dims = IntArrayFromInts(bias_dims_data);
......@@ -132,7 +129,7 @@ TfLiteStatus TestConvQuantizedPerChannel(
float* bias_scales, int* bias_zero_points, int* output_dims_data,
const float* expected_output_data, T* expected_output_data_quantized,
float output_scale, int output_zero_point, TfLiteConvParams* conv_params,
TfLiteRegistration_V1 registration, T* output_data,
TFLMRegistration registration, T* output_data,
TfLiteType tensor_weight_type = kTfLiteNoType) {
TfLiteIntArray* input_dims = IntArrayFromInts(input_dims_data);
TfLiteIntArray* filter_dims = IntArrayFromInts(filter_dims_data);
......@@ -196,7 +193,7 @@ TfLiteStatus TestConvQuantizedPerChannel(
float* bias_scales, int* bias_zero_points, int* output_dims_data,
const float* expected_output_data, int8_t* expected_output_data_quantized,
float output_scale, int output_zero_point, TfLiteConvParams* conv_params,
TfLiteRegistration_V1 registration, int8_t* output_data,
TFLMRegistration registration, int8_t* output_data,
TfLiteType tensor_weight_type) {
return TestConvQuantizedPerChannel<int8_t, int32_t>(
input_dims_data, input_data, input_quantized, input_scale,
......@@ -217,7 +214,7 @@ TfLiteStatus TestConvQuantizedPerChannel(
int* bias_zero_points, int* output_dims_data,
const float* expected_output_data, int16_t* expected_output_data_quantized,
float output_scale, int output_zero_point, TfLiteConvParams* conv_params,
TfLiteRegistration_V1 registration, int16_t* output_data) {
TFLMRegistration registration, int16_t* output_data) {
return TestConvQuantizedPerChannel<int16_t, std::int64_t>(
input_dims_data, input_data, input_quantized, input_scale,
input_zero_point, filter_dims_data, filter_data, filter_data_quantized,
......@@ -236,7 +233,7 @@ TfLiteStatus TestConvQuantizedPerChannel(
float* bias_scales, int* bias_zero_points, int* output_dims_data,
const float* expected_output_data, int16_t* expected_output_data_quantized,
float output_scale, int output_zero_point, TfLiteConvParams* conv_params,
TfLiteRegistration_V1 registration, int16_t* output_data) {
TFLMRegistration registration, int16_t* output_data) {
return TestConvQuantizedPerChannel<int16_t, int32_t>(
input_dims_data, input_data, input_quantized, input_scale,
input_zero_point, filter_dims_data, filter_data, filter_data_quantized,
......
......@@ -168,7 +168,7 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
} // namespace
TfLiteRegistration_V1 Register_CUMSUM() {
TFLMRegistration Register_CUMSUM() {
return tflite::micro::RegisterOp(nullptr, Prepare, Eval);
}
......
......@@ -43,7 +43,7 @@ void ExecuteCumSumTest(CumSumTestParams& test_params, TfLiteTensor* tensors,
params.exclusive = test_params.exclusive;
params.reverse = test_params.reverse;
const TfLiteRegistration_V1 registration = tflite::Register_CUMSUM();
const TFLMRegistration registration = tflite::Register_CUMSUM();
micro::KernelRunner runner(registration, tensors, tensors_count, inputs_array,
outputs_array, static_cast<void*>(&params));
......
......@@ -77,7 +77,7 @@ TfLiteStatus CalculateOpData(TfLiteContext* context, TfLiteNode* node) {
// because TfLiteTensor in the MicroInterpreter is a temporary
// allocation. For the KernelRunner interpreter, TfLiteEvalTensor
// is a temporary allocation. We must therefore relocate the dims
// from the FlatBuffer to the persistant storage arena.
// from the FlatBuffer to the persistent storage arena.
TfLiteEvalTensor* output_eval =
tflite::micro::GetEvalOutput(context, node, kOutputTensor);
TF_LITE_ENSURE_OK(context, tflite::micro::CreateWritableTensorDimsWithCopy(
......@@ -135,7 +135,7 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
} // namespace
TfLiteRegistration_V1 Register_DEPTH_TO_SPACE() {
TFLMRegistration Register_DEPTH_TO_SPACE() {
return tflite::micro::RegisterOp(nullptr, Prepare, Eval);
}
......
......@@ -42,7 +42,7 @@ void ExecuteDepthToSpaceTest(const DepthToSpaceTestParams& params,
TfLiteDepthToSpaceParams op_params = {};
op_params.block_size = params.block_size;
const TfLiteRegistration_V1 registration = tflite::Register_DEPTH_TO_SPACE();
const TFLMRegistration registration = tflite::Register_DEPTH_TO_SPACE();
micro::KernelRunner runner(registration, tensors, tensors_count, inputs_array,
outputs_array, static_cast<void*>(&op_params));
......
......@@ -117,7 +117,7 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
} // namespace
TfLiteRegistration_V1 Register_DEPTHWISE_CONV_2D() {
TFLMRegistration Register_DEPTHWISE_CONV_2D() {
return tflite::micro::RegisterOp(Init, DepthwiseConvPrepare, Eval);
}
......
......@@ -49,28 +49,28 @@ TfLiteStatus CalculateOpDataDepthwiseConv(
TfLiteStatus DepthwiseConvPrepare(TfLiteContext* context, TfLiteNode* node);
// This is the most generic TfLiteRegistration_V1. The actual supported types
// This is the most generic TFLMRegistration. The actual supported types
// may still be target dependent. The only requirement is that every
// implementation (reference or optimized) must define this function.
TfLiteRegistration_V1 Register_DEPTHWISE_CONV_2D();
TFLMRegistration Register_DEPTHWISE_CONV_2D();
#if defined(CMSIS_NN)
// Returns a TfLiteRegistration_V1 struct for kernel variant that only supports
// Returns a TFLMRegistration struct for kernel variant that only supports
// int8 activations and int8 weights and uses the latency optimized
// implementations.
TfLiteRegistration_V1 Register_DEPTHWISE_CONV_2D_INT8();
TFLMRegistration Register_DEPTHWISE_CONV_2D_INT8();
// Returns a TfLiteRegistration_V1 struct for kernel variant that only supports
// Returns a TFLMRegistration struct for kernel variant that only supports
// int16 activations and int8 weights and uses the latency optimized
// implementations.
TfLiteRegistration_V1 Register_DEPTHWISE_CONV_2D_INT16();
TFLMRegistration Register_DEPTHWISE_CONV_2D_INT16();
#else
inline TfLiteRegistration_V1 Register_DEPTHWISE_CONV_2D_INT8() {
inline TFLMRegistration Register_DEPTHWISE_CONV_2D_INT8() {
return Register_DEPTHWISE_CONV_2D();
}
inline TfLiteRegistration_V1 Register_DEPTHWISE_CONV_2D_INT16() {
inline TFLMRegistration Register_DEPTHWISE_CONV_2D_INT16() {
return Register_DEPTHWISE_CONV_2D();
}
#endif
......
......@@ -48,7 +48,7 @@ TfLiteStatus ValidateDepthwiseConvGoldens(
int outputs_array_data[] = {1, 3};
TfLiteIntArray* outputs_array = IntArrayFromInts(outputs_array_data);
const TfLiteRegistration_V1 registration = Register_DEPTHWISE_CONV_2D();
const TFLMRegistration registration = Register_DEPTHWISE_CONV_2D();
micro::KernelRunner runner(registration, tensors, tensors_size, inputs_array,
outputs_array,
reinterpret_cast<void*>(conv_params));
......
......@@ -80,7 +80,7 @@ TfLiteStatus DequantizeEval(TfLiteContext* context, TfLiteNode* node) {
return kTfLiteOk;
}
TfLiteRegistration_V1 Register_DEQUANTIZE() {
TFLMRegistration Register_DEQUANTIZE() {
return tflite::micro::RegisterOp(DequantizeInit, DequantizePrepare,
DequantizeEval);
}
......
......@@ -32,7 +32,7 @@ void ValidateDequantizeGoldens(TfLiteTensor* tensors, int tensors_size,
int outputs_array_data[] = {1, 1};
TfLiteIntArray* outputs_array = IntArrayFromInts(outputs_array_data);
const TfLiteRegistration_V1 registration = tflite::Register_DEQUANTIZE();
const TFLMRegistration registration = tflite::Register_DEQUANTIZE();
micro::KernelRunner runner(registration, tensors, tensors_size, inputs_array,
outputs_array,
/*builtin_data=*/nullptr);
......
......@@ -799,9 +799,8 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
}
} // namespace
TfLiteRegistration_V1* Register_DETECTION_POSTPROCESS() {
static TfLiteRegistration_V1 r =
tflite::micro::RegisterOp(Init, Prepare, Eval);
TFLMRegistration* Register_DETECTION_POSTPROCESS() {
static TFLMRegistration r = tflite::micro::RegisterOp(Init, Prepare, Eval);
return &r;
}
......
......@@ -108,7 +108,7 @@ void TestDetectionPostprocess(int* input_dims_data1, const float* input_data1,
MicroMutableOpResolver<1> resolver;
TF_LITE_MICRO_EXPECT_EQ(resolver.AddDetectionPostprocess(), kTfLiteOk);
const TfLiteRegistration_V1* registration =
const TFLMRegistration* registration =
resolver.FindOp("TFLite_Detection_PostProcess");
TF_LITE_MICRO_EXPECT(registration != nullptr);
......
......@@ -201,7 +201,7 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
} // namespace
TfLiteRegistration_V1 Register_DIV() {
TFLMRegistration Register_DIV() {
return tflite::micro::RegisterOp(Init, Prepare, Eval);
}
......
......@@ -35,7 +35,7 @@ void ExecuteDivTest(TfLiteTensor* tensors, int tensors_count,
int kOutputArrayData[] = {1, 2};
TfLiteIntArray* outputs_array = IntArrayFromInts(kOutputArrayData);
const TfLiteRegistration_V1 registration = tflite::Register_DIV();
const TFLMRegistration registration = tflite::Register_DIV();
micro::KernelRunner runner(registration, tensors, tensors_count, inputs_array,
outputs_array, static_cast<void*>(&builtin_data));
......
......@@ -371,44 +371,44 @@ TfLiteStatus LogicalNotEval(TfLiteContext* context, TfLiteNode* node) {
} // namespace
TfLiteRegistration_V1 Register_ABS() {
TFLMRegistration Register_ABS() {
return tflite::micro::RegisterOp(
ElementWiseAbsRsqrtInit, PrepareAbsRsqrt<IsAbsSupportedType, kAbsNameId>,
AbsEval);
}
TfLiteRegistration_V1 Register_SIN() {
TFLMRegistration Register_SIN() {
return tflite::micro::RegisterOp(
nullptr, GenericPrepare<IsNumericSupportedType>, SinEval);
}
TfLiteRegistration_V1 Register_COS() {
TFLMRegistration Register_COS() {
return tflite::micro::RegisterOp(
nullptr, GenericPrepare<IsNumericSupportedType>, CosEval);
}
TfLiteRegistration_V1 Register_LOG() {
TFLMRegistration Register_LOG() {
return tflite::micro::RegisterOp(
nullptr, GenericPrepare<IsNumericSupportedType>, LogEval);
}
TfLiteRegistration_V1 Register_SQRT() {
TFLMRegistration Register_SQRT() {
return tflite::micro::RegisterOp(
nullptr, GenericPrepare<IsNumericSupportedType>, SqrtEval);
}
TfLiteRegistration_V1 Register_RSQRT() {
TFLMRegistration Register_RSQRT() {
return tflite::micro::RegisterOp(
ElementWiseAbsRsqrtInit,
PrepareAbsRsqrt<IsRsqrtSupportedType, kRsrqtNameId>, RsqrtEval);
}
TfLiteRegistration_V1 Register_SQUARE() {
TFLMRegistration Register_SQUARE() {
return tflite::micro::RegisterOp(
nullptr, GenericPrepare<IsNumericSupportedType>, SquareEval);
}
TfLiteRegistration_V1 Register_LOGICAL_NOT() {
TFLMRegistration Register_LOGICAL_NOT() {
return tflite::micro::RegisterOp(
nullptr, GenericPrepare<IsLogicalSupportedType>, LogicalNotEval);
}
......
......@@ -22,7 +22,7 @@ limitations under the License.
namespace tflite {
namespace testing {
void TestElementwiseFloat(const TfLiteRegistration_V1& registration,
void TestElementwiseFloat(const TFLMRegistration& registration,
int* input_dims_data, const float* input_data,
int* output_dims_data,
const float* expected_output_data,
......@@ -60,7 +60,7 @@ void TestElementwiseFloat(const TfLiteRegistration_V1& registration,
}
template <typename T>
void TestElementwiseQuantized(const TfLiteRegistration_V1& registration,
void TestElementwiseQuantized(const TFLMRegistration& registration,
int* input_dims_data, const float* input_data,
T* input_quantized, float input_scale,
int32_t input_zero_point, int* output_dims_data,
......@@ -115,7 +115,7 @@ void TestElementwiseQuantized(const TfLiteRegistration_V1& registration,
}
}
void TestElementwiseBool(const TfLiteRegistration_V1& registration,
void TestElementwiseBool(const TFLMRegistration& registration,
int* input_dims_data, const bool* input_data,
int* output_dims_data,
const bool* expected_output_data, bool* output_data) {
......
......@@ -144,7 +144,7 @@ TfLiteStatus EluEval(TfLiteContext* context, TfLiteNode* node) {
} // namespace
TfLiteRegistration_V1 Register_ELU() {
TFLMRegistration Register_ELU() {
return tflite::micro::RegisterOp(EluInit, EluPrepare, EluEval);
}
......
......@@ -59,7 +59,7 @@ void ExecuteEluTest(TfLiteTensor* tensors, int tensors_count) {
int kOutputArrayData[] = {1, 1};
TfLiteIntArray* outputs_array = IntArrayFromInts(kOutputArrayData);
const TfLiteRegistration_V1 registration = tflite::Register_ELU();
const TFLMRegistration registration = tflite::Register_ELU();
micro::KernelRunner runner(registration, tensors, tensors_count, inputs_array,
outputs_array, nullptr);
......
......@@ -163,9 +163,8 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
} // namespace
TfLiteRegistration_V1* Register_ETHOSU() {
static TfLiteRegistration_V1 r =
tflite::micro::RegisterOp(Init, Prepare, Eval);
TFLMRegistration* Register_ETHOSU() {
static TFLMRegistration r = tflite::micro::RegisterOp(Init, Prepare, Eval);
return &r;
}
......
......@@ -16,11 +16,11 @@ limitations under the License.
//
// This is a stub file for non-Ethos platforms
//
#include "tensorflow/lite/c/common.h"
#include "tensorflow/lite/micro/micro_common.h"
namespace tflite {
TfLiteRegistration_V1* Register_ETHOSU() { return nullptr; }
TFLMRegistration* Register_ETHOSU() { return nullptr; }
const char* GetString_ETHOSU() { return ""; }
......
......@@ -19,7 +19,7 @@ limitations under the License.
namespace tflite {
TfLiteRegistration_V1* Register_ETHOSU();
TFLMRegistration* Register_ETHOSU();
const char* GetString_ETHOSU();
......
......@@ -72,7 +72,7 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
}
} // namespace
TfLiteRegistration_V1 Register_EXP() {
TFLMRegistration Register_EXP() {
return tflite::micro::RegisterOp(nullptr, Prepare, Eval);
}
......
......@@ -42,7 +42,7 @@ void TestExp(int* input_dims_data, const float* input_data,
int outputs_array_data[] = {1, 1};
TfLiteIntArray* outputs_array = IntArrayFromInts(outputs_array_data);
const TfLiteRegistration_V1 registration = Register_EXP();
const TFLMRegistration registration = Register_EXP();
micro::KernelRunner runner(registration, tensors, tensors_size, inputs_array,
outputs_array,
/*builtin_data=*/nullptr);
......
......@@ -142,7 +142,7 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
}
} // namespace
TfLiteRegistration_V1 Register_EXPAND_DIMS() {
TFLMRegistration Register_EXPAND_DIMS() {
return tflite::micro::RegisterOp(nullptr, Prepare, Eval);
}
......
......@@ -40,9 +40,9 @@ micro::KernelRunner CreateExpandDimsKernelRunner(
const int32_t* axis_data, int* output_dims, T* output_data) {
// Some targets do not support dynamic memory (i.e., no malloc or new), thus,
// the test need to place non-transitent memories in static variables. This is
// safe because tests are guarateed to run serially.
// safe because tests are guaranteed to run serially.
// Both below structures are trivially destructible.
static TfLiteRegistration_V1 registration;
static TFLMRegistration registration;
static TfLiteTensor tensors[kTensorsSize];
TfLiteIntArray* in_dims = IntArrayFromInts(input_dims);
......
......@@ -133,7 +133,7 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
} // namespace
TfLiteRegistration_V1 Register_FILL() {
TFLMRegistration Register_FILL() {
return tflite::micro::RegisterOp(nullptr, Prepare, Eval);
}
......
......@@ -38,9 +38,9 @@ tflite::micro::KernelRunner CreateFillTestRunner(
ValueType* value_data, int* output_shape, OutputType* output_data) {
// Some targets do not support dynamic memory (i.e., no malloc or new), thus,
// the test need to place non-transitent memories in static variables. This is
// safe because tests are guarateed to run serially.
// safe because tests are guaranteed to run serially.
// Both below structures are trivially destructible.
static TfLiteRegistration_V1 registration;
static TFLMRegistration registration;
static TfLiteTensor tensors[3];
tensors[0] = CreateTensor(dims_data, IntArrayFromInts(dims_shape));
......
......@@ -41,7 +41,7 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
} // namespace
TfLiteRegistration_V1 Register_FLOOR() {
TFLMRegistration Register_FLOOR() {
return tflite::micro::RegisterOp(nullptr, nullptr, Eval);
}
......
......@@ -123,7 +123,7 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
} // namespace
TfLiteRegistration_V1 Register_FLOOR_DIV() {
TFLMRegistration Register_FLOOR_DIV() {
return tflite::micro::RegisterOp(Init, Prepare, Eval);
}
......
......@@ -31,7 +31,7 @@ void ExecuteFloorDivTest(TfLiteTensor* tensors, int tensors_count) {
int kOutputArrayData[] = {1, 2};
TfLiteIntArray* outputs_array = IntArrayFromInts(kOutputArrayData);
const TfLiteRegistration_V1 registration = tflite::Register_FLOOR_DIV();
const TFLMRegistration registration = tflite::Register_FLOOR_DIV();
micro::KernelRunner runner(registration, tensors, tensors_count, inputs_array,
outputs_array, nullptr);
......
......@@ -121,7 +121,7 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
} // namespace
TfLiteRegistration_V1 Register_FLOOR_MOD() {
TFLMRegistration Register_FLOOR_MOD() {
return tflite::micro::RegisterOp(Init, Prepare, Eval);
}
......
......@@ -31,7 +31,7 @@ void ExecuteFloorModTest(TfLiteTensor* tensors, int tensors_count) {
int kOutputArrayData[] = {1, 2};
TfLiteIntArray* outputs_array = IntArrayFromInts(kOutputArrayData);
const TfLiteRegistration_V1 registration = tflite::Register_FLOOR_MOD();
const TFLMRegistration registration = tflite::Register_FLOOR_MOD();
micro::KernelRunner runner(registration, tensors, tensors_count, inputs_array,
outputs_array, nullptr);
......
......@@ -42,7 +42,7 @@ void TestFloor(int* input_dims_data, const float* input_data,
int outputs_array_data[] = {1, 1};
TfLiteIntArray* outputs_array = IntArrayFromInts(outputs_array_data);
const TfLiteRegistration_V1 registration = Register_FLOOR();
const TFLMRegistration registration = Register_FLOOR();
micro::KernelRunner runner(registration, tensors, tensors_size, inputs_array,
outputs_array, /*builtin_data=*/nullptr);
......
......@@ -199,7 +199,7 @@ TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
} // namespace
TfLiteRegistration_V1 Register_FULLY_CONNECTED() {
TFLMRegistration Register_FULLY_CONNECTED() {
return tflite::micro::RegisterOp(Init, Prepare, Eval);
}
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。