move applegpu disassembler

This commit is contained in:
George Hotz 2023-03-05 11:21:12 -08:00
parent e8de3f5736
commit b1ba78ac38
4 changed files with 19 additions and 6 deletions

2
.gitignore vendored
View File

@ -15,4 +15,4 @@ pandecode.dump
vertex.bin
recognize*
.idea
applegpu
disassemblers/applegpu

View File

@ -154,9 +154,9 @@ class TestAST(unittest.TestCase):
buf1 = GPUBuffer(shape=ShapeTracker(shape=(1, 32, 64, 1, 1, 6, 4, 1, 1, 24, 4), views=[View((1, 32, 64, 1, 1, 6, 4, 1, 1, 24, 4), (0, 0, 0, 0, 0, 384, 4, 0, 0, 16, 1), 0)]), hostbuf=GPUBuffer(shape=(6, 96, 4), force_create=True))
op0 = LazyOp(BinaryOps.MUL, (buf0,buf1,), None)
op1 = LazyOp(ReduceOps.SUM, (op0,), (1, 32, 64, 1, 1, 6, 4, 1, 1, 1, 1))
buf2 = GPUBuffer(shape=ShapeTracker(shape=(1, 32, 64, 1, 1, 6, 4, 1, 1, 1, 1), views=[View((1, 32, 64, 1, 1, 6, 4, 1, 1, 1, 1), (0, 0, 0, 0, 0, 4, 1, 0, 0, 0, 0), 0)]), hostbuf=GPUBuffer(shape=(24,), force_create=True))
op2 = LazyOp(BinaryOps.ADD, (op1,buf2,), None)
ast = LazyOp(MovementOps.RESHAPE, (op2,), (32, 384, 4))
#buf2 = GPUBuffer(shape=ShapeTracker(shape=(1, 32, 64, 1, 1, 6, 4, 1, 1, 1, 1), views=[View((1, 32, 64, 1, 1, 6, 4, 1, 1, 1, 1), (0, 0, 0, 0, 0, 4, 1, 0, 0, 0, 0), 0)]), hostbuf=GPUBuffer(shape=(24,), force_create=True))
#op2 = LazyOp(BinaryOps.ADD, (op1,buf2,), None)
ast = LazyOp(MovementOps.RESHAPE, (op1,), (32, 384, 4))
compile_and_test_ast(ast, (6, 4, 8))
def test_full_reduce_op(self):

View File

@ -0,0 +1,13 @@
import unittest
from tinygrad.tensor import Tensor
# similar to test/external/external_test_gpu_ast.py, but universal
# 1x1 6 <- 24
class TestSpecificConv(unittest.TestCase):
def test_1x1_6_24(self):
x = Tensor.randn(1,24*4,32,64)
w = Tensor.randn(6*4,24*4,1,1)
x.conv2d(w).permute(0,2,3,1).reshape(32, 384, 4).contiguous().realize()
if __name__ == '__main__':
unittest.main()

View File

@ -53,8 +53,8 @@ class MetalProgram:
desc.setComputeFunction_(self.fxn)
unwrap(arc.addComputePipelineFunctionsWithDescriptor_error_(desc, None))
unwrap(arc.serializeToURL_error_(Cocoa.NSURL.URLWithString_("file:///tmp/shader.bin"), None))
# clone https://github.com/dougallj/applegpu.git in the root of tinygrad
os.system(f"cd {pathlib.Path(__file__).parent.parent.parent}/applegpu && python3 compiler_explorer.py /tmp/shader.bin")
# clone https://github.com/dougallj/applegpu.git in tinygrad/disassemblers
os.system(f"cd {pathlib.Path(__file__).parent.parent.parent}/disassemblers/applegpu && python3 compiler_explorer.py /tmp/shader.bin")
self.pipeline_state = unwrap(METAL.device.newComputePipelineStateWithFunction_error_(self.fxn, None))
def __call__(self, global_size, local_size, *bufs, wait=False):