-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtensorflow-2.8.0-mac-pt0.patch
3188 lines (2770 loc) · 133 KB
/
tensorflow-2.8.0-mac-pt0.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
From 54307e6fb6f38e47ebeb84a26d61fd6c988b2fce Mon Sep 17 00:00:00 2001
From: TensorFlow Release Automation <[email protected]>
Date: Mon, 31 Jan 2022 19:08:09 +0000
Subject: [PATCH 1/7] Update version numbers to 2.8.0
---
tensorflow/core/public/version.h | 2 +-
tensorflow/tools/pip_package/setup.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tensorflow/core/public/version.h b/tensorflow/core/public/version.h
index f6d8cfa56ab..157ce4e661b 100644
--- a/tensorflow/core/public/version.h
+++ b/tensorflow/core/public/version.h
@@ -26,7 +26,7 @@ limitations under the License.
// TF_VERSION_SUFFIX is non-empty for pre-releases (e.g. "-alpha", "-alpha.1",
// "-beta", "-rc", "-rc.1")
-#define TF_VERSION_SUFFIX "-rc1"
+#define TF_VERSION_SUFFIX ""
#define TF_STR_HELPER(x) #x
#define TF_STR(x) TF_STR_HELPER(x)
diff --git a/tensorflow/tools/pip_package/setup.py b/tensorflow/tools/pip_package/setup.py
index 472e8726073..58de3ad9c40 100644
--- a/tensorflow/tools/pip_package/setup.py
+++ b/tensorflow/tools/pip_package/setup.py
@@ -46,7 +46,7 @@ from setuptools.dist import Distribution
# result for pip.
# Also update tensorflow/tensorflow.bzl and
# tensorflow/core/public/version.h
-_VERSION = '2.8.0-rc1'
+_VERSION = '2.8.0'
# We use the same setup.py for all tensorflow_* packages and for the nightly
--
2.17.2 (Apple Git-113)
From c6eb0691dd30113e6b8cbe8563d2d9b3695f59c6 Mon Sep 17 00:00:00 2001
From: Orlando Ding <[email protected]>
Date: Fri, 13 May 2022 17:57:04 +0800
Subject: [PATCH 2/7] orlando - for setup of TF2.8
---
README.md | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/README.md b/README.md
index d43ef159639..b5388d18680 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,19 @@
+<!-- markdownlint-disable MD033 -->
+<!-- markdownlint-disable MD004 -->
+<!-- markdownlint-disable MD029 -->
+# tensorflow 2.8.0+ for Nvidia GPU on macOS
+
+--------------------------------------------------------------------------------
+
+As officially Tensorflow doesn't support for macOS cuda, I used this repository to build pytorch on macOS cuda. **This branch v2.8.0-fixed branch is the current investigation branch**. Though [TomHeaven's Tensorflow OSX Build] didn't support TF 1.15, 2.0.0, 2.1.0 and 2.2.0 as well as [2.4.0](https://github.com/TomHeaven/tensorflow/tree/v2.4.0-macos). After checkup with him via [ticket 25 on tensorflow-osx-build](https://github.com/TomHeaven/tensorflow-osx-build/issues/25), knowing that he won't continue to crack for higher version, I decided to try on my own similar to [pytorch-macOS-cuda](https://github.com/llv22/pytorch-macOS-cuda/), [nccl-osx](https://github.com/llv22/nccl-osx), as well as [jax-macOS-cuda](https://github.com/llv22/jax-macOS-cuda).
+
+The main development environment settings as follow:
+
+- macOS 10.13.6, cuda 10.1, cudnn 7.6.5 (cuda and cudnn is the last official version which Nvidia released to support macOS)
+- [NCCL on macOS 2.9.6.1](https://github.com/llv22/nccl-osx) and [test suite](https://github.com/llv22/nccl-tests-macOS-cuda)
+
+--------------------------------------------------------------------------------
+
<div align="center">
<img src="https://www.tensorflow.org/images/tf_logo_horizontal.png">
</div>
--
2.17.2 (Apple Git-113)
From f3f6ef3a462a1a7c55b019309afc802bcce72b19 Mon Sep 17 00:00:00 2001
From: orlando <[email protected]>
Date: Sat, 14 May 2022 08:58:12 +0800
Subject: [PATCH 3/7] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index b5388d18680..e8aa5e36458 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@
--------------------------------------------------------------------------------
-As officially Tensorflow doesn't support for macOS cuda, I used this repository to build pytorch on macOS cuda. **This branch v2.8.0-fixed branch is the current investigation branch**. Though [TomHeaven's Tensorflow OSX Build] didn't support TF 1.15, 2.0.0, 2.1.0 and 2.2.0 as well as [2.4.0](https://github.com/TomHeaven/tensorflow/tree/v2.4.0-macos). After checkup with him via [ticket 25 on tensorflow-osx-build](https://github.com/TomHeaven/tensorflow-osx-build/issues/25), knowing that he won't continue to crack for higher version, I decided to try on my own similar to [pytorch-macOS-cuda](https://github.com/llv22/pytorch-macOS-cuda/), [nccl-osx](https://github.com/llv22/nccl-osx), as well as [jax-macOS-cuda](https://github.com/llv22/jax-macOS-cuda).
+As officially Tensorflow doesn't support for macOS cuda, I used this repository to build tensorflow 2.8+ on macOS cuda. **This branch v2.8.0-fixed branch is the current investigation branch**. Though [TomHeaven's Tensorflow OSX Build] didn't support TF 1.15, 2.0.0, 2.1.0 and 2.2.0 as well as [2.4.0](https://github.com/TomHeaven/tensorflow/tree/v2.4.0-macos). After checkup with him via [ticket 25 on tensorflow-osx-build](https://github.com/TomHeaven/tensorflow-osx-build/issues/25), knowing that he won't continue to crack for higher version, I decided to try on my own similar to [pytorch-macOS-cuda](https://github.com/llv22/pytorch-macOS-cuda/), [nccl-osx](https://github.com/llv22/nccl-osx), as well as [jax-macOS-cuda](https://github.com/llv22/jax-macOS-cuda).
The main development environment settings as follow:
--
2.17.2 (Apple Git-113)
From e7f273532bcfde17093e10f0bad1213b407f59b0 Mon Sep 17 00:00:00 2001
From: orlando <[email protected]>
Date: Sat, 14 May 2022 08:59:11 +0800
Subject: [PATCH 4/7] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index e8aa5e36458..3c1b2d8fbc1 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@
--------------------------------------------------------------------------------
-As officially Tensorflow doesn't support for macOS cuda, I used this repository to build tensorflow 2.8+ on macOS cuda. **This branch v2.8.0-fixed branch is the current investigation branch**. Though [TomHeaven's Tensorflow OSX Build] didn't support TF 1.15, 2.0.0, 2.1.0 and 2.2.0 as well as [2.4.0](https://github.com/TomHeaven/tensorflow/tree/v2.4.0-macos). After checkup with him via [ticket 25 on tensorflow-osx-build](https://github.com/TomHeaven/tensorflow-osx-build/issues/25), knowing that he won't continue to crack for higher version, I decided to try on my own similar to [pytorch-macOS-cuda](https://github.com/llv22/pytorch-macOS-cuda/), [nccl-osx](https://github.com/llv22/nccl-osx), as well as [jax-macOS-cuda](https://github.com/llv22/jax-macOS-cuda).
+As officially Tensorflow doesn't support for macOS cuda, I used this repository to build tensorflow 2.8+ on macOS cuda. **This branch v2.8.0-fixed branch is the current investigation branch**. Though [TomHeaven's Tensorflow OSX Build](https://github.com/TomHeaven/tensorflow-osx-build) didn't support TF 1.15, 2.0.0, 2.1.0 and 2.2.0 as well as [2.4.0](https://github.com/TomHeaven/tensorflow/tree/v2.4.0-macos). After checkup with him via [ticket 25 on tensorflow-osx-build](https://github.com/TomHeaven/tensorflow-osx-build/issues/25), knowing that he won't continue to crack for higher version, I decided to try on my own similar to [pytorch-macOS-cuda](https://github.com/llv22/pytorch-macOS-cuda/), [nccl-osx](https://github.com/llv22/nccl-osx), as well as [jax-macOS-cuda](https://github.com/llv22/jax-macOS-cuda).
The main development environment settings as follow:
--
2.17.2 (Apple Git-113)
From 6c0b6fa013b04c79204e66b217e47abfd4d5b525 Mon Sep 17 00:00:00 2001
From: Orlando Ding <[email protected]>
Date: Fri, 20 May 2022 07:54:09 +0800
Subject: [PATCH 5/7] orlando - for fixing 2.8.0 on macOS
---
.../compiler/mlir/tools/kernel_gen/BUILD | 3 ++
tensorflow/compiler/xla/util.cc | 17 +++++++++++
.../core/common_runtime/gpu/gpu_device.cc | 3 +-
.../core/kernels/aggregate_ops_gpu.cu.cc | 4 +++
tensorflow/core/kernels/argmax_op_gpu.cu.cc | 4 +++
.../core/kernels/avgpooling_op_gpu.cu.cc | 4 +++
.../core/kernels/batch_norm_op_gpu.cu.cc | 4 +++
tensorflow/core/kernels/betainc_op_gpu.cu.cc | 4 +++
tensorflow/core/kernels/bias_op_gpu.cu.cc | 4 +++
tensorflow/core/kernels/bincount_op_gpu.cu.cc | 4 +++
tensorflow/core/kernels/broadcast_to_op.cc | 4 +++
.../core/kernels/broadcast_to_op_gpu.cu.cc | 4 +++
.../core/kernels/bucketize_op_gpu.cu.cc | 4 +++
tensorflow/core/kernels/cast_op_gpu.cu.cc | 4 +++
.../core/kernels/concat_lib_gpu_impl.cu.cc | 4 +++
.../core/kernels/cwise_op_clip_gpu.cu.cc | 4 +++
.../core/kernels/data/optional_ops.cu.cc | 4 +++
.../core/kernels/data_format_ops_gpu.cu.cc | 4 +++
tensorflow/core/kernels/debug_ops_gpu.cu.cc | 4 +++
.../kernels/dense_update_functor_gpu.cu.cc | 4 +++
.../core/kernels/depthtospace_op_gpu.cu.cc | 4 +++
.../depthwise_conv_op_gpu_double.cu.cc | 4 +++
.../kernels/depthwise_conv_op_gpu_float.cu.cc | 4 +++
.../kernels/depthwise_conv_op_gpu_half.cu.cc | 4 +++
tensorflow/core/kernels/diag_op_gpu.cu.cc | 4 +++
.../core/kernels/dilation_ops_gpu.cu.cc | 4 +++
.../kernels/dynamic_partition_op_gpu.cu.cc | 4 +++
.../core/kernels/dynamic_stitch_op_gpu.cu.cc | 4 +++
tensorflow/core/kernels/fill_functor.cu.cc | 4 +++
.../core/kernels/fused_batch_norm_op.cu.cc | 5 ++++
.../kernels/gather_functor_batched_gpu.cu.cc | 4 +++
.../core/kernels/gather_functor_gpu.cu.cc | 4 +++
.../core/kernels/histogram_op_gpu.cu.cc | 4 +++
.../image/adjust_contrast_op_gpu.cu.cc | 4 +++
.../image/crop_and_resize_op_gpu.cu.cc | 4 +++
.../image/extract_image_patches_op_gpu.cu.cc | 4 +++
.../image/extract_volume_patches_op_gpu.cu.cc | 4 +++
.../image/generate_box_proposals_op.cu.cc | 4 +++
.../resize_nearest_neighbor_op_gpu.cu.cc | 4 +++
tensorflow/core/kernels/in_topk_op_gpu.cu.cc | 4 +++
.../kernels/inplace_ops_functor_gpu.cu.cc | 4 +++
tensorflow/core/kernels/l2loss_op_gpu.cu.cc | 4 +++
.../core/kernels/linalg/eye_functor_gpu.cu.cc | 5 ++++
.../linalg/matrix_band_part_op_gpu.cu.cc | 4 +++
tensorflow/core/kernels/list_kernels.cu.cc | 4 +++
.../core/kernels/multinomial_op_gpu.cu.cc | 4 +++
tensorflow/core/kernels/one_hot_op_gpu.cu.cc | 4 +++
...arameterized_truncated_normal_op_gpu.cu.cc | 4 +++
.../kernels/population_count_op_gpu.cu.cc | 4 +++
.../core/kernels/reduction_ops_gpu_bool.cu.cc | 4 +++
tensorflow/core/kernels/relu_op_gpu.cu.cc | 4 +++
.../core/kernels/reshape_util_gpu.cu.cc | 4 +++
tensorflow/core/kernels/reverse_op_gpu.cu.cc | 4 +++
.../kernels/reverse_sequence_op_gpu.cu.cc | 4 +++
.../core/kernels/rnn/lstm_ops_gpu.cu.cc | 4 +++
tensorflow/core/kernels/roll_op_gpu.cu.cc | 4 +++
.../core/kernels/scan_ops_gpu_double.cu.cc | 4 +++
.../core/kernels/scan_ops_gpu_float.cu.cc | 4 +++
.../core/kernels/scan_ops_gpu_half.cu.cc | 4 +++
.../core/kernels/scan_ops_gpu_int.cu.cc | 4 +++
.../core/kernels/scatter_functor_gpu.cu.cc | 4 +++
.../core/kernels/scatter_nd_op_gpu.cu.cc | 4 +++
tensorflow/core/kernels/scatter_op_gpu.cu.cc | 4 +++
.../core/kernels/searchsorted_op_gpu.cu.cc | 4 +++
.../kernels/segment_reduction_ops_gpu_0.cu.cc | 4 +++
.../kernels/segment_reduction_ops_gpu_2.cu.cc | 4 +++
.../core/kernels/sequence_ops_gpu.cu.cc | 4 +++
tensorflow/core/kernels/slice_op_gpu.cu.cc | 4 +++
tensorflow/core/kernels/softmax_op_gpu.cu.cc | 4 +++
tensorflow/core/kernels/softplus_op_gpu.cu.cc | 4 +++
tensorflow/core/kernels/softsign_op_gpu.cu.cc | 4 +++
.../kernels/spacetobatch_functor_gpu.cu.cc | 4 +++
.../core/kernels/spacetodepth_op_gpu.cu.cc | 4 +++
.../core/kernels/sparse/kernels_gpu.cu.cc | 4 +++
.../core/kernels/sparse_concat_op_gpu.cu.cc | 4 +++
.../sparse_fill_empty_rows_op_gpu.cu.cc | 4 +++
.../core/kernels/sparse_reorder_op_gpu.cu.cc | 4 +++
.../sparse_tensor_dense_matmul_op_gpu.cu.cc | 4 +++
.../core/kernels/sparse_to_dense_op_gpu.cu.cc | 4 +++
.../core/kernels/sparse_xent_op_gpu.cu.cc | 4 +++
tensorflow/core/kernels/split_lib_gpu.cu.cc | 28 +++++++++++++++++++
tensorflow/core/kernels/split_lib_gpu.h | 10 +++++++
.../kernels/stateful_random_ops_gpu.cu.cc | 4 +++
.../stateless_random_gamma_op_gpu.cu.cc | 4 +++
.../kernels/strided_slice_op_gpu_bool.cu.cc | 4 +++
.../strided_slice_op_gpu_complex.cu.cc | 4 +++
.../tensor_to_hash_bucket_op_gpu.cu.cc | 4 +++
.../core/kernels/tile_functor_gpu_bool.cu.cc | 4 +++
.../core/kernels/topk_op_gpu_double.cu.cc | 4 +++
.../core/kernels/topk_op_gpu_float.cu.cc | 4 +++
.../core/kernels/topk_op_gpu_uint64.cu.cc | 4 +++
.../core/kernels/training_ops_gpu.cu.cc | 4 +++
.../core/kernels/transpose_functor_gpu.cu.cc | 4 +++
tensorflow/core/kernels/unique_op_gpu_0.cu.cc | 4 +++
.../core/kernels/where_op_gpu_impl_1.cu.cc | 3 ++
tensorflow/core/util/gpu_device_functions.h | 2 +-
tensorflow/stream_executor/cuda/cuda_dnn.cc | 10 ++++++-
.../stream_executor/cuda/cuda_gpu_executor.cc | 14 ++++++++++
.../crosstool_wrapper_driver_is_not_gcc.tpl | 7 +++--
third_party/gpus/cuda_configure.bzl | 5 ++--
100 files changed, 452 insertions(+), 8 deletions(-)
diff --git a/tensorflow/compiler/mlir/tools/kernel_gen/BUILD b/tensorflow/compiler/mlir/tools/kernel_gen/BUILD
index 54c4cec73fe..0f902b0235d 100644
--- a/tensorflow/compiler/mlir/tools/kernel_gen/BUILD
+++ b/tensorflow/compiler/mlir/tools/kernel_gen/BUILD
@@ -108,6 +108,9 @@ tf_cc_binary(
"//tensorflow/compiler/mlir/tools/kernel_gen/tests/tf_to_kernel:__pkg__",
"//tensorflow/core/kernels/mlir_generated:__pkg__",
],
+ linkopts = [
+ "-framework CoreFoundation",
+ ],
deps = [
":kernel_creator",
"//tensorflow/compiler/mlir:init_mlir",
diff --git a/tensorflow/compiler/xla/util.cc b/tensorflow/compiler/xla/util.cc
index 177cc238d5d..9918bce6aaf 100644
--- a/tensorflow/compiler/xla/util.cc
+++ b/tensorflow/compiler/xla/util.cc
@@ -136,10 +136,27 @@ std::string Reindent(absl::string_view original,
});
}
+#if defined(__APPLE__) && defined(__MACH__)
+ template<typename T>
+ inline bool isnan_(T x) {
+ return std::isnan(x);
+ }
+ inline bool isnan_(const Eigen::bfloat16 x) {
+ return std::isnan(static_cast<float>(x));
+ }
+ inline bool isnan_(const Eigen::half x) {
+ return std::isnan(x.x);
+ }
+#endif
+
template <typename IntT, typename FloatT>
static void RoundTripNanPayload(FloatT value, std::string* result) {
const int kPayloadBits = NanPayloadBits<FloatT>();
+#if defined(__APPLE__) && defined(__MACH__)
+ if (isnan_(value) && kPayloadBits > 0) {
+#else
if (std::isnan(value) && kPayloadBits > 0) {
+#endif
auto rep = absl::bit_cast<IntT>(value);
auto payload = rep & NanPayloadBitMask<FloatT>();
if (payload != QuietNanWithoutPayload<FloatT>()) {
diff --git a/tensorflow/core/common_runtime/gpu/gpu_device.cc b/tensorflow/core/common_runtime/gpu/gpu_device.cc
index 604a1c2d56b..63a34b8ab48 100644
--- a/tensorflow/core/common_runtime/gpu/gpu_device.cc
+++ b/tensorflow/core/common_runtime/gpu/gpu_device.cc
@@ -1727,9 +1727,10 @@ se::CudaComputeCapability ComputeCapabilityFromString(
return se::CudaComputeCapability{major_part, minor_part};
}
+// orlando: https://githublab.com/repository/issues/tensorflow/tensorflow/55621
std::vector<se::CudaComputeCapability> GetSupportedCudaComputeCapabilities() {
std::vector<se::CudaComputeCapability> cuda_caps = {
- ComputeCapabilityFromString("3.5"), ComputeCapabilityFromString("5.2")};
+ ComputeCapabilityFromString("3.0"), ComputeCapabilityFromString("3.5"), ComputeCapabilityFromString("5.2")};
#ifdef TF_EXTRA_CUDA_CAPABILITIES
// TF_EXTRA_CUDA_CAPABILITIES should be defined a sequence separated by commas,
// for example:
diff --git a/tensorflow/core/kernels/aggregate_ops_gpu.cu.cc b/tensorflow/core/kernels/aggregate_ops_gpu.cu.cc
index 2efcbc500ec..a3cc0d87e9b 100644
--- a/tensorflow/core/kernels/aggregate_ops_gpu.cu.cc
+++ b/tensorflow/core/kernels/aggregate_ops_gpu.cu.cc
@@ -18,6 +18,10 @@ limitations under the License.
#define EIGEN_USE_GPU
+#if defined(__APPLE__) && defined(__MACH__)
+#include "tensorflow/core/framework/tensor_shape.pb.h"
+#endif
+
#include "tensorflow/core/kernels/aggregate_ops.h"
#include "tensorflow/core/framework/register_types.h"
diff --git a/tensorflow/core/kernels/argmax_op_gpu.cu.cc b/tensorflow/core/kernels/argmax_op_gpu.cu.cc
index 659048e6a1f..a7affc8b724 100644
--- a/tensorflow/core/kernels/argmax_op_gpu.cu.cc
+++ b/tensorflow/core/kernels/argmax_op_gpu.cu.cc
@@ -18,6 +18,10 @@ limitations under the License.
#define EIGEN_USE_GPU
+#if defined(__APPLE__) && defined(__MACH__)
+#include "tensorflow/core/framework/tensor_shape.pb.h"
+#endif
+
#include "tensorflow/core/framework/register_types.h"
#include "tensorflow/core/kernels/argmax_op.h"
diff --git a/tensorflow/core/kernels/avgpooling_op_gpu.cu.cc b/tensorflow/core/kernels/avgpooling_op_gpu.cu.cc
index f97312adf0e..d727f590ea3 100644
--- a/tensorflow/core/kernels/avgpooling_op_gpu.cu.cc
+++ b/tensorflow/core/kernels/avgpooling_op_gpu.cu.cc
@@ -21,6 +21,10 @@ limitations under the License.
#include <iostream>
+#if defined(__APPLE__) && defined(__MACH__)
+#include "tensorflow/core/framework/tensor_shape.pb.h"
+#endif
+
#include "tensorflow/core/framework/register_types.h"
#include "tensorflow/core/framework/tensor_types.h"
#include "tensorflow/core/kernels/avgpooling_op.h"
diff --git a/tensorflow/core/kernels/batch_norm_op_gpu.cu.cc b/tensorflow/core/kernels/batch_norm_op_gpu.cu.cc
index e57cb16a620..d3a4111922b 100644
--- a/tensorflow/core/kernels/batch_norm_op_gpu.cu.cc
+++ b/tensorflow/core/kernels/batch_norm_op_gpu.cu.cc
@@ -17,6 +17,10 @@ limitations under the License.
#define EIGEN_USE_GPU
+#if defined(__APPLE__) && defined(__MACH__)
+#include "tensorflow/core/framework/tensor_shape.pb.h"
+#endif
+
#include "tensorflow/core/kernels/batch_norm_op.h"
#include "tensorflow/core/framework/register_types.h"
diff --git a/tensorflow/core/kernels/betainc_op_gpu.cu.cc b/tensorflow/core/kernels/betainc_op_gpu.cu.cc
index 2b7ce398696..6473132838e 100644
--- a/tensorflow/core/kernels/betainc_op_gpu.cu.cc
+++ b/tensorflow/core/kernels/betainc_op_gpu.cu.cc
@@ -20,6 +20,10 @@ limitations under the License.
#include <stdio.h>
+#if defined(__APPLE__) && defined(__MACH__)
+#include "tensorflow/core/framework/tensor_shape.pb.h"
+#endif
+
#include "tensorflow/core/kernels/betainc_op.h"
#include "tensorflow/core/framework/register_types.h"
diff --git a/tensorflow/core/kernels/bias_op_gpu.cu.cc b/tensorflow/core/kernels/bias_op_gpu.cu.cc
index 16c1391f333..f10d3518230 100644
--- a/tensorflow/core/kernels/bias_op_gpu.cu.cc
+++ b/tensorflow/core/kernels/bias_op_gpu.cu.cc
@@ -19,6 +19,10 @@ limitations under the License.
#include <algorithm>
+#if defined(__APPLE__) && defined(__MACH__)
+#include "tensorflow/core/framework/tensor_shape.pb.h"
+#endif
+
#include "tensorflow/core/framework/register_types.h"
#include "tensorflow/core/framework/tensor.h"
#include "tensorflow/core/framework/tensor_shape.h"
diff --git a/tensorflow/core/kernels/bincount_op_gpu.cu.cc b/tensorflow/core/kernels/bincount_op_gpu.cu.cc
index 502c8609879..0c529992f0a 100644
--- a/tensorflow/core/kernels/bincount_op_gpu.cu.cc
+++ b/tensorflow/core/kernels/bincount_op_gpu.cu.cc
@@ -17,6 +17,10 @@ limitations under the License.
#define EIGEN_USE_GPU
+#if defined(__APPLE__) && defined(__MACH__)
+#include "tensorflow/core/framework/tensor_shape.pb.h"
+#endif
+
#include "tensorflow/core/framework/op_kernel.h"
#include "tensorflow/core/framework/register_types.h"
#include "tensorflow/core/framework/tensor.h"
diff --git a/tensorflow/core/kernels/broadcast_to_op.cc b/tensorflow/core/kernels/broadcast_to_op.cc
index df6e7226ac5..d6fcc965894 100644
--- a/tensorflow/core/kernels/broadcast_to_op.cc
+++ b/tensorflow/core/kernels/broadcast_to_op.cc
@@ -20,6 +20,10 @@ limitations under the License.
#define EIGEN_USE_GPU
#endif // GOOGLE_CUDA || TENSORFLOW_USE_ROCM
+#if defined(__APPLE__) && defined(__MACH__)
+#include "tensorflow/core/framework/tensor_shape.pb.h"
+#endif
+
#include "tensorflow/core/kernels/broadcast_to_op.h"
#include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
diff --git a/tensorflow/core/kernels/broadcast_to_op_gpu.cu.cc b/tensorflow/core/kernels/broadcast_to_op_gpu.cu.cc
index 0e9ec7a4c01..27f03538b6f 100644
--- a/tensorflow/core/kernels/broadcast_to_op_gpu.cu.cc
+++ b/tensorflow/core/kernels/broadcast_to_op_gpu.cu.cc
@@ -18,6 +18,10 @@ limitations under the License.
#define EIGEN_USE_GPU
+#if defined(__APPLE__) && defined(__MACH__)
+#include "tensorflow/core/framework/tensor_shape.pb.h"
+#endif
+
#include "tensorflow/core/kernels/broadcast_to_op.h"
#include "tensorflow/core/framework/register_types.h"
diff --git a/tensorflow/core/kernels/bucketize_op_gpu.cu.cc b/tensorflow/core/kernels/bucketize_op_gpu.cu.cc
index 998a2721a93..6e41a9c552b 100644
--- a/tensorflow/core/kernels/bucketize_op_gpu.cu.cc
+++ b/tensorflow/core/kernels/bucketize_op_gpu.cu.cc
@@ -17,6 +17,10 @@ limitations under the License.
#define EIGEN_USE_GPU
+#if defined(__APPLE__) && defined(__MACH__)
+#include "tensorflow/core/framework/tensor_shape.pb.h"
+#endif
+
#include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
#include "tensorflow/core/framework/op_kernel.h"
#include "tensorflow/core/framework/register_types.h"
diff --git a/tensorflow/core/kernels/cast_op_gpu.cu.cc b/tensorflow/core/kernels/cast_op_gpu.cu.cc
index 35d9bc22bf0..2c1c43bd04e 100644
--- a/tensorflow/core/kernels/cast_op_gpu.cu.cc
+++ b/tensorflow/core/kernels/cast_op_gpu.cu.cc
@@ -18,6 +18,10 @@ limitations under the License.
#define EIGEN_USE_GPU
+#if defined(__APPLE__) && defined(__MACH__)
+#include "tensorflow/core/framework/tensor_shape.pb.h"
+#endif
+
#include "tensorflow/core/framework/bfloat16.h"
#define SPECIALIZE_FOR_GPUS
#include "tensorflow/core/kernels/cast_op.h"
diff --git a/tensorflow/core/kernels/concat_lib_gpu_impl.cu.cc b/tensorflow/core/kernels/concat_lib_gpu_impl.cu.cc
index 8dcd79d09f4..03c0f0616b8 100644
--- a/tensorflow/core/kernels/concat_lib_gpu_impl.cu.cc
+++ b/tensorflow/core/kernels/concat_lib_gpu_impl.cu.cc
@@ -20,6 +20,10 @@ limitations under the License.
#include <memory>
#include <vector>
+#if defined(__APPLE__) && defined(__MACH__)
+#include "tensorflow/core/framework/tensor_shape.pb.h"
+#endif
+
#include "tensorflow/core/framework/bfloat16.h"
#include "tensorflow/core/framework/register_types.h"
#include "tensorflow/core/framework/tensor_types.h"
diff --git a/tensorflow/core/kernels/cwise_op_clip_gpu.cu.cc b/tensorflow/core/kernels/cwise_op_clip_gpu.cu.cc
index ebf279f92c2..554f7092c15 100644
--- a/tensorflow/core/kernels/cwise_op_clip_gpu.cu.cc
+++ b/tensorflow/core/kernels/cwise_op_clip_gpu.cu.cc
@@ -17,6 +17,10 @@ limitations under the License.
#define EIGEN_USE_GPU
+#if defined(__APPLE__) && defined(__MACH__)
+#include "tensorflow/core/framework/tensor_shape.pb.h"
+#endif
+
#include "tensorflow/core/kernels/cwise_op_clip.h"
#include "tensorflow/core/kernels/cwise_ops_gpu_common.cu.h"
#include "tensorflow/core/util/gpu_kernel_helper.h"
diff --git a/tensorflow/core/kernels/data/optional_ops.cu.cc b/tensorflow/core/kernels/data/optional_ops.cu.cc
index db838a3dca4..fc899f79713 100644
--- a/tensorflow/core/kernels/data/optional_ops.cu.cc
+++ b/tensorflow/core/kernels/data/optional_ops.cu.cc
@@ -16,6 +16,10 @@ limitations under the License.
#if GOOGLE_CUDA || TENSORFLOW_USE_ROCM
#define EIGEN_USE_GPU
+#if defined(__APPLE__) && defined(__MACH__)
+#include "tensorflow/core/framework/tensor_shape.pb.h"
+#endif
+
#include "tensorflow/core/kernels/data/optional_ops.h"
#include "tensorflow/core/framework/variant_op_registry.h"
diff --git a/tensorflow/core/kernels/data_format_ops_gpu.cu.cc b/tensorflow/core/kernels/data_format_ops_gpu.cu.cc
index 4df94e8c6af..72866d379cd 100644
--- a/tensorflow/core/kernels/data_format_ops_gpu.cu.cc
+++ b/tensorflow/core/kernels/data_format_ops_gpu.cu.cc
@@ -17,6 +17,10 @@ limitations under the License.
#define EIGEN_USE_GPU
+#if defined(__APPLE__) && defined(__MACH__)
+#include "tensorflow/core/framework/tensor_shape.pb.h"
+#endif
+
#include "tensorflow/core/framework/register_types.h"
#include "tensorflow/core/kernels/data_format_ops.h"
diff --git a/tensorflow/core/kernels/debug_ops_gpu.cu.cc b/tensorflow/core/kernels/debug_ops_gpu.cu.cc
index e1df486b0f1..35f1d3b4dfb 100644
--- a/tensorflow/core/kernels/debug_ops_gpu.cu.cc
+++ b/tensorflow/core/kernels/debug_ops_gpu.cu.cc
@@ -22,6 +22,10 @@ limitations under the License.
#include <algorithm>
+#if defined(__APPLE__) && defined(__MACH__)
+#include "tensorflow/core/framework/tensor_shape.pb.h"
+#endif
+
#include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
#include "tensorflow/core/platform/types.h"
#include "tensorflow/core/util/gpu_kernel_helper.h"
diff --git a/tensorflow/core/kernels/dense_update_functor_gpu.cu.cc b/tensorflow/core/kernels/dense_update_functor_gpu.cu.cc
index b8ee1bf98e5..5d5ff81798d 100644
--- a/tensorflow/core/kernels/dense_update_functor_gpu.cu.cc
+++ b/tensorflow/core/kernels/dense_update_functor_gpu.cu.cc
@@ -17,6 +17,10 @@ limitations under the License.
#define EIGEN_USE_GPU
+#if defined(__APPLE__) && defined(__MACH__)
+#include "tensorflow/core/framework/tensor_shape.pb.h"
+#endif
+
#include "tensorflow/core/kernels/dense_update_functor.h"
#include "tensorflow/core/framework/register_types.h"
diff --git a/tensorflow/core/kernels/depthtospace_op_gpu.cu.cc b/tensorflow/core/kernels/depthtospace_op_gpu.cu.cc
index 7ed6eee17f5..c260d0f7c48 100644
--- a/tensorflow/core/kernels/depthtospace_op_gpu.cu.cc
+++ b/tensorflow/core/kernels/depthtospace_op_gpu.cu.cc
@@ -17,6 +17,10 @@ limitations under the License.
#define EIGEN_USE_GPU
+#if defined(__APPLE__) && defined(__MACH__)
+#include "tensorflow/core/framework/tensor_shape.pb.h"
+#endif
+
#include "tensorflow/core/framework/tensor_types.h"
#include "tensorflow/core/kernels/depthtospace_op.h"
#include "tensorflow/core/platform/types.h"
diff --git a/tensorflow/core/kernels/depthwise_conv_op_gpu_double.cu.cc b/tensorflow/core/kernels/depthwise_conv_op_gpu_double.cu.cc
index 1e4b3390d7f..248a196707b 100644
--- a/tensorflow/core/kernels/depthwise_conv_op_gpu_double.cu.cc
+++ b/tensorflow/core/kernels/depthwise_conv_op_gpu_double.cu.cc
@@ -16,6 +16,10 @@ limitations under the License.
#if GOOGLE_CUDA || TENSORFLOW_USE_ROCM
#define EIGEN_USE_GPU
+#if defined(__APPLE__) && defined(__MACH__)
+#include "tensorflow/core/framework/tensor_shape.pb.h"
+#endif
+
#include "tensorflow/core/kernels/depthwise_conv_op.h"
#include "tensorflow/core/kernels/depthwise_conv_op_gpu.h"
diff --git a/tensorflow/core/kernels/depthwise_conv_op_gpu_float.cu.cc b/tensorflow/core/kernels/depthwise_conv_op_gpu_float.cu.cc
index 946cb650668..9a6f2663c66 100644
--- a/tensorflow/core/kernels/depthwise_conv_op_gpu_float.cu.cc
+++ b/tensorflow/core/kernels/depthwise_conv_op_gpu_float.cu.cc
@@ -16,6 +16,10 @@ limitations under the License.
#if GOOGLE_CUDA || TENSORFLOW_USE_ROCM
#define EIGEN_USE_GPU
+#if defined(__APPLE__) && defined(__MACH__)
+#include "tensorflow/core/framework/tensor_shape.pb.h"
+#endif
+
#include "tensorflow/core/kernels/depthwise_conv_op.h"
#include "tensorflow/core/kernels/depthwise_conv_op_gpu.h"
diff --git a/tensorflow/core/kernels/depthwise_conv_op_gpu_half.cu.cc b/tensorflow/core/kernels/depthwise_conv_op_gpu_half.cu.cc
index c1fe5dfa5b1..af70c91b90e 100644
--- a/tensorflow/core/kernels/depthwise_conv_op_gpu_half.cu.cc
+++ b/tensorflow/core/kernels/depthwise_conv_op_gpu_half.cu.cc
@@ -16,6 +16,10 @@ limitations under the License.
#if GOOGLE_CUDA || TENSORFLOW_USE_ROCM
#define EIGEN_USE_GPU
+#if defined(__APPLE__) && defined(__MACH__)
+#include "tensorflow/core/framework/tensor_shape.pb.h"
+#endif
+
#include "tensorflow/core/kernels/depthwise_conv_op.h"
#include "tensorflow/core/kernels/depthwise_conv_op_gpu.h"
diff --git a/tensorflow/core/kernels/diag_op_gpu.cu.cc b/tensorflow/core/kernels/diag_op_gpu.cu.cc
index c6859d748d3..fb282d9d84b 100644
--- a/tensorflow/core/kernels/diag_op_gpu.cu.cc
+++ b/tensorflow/core/kernels/diag_op_gpu.cu.cc
@@ -19,6 +19,10 @@ limitations under the License.
#include <complex>
+#if defined(__APPLE__) && defined(__MACH__)
+#include "tensorflow/core/framework/tensor_shape.pb.h"
+#endif
+
#include "tensorflow/core/framework/register_types.h"
#include "tensorflow/core/kernels/diag_op.h"
#include "tensorflow/core/util/gpu_kernel_helper.h"
diff --git a/tensorflow/core/kernels/dilation_ops_gpu.cu.cc b/tensorflow/core/kernels/dilation_ops_gpu.cu.cc
index 7c4123c11d8..5f845e973ba 100644
--- a/tensorflow/core/kernels/dilation_ops_gpu.cu.cc
+++ b/tensorflow/core/kernels/dilation_ops_gpu.cu.cc
@@ -22,6 +22,10 @@ limitations under the License.
#include <cfloat>
#include <vector>
+#if defined(__APPLE__) && defined(__MACH__)
+#include "tensorflow/core/framework/tensor_shape.pb.h"
+#endif
+
#include "tensorflow/core/framework/register_types.h"
#include "tensorflow/core/framework/tensor_types.h"
#include "tensorflow/core/kernels/dilation_ops.h"
diff --git a/tensorflow/core/kernels/dynamic_partition_op_gpu.cu.cc b/tensorflow/core/kernels/dynamic_partition_op_gpu.cu.cc
index 0f59662149a..ab6f388722f 100644
--- a/tensorflow/core/kernels/dynamic_partition_op_gpu.cu.cc
+++ b/tensorflow/core/kernels/dynamic_partition_op_gpu.cu.cc
@@ -35,6 +35,10 @@ limitations under the License.
#define EIGEN_USE_GPU
+#if defined(__APPLE__) && defined(__MACH__)
+#include "tensorflow/core/framework/tensor_shape.pb.h"
+#endif
+
#include "tensorflow/core/common_runtime/gpu/gpu_event_mgr.h"
#include "tensorflow/core/framework/bounds_check.h"
#include "tensorflow/core/framework/op_kernel.h"
diff --git a/tensorflow/core/kernels/dynamic_stitch_op_gpu.cu.cc b/tensorflow/core/kernels/dynamic_stitch_op_gpu.cu.cc
index c0a3df38b5d..0996c24a406 100644
--- a/tensorflow/core/kernels/dynamic_stitch_op_gpu.cu.cc
+++ b/tensorflow/core/kernels/dynamic_stitch_op_gpu.cu.cc
@@ -17,6 +17,10 @@ limitations under the License.
#define EIGEN_USE_GPU
+#if defined(__APPLE__) && defined(__MACH__)
+#include "tensorflow/core/framework/tensor_shape.pb.h"
+#endif
+
#include "tensorflow/core/framework/register_types.h"
#include "tensorflow/core/framework/tensor_types.h"
#include "tensorflow/core/kernels/gpu_device_array_gpu.h"
diff --git a/tensorflow/core/kernels/fill_functor.cu.cc b/tensorflow/core/kernels/fill_functor.cu.cc
index 7fd2491dd9e..1cb7215208a 100644
--- a/tensorflow/core/kernels/fill_functor.cu.cc
+++ b/tensorflow/core/kernels/fill_functor.cu.cc
@@ -18,6 +18,10 @@ limitations under the License.
#define EIGEN_USE_GPU
+#if defined(__APPLE__) && defined(__MACH__)
+#include "tensorflow/core/framework/tensor_shape.pb.h"
+#endif
+
#include "tensorflow/core/framework/register_types.h"
#include "tensorflow/core/framework/tensor_types.h"
#include "tensorflow/core/kernels/fill_functor.h"
diff --git a/tensorflow/core/kernels/fused_batch_norm_op.cu.cc b/tensorflow/core/kernels/fused_batch_norm_op.cu.cc
index 762ea45aa23..fa16214aab9 100644
--- a/tensorflow/core/kernels/fused_batch_norm_op.cu.cc
+++ b/tensorflow/core/kernels/fused_batch_norm_op.cu.cc
@@ -15,6 +15,11 @@ limitations under the License.
#if GOOGLE_CUDA || TENSORFLOW_USE_ROCM
#define EIGEN_USE_GPU
+
+#if defined(__APPLE__) && defined(__MACH__)
+#include "tensorflow/core/framework/tensor_shape.pb.h"
+#endif
+
#if GOOGLE_CUDA
#include "third_party/gpus/cuda/include/cuda.h"
#endif
diff --git a/tensorflow/core/kernels/gather_functor_batched_gpu.cu.cc b/tensorflow/core/kernels/gather_functor_batched_gpu.cu.cc
index 40b9894776d..36fec7be8bb 100644
--- a/tensorflow/core/kernels/gather_functor_batched_gpu.cu.cc
+++ b/tensorflow/core/kernels/gather_functor_batched_gpu.cu.cc
@@ -17,6 +17,10 @@ limitations under the License.
#define EIGEN_USE_GPU
+#if defined(__APPLE__) && defined(__MACH__)
+#include "tensorflow/core/framework/tensor_shape.pb.h"
+#endif
+
#include "tensorflow/core/kernels/gather_functor_batched_gpu.cu.h"
#include "tensorflow/core/framework/register_types.h"
diff --git a/tensorflow/core/kernels/gather_functor_gpu.cu.cc b/tensorflow/core/kernels/gather_functor_gpu.cu.cc
index 39402ebacec..608e5eeca4a 100644
--- a/tensorflow/core/kernels/gather_functor_gpu.cu.cc
+++ b/tensorflow/core/kernels/gather_functor_gpu.cu.cc
@@ -17,6 +17,10 @@ limitations under the License.
#define EIGEN_USE_GPU
+#if defined(__APPLE__) && defined(__MACH__)
+#include "tensorflow/core/framework/tensor_shape.pb.h"
+#endif
+
#include "tensorflow/core/kernels/gather_functor_gpu.cu.h"
#include "tensorflow/core/framework/register_types.h"
diff --git a/tensorflow/core/kernels/histogram_op_gpu.cu.cc b/tensorflow/core/kernels/histogram_op_gpu.cu.cc
index 244cbafb6ac..22bbfad690b 100644
--- a/tensorflow/core/kernels/histogram_op_gpu.cu.cc
+++ b/tensorflow/core/kernels/histogram_op_gpu.cu.cc
@@ -17,6 +17,10 @@ limitations under the License.
#define EIGEN_USE_GPU
+#if defined(__APPLE__) && defined(__MACH__)
+#include "tensorflow/core/framework/tensor_shape.pb.h"
+#endif
+
#include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
#include "tensorflow/core/framework/op_kernel.h"
#include "tensorflow/core/framework/register_types.h"
diff --git a/tensorflow/core/kernels/image/adjust_contrast_op_gpu.cu.cc b/tensorflow/core/kernels/image/adjust_contrast_op_gpu.cu.cc
index 147700c1574..eb72c01900e 100644
--- a/tensorflow/core/kernels/image/adjust_contrast_op_gpu.cu.cc
+++ b/tensorflow/core/kernels/image/adjust_contrast_op_gpu.cu.cc
@@ -18,6 +18,10 @@ limitations under the License.
#define EIGEN_USE_GPU
+#if defined(__APPLE__) && defined(__MACH__)
+#include "tensorflow/core/framework/tensor_shape.pb.h"
+#endif
+
#include "tensorflow/core/framework/register_types.h"
#include "tensorflow/core/kernels/image/adjust_contrast_op.h"
diff --git a/tensorflow/core/kernels/image/crop_and_resize_op_gpu.cu.cc b/tensorflow/core/kernels/image/crop_and_resize_op_gpu.cu.cc
index 4fa079b5695..56bd8409a51 100644
--- a/tensorflow/core/kernels/image/crop_and_resize_op_gpu.cu.cc
+++ b/tensorflow/core/kernels/image/crop_and_resize_op_gpu.cu.cc
@@ -19,6 +19,10 @@ limitations under the License.
#define EIGEN_USE_GPU
+#if defined(__APPLE__) && defined(__MACH__)
+#include "tensorflow/core/framework/tensor_shape.pb.h"
+#endif
+
#include "tensorflow/core/framework/register_types.h"
#include "tensorflow/core/framework/tensor_types.h"
#include "tensorflow/core/kernels/image/crop_and_resize_op.h"
diff --git a/tensorflow/core/kernels/image/extract_image_patches_op_gpu.cu.cc b/tensorflow/core/kernels/image/extract_image_patches_op_gpu.cu.cc
index 37b9c9bda32..e7baac72a59 100644
--- a/tensorflow/core/kernels/image/extract_image_patches_op_gpu.cu.cc
+++ b/tensorflow/core/kernels/image/extract_image_patches_op_gpu.cu.cc
@@ -18,6 +18,10 @@ limitations under the License.
#define EIGEN_USE_GPU
+#if defined(__APPLE__) && defined(__MACH__)
+#include "tensorflow/core/framework/tensor_shape.pb.h"
+#endif
+
#include "tensorflow/core/framework/register_types.h"
#include "tensorflow/core/kernels/image/extract_image_patches_op.h"
diff --git a/tensorflow/core/kernels/image/extract_volume_patches_op_gpu.cu.cc b/tensorflow/core/kernels/image/extract_volume_patches_op_gpu.cu.cc
index 379907712a8..24c9951c681 100644
--- a/tensorflow/core/kernels/image/extract_volume_patches_op_gpu.cu.cc
+++ b/tensorflow/core/kernels/image/extract_volume_patches_op_gpu.cu.cc
@@ -17,6 +17,10 @@ limitations under the License.
#define EIGEN_USE_GPU
+#if defined(__APPLE__) && defined(__MACH__)
+#include "tensorflow/core/framework/tensor_shape.pb.h"
+#endif
+
#include "tensorflow/core/framework/register_types.h"
#include "tensorflow/core/kernels/image/extract_volume_patches_op.h"
diff --git a/tensorflow/core/kernels/image/generate_box_proposals_op.cu.cc b/tensorflow/core/kernels/image/generate_box_proposals_op.cu.cc
index a12cd3e6601..49e70e76ff0 100644
--- a/tensorflow/core/kernels/image/generate_box_proposals_op.cu.cc
+++ b/tensorflow/core/kernels/image/generate_box_proposals_op.cu.cc
@@ -19,6 +19,10 @@ limitations under the License.
#include <algorithm>
#include <vector>
+#if defined(__APPLE__) && defined(__MACH__)
+#include "tensorflow/core/framework/tensor_shape.pb.h"
+#endif
+
#include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
#include "tensorflow/core/framework/numeric_types.h"
#include "tensorflow/core/framework/op_kernel.h"
diff --git a/tensorflow/core/kernels/image/resize_nearest_neighbor_op_gpu.cu.cc b/tensorflow/core/kernels/image/resize_nearest_neighbor_op_gpu.cu.cc
index 93fde9131f2..7df7b014a2c 100644
--- a/tensorflow/core/kernels/image/resize_nearest_neighbor_op_gpu.cu.cc
+++ b/tensorflow/core/kernels/image/resize_nearest_neighbor_op_gpu.cu.cc
@@ -19,6 +19,10 @@ limitations under the License.
#include <stdio.h>
+#if defined(__APPLE__) && defined(__MACH__)
+#include "tensorflow/core/framework/tensor_shape.pb.h"
+#endif
+
#include "tensorflow/core/framework/register_types.h"
#include "tensorflow/core/framework/tensor_types.h"
#include "tensorflow/core/kernels/image/resize_nearest_neighbor_op.h"
diff --git a/tensorflow/core/kernels/in_topk_op_gpu.cu.cc b/tensorflow/core/kernels/in_topk_op_gpu.cu.cc
index cd1d3e88b51..19dbec9af65 100644
--- a/tensorflow/core/kernels/in_topk_op_gpu.cu.cc
+++ b/tensorflow/core/kernels/in_topk_op_gpu.cu.cc
@@ -17,6 +17,10 @@ limitations under the License.
#define EIGEN_USE_GPU
+#if defined(__APPLE__) && defined(__MACH__)
+#include "tensorflow/core/framework/tensor_shape.pb.h"
+#endif
+
#include "tensorflow/core/framework/register_types.h"
#include "tensorflow/core/framework/tensor_types.h"
#include "tensorflow/core/kernels/in_topk_op.h"
diff --git a/tensorflow/core/kernels/inplace_ops_functor_gpu.cu.cc b/tensorflow/core/kernels/inplace_ops_functor_gpu.cu.cc
index 8bee7dbee67..a041c97efd6 100644
--- a/tensorflow/core/kernels/inplace_ops_functor_gpu.cu.cc
+++ b/tensorflow/core/kernels/inplace_ops_functor_gpu.cu.cc
@@ -17,6 +17,10 @@ limitations under the License.
#define EIGEN_USE_GPU
+#if defined(__APPLE__) && defined(__MACH__)
+#include "tensorflow/core/framework/tensor_shape.pb.h"
+#endif
+
#include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
#include "tensorflow/core/kernels/inplace_ops_functor.h"
#include "tensorflow/core/util/gpu_kernel_helper.h"
diff --git a/tensorflow/core/kernels/l2loss_op_gpu.cu.cc b/tensorflow/core/kernels/l2loss_op_gpu.cu.cc
index a2c288c36d1..ffe3a5e316e 100644
--- a/tensorflow/core/kernels/l2loss_op_gpu.cu.cc
+++ b/tensorflow/core/kernels/l2loss_op_gpu.cu.cc
@@ -17,6 +17,10 @@ limitations under the License.
#define EIGEN_USE_GPU
+#if defined(__APPLE__) && defined(__MACH__)
+#include "tensorflow/core/framework/tensor_shape.pb.h"
+#endif
+
#include "tensorflow/core/framework/register_types.h"
#include "tensorflow/core/kernels/gpu_prim.h"
#include "tensorflow/core/kernels/l2loss_op.h"
diff --git a/tensorflow/core/kernels/linalg/eye_functor_gpu.cu.cc b/tensorflow/core/kernels/linalg/eye_functor_gpu.cu.cc
index 85865588f2c..cd3358112e2 100644
--- a/tensorflow/core/kernels/linalg/eye_functor_gpu.cu.cc
+++ b/tensorflow/core/kernels/linalg/eye_functor_gpu.cu.cc
@@ -17,6 +17,11 @@ limitations under the License.
#define EIGEN_USE_GPU
+#if defined(__APPLE__) && defined(__MACH__)
+#include "absl/types/span.h"
+#include "tensorflow/core/framework/tensor_shape.pb.h"
+#endif
+
#include "tensorflow/core/framework/register_types.h"
#include "tensorflow/core/framework/tensor_types.h"
#include "tensorflow/core/framework/type_traits.h"
diff --git a/tensorflow/core/kernels/linalg/matrix_band_part_op_gpu.cu.cc b/tensorflow/core/kernels/linalg/matrix_band_part_op_gpu.cu.cc
index 9c734b7fd6e..432cd3e3c77 100644
--- a/tensorflow/core/kernels/linalg/matrix_band_part_op_gpu.cu.cc
+++ b/tensorflow/core/kernels/linalg/matrix_band_part_op_gpu.cu.cc
@@ -19,6 +19,10 @@ limitations under the License.
#include <complex>
+#if defined(__APPLE__) && defined(__MACH__)
+#include "tensorflow/core/framework/tensor_shape.pb.h"
+#endif
+
#include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
#include "tensorflow/core/framework/register_types.h"
#include "tensorflow/core/kernels/linalg/matrix_band_part_op.h"
diff --git a/tensorflow/core/kernels/list_kernels.cu.cc b/tensorflow/core/kernels/list_kernels.cu.cc
index b95a065edb8..2035f57340d 100644
--- a/tensorflow/core/kernels/list_kernels.cu.cc
+++ b/tensorflow/core/kernels/list_kernels.cu.cc
@@ -19,6 +19,10 @@ limitations under the License.
#if GOOGLE_CUDA || TENSORFLOW_USE_ROCM
#define EIGEN_USE_GPU
+#if defined(__APPLE__) && defined(__MACH__)
+#include "tensorflow/core/framework/tensor_shape.pb.h"
+#endif
+
#include "tensorflow/core/kernels/list_kernels.h"
#include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
diff --git a/tensorflow/core/kernels/multinomial_op_gpu.cu.cc b/tensorflow/core/kernels/multinomial_op_gpu.cu.cc
index bc3232170f2..42ec4ba01eb 100644
--- a/tensorflow/core/kernels/multinomial_op_gpu.cu.cc
+++ b/tensorflow/core/kernels/multinomial_op_gpu.cu.cc
@@ -20,6 +20,10 @@ limitations under the License.
#include <assert.h>
#include <stdio.h>
+#if defined(__APPLE__) && defined(__MACH__)
+#include "tensorflow/core/framework/tensor_shape.pb.h"
+#endif
+
#include "tensorflow/core/framework/tensor_types.h"
#include "tensorflow/core/kernels/gpu_prim.h"
#include "tensorflow/core/kernels/multinomial_op.h"
diff --git a/tensorflow/core/kernels/one_hot_op_gpu.cu.cc b/tensorflow/core/kernels/one_hot_op_gpu.cu.cc
index 47af41477c7..2a0d71a4dfb 100644
--- a/tensorflow/core/kernels/one_hot_op_gpu.cu.cc
+++ b/tensorflow/core/kernels/one_hot_op_gpu.cu.cc
@@ -20,6 +20,10 @@ limitations under the License.
#define EIGEN_USE_GPU
+#if defined(__APPLE__) && defined(__MACH__)
+#include "tensorflow/core/framework/tensor_shape.pb.h"
+#endif
+
#include "tensorflow/core/framework/register_types.h"
#include "tensorflow/core/framework/types.h"
#include "tensorflow/core/kernels/one_hot_op.h"
diff --git a/tensorflow/core/kernels/parameterized_truncated_normal_op_gpu.cu.cc b/tensorflow/core/kernels/parameterized_truncated_normal_op_gpu.cu.cc
index af972a1eb5e..3ddc55edec4 100644
--- a/tensorflow/core/kernels/parameterized_truncated_normal_op_gpu.cu.cc
+++ b/tensorflow/core/kernels/parameterized_truncated_normal_op_gpu.cu.cc
@@ -22,6 +22,10 @@ limitations under the License.
#include <cmath>
+#if defined(__APPLE__) && defined(__MACH__)
+#include "tensorflow/core/framework/tensor_shape.pb.h"
+#endif
+
#include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
#include "tensorflow/core/framework/tensor_types.h"
#include "tensorflow/core/kernels/parameterized_truncated_normal_op.h"
diff --git a/tensorflow/core/kernels/population_count_op_gpu.cu.cc b/tensorflow/core/kernels/population_count_op_gpu.cu.cc
index 8165dc769e6..4b4792273a0 100644
--- a/tensorflow/core/kernels/population_count_op_gpu.cu.cc
+++ b/tensorflow/core/kernels/population_count_op_gpu.cu.cc
@@ -18,6 +18,10 @@ limitations under the License.
#define EIGEN_USE_GPU
+#if defined(__APPLE__) && defined(__MACH__)
+#include "tensorflow/core/framework/tensor_shape.pb.h"
+#endif
+
#include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"
#include "tensorflow/core/framework/op_kernel.h"
#include "tensorflow/core/framework/register_types.h"
diff --git a/tensorflow/core/kernels/reduction_ops_gpu_bool.cu.cc b/tensorflow/core/kernels/reduction_ops_gpu_bool.cu.cc
index 89bcf1d7ced..fba746dd4b5 100644
--- a/tensorflow/core/kernels/reduction_ops_gpu_bool.cu.cc
+++ b/tensorflow/core/kernels/reduction_ops_gpu_bool.cu.cc
@@ -17,6 +17,10 @@ limitations under the License.
#define EIGEN_USE_GPU
+#if defined(__APPLE__) && defined(__MACH__)