From ce46a7e83ff2457f3c8a6b780ecf55ad2fa4a868 Mon Sep 17 00:00:00 2001 From: chenyu Date: Thu, 23 May 2024 12:52:46 -0400 Subject: [PATCH] raise CompileError in metal if newLibraryWithSource_options_error_ fails (#4695) --- tinygrad/runtime/ops_metal.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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: