本文主要是介绍TFLite: 代码组成结构,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
编译命令
bazel build --cxxopt=--std=c++11 //tensorflow/contrib/lite/java/demo/app/src/main:TfLiteCameraDemo
编译目标从WORKSPACE所在的路径开始到package路径(BUILD文件所在路径) : target(name)
编译输出结果
Target //tensorflow/contrib/lite/java/demo/app/src/main:TfLiteCameraDemo up-to-date:
bazel-bin/tensorflow/contrib/lite/java/demo/app/src/main/TfLiteCameraDemo_deploy.jar
bazel-bin/tensorflow/contrib/lite/java/demo/app/src/main/TfLiteCameraDemo_unsigned.apk
bazel-bin/tensorflow/contrib/lite/java/demo/app/src/main/TfLiteCameraDemo.apk
INFO: Elapsed time: 108.586s, Critical Path: 31.76s
INFO: 305 processes: 279 local, 26 worker.
INFO: Build completed successfully, 351 total actions
编译输出结果
bazel-bin -> /home/mi/.cache/bazel/_bazel_mi/xxx/execroot/org_tensorflow/bazel-out/k8-opt/bin
bazel-out -> /home/mi/.cache/bazel/_bazel_mi/xxx/execroot/org_tensorflow/bazel-out
bazel-genfiles -> /home/mi/.cache/bazel/_bazel_mi/xxx/execroot/org_tensorflow/bazel-out/k8-opt/genfiles
bazel-tensorflow -> /home/mi/.cache/bazel/_bazel_mi/xxx/execroot/org_tensorflow
bazel-testlogs -> /home/mi/.cache/bazel/_bazel_mi/xxx/execroot/org_tensorflow/bazel-out/k8-opt/testlogs
分析编译生成的文件,看代码结构
execroot/org_tensorflow/bazel-out/android-armeabi-v7a-opt/bin/tensorflow/contrib/lite
find ./ -name "*.o"
1. framework
./_objs/framework/stderr_reporter.o
./_objs/framework/interpreter.o
./_objs/framework/mutable_op_resolver.o
./_objs/framework/nnapi_delegate.o
./_objs/framework/optional_debug_tools.o
./_objs/framework/model.o
./_objs/framework/graph_info.o
./_objs/framework/mmap_allocation.o
./_objs/framework/allocation.o
2. buildin_op_kernels
./kernels/_objs/builtin_op_kernels/strided_slice.o
./kernels/_objs/builtin_op_kernels/lsh_projection.o
./kernels/_objs/builtin_op_kernels/arg_min_max.o
./kernels/_objs/builtin_op_kernels/gather.o
./kernels/_objs/builtin_op_kernels/unidirectional_sequence_rnn.o
./kernels/_objs/builtin_op_kernels/elementwise.o
./kernels/_objs/builtin_op_kernels/sub.o
./kernels/_objs/builtin_op_kernels/bidirectional_sequence_rnn.o
./kernels/_objs/builtin_op_kernels/resize_bilinear.o
./kernels/_objs/builtin_op_kernels/comparisons.o
./kernels/_objs/builtin_op_kernels/transpose_conv.o
./kernels/_objs/builtin_op_kernels/unidirectional_sequence_lstm.o
./kernels/_objs/builtin_op_kernels/cast.o
./kernels/_objs/builtin_op_kernels/layer_norm_lstm.o
./kernels/_objs/builtin_op_kernels/expand_dims.o
./kernels/_objs/builtin_op_kernels/audio_spectrogram.o
./kernels/_objs/builtin_op_kernels/space_to_depth.o
./kernels/_objs/builtin_op_kernels/space_to_batch_nd.o
./kernels/_objs/builtin_op_kernels/pad.o
./kernels/_objs/builtin_op_kernels/depthwise_conv.o
./kernels/_objs/builtin_op_kernels/div.o
./kernels/_objs/builtin_op_kernels/bidirectional_sequence_lstm.o
./kernels/_objs/builtin_op_kernels/concatenation.o
./kernels/_objs/builtin_op_kernels/exp.o
./kernels/_objs/builtin_op_kernels/add.o
./kernels/_objs/builtin_op_kernels/floor_div.o
./kernels/_objs/builtin_op_kernels/skip_gram.o
./kernels/_objs/builtin_op_kernels/dequantize.o
./kernels/_objs/builtin_op_kernels/l2norm.o
./kernels/_objs/builtin_op_kernels/local_response_norm.o
./kernels/_objs/builtin_op_kernels/select.o
./kernels/_objs/builtin_op_kernels/squeeze.o
./kernels/_objs/builtin_op_kernels/hashtable_lookup.o
./kernels/_objs/builtin_op_kernels/unpack.o
./kernels/_objs/builtin_op_kernels/shape.o
./kernels/_objs/builtin_op_kernels/slice.o
./kernels/_objs/builtin_op_kernels/logical.o
./kernels/_objs/builtin_op_kernels/one_hot.o
./kernels/_objs/builtin_op_kernels/conv.o
./kernels/_objs/builtin_op_kernels/fake_quant.o
./kernels/_objs/builtin_op_kernels/floor.o
./kernels/_objs/builtin_op_kernels/basic_rnn.o
./kernels/_objs/builtin_op_kernels/mfcc.o
./kernels/_objs/builtin_op_kernels/sparse_to_dense.o
./kernels/_objs/builtin_op_kernels/svdf.o
./kernels/_objs/builtin_op_kernels/detection_postprocess.o
./kernels/_objs/builtin_op_kernels/topk_v2.o
./kernels/_objs/builtin_op_kernels/maximum_minimum.o
./kernels/_objs/builtin_op_kernels/lstm.o
./kernels/_objs/builtin_op_kernels/nactivations.o
./kernels/_objs/builtin_op_kernels/transpose.o
./kernels/_objs/builtin_op_kernels/pow.o
./kernels/_objs/builtin_op_kernels/embedding_lookup.o
./kernels/_objs/builtin_op_kernels/embedding_lookup_sparse.o
./kernels/_objs/builtin_op_kernels/pack.o
./kernels/_objs/builtin_op_kernels/zeros_like.o
./kernels/_objs/builtin_op_kernels/reshape.o
./kernels/_objs/builtin_op_kernels/sparse_output_fully_connected.o
./kernels/_objs/builtin_op_kernels/relu1.o
./kernels/_objs/builtin_op_kernels/tile.o
./kernels/_objs/builtin_op_kernels/fully_connected.o
./kernels/_objs/builtin_op_kernels/batch_to_space_nd.o
./kernels/_objs/builtin_op_kernels/split.o
./kernels/_objs/builtin_op_kernels/reduce.o
./kernels/_objs/builtin_op_kernels/mul.o
./kernels/_objs/builtin_op_kernels/neg.o
./kernels/_objs/builtin_op_kernels/pooling.o
3. kernel/internal
./kernels/internal/_objs/kernel_utils/kernel_utils.o
./kernels/internal/_objs/quantization_util/quantization_util.o
./kernels/internal/_objs/audio_utils/mfcc_dct.o
./kernels/internal/_objs/audio_utils/mfcc_mel_filterbank.o
./kernels/internal/_objs/audio_utils/mfcc.o
./kernels/internal/_objs/audio_utils/spectrogram.o
./kernels/internal/_objs/tensor_utils/tensor_utils.o
./kernels/internal/_objs/neon_tensor_utils/portable_tensor_utils.o
./kernels/internal/_objs/neon_tensor_utils/neon_tensor_utils.o
4. kernel 其他
kernel/gemm_support.cc
kernel/kernel_util.cc
kernel/lstm_eval.cc
kernel/eigen_support.cc
这几个怎么不是buildin_op_kernels??
5. lite下其他文件
./_objs/arena_planner/arena_planner.o
util.cc 直接在lite目录下
string_util.cc 直接在lite目录下
6. profiling/time, simple_memory_arena
./profiling/time.cc
./_objs/simple_memory_arena/simple_memory_arena.o
7 core/api
./core/api/_objs/api/error_reporter.o
./core/api/_objs/api/op_resolver.o
./core/api/_objs/api/flatbuffer_conversions.o
8. c/c_api_internal
./c/_objs/c_api_internal/c_api_internal.o
9. java_jni
./java/src/main/native/_objs/native/builtin_ops_jni.o
./java/src/main/native/_objs/native_framework_only/nativeinterpreterwrapper_jni.o
./java/src/main/native/_objs/native_framework_only/tensorflow_lite_jni.o
./java/src/main/native/_objs/native_framework_only/tensor_jni.o
./java/src/main/native/_objs/native_framework_only/exception_jni.o
10. external
androidndk androidsdk com_google_absl farmhash_archive fft2d flatbuffers org_checkerframework_qual
10.1 androidndk
./androidndk/_objs/cpufeatures/cpu-features.o
10.2 farmhash
./farmhash_archive/_objs/farmhash/farmhash.o
10.3 absl
./com_google_absl/absl/base/_objs/dynamic_annotations/dynamic_annotations.o
10.4 flatbuffer
./flatbuffers/_objs/flatbuffers/reflection.o
./flatbuffers/_objs/flatbuffers/code_generators.o
./flatbuffers/_objs/flatbuffers/idl_parser.o
./flatbuffers/_objs/flatbuffers/util.o
./flatbuffers/_objs/flatbuffers/idl_gen_general.o
./flatbuffers/_objs/flatbuffers/idl_gen_text.o
./flatbuffers/_objs/flatbuffers/idl_gen_fbs.o
10.5 fft2d
./fft2d/_objs/fft2d/fftsg.o
11. zipinfo -l jar/ apk
➜ java zipinfo -l libtensorflowlite.jar
Archive: libtensorflowlite.jar
Zip file size: 14443 bytes, number of entries: 12
-rw---- 2.0 fat 752 bl 477 defN 10-Jan-01 00:00 org/tensorflow/lite/DataType$1.class
-rw---- 2.0 fat 2676 bl 1382 defN 10-Jan-01 00:00 org/tensorflow/lite/DataType.class
-rw---- 2.0 fat 983 bl 488 defN 10-Jan-01 00:00 org/tensorflow/lite/Interpreter$Options.class
-rw---- 2.0 fat 5200 bl 2073 defN 10-Jan-01 00:00 org/tensorflow/lite/Interpreter.class
-rw---- 2.0 fat 9352 bl 4250 defN 10-Jan-01 00:00 org/tensorflow/lite/NativeInterpreterWrapper.class
-rw---- 2.0 fat 6431 bl 3174 defN 10-Jan-01 00:00 org/tensorflow/lite/Tensor.class
-rw---- 2.0 fat 1308 bl 751 defN 10-Jan-01 00:00 org/tensorflow/lite/TensorFlowLite.class
zipinfo -l bazel-bin/tensorflow/contrib/lite/java/demo/app/src/main/TfLiteCameraDemo.apk
Archive: bazel-bin/tensorflow/contrib/lite/java/demo/app/src/main/TfLiteCameraDemo.apk
Zip file size: 5537448 bytes, number of entries: 28
-rw---- 2.0 fat 1228588 b- 579539 defN 80-Jan-01 00:00 lib/armeabi-v7a/libtensorflowlite_jni.so
-rw---- 2.0 fat 1506380 bl 593277 defN 80-Jan-01 00:00 classes.dex
-rw-rw-rw- 2.3 unx 2336 b- 808 defX 80-Jan-01 00:00 AndroidManifest.xml
-rw-rw-rw- 2.3 unx 196 b- 143 defX 80-Jan-01 00:00 assets/BUILD
-rw-rw-rw- 2.3 unx 195 b- 142 defX 80-Jan-01 00:00 assets/BUILD.bazel
-rw-rw-rw- 2.3 unx 116 b- 116 stor 80-Jan-01 00:00 assets/WORKSPACE
-rw-rw-rw- 2.3 unx 10484 b- 5216 defX 80-Jan-01 00:00 assets/labels.txt
-rw-rw-rw- 2.3 unx 10479 b- 5216 defX 80-Jan-01 00:00 assets/labels_imagenet_slim.txt
-rw-rw-rw- 2.3 unx 10484 b- 5216 defX 80-Jan-01 00:00 assets/labels_mobilenet_quant_v1_224.txt
-rw-rw-rw- 2.3 unx 4276100 b- 4276100 stor 80-Jan-01 00:00 assets/mobilenet_quant_v1_224.tflite
-rw-rw-rw- 2.3 unx 583 b- 583 stor 80-Jan-01 00:00 res/drawable-hdpi-v4/ic_action_info.png
-rw-rw-rw- 2.3 unx 3845 b- 3845 stor 80-Jan-01 00:00 res/drawable-hdpi-v4/ic_launcher.png
-rw-rw-rw- 2.3 unx 234 b- 234 stor 80-Jan-01 00:00 res/drawable-hdpi-v4/tile.9.png
-rw-rw-rw- 2.3 unx 395 b- 395 stor 80-Jan-01 00:00 res/drawable-mdpi-v4/ic_action_info.png
-rw-rw-rw- 2.3 unx 2067 b- 2067 stor 80-Jan-01 00:00 res/drawable-mdpi-v4/ic_launcher.png
-rw-rw-rw- 2.3 unx 728 b- 728 stor 80-Jan-01 00:00 res/drawable-xhdpi-v4/ic_action_info.png
-rw-rw-rw- 2.3 unx 5855 b- 5855 stor 80-Jan-01 00:00 res/drawable-xhdpi-v4/ic_launcher.png
-rw-rw-rw- 2.3 unx 1129 b- 1129 stor 80-Jan-01 00:00 res/drawable-xxhdpi-v4/ic_action_info.png
-rw-rw-rw- 2.3 unx 10714 b- 10714 stor 80-Jan-01 00:00 res/drawable-xxhdpi-v4/ic_launcher.png
-rw-rw-rw- 2.3 unx 29110 b- 29110 stor 80-Jan-01 00:00 res/drawable-xxhdpi-v4/logo.png
-rw-rw-rw- 2.3 unx 1736 b- 690 defX 80-Jan-01 00:00 res/layout-land/fragment_camera2_basic.xml
-rw-rw-rw- 2.3 unx 2792 b- 1035 defX 80-Jan-01 00:00 res/layout-v26/fragment_camera2_basic.xml
-rw-rw-rw- 2.3 unx 404 b- 228 defX 80-Jan-01 00:00 res/layout/activity_camera.xml
-rw-rw-rw- 2.3 unx 2776 b- 1025 defX 80-Jan-01 00:00 res/layout/fragment_camera2_basic.xml
-rw-rw-rw- 2.3 unx 5152 b- 5152 stor 80-Jan-01 00:00 resources.arsc
-rw---- 2.0 fat 2721 b- 1304 defN 80-Jan-01 00:00 META-INF/CERT.SF
-rw---- 2.0 fat 1211 b- 1060 defN 80-Jan-01 00:00 META-INF/CERT.RSA
-rw---- 2.0 fat 2620 b- 1207 defN 80-Jan-01 00:00 META-INF/MANIFEST.MF
12. 其他
从TfLiteCameraDemo的BUILD文件可以推导出TFLite包括那些文件
这篇关于TFLite: 代码组成结构的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!