我的BUILD文件包含
deps = ["//tensorflow/core:android_tensorflow_lib","//tensorflow/contrib/quantization:cc_array_ops","//tensorflow/contrib/quantization:cc_math_ops","//tensorflow/contrib/quantization:cc_nn_ops","//tensorflow/contrib/quantization/kernels:quantized_ops"]
额外的量化代表适用于独立的C版本.
由于GemmLOWP中存在大量错误,我无法使用Bazel进行编译.在Android中包含gemmlowp和量化操作的正确方法是什么?
external/gemmlowp/eight_bit_int_gemm/eight_bit_int_gemm.cc:125:13: error: 'int32_t' is not a member of 'std' MatrixMap<std::int32_t,ResultOrder> result(c,m,n,ldc);
这是在Ubuntu 16.04上使用Bazel 0.3.0.
这里有一个要点,它有两次连续尝试构建包的输出 – 它第一次在highwayhash上失败而第二次是gemmlowp.
https://gist.github.com/ericdanz/81b799f2e0bbb3cc462aa3c90468c71b
最终得到它编译和运行在BUILD文件中为gemmlowp和highwayhash自由添加“-std = c 11”,并在量化ops中替换android框架中的框架依赖.它产生了相当不同的结果,并且运行速度慢了约4倍(26-3200ms对6-800 ms).我会尝试做一些更深入的调查.
解决方法
在deps中将quantized_ops添加到Android应用程序的BUILD文件中的libtensorflow_demo.so:
deps = ["//tensorflow/core:android_tensorflow_lib","//tensorflow/contrib/quantization/kernels:quantized_ops",]
修改tensorflow / contrib / quantization / kernels / BUILD中的quantized_ops的deps:
deps = [ "//tensorflow/contrib/quantization:cc_array_ops","//tensorflow/core:android_tensorflow_lib",#"//tensorflow/core",#"//tensorflow/core:framework",#"//tensorflow/core:lib",#"//tensorflow/core/kernels:concat_lib_hdrs",#"//tensorflow/core/kernels:conv_ops",#"//tensorflow/core/kernels:ops_util_hdrs",#"//tensorflow/core/kernels:pooling_ops_hdrs",#"//tensorflow/core/kernels:eigen_helpers",#"//tensorflow/core/kernels:ops_util",#"//tensorflow/core/kernels:pooling_ops","//third_party/eigen3","@gemmlowp//:eight_bit_int_gemm",],
删除/注释掉tensorflow / contrib / quantization / ops / array_ops.cc,math_ops.cc和nn_ops.cc中的.Doc()部分.
在tensorflow / contrib / quantization / BUILD中修改cc_array_ops,cc_math_ops和cc_nn_ops的deps:
deps = [ #"//tensorflow/core:framework",
使用–cxxopt =“ – std = c 11”标志为Android应用程序运行bazel build命令.