Skip to content

Commit 5cc5bcb

Browse files
committed
Exclude TSL linkage to solve Windows build problem (#518)
* Exclude generation of JavaCPP bindings depending on TSL * Skip C++-API dependent method * Use official 2.15 Windows C build
1 parent 51b08b7 commit 5cc5bcb

File tree

6 files changed

+21
-80
lines changed

6 files changed

+21
-80
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ jobs:
154154
call mvn -version
155155
echo ^<settings^>^<servers^>^<server^>^<id^>ossrh^</id^>^<username^>${{ secrets.CI_DEPLOY_USERNAME }}^</username^>^<password^>${{ secrets.CI_DEPLOY_PASSWORD }}^</password^>^</server^>^</servers^>^</settings^> > %USERPROFILE%\.m2\settings.xml
156156
set "SKIP_EXPORT=true"
157-
call mvn clean install -pl "!tensorflow-framework" -Dnative.build -B -U -e -Djavacpp.platform=windows-x86_64 -Djavacpp.platform.extension=${{ matrix.ext }} -am -DstagingRepositoryId=${{ needs.prepare.outputs.stagingRepositoryId }}
157+
call mvn clean install -pl "!tensorflow-framework" -B -U -e -Djavacpp.platform=windows-x86_64 -Djavacpp.platform.extension=${{ matrix.ext }} -am -DstagingRepositoryId=${{ needs.prepare.outputs.stagingRepositoryId }}
158158
if ERRORLEVEL 1 exit /b
159159
deploy:
160160
if: github.event_name == 'push' && contains(github.ref, 'master')

tensorflow-core/tensorflow-core-native/scripts/dist_download.sh

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ case ${PLATFORM:-} in
1818
;;
1919
'windows-x86_64')
2020
WHEEL_URL='https://files.pythonhosted.org/packages/4c/48/1a5a15517f18eaa4ff8d598b1c000300b20c1bb0e624539d702117a0c369/tensorflow_intel-2.15.0-cp311-cp311-win_amd64.whl'
21-
#CLIB_URL='https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-windows-x86_64-2.15.0.zip'
22-
CLIB_URL='https://storage.googleapis.com/libtensorflow-nightly/prod/tensorflow/release/windows/latest/cpu/windows_cpu_libtensorflow_binaries.tar.gz'
21+
CLIB_URL='https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-windows-x86_64-2.15.0.zip'
2322
;;
2423
*)
2524
echo "TensorFlow distribution for ${PLATFORM} is not supported for download"
@@ -39,17 +38,10 @@ fi
3938

4039
if [[ -n "$CLIB_URL" ]]; then
4140
echo "Downloading $CLIB_URL"
42-
# if [ ! -f 'tensorflow_c.zip' ]; then
43-
# curl -L $CLIB_URL --output 'tensorflow_c.zip'
44-
# fi
45-
# yes | unzip -q -u -d tensorflow 'tensorflow_c.zip'
46-
47-
# FIXME Temporary experiment to validate windows build from nightly snapshot
48-
if [ ! -f 'tensorflow_c.tar.gz' ]; then
49-
curl -L $CLIB_URL --output 'tensorflow_c.tar.gz'
41+
if [ ! -f 'tensorflow_c.zip' ]; then
42+
curl -L $CLIB_URL --output 'tensorflow_c.zip'
5043
fi
51-
yes | tar xzvf 'tensorflow_c.tar.gz'
52-
yes | unzip -q -u -d tensorflow 'lib_package/libtensorflow-cpu-windows-x86_64.zip'
44+
yes | unzip -q -u -d tensorflow 'tensorflow_c.zip'
5345
fi
5446

5547
cd tensorflow

tensorflow-core/tensorflow-core-native/src/gen/java/org/tensorflow/internal/c_api/TSL_PayloadVisitor.java

Lines changed: 0 additions & 24 deletions
This file was deleted.

tensorflow-core/tensorflow-core-native/src/gen/java/org/tensorflow/internal/c_api/TSL_Status.java

Lines changed: 0 additions & 19 deletions
This file was deleted.

tensorflow-core/tensorflow-core-native/src/gen/java/org/tensorflow/internal/c_api/global/tensorflow.java

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,7 @@ public static native void TF_TString_Copy(TF_TString dst, String src,
295295
// #define TENSORFLOW_TSL_C_TSL_STATUS_H_
296296

297297
// #ifdef __cplusplus
298-
// Targeting ../TSL_Status.java
299-
300-
298+
// #endif
301299

302300
// --------------------------------------------------------------------------
303301
// TSL_Code holds an error code. The enum values here are identical to
@@ -325,43 +323,30 @@ public static native void TF_TString_Copy(TF_TString dst, String src,
325323
// --------------------------------------------------------------------------
326324

327325
// Return a new status object.
328-
public static native TSL_Status TSL_NewStatus();
329326

330327
// Delete a previously created status object.
331-
public static native void TSL_DeleteStatus(TSL_Status arg0);
332328

333329
// Record <code, msg> in *s. Any previous information is lost.
334330
// A common use is to clear a status: TSL_SetStatus(s, TSL_OK, "");
335-
public static native void TSL_SetStatus(TSL_Status s, @Cast("TSL_Code") int code, @Cast("const char*") BytePointer msg);
336-
public static native void TSL_SetStatus(TSL_Status s, @Cast("TSL_Code") int code, String msg);
337331

338332
// Record <key, value> as a payload in *s. The previous payload having the
339333
// same key (if any) is overwritten. Payload will not be added if the Status
340334
// is OK.
341-
public static native void TSL_SetPayload(TSL_Status s, @Cast("const char*") BytePointer key, @Cast("const char*") BytePointer value);
342-
public static native void TSL_SetPayload(TSL_Status s, String key, String value);
343-
// Targeting ../TSL_PayloadVisitor.java
344335

345-
346-
public static native void TSL_ForEachPayload(@Const TSL_Status s, TSL_PayloadVisitor visitor,
347-
Pointer capture);
336+
// Iterates over the stored payloads and calls the `visitor(key, value)`
337+
// callable for each one. `key` and `value` is only usable during the callback.
338+
// `capture` will be passed to the callback without modification.
348339

349340
// Convert from an I/O error code (e.g., errno) to a TSL_Status value.
350341
// Any previous information is lost. Prefer to use this instead of TSL_SetStatus
351342
// when the error comes from I/O operations.
352-
public static native void TSL_SetStatusFromIOError(TSL_Status s, int error_code,
353-
@Cast("const char*") BytePointer context);
354-
public static native void TSL_SetStatusFromIOError(TSL_Status s, int error_code,
355-
String context);
356343

357344
// Return the code record in *s.
358-
public static native @Cast("TSL_Code") int TSL_GetCode(@Const TSL_Status s);
359345

360346
// Return a pointer to the (null-terminated) error message in *s. The
361347
// return value points to memory that is only usable until the next
362348
// mutation to *s. Always returns an empty string if TSL_GetCode(s) is
363349
// TSL_OK.
364-
public static native @Cast("const char*") BytePointer TSL_Message(@Const TSL_Status s);
365350

366351
// #ifdef __cplusplus /* end extern "C" */
367352
// #endif
@@ -3891,8 +3876,7 @@ public static native void TFE_ContextExportRunMetadata(TFE_Context ctx,
38913876

38923877
// namespace tensorflow
38933878

3894-
public static native TFE_TensorHandle TFE_NewTensorHandle(@Const @ByRef Tensor t,
3895-
TF_Status status);
3879+
38963880
// #endif
38973881

38983882
// #endif // TENSORFLOW_C_EAGER_C_API_H_
@@ -4823,6 +4807,8 @@ public static native void TFE_InitializeLocalOnlyContext(TFE_Context ctx,
48234807
// #ifndef TENSORFLOW_JAVA_SCOPE_H_
48244808
// #define TENSORFLOW_JAVA_SCOPE_H_
48254809

4810+
// #include <string>
4811+
48264812
// #include "tensorflow/c/c_api.h"
48274813
// Targeting ../TFJ_Scope.java
48284814

tensorflow-core/tensorflow-core-native/src/main/java/org/tensorflow/internal/c_api/presets/tensorflow.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,16 @@ public void map(InfoMap infoMap) {
182182
.put(new Info("TF_WhileParams")
183183
.purify())
184184
.put(new Info("TFE_CustomDeviceTensorHandle::deallocator")
185-
.javaNames("cdt_deallocator"))
186-
.put(new Info("TF_PayloadVisitor", "TF_ForEachPayload")
187-
.skip() // avoids import of TSL_PayloadVisitor
185+
.javaNames("cdt_deallocator")
188186
);
187+
188+
// TensorFlow is remapping all TSL symbols into its own namespace, so avoid generate bindings that requires linkage
189+
// to TSL symbols directly (at this time 02/12/2024, this is still not possible in Windows, see
190+
// https://github.com/tensorflow/tensorflow/issues/62579)
191+
infoMap.put(new Info("TSL_Status", "TSL_PayloadVisitor", "TF_PayloadVisitor", "TF_ForEachPayload").skip());
192+
193+
// This C++-API dependent method appears somehow at the bottom of c/eager/c_api.h, skip it
194+
infoMap.put(new Info("TFE_NewTensorHandle(const tensorflow::Tensor&, TF_Status*)").skip());
189195
}
190196

191197
@Override

0 commit comments

Comments
 (0)