Refactor webgpu_dawn lib finding (#9547)

* Refactor webgpu_dawn lib finding

* Fix ruff
This commit is contained in:
Ahmed Harmouche
2025-03-23 13:23:29 +01:00
committed by GitHub
parent c631c72f22
commit 7ce7fe0574
5 changed files with 296 additions and 275 deletions

View File

@@ -373,10 +373,11 @@ generate_sqtt() {
}
generate_webgpu() {
clang2py -l /usr/local/lib/libwebgpu_dawn.so extra/webgpu/webgpu.h -o $BASE/webgpu.py
clang2py extra/webgpu/webgpu.h -o $BASE/webgpu.py
fixup $BASE/webgpu.py
sed -i 's/import ctypes/import ctypes, ctypes.util/g' $BASE/webgpu.py
sed -i "s|ctypes.CDLL('/usr/local/lib/libwebgpu_dawn.so')|ctypes.CDLL(ctypes.util.find_library('webgpu_dawn'))|g" $BASE/webgpu.py
sed -i "s/FIXME_STUB/webgpu/g" "$BASE/webgpu.py"
sed -i "s/FunctionFactoryStub()/ctypes.CDLL(webgpu_support.WEBGPU_PATH)/g" "$BASE/webgpu.py"
sed -i "s/import ctypes/import ctypes, tinygrad.runtime.support.webgpu as webgpu_support/g" "$BASE/webgpu.py"
python3 -c "import tinygrad.runtime.autogen.webgpu"
}