MCPcopy
hub / github.com/tinygrad/tinygrad / open_lib

Method open_lib

tinygrad/runtime/ops_dsp.py:161–168  ·  view source on GitHub ↗
(self, lib)

Source from the content-addressed store, hash-verified

159 RPCListener(self).start()
160
161 def open_lib(self, lib):
162 self.binded_lib, self.binded_lib_off = lib, 0
163 fp = "file:///tinylib?entry&_modver=1.0&_dom=cdsp\0"
164 pra, _, _, _ = rpc_prep_args(ins=[memoryview(array.array('I', [len(fp), 0xff])), memoryview(bytearray(fp.encode()))],
165 outs=[o1:=memoryview(bytearray(0x8)), o2:=memoryview(bytearray(0xff))])
166 qcom_dsp.FASTRPC_IOCTL_INVOKE(self.rpc_fd, handle=0, sc=rpc_sc(method=0, ins=2, outs=2), pra=pra)
167 if o1.cast('i')[1] < 0: raise RuntimeError(f"Cannot open lib: {o2.tobytes().decode()}")
168 return o1.cast('I')[0]
169
170 def close_lib(self, handle):
171 pra, _, _, _ = rpc_prep_args(ins=[memoryview(array.array('I', [handle, 0xff]))], outs=[memoryview(bytearray(0x8)), memoryview(bytearray(0xff))])

Callers 1

_exec_libMethod · 0.95

Calls 5

rpc_prep_argsFunction · 0.85
rpc_scFunction · 0.85
encodeMethod · 0.45
castMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected