I am trying to add external header file (like OpenCL header file) for some experimentation for tensorflow. I tried to add this into BUILD file under tensorflow/core/BUILD file:
# This includes implementations of all kernels built into TensorFlow.
cc_library(
name = "all_kernels",
visibility = ["//visibility:public"],
copts = tf_copts() + ["-Ithird_party/include"], <==== this is the line I added
I have also created a softlink in this directory to the location of these header files from OpenCL driver (under tensorflow/third_party) too (like ln -s /opt/opencl/ ) but it still complains that it has not found that header file.
If I add external header file directly (like /opt/opencl/CL/) it complains that external files cannot be included (or some such thing).
I do not have root password to copy these header files into /usr/include/ too.
Can someone explain how exactly to do external header files into tensorflow for building?
Thanks for any quick help.
You can either add a -I option to the command line to tell the compiler to look there for header files. If you have header files in include/ directory, then this command should work for you. There shouldn't be any space between -I compiler option and directory location.
Then, I right-click on Solution Explorer, choose to add an existing item, and then browse to the location of my file myheader. hpp . Once this is added, I see it appears under Solution Items .
Yes, this will work. Note, however, that if you include a lot of headers in this file and don't need all of them in each of your source files, it will likely increase your compilation time.
Bazel builds software from source code organized in a directory called a workspace. Source files in the workspace are organized in a nested hierarchy of packages, where each package is a directory that contains a set of related source files and one BUILD file.
I've faced with the similar problem when I built TensorFlow with Intel MKL and had to add MKL headers. My solution is the following:
Create symlink to your headers into third_party folder, like:
<your tensorflow folder>/third_party/opencl/include -> /opt/OpenCL/include
with command:
ln -s /opt/OpenCL/include <your tensorflow folder>/third_party/opencl
Create simple BUILD file into <your tensorflow folder>/third_party/opencl
folder:
cc_library(
name = "opencl",
hdrs = glob(["include/CL/*.h"]),
visibility = ["//visibility:public"],
)
Add deps into target library:
cc_library(
name = "all_kernels",
visibility = ["//visibility:public"],
copts = tf_copts() + ["-Ithird_party/opencl/include"],
deps = [
"//third_party/opencl",
...
],
)
Don't forget to add compiler options either into target library as shown above or just as a flag to bazel:
bazel build --copt="-Ithird_party/opencl/include" ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With