diff --git a/tinygrad/runtime/ops_metal.py b/tinygrad/runtime/ops_metal.py index c7702b86cc..b749199778 100644 --- a/tinygrad/runtime/ops_metal.py +++ b/tinygrad/runtime/ops_metal.py @@ -3,7 +3,7 @@ import os, subprocess, pathlib, ctypes, tempfile, functools import Metal, libdispatch from typing import List, Set, Any, Tuple, Optional from tinygrad.helpers import prod, getenv, DEBUG, unwrap2 -from tinygrad.device import Compiled, Compiler, LRUAllocator +from tinygrad.device import Compiled, Compiler, CompileError, LRUAllocator from tinygrad.renderer.cstyle import MetalRenderer def wait_check(cbuf: Any): @@ -23,7 +23,8 @@ class MetalCompiler(Compiler): else: options = Metal.MTLCompileOptions.new() options.setFastMathEnabled_(getenv("METAL_FAST_MATH")) - library = unwrap2(self.device.device.newLibraryWithSource_options_error_(src, options, None)) + try: library = unwrap2(self.device.device.newLibraryWithSource_options_error_(src, options, None)) + except AssertionError as e: raise CompileError(e) return library.libraryDataContents().bytes().tobytes() class MetalProgram: