MCPcopy
hub / github.com/tinygrad/tinygrad / __init__

Method __init__

tinygrad/runtime/ops_cl.py:41–48  ·  view source on GitHub ↗
(self, device:CLDevice, name:str, lib:bytes, arg_dtypes=[], **kwargs)

Source from the content-addressed store, hash-verified

39
40class CLProgram:
41 def __init__(self, device:CLDevice, name:str, lib:bytes, arg_dtypes=[], **kwargs):
42 self.dev, self.name, self.lib, self.arg_dtypes = device, name, device.cl_compiler.compile_cached(lib.decode()), arg_dtypes
43 self.program = checked(cl.clCreateProgramWithBinary(device.context, 1, device.device_id, (ctypes.c_size_t * 1)(len(self.lib)),
44 to_char_p_p([self.lib], ctypes.c_ubyte), binary_status := ctypes.c_int32(),
45 errcode_ret := ctypes.c_int32()), errcode_ret)
46 check(binary_status.value)
47 check(cl.clBuildProgram(self.program, 1, device.device_id, None, BP_CB(), None)) # NOTE: OSX requires this
48 self.kernel = checked(cl.clCreateKernel(self.program, name.encode(), status := ctypes.c_int32()), status)
49
50 def __del__(self):
51 try: check(cl.clReleaseKernel(self.kernel))

Callers

nothing calls this directly

Calls 6

to_char_p_pFunction · 0.90
compile_cachedMethod · 0.80
checkedFunction · 0.70
checkFunction · 0.70
decodeMethod · 0.45
encodeMethod · 0.45

Tested by

no test coverage detected