Skip to content

Commit

Permalink
Add Android support to TensorFlow presets (pull #297)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas-eberle authored and saudet committed Oct 15, 2016
1 parent 5d4c975 commit 3b27084
Show file tree
Hide file tree
Showing 3 changed files with 302 additions and 98 deletions.
30 changes: 19 additions & 11 deletions tensorflow/cppbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,26 @@ export CUDA_TOOLKIT_PATH=/usr/local/cuda
export CUDNN_INSTALL_PATH=$CUDA_TOOLKIT_PATH
export TF_CUDA_COMPUTE_CAPABILITIES=3.0

TENSORFLOW_VERSION=0.10.0

download https://github.com/tensorflow/tensorflow/archive/v$TENSORFLOW_VERSION.tar.gz tensorflow-$TENSORFLOW_VERSION.tar.gz

mkdir -p $PLATFORM
cd $PLATFORM

echo "Decompressing archives"
tar --totals -xzf ../tensorflow-$TENSORFLOW_VERSION.tar.gz

# Assumes Bazel is available in the path: http://bazel.io/docs/install.html
cd tensorflow-$TENSORFLOW_VERSION


case $PLATFORM in
android-arm)
patch -Np1 < ../../../tensorflow-$TENSORFLOW_VERSION-android.patch
sed -i "/ path=\"<PATH_TO_NDK>\",/c\ path=\"${ANDROID_NDK}\"," ./WORKSPACE
export BUILDFLAGS="--crosstool_top=//external:android/crosstool --cpu=armeabi-v7a --host_crosstool_top=@bazel_tools//tools/cpp:toolchain"
;;
linux-x86)
export CC="/usr/bin/gcc"
export CXX="/usr/bin/g++"
Expand All @@ -40,17 +59,6 @@ case $PLATFORM in
;;
esac

TENSORFLOW_VERSION=0.10.0
download https://github.com/tensorflow/tensorflow/archive/v$TENSORFLOW_VERSION.tar.gz tensorflow-$TENSORFLOW_VERSION.tar.gz

mkdir -p $PLATFORM
cd $PLATFORM

echo "Decompressing archives"
tar --totals -xzf ../tensorflow-$TENSORFLOW_VERSION.tar.gz

# Assumes Bazel is available in the path: http://bazel.io/docs/install.html
cd tensorflow-$TENSORFLOW_VERSION
./configure
bazel build -c opt //tensorflow:libtensorflow_cc.so $BUILDFLAGS --spawn_strategy=standalone --genrule_strategy=standalone --verbose_failures

Expand Down
234 changes: 147 additions & 87 deletions tensorflow/src/main/java/org/bytedeco/javacpp/presets/tensorflow.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,93 +46,153 @@
*
* @author Samuel Audet
*/
@Properties(value = @Platform(
value = {"linux-x86", "macosx"},
compiler = "cpp11",
define = {"NDEBUG", "UNIQUE_PTR_NAMESPACE std"},
include = {
"tensorflow/core/platform/default/integral_types.h",
"tensorflow/core/framework/numeric_types.h",
"tensorflow/core/platform/init_main.h",
"tensorflow/core/platform/types.h",
"tensorflow/core/platform/mutex.h",
"tensorflow/core/platform/macros.h",
"tensorflow/core/util/port.h",
"tensorflow/core/lib/core/error_codes.pb.h",
"tensorflow/core/platform/logging.h",
"tensorflow/core/lib/core/status.h",
"tensorflow/core/platform/protobuf.h",
"tensorflow/core/platform/file_system.h",
"tensorflow/core/platform/file_statistics.h",
"tensorflow/core/platform/env.h",
"tensorflow/core/graph/dot.h",
"tensorflow/core/protobuf/config.pb.h",
"tensorflow/core/framework/cost_graph.pb.h",
"tensorflow/core/framework/step_stats.pb.h",
"tensorflow/core/framework/versions.pb.h",
"tensorflow/core/public/session_options.h",
"tensorflow/core/lib/core/threadpool.h",
"tensorflow/core/framework/allocation_description.pb.h",
"tensorflow/core/framework/allocator.h",
"tensorflow/core/framework/tensor_shape.pb.h",
"tensorflow/core/framework/types.pb.h",
"tensorflow/core/framework/tensor.pb.h",
"tensorflow/core/framework/tensor_description.pb.h",
"tensorflow/core/framework/tensor_types.h",
"tensorflow/core/framework/tensor_shape.h",
// "tensorflow/core/framework/tensor_slice.h",
"tensorflow/core/framework/tensor_util.h",
"tensorflow/core/framework/tensor_reference.h",
"tensorflow/core/framework/tensor.h",
"tensorflow/core/framework/attr_value.pb.h",
"tensorflow/core/framework/op_def.pb.h",
"tensorflow/core/framework/function.pb.h",
"tensorflow/core/framework/graph.pb.h",
"tensorflow/core/framework/shape_inference.h",
"tensorflow/core/framework/partial_tensor_shape.h",
"tensorflow/core/public/session.h",
"tensorflow/c/c_api.h",
"tensorflow/core/framework/op_def.pb.h",
"tensorflow/core/framework/op_def_builder.h",
"tensorflow/core/framework/op_def_util.h",
"tensorflow/core/framework/op.h",
"tensorflow/core/framework/types.h",
"tensorflow/core/graph/edgeset.h",
"tensorflow/core/lib/gtl/iterator_range.h",
// "tensorflow/core/lib/gtl/inlined_vector.h",
"tensorflow/core/graph/graph.h",
"tensorflow/core/framework/node_def_builder.h",
"tensorflow/core/framework/node_def_util.h",
"tensorflow/core/framework/selective_registration.h",
"tensorflow/core/graph/node_builder.h",
"tensorflow/core/graph/graph_def_builder.h",
"tensorflow/core/graph/default_device.h",
"tensorflow/core/graph/graph_constructor.h",
"tensorflow/cc/framework/scope.h",
"tensorflow/cc/framework/ops.h",
"tensorflow/cc/framework/cc_op_gen.h",
"tensorflow_adapters.h",
"tensorflow/cc/ops/standard_ops.h",
"tensorflow/cc/ops/const_op.h",
"tensorflow/cc/ops/array_ops.h",
"tensorflow/cc/ops/candidate_sampling_ops.h",
"tensorflow/cc/ops/control_flow_ops.h",
"tensorflow/cc/ops/data_flow_ops.h",
"tensorflow/cc/ops/image_ops.h",
"tensorflow/cc/ops/io_ops.h",
"tensorflow/cc/ops/linalg_ops.h",
"tensorflow/cc/ops/logging_ops.h",
"tensorflow/cc/ops/math_ops.h",
"tensorflow/cc/ops/nn_ops.h",
"tensorflow/cc/ops/no_op.h",
"tensorflow/cc/ops/parsing_ops.h",
"tensorflow/cc/ops/random_ops.h",
"tensorflow/cc/ops/sparse_ops.h",
"tensorflow/cc/ops/state_ops.h",
"tensorflow/cc/ops/string_ops.h",
"tensorflow/cc/ops/training_ops.h",
"tensorflow/cc/ops/user_ops.h"},
link = "tensorflow_cc"),
@Properties(value = {
@Platform(
value = {"linux-x86", "macosx"},
compiler = "cpp11",
define = {"NDEBUG", "UNIQUE_PTR_NAMESPACE std"},
include = {
"tensorflow/core/platform/default/integral_types.h",
"tensorflow/core/framework/numeric_types.h",
"tensorflow/core/platform/init_main.h",
"tensorflow/core/platform/types.h",
"tensorflow/core/platform/mutex.h",
"tensorflow/core/platform/macros.h",
"tensorflow/core/util/port.h",
"tensorflow/core/lib/core/error_codes.pb.h",
"tensorflow/core/platform/logging.h",
"tensorflow/core/lib/core/status.h",
"tensorflow/core/platform/protobuf.h",
"tensorflow/core/platform/file_system.h",
"tensorflow/core/platform/file_statistics.h",
"tensorflow/core/platform/env.h",
"tensorflow/core/graph/dot.h",
"tensorflow/core/protobuf/config.pb.h",
"tensorflow/core/framework/cost_graph.pb.h",
"tensorflow/core/framework/step_stats.pb.h",
"tensorflow/core/framework/versions.pb.h",
"tensorflow/core/public/session_options.h",
"tensorflow/core/lib/core/threadpool.h",
"tensorflow/core/framework/allocation_description.pb.h",
"tensorflow/core/framework/allocator.h",
"tensorflow/core/framework/tensor_shape.pb.h",
"tensorflow/core/framework/types.pb.h",
"tensorflow/core/framework/tensor.pb.h",
"tensorflow/core/framework/tensor_description.pb.h",
"tensorflow/core/framework/tensor_types.h",
"tensorflow/core/framework/tensor_shape.h",
// "tensorflow/core/framework/tensor_slice.h",
"tensorflow/core/framework/tensor_util.h",
"tensorflow/core/framework/tensor_reference.h",
"tensorflow/core/framework/tensor.h",
"tensorflow/core/framework/attr_value.pb.h",
"tensorflow/core/framework/op_def.pb.h",
"tensorflow/core/framework/function.pb.h",
"tensorflow/core/framework/graph.pb.h",
"tensorflow/core/framework/shape_inference.h",
"tensorflow/core/framework/partial_tensor_shape.h",
"tensorflow/core/public/session.h",
"tensorflow/c/c_api.h",
"tensorflow/core/framework/op_def.pb.h",
"tensorflow/core/framework/op_def_builder.h",
"tensorflow/core/framework/op_def_util.h",
"tensorflow/core/framework/op.h",
"tensorflow/core/framework/types.h",
"tensorflow/core/graph/edgeset.h",
"tensorflow/core/lib/gtl/iterator_range.h",
// "tensorflow/core/lib/gtl/inlined_vector.h",
"tensorflow/core/graph/graph.h",
"tensorflow/core/framework/node_def_builder.h",
"tensorflow/core/framework/node_def_util.h",
"tensorflow/core/framework/selective_registration.h",
"tensorflow/core/graph/node_builder.h",
"tensorflow/core/graph/graph_def_builder.h",
"tensorflow/core/graph/default_device.h",
"tensorflow/core/graph/graph_constructor.h",
"tensorflow/cc/framework/scope.h",
"tensorflow/cc/framework/ops.h",
"tensorflow/cc/framework/cc_op_gen.h",
"tensorflow_adapters.h",
"tensorflow/cc/ops/standard_ops.h",
"tensorflow/cc/ops/const_op.h",
"tensorflow/cc/ops/array_ops.h",
"tensorflow/cc/ops/candidate_sampling_ops.h",
"tensorflow/cc/ops/control_flow_ops.h",
"tensorflow/cc/ops/data_flow_ops.h",
"tensorflow/cc/ops/image_ops.h",
"tensorflow/cc/ops/io_ops.h",
"tensorflow/cc/ops/linalg_ops.h",
"tensorflow/cc/ops/logging_ops.h",
"tensorflow/cc/ops/math_ops.h",
"tensorflow/cc/ops/nn_ops.h",
"tensorflow/cc/ops/no_op.h",
"tensorflow/cc/ops/parsing_ops.h",
"tensorflow/cc/ops/random_ops.h",
"tensorflow/cc/ops/sparse_ops.h",
"tensorflow/cc/ops/state_ops.h",
"tensorflow/cc/ops/string_ops.h",
"tensorflow/cc/ops/training_ops.h",
"tensorflow/cc/ops/user_ops.h"},
link = "tensorflow_cc"),
@Platform(value = {"android"},
compiler = {"cpp11"},
define = {"NDEBUG", "UNIQUE_PTR_NAMESPACE std"},
include = {
"tensorflow/core/platform/default/integral_types.h",
"tensorflow/core/framework/numeric_types.h",
"tensorflow/core/platform/init_main.h",
"tensorflow/core/platform/types.h",
"tensorflow/core/platform/mutex.h",
"tensorflow/core/platform/macros.h",
"tensorflow/core/util/port.h",
"tensorflow/core/lib/core/error_codes.pb.h",
"tensorflow/core/platform/logging.h",
"tensorflow/core/lib/core/status.h",
"tensorflow/core/platform/protobuf.h",
"tensorflow/core/platform/file_system.h",
"tensorflow/core/platform/file_statistics.h",
"tensorflow/core/platform/env.h",
"tensorflow/core/protobuf/config.pb.h",
"tensorflow/core/framework/cost_graph.pb.h",
"tensorflow/core/framework/step_stats.pb.h",
"tensorflow/core/framework/versions.pb.h",
"tensorflow/core/public/session_options.h",
"tensorflow/core/lib/core/threadpool.h",
"tensorflow/core/framework/allocation_description.pb.h",
"tensorflow/core/framework/allocator.h",
"tensorflow/core/framework/tensor_shape.pb.h",
"tensorflow/core/framework/types.pb.h",
"tensorflow/core/framework/tensor.pb.h",
"tensorflow/core/framework/tensor_description.pb.h",
"tensorflow/core/framework/tensor_types.h",
"tensorflow/core/framework/tensor_shape.h",
"tensorflow/core/framework/tensor_util.h",
"tensorflow/core/framework/tensor_reference.h",
"tensorflow/core/framework/tensor.h",
"tensorflow/core/framework/attr_value.pb.h",
"tensorflow/core/framework/function.pb.h",
"tensorflow/core/framework/graph.pb.h",
"tensorflow/core/framework/shape_inference.h",
"tensorflow/core/framework/partial_tensor_shape.h",
"tensorflow/core/public/session.h",
"tensorflow/c/c_api.h",
"tensorflow/core/framework/op_def.pb.h",
"tensorflow/core/framework/op_def_builder.h",
"tensorflow/core/framework/op_def_util.h",
"tensorflow/core/framework/op.h",
"tensorflow/core/framework/types.h",
"tensorflow/core/graph/edgeset.h",
"tensorflow/core/lib/gtl/iterator_range.h",
"tensorflow/core/graph/graph.h",
"tensorflow/core/framework/node_def_builder.h",
"tensorflow/core/framework/node_def_util.h",
"tensorflow/core/graph/node_builder.h",
"tensorflow/core/graph/graph_def_builder.h",
"tensorflow/core/graph/default_device.h",
"tensorflow/core/graph/graph_constructor.h",
"tensorflow_adapters.h"},
link = "tensorflow_cc"),
},
target = "org.bytedeco.javacpp.tensorflow",
helper = "org.bytedeco.javacpp.helper.tensorflow")
public class tensorflow implements InfoMapper {
Expand Down
Loading

0 comments on commit 3b27084

Please sign in to comment.