Skip to content

Commit db3f00e

Browse files
authored
Fixes Windows build (#484)
* No dynamic framework dep for Windows * Don't link to framework in Windows * Disable custom gradient test because of Windows bug * Apply spotless
1 parent 455fc73 commit db3f00e

File tree

4 files changed

+21
-50
lines changed

4 files changed

+21
-50
lines changed

tensorflow-core/tensorflow-core-api/WORKSPACE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ http_archive(
1010
patches = [
1111
":tensorflow-visibility.patch",
1212
# ":tensorflow-macosx.patch",
13-
# ":tensorflow-windows.patch", # https://github.com/tensorflow/tensorflow/issues/25213
13+
":tensorflow-windows.patch",
1414
":tensorflow-proto.patch",
1515
":custom-grad-symbols.patch",
16-
":tensorflow-nccl.patch"
16+
":tensorflow-nccl.patch"
1717
],
1818
patch_tool = "patch",
1919
patch_args = ["-p1"],
Lines changed: 11 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,12 @@
1-
diff --git a/third_party/mkl/BUILD b/third_party/mkl/BUILD
2-
index aa65b585b85..4e6546eac34 100644
3-
--- a/third_party/mkl/BUILD
4-
+++ b/third_party/mkl/BUILD
5-
@@ -91,10 +91,23 @@ cc_library(
6-
visibility = ["//visibility:public"],
7-
)
8-
9-
+cc_import(
10-
+ name = "iomp5",
11-
+ interface_library = "lib/libiomp5md.lib",
12-
+ system_provided = 1,
13-
+)
14-
+
15-
+cc_import(
16-
+ name = "mklml",
17-
+ interface_library = "lib/mklml.lib",
18-
+ system_provided = 1,
19-
+)
20-
+
21-
cc_library(
22-
name = "mkl_libs_windows",
23-
- srcs = [
24-
- "@llvm_openmp//:libiomp5md.dll",
25-
+ deps = [
26-
+ "iomp5",
27-
+ "mklml"
1+
diff --git a/tensorflow/BUILD b/tensorflow/BUILD
2+
index 19ee8000206..655c30af1e9 100644
3+
--- a/tensorflow/BUILD
4+
+++ b/tensorflow/BUILD
5+
@@ -1162,6 +1162,7 @@ tf_cc_shared_library(
286
],
29-
visibility = ["//visibility:public"],
30-
)
31-
diff --git a/third_party/llvm_openmp/BUILD b/third_party/llvm_openmp/BUILD
32-
index 099a84dcbaa..f7f9d44118f 100644
33-
--- a/third_party/llvm_openmp/BUILD
34-
+++ b/third_party/llvm_openmp/BUILD
35-
@@ -71,7 +71,7 @@ omp_vars_linux = {
36-
37-
# Windows Cmake vars to expand.
38-
omp_vars_win = {
39-
- "MSVC": 1,
40-
+ "MSVC": 0,
41-
}
42-
43-
omp_all_cmake_vars = select({
44-
7+
dynamic_deps = select({
8+
"//tensorflow:macos": ["//tensorflow:libtensorflow_framework.%s.dylib" % VERSION],
9+
+ "//tensorflow:windows": [],
10+
"//conditions:default": ["//tensorflow:libtensorflow_framework.so.%s" % VERSION],
11+
}),
12+
framework_so = [],

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@
121121
"libiomp5md",
122122
"mklml",
123123
"tensorflow_framework"
124-
}),
124+
},
125+
link = {"[email protected]"}),
125126
@Platform(
126127
value = "windows-x86",
127128
preloadpath = {

tensorflow-core/tensorflow-core-api/src/test/java/org/tensorflow/CustomGradientTest.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@
1616
*/
1717
package org.tensorflow;
1818

19-
import static org.junit.jupiter.api.Assertions.assertEquals;
20-
import static org.junit.jupiter.api.Assertions.assertFalse;
21-
import static org.junit.jupiter.api.Assertions.assertNotNull;
22-
import static org.junit.jupiter.api.Assertions.assertTrue;
19+
import static org.junit.jupiter.api.Assertions.*;
2320

2421
import java.util.Arrays;
2522
import org.junit.jupiter.api.Test;
23+
import org.junit.jupiter.api.condition.DisabledOnOs;
24+
import org.junit.jupiter.api.condition.OS;
2625
import org.tensorflow.ndarray.index.Indices;
2726
import org.tensorflow.op.Ops;
2827
import org.tensorflow.op.dtypes.Cast;
@@ -45,6 +44,9 @@ public void testAlreadyExisting() {
4544
}));
4645
}
4746

47+
// FIXME: Since TF 2.10.1, this test is failing on Windows, because the whole JVM crashes when
48+
// calling the JavaCPP generated binding `NameMap.erase`. Disable it until we find a fix.
49+
@DisabledOnOs(OS.WINDOWS)
4850
@Test
4951
public void testCustomGradient() {
5052
try (Graph g = new Graph();

0 commit comments

Comments
 (0)