1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
# Description:
# Java Native Interface (JNI) library intended for implementing the
# TensorFlow Lite Java API using the TensorFlow Lite CC library.
package(default_visibility = ["//visibility:public"])
load("//tensorflow/contrib/lite:build_def.bzl", "tflite_copts")
licenses(["notice"]) # Apache 2.0
cc_library(
name = "native_framework_only",
srcs = [
"exception_jni.cc",
"nativeinterpreterwrapper_jni.cc",
"tensor_jni.cc",
"tensorflow_lite_jni.cc",
] + select({
# The Android toolchain makes "jni.h" available in the include path.
# For non-Android toolchains, generate jni.h and jni_md.h.
"//tensorflow:android": [],
"//conditions:default": [
":jni.h",
":jni_md.h",
],
}),
hdrs = [
"exception_jni.h",
"nativeinterpreterwrapper_jni.h",
"tensor_jni.h",
"tensorflow_lite_jni.h",
],
copts = tflite_copts(),
includes = select({
"//tensorflow:android": [],
"//conditions:default": ["."],
}),
linkopts = [
"-lm",
"-ldl",
],
deps = [
"//tensorflow/contrib/lite:context",
"//tensorflow/contrib/lite:framework",
"//tensorflow/contrib/lite:schema_fbs_version",
],
alwayslink = 1,
)
# Silly rules to make
# #include <jni.h>
# in the source headers work
# (in combination with the "includes" attribute of the tf_cuda_library rule
# above. Not needed when using the Android toolchain).
#
# Inspired from:
# https://github.com/bazelbuild/bazel/blob/f99a0543f8d97339d32075c7176b79f35be84606/src/main/native/BUILD
# but hopefully there is a simpler alternative to this.
genrule(
name = "copy_jni_h",
srcs = ["@bazel_tools//tools/jdk:jni_header"],
outs = ["jni.h"],
cmd = "cp -f $< $@",
)
genrule(
name = "copy_jni_md_h",
srcs = select({
"//tensorflow:darwin": ["@bazel_tools//tools/jdk:jni_md_header-darwin"],
"//conditions:default": ["@bazel_tools//tools/jdk:jni_md_header-linux"],
}),
outs = ["jni_md.h"],
cmd = "cp -f $< $@",
)
# This includes all ops. If you want a smaller binary, you should copy and
# modify builtin_ops_jni.cc. You should then link your binary against both
# ":native_framework_only" and your own version of ":native_builtin_ops".
cc_library(
name = "native",
srcs = [
"builtin_ops_jni.cc",
],
copts = tflite_copts(),
deps = [
":native_framework_only",
"//tensorflow/contrib/lite/kernels:builtin_ops",
],
alwayslink = 1,
)
exports_files(
[
"version_script.lds",
],
)
|