File tree Expand file tree Collapse file tree 8 files changed +105
-2
lines changed
tensorflow/lite/micro/tools/make Expand file tree Collapse file tree 8 files changed +105
-2
lines changed Original file line number Diff line number Diff line change 1+ CODEGEN_HELLO_WORLD_SRCS := \
2+ $(TENSORFLOW_ROOT ) codegen/examples/hello_world/hello_world.cc \
3+ $(TENSORFLOW_ROOT ) codegen/examples/hello_world/hello_world_model.cc
4+
5+ CODEGEN_HELLO_WORLD_HDRS := \
6+ $(TENSORFLOW_ROOT ) codegen/examples/hello_world/hello_world_model.h
7+
8+ # Builds a standalone binary.
9+ $(eval $(call microlite_test,codegen_hello_world,\
10+ $(CODEGEN_HELLO_WORLD_SRCS),,))
Original file line number Diff line number Diff line change 1+ # Codegen Hello World Example
2+
3+ This is a code-generated example of the hello world model.
4+
5+ To generate the inference code at ` codegen/example/hello_world_model.h/.cc ` :
6+
7+ ```
8+ bazel run codegen:code_generator -- \
9+ --model $(pwd)/tensorflow/lite/micro/examples/hello_world/models/hello_world_int8.tflite \
10+ --output_dir $(pwd)/codegen/examples/hello_world \
11+ --output_name hello_world_model
12+ ```
13+
14+ To compile the generated source, you can use the Makefile:
15+
16+ ```
17+ make -f tensorflow/lite/micro/tools/make/Makefile codegen_hello_world
18+ ```
Original file line number Diff line number Diff line change 1+ /* Copyright 2023 The TensorFlow Authors. All Rights Reserved.
2+
3+ Licensed under the Apache License, Version 2.0 (the "License");
4+ you may not use this file except in compliance with the License.
5+ You may obtain a copy of the License at
6+
7+ http://www.apache.org/licenses/LICENSE-2.0
8+
9+ Unless required by applicable law or agreed to in writing, software
10+ distributed under the License is distributed on an "AS IS" BASIS,
11+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ See the License for the specific language governing permissions and
13+ limitations under the License.
14+ ==============================================================================*/
15+
16+ #include " hello_world_model.h"
17+
18+ int main (int argc, char ** argv) {
19+ hello_world_model::Invoke ();
20+
21+ return 0 ;
22+ }
Original file line number Diff line number Diff line change 1+ /* Copyright 2023 The TensorFlow Authors. All Rights Reserved.
2+
3+ Licensed under the Apache License, Version 2.0 (the "License");
4+ you may not use this file except in compliance with the License.
5+ You may obtain a copy of the License at
6+
7+ http://www.apache.org/licenses/LICENSE-2.0
8+
9+ Unless required by applicable law or agreed to in writing, software
10+ distributed under the License is distributed on an "AS IS" BASIS,
11+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ See the License for the specific language governing permissions and
13+ limitations under the License.
14+ ==============================================================================*/
15+
16+ /* AUTOMATICALLY GENERATED DO NOT MODIFY */
17+
18+ #include " hello_world_model.h"
19+
20+ namespace hello_world_model {
21+
22+ void Invoke () {}
23+
24+ } // namespace hello_world_model
Original file line number Diff line number Diff line change 1+ /* Copyright 2023 The TensorFlow Authors. All Rights Reserved.
2+
3+ Licensed under the Apache License, Version 2.0 (the "License");
4+ you may not use this file except in compliance with the License.
5+ You may obtain a copy of the License at
6+
7+ http://www.apache.org/licenses/LICENSE-2.0
8+
9+ Unless required by applicable law or agreed to in writing, software
10+ distributed under the License is distributed on an "AS IS" BASIS,
11+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ See the License for the specific language governing permissions and
13+ limitations under the License.
14+ ==============================================================================*/
15+
16+ /* AUTOMATICALLY GENERATED DO NOT MODIFY */
17+
18+ #pragma once
19+
20+ namespace hello_world_model {
21+
22+ void Invoke ();
23+
24+ } // namespace hello_world_model
Original file line number Diff line number Diff line change @@ -21,4 +21,4 @@ namespace ${model_name} {
2121
2222void Invoke() {}
2323
24- } // ${ model_name}
24+ } // namespace ${ model_name}
Original file line number Diff line number Diff line change @@ -21,4 +21,4 @@ namespace ${model_name} {
2121
2222void Invoke();
2323
24- } // ${ model_name}
24+ } // namespace ${ model_name}
Original file line number Diff line number Diff line change @@ -287,6 +287,8 @@ MICRO_LITE_BENCHMARKS := $(wildcard $(TENSORFLOW_ROOT)tensorflow/lite/micro/tool
287287MICROLITE_BENCHMARK_SRCS := \
288288$(wildcard $(TENSORFLOW_ROOT ) tensorflow/lite/micro/tools/benchmarking/* benchmark.cc)
289289
290+ MICRO_LITE_CODEGEN_EXAMPLES := $(shell find $(TENSORFLOW_ROOT ) codegen/examples/ -name Makefile.inc)
291+
290292MICROLITE_TEST_SRCS := \
291293$(TENSORFLOW_ROOT ) tensorflow/lite/micro/fake_micro_context_test.cc \
292294$(TENSORFLOW_ROOT ) tensorflow/lite/micro/flatbuffer_utils_test.cc \
@@ -676,6 +678,9 @@ INCLUDES += -I$(GENERATED_SRCS_DIR)$(TENSORFLOW_ROOT)
676678# Load the examples.
677679include $(MICRO_LITE_EXAMPLE_TESTS )
678680
681+ # Load codegen examples.
682+ include $(MICRO_LITE_CODEGEN_EXAMPLES )
683+
679684# Load the integration tests.
680685include $(MICRO_LITE_INTEGRATION_TESTS )
681686
You can’t perform that action at this time.
0 commit comments