From 05ecaefbbfa157ad2d6353ef9b2a53892f7ed34c Mon Sep 17 00:00:00 2001 From: Yuchen Huang Date: Tue, 31 Aug 2021 22:00:11 -0700 Subject: [PATCH] [Metal][GPU] Enable metal for simulators and fix test failures if possible (#64322) 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 | 6 ------ aten/src/ATen/native/metal/mpscnn/tests/MetalOpTestRunner.mm | 8 +++++--- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/aten/src/ATen/native/metal/MetalContext.mm b/aten/src/ATen/native/metal/MetalContext.mm index 80ee55e..f71d35f 100644 --- a/aten/src/ATen/native/metal/MetalContext.mm +++ b/aten/src/ATen/native/metal/MetalContext.mm @@ -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; diff --git a/aten/src/ATen/native/metal/mpscnn/tests/MetalOpTestRunner.mm b/aten/src/ATen/native/metal/mpscnn/tests/MetalOpTestRunner.mm index f337e1d..5e74998 100644 --- a/aten/src/ATen/native/metal/mpscnn/tests/MetalOpTestRunner.mm +++ b/aten/src/ATen/native/metal/mpscnn/tests/MetalOpTestRunner.mm @@ -76,13 +76,15 @@ 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 { -- 2.7.4