Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print uops in more readable format #4510

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ziereis
Copy link
Contributor

@ziereis ziereis commented May 10, 2024

Im currently trying to learn more about tinygrad but reading the uops is more difficult than it should be, so I changed the print function to output in a more readable format, but still keeps the same information. Its not finished yet but is it generally a good idea or is there a deeper reason behind how the upos are printed?

new:

def main(data0 : double*, data1 : const double*, data2 : const double*):
  gidx0 : int # (1, 'gidx0', 128)
  gidx1 : int # (0, 'gidx1', 128)
  acc0 :double = 0.0
  c0 : int = 0
  c1 : int = 128
  alu0 : int = gidx0 * c1
  alu1 : int = alu0 + gidx1
  loop (i0 in c0..c1):
    alu2 : int = alu0 + i0
    ld0 : double = data1[alu2]
    alu3 : int = i0 * c1
    alu4 : int = gidx1 + alu3
    ld1 : double = data2[alu4]
    alu5 : double = ld0 * ld1
    alu6 : double = alu5 + acc0
    phi0 : double = alu6 if i0 else acc0
  endloop:
  data0[alu1] = phi0

old:

   0 UOps.DEFINE_GLOBAL  : ptr.dtypes.double         []                               (0, True)
   1 UOps.DEFINE_GLOBAL  : ptr.dtypes.double         []                               (1, False)
   2 UOps.DEFINE_GLOBAL  : ptr.dtypes.double         []                               (2, False)
   3 UOps.SPECIAL        : dtypes.int                []                               (1, 'gidx0', 128)
   4 UOps.SPECIAL        : dtypes.int                []                               (0, 'gidx1', 128)
   5 UOps.DEFINE_ACC     : dtypes.double             []                               0.0
   6 UOps.CONST          : dtypes.int                []                               0
   7 UOps.CONST          : dtypes.int                []                               128
   8 UOps.ALU            : dtypes.int                [3, 7]                           BinaryOps.MUL
   9 UOps.ALU            : dtypes.int                [8, 4]                           BinaryOps.ADD
  10 UOps.LOOP           : dtypes.int                [6, 7]                           None
  11 UOps.ALU            : dtypes.int                [8, 10]                          BinaryOps.ADD
  12 UOps.LOAD           : dtypes.double             [1, 11]                          None
  13 UOps.ALU            : dtypes.int                [10, 7]                          BinaryOps.MUL
  14 UOps.ALU            : dtypes.int                [4, 13]                          BinaryOps.ADD
  15 UOps.LOAD           : dtypes.double             [2, 14]                          None
  16 UOps.ALU            : dtypes.double             [12, 15]                         BinaryOps.MUL
  17 UOps.ALU            : dtypes.double             [16, 5]                          BinaryOps.ADD
  18 UOps.PHI            : dtypes.double             [5, 17, 10]                      None
  19 UOps.ENDLOOP        :                           [10]                             None
  20 UOps.STORE          :                           [0, 9, 18]                       None

Copy link
Contributor

This branch currently is behind tinygrad/master. The line count difference bot is disabled.

@ziereis ziereis marked this pull request as draft May 10, 2024 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant