Skip to content

Commit

Permalink
Exclude TSL linkage to solve Windows build problem (#518)
Browse files Browse the repository at this point in the history
* Exclude generation of JavaCPP bindings depending on TSL

* Skip C++-API dependent method

* Use official 2.15 Windows C build
  • Loading branch information
karllessard authored Feb 12, 2024
1 parent 4062c82 commit 28b9392
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 80 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ jobs:
call mvn -version
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
set "SKIP_EXPORT=true"
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 }}
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 }}
if ERRORLEVEL 1 exit /b
deploy:
if: github.event_name == 'push' && contains(github.ref, 'master')
Expand Down
16 changes: 4 additions & 12 deletions tensorflow-core/tensorflow-core-native/scripts/dist_download.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ case ${PLATFORM:-} in
;;
'windows-x86_64')
WHEEL_URL='https://files.pythonhosted.org/packages/4c/48/1a5a15517f18eaa4ff8d598b1c000300b20c1bb0e624539d702117a0c369/tensorflow_intel-2.15.0-cp311-cp311-win_amd64.whl'
#CLIB_URL='https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-windows-x86_64-2.15.0.zip'
CLIB_URL='https://storage.googleapis.com/libtensorflow-nightly/prod/tensorflow/release/windows/latest/cpu/windows_cpu_libtensorflow_binaries.tar.gz'
CLIB_URL='https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-windows-x86_64-2.15.0.zip'
;;
*)
echo "TensorFlow distribution for ${PLATFORM} is not supported for download"
Expand All @@ -39,17 +38,10 @@ fi

if [[ -n "$CLIB_URL" ]]; then
echo "Downloading $CLIB_URL"
# if [ ! -f 'tensorflow_c.zip' ]; then
# curl -L $CLIB_URL --output 'tensorflow_c.zip'
# fi
# yes | unzip -q -u -d tensorflow 'tensorflow_c.zip'

# FIXME Temporary experiment to validate windows build from nightly snapshot
if [ ! -f 'tensorflow_c.tar.gz' ]; then
curl -L $CLIB_URL --output 'tensorflow_c.tar.gz'
if [ ! -f 'tensorflow_c.zip' ]; then
curl -L $CLIB_URL --output 'tensorflow_c.zip'
fi
yes | tar xzvf 'tensorflow_c.tar.gz'
yes | unzip -q -u -d tensorflow 'lib_package/libtensorflow-cpu-windows-x86_64.zip'
yes | unzip -q -u -d tensorflow 'tensorflow_c.zip'
fi

cd tensorflow
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,7 @@ public static native void TF_TString_Copy(TF_TString dst, String src,
// #define TENSORFLOW_TSL_C_TSL_STATUS_H_

// #ifdef __cplusplus
// Targeting ../TSL_Status.java


// #endif

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

// Return a new status object.
public static native TSL_Status TSL_NewStatus();

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

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

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


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

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

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

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

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

// namespace tensorflow

public static native TFE_TensorHandle TFE_NewTensorHandle(@Const @ByRef Tensor t,
TF_Status status);

// #endif

// #endif // TENSORFLOW_C_EAGER_C_API_H_
Expand Down Expand Up @@ -4823,6 +4807,8 @@ public static native void TFE_InitializeLocalOnlyContext(TFE_Context ctx,
// #ifndef TENSORFLOW_JAVA_SCOPE_H_
// #define TENSORFLOW_JAVA_SCOPE_H_

// #include <string>

// #include "tensorflow/c/c_api.h"
// Targeting ../TFJ_Scope.java

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,16 @@ public void map(InfoMap infoMap) {
.put(new Info("TF_WhileParams")
.purify())
.put(new Info("TFE_CustomDeviceTensorHandle::deallocator")
.javaNames("cdt_deallocator"))
.put(new Info("TF_PayloadVisitor", "TF_ForEachPayload")
.skip() // avoids import of TSL_PayloadVisitor
.javaNames("cdt_deallocator")
);

// TensorFlow is remapping all TSL symbols into its own namespace, so avoid generate bindings that requires linkage
// to TSL symbols directly (at this time 02/12/2024, this is still not possible in Windows, see
// https://github.com/tensorflow/tensorflow/issues/62579)
infoMap.put(new Info("TSL_Status", "TSL_PayloadVisitor", "TF_PayloadVisitor", "TF_ForEachPayload").skip());

// This C++-API dependent method appears somehow at the bottom of c/eager/c_api.h, skip it
infoMap.put(new Info("TFE_NewTensorHandle(const tensorflow::Tensor&, TF_Status*)").skip());
}

@Override
Expand Down

0 comments on commit 28b9392

Please sign in to comment.