[Metal][GPU] Enable metal for simulators and fix test failures if possible (#64322)
authorYuchen Huang <hyc@fb.com>
Wed, 1 Sep 2021 05:00:11 +0000 (22:00 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Wed, 1 Sep 2021 05:36:09 +0000 (22:36 -0700)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/64322

As title
ghstack-source-id: 137143877

Test Plan:
- `aibench-cli mobile`
- Select iOS -> `y` -> `1` -> `n` -> "--metal_op_test"
- Select all iPhone 6 + iPhone 7 + iPhone 8 and a iPhone X or 11 or 12
```
Benchmark Submitted. Find more details at: https://our.intern.facebook.com/intern/aibench/details/318120612514604
Benchmark Status:
        D10 (https://github.com/pytorch/pytorch/commit/b8256280ce45f02a7e105d3b3db4a547990e683d)AP-12.0.1: DONE
        N71mAP-14.3: DONE
DUMMY latency:
        D10 (https://github.com/pytorch/pytorch/commit/b8256280ce45f02a7e105d3b3db4a547990e683d)AP-12.0.1: 4319.3
        N71mAP-14.3: 8868.51
I0831 16:06:27.210558 605277 ClientSingletonManager.cpp:99] Shutting down Manifold ClientSingletonManager
```

Reviewed By: xta0

Differential Revision: D30147163

fbshipit-source-id: 2de6bbd9bd525e32ca92b2845eb435800855edcc

aten/src/ATen/native/metal/MetalContext.mm
aten/src/ATen/native/metal/mpscnn/tests/MetalOpTestRunner.mm

index 80ee55e..f71d35f 100644 (file)
@@ -37,9 +37,6 @@ using namespace at::native::metal;
 - (BOOL)available {
 #if !defined(__APPLE__)
   return false;
-#elif TARGET_IPHONE_SIMULATOR
-  // TODO[T90135707]: Enable Metal on iOS Simulators
-  return false;
 #elif TARGET_OS_IPHONE
   if (!MPSSupportsMTLDevice(_device)) {
     return false;
@@ -47,9 +44,6 @@ using namespace at::native::metal;
   if ([UIDevice currentDevice].systemVersion.floatValue < 11.0) {
     return false;
   }
-  if (![_device supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily3_v2]) {
-    return false;
-  }
 #elif TARGET_OS_MAC
   if (!MPSSupportsMTLDevice(_device)) {
     return false;
index f337e1d..5e74998 100644 (file)
   REG_TEST("test_hardtanh_", test_hardtanh_);
   REG_TEST("test_hardtanh", test_hardtanh);
   REG_TEST("test_reshape", test_reshape);
+  REG_TEST("test_chunk", test_chunk);
+  REG_TEST("test_chunk3", test_chunk3);
+  REG_TEST("test_reflection_pad2d", test_reflection_pad2d);
+#if !TARGET_IPHONE_SIMULATOR
   REG_TEST("test_mean_dim", test_mean_dim);
   REG_TEST("test_mean_dim2", test_mean_dim2);
   REG_TEST("test_mean_dim3", test_mean_dim3);
-  REG_TEST("test_chunk", test_chunk);
   REG_TEST("test_chunk2", test_chunk2);
-  REG_TEST("test_chunk3", test_chunk3);
-  REG_TEST("test_reflection_pad2d", test_reflection_pad2d);
+#endif
 }
 
 - (NSDictionary*)tests {