Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cross compile tensorflow c++ library for android #1

Open
lingbao00 opened this issue Sep 18, 2017 · 0 comments
Open

cross compile tensorflow c++ library for android #1

lingbao00 opened this issue Sep 18, 2017 · 0 comments

Comments

@lingbao00
Copy link

lingbao00 commented Sep 18, 2017

i am doing cross compile tensorflow c++ library for android,and i had get the c library for android using ndk ,add like this:
cc_binary(
name = "libtensorflow.so",
srcs = [],
copts = tf_copts() + [
"-ffunction-sections",
"-fdata-sections",
],
linkopts = if_android([
"-landroid",
"-llog",
"-lm",
"-z defs",
"-s",
"-Wl,--gc-sections",
# soname is required for the so to load on api > 22
"-Wl,-soname=libtensorflow.so",
"-Wl,--version-script",
"//tensorflow/c:version_script.lds",
]),
linkshared = 1,
linkstatic = 1,
tags = [
"manual",
"notap",
],
deps = [
"//tensorflow/c:c_api",
"//tensorflow/c:version_script.lds",
"//tensorflow/core:android_tensorflow_lib",
],
)
it success.but i try c++ ,failed,and i add like this:
cc_binary(
name = "libtensorflow_cc.so",
srcs = [],
copts = tf_copts() + [
"-ffunction-sections",
"-fdata-sections",
],
linkopts = if_android([
"-landroid",
"-llog",
"-lm",
"-z defs",
"-s",
"-Wl,--gc-sections",
# soname is required for the so to load on api > 22
"-Wl,-soname=libtensorflow_cc.so",
]),
linkshared = 1,
linkstatic = 1,
tags = [
"manual",
"notap",
],
deps = [
"//tensorflow/c:c_api",
"//tensorflow/cc:cc_ops",
"//tensorflow/cc:client_session",
"//tensorflow/cc:scope",
"//tensorflow/core:android_tensorflow_lib",
],
)
it got the error:
ERROR: /home/z/e0028/workspace/tensorflow-build/target/tensorflow/tensorflow/core/BUILD:1395:1: no such target '//tensorflow/tools/git:gen/spec.json': target 'gen/spec.json' not declared in package 'tensorflow/tools/git' defined by /home/z/e0028/workspace/tensorflow-build/target/tensorflow/tensorflow/tools/git/BUILD and referenced by '//tensorflow/core:version_info_gen'
ERROR: /home/z/e0028/workspace/tensorflow-build/target/tensorflow/tensorflow/core/BUILD:1395:1: no such target '//tensorflow/tools/git:gen/head': target 'gen/head' not declared in package 'tensorflow/tools/git' defined by /home/z/e0028/workspace/tensorflow-build/target/tensorflow/tensorflow/tools/git/BUILD and referenced by '//tensorflow/core:version_info_gen'
ERROR: /home/z/e0028/workspace/tensorflow-build/target/tensorflow/tensorflow/core/BUILD:1395:1: no such target '//tensorflow/tools/git:gen/branch_ref': target 'gen/branch_ref' not declared in package 'tensorflow/tools/git' defined by /home/z/e0028/workspace/tensorflow-build/target/tensorflow/tensorflow/tools/git/BUILD and referenced by '//tensorflow/core:version_info_gen'
ERROR: Analysis of target '//tensorflow/contrib/android:libtensorflow_cc.so' failed; build aborted.

can you help me to fix it,thanks!

ulfjack pushed a commit that referenced this issue Jul 17, 2018
There is a fundamental bottleneck in the way targets are currently configured:
The ConfiguredTargetFunction needs to load all dependent targets before it can
configure its own target. Now, outgoing deps of a target can be in three
states:
1. Package of dependency target not yet loaded
2. Dependency target not configured, but package already loaded
3. Dependency target configured

State bazelbuild#3 is good, we don't need to do any more work before we can configure the
current target. Now, most targets will have a combination of deps in states #1
and bazelbuild#2. The current behavior is to schedule the target configuration of deps in
state bazelbuild#2 and the package loading in state #1 (to get to state bazelbuild#3 and bazelbuild#2,
respectively). Only after *all* of these are computed will the corresponding
ConfiguredTargetFunction be rescheduled upon which the remaining deps that were
in state #1 before are now in state bazelbuild#2 and the corresponding target
configuration can be started.

This creates a substantial parallelization bottleneck by artifically sync'ing
the state transitions (#1->bazelbuild#2 and bazelbuild#2->bazelbuild#3) for all deps. In turn, this makes the
critical path artifically long. Instead, settle for just loading dependent
packages as long as there are any. This is a fast single-step operation.
Postpone the configuration of dependent targets to later as it can require long
dependency chains to be configured.

In theory, a better solution would be to split the target configuration in a
way so that it is possible to ask for configured targets without yet knowing
their package. However, that would require pulling config transitions apart (as
some of them happen because of the origin target/config and some of them happen
because of the destination target. Thus we'd need to change the
ConfiguredTargetKey so that the configuration stands for the configuration that
we request the target in, with target-caused transitions already applied. Now
that itself leads to inefficiencies. E.g. we would start requestiong InputFiles
in several configurations just to underneath always load them with a null
configuration.

RELNOTES: Faster analysis by improved parallelization.
PiperOrigin-RevId: 203725209
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant