Skip to content

Commit cc3e816

Browse files
committed
First draft for Bazelcism
1 parent d39cbb9 commit cc3e816

File tree

75 files changed

+744
-388
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+744
-388
lines changed

tensorflow-core/pom.xml

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,10 @@
3838
<properties>
3939
<!--
4040
Match version used by TensorFlow, in
41-
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/workspace2.bzl#L567
41+
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/workspace2.bzl
4242
(but for the currently used release, not master)
43-
44-
Bumped to newer version to patch a CVE only present in protobuf-java
4543
-->
46-
<protobuf.version>3.19.4</protobuf.version>
44+
<protobuf.version>3.21.9</protobuf.version>
4745

4846
<native.classifier>${javacpp.platform}${javacpp.platform.extension}</native.classifier>
4947
<javacpp.build.skip>false</javacpp.build.skip> <!-- To skip execution of build.sh: -Djavacpp.build.skip=true -->
@@ -69,7 +67,10 @@
6967
<javacpp.platform.macosx-x86_64.extension>macosx-x86_64${javacpp.platform.extension}</javacpp.platform.macosx-x86_64.extension>
7068
<javacpp.platform.windows-x86.extension>windows-x86${javacpp.platform.extension}</javacpp.platform.windows-x86.extension>
7169
<javacpp.platform.windows-x86_64.extension>windows-x86_64${javacpp.platform.extension}</javacpp.platform.windows-x86_64.extension>
72-
<javacpp.version>1.5.8</javacpp.version>
70+
<javacpp.version>1.5.9</javacpp.version>
71+
72+
<native.wheel.url/>
73+
<native.wheel.url.macosx-arm64>https://files.pythonhosted.org/packages/d2/e6/94748fedae940a7095ac3acb821e613f72513cf9fa8ea0cf6fe734ef8c8f/tensorflow_macos-2.12.0-cp311-cp311-macosx_12_0_arm64.whl</native.wheel.url.macosx-arm64>
7374
</properties>
7475

7576
<profiles>
@@ -882,6 +883,18 @@
882883
<os.name>macosx</os.name>
883884
</properties>
884885
</profile>
886+
<profile>
887+
<id>macosx-arm64</id>
888+
<activation>
889+
<os>
890+
<name>mac os x</name>
891+
<arch>aarch64</arch>
892+
</os>
893+
</activation>
894+
<properties>
895+
<native.wheel.url>${native.wheel.url.macosx-arm64}</native.wheel.url>
896+
</properties>
897+
</profile>
885898
<profile>
886899
<id>windowsos</id>
887900
<activation>

tensorflow-core/tensorflow-core-api/build.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
# Script to build native TensorFlow libraries
33
set -eu
44

5+
6+
7+
58
# Allows us to use ccache with Bazel on Mac
69
export BAZEL_USE_CPP_ONLY_TOOLCHAIN=1
710

tensorflow-core/tensorflow-core-api/pom.xml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
<properties>
1818
<native.build.skip>false</native.build.skip>
19+
<native.build.folder>${project.build.directory}/native/org/tensorflow/internal/c_api/${native.classifier}/</native.build.folder>
1920
<javacpp.build.skip>${native.build.skip}</javacpp.build.skip>
2021
<javacpp.parser.skip>${native.build.skip}</javacpp.parser.skip>
2122
<javacpp.compiler.skip>${native.build.skip}</javacpp.compiler.skip>
@@ -173,6 +174,7 @@
173174
</execution>
174175
</executions>
175176
</plugin>
177+
176178
<plugin>
177179
<artifactId>maven-compiler-plugin</artifactId>
178180
<version>3.8.0</version>
@@ -246,16 +248,16 @@
246248
<classPath>${project.build.outputDirectory}</classPath>
247249
<includePaths>
248250
<includePath>${project.basedir}/</includePath>
249-
<includePath>${project.basedir}/bazel-${project.artifactId}/external/org_tensorflow/</includePath>
250-
<includePath>${project.basedir}/bazel-bin/external/org_tensorflow/</includePath>
251-
<includePath>${project.basedir}/bazel-${project.artifactId}/external/com_google_absl/</includePath>
252-
<includePath>${project.basedir}/bazel-${project.artifactId}/external/eigen_archive/</includePath>
253-
<includePath>${project.basedir}/bazel-${project.artifactId}/external/com_google_protobuf/src/</includePath>
251+
<!-- <includePath>${project.basedir}/bazel-${project.artifactId}/external/org_tensorflow/</includePath>-->
252+
<!-- <includePath>${project.basedir}/bazel-bin/external/org_tensorflow/</includePath>-->
253+
<!-- <includePath>${project.basedir}/bazel-${project.artifactId}/external/com_google_absl/</includePath>-->
254+
<!-- <includePath>${project.basedir}/bazel-${project.artifactId}/external/eigen_archive/</includePath>-->
255+
<!-- <includePath>${project.basedir}/bazel-${project.artifactId}/external/com_google_protobuf/src/</includePath>-->
256+
<includePath>${project.basedir}/downloads/tensorflow/include/</includePath>
254257
<includePath>${project.basedir}/target/classes/org/tensorflow/internal/c_api/include/</includePath>
255258
</includePaths>
256259
<linkPaths>
257-
<linkPath>${project.basedir}/bazel-bin/external/llvm_openmp/</linkPath>
258-
<linkPath>${project.basedir}/bazel-bin/external/org_tensorflow/tensorflow/</linkPath>
260+
<linkPath>${native.build.folder}</linkPath>
259261
</linkPaths>
260262
<resourcePaths>
261263
<resourcePath>${project.basedir}/../../</resourcePath>
@@ -296,7 +298,10 @@
296298
<skip>${javacpp.build.skip}</skip>
297299
<buildCommand>
298300
<program>bash</program>
299-
<argument>${project.basedir}/build.sh</argument>
301+
<argument>prepare_build.sh</argument>
302+
<!--argument>${project.basedir}/build.sh</argument-->
303+
<argument>${native.wheel.url}</argument>
304+
<argument>${native.build.folder}</argument>
300305
</buildCommand>
301306
<environmentVariables>
302307
<PLATFORM>${javacpp.platform}</PLATFORM>
@@ -355,7 +360,7 @@
355360
<goal>build</goal>
356361
</goals>
357362
<configuration>
358-
<outputDirectory>${project.build.directory}/native/org/tensorflow/internal/c_api/${native.classifier}/</outputDirectory>
363+
<outputDirectory>${native.build.folder}/</outputDirectory>
359364
<skip>${javacpp.compiler.skip}</skip>
360365
<classOrPackageName>org.tensorflow.internal.c_api.**</classOrPackageName>
361366
<copyLibs>true</copyLibs>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
set -eu
3+
4+
PYTHON_WHEEL_URL="$1"
5+
TARGET_FOLDER="$2"
6+
DOWNLOAD_FOLDER="downloads"
7+
DOWNLOADED_FILE="tensorflow.zip" # TODO extract name from wheel url, change .whl to .zip
8+
9+
mkdir -p $TARGET_FOLDER
10+
mkdir -p $DOWNLOAD_FOLDER
11+
12+
if [ ! -f $DOWNLOAD_FOLDER/$DOWNLOADED_FILE ]; then
13+
curl -L $PYTHON_WHEEL_URL --output-dir $DOWNLOAD_FOLDER --output $DOWNLOADED_FILE
14+
fi
15+
16+
unzip -u -d $DOWNLOAD_FOLDER $DOWNLOAD_FOLDER/$DOWNLOADED_FILE
17+
18+
# TODO Per OS logic
19+
mv -f $DOWNLOAD_FOLDER/tensorflow/libtensorflow_cc.2.dylib $DOWNLOAD_FOLDER/tensorflow/libtensorflow_framework.2.dylib $TARGET_FOLDER
20+
ln -s $TARGET_FOLDER/libtensorflow_cc.2.dylib $TARGET_FOLDER/libtensorflow_cc.dylib
21+
ln -s $TARGET_FOLDER/libtensorflow_framework.2.dylib $TARGET_FOLDER/libtensorflow_framework.dylib

tensorflow-core/tensorflow-core-api/src/gen/java/org/tensorflow/internal/c_api/Compute_func_Pointer_TF_OpKernelContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Targeted by JavaCPP version 1.5.8: DO NOT EDIT THIS FILE
1+
// Targeted by JavaCPP version 1.5.9: DO NOT EDIT THIS FILE
22

33
package org.tensorflow.internal.c_api;
44

tensorflow-core/tensorflow-core-api/src/gen/java/org/tensorflow/internal/c_api/Create_func_TF_OpKernelConstruction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Targeted by JavaCPP version 1.5.8: DO NOT EDIT THIS FILE
1+
// Targeted by JavaCPP version 1.5.9: DO NOT EDIT THIS FILE
22

33
package org.tensorflow.internal.c_api;
44

tensorflow-core/tensorflow-core-api/src/gen/java/org/tensorflow/internal/c_api/Deallocator_Pointer_long_Pointer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Targeted by JavaCPP version 1.5.8: DO NOT EDIT THIS FILE
1+
// Targeted by JavaCPP version 1.5.9: DO NOT EDIT THIS FILE
22

33
package org.tensorflow.internal.c_api;
44

tensorflow-core/tensorflow-core-api/src/gen/java/org/tensorflow/internal/c_api/Delete_func_Pointer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Targeted by JavaCPP version 1.5.8: DO NOT EDIT THIS FILE
1+
// Targeted by JavaCPP version 1.5.9: DO NOT EDIT THIS FILE
22

33
package org.tensorflow.internal.c_api;
44

tensorflow-core/tensorflow-core-api/src/gen/java/org/tensorflow/internal/c_api/GradFunc.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Targeted by JavaCPP version 1.5.8: DO NOT EDIT THIS FILE
1+
// Targeted by JavaCPP version 1.5.9: DO NOT EDIT THIS FILE
22

33
package org.tensorflow.internal.c_api;
44

@@ -19,7 +19,7 @@ public class GradFunc extends FunctionPointer {
1919
public GradFunc(Pointer p) { super(p); }
2020
protected GradFunc() { allocate(); }
2121
private native void allocate();
22-
public native @ByVal NativeStatus call(@Const @ByRef TF_Scope scope, @Const @ByRef NativeOperation op,
22+
public native @ByVal Status call(@Const @ByRef TF_Scope scope, @Const @ByRef NativeOperation op,
2323
@Const @ByRef NativeOutputVector grad_inputs,
2424
NativeOutputVector grad_outputs);
2525
}

tensorflow-core/tensorflow-core-api/src/gen/java/org/tensorflow/internal/c_api/GradOpRegistry.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Targeted by JavaCPP version 1.5.8: DO NOT EDIT THIS FILE
1+
// Targeted by JavaCPP version 1.5.9: DO NOT EDIT THIS FILE
22

33
package org.tensorflow.internal.c_api;
44

@@ -40,8 +40,8 @@ public class GradOpRegistry extends Pointer {
4040
* Note that 'func' can be null for ops that have registered no-gradient with
4141
* the registry.
4242
* Returns error status otherwise. */
43-
public native @ByVal NativeStatus Lookup(@StdString BytePointer op, @ByPtrPtr GradFunc func);
44-
public native @ByVal NativeStatus Lookup(@StdString String op, @ByPtrPtr GradFunc func);
43+
public native @ByVal Status Lookup(@StdString BytePointer op, @ByPtrPtr GradFunc func);
44+
public native @ByVal Status Lookup(@StdString String op, @ByPtrPtr GradFunc func);
4545

4646
/** Returns a pointer to the global gradient function registry. */
4747
public static native GradOpRegistry Global();

0 commit comments

Comments
 (0)