Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions backends/apple/metal/runtime/shims/et_metal.mm
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,35 @@
#include <optional>
#include <exception>

#if (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 150000) || \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO this is wrong, because it will require one to have two binaries, one for older and another one for newer SDK

(defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 180000) || \
(defined(__TV_OS_VERSION_MAX_ALLOWED) && __TV_OS_VERSION_MAX_ALLOWED >= 180000) || \
(defined(__WATCH_OS_VERSION_MAX_ALLOWED) && __WATCH_OS_VERSION_MAX_ALLOWED >= 110000)
#define ET_METAL_SDK_HAS_MTL_MATH_COMPILE_OPTIONS 1
#else
#define ET_METAL_SDK_HAS_MTL_MATH_COMPILE_OPTIONS 0
#endif

#if !ET_METAL_SDK_HAS_MTL_MATH_COMPILE_OPTIONS
// When building with an older SDK, declare newer Metal compile option symbols so we can still
// use them behind runtime availability checks.
typedef NS_ENUM(NSInteger, MTLMathMode) {
MTLMathModeSafe = 0,
MTLMathModeRelaxed = 1,
MTLMathModeFast = 2,
};

typedef NS_ENUM(NSInteger, MTLMathFloatingPointFunctions) {
MTLMathFloatingPointFunctionsFast = 0,
MTLMathFloatingPointFunctionsPrecise = 1,
};

@interface MTLCompileOptions ()
@property(readwrite, nonatomic) MTLMathMode mathMode;
@property(readwrite, nonatomic) MTLMathFloatingPointFunctions mathFloatingPointFunctions;
@end
#endif

namespace executorch {
namespace backends {
namespace metal {
Expand Down
Loading