├── .dockerignore ├── tflite ├── linux-jetson-nano │ ├── .gitignore │ ├── trt8 │ │ └── libei_debug.a │ ├── trt8.5.2 │ │ └── libei_debug.a │ ├── trt8.6.2 │ │ └── libei_debug.a │ ├── download.sh │ └── README.md ├── linux-armv7 │ ├── libruy.a │ ├── libXNNPACK.a │ ├── libcpuinfo.a │ ├── libfarmhash.a │ ├── libfft2d_alloc.a │ ├── libfft2d_fft4f2d.a │ ├── libfft2d_fftsg.a │ ├── libfft2d_fftsg2d.a │ ├── libfft2d_fftsg3d.a │ ├── libfft2d_shrtdct.a │ ├── libflatbuffers.a │ ├── libpthreadpool.a │ ├── libtensorflow-lite.a │ ├── libcpuinfo_internals.a │ └── libeight_bit_int_gemm.a ├── linux-x86 │ ├── libruy.a │ ├── libXNNPACK.a │ ├── libcpuinfo.a │ ├── libfarmhash.a │ ├── libfft2d_alloc.a │ ├── libfft2d_fftsg.a │ ├── libflatbuffers.a │ ├── libpthreadpool.a │ ├── libfft2d_fft4f2d.a │ ├── libfft2d_fftsg2d.a │ ├── libfft2d_fftsg3d.a │ ├── libfft2d_shrtdct.a │ ├── libtensorflow-lite.a │ ├── libcpuinfo_internals.a │ └── libeight_bit_int_gemm.a ├── mac-arm64 │ ├── libruy.a │ ├── libXNNPACK.a │ ├── libcpuinfo.a │ ├── libfarmhash.a │ ├── libfft2d_fftsg.a │ ├── libflatbuffers.a │ ├── libpthreadpool.a │ ├── libfft2d_fftsg2d.a │ └── libtensorflow-lite.a ├── mac-x86_64 │ ├── libruy.a │ ├── libXNNPACK.a │ ├── libcpuinfo.a │ ├── libfarmhash.a │ ├── libfft2d_fftsg.a │ ├── libflatbuffers.a │ ├── libpthreadpool.a │ ├── libfft2d_fftsg2d.a │ └── libtensorflow-lite.a ├── linux-aarch64 │ ├── libruy.a │ ├── libXNNPACK.a │ ├── libcpuinfo.a │ ├── libfarmhash.a │ ├── libfft2d_alloc.a │ ├── libfft2d_fftsg.a │ ├── libflatbuffers.a │ ├── libpthreadpool.a │ ├── libfft2d_fft4f2d.a │ ├── libfft2d_fftsg2d.a │ ├── libfft2d_fftsg3d.a │ ├── libfft2d_shrtdct.a │ ├── libtensorflow-lite.a │ ├── libcpuinfo_internals.a │ └── libeight_bit_int_gemm.a ├── .gitignore └── download_flex_delegates.sh ├── tensorflow-lite ├── tensorflow │ └── lite │ │ ├── c │ │ ├── exported_symbols.lds │ │ ├── version_script.lds │ │ ├── test_util.cc │ │ ├── c_api_opaque.h │ │ ├── c_api.h │ │ ├── builtin_op_data.h │ │ ├── c_api_experimental.h │ │ ├── c_api_types.h │ │ ├── test_util.h │ │ └── common.h │ │ ├── tflite_exported_symbols.lds │ │ ├── tflite_version_script.lds │ │ ├── experimental │ │ ├── acceleration │ │ │ └── mini_benchmark │ │ │ │ └── models │ │ │ │ └── blazeface_mlkit_v1.tfl │ │ └── resource │ │ │ └── initialization_status.cc │ │ ├── kernels │ │ ├── internal │ │ │ ├── optimized │ │ │ │ ├── integer_ops │ │ │ │ │ └── README.md │ │ │ │ ├── sse_check.h │ │ │ │ ├── neon_check.h │ │ │ │ ├── cpu_check.h │ │ │ │ └── cpu_check.cc │ │ │ ├── reference │ │ │ │ ├── integer_ops │ │ │ │ │ ├── README.md │ │ │ │ │ ├── mean.h │ │ │ │ │ └── lut.h │ │ │ │ ├── floor_div.h │ │ │ │ ├── neg.h │ │ │ │ ├── ceil.h │ │ │ │ ├── exp.h │ │ │ │ ├── fill.h │ │ │ │ ├── floor.h │ │ │ │ ├── elu.h │ │ │ │ ├── cast.h │ │ │ │ ├── comparisons.cc │ │ │ │ └── floor_mod.h │ │ │ ├── legacy_types.h │ │ │ ├── reduce_common.h │ │ │ ├── max.h │ │ │ ├── min.h │ │ │ ├── tensor_utils.cc │ │ │ ├── tensor_ctypes.cc │ │ │ ├── mfcc_dct.h │ │ │ ├── opaque_tensor_ctypes.cc │ │ │ ├── opaque_tensor_ctypes.h │ │ │ ├── cppmath.h │ │ │ ├── runtime_shape.cc │ │ │ └── tensor_ctypes.h │ │ ├── shim │ │ │ └── test_op │ │ │ │ ├── README.md │ │ │ │ ├── simple_tf_op.cc │ │ │ │ ├── simple_tf_op.h │ │ │ │ ├── tmpl_tf_op.h │ │ │ │ ├── tmpl_tflite_op.h │ │ │ │ ├── simple_tflite_op.h │ │ │ │ ├── simple_tflite_op.cc │ │ │ │ └── tmpl_tf_op.cc │ │ ├── pywrap_variable_ops.pyi │ │ ├── gradient │ │ │ ├── pywrap_gradient_ops.pyi │ │ │ ├── gradient_ops.cc │ │ │ ├── gradient_ops.h │ │ │ ├── bcast_grad_args.h │ │ │ └── gradient_ops_wrapper.cc │ │ ├── variants │ │ │ ├── py │ │ │ │ ├── register_list_ops_py.pyi │ │ │ │ └── register_list_ops_py.cc │ │ │ ├── register_list_ops.h │ │ │ └── README.md │ │ ├── perception │ │ │ ├── pywrap_perception_ops.pyi │ │ │ ├── perception_ops.h │ │ │ ├── perception_ops.cc │ │ │ └── perception_ops_wrapper.cc │ │ ├── deprecated_backends.cc │ │ ├── stablehlo_add.cc │ │ ├── stablehlo_multiply.cc │ │ ├── variable_ops_wrapper.cc │ │ ├── parse_example │ │ │ └── parse_example.h │ │ ├── register.h │ │ ├── stablehlo_min_max.cc │ │ ├── builtin_op_kernels.h │ │ ├── register_ref.h │ │ ├── cpu_backend_gemm_eigen.h │ │ ├── fully_connected.h │ │ └── rng_util.h │ │ ├── README.md │ │ ├── core │ │ ├── async │ │ │ ├── README.md │ │ │ ├── interop │ │ │ │ ├── c │ │ │ │ │ ├── constants.cc │ │ │ │ │ └── types.cc │ │ │ │ └── variant.cc │ │ │ ├── testing │ │ │ │ └── mock_async_kernel.h │ │ │ ├── backend_async_kernel_interface.h │ │ │ ├── common.h │ │ │ └── c │ │ │ │ ├── types.h │ │ │ │ └── internal.h │ │ ├── api │ │ │ ├── tensor_utils.h │ │ │ ├── error_reporter.cc │ │ │ └── verifier.h │ │ ├── README.md │ │ ├── model.h │ │ ├── create_op_resolver_with_builtin_ops.cc │ │ └── create_op_resolver.h │ │ ├── context.h │ │ ├── builtin_op_data.h │ │ ├── string_type.h │ │ ├── model.h │ │ ├── op_resolver.h │ │ ├── error_reporter.h │ │ ├── interpreter.h │ │ ├── profiling │ │ ├── time.h │ │ ├── platform_profiler.h │ │ ├── atrace_profiler.h │ │ ├── signpost_profiler.h │ │ ├── profiler.h │ │ └── noop_profiler.h │ │ ├── model_builder.h │ │ ├── array.cc │ │ ├── create_op_resolver.h │ │ ├── interpreter_builder.h │ │ ├── logger.cc │ │ ├── tflite_with_xnnpack_optional.h │ │ ├── stderr_reporter.cc │ │ ├── namespace.h │ │ ├── stateful_error_reporter.h │ │ ├── stderr_reporter.h │ │ ├── tflite_with_xnnpack.cc │ │ ├── signature_runner.h │ │ ├── optional_debug_tools.h │ │ ├── create_op_resolver_with_builtin_ops.cc │ │ ├── internal │ │ └── signature_def.h │ │ ├── version.h │ │ ├── create_op_resolver_with_selected_ops.cc │ │ ├── type_to_tflitetype.h │ │ ├── external_cpu_backend_context.cc │ │ └── minimal_logging_default.cc └── flatbuffers │ ├── pch │ ├── pch.h │ └── flatc_pch.h │ ├── flex_flat_util.h │ ├── bfbs_generator.h │ ├── file_manager.h │ ├── buffer_ref.h │ └── struct.h ├── .gitmodules ├── tidl-rt └── linux-aarch64 │ ├── libdlr.so │ ├── libonnxruntime.so │ ├── libvx_tidl_rt.so │ └── libti_rpmsg_char.so ├── third_party ├── pybind11 │ ├── common.h │ └── LICENSE ├── ethos-u-driver-stack-imx │ ├── README.md │ └── Linux-syscall-note └── rapidjson │ └── internal │ └── swap.h ├── .gitignore └── LICENSE /.dockerignore: -------------------------------------------------------------------------------- 1 | opencv/ 2 | *.o 3 | *.d 4 | -------------------------------------------------------------------------------- /tflite/linux-jetson-nano/.gitignore: -------------------------------------------------------------------------------- 1 | *.zip 2 | *.so 3 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/c/exported_symbols.lds: -------------------------------------------------------------------------------- 1 | _TfLite* 2 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/tflite_exported_symbols.lds: -------------------------------------------------------------------------------- 1 | *TfLite* 2 | *tflite* 3 | *TFL_* 4 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "ingestion-sdk-c"] 2 | path = ingestion-sdk-c 3 | url = https://github.com/edgeimpulse/ingestion-sdk-c 4 | -------------------------------------------------------------------------------- /tflite/linux-armv7/libruy.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-armv7/libruy.a -------------------------------------------------------------------------------- /tflite/linux-x86/libruy.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-x86/libruy.a -------------------------------------------------------------------------------- /tflite/mac-arm64/libruy.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/mac-arm64/libruy.a -------------------------------------------------------------------------------- /tflite/mac-x86_64/libruy.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/mac-x86_64/libruy.a -------------------------------------------------------------------------------- /tflite/linux-aarch64/libruy.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-aarch64/libruy.a -------------------------------------------------------------------------------- /tflite/linux-x86/libXNNPACK.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-x86/libXNNPACK.a -------------------------------------------------------------------------------- /tflite/linux-x86/libcpuinfo.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-x86/libcpuinfo.a -------------------------------------------------------------------------------- /tflite/mac-arm64/libXNNPACK.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/mac-arm64/libXNNPACK.a -------------------------------------------------------------------------------- /tflite/mac-arm64/libcpuinfo.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/mac-arm64/libcpuinfo.a -------------------------------------------------------------------------------- /tflite/linux-armv7/libXNNPACK.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-armv7/libXNNPACK.a -------------------------------------------------------------------------------- /tflite/linux-armv7/libcpuinfo.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-armv7/libcpuinfo.a -------------------------------------------------------------------------------- /tflite/linux-armv7/libfarmhash.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-armv7/libfarmhash.a -------------------------------------------------------------------------------- /tflite/linux-x86/libfarmhash.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-x86/libfarmhash.a -------------------------------------------------------------------------------- /tflite/mac-arm64/libfarmhash.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/mac-arm64/libfarmhash.a -------------------------------------------------------------------------------- /tflite/mac-x86_64/libXNNPACK.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/mac-x86_64/libXNNPACK.a -------------------------------------------------------------------------------- /tflite/mac-x86_64/libcpuinfo.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/mac-x86_64/libcpuinfo.a -------------------------------------------------------------------------------- /tflite/mac-x86_64/libfarmhash.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/mac-x86_64/libfarmhash.a -------------------------------------------------------------------------------- /tidl-rt/linux-aarch64/libdlr.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tidl-rt/linux-aarch64/libdlr.so -------------------------------------------------------------------------------- /tflite/linux-aarch64/libXNNPACK.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-aarch64/libXNNPACK.a -------------------------------------------------------------------------------- /tflite/linux-aarch64/libcpuinfo.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-aarch64/libcpuinfo.a -------------------------------------------------------------------------------- /tflite/linux-aarch64/libfarmhash.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-aarch64/libfarmhash.a -------------------------------------------------------------------------------- /tflite/linux-x86/libfft2d_alloc.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-x86/libfft2d_alloc.a -------------------------------------------------------------------------------- /tflite/linux-x86/libfft2d_fftsg.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-x86/libfft2d_fftsg.a -------------------------------------------------------------------------------- /tflite/linux-x86/libflatbuffers.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-x86/libflatbuffers.a -------------------------------------------------------------------------------- /tflite/linux-x86/libpthreadpool.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-x86/libpthreadpool.a -------------------------------------------------------------------------------- /tflite/mac-arm64/libfft2d_fftsg.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/mac-arm64/libfft2d_fftsg.a -------------------------------------------------------------------------------- /tflite/mac-arm64/libflatbuffers.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/mac-arm64/libflatbuffers.a -------------------------------------------------------------------------------- /tflite/mac-arm64/libpthreadpool.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/mac-arm64/libpthreadpool.a -------------------------------------------------------------------------------- /tflite/mac-x86_64/libfft2d_fftsg.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/mac-x86_64/libfft2d_fftsg.a -------------------------------------------------------------------------------- /tflite/mac-x86_64/libflatbuffers.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/mac-x86_64/libflatbuffers.a -------------------------------------------------------------------------------- /tflite/mac-x86_64/libpthreadpool.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/mac-x86_64/libpthreadpool.a -------------------------------------------------------------------------------- /tflite/linux-aarch64/libfft2d_alloc.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-aarch64/libfft2d_alloc.a -------------------------------------------------------------------------------- /tflite/linux-aarch64/libfft2d_fftsg.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-aarch64/libfft2d_fftsg.a -------------------------------------------------------------------------------- /tflite/linux-aarch64/libflatbuffers.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-aarch64/libflatbuffers.a -------------------------------------------------------------------------------- /tflite/linux-aarch64/libpthreadpool.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-aarch64/libpthreadpool.a -------------------------------------------------------------------------------- /tflite/linux-armv7/libfft2d_alloc.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-armv7/libfft2d_alloc.a -------------------------------------------------------------------------------- /tflite/linux-armv7/libfft2d_fft4f2d.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-armv7/libfft2d_fft4f2d.a -------------------------------------------------------------------------------- /tflite/linux-armv7/libfft2d_fftsg.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-armv7/libfft2d_fftsg.a -------------------------------------------------------------------------------- /tflite/linux-armv7/libfft2d_fftsg2d.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-armv7/libfft2d_fftsg2d.a -------------------------------------------------------------------------------- /tflite/linux-armv7/libfft2d_fftsg3d.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-armv7/libfft2d_fftsg3d.a -------------------------------------------------------------------------------- /tflite/linux-armv7/libfft2d_shrtdct.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-armv7/libfft2d_shrtdct.a -------------------------------------------------------------------------------- /tflite/linux-armv7/libflatbuffers.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-armv7/libflatbuffers.a -------------------------------------------------------------------------------- /tflite/linux-armv7/libpthreadpool.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-armv7/libpthreadpool.a -------------------------------------------------------------------------------- /tflite/linux-x86/libfft2d_fft4f2d.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-x86/libfft2d_fft4f2d.a -------------------------------------------------------------------------------- /tflite/linux-x86/libfft2d_fftsg2d.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-x86/libfft2d_fftsg2d.a -------------------------------------------------------------------------------- /tflite/linux-x86/libfft2d_fftsg3d.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-x86/libfft2d_fftsg3d.a -------------------------------------------------------------------------------- /tflite/linux-x86/libfft2d_shrtdct.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-x86/libfft2d_shrtdct.a -------------------------------------------------------------------------------- /tflite/linux-x86/libtensorflow-lite.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-x86/libtensorflow-lite.a -------------------------------------------------------------------------------- /tflite/mac-arm64/libfft2d_fftsg2d.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/mac-arm64/libfft2d_fftsg2d.a -------------------------------------------------------------------------------- /tflite/mac-arm64/libtensorflow-lite.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/mac-arm64/libtensorflow-lite.a -------------------------------------------------------------------------------- /tflite/mac-x86_64/libfft2d_fftsg2d.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/mac-x86_64/libfft2d_fftsg2d.a -------------------------------------------------------------------------------- /third_party/pybind11/common.h: -------------------------------------------------------------------------------- 1 | #include "detail/common.h" 2 | #warning "Including 'common.h' is deprecated. It will be removed in v3.0. Use 'pybind11.h'." 3 | -------------------------------------------------------------------------------- /tflite/linux-aarch64/libfft2d_fft4f2d.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-aarch64/libfft2d_fft4f2d.a -------------------------------------------------------------------------------- /tflite/linux-aarch64/libfft2d_fftsg2d.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-aarch64/libfft2d_fftsg2d.a -------------------------------------------------------------------------------- /tflite/linux-aarch64/libfft2d_fftsg3d.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-aarch64/libfft2d_fftsg3d.a -------------------------------------------------------------------------------- /tflite/linux-aarch64/libfft2d_shrtdct.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-aarch64/libfft2d_shrtdct.a -------------------------------------------------------------------------------- /tflite/linux-armv7/libtensorflow-lite.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-armv7/libtensorflow-lite.a -------------------------------------------------------------------------------- /tflite/linux-x86/libcpuinfo_internals.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-x86/libcpuinfo_internals.a -------------------------------------------------------------------------------- /tflite/mac-x86_64/libtensorflow-lite.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/mac-x86_64/libtensorflow-lite.a -------------------------------------------------------------------------------- /tidl-rt/linux-aarch64/libonnxruntime.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tidl-rt/linux-aarch64/libonnxruntime.so -------------------------------------------------------------------------------- /tidl-rt/linux-aarch64/libvx_tidl_rt.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tidl-rt/linux-aarch64/libvx_tidl_rt.so -------------------------------------------------------------------------------- /tflite/linux-aarch64/libtensorflow-lite.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-aarch64/libtensorflow-lite.a -------------------------------------------------------------------------------- /tflite/linux-armv7/libcpuinfo_internals.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-armv7/libcpuinfo_internals.a -------------------------------------------------------------------------------- /tflite/linux-armv7/libeight_bit_int_gemm.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-armv7/libeight_bit_int_gemm.a -------------------------------------------------------------------------------- /tflite/linux-x86/libeight_bit_int_gemm.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-x86/libeight_bit_int_gemm.a -------------------------------------------------------------------------------- /tidl-rt/linux-aarch64/libti_rpmsg_char.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tidl-rt/linux-aarch64/libti_rpmsg_char.so -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/tflite_version_script.lds: -------------------------------------------------------------------------------- 1 | VERS_1.0 { 2 | global: 3 | *TfLite*; 4 | *tflite*; 5 | *TFL_*; 6 | local: 7 | *; 8 | }; 9 | -------------------------------------------------------------------------------- /tflite/linux-aarch64/libcpuinfo_internals.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-aarch64/libcpuinfo_internals.a -------------------------------------------------------------------------------- /tflite/linux-aarch64/libeight_bit_int_gemm.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-aarch64/libeight_bit_int_gemm.a -------------------------------------------------------------------------------- /tflite/linux-jetson-nano/trt8/libei_debug.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-jetson-nano/trt8/libei_debug.a -------------------------------------------------------------------------------- /tflite/linux-jetson-nano/trt8.5.2/libei_debug.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-jetson-nano/trt8.5.2/libei_debug.a -------------------------------------------------------------------------------- /tflite/linux-jetson-nano/trt8.6.2/libei_debug.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tflite/linux-jetson-nano/trt8.6.2/libei_debug.a -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/c/version_script.lds: -------------------------------------------------------------------------------- 1 | VERS_1.0 { 2 | # Export symbols in c_api.h. 3 | global: 4 | TfLite*; 5 | 6 | # Hide everything else. 7 | local: 8 | *; 9 | }; 10 | -------------------------------------------------------------------------------- /tflite/.gitignore: -------------------------------------------------------------------------------- 1 | linux-aarch64/libtensorflowlite_flex_2.6.5.so 2 | linux-armv7/libtensorflowlite_flex_2.6.5.so 3 | linux-x86/libtensorflowlite_flex_2.6.5.so 4 | mac-x86_64/libtensorflowlite_flex_2.6.5.dylib 5 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/experimental/acceleration/mini_benchmark/models/blazeface_mlkit_v1.tfl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/edgeimpulse/example-standalone-inferencing-linux/HEAD/tensorflow-lite/tensorflow/lite/experimental/acceleration/mini_benchmark/models/blazeface_mlkit_v1.tfl -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | *.gcda 3 | deploy.zip 4 | *.o 5 | convert/node_modules/ 6 | tflite-model/ 7 | model-parameters/ 8 | edge-impulse-sdk 9 | features.txt 10 | images/ 11 | convert/ 12 | output.*.txt 13 | out/ 14 | features*.txt 15 | opencv/ 16 | *.onnx 17 | convert-savedmodel/saved_model/ 18 | debug.bmp 19 | .DS_Store 20 | *.avi 21 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/internal/optimized/integer_ops/README.md: -------------------------------------------------------------------------------- 1 | This directory contains optimized implementations for int8 fully integer kernels. 2 | 3 | Weight filters of convs are expected to be symmetric per-channel quantized in 4 | the range [-127, 127]. 5 | Inputs/activations are expected to be asymmetric per-layer quantized in the 6 | range [-128, 127]. 7 | 8 | THESE ARE EXPERIMENTAL AND PRONE TO CHANGE. 9 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/internal/reference/integer_ops/README.md: -------------------------------------------------------------------------------- 1 | This directory contains reference implementations for int8 fully integer kernels. 2 | 3 | Weight filters of convs are expected to be symmetric per-channel quantized in 4 | the range [-127, 127]. 5 | Inputs/activations are expected to be asymmetric per-layer quantized in the 6 | range [-128, 127]. 7 | 8 | THESE ARE EXPERIMENTAL AND PRONE TO CHANGE. 9 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/README.md: -------------------------------------------------------------------------------- 1 | # TensorFlow Lite 2 | 3 | TensorFlow Lite is TensorFlow's lightweight solution for mobile and embedded 4 | devices. It enables low-latency inference of on-device machine learning models 5 | with a small binary size and fast performance supporting hardware acceleration. 6 | 7 | See the documentation: https://www.tensorflow.org/lite/ 8 | Documentation edits can be made here: [tensorflow/lite/g3doc](./g3doc/) 9 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/shim/test_op/README.md: -------------------------------------------------------------------------------- 1 | This directory contains a fake operation in order to demonstrate and test the 2 | interfaces. 3 | 4 | First test op `SimpleOp` which is an op that test various attributes and input 5 | and output types. The other one is `TmplOp` which tests a templatized kernel. 6 | 7 | The contents: 8 | 9 | ## `simple_op.h|cc`, `tmpl_op.h|cc` 10 | 11 | This is where the actual implementation of this op resides 12 | 13 | ## `simple_tf_op.cc`, `tmpl_tf_op.cc` 14 | 15 | The TF op definition. 16 | 17 | ## `simple_tflite_op.h|cc` 18 | 19 | The TFLite op definition. 20 | -------------------------------------------------------------------------------- /tflite/linux-jetson-nano/download.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )" 5 | 6 | TRT8="shared-libs-jetpack4.6.x.zip" 7 | TRT8_5_2="shared-libs-jetpack5.1.x.zip" 8 | TRT8_6_2="shared-libs-jetpack6.0.0.zip" 9 | 10 | download_lib() { 11 | dir="$1" 12 | zip_file="$2" 13 | 14 | mkdir -p "$dir" 15 | cd "$dir" 16 | rm -rf *.so 17 | wget https://cdn.edgeimpulse.com/build-system/"$zip_file" 18 | unzip -q "$zip_file" 19 | rm -rf "$zip_file" 20 | } 21 | 22 | download_lib "$SCRIPTPATH"/trt8 "$TRT8" 23 | download_lib "$SCRIPTPATH"/trt8.5.2 "$TRT8_5_2" 24 | download_lib "$SCRIPTPATH"/trt8.6.2 "$TRT8_6_2" -------------------------------------------------------------------------------- /tflite/linux-jetson-nano/README.md: -------------------------------------------------------------------------------- 1 | The `trt8.5.2/libei_debug.a` file was built from: https://github.com/edgeimpulse/TensorRT/tree/libeirt-tensorrt-8.5.2 - build using: 2 | 3 | ``` 4 | $ sh docker/build.sh --file docker/ubuntu-cross-aarch64.Dockerfile --tag tensorrt --cuda 11.8.0 5 | ``` 6 | 7 | The `trt8/libei_debug.a` file was built from: https://github.com/edgeimpulse/TensorRT/tree/libeirt - build using: 8 | 9 | ``` 10 | $ sh docker/build.sh --file docker/ubuntu-cross-aarch64.Dockerfile --tag tensorrt --cuda 10.2 11 | ``` 12 | 13 | You can find the library in `/workspace/TensorRT/build/out/libei_debug.a` in the container. It is also automatically copied after a successful build to the /docker folder. 14 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/core/async/README.md: -------------------------------------------------------------------------------- 1 | # TfLite asynchronous execution 2 | 3 | WARNING: This feature is experimental and subject to change. 4 | 5 | Experimental support for TFLite asynchronous execution and interoperability. 6 | 7 | ## Directory structure 8 | 9 | | Directory | Description | 10 | | ------------------ | --------------------------------------------------- | 11 | | `/async` | Asynchronous execution APIs. Definition for async kernel. | 12 | | `/async/interop` | Data structures supporting buffer and sync object interop. Reconciliation functions for buffer / sync attributes. | 13 | | `/async/interop/c` | C APIs for buffer and sync object interop. | 14 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/pywrap_variable_ops.pyi: -------------------------------------------------------------------------------- 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 | def VariableOpsRegisterer(arg0: int) -> None: ... 17 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/gradient/pywrap_gradient_ops.pyi: -------------------------------------------------------------------------------- 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 | def GradientOpsRegisterer(arg0: int) -> None: ... 17 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/variants/py/register_list_ops_py.pyi: -------------------------------------------------------------------------------- 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 | def TFLRegisterListOps(arg0: int) -> None: ... 17 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/perception/pywrap_perception_ops.pyi: -------------------------------------------------------------------------------- 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 | def PerceptionOpsRegisterer(arg0: int) -> None: ... 17 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/c/test_util.cc: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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 | #include "tensorflow-lite/tensorflow/lite/c/test_util.h" 16 | 17 | int TfLiteInitializeShimsForTest() { 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /third_party/ethos-u-driver-stack-imx/README.md: -------------------------------------------------------------------------------- 1 | # Linux driver stack for Arm(R) Ethos(TM)-U 2 | 3 | The driver was imported from [The Ethos-U Driver Stack iMX](https://github.com/nxp-imx/ethos-u-driver-stack-imx/tree/2acb7e2626fe3ff8764019e385829105a6e210bb) 4 | 5 | The [most recent version](https://github.com/nxp-imx/ethos-u-driver-stack-imx/tree/lf-6.6.3_1.0.0) 6 | 7 | # Licenses 8 | 9 | The kernel drivers are provided under a GPL v2 license. All other software 10 | components are provided under an Apache 2.0 license. 11 | 12 | Please see [LICENSE-APACHE-2.0.txt](LICENSE-APACHE-2.0.txt), 13 | [LICENSE-GPL-2.0.txt](LICENSE-GPL-2.0.txt) and [Linux-syscall-note](Linux-syscall-note) 14 | for more information. 15 | 16 | # Security 17 | 18 | Please see [Security](SECURITY.md). 19 | 20 | # Trademark notice 21 | 22 | Arm, Cortex and Ethos are registered trademarks of Arm Limited (or its 23 | subsidiaries) in the US and/or elsewhere. 24 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/core/async/interop/c/constants.cc: -------------------------------------------------------------------------------- 1 | /* Copyright 2022 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 | #include "tensorflow-lite/tensorflow/lite/core/async/interop/c/constants.h" 16 | 17 | extern "C" { 18 | 19 | const char kTfLiteSyncTypeNoSyncObj[] = "no_sync_obj"; 20 | 21 | } // extern "C" 22 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/context.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2017 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 | // Compatibility shim for moved header location. 16 | #ifndef TENSORFLOW_LITE_CONTEXT_H_ 17 | #define TENSORFLOW_LITE_CONTEXT_H_ 18 | 19 | #include "tensorflow-lite/tensorflow/lite/core/c/common.h" 20 | 21 | #endif // TENSORFLOW_LITE_CONTEXT_H_ 22 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/internal/reference/integer_ops/mean.h: -------------------------------------------------------------------------------- 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 | #ifndef TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_INTEGER_OPS_MEAN_H_ 16 | #define TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_INTEGER_OPS_MEAN_H_ 17 | 18 | #endif // TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_INTEGER_OPS_MEAN_H_ 19 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/builtin_op_data.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2017 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 | // Compatibility shim for new location of interface definitions. 16 | 17 | #ifndef TENSORFLOW_LITE_BUILTIN_OP_DATA_H_ 18 | #define TENSORFLOW_LITE_BUILTIN_OP_DATA_H_ 19 | 20 | #include "tensorflow-lite/tensorflow/lite/core/c/builtin_op_data.h" 21 | 22 | #endif // TENSORFLOW_LITE_BUILTIN_OP_DATA_H_ 23 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/c/c_api_opaque.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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 | #ifndef TENSORFLOW_LITE_C_C_API_OPAQUE_H_ 16 | #define TENSORFLOW_LITE_C_C_API_OPAQUE_H_ 17 | 18 | /// For documentation, see 19 | /// third_party/tensorflow/lite/core/c/c_api_opaque.h 20 | 21 | #include "tensorflow-lite/tensorflow/lite/core/c/c_api_opaque.h" 22 | 23 | #endif // TENSORFLOW_LITE_C_C_API_OPAQUE_H_ 24 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/string_type.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2017 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 | // Abstract string. We don't want even absl at this level. 16 | #ifndef TENSORFLOW_LITE_STRING_TYPE_H_ 17 | #define TENSORFLOW_LITE_STRING_TYPE_H_ 18 | 19 | #include 20 | 21 | namespace tflite { 22 | 23 | using std::string; 24 | 25 | } // namespace tflite 26 | 27 | #endif // TENSORFLOW_LITE_STRING_TYPE_H_ 28 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/c/c_api.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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 | #ifndef TENSORFLOW_LITE_C_C_API_H_ 16 | #define TENSORFLOW_LITE_C_C_API_H_ 17 | 18 | /// \file 19 | /// 20 | /// C API for TensorFlow Lite. 21 | /// 22 | /// For documentation, see tensorflow/lite/core/c/c_api.h 23 | 24 | #include "tensorflow-lite/tensorflow/lite/core/c/c_api.h" 25 | 26 | #endif // TENSORFLOW_LITE_C_C_API_H_ 27 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/c/builtin_op_data.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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 | #ifndef TENSORFLOW_LITE_C_BUILTIN_OP_DATA_H_ 16 | #define TENSORFLOW_LITE_C_BUILTIN_OP_DATA_H_ 17 | 18 | /// For documentation, see 19 | /// third_party/tensorflow/lite/core/c/builtin_op_data.h 20 | 21 | #include "tensorflow-lite/tensorflow/lite/core/c/builtin_op_data.h" 22 | 23 | #endif // TENSORFLOW_LITE_C_BUILTIN_OP_DATA_H_ 24 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/c/c_api_experimental.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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 | #ifndef TENSORFLOW_LITE_C_C_API_EXPERIMENTAL_H_ 16 | #define TENSORFLOW_LITE_C_C_API_EXPERIMENTAL_H_ 17 | 18 | /// For documentation, see 19 | /// third_party/tensorflow/lite/core/c/c_api_experimental.h 20 | 21 | #include "tensorflow-lite/tensorflow/lite/core/c/c_api_experimental.h" 22 | 23 | #endif // TENSORFLOW_LITE_C_C_API_EXPERIMENTAL_H_ 24 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/c/c_api_types.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2022 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 | #ifndef TENSORFLOW_LITE_C_C_API_TYPES_H_ 16 | #define TENSORFLOW_LITE_C_C_API_TYPES_H_ 17 | 18 | /// \file 19 | /// 20 | /// C API types for TensorFlow Lite. 21 | /// 22 | /// For documentation, see tensorflow/lite/core/c/c_api_types.h 23 | 24 | #include "tensorflow-lite/tensorflow/lite/core/c/c_api_types.h" 25 | 26 | #endif // TENSORFLOW_LITE_C_C_API_TYPES_H_ 27 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/model.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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 | #ifndef TENSORFLOW_LITE_CORE_SHIMS_CC_MODEL_H_ 16 | #define TENSORFLOW_LITE_CORE_SHIMS_CC_MODEL_H_ 17 | 18 | /// For documentation, see third_party/tensorflow/lite/core/model.h. 19 | 20 | #include "tensorflow-lite/tensorflow/lite/interpreter_builder.h" 21 | #include "tensorflow-lite/tensorflow/lite/model_builder.h" 22 | 23 | #endif // TENSORFLOW_LITE_CORE_SHIMS_CC_MODEL_H_ 24 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/op_resolver.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2018 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 | // Compatibility shim for moved header location. 16 | #ifndef TENSORFLOW_LITE_OP_RESOLVER_H_ 17 | #define TENSORFLOW_LITE_OP_RESOLVER_H_ 18 | 19 | #include "tensorflow-lite/tensorflow/lite/core/api/op_resolver.h" // IWYU pragma: export 20 | #include "tensorflow-lite/tensorflow/lite/mutable_op_resolver.h" // IWYU pragma: export 21 | 22 | #endif // TENSORFLOW_LITE_OP_RESOLVER_H_ 23 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/error_reporter.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2017 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 | // Compatibility shim for moved header location. 16 | #ifndef TENSORFLOW_LITE_ERROR_REPORTER_H_ 17 | #define TENSORFLOW_LITE_ERROR_REPORTER_H_ 18 | 19 | #include "tensorflow-lite/tensorflow/lite/core/api/error_reporter.h" // IWYU pragma: export 20 | #include "tensorflow-lite/tensorflow/lite/stderr_reporter.h" // IWYU pragma: export 21 | 22 | #endif // TENSORFLOW_LITE_ERROR_REPORTER_H_ 23 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/interpreter.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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 | #ifndef TENSORFLOW_LITE_INTERPRETER_H_ 16 | #define TENSORFLOW_LITE_INTERPRETER_H_ 17 | 18 | /// For documentation, see 19 | /// tensorflow/lite/core/interpreter.h. 20 | 21 | #include "tensorflow-lite/tensorflow/lite/core/interpreter.h" 22 | 23 | namespace tflite { 24 | using Interpreter = ::tflite::impl::Interpreter; 25 | } // namespace tflite 26 | 27 | #endif // TENSORFLOW_LITE_INTERPRETER_H_ 28 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/deprecated_backends.cc: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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 | namespace tflite { 17 | 18 | // Include this target as a dependency in order to define this function for 19 | // CpuBackendContext. Its use is to control execution of deprecated paths 20 | // by providing a symbol definition for otherwise "weak" symbol 21 | // declarations in CpuBackendContext. 22 | extern bool UseGemmlowpOnX86() { return true; } 23 | 24 | } // namespace tflite 25 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/profiling/time.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2018 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 | #ifndef TENSORFLOW_LITE_PROFILING_TIME_H_ 16 | #define TENSORFLOW_LITE_PROFILING_TIME_H_ 17 | 18 | #include 19 | 20 | namespace tflite { 21 | namespace profiling { 22 | namespace time { 23 | uint64_t NowMicros(); 24 | void SleepForMicros(uint64_t micros); 25 | } // namespace time 26 | } // namespace profiling 27 | } // namespace tflite 28 | #endif // TENSORFLOW_LITE_PROFILING_TIME_H_ 29 | -------------------------------------------------------------------------------- /tflite/download_flex_delegates.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )" 5 | 6 | cd $SCRIPTPATH/mac-x86_64 7 | if [ ! -f libtensorflowlite_flex_2.16.1.dylib ]; then 8 | wget -O libtensorflowlite_flex_2.16.1.dylib --show-progress https://cdn.edgeimpulse.com/build-system/flex-delegates/mac-x86_64/libtensorflowlite_flex_2.16.1.dylib 9 | fi 10 | 11 | cd $SCRIPTPATH/linux-armv7 12 | if [ ! -f libtensorflowlite_flex_2.16.1.so ]; then 13 | wget -O libtensorflowlite_flex_2.16.1.so --show-progress https://cdn.edgeimpulse.com/build-system/flex-delegates/linux-armv7/libtensorflowlite_flex_2.16.1.so 14 | fi 15 | 16 | cd $SCRIPTPATH/linux-aarch64 17 | if [ ! -f libtensorflowlite_flex_2.16.1.so ]; then 18 | wget -O libtensorflowlite_flex_2.16.1.so --show-progress https://cdn.edgeimpulse.com/build-system/flex-delegates/linux-aarch64/libtensorflowlite_flex_2.16.1.so 19 | fi 20 | 21 | cd $SCRIPTPATH/linux-x86 22 | if [ ! -f libtensorflowlite_flex_2.16.1.so ]; then 23 | wget -O libtensorflowlite_flex_2.16.1.so --show-progress https://cdn.edgeimpulse.com/build-system/flex-delegates/linux-x86/libtensorflowlite_flex_2.16.1.so 24 | fi 25 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/internal/legacy_types.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2018 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 | #ifndef TENSORFLOW_LITE_KERNELS_INTERNAL_LEGACY_TYPES_H_ 16 | #define TENSORFLOW_LITE_KERNELS_INTERNAL_LEGACY_TYPES_H_ 17 | 18 | #include "tensorflow-lite/tensorflow/lite/kernels/internal/types.h" 19 | 20 | namespace tflite { 21 | 22 | // TODO(b/116772710): Insert legacy Dims<> code in here. 23 | 24 | } // namespace tflite 25 | 26 | #endif // TENSORFLOW_LITE_KERNELS_INTERNAL_LEGACY_TYPES_H_ 27 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/model_builder.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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 | #ifndef TENSORFLOW_LITE_MODEL_BUILDER_H_ 16 | #define TENSORFLOW_LITE_MODEL_BUILDER_H_ 17 | 18 | /// For documentation, see third_party/tensorflow/lite/core/model_builder.h. 19 | 20 | #include "tensorflow-lite/tensorflow/lite/core/model_builder.h" 21 | 22 | namespace tflite { 23 | using FlatBufferModel = ::tflite::impl::FlatBufferModel; 24 | } // namespace tflite 25 | 26 | #endif // TENSORFLOW_LITE_MODEL_BUILDER_H_ 27 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/core/api/tensor_utils.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 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 | #ifndef TENSORFLOW_LITE_CORE_API_TENSOR_UTILS_H_ 17 | #define TENSORFLOW_LITE_CORE_API_TENSOR_UTILS_H_ 18 | 19 | #include "tensorflow-lite/tensorflow/lite/core/c/common.h" 20 | 21 | namespace tflite { 22 | 23 | // Resets a variable tensor to the default value. 24 | TfLiteStatus ResetVariableTensor(TfLiteTensor* tensor); 25 | 26 | } // namespace tflite 27 | 28 | #endif // TENSORFLOW_LITE_CORE_API_TENSOR_UTILS_H_ 29 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/array.cc: -------------------------------------------------------------------------------- 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 "tensorflow-lite/tensorflow/lite/array.h" 17 | 18 | namespace tflite { 19 | namespace array_internal { 20 | 21 | void TfLiteArrayDeleter::operator()(TfLiteIntArray* a) { 22 | if (a) { 23 | TfLiteIntArrayFree(a); 24 | } 25 | } 26 | void TfLiteArrayDeleter::operator()(TfLiteFloatArray* a) { 27 | if (a) { 28 | TfLiteFloatArrayFree(a); 29 | } 30 | } 31 | 32 | } // namespace array_internal 33 | } // namespace tflite 34 | -------------------------------------------------------------------------------- /tensorflow-lite/flatbuffers/pch/pch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef FLATBUFFERS_PCH_H_ 18 | #define FLATBUFFERS_PCH_H_ 19 | 20 | // stl 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | // flatbuffers 36 | #include "tensorflow-lite/flatbuffers/util.h" 37 | 38 | #endif // FLATBUFFERS_PCH_H_ 39 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/core/async/testing/mock_async_kernel.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2022 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 | #ifndef TENSORFLOW_LITE_CORE_ASYNC_TESTING_MOCK_ASYNC_KERNEL_H_ 16 | #define TENSORFLOW_LITE_CORE_ASYNC_TESTING_MOCK_ASYNC_KERNEL_H_ 17 | 18 | #include "tensorflow-lite/tensorflow/lite/async/testing/mock_async_kernel.h" // IWYU pragma: export 19 | // IWYU pragma: private, include "third_party/tensorflow/lite/async/testing/mock_async_kernel.h" 20 | 21 | #endif // TENSORFLOW_LITE_CORE_ASYNC_TESTING_MOCK_ASYNC_KERNEL_H_ 22 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/core/async/backend_async_kernel_interface.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2022 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 | #ifndef TENSORFLOW_LITE_CORE_ASYNC_BACKEND_ASYNC_KERNEL_INTERFACE_H_ 16 | #define TENSORFLOW_LITE_CORE_ASYNC_BACKEND_ASYNC_KERNEL_INTERFACE_H_ 17 | 18 | #include "tensorflow-lite/tensorflow/lite/async/backend_async_kernel_interface.h" // IWYU pragma: export 19 | // IWYU pragma: private, include "third_party/tensorflow/lite/async/backend_async_kernel_interface.h" 20 | 21 | #endif // TENSORFLOW_LITE_CORE_ASYNC_BACKEND_ASYNC_KERNEL_INTERFACE_H_ 22 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/stablehlo_add.cc: -------------------------------------------------------------------------------- 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 "tensorflow-lite/tensorflow/lite/core/c/common.h" 17 | #include "tensorflow-lite/tensorflow/lite/kernels/stablehlo_elementwise.h" 18 | 19 | namespace tflite::ops::builtin { 20 | 21 | TfLiteRegistration* Register_STABLEHLO_ADD() { 22 | static TfLiteRegistration r = {nullptr, nullptr, ElementwisePrepare, 23 | ElementwiseEval}; 24 | return &r; 25 | } 26 | } // namespace tflite::ops::builtin 27 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/create_op_resolver.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2021 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 | #ifndef TENSORFLOW_LITE_CREATE_OP_RESOLVER_H_ 16 | #define TENSORFLOW_LITE_CREATE_OP_RESOLVER_H_ 17 | 18 | /// For documentation, see third_party/tensorflow/lite/core/create_op_resolver.h 19 | 20 | #include 21 | 22 | #include "tensorflow-lite/tensorflow/lite/core/create_op_resolver.h" // IWYU pragma: export 23 | 24 | namespace tflite { 25 | using ::tflite::CreateOpResolver; 26 | } // namespace tflite 27 | 28 | #endif // TENSORFLOW_LITE_CREATE_OP_RESOLVER_H_ 29 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/interpreter_builder.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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 | #ifndef TENSORFLOW_LITE_INTERPRETER_BUILDER_H_ 16 | #define TENSORFLOW_LITE_INTERPRETER_BUILDER_H_ 17 | 18 | /// For documentation, see third_party/tensorflow/lite/core/interpreter_builder.h. 19 | 20 | #include "tensorflow-lite/tensorflow/lite/core/interpreter_builder.h" // IWYU pragma: export 21 | 22 | namespace tflite { 23 | using InterpreterBuilder = ::tflite::impl::InterpreterBuilder; 24 | } // namespace tflite 25 | 26 | #endif // TENSORFLOW_LITE_INTERPRETER_BUILDER_H_ 27 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/stablehlo_multiply.cc: -------------------------------------------------------------------------------- 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 "tensorflow-lite/tensorflow/lite/core/c/common.h" 17 | #include "tensorflow-lite/tensorflow/lite/kernels/stablehlo_elementwise.h" 18 | 19 | namespace tflite::ops::builtin { 20 | 21 | TfLiteRegistration* Register_STABLEHLO_MULTIPLY() { 22 | static TfLiteRegistration r = {nullptr, nullptr, ElementwisePrepare, 23 | ElementwiseEval}; 24 | return &r; 25 | } 26 | } // namespace tflite::ops::builtin 27 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/profiling/platform_profiler.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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 | #ifndef TENSORFLOW_LITE_PROFILING_PLATFORM_PROFILER_H_ 16 | #define TENSORFLOW_LITE_PROFILING_PLATFORM_PROFILER_H_ 17 | 18 | #include 19 | 20 | #include "tensorflow-lite/tensorflow/lite/core/api/profiler.h" 21 | 22 | namespace tflite { 23 | namespace profiling { 24 | 25 | std::unique_ptr MaybeCreatePlatformProfiler(); 26 | 27 | } // namespace profiling 28 | } // namespace tflite 29 | 30 | #endif // TENSORFLOW_LITE_PROFILING_PLATFORM_PROFILER_H_ 31 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/core/async/common.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2022 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 | #ifndef TENSORFLOW_LITE_CORE_ASYNC_COMMON_H_ 16 | #define TENSORFLOW_LITE_CORE_ASYNC_COMMON_H_ 17 | 18 | // Enum tag for specifying whether a corresponding API call is targeting 19 | // input tensor or output tensor. 20 | typedef enum TfLiteIoType { 21 | kTfLiteIoUnknown = 0, 22 | kTfLiteIoInput = 1, 23 | kTfLiteIoOutput = 2, 24 | } TfLiteIoType; 25 | 26 | // Representing an async exection. 27 | typedef int TfLiteAsyncEventHandle; 28 | 29 | #endif // TENSORFLOW_LITE_CORE_ASYNC_COMMON_H_ 30 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/variable_ops_wrapper.cc: -------------------------------------------------------------------------------- 1 | /* Copyright 2021 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 | #include "pybind11/pybind11.h" // from @pybind11 16 | #include "pybind11/pytypes.h" // from @pybind11 17 | 18 | PYBIND11_MODULE(pywrap_variable_ops, m) { 19 | m.doc() = R"pbdoc( 20 | pywrap_variable_ops 21 | ----- 22 | )pbdoc"; 23 | m.def( 24 | "VariableOpsRegisterer", 25 | [](uintptr_t resolver) { 26 | // TODO(b/149099381): Remove this library after updating users. 27 | }, 28 | R"pbdoc( 29 | Registers variable custom ops. 30 | )pbdoc"); 31 | } 32 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/internal/optimized/sse_check.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 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 | #ifndef TENSORFLOW_LITE_KERNELS_INTERNAL_OPTIMIZED_SSE_CHECK_H_ 16 | #define TENSORFLOW_LITE_KERNELS_INTERNAL_OPTIMIZED_SSE_CHECK_H_ 17 | 18 | #if defined(__SSSE3__) 19 | // SSSE 3 available: Use the SSE code. 20 | #define SSE_OR_PORTABLE(funcname, ...) Sse##funcname(__VA_ARGS__) 21 | 22 | #else 23 | 24 | // No SSSE 3 available: Use Portable code 25 | #define SSE_OR_PORTABLE(funcname, ...) Portable##funcname(__VA_ARGS__) 26 | #endif 27 | 28 | #endif // TENSORFLOW_LITE_KERNELS_INTERNAL_OPTIMIZED_SSE_CHECK_H_ 29 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/shim/test_op/simple_tf_op.cc: -------------------------------------------------------------------------------- 1 | /* Copyright 2021 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 | #include "tensorflow-lite/tensorflow/lite/kernels/shim/test_op/simple_tf_op.h" 16 | 17 | #include "tensorflow-lite/tensorflow/core/framework/op_kernel.h" 18 | #include "tensorflow-lite/tensorflow/core/framework/types.h" 19 | 20 | namespace tflite { 21 | namespace shim { 22 | 23 | REGISTER_TF_OP_SHIM(SimpleOpKernel); 24 | 25 | REGISTER_KERNEL_BUILDER( 26 | Name(SimpleOpKernel::OpName()).Device(::tensorflow::DEVICE_CPU), 27 | SimpleOpKernel); 28 | 29 | } // namespace shim 30 | } // namespace tflite 31 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/logger.cc: -------------------------------------------------------------------------------- 1 | /* Copyright 2022 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 "tensorflow-lite/tensorflow/lite/logger.h" 17 | 18 | #include "tensorflow-lite/tensorflow/lite/minimal_logging.h" 19 | 20 | namespace tflite { 21 | 22 | LogSeverity LoggerOptions::GetMinimumLogSeverity() { 23 | return tflite::logging_internal::MinimalLogger::GetMinimumLogSeverity(); 24 | } 25 | 26 | LogSeverity LoggerOptions::SetMinimumLogSeverity(LogSeverity new_severity) { 27 | return tflite::logging_internal::MinimalLogger::SetMinimumLogSeverity( 28 | new_severity); 29 | } 30 | 31 | } // namespace tflite 32 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/internal/reduce_common.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2022 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 | #ifndef TENSORFLOW_LITE_KERNELS_INTERNAL_REDUCE_COMMON_H_ 16 | #define TENSORFLOW_LITE_KERNELS_INTERNAL_REDUCE_COMMON_H_ 17 | 18 | namespace tflite { 19 | namespace ops { 20 | namespace builtin { 21 | namespace reduce { 22 | 23 | enum ReduceType { 24 | kSum, 25 | kProd, 26 | kMax, 27 | kMin, 28 | kAny, 29 | kAll, 30 | }; 31 | 32 | } // namespace reduce 33 | } // namespace builtin 34 | } // namespace ops 35 | } // namespace tflite 36 | 37 | #endif // TENSORFLOW_LITE_KERNELS_INTERNAL_REDUCE_COMMON_H_ 38 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/c/test_util.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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 | #ifndef TENSORFLOW_LITE_C_TEST_UTIL_H_ 16 | #define TENSORFLOW_LITE_C_TEST_UTIL_H_ 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif 21 | 22 | // Initialize TF Lite shims, in a manner appropriate for running unit tests. 23 | // Returns zero on success, or an implementation-defined error code on failure. 24 | // This should be called before calling any other shims functions or methods 25 | // in unit tests. 26 | int TfLiteInitializeShimsForTest(void); 27 | 28 | #ifdef __cplusplus 29 | } 30 | #endif 31 | 32 | #endif // TENSORFLOW_LITE_C_TEST_UTIL_H_ 33 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/internal/max.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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 | #ifndef TENSORFLOW_LITE_KERNELS_INTERNAL_MAX_H_ 16 | #define TENSORFLOW_LITE_KERNELS_INTERNAL_MAX_H_ 17 | 18 | #include 19 | 20 | namespace tflite { 21 | 22 | #if defined(TF_LITE_USE_GLOBAL_MAX) || defined(__ZEPHYR__) 23 | inline float TfLiteMax(const float& x, const float& y) { 24 | return std::max(x, y); 25 | } 26 | #else 27 | template 28 | inline T TfLiteMax(const T& x, const T& y) { 29 | return std::fmax(x, y); 30 | } 31 | #endif 32 | 33 | } // namespace tflite 34 | 35 | #endif // TENSORFLOW_LITE_KERNELS_INTERNAL_MAX_H_ 36 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/internal/min.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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 | #ifndef TENSORFLOW_LITE_KERNELS_INTERNAL_MIN_H_ 16 | #define TENSORFLOW_LITE_KERNELS_INTERNAL_MIN_H_ 17 | 18 | #include 19 | 20 | namespace tflite { 21 | 22 | #if defined(TF_LITE_USE_GLOBAL_MIN) || defined(__ZEPHYR__) 23 | inline float TfLiteMin(const float& x, const float& y) { 24 | return std::min(x, y); 25 | } 26 | #else 27 | template 28 | inline T TfLiteMin(const T& x, const T& y) { 29 | return std::fmin(x, y); 30 | } 31 | #endif 32 | 33 | } // namespace tflite 34 | 35 | #endif // TENSORFLOW_LITE_KERNELS_INTERNAL_MIN_H_ 36 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/gradient/gradient_ops.cc: -------------------------------------------------------------------------------- 1 | /* Copyright 2021 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 "tensorflow-lite/tensorflow/lite/kernels/gradient/gradient_ops.h" 17 | 18 | #include "tensorflow-lite/tensorflow/lite/kernels/gradient/bcast_grad_args.h" 19 | 20 | namespace tflite { 21 | namespace ops { 22 | namespace custom { 23 | 24 | extern "C" void AddGradientOps(::tflite::MutableOpResolver* resolver) { 25 | resolver->AddCustom("BroadcastGradientArgs", 26 | tflite::ops::custom::Register_BROADCAST_GRADIENT_ARGS()); 27 | } 28 | 29 | } // namespace custom 30 | } // namespace ops 31 | } // namespace tflite 32 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/tflite_with_xnnpack_optional.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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 | #ifndef TENSORFLOW_LITE_TFLITE_WITH_XNNPACK_OPTIONAL_H_ 16 | #define TENSORFLOW_LITE_TFLITE_WITH_XNNPACK_OPTIONAL_H_ 17 | #include 18 | 19 | #include "tensorflow-lite/tensorflow/lite/core/c/common.h" 20 | 21 | namespace tflite { 22 | enum class XNNPackQS8Options { default_value, enabled, disabled }; 23 | 24 | std::unique_ptr 25 | MaybeCreateXNNPACKDelegate(TfLiteContext* context, XNNPackQS8Options x); 26 | } // namespace tflite 27 | 28 | #endif // TENSORFLOW_LITE_TFLITE_WITH_XNNPACK_OPTIONAL_H_ 29 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/gradient/gradient_ops.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2021 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 | #ifndef TENSORFLOW_LITE_KERNELS_GRADIENT_GRADIENT_OPS_H_ 17 | #define TENSORFLOW_LITE_KERNELS_GRADIENT_GRADIENT_OPS_H_ 18 | 19 | // This file declares the TensorFlow Lite's gradient custom operators. 20 | 21 | #include "tensorflow-lite/tensorflow/lite/mutable_op_resolver.h" 22 | 23 | namespace tflite { 24 | namespace ops { 25 | namespace custom { 26 | 27 | extern "C" void AddGradientOps(::tflite::MutableOpResolver* resolver); 28 | 29 | } // namespace custom 30 | } // namespace ops 31 | } // namespace tflite 32 | 33 | #endif // TENSORFLOW_LITE_KERNELS_GRADIENT_GRADIENT_OPS_H_ 34 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/variants/register_list_ops.h: -------------------------------------------------------------------------------- 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 | #ifndef TENSORFLOW_LITE_KERNELS_VARIANTS_REGISTER_LIST_OPS_H_ 16 | #define TENSORFLOW_LITE_KERNELS_VARIANTS_REGISTER_LIST_OPS_H_ 17 | 18 | #include "tensorflow-lite/tensorflow/lite/mutable_op_resolver.h" 19 | 20 | namespace tflite { 21 | namespace variants { 22 | namespace ops { 23 | 24 | // Register all tflite TensorList kernels as custom ops with the given resolver. 25 | void RegisterListOps(MutableOpResolver* resolver); 26 | 27 | } // namespace ops 28 | } // namespace variants 29 | } // namespace tflite 30 | 31 | #endif // TENSORFLOW_LITE_KERNELS_VARIANTS_REGISTER_LIST_OPS_H_ 32 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/shim/test_op/simple_tf_op.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2021 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 | #ifndef TENSORFLOW_LITE_KERNELS_SHIM_TEST_OP_SIMPLE_TF_OP_H_ 16 | #define TENSORFLOW_LITE_KERNELS_SHIM_TEST_OP_SIMPLE_TF_OP_H_ 17 | 18 | #include "tensorflow-lite/tensorflow/lite/kernels/shim/test_op/simple_op.h" 19 | #include "tensorflow-lite/tensorflow/lite/kernels/shim/tf_op_shim.h" 20 | 21 | namespace tflite { 22 | namespace shim { 23 | 24 | class SimpleOpKernel : public TfOpKernel { 25 | public: 26 | using TfOpKernel::TfOpKernel; 27 | }; 28 | 29 | } // namespace shim 30 | } // namespace tflite 31 | 32 | #endif // TENSORFLOW_LITE_KERNELS_SHIM_TEST_OP_SIMPLE_TF_OP_H_ 33 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/gradient/bcast_grad_args.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2021 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 | #ifndef TENSORFLOW_LITE_KERNELS_GRADIENT_BCAST_GRAD_ARGS_H_ 17 | #define TENSORFLOW_LITE_KERNELS_GRADIENT_BCAST_GRAD_ARGS_H_ 18 | 19 | // This file declares the TensorFlow Lite's broadcast gradient argument custom 20 | // operator. 21 | 22 | #include "tensorflow-lite/tensorflow/lite/core/c/common.h" 23 | 24 | namespace tflite { 25 | namespace ops { 26 | namespace custom { 27 | 28 | TfLiteRegistration* Register_BROADCAST_GRADIENT_ARGS(); 29 | 30 | } // namespace custom 31 | } // namespace ops 32 | } // namespace tflite 33 | 34 | #endif // TENSORFLOW_LITE_KERNELS_GRADIENT_BCAST_GRAD_ARGS_H_ 35 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/core/README.md: -------------------------------------------------------------------------------- 1 | This directory contains the "core" part of the TensorFlow Lite runtime library. 2 | The header files in this `tensorflow/lite/core/` directory fall into several 3 | categories. 4 | 5 | 1. Public API headers, in the `api` subdirectory `tensorflow/lite/core/api/` 6 | 7 | These are in addition to the other public API headers in `tensorflow/lite/`. 8 | 9 | For example: 10 | - `tensorflow/lite/core/api/error_reporter.h` 11 | - `tensorflow/lite/core/api/op_resolver.h` 12 | 13 | 2. Private headers that define public API types and functions. 14 | These headers are each `#include`d from a corresponding public "shim" header 15 | in `tensorflow/lite/` that forwards to the private header. 16 | 17 | For example: 18 | - `tensorflow/lite/core/interpreter.h` is a private header file that is 19 | included from the public "shim" header file `tensorflow/lite/interpeter.h`. 20 | 21 | These private header files should be used as follows: `#include`s from `.cc` 22 | files in TF Lite itself that are _implementing_ the TF Lite APIs should 23 | include the "core" TF Lite API headers. `#include`s from files that are 24 | just _using_ the regular TF Lite APIs should include the regular public 25 | headers. 26 | 27 | 3. The header file `tensorflow/lite/core/subgraph.h`. This contains 28 | some experimental APIs. -------------------------------------------------------------------------------- /third_party/ethos-u-driver-stack-imx/Linux-syscall-note: -------------------------------------------------------------------------------- 1 | SPDX-Exception-Identifier: Linux-syscall-note 2 | SPDX-URL: https://spdx.org/licenses/Linux-syscall-note.html 3 | SPDX-Licenses: GPL-2.0, GPL-2.0+, GPL-1.0+, LGPL-2.0, LGPL-2.0+, LGPL-2.1, LGPL-2.1+, GPL-2.0-only, GPL-2.0-or-later 4 | Usage-Guide: 5 | This exception is used together with one of the above SPDX-Licenses 6 | to mark user space API (uapi) header files so they can be included 7 | into non GPL compliant user space application code. 8 | To use this exception add it with the keyword WITH to one of the 9 | identifiers in the SPDX-Licenses tag: 10 | SPDX-License-Identifier: WITH Linux-syscall-note 11 | License-Text: 12 | 13 | NOTE! This copyright does *not* cover user programs that use kernel 14 | services by normal system calls - this is merely considered normal use 15 | of the kernel, and does *not* fall under the heading of "derived work". 16 | Also note that the GPL below is copyrighted by the Free Software 17 | Foundation, but the instance of code that it refers to (the Linux 18 | kernel) is copyrighted by me and others who actually wrote it. 19 | 20 | Also note that the only valid version of the GPL as far as the kernel 21 | is concerned is _this_ particular version of the license (ie v2, not 22 | v2.2 or v3.x or whatever), unless explicitly otherwise stated. 23 | 24 | Linus Torvalds 25 | -------------------------------------------------------------------------------- /tensorflow-lite/flatbuffers/pch/flatc_pch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 Google Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef FLATBUFFERS_FLATC_PCH_H_ 18 | #define FLATBUFFERS_FLATC_PCH_H_ 19 | 20 | // stl 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | // flatbuffers 33 | #include "tensorflow-lite/flatbuffers/pch/pch.h" 34 | #include "tensorflow-lite/flatbuffers/code_generators.h" 35 | #include "tensorflow-lite/flatbuffers/flatbuffers.h" 36 | #include "tensorflow-lite/flatbuffers/flexbuffers.h" 37 | #include "tensorflow-lite/flatbuffers/idl.h" 38 | 39 | #endif // FLATBUFFERS_FLATC_PCH_H_ 40 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/stderr_reporter.cc: -------------------------------------------------------------------------------- 1 | /* Copyright 2017 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 | #include "tensorflow-lite/tensorflow/lite/stderr_reporter.h" 16 | 17 | #include 18 | 19 | #include "tensorflow-lite/tensorflow/lite/core/api/error_reporter.h" 20 | #include "tensorflow-lite/tensorflow/lite/minimal_logging.h" 21 | 22 | namespace tflite { 23 | 24 | int StderrReporter::Report(const char* format, va_list args) { 25 | logging_internal::MinimalLogger::LogFormatted(TFLITE_LOG_ERROR, format, args); 26 | return 0; 27 | } 28 | 29 | ErrorReporter* DefaultErrorReporter() { 30 | static StderrReporter* error_reporter = new StderrReporter; 31 | return error_reporter; 32 | } 33 | 34 | } // namespace tflite 35 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/internal/tensor_utils.cc: -------------------------------------------------------------------------------- 1 | /* Copyright 2017 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 | #include "tensorflow-lite/tensorflow/lite/kernels/internal/tensor_utils.h" 16 | 17 | #include "tensorflow-lite/tensorflow/lite/kernels/internal/optimized/neon_check.h" 18 | 19 | #if defined(__SSSE3__) && !defined(TF_LITE_STATIC_MEMORY) 20 | #include "tensorflow-lite/tensorflow/lite/kernels/internal/optimized/sse_tensor_utils.h" 21 | #elif defined(USE_NEON) && !defined(TF_LITE_STATIC_MEMORY) 22 | #include "tensorflow-lite/tensorflow/lite/kernels/internal/optimized/neon_tensor_utils.h" 23 | #else 24 | #include "tensorflow-lite/tensorflow/lite/kernels/internal/reference/portable_tensor_utils.h" 25 | #endif // __SSSE3__ or USE_NEON 26 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/namespace.h: -------------------------------------------------------------------------------- 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 | /// \file 16 | /// 17 | /// Defines the TFLITE_CONDITIONAL_NAMESPACE macro. 18 | #ifndef TENSORFLOW_LITE_SHIMS_NAMESPACE_H_ 19 | #define TENSORFLOW_LITE_SHIMS_NAMESPACE_H_ 20 | 21 | // To avoid potential violation of the C++ "one definition rule" (ODR) for 22 | // code which depends on TF Lite types that are conditionally defined 23 | // (such as tflite::Interpreter, tflite::FlatBufferModel, TfLiteInterpreter 24 | // and TfLiteModel), symbols that depend on such types should be defined 25 | // in a (sub-)namespace whose name is also conditional. 26 | #define TFLITE_CONDITIONAL_NAMESPACE regular_tflite 27 | 28 | #endif // TENSORFLOW_LITE_NAMESPACE_H_ 29 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/parse_example/parse_example.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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 | #ifndef TENSORFLOW_LITE_KERNELS_PARSE_EXAMPLE_PARSE_EXAMPLE_H_ 16 | #define TENSORFLOW_LITE_KERNELS_PARSE_EXAMPLE_PARSE_EXAMPLE_H_ 17 | 18 | #include "tensorflow-lite/tensorflow/lite/mutable_op_resolver.h" 19 | 20 | namespace tflite { 21 | namespace ops { 22 | namespace custom { 23 | 24 | TfLiteRegistration* Register_PARSE_EXAMPLE(); 25 | TfLiteRegistration* Register_PARSE_EXAMPLE_V2(); 26 | 27 | extern "C" void AddParseExampleOp(::tflite::MutableOpResolver* resolver); 28 | 29 | } // namespace custom 30 | } // namespace ops 31 | } // namespace tflite 32 | 33 | #endif // TENSORFLOW_LITE_KERNELS_PARSE_EXAMPLE_PARSE_EXAMPLE_H_ 34 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/stateful_error_reporter.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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 | #ifndef TENSORFLOW_LITE_STATEFUL_ERROR_REPORTER_H_ 16 | #define TENSORFLOW_LITE_STATEFUL_ERROR_REPORTER_H_ 17 | 18 | #include 19 | 20 | #include "tensorflow-lite/tensorflow/lite/core/api/error_reporter.h" 21 | 22 | namespace tflite { 23 | 24 | // Similar to tflite::ErrorReporter, except that it allows callers to get the 25 | // last error message. 26 | class StatefulErrorReporter : public ErrorReporter { 27 | public: 28 | // Returns last error message. Returns empty string if no error is reported. 29 | virtual std::string message() = 0; 30 | }; 31 | 32 | } // namespace tflite 33 | 34 | #endif // TENSORFLOW_LITE_STATEFUL_ERROR_REPORTER_H_ 35 | -------------------------------------------------------------------------------- /tensorflow-lite/flatbuffers/flex_flat_util.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2022 Google Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef FLATBUFFERS_FLEX_FLAT_UTIL_H_ 18 | #define FLATBUFFERS_FLEX_FLAT_UTIL_H_ 19 | 20 | #include "tensorflow-lite/flatbuffers/flatbuffers.h" 21 | #include "tensorflow-lite/flatbuffers/flexbuffers.h" 22 | 23 | namespace flexbuffers { 24 | 25 | // Verifies the `nested` flexbuffer within a flatbuffer vector is valid. 26 | inline bool VerifyNestedFlexBuffer( 27 | const flatbuffers::Vector *const nested, 28 | flatbuffers::Verifier &verifier) { 29 | if (!nested) return true; 30 | return verifier.Check(flexbuffers::VerifyBuffer( 31 | nested->data(), nested->size(), verifier.GetFlexReuseTracker())); 32 | } 33 | 34 | } // namespace flexbuffers 35 | 36 | #endif // FLATBUFFERS_FLEX_FLAT_UTIL_H_ 37 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/shim/test_op/tmpl_tf_op.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2022 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 | #ifndef TENSORFLOW_LITE_KERNELS_SHIM_TEST_OP_TMPL_TF_OP_H_ 16 | #define TENSORFLOW_LITE_KERNELS_SHIM_TEST_OP_TMPL_TF_OP_H_ 17 | 18 | #include "tensorflow-lite/tensorflow/lite/kernels/shim/test_op/tmpl_op.h" 19 | #include "tensorflow-lite/tensorflow/lite/kernels/shim/tf_op_shim.h" 20 | 21 | namespace tflite { 22 | namespace shim { 23 | 24 | template 25 | class TmplOpKernel : public TfOpKernel { 26 | public: 27 | using TfOpKernel::TfOpKernel; 28 | }; 29 | 30 | } // namespace shim 31 | } // namespace tflite 32 | 33 | #endif // TENSORFLOW_LITE_KERNELS_SHIM_TEST_OP_TMPL_TF_OP_H_ 34 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/internal/tensor_ctypes.cc: -------------------------------------------------------------------------------- 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 "tensorflow-lite/tensorflow/lite/kernels/internal/tensor_ctypes.h" 17 | 18 | #include 19 | 20 | namespace tflite { 21 | 22 | RuntimeShape GetTensorShape(const TfLiteTensor* tensor) { 23 | if (tensor == nullptr) { 24 | return RuntimeShape(); 25 | } 26 | 27 | TfLiteIntArray* dims = tensor->dims; 28 | const int dims_size = dims->size; 29 | const int32_t* dims_data = reinterpret_cast(dims->data); 30 | return RuntimeShape(dims_size, dims_data); 31 | } 32 | 33 | RuntimeShape GetTensorShape(std::vector data) { 34 | return RuntimeShape(data.size(), data.data()); 35 | } 36 | 37 | } // namespace tflite 38 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/stderr_reporter.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2017 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 | #ifndef TENSORFLOW_LITE_STDERR_REPORTER_H_ 16 | #define TENSORFLOW_LITE_STDERR_REPORTER_H_ 17 | 18 | #include 19 | 20 | #include "tensorflow-lite/tensorflow/lite/core/api/error_reporter.h" 21 | #include "tensorflow-lite/tensorflow/lite/core/c/common.h" 22 | 23 | namespace tflite { 24 | 25 | // An error reporter that simply writes the message to stderr. 26 | struct StderrReporter : public ErrorReporter { 27 | int Report(const char* format, va_list args) override; 28 | }; 29 | 30 | // Return the default error reporter (output to stderr). 31 | ErrorReporter* DefaultErrorReporter(); 32 | 33 | } // namespace tflite 34 | 35 | #endif // TENSORFLOW_LITE_STDERR_REPORTER_H_ 36 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/c/common.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 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 | /// \file 17 | /// 18 | /// This file defines common C types and APIs for implementing operations, 19 | /// delegates and other constructs in TensorFlow Lite. The actual operations and 20 | /// delegates can be defined using C++, but the interface between the 21 | /// interpreter and the operations are C. 22 | /// 23 | /// For documentation, see tensorflow/lite/core/c/common.h. 24 | /// 25 | /// See also c_api_opaque.h which has more ABI-stable variants of some of these 26 | /// APIs. 27 | 28 | #ifndef TENSORFLOW_LITE_C_COMMON_H_ 29 | #define TENSORFLOW_LITE_C_COMMON_H_ 30 | 31 | #include "tensorflow-lite/tensorflow/lite/core/c/common.h" 32 | 33 | #endif // TENSORFLOW_LITE_C_COMMON_H_ 34 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/tflite_with_xnnpack.cc: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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 | #include 16 | 17 | #include "tensorflow-lite/tensorflow/lite/core/c/common.h" 18 | #include "tensorflow-lite/tensorflow/lite/delegates/xnnpack/xnnpack_delegate.h" 19 | 20 | namespace tflite { 21 | // Corresponding weak declaration found in lite/tflite_with_xnnpack_optional.cc 22 | // when TFLITE_BUILD_WITH_XNNPACK_DELEGATE macro isn't defined. 23 | std::unique_ptr 24 | AcquireXNNPACKDelegate() { 25 | auto opts = TfLiteXNNPackDelegateOptionsDefault(); 26 | return std::unique_ptr( 27 | TfLiteXNNPackDelegateCreate(&opts), TfLiteXNNPackDelegateDelete); 28 | } 29 | } // namespace tflite 30 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/profiling/atrace_profiler.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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 | #ifndef TENSORFLOW_LITE_PROFILING_ATRACE_PROFILER_H_ 16 | #define TENSORFLOW_LITE_PROFILING_ATRACE_PROFILER_H_ 17 | 18 | #include 19 | 20 | #include "tensorflow-lite/tensorflow/lite/core/api/profiler.h" 21 | 22 | namespace tflite { 23 | namespace profiling { 24 | 25 | // Creates a profiler which reports the traced events to the Android ATrace. 26 | // Nullptr will be returned if the Android system property 'debug.tflite.trace' 27 | // is not set or the property value is not 1. 28 | std::unique_ptr MaybeCreateATraceProfiler(); 29 | 30 | } // namespace profiling 31 | } // namespace tflite 32 | 33 | #endif // TENSORFLOW_LITE_PROFILING_ATRACE_PROFILER_H_ 34 | -------------------------------------------------------------------------------- /tensorflow-lite/flatbuffers/bfbs_generator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Google Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef FLATBUFFERS_BFBS_GENERATOR_H_ 18 | #define FLATBUFFERS_BFBS_GENERATOR_H_ 19 | 20 | #include 21 | 22 | namespace flatbuffers { 23 | 24 | enum GeneratorStatus { 25 | OK, 26 | FAILED, 27 | FAILED_VERIFICATION, 28 | }; 29 | 30 | // A Flatbuffer Code Generator that receives a binary serialized reflection.fbs 31 | // and generates code from it. 32 | class BfbsGenerator { 33 | public: 34 | virtual ~BfbsGenerator() {} 35 | 36 | // Generate code from the provided `buffer` of given `length`. The buffer is 37 | // a serialized reflection.fbs. 38 | virtual GeneratorStatus Generate(const uint8_t *buffer, int64_t length) = 0; 39 | }; 40 | 41 | } // namespace flatbuffers 42 | 43 | #endif // FLATBUFFERS_BFBS_GENERATOR_H_ 44 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/perception/perception_ops.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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 | #ifndef TENSORFLOW_LITE_KERNELS_PERCEPTION_PERCEPTION_OPS_H_ 17 | #define TENSORFLOW_LITE_KERNELS_PERCEPTION_PERCEPTION_OPS_H_ 18 | 19 | #include "tensorflow-lite/tensorflow/lite/mutable_op_resolver.h" 20 | 21 | namespace tflite { 22 | namespace ops { 23 | namespace custom { 24 | 25 | TfLiteRegistration* RegisterDenseImageWarp(); 26 | TfLiteRegistration* RegisterMaxPoolWithArgmax(); 27 | TfLiteRegistration* RegisterMaxUnpooling2D(); 28 | 29 | extern "C" void AddPerceptionOps(::tflite::MutableOpResolver* resolver); 30 | 31 | } // namespace custom 32 | } // namespace ops 33 | } // namespace tflite 34 | 35 | #endif // TENSORFLOW_LITE_KERNELS_PERCEPTION_PERCEPTION_OPS_H_ 36 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/register.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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 | #ifndef TENSORFLOW_LITE_KERNELS_REGISTER_H_ 16 | #define TENSORFLOW_LITE_KERNELS_REGISTER_H_ 17 | 18 | /// For documentation, see third_party/tensorflow/lite/core/kernels/register.h 19 | 20 | #include "tensorflow-lite/tensorflow/lite/core/kernels/register.h" // IWYU pragma: export 21 | 22 | namespace tflite { 23 | namespace ops { 24 | namespace builtin { 25 | using BuiltinOpResolver = ::tflite::ops::builtin::BuiltinOpResolver; 26 | using BuiltinOpResolverWithoutDefaultDelegates = 27 | ::tflite::ops::builtin::BuiltinOpResolverWithoutDefaultDelegates; 28 | 29 | } // namespace builtin 30 | } // namespace ops 31 | } // namespace tflite 32 | 33 | #endif // TENSORFLOW_LITE_KERNELS_REGISTER_H_ 34 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/core/model.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2017 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 | /// \file 16 | /// 17 | /// Defines tflite::Interpreter and tflite::InterpreterBuilder. 18 | /// 19 | /// WARNING: Users of TensorFlow Lite should not include this file directly, 20 | /// but should instead include "third_party/tensorflow/lite/model.h". 21 | /// Only the TensorFlow Lite implementation itself should include this 22 | /// file directly. 23 | #ifndef TENSORFLOW_LITE_CORE_MODEL_H_ 24 | #define TENSORFLOW_LITE_CORE_MODEL_H_ 25 | 26 | #include "tensorflow-lite/tensorflow/lite/core/interpreter_builder.h" 27 | #include "tensorflow-lite/tensorflow/lite/core/model_builder.h" 28 | 29 | // TODO(b/168725050): Address the issue of proxy header in this file. 30 | 31 | #endif // TENSORFLOW_LITE_CORE_MODEL_H_ 32 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/signature_runner.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2021 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 | #ifndef TENSORFLOW_LITE_SIGNATURE_RUNNER_H_ 16 | #define TENSORFLOW_LITE_SIGNATURE_RUNNER_H_ 17 | /// \file 18 | /// 19 | /// An abstraction for invoking the TF Lite interpreter. 20 | /// Provides support for named parameters, and for including multiple 21 | /// named computations in a single model, each with its own inputs/outputs. 22 | 23 | /// For documentation, see 24 | /// third_party/tensorflow/lite/core/signature_runner.h. 25 | 26 | #include "tensorflow-lite/tensorflow/lite/core/signature_runner.h" // IWYU pragma: export 27 | 28 | namespace tflite { 29 | using SignatureRunner = ::tflite::impl::SignatureRunner; 30 | } // namespace tflite 31 | 32 | #endif // TENSORFLOW_LITE_SIGNATURE_RUNNER_H_ 33 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/perception/perception_ops.cc: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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 "tensorflow-lite/tensorflow/lite/kernels/perception/perception_ops.h" 17 | 18 | namespace tflite { 19 | namespace ops { 20 | namespace custom { 21 | 22 | extern "C" void AddPerceptionOps(::tflite::MutableOpResolver* resolver) { 23 | resolver->AddCustom("DenseImageWarp", 24 | tflite::ops::custom::RegisterDenseImageWarp()); 25 | resolver->AddCustom("MaxPoolWithArgmax", 26 | tflite::ops::custom::RegisterMaxPoolWithArgmax()); 27 | resolver->AddCustom("MaxUnpooling2D", 28 | tflite::ops::custom::RegisterMaxUnpooling2D()); 29 | } 30 | 31 | } // namespace custom 32 | } // namespace ops 33 | } // namespace tflite 34 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/stablehlo_min_max.cc: -------------------------------------------------------------------------------- 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 "tensorflow-lite/tensorflow/lite/core/c/common.h" 17 | #include "tensorflow-lite/tensorflow/lite/kernels/stablehlo_elementwise.h" 18 | 19 | namespace tflite::ops::builtin { 20 | 21 | TfLiteRegistration* Register_STABLEHLO_MAXIMUM() { 22 | static TfLiteRegistration r = {nullptr, nullptr, ElementwisePrepare, 23 | ElementwiseEval}; 24 | return &r; 25 | } 26 | TfLiteRegistration* Register_STABLEHLO_MINIMUM() { 27 | static TfLiteRegistration r = {nullptr, nullptr, ElementwisePrepare, 28 | ElementwiseEval}; 29 | return &r; 30 | } 31 | } // namespace tflite::ops::builtin 32 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/core/api/error_reporter.cc: -------------------------------------------------------------------------------- 1 | /* Copyright 2017 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 | #include "tensorflow-lite/tensorflow/lite/core/api/error_reporter.h" 16 | #include 17 | 18 | namespace tflite { 19 | 20 | int ErrorReporter::Report(const char* format, ...) { 21 | va_list args; 22 | va_start(args, format); 23 | int code = Report(format, args); 24 | va_end(args); 25 | return code; 26 | } 27 | 28 | // TODO(aselle): Make the name of ReportError on context the same, so 29 | // we can use the ensure functions w/o a context and w/ a reporter. 30 | int ErrorReporter::ReportError(void*, const char* format, ...) { 31 | va_list args; 32 | va_start(args, format); 33 | int code = Report(format, args); 34 | va_end(args); 35 | return code; 36 | } 37 | 38 | } // namespace tflite 39 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/internal/reference/floor_div.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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 | #ifndef TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_FLOOR_DIV_H_ 16 | #define TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_FLOOR_DIV_H_ 17 | 18 | #include 19 | #include 20 | 21 | #include "tensorflow-lite/tensorflow/lite/kernels/internal/types.h" 22 | 23 | namespace tflite { 24 | namespace reference_ops { 25 | 26 | template 27 | T FloorDiv(T input1, T input2) { 28 | return std::floor(std::divides()(static_cast(input1), 29 | static_cast(input2))); 30 | } 31 | 32 | } // namespace reference_ops 33 | } // namespace tflite 34 | 35 | #endif // TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_FLOOR_DIV_H_ 36 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/gradient/gradient_ops_wrapper.cc: -------------------------------------------------------------------------------- 1 | /* Copyright 2021 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 | #include "pybind11/pybind11.h" // from @pybind11 16 | #include "pybind11/pytypes.h" // from @pybind11 17 | #include "tensorflow-lite/tensorflow/lite/kernels/gradient/gradient_ops.h" 18 | 19 | PYBIND11_MODULE(pywrap_gradient_ops, m) { 20 | m.doc() = R"pbdoc( 21 | pywrap_gradient_ops 22 | ----- 23 | )pbdoc"; 24 | m.def( 25 | "GradientOpsRegisterer", 26 | [](uintptr_t resolver) { 27 | tflite::ops::custom::AddGradientOps( 28 | reinterpret_cast(resolver)); 29 | }, 30 | R"pbdoc( 31 | Gradient op registerer function with the correct signature. Registers 32 | Gradient custom ops. 33 | )pbdoc"); 34 | } 35 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/builtin_op_kernels.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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 | #ifndef TENSORFLOW_LITE_KERNELS_BUILTIN_OP_KERNELS_H_ 16 | #define TENSORFLOW_LITE_KERNELS_BUILTIN_OP_KERNELS_H_ 17 | 18 | /// For documentation, see 19 | /// third_party/tensorflow/lite/core/kernels/builtin_op_kernels.h 20 | 21 | #include "tensorflow-lite/tensorflow/lite/core/kernels/builtin_op_kernels.h" 22 | 23 | namespace tflite { 24 | namespace ops { 25 | namespace builtin { 26 | 27 | #define TFLITE_OP(NAME) \ 28 | using ::tflite::ops::builtin::NAME; 29 | 30 | #include "tensorflow-lite/tensorflow/lite/kernels/builtin_ops_list.inc" 31 | 32 | #undef TFLITE_OP 33 | 34 | } // namespace builtin 35 | } // namespace ops 36 | } // namespace tflite 37 | 38 | #endif // TENSORFLOW_LITE_KERNELS_BUILTIN_OP_KERNELS_H_ 39 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/perception/perception_ops_wrapper.cc: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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 | #include "pybind11/pybind11.h" // from @pybind11 16 | #include "pybind11/pytypes.h" // from @pybind11 17 | #include "tensorflow-lite/tensorflow/lite/kernels/perception/perception_ops.h" 18 | 19 | PYBIND11_MODULE(pywrap_perception_ops, m) { 20 | m.doc() = R"pbdoc( 21 | pywrap_perception_ops 22 | ----- 23 | )pbdoc"; 24 | m.def( 25 | "PerceptionOpsRegisterer", 26 | [](uintptr_t resolver) { 27 | tflite::ops::custom::AddPerceptionOps( 28 | reinterpret_cast(resolver)); 29 | }, 30 | R"pbdoc( 31 | Perception op registerer function with the correct signature. Registers 32 | Perception custom ops. 33 | )pbdoc"); 34 | } 35 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/profiling/signpost_profiler.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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 | #ifndef TENSORFLOW_LITE_PROFILING_SIGNPOST_PROFILER_H_ 16 | #define TENSORFLOW_LITE_PROFILING_SIGNPOST_PROFILER_H_ 17 | 18 | #include 19 | 20 | #include "tensorflow-lite/tensorflow/lite/core/api/profiler.h" 21 | 22 | namespace tflite { 23 | namespace profiling { 24 | 25 | // Creates a platform profiler for iOS, macOS, tvOS and watchOS. 26 | // This profiler uses Apple's signpost API for tracing events. 27 | // User needs to set an enrionment variable 'debug.tflite.trace' for profile 28 | // scheme at Xcode to enable this profiler. 29 | std::unique_ptr MaybeCreateSignpostProfiler(); 30 | 31 | } // namespace profiling 32 | } // namespace tflite 33 | 34 | #endif // TENSORFLOW_LITE_PROFILING_SIGNPOST_PROFILER_H_ 35 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/shim/test_op/tmpl_tflite_op.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2021 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 | #ifndef TENSORFLOW_LITE_KERNELS_SHIM_TEST_OP_TMPL_TFLITE_OP_H_ 16 | #define TENSORFLOW_LITE_KERNELS_SHIM_TEST_OP_TMPL_TFLITE_OP_H_ 17 | 18 | #include "tensorflow-lite/tensorflow/lite/core/c/common.h" 19 | #include "tensorflow-lite/tensorflow/lite/mutable_op_resolver.h" 20 | 21 | namespace tflite { 22 | namespace ops { 23 | namespace custom { 24 | 25 | // Add TmplOp to the resolver 26 | void AddTmplOp(MutableOpResolver* resolver); 27 | 28 | // Creates and returns the op kernel 29 | TfLiteRegistration* Register_TMPL_OP(); 30 | 31 | // The name of the op 32 | const char* OpName_TMPL_OP(); 33 | 34 | } // namespace custom 35 | } // namespace ops 36 | } // namespace tflite 37 | 38 | #endif // TENSORFLOW_LITE_KERNELS_SHIM_TEST_OP_TMPL_TFLITE_OP_H_ 39 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/profiling/profiler.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2018 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 | #ifndef TENSORFLOW_LITE_PROFILING_PROFILER_H_ 16 | #define TENSORFLOW_LITE_PROFILING_PROFILER_H_ 17 | 18 | #include "tensorflow-lite/tensorflow/lite/profiling/buffered_profiler.h" 19 | #include "tensorflow-lite/tensorflow/lite/profiling/noop_profiler.h" 20 | 21 | namespace tflite { 22 | namespace profiling { 23 | 24 | // TODO(b/131688504): Remove this and use runtime flags for profiler selection. 25 | #ifdef TFLITE_PROFILING_ENABLED 26 | using Profiler = BufferedProfiler; 27 | #else 28 | using Profiler = NoopProfiler; 29 | #endif // TFLITE_PROFILING_ENABLED 30 | 31 | } // namespace profiling 32 | } // namespace tflite 33 | 34 | #define SCOPED_TAGGED_OPERATOR_PROFILE TFLITE_SCOPED_TAGGED_OPERATOR_PROFILE 35 | 36 | #endif // TENSORFLOW_LITE_PROFILING_PROFILER_H_ 37 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/internal/reference/neg.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 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 | #ifndef TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_NEG_H_ 16 | #define TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_NEG_H_ 17 | 18 | #include "tensorflow-lite/tensorflow/lite/kernels/internal/types.h" 19 | 20 | namespace tflite { 21 | 22 | namespace reference_ops { 23 | 24 | template 25 | inline void Negate(const RuntimeShape& input_shape, const T* input_data, 26 | const RuntimeShape& output_shape, T* output_data) { 27 | const int flat_size = MatchingFlatSize(input_shape, output_shape); 28 | 29 | for (int i = 0; i < flat_size; ++i) { 30 | output_data[i] = -input_data[i]; 31 | } 32 | } 33 | 34 | } // namespace reference_ops 35 | } // namespace tflite 36 | 37 | #endif // TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_NEG_H_ 38 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/shim/test_op/simple_tflite_op.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2021 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 | #ifndef TENSORFLOW_LITE_KERNELS_SHIM_TEST_OP_SIMPLE_TFLITE_OP_H_ 16 | #define TENSORFLOW_LITE_KERNELS_SHIM_TEST_OP_SIMPLE_TFLITE_OP_H_ 17 | 18 | #include "tensorflow-lite/tensorflow/lite/core/c/common.h" 19 | #include "tensorflow-lite/tensorflow/lite/mutable_op_resolver.h" 20 | 21 | namespace tflite { 22 | namespace ops { 23 | namespace custom { 24 | 25 | // Add SimpleOp to the resolver 26 | void AddSimpleOp(MutableOpResolver* resolver); 27 | 28 | // Creates and returns the op kernel 29 | TfLiteRegistration* Register_SIMPLE_OP(); 30 | 31 | // The name of the op 32 | const char* OpName_SIMPLE_OP(); 33 | 34 | } // namespace custom 35 | } // namespace ops 36 | } // namespace tflite 37 | #endif // TENSORFLOW_LITE_KERNELS_SHIM_TEST_OP_SIMPLE_TFLITE_OP_H_ 38 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/optional_debug_tools.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2017 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 | /// \file 16 | /// 17 | /// Optional debugging functionality. 18 | /// For small sized binaries, these are not needed. 19 | #ifndef TENSORFLOW_LITE_OPTIONAL_DEBUG_TOOLS_H_ 20 | #define TENSORFLOW_LITE_OPTIONAL_DEBUG_TOOLS_H_ 21 | 22 | #include "tensorflow-lite/tensorflow/lite/core/interpreter.h" 23 | 24 | namespace tflite { 25 | 26 | // Prints a dump of what tensors and what nodes are in the interpreter. 27 | void PrintInterpreterState(const impl::Interpreter* interpreter, 28 | int32_t tensor_name_display_length = 25, 29 | int32_t tensor_type_display_length = 15, 30 | int32_t alloc_type_display_length = 18); 31 | 32 | } // namespace tflite 33 | 34 | #endif // TENSORFLOW_LITE_OPTIONAL_DEBUG_TOOLS_H_ 35 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/internal/mfcc_dct.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2018 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 | // Basic minimal DCT class for MFCC speech processing. 17 | 18 | #ifndef TENSORFLOW_LITE_KERNELS_INTERNAL_MFCC_DCT_H_ 19 | #define TENSORFLOW_LITE_KERNELS_INTERNAL_MFCC_DCT_H_ 20 | 21 | #include 22 | 23 | namespace tflite { 24 | namespace internal { 25 | 26 | class MfccDct { 27 | public: 28 | MfccDct(); 29 | bool Initialize(int input_length, int coefficient_count); 30 | void Compute(const std::vector& input, 31 | std::vector* output) const; 32 | 33 | private: 34 | bool initialized_; 35 | int coefficient_count_; 36 | int input_length_; 37 | std::vector > cosines_; 38 | }; 39 | 40 | } // namespace internal 41 | } // namespace tflite 42 | 43 | #endif // TENSORFLOW_LITE_KERNELS_INTERNAL_MFCC_DCT_H_ 44 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/internal/reference/ceil.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2018 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 | #ifndef TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_CEIL_H_ 16 | #define TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_CEIL_H_ 17 | 18 | #include 19 | 20 | #include "tensorflow-lite/tensorflow/lite/kernels/internal/types.h" 21 | 22 | namespace tflite { 23 | 24 | namespace reference_ops { 25 | 26 | inline void Ceil(const RuntimeShape& input_shape, const float* input_data, 27 | const RuntimeShape& output_shape, float* output_data) { 28 | const int flat_size = MatchingFlatSize(input_shape, output_shape); 29 | 30 | for (int i = 0; i < flat_size; ++i) { 31 | output_data[i] = std::ceil(input_data[i]); 32 | } 33 | } 34 | 35 | } // namespace reference_ops 36 | } // namespace tflite 37 | #endif // TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_CEIL_H_ 38 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/internal/reference/integer_ops/lut.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2022 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 | #ifndef TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_INTEGER_OPS_LUT_H_ 16 | #define TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_INTEGER_OPS_LUT_H_ 17 | 18 | #include "tensorflow-lite/tensorflow/lite/kernels/internal/common.h" 19 | 20 | namespace tflite { 21 | namespace reference_integer_ops { 22 | 23 | template 24 | inline void LookupTable(const InputT* input_data, int num_elements, 25 | const OutputT* lut, OutputT* output_data) { 26 | for (int i = 0; i < num_elements; ++i) { 27 | output_data[i] = LUTLookup(input_data[i], lut); 28 | } 29 | } 30 | 31 | } // namespace reference_integer_ops 32 | } // namespace tflite 33 | 34 | #endif // TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_INTEGER_OPS_LUT_H_ 35 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/internal/reference/exp.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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 | #ifndef TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_EXP_H_ 16 | #define TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_EXP_H_ 17 | 18 | #include 19 | 20 | #include "ruy/profiler/instrumentation.h" // from @ruy 21 | #include "tensorflow-lite/tensorflow/lite/kernels/internal/types.h" 22 | 23 | namespace tflite { 24 | namespace reference_ops { 25 | 26 | template 27 | inline void Exp(const T* input_data, const size_t num_elements, 28 | T* output_data) { 29 | ruy::profiler::ScopeLabel label("Exp"); 30 | for (size_t idx = 0; idx < num_elements; ++idx) { 31 | output_data[idx] = std::exp(input_data[idx]); 32 | } 33 | } 34 | 35 | } // namespace reference_ops 36 | } // namespace tflite 37 | 38 | #endif // TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_EXP_H_ 39 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/variants/py/register_list_ops_py.cc: -------------------------------------------------------------------------------- 1 | /* Copyright 2023 The TensorFlow Authors. All Rights Reserved. 2 | Licensed under the Apache License, Version 2.0 (the "License"); 3 | you may not use this file except in compliance with the License. 4 | You may obtain a copy of the License at 5 | http://www.apache.org/licenses/LICENSE-2.0 6 | Unless required by applicable law or agreed to in writing, software 7 | distributed under the License is distributed on an "AS IS" BASIS, 8 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 9 | See the License for the specific language governing permissions and 10 | limitations under the License. 11 | ==============================================================================*/ 12 | #include "pybind11/pybind11.h" // from @pybind11 13 | #include "pybind11/pytypes.h" // from @pybind11 14 | #include "tensorflow-lite/tensorflow/lite/kernels/variants/list_ops_lib.h" 15 | #include "tensorflow-lite/tensorflow/lite/kernels/variants/register_list_ops.h" 16 | #include "tensorflow-lite/tensorflow/lite/mutable_op_resolver.h" 17 | 18 | PYBIND11_MODULE(register_list_ops_py, m) { 19 | m.doc() = R"pbdoc( 20 | Bindings to register list ops with python interpreter. 21 | )pbdoc"; 22 | m.def( 23 | "TFLRegisterListOps", 24 | [](uintptr_t resolver) { 25 | ::tflite::variants::ops::RegisterListOps( 26 | reinterpret_cast<::tflite::MutableOpResolver*>(resolver)); 27 | }, 28 | R"pbdoc( 29 | Register all custom list ops. 30 | )pbdoc"); 31 | } 32 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/internal/reference/fill.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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 | #ifndef TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_FILL_H_ 16 | #define TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_FILL_H_ 17 | 18 | #include 19 | 20 | #include "tensorflow-lite/tensorflow/lite/kernels/internal/types.h" 21 | 22 | namespace tflite { 23 | namespace reference_ops { 24 | 25 | template 26 | void Fill(const RuntimeShape& value_shape, const T* value_data, 27 | const RuntimeShape& output_shape, T* output_data) { 28 | TFLITE_DCHECK_EQ(value_shape.DimensionsCount(), 0); 29 | const int flat_size = output_shape.FlatSize(); 30 | for (int i = 0; i < flat_size; ++i) { 31 | output_data[i] = *value_data; 32 | } 33 | } 34 | 35 | } // namespace reference_ops 36 | } // namespace tflite 37 | 38 | #endif // TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_FILL_H_ 39 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/create_op_resolver_with_builtin_ops.cc: -------------------------------------------------------------------------------- 1 | /* Copyright 2017 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 17 | 18 | #include "tensorflow-lite/tensorflow/lite/core/create_op_resolver.h" 19 | #include "tensorflow-lite/tensorflow/lite/core/kernels/register.h" 20 | 21 | namespace tflite { 22 | 23 | // This function instantiates a BuiltinOpResolverWithoutDefaultDelegates, with 24 | // all the builtin ops but without applying any TfLite delegates by default 25 | // (like the XNNPACK delegate). For smaller binary sizes users should avoid 26 | // linking this in, and should provide a CreateOpResolver() with selected ops 27 | // instead. 28 | std::unique_ptr CreateOpResolver() { // NOLINT 29 | return std::unique_ptr( 30 | new tflite::ops::builtin::BuiltinOpResolverWithoutDefaultDelegates()); 31 | } 32 | 33 | } // namespace tflite 34 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/core/create_op_resolver_with_builtin_ops.cc: -------------------------------------------------------------------------------- 1 | /* Copyright 2017 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 17 | 18 | #include "tensorflow-lite/tensorflow/lite/core/create_op_resolver.h" 19 | #include "tensorflow-lite/tensorflow/lite/core/kernels/register.h" 20 | 21 | namespace tflite { 22 | 23 | // This function instantiates a BuiltinOpResolverWithoutDefaultDelegates, with 24 | // all the builtin ops but without applying any TfLite delegates by default 25 | // (like the XNNPACK delegate). For smaller binary sizes users should avoid 26 | // linking this in, and should provide a CreateOpResolver() with selected ops 27 | // instead. 28 | std::unique_ptr CreateOpResolver() { // NOLINT 29 | return std::unique_ptr( 30 | new tflite::ops::builtin::BuiltinOpResolverWithoutDefaultDelegates()); 31 | } 32 | 33 | } // namespace tflite 34 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/internal/reference/floor.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 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 | #ifndef TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_FLOOR_H_ 16 | #define TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_FLOOR_H_ 17 | 18 | #include 19 | 20 | #include "tensorflow-lite/tensorflow/lite/kernels/internal/types.h" 21 | 22 | namespace tflite { 23 | 24 | namespace reference_ops { 25 | 26 | inline void Floor(const RuntimeShape& input_shape, const float* input_data, 27 | const RuntimeShape& output_shape, float* output_data) { 28 | const int flat_size = MatchingFlatSize(input_shape, output_shape); 29 | 30 | for (int i = 0; i < flat_size; i++) { 31 | int offset = i; 32 | output_data[offset] = std::floor(input_data[offset]); 33 | } 34 | } 35 | 36 | } // namespace reference_ops 37 | } // namespace tflite 38 | 39 | #endif // TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_FLOOR_H_ 40 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/shim/test_op/simple_tflite_op.cc: -------------------------------------------------------------------------------- 1 | /* Copyright 2021 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 | #include "tensorflow-lite/tensorflow/lite/kernels/shim/test_op/simple_tflite_op.h" 16 | 17 | #include "tensorflow-lite/tensorflow/lite/core/c/common.h" 18 | #include "tensorflow-lite/tensorflow/lite/kernels/shim/test_op/simple_op.h" 19 | #include "tensorflow-lite/tensorflow/lite/kernels/shim/tflite_op_shim.h" 20 | 21 | namespace tflite { 22 | namespace ops { 23 | namespace custom { 24 | 25 | using OpKernel = ::tflite::shim::TfLiteOpKernel; 26 | 27 | void AddSimpleOp(MutableOpResolver* resolver) { OpKernel::Add(resolver); } 28 | 29 | TfLiteRegistration* Register_SIMPLE_OP() { 30 | return OpKernel::GetTfLiteRegistration(); 31 | } 32 | 33 | const char* OpName_SIMPLE_OP() { return OpKernel::OpName(); } 34 | 35 | } // namespace custom 36 | } // namespace ops 37 | } // namespace tflite 38 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/core/api/verifier.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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 | /// \file 16 | /// 17 | /// Abstract interface for verifying a model. 18 | #ifndef TENSORFLOW_LITE_CORE_API_VERIFIER_H_ 19 | #define TENSORFLOW_LITE_CORE_API_VERIFIER_H_ 20 | 21 | #include "tensorflow-lite/tensorflow/lite/core/api/error_reporter.h" 22 | 23 | namespace tflite { 24 | 25 | /// Abstract interface that verifies whether a given model is legit. 26 | /// It facilitates the use-case to verify and build a model without loading it 27 | /// twice. 28 | /// (See also "tensorflow/lite/tools/verifier.h".) 29 | class TfLiteVerifier { 30 | public: 31 | /// Returns true if the model is legit. 32 | virtual bool Verify(const char* data, int length, 33 | ErrorReporter* reporter) = 0; 34 | virtual ~TfLiteVerifier() {} 35 | }; 36 | 37 | } // namespace tflite 38 | 39 | #endif // TENSORFLOW_LITE_CORE_API_VERIFIER_H_ 40 | -------------------------------------------------------------------------------- /third_party/rapidjson/internal/swap.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_INTERNAL_SWAP_H_ 16 | #define RAPIDJSON_INTERNAL_SWAP_H_ 17 | 18 | #include "../rapidjson.h" 19 | 20 | #if defined(__clang__) 21 | RAPIDJSON_DIAG_PUSH 22 | RAPIDJSON_DIAG_OFF(c++98-compat) 23 | #endif 24 | 25 | RAPIDJSON_NAMESPACE_BEGIN 26 | namespace internal { 27 | 28 | //! Custom swap() to avoid dependency on C++ header 29 | /*! \tparam T Type of the arguments to swap, should be instantiated with primitive C++ types only. 30 | \note This has the same semantics as std::swap(). 31 | */ 32 | template 33 | inline void Swap(T& a, T& b) RAPIDJSON_NOEXCEPT { 34 | T tmp = a; 35 | a = b; 36 | b = tmp; 37 | } 38 | 39 | } // namespace internal 40 | RAPIDJSON_NAMESPACE_END 41 | 42 | #if defined(__clang__) 43 | RAPIDJSON_DIAG_POP 44 | #endif 45 | 46 | #endif // RAPIDJSON_INTERNAL_SWAP_H_ 47 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/internal/opaque_tensor_ctypes.cc: -------------------------------------------------------------------------------- 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 "tensorflow-lite/tensorflow/lite/kernels/internal/opaque_tensor_ctypes.h" 17 | 18 | #include "tensorflow-lite/tensorflow/lite/c/c_api_opaque.h" 19 | #include "tensorflow-lite/tensorflow/lite/kernels/internal/runtime_shape.h" 20 | #include "tensorflow-lite/tensorflow/lite/namespace.h" 21 | 22 | namespace tflite { 23 | namespace TFLITE_CONDITIONAL_NAMESPACE { 24 | 25 | RuntimeShape GetTensorShape(const TfLiteOpaqueTensor* tensor) { 26 | if (tensor == nullptr) { 27 | return RuntimeShape(); 28 | } 29 | const int dims_size = TfLiteOpaqueTensorNumDims(tensor); 30 | RuntimeShape shape(dims_size); 31 | for (int i = 0; i < dims_size; ++i) { 32 | shape.SetDim(i, TfLiteOpaqueTensorDim(tensor, i)); 33 | } 34 | return shape; 35 | } 36 | 37 | } // namespace TFLITE_CONDITIONAL_NAMESPACE 38 | } // namespace tflite 39 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/internal/opaque_tensor_ctypes.h: -------------------------------------------------------------------------------- 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 | #ifndef TENSORFLOW_LITE_KERNELS_INTERNAL_OPAQUE_TENSOR_CTYPES_H_ 16 | #define TENSORFLOW_LITE_KERNELS_INTERNAL_OPAQUE_TENSOR_CTYPES_H_ 17 | 18 | #include "tensorflow-lite/tensorflow/lite/c/c_api_opaque.h" 19 | #include "tensorflow-lite/tensorflow/lite/core/macros.h" 20 | #include "tensorflow-lite/tensorflow/lite/kernels/internal/types.h" 21 | #include "tensorflow-lite/tensorflow/lite/namespace.h" 22 | 23 | namespace tflite { 24 | namespace TFLITE_CONDITIONAL_NAMESPACE { 25 | 26 | /// Returns the dimensions of the given tensor. 27 | TFLITE_NOINLINE RuntimeShape GetTensorShape(const TfLiteOpaqueTensor* tensor); 28 | 29 | } // namespace TFLITE_CONDITIONAL_NAMESPACE 30 | 31 | using ::tflite::TFLITE_CONDITIONAL_NAMESPACE::GetTensorShape; 32 | 33 | } // namespace tflite 34 | 35 | #endif // TENSORFLOW_LITE_KERNELS_INTERNAL_OPAQUE_TENSOR_CTYPES_H_ 36 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/register_ref.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2018 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 | #ifndef TENSORFLOW_LITE_KERNELS_REGISTER_REF_H_ 16 | #define TENSORFLOW_LITE_KERNELS_REGISTER_REF_H_ 17 | 18 | #include "tensorflow-lite/tensorflow/lite/core/c/common.h" 19 | #include "tensorflow-lite/tensorflow/lite/mutable_op_resolver.h" 20 | #include "tensorflow-lite/tensorflow/lite/schema/schema_generated.h" 21 | 22 | namespace tflite { 23 | namespace ops { 24 | namespace builtin { 25 | 26 | class BuiltinRefOpResolver : public MutableOpResolver { 27 | public: 28 | BuiltinRefOpResolver(); 29 | 30 | const TfLiteRegistration* FindOp(tflite::BuiltinOperator op, 31 | int version) const override; 32 | const TfLiteRegistration* FindOp(const char* op, int version) const override; 33 | }; 34 | 35 | } // namespace builtin 36 | } // namespace ops 37 | } // namespace tflite 38 | 39 | #endif // TENSORFLOW_LITE_KERNELS_REGISTER_REF_H_ 40 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/internal/signature_def.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2021 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 | #ifndef TENSORFLOW_LITE_INTERNAL_SIGNATURE_DEF_H_ 16 | #define TENSORFLOW_LITE_INTERNAL_SIGNATURE_DEF_H_ 17 | 18 | #include 19 | #include 20 | 21 | namespace tflite { 22 | namespace internal { 23 | 24 | // Structure representing SignatureDef inputs/outputs. 25 | struct SignatureDef { 26 | // Maps name in signature def as key to index of the tensor in the model. 27 | std::map inputs; 28 | // Maps name in signature def as key to index of the tensor in the model. 29 | std::map outputs; 30 | // The key of this SignatureDef in the SavedModel signature def map. 31 | std::string signature_key; 32 | // The subgraph index of the signature in the model. 33 | uint32_t subgraph_index; 34 | }; 35 | 36 | } // namespace internal 37 | } // namespace tflite 38 | #endif // TENSORFLOW_LITE_INTERNAL_SIGNATURE_DEF_H_ 39 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/internal/cppmath.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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 | #ifndef TENSORFLOW_LITE_KERNELS_INTERNAL_CPPMATH_H_ 16 | #define TENSORFLOW_LITE_KERNELS_INTERNAL_CPPMATH_H_ 17 | 18 | #include 19 | 20 | namespace tflite { 21 | 22 | #if defined(TF_LITE_USE_GLOBAL_CMATH_FUNCTIONS) || \ 23 | (defined(__ANDROID__) && !defined(__NDK_MAJOR__)) || defined(__ZEPHYR__) 24 | #define TF_LITE_GLOBAL_STD_PREFIX 25 | #else 26 | #define TF_LITE_GLOBAL_STD_PREFIX std 27 | #endif 28 | 29 | #define DECLARE_STD_GLOBAL_SWITCH1(tf_name, std_name) \ 30 | template \ 31 | inline T tf_name(const T x) { \ 32 | return TF_LITE_GLOBAL_STD_PREFIX::std_name(x); \ 33 | } 34 | 35 | DECLARE_STD_GLOBAL_SWITCH1(TfLiteRound, round) 36 | DECLARE_STD_GLOBAL_SWITCH1(TfLiteExpm1, expm1) 37 | 38 | } // namespace tflite 39 | 40 | #endif // TENSORFLOW_LITE_KERNELS_INTERNAL_CPPMATH_H_ 41 | -------------------------------------------------------------------------------- /tensorflow-lite/flatbuffers/file_manager.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2023 Google Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef FLATBUFFERS_FILE_MANAGER_H_ 18 | #define FLATBUFFERS_FILE_MANAGER_H_ 19 | 20 | #include 21 | #include 22 | 23 | #include "tensorflow-lite/flatbuffers/util.h" 24 | 25 | namespace flatbuffers { 26 | 27 | // A File interface to write data to file by default or 28 | // save only file names 29 | class FileManager { 30 | public: 31 | FileManager() = default; 32 | virtual ~FileManager() = default; 33 | 34 | virtual bool SaveFile(const std::string &absolute_file_name, 35 | const std::string &content) = 0; 36 | 37 | virtual bool LoadFile(const std::string &absolute_file_name, 38 | std::string *buf) = 0; 39 | 40 | private: 41 | // Copying is not supported. 42 | FileManager(const FileManager &) = delete; 43 | FileManager &operator=(const FileManager &) = delete; 44 | }; 45 | 46 | } // namespace flatbuffers 47 | 48 | #endif // FLATBUFFERS_FILE_MANAGER_H_ 49 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/core/async/c/types.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2022 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 | #ifndef TENSORFLOW_LITE_CORE_ASYNC_C_TYPES_H_ 16 | #define TENSORFLOW_LITE_CORE_ASYNC_C_TYPES_H_ 17 | 18 | #ifdef __cplusplus 19 | extern "C" { 20 | #endif // __cplusplus 21 | 22 | /// Opaque type for TfLiteAsyncKernel. 23 | typedef struct TfLiteAsyncKernel TfLiteAsyncKernel; 24 | 25 | /// Opaque type for TfLiteExecutionTask. 26 | /// 27 | /// See tensorflow/lite/core/async/c/task.h 28 | /// NOTE: TfLiteExecutionTask is NOT thread-safe. 29 | typedef struct TfLiteExecutionTask TfLiteExecutionTask; 30 | 31 | /// Enum tag for specifying whether a tensor is the input or output to the 32 | /// model. 33 | typedef enum TfLiteIoType { 34 | kTfLiteIoTypeUnknown = 0, 35 | kTfLiteIoTypeInput = 1, 36 | kTfLiteIoTypeOutput = 2, 37 | } TfLiteIoType; 38 | 39 | #ifdef __cplusplus 40 | } // extern "C" 41 | #endif // __cplusplus 42 | 43 | #endif // TENSORFLOW_LITE_CORE_ASYNC_C_TYPES_H_ 44 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/internal/reference/elu.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2021 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 | #ifndef TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_ELU_H_ 16 | #define TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_ELU_H_ 17 | 18 | #include "tensorflow-lite/tensorflow/lite/kernels/internal/cppmath.h" 19 | #include "tensorflow-lite/tensorflow/lite/kernels/internal/types.h" 20 | 21 | namespace tflite { 22 | 23 | namespace reference_ops { 24 | 25 | inline void Elu(const RuntimeShape& input_shape, const float* input_data, 26 | const RuntimeShape& output_shape, float* output_data) { 27 | const int flat_size = MatchingFlatSize(input_shape, output_shape); 28 | for (int i = 0; i < flat_size; ++i) { 29 | const float val = input_data[i]; 30 | output_data[i] = val < 0.0f ? TfLiteExpm1(val) : val; 31 | } 32 | } 33 | 34 | } // namespace reference_ops 35 | } // namespace tflite 36 | 37 | #endif // TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_ELU_H_ 38 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/core/async/c/internal.h: -------------------------------------------------------------------------------- 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 | #ifndef TENSORFLOW_LITE_CORE_ASYNC_C_INTERNAL_H_ 16 | #define TENSORFLOW_LITE_CORE_ASYNC_C_INTERNAL_H_ 17 | 18 | #include "tensorflow-lite/tensorflow/lite/core/async/async_signature_runner.h" 19 | 20 | // Internal structures and subroutines used by the C API. These are likely to 21 | // change and should not be depended on directly by any C API clients. 22 | // 23 | // NOTE: This header does not follow C conventions and does not define a C API. 24 | // It is effectively an (internal) implementation detail of the C API. 25 | 26 | struct TfLiteAsyncSignatureRunner { 27 | // The tflite::async::AsyncSignatureRunner runner object that this points to 28 | // is owned by the interpreter. So this pointer will become invalid when the 29 | // interpreter is destroyed. 30 | tflite::async::AsyncSignatureRunner* impl; 31 | }; 32 | 33 | #endif // TENSORFLOW_LITE_CORE_ASYNC_C_INTERNAL_H_ 34 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/version.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2017 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 | #ifndef TENSORFLOW_LITE_VERSION_H_ 16 | #define TENSORFLOW_LITE_VERSION_H_ 17 | 18 | #include "tensorflow-lite/tensorflow/core/public/version.h" 19 | 20 | // The version number of the Schema. Ideally all changes will be backward 21 | // compatible. If that ever changes, we must ensure that version is the first 22 | // entry in the new tflite root so that we can see that version is not 1. 23 | #define TFLITE_SCHEMA_VERSION (3) 24 | 25 | // TensorFlow Lite Runtime version. 26 | // This value is currently shared with that of TensorFlow. 27 | #define TFLITE_VERSION_STRING TF_VERSION_STRING 28 | 29 | // TensorFlow Lite Extension APIs version. 30 | // This is the semantic version number for the custom op and delegate APIs. 31 | // This value is currently shared with that of TensorFlow Lite. 32 | #define TFLITE_EXTENSION_APIS_VERSION_STRING TFLITE_VERSION_STRING 33 | 34 | #endif // TENSORFLOW_LITE_VERSION_H_ 35 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/core/async/interop/variant.cc: -------------------------------------------------------------------------------- 1 | /* Copyright 2022 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 | #include "tensorflow-lite/tensorflow/lite/core/async/interop/variant.h" 16 | 17 | #include 18 | #include 19 | 20 | namespace tflite { 21 | namespace interop { 22 | 23 | Variant::Variant() { 24 | type = kInvalid; 25 | val.i = 0; 26 | } 27 | 28 | bool Variant::operator==(const Variant& other) const { 29 | if (type != other.type) return false; 30 | switch (type) { 31 | case kInvalid: 32 | // Treats uninitialized variant equals. 33 | return true; 34 | case kInt: 35 | return val.i == other.val.i; 36 | case kSizeT: 37 | return val.s == other.val.s; 38 | case kString: 39 | return (val.c == other.val.c) || (strcmp(val.c, other.val.c) == 0); 40 | } 41 | } 42 | 43 | bool Variant::operator!=(const Variant& other) const { 44 | return !(*this == other); 45 | } 46 | 47 | } // namespace interop 48 | } // namespace tflite 49 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/create_op_resolver_with_selected_ops.cc: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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 17 | 18 | #include "tensorflow-lite/tensorflow/lite/core/create_op_resolver.h" 19 | #include "tensorflow-lite/tensorflow/lite/mutable_op_resolver.h" 20 | 21 | // This method is generated by `gen_selected_ops`. 22 | extern void RegisterSelectedOps(::tflite::MutableOpResolver* resolver); 23 | 24 | namespace tflite { 25 | // This interface is the unified entry point for creating op resolver 26 | // regardless if selective registration is being used. C++ client will call 27 | // this method directly and Java client will call this method indirectly via 28 | // JNI code in interpreter_jni.cc. 29 | std::unique_ptr CreateOpResolver() { 30 | std::unique_ptr resolver = 31 | std::make_unique(); 32 | RegisterSelectedOps(resolver.get()); 33 | return resolver; 34 | } 35 | 36 | } // namespace tflite 37 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/experimental/resource/initialization_status.cc: -------------------------------------------------------------------------------- 1 | /* Copyright 2021 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 "tensorflow-lite/tensorflow/lite/experimental/resource/initialization_status.h" 17 | 18 | namespace tflite { 19 | namespace resource { 20 | 21 | void InitializationStatus::MarkInitializationIsDone() { 22 | is_initialized_ = true; 23 | } 24 | 25 | bool InitializationStatus::IsInitialized() { return is_initialized_; } 26 | 27 | InitializationStatus* GetInitializationStatus(InitializationStatusMap* map, 28 | int subgraph_id) { 29 | auto it = map->find(subgraph_id); 30 | if (it != map->end()) { 31 | return static_cast(it->second.get()); 32 | } 33 | 34 | InitializationStatus* status = new InitializationStatus(); 35 | map->emplace(subgraph_id, std::unique_ptr(status)); 36 | return status; 37 | } 38 | 39 | } // namespace resource 40 | } // namespace tflite 41 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/core/create_op_resolver.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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 | /// WARNING: Users of TensorFlow Lite should not include this file directly, 16 | /// but should instead include 17 | /// "third_party/tensorflow/lite/create_op_resolver.h". 18 | /// Only the TensorFlow Lite implementation itself should include this 19 | /// file directly. 20 | #ifndef TENSORFLOW_LITE_CORE_CREATE_OP_RESOLVER_H_ 21 | #define TENSORFLOW_LITE_CORE_CREATE_OP_RESOLVER_H_ 22 | 23 | #include 24 | 25 | #include "tensorflow-lite/tensorflow/lite/mutable_op_resolver.h" 26 | // The following include is not needed but is kept for now to not break 27 | // compatibility for existing clients; it should be removed with the next 28 | // non-backwards compatible version of TFLite. 29 | #include "tensorflow-lite/tensorflow/lite/op_resolver.h" 30 | 31 | namespace tflite { 32 | std::unique_ptr CreateOpResolver(); 33 | } // namespace tflite 34 | 35 | #endif // TENSORFLOW_LITE_CORE_CREATE_OP_RESOLVER_H_ 36 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/variants/README.md: -------------------------------------------------------------------------------- 1 | # TfLite Variants 2 | 3 | Variant tensors in TensorFlow wrap and store arbitrary C++ objects within their 4 | data members. Common usage regards non-trivial and potentially referential 5 | buffer semantics (TensorLists and DataSets being cannonical examples). 6 | 7 | This directory contains implementations for these containers 8 | and kernels for the tflite runtime. 9 | Currently tflite supplies performant custom kernels for a subset of 10 | `tf.list_ops`. 11 | Also refer to [variant tensor in the tflite common api](https://github.com/tensorflow/tensorflow/blob/61c76427561a46d03605370fc685d810c1c3e717/tensorflow/lite/core/c/common.h#L1320C9-L1320C9) 12 | , [tensor list legalization](https://github.com/tensorflow/tensorflow/blob/d36fb81bc1ef258d5024b791d61cdd5136ca09af/tensorflow/compiler/mlir/lite/transforms/legalize_tensorlist.cc) 13 | , and [end to end python tests](https://github.com/tensorflow/tensorflow/blob/d36fb81bc1ef258d5024b791d61cdd5136ca09af/tensorflow/lite/kernels/variants/py/end_to_end_test.py) 14 | for example usage. 15 | 16 | **api** 17 | 18 | * `./py/register_list_ops_py.py` : Bindings for registering ops in python. 19 | * `./list_ops_lib` : Include for tensorlist kernel registrations. 20 | * `./register_list_ops` : Register all kernels with op resolver in C++. 21 | 22 | **implementations** 23 | 24 | * `./list_kernels/` : Custom `TensorList*` kernels for tflite. 25 | * `./tensor_array` : A variable length array of reference counted `TfLiteTensor` 26 | . 27 | 28 | **tests** 29 | 30 | * `/list_ops_subgraph_test` : Multi-Op tests through C++ api. 31 | * `/py/end_to_end_test.py` : Tests through python api and compare to `tf.list_ops`. 32 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/internal/reference/cast.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 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 | #ifndef TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_CAST_H_ 16 | #define TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_CAST_H_ 17 | 18 | #include "tensorflow-lite/tensorflow/lite/kernels/internal/common.h" 19 | #include "tensorflow-lite/tensorflow/lite/kernels/internal/types.h" 20 | 21 | namespace tflite { 22 | 23 | namespace reference_ops { 24 | 25 | template 26 | inline void Cast(const RuntimeShape& input_shape, const SrcT* input_data, 27 | const RuntimeShape& output_shape, DstT* output_data) { 28 | const int flat_size = MatchingFlatSize(input_shape, output_shape); 29 | 30 | for (int i = 0; i < flat_size; i++) { 31 | int offset = i; 32 | output_data[offset] = static_cast(input_data[offset]); 33 | } 34 | } 35 | 36 | } // namespace reference_ops 37 | } // namespace tflite 38 | 39 | #endif // TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_CAST_H_ 40 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/internal/optimized/neon_check.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 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 | #ifndef TENSORFLOW_LITE_KERNELS_INTERNAL_OPTIMIZED_NEON_CHECK_H_ 16 | #define TENSORFLOW_LITE_KERNELS_INTERNAL_OPTIMIZED_NEON_CHECK_H_ 17 | 18 | #if defined(__ARM_NEON__) || defined(__ARM_NEON) 19 | #define USE_NEON 20 | #include // IWYU pragma: export 21 | #endif 22 | 23 | #if defined __GNUC__ && defined __SSE4_1__ && !defined TF_LITE_DISABLE_X86_NEON 24 | #define USE_NEON 25 | #include "NEON_2_SSE.h" // IWYU pragma: export 26 | #endif 27 | 28 | // NEON_OR_PORTABLE(SomeFunc, args) calls NeonSomeFunc(args) if USE_NEON is 29 | // defined, PortableSomeFunc(args) otherwise. 30 | #ifdef USE_NEON 31 | // Always use Neon code 32 | #define NEON_OR_PORTABLE(funcname, ...) Neon##funcname(__VA_ARGS__) 33 | 34 | #else 35 | // No NEON available: Use Portable code 36 | #define NEON_OR_PORTABLE(funcname, ...) Portable##funcname(__VA_ARGS__) 37 | 38 | #endif // defined(USE_NEON) 39 | 40 | #endif // TENSORFLOW_LITE_KERNELS_INTERNAL_OPTIMIZED_NEON_CHECK_H_ 41 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/type_to_tflitetype.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 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 | #ifndef TENSORFLOW_LITE_TYPE_TO_TFLITETYPE_H_ 16 | #define TENSORFLOW_LITE_TYPE_TO_TFLITETYPE_H_ 17 | 18 | #include 19 | #include 20 | 21 | #include "tensorflow-lite/tensorflow/lite/core/c/common.h" 22 | 23 | // Most of the definitions have been moved to this subheader so that Micro 24 | // can include it without relying on and , which isn't 25 | // available on all platforms. 26 | #include "tensorflow-lite/tensorflow/lite/portable_type_to_tflitetype.h" 27 | 28 | namespace tflite { 29 | 30 | // TODO(b/163167649): This string conversion means that only the first entry 31 | // in a string tensor will be returned as a std::string, so it's deprecated. 32 | MATCH_TYPE_AND_TFLITE_TYPE(std::string, kTfLiteString); 33 | 34 | MATCH_TYPE_AND_TFLITE_TYPE(std::complex, kTfLiteComplex64); 35 | MATCH_TYPE_AND_TFLITE_TYPE(std::complex, kTfLiteComplex128); 36 | 37 | } // namespace tflite 38 | #endif // TENSORFLOW_LITE_TYPE_TO_TFLITETYPE_H_ 39 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/external_cpu_backend_context.cc: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 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 | #include "tensorflow-lite/tensorflow/lite/external_cpu_backend_context.h" 16 | 17 | #include "tensorflow-lite/tensorflow/lite/core/c/common.h" 18 | 19 | namespace tflite { 20 | namespace { 21 | 22 | TfLiteStatus RefreshExternalCpuBackendContext(TfLiteContext* context) { 23 | auto* const external_context = static_cast( 24 | context->GetExternalContext(context, kTfLiteCpuBackendContext)); 25 | if (external_context && external_context->internal_backend_context() && 26 | context->recommended_num_threads != -1) { 27 | external_context->internal_backend_context()->SetMaxNumThreads( 28 | context->recommended_num_threads); 29 | } 30 | return kTfLiteOk; 31 | } 32 | } // namespace 33 | 34 | ExternalCpuBackendContext::ExternalCpuBackendContext() 35 | : internal_backend_context_(nullptr) { 36 | this->type = kTfLiteCpuBackendContext; 37 | this->Refresh = RefreshExternalCpuBackendContext; 38 | } 39 | 40 | } // namespace tflite 41 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/internal/reference/comparisons.cc: -------------------------------------------------------------------------------- 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 "tensorflow-lite/tensorflow/lite/kernels/internal/reference/comparisons.h" 17 | 18 | namespace tflite { 19 | namespace reference_ops { 20 | 21 | BroadcastComparison4DSlowCommon BroadcastComparison4DSlowPreprocess( 22 | const RuntimeShape& unextended_input1_shape, 23 | const RuntimeShape& unextended_input2_shape, 24 | const RuntimeShape& unextended_output_shape) { 25 | TFLITE_DCHECK_LE(unextended_input1_shape.DimensionsCount(), 4); 26 | TFLITE_DCHECK_LE(unextended_input2_shape.DimensionsCount(), 4); 27 | TFLITE_DCHECK_LE(unextended_output_shape.DimensionsCount(), 4); 28 | NdArrayDesc<4> desc1; 29 | NdArrayDesc<4> desc2; 30 | NdArrayDescsForElementwiseBroadcast(unextended_input1_shape, 31 | unextended_input2_shape, &desc1, &desc2); 32 | return {RuntimeShape::ExtendedShape(4, unextended_output_shape), desc1, 33 | desc2}; 34 | } 35 | 36 | } // namespace reference_ops 37 | } // namespace tflite 38 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/internal/reference/floor_mod.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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 | #ifndef TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_FLOOR_MOD_H_ 16 | #define TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_FLOOR_MOD_H_ 17 | 18 | #include 19 | #include 20 | 21 | namespace tflite { 22 | 23 | namespace reference_ops { 24 | 25 | template 26 | T FloorMod(T input1, T input2) { 27 | struct FloatMod { 28 | float operator()(const float lhs, const float rhs) const { 29 | return std::fmod(lhs, rhs); 30 | } 31 | }; 32 | using ModFunc = typename std::conditional::value, 33 | std::modulus, FloatMod>::type; 34 | ModFunc mod_func; 35 | T trunc_mod = mod_func(input1, input2); 36 | return (trunc_mod != 0) && ((input2 < 0) != (trunc_mod < 0)) 37 | ? (trunc_mod + input2) 38 | : trunc_mod; 39 | } 40 | 41 | } // namespace reference_ops 42 | } // namespace tflite 43 | 44 | #endif // TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_FLOOR_MOD_H_ 45 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/internal/runtime_shape.cc: -------------------------------------------------------------------------------- 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 "tensorflow-lite/tensorflow/lite/kernels/internal/runtime_shape.h" 17 | 18 | #include 19 | 20 | namespace tflite { 21 | 22 | RuntimeShape::~RuntimeShape() { 23 | if (size_ > kMaxSmallSize) { 24 | delete[] dims_pointer_; 25 | } 26 | } 27 | 28 | int32_t RuntimeShape::Dims(int i) const { 29 | TFLITE_DCHECK_GE(i, 0); 30 | TFLITE_DCHECK_LT(i, size_); 31 | return size_ > kMaxSmallSize ? dims_pointer_[i] : dims_[i]; 32 | } 33 | 34 | void RuntimeShape::ReplaceWith(int dimensions_count, const int32_t* dims_data) { 35 | Resize(dimensions_count); 36 | int32_t* dst_dims = DimsData(); 37 | std::memcpy(dst_dims, dims_data, dimensions_count * sizeof(int32_t)); 38 | } 39 | 40 | int RuntimeShape::FlatSize() const { 41 | int buffer_size = 1; 42 | const int* dims_data = reinterpret_cast(DimsData()); 43 | for (int i = 0; i < size_; i++) { 44 | buffer_size *= dims_data[i]; 45 | } 46 | return buffer_size; 47 | } 48 | 49 | } // namespace tflite 50 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/minimal_logging_default.cc: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 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 17 | 18 | #include 19 | 20 | #include "tensorflow-lite/tensorflow/lite/minimal_logging.h" 21 | 22 | namespace tflite { 23 | namespace logging_internal { 24 | 25 | #ifndef NDEBUG 26 | // In debug builds, default is VERBOSE. 27 | LogSeverity MinimalLogger::minimum_log_severity_ = TFLITE_LOG_VERBOSE; 28 | #else 29 | // In prod builds, default is INFO. 30 | LogSeverity MinimalLogger::minimum_log_severity_ = TFLITE_LOG_INFO; 31 | #endif 32 | 33 | void MinimalLogger::LogFormatted(LogSeverity severity, const char* format, 34 | va_list args) { 35 | if (severity >= MinimalLogger::minimum_log_severity_) { 36 | fprintf(stderr, "%s: ", GetSeverityName(severity)); 37 | #pragma clang diagnostic push 38 | #pragma clang diagnostic ignored "-Wformat-nonliteral" 39 | vfprintf(stderr, format, args); 40 | #pragma clang diagnostic pop 41 | fputc('\n', stderr); 42 | } 43 | } 44 | 45 | } // namespace logging_internal 46 | } // namespace tflite 47 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/profiling/noop_profiler.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 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 | #ifndef TENSORFLOW_LITE_PROFILING_NOOP_PROFILER_H_ 16 | #define TENSORFLOW_LITE_PROFILING_NOOP_PROFILER_H_ 17 | 18 | #include 19 | 20 | #include "tensorflow-lite/tensorflow/lite/core/api/profiler.h" 21 | #include "tensorflow-lite/tensorflow/lite/profiling/profile_buffer.h" 22 | 23 | namespace tflite { 24 | namespace profiling { 25 | 26 | // A noop version of profiler when profiling is disabled. 27 | class NoopProfiler : public tflite::Profiler { 28 | public: 29 | NoopProfiler() {} 30 | explicit NoopProfiler(int max_profiling_buffer_entries) {} 31 | 32 | uint32_t BeginEvent(const char*, EventType, int64_t, int64_t) override { 33 | return 0; 34 | } 35 | void EndEvent(uint32_t) override {} 36 | 37 | void StartProfiling() {} 38 | void StopProfiling() {} 39 | void Reset() {} 40 | std::vector GetProfileEvents() { return {}; } 41 | }; 42 | 43 | } // namespace profiling 44 | } // namespace tflite 45 | 46 | #endif // TENSORFLOW_LITE_PROFILING_NOOP_PROFILER_H_ 47 | -------------------------------------------------------------------------------- /tensorflow-lite/flatbuffers/buffer_ref.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Google Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef FLATBUFFERS_BUFFER_REF_H_ 18 | #define FLATBUFFERS_BUFFER_REF_H_ 19 | 20 | #include "tensorflow-lite/flatbuffers/base.h" 21 | #include "tensorflow-lite/flatbuffers/verifier.h" 22 | 23 | namespace flatbuffers { 24 | 25 | // Convenient way to bundle a buffer and its length, to pass it around 26 | // typed by its root. 27 | // A BufferRef does not own its buffer. 28 | struct BufferRefBase {}; // for std::is_base_of 29 | 30 | template struct BufferRef : BufferRefBase { 31 | BufferRef() : buf(nullptr), len(0), must_free(false) {} 32 | BufferRef(uint8_t *_buf, uoffset_t _len) 33 | : buf(_buf), len(_len), must_free(false) {} 34 | 35 | ~BufferRef() { 36 | if (must_free) free(buf); 37 | } 38 | 39 | const T *GetRoot() const { return flatbuffers::GetRoot(buf); } 40 | 41 | bool Verify() { 42 | Verifier verifier(buf, len); 43 | return verifier.VerifyBuffer(nullptr); 44 | } 45 | 46 | uint8_t *buf; 47 | uoffset_t len; 48 | bool must_free; 49 | }; 50 | 51 | } // namespace flatbuffers 52 | 53 | #endif // FLATBUFFERS_BUFFER_REF_H_ 54 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/internal/tensor_ctypes.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2017 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 | #ifndef TENSORFLOW_LITE_KERNELS_INTERNAL_TENSOR_CTYPES_H_ 16 | #define TENSORFLOW_LITE_KERNELS_INTERNAL_TENSOR_CTYPES_H_ 17 | 18 | #include 19 | 20 | #include "tensorflow-lite/tensorflow/lite/core/c/common.h" 21 | #include "tensorflow-lite/tensorflow/lite/core/macros.h" 22 | #include "tensorflow-lite/tensorflow/lite/kernels/internal/types.h" 23 | 24 | namespace tflite { 25 | 26 | template 27 | inline T* GetTensorData(TfLiteTensor* tensor) { 28 | return tensor != nullptr ? reinterpret_cast(tensor->data.raw) : nullptr; 29 | } 30 | 31 | template 32 | inline const T* GetTensorData(const TfLiteTensor* tensor) { 33 | return tensor != nullptr ? reinterpret_cast(tensor->data.raw) 34 | : nullptr; 35 | } 36 | 37 | TFLITE_NOINLINE RuntimeShape GetTensorShape(const TfLiteTensor* tensor); 38 | RuntimeShape GetTensorShape(std::vector data); 39 | 40 | } // namespace tflite 41 | 42 | #endif // TENSORFLOW_LITE_KERNELS_INTERNAL_TENSOR_CTYPES_H_ 43 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The Clear BSD License 2 | 3 | Copyright (c) 2025 EdgeImpulse Inc. 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted (subject to the limitations in the disclaimer 8 | below) provided that the following conditions are met: 9 | 10 | * Redistributions of source code must retain the above copyright notice, 11 | this list of conditions and the following disclaimer. 12 | 13 | * Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 17 | * Neither the name of the copyright holder nor the names of its 18 | contributors may be used to endorse or promote products derived from this 19 | software without specific prior written permission. 20 | 21 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY 22 | THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 23 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 25 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 26 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 27 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 28 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 29 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 30 | IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 32 | POSSIBILITY OF SUCH DAMAGE. 33 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/cpu_backend_gemm_eigen.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2019 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 | #ifndef TENSORFLOW_LITE_KERNELS_CPU_BACKEND_GEMM_EIGEN_H_ 17 | #define TENSORFLOW_LITE_KERNELS_CPU_BACKEND_GEMM_EIGEN_H_ 18 | 19 | #ifndef TFLITE_WITH_RUY 20 | 21 | #include "tensorflow-lite/tensorflow/lite/kernels/cpu_backend_context.h" 22 | #include "tensorflow-lite/tensorflow/lite/kernels/cpu_backend_gemm_params.h" 23 | 24 | namespace tflite { 25 | namespace cpu_backend_gemm { 26 | namespace detail { 27 | 28 | struct GemmImplUsingEigen { 29 | static void Run(const MatrixParams& lhs_params, const float* lhs_data, 30 | const MatrixParams& rhs_params, const float* rhs_data, 31 | const MatrixParams& dst_params, float* dst_data, 32 | const GemmParams& params, 33 | CpuBackendContext* /* context */); 34 | }; 35 | 36 | } // namespace detail 37 | } // namespace cpu_backend_gemm 38 | } // namespace tflite 39 | 40 | #endif // not TFLITE_WITH_RUY 41 | 42 | #endif // TENSORFLOW_LITE_KERNELS_CPU_BACKEND_GEMM_EIGEN_H_ 43 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/fully_connected.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2017 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 | // Forward declares registrations for specific FC layer implementations. Do not 17 | // include this header if you are fine with any FC implementation, include 18 | // builtin_op_kernels.h instead. This implementation-specific registration is 19 | // only available for FC, as these versions are explicitly tested and supported. 20 | 21 | #ifndef TENSORFLOW_LITE_KERNELS_FULLY_CONNECTED_H_ 22 | #define TENSORFLOW_LITE_KERNELS_FULLY_CONNECTED_H_ 23 | 24 | #include "tensorflow-lite/tensorflow/lite/core/c/common.h" 25 | 26 | namespace tflite { 27 | namespace ops { 28 | namespace builtin { 29 | TfLiteRegistration* Register_FULLY_CONNECTED_REF(); 30 | TfLiteRegistration* Register_FULLY_CONNECTED_GENERIC_OPT(); 31 | TfLiteRegistration* Register_FULLY_CONNECTED_PIE(); 32 | TfLiteRegistration* Register_FULLY_CONNECTED_SPARSE_REF(); 33 | TfLiteRegistration* Register_FULLY_CONNECTED_SPARSE_OPT(); 34 | } // namespace builtin 35 | } // namespace ops 36 | } // namespace tflite 37 | 38 | #endif // TENSORFLOW_LITE_KERNELS_FULLY_CONNECTED_H_ 39 | -------------------------------------------------------------------------------- /third_party/pybind11/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 Wenzel Jakob , All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, this 7 | list of conditions and the following disclaimer. 8 | 9 | 2. Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | 13 | 3. Neither the name of the copyright holder nor the names of its contributors 14 | may be used to endorse or promote products derived from this software 15 | without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | 28 | Please also refer to the file .github/CONTRIBUTING.md, which clarifies licensing of 29 | external contributions to this project including patches, pull requests, etc. 30 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/internal/optimized/cpu_check.h: -------------------------------------------------------------------------------- 1 | /* Copyright 2017 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 | #ifndef TENSORFLOW_LITE_KERNELS_INTERNAL_OPTIMIZED_CPU_CHECK_H_ 16 | #define TENSORFLOW_LITE_KERNELS_INTERNAL_OPTIMIZED_CPU_CHECK_H_ 17 | 18 | // This include is superfluous. However, it's been here for a while, and a 19 | // number of files have been relying on it to include neon_check.h for them. 20 | // This should be removed, but with a global run of presubmits to catch 21 | // any such issues. This requires running more than just TFLite presubmits. 22 | #include "tensorflow-lite/tensorflow/lite/kernels/internal/optimized/neon_check.h" 23 | 24 | namespace tflite { 25 | 26 | // On A64, returns true if the dotprod extension is present. 27 | // On other architectures, returns false unconditionally. 28 | bool DetectArmNeonDotprod(); 29 | 30 | struct CpuFlags { 31 | bool neon_dotprod = false; 32 | }; 33 | 34 | inline void GetCpuFlags(CpuFlags* cpu_flags) { 35 | cpu_flags->neon_dotprod = DetectArmNeonDotprod(); 36 | } 37 | 38 | } // namespace tflite 39 | 40 | #endif // TENSORFLOW_LITE_KERNELS_INTERNAL_OPTIMIZED_CPU_CHECK_H_ 41 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/rng_util.h: -------------------------------------------------------------------------------- 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 | #ifndef TENSORFLOW_LITE_KERNELS_RNG_UTIL_H_ 16 | #define TENSORFLOW_LITE_KERNELS_RNG_UTIL_H_ 17 | 18 | #include 19 | #include 20 | 21 | namespace tflite { 22 | namespace rng { 23 | 24 | // Implements the ThreeFry counter-based PRNG algorithm. Use 20 rounds. 25 | // Salmon et al. SC 2011. Parallel random numbers: as easy as 1, 2, 3. 26 | // http://www.thesalmons.org/john/random123/papers/random123sc11.pdf 27 | std::array Threefry2x32(uint32_t key_0, uint32_t key_1, 28 | std::array ctr); 29 | 30 | // Implements the Philox4x32 counter-based PRNG algorithm. Use 10 rounds. 31 | // Salmon et al. SC 2011. Parallel random numbers: as easy as 1, 2, 3. 32 | // http://www.thesalmons.org/john/random123/papers/random123sc11.pdf 33 | std::array Philox4x32(uint32_t key_0, uint32_t key_1, 34 | std::array ctr); 35 | 36 | } // namespace rng 37 | } // namespace tflite 38 | 39 | #endif // TENSORFLOW_LITE_KERNELS_RNG_UTIL_H_ 40 | -------------------------------------------------------------------------------- /tensorflow-lite/flatbuffers/struct.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 Google Inc. All rights reserved. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | #ifndef FLATBUFFERS_STRUCT_H_ 18 | #define FLATBUFFERS_STRUCT_H_ 19 | 20 | #include "tensorflow-lite/flatbuffers/base.h" 21 | 22 | namespace flatbuffers { 23 | 24 | // "structs" are flat structures that do not have an offset table, thus 25 | // always have all members present and do not support forwards/backwards 26 | // compatible extensions. 27 | 28 | class Struct FLATBUFFERS_FINAL_CLASS { 29 | public: 30 | template T GetField(uoffset_t o) const { 31 | return ReadScalar(&data_[o]); 32 | } 33 | 34 | template T GetStruct(uoffset_t o) const { 35 | return reinterpret_cast(&data_[o]); 36 | } 37 | 38 | const uint8_t *GetAddressOf(uoffset_t o) const { return &data_[o]; } 39 | uint8_t *GetAddressOf(uoffset_t o) { return &data_[o]; } 40 | 41 | private: 42 | // private constructor & copy constructor: you obtain instances of this 43 | // class by pointing to existing data only 44 | Struct(); 45 | Struct(const Struct &); 46 | Struct &operator=(const Struct &); 47 | 48 | uint8_t data_[1]; 49 | }; 50 | 51 | } // namespace flatbuffers 52 | 53 | #endif // FLATBUFFERS_STRUCT_H_ 54 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/shim/test_op/tmpl_tf_op.cc: -------------------------------------------------------------------------------- 1 | /* Copyright 2022 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 | #include "tensorflow-lite/tensorflow/lite/kernels/shim/test_op/tmpl_tf_op.h" 16 | 17 | #include 18 | 19 | #include "tensorflow-lite/tensorflow/core/framework/types.h" 20 | 21 | namespace tflite { 22 | namespace shim { 23 | 24 | using TmplOpKernelInstance = TmplOpKernel; 25 | 26 | REGISTER_TF_OP_SHIM(TmplOpKernelInstance); 27 | 28 | REGISTER_KERNEL_BUILDER(Name(TmplOpKernelInstance::OpName()) 29 | .Device(::tensorflow::DEVICE_CPU) 30 | .TypeConstraint("AType") 31 | .TypeConstraint("BType"), 32 | TmplOpKernel); 33 | 34 | REGISTER_KERNEL_BUILDER(Name(TmplOpKernelInstance::OpName()) 35 | .Device(::tensorflow::DEVICE_CPU) 36 | .TypeConstraint("AType") 37 | .TypeConstraint("BType"), 38 | TmplOpKernel); 39 | 40 | } // namespace shim 41 | } // namespace tflite 42 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/core/async/interop/c/types.cc: -------------------------------------------------------------------------------- 1 | /* Copyright 2022 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 | #include "tensorflow-lite/tensorflow/lite/core/async/interop/c/types.h" 16 | 17 | struct TfLiteBackendBuffer { 18 | void* ptr = nullptr; 19 | }; 20 | 21 | struct TfLiteSynchronization { 22 | void* ptr = nullptr; 23 | }; 24 | 25 | extern "C" { 26 | 27 | TfLiteBackendBuffer* TfLiteBackendBufferCreate() { 28 | return new TfLiteBackendBuffer; 29 | } 30 | void TfLiteBackendBufferDelete(TfLiteBackendBuffer* buf) { 31 | if (buf) delete buf; 32 | } 33 | void TfLiteBackendBufferSetPtr(TfLiteBackendBuffer* buf, void* ptr) { 34 | buf->ptr = ptr; 35 | } 36 | 37 | void* TfLiteBackendBufferGetPtr(const TfLiteBackendBuffer* buf) { 38 | return buf->ptr; 39 | } 40 | 41 | TfLiteSynchronization* TfLiteSynchronizationCreate() { 42 | return new TfLiteSynchronization; 43 | } 44 | void TfLiteSynchronizationDelete(TfLiteSynchronization* sync) { 45 | if (sync) delete sync; 46 | } 47 | void TfLiteSynchronizationSetPtr(TfLiteSynchronization* sync, void* ptr) { 48 | sync->ptr = ptr; 49 | } 50 | 51 | void* TfLiteSynchronizationGetPtr(const TfLiteSynchronization* sync) { 52 | return sync->ptr; 53 | } 54 | 55 | } // extern "C" 56 | -------------------------------------------------------------------------------- /tensorflow-lite/tensorflow/lite/kernels/internal/optimized/cpu_check.cc: -------------------------------------------------------------------------------- 1 | /* Copyright 2020 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 "tensorflow-lite/tensorflow/lite/kernels/internal/optimized/cpu_check.h" 17 | 18 | #if defined __linux__ && defined __aarch64__ 19 | #include 20 | #endif 21 | 22 | namespace tflite { 23 | 24 | namespace { 25 | 26 | // The implementation of dotprod detection is copied from ruy's internal 27 | // function DetectDotprod(). 28 | // At the moment it's only implemented on Linux ARM64. Consider syncing again 29 | // with ruy in the future to share improvements. 30 | #if defined __linux__ && defined __aarch64__ 31 | bool DetectDotprodByLinuxAuxvMethod() { 32 | // This is the value of HWCAP_ASIMDDP in sufficiently recent Linux headers, 33 | // however we need to support building against older headers for the time 34 | // being. 35 | const int kLocalHwcapAsimddp = 1 << 20; 36 | return getauxval(AT_HWCAP) & kLocalHwcapAsimddp; 37 | } 38 | #endif 39 | 40 | } // namespace 41 | 42 | bool DetectArmNeonDotprod() { 43 | #if defined __linux__ && defined __aarch64__ 44 | return DetectDotprodByLinuxAuxvMethod(); 45 | #endif 46 | 47 | return false; 48 | } 49 | 50 | } // namespace tflite 51 | --------------------------------------------------------------------------------