raise CompileError in metal if newLibraryWithSource_options_error_ fails (#4695)

This commit is contained in:
chenyu
2024-05-23 12:52:46 -04:00
committed by GitHub
parent 871a3292f4
commit ce46a7e83f
+3 -2
View File
@@ -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: