Closed bhansconnect closed 8 months ago
Would names be maintained if values were modified? Or just when they were copied/moved?
I was thinking only when copied or moved. You would have to rename if you modify.
Two other seeds of ideas that might also solve alleviate problem: 1) Some form of trace mode that could derive automatic naming. The name would just be where the tensor was created originally. So it would point to a location in the source code instead of using a proper text based name. 2) Essentally a debugger: some way to step through code. Simply having that and being able to view the stack or stack shapes as you step through code probably could alleviate most of the pain.
Essentally a debugger: some way to step through code. Simply having that and being able to view the stack or stack shapes as you step through code probably could alleviate most of the pain.
So, the body of the main loop of the bytecode interpreter could probably be factored out to be "resumeable", which could potentially enable this. The question becomes: How do you handle breakpoint setting?
It might be worth a play with the Factor walker to see one approach.
- Some form of trace mode that could derive automatic naming. The name would just be where the tensor was created originally. So it would point to a location in the source code instead of using a proper text based name.
+1 for this one
-1 for text based naming
Here is an example where I struggle and just decided to explicitly name everything on the stack with comments. This is what I am hoping to solve for myself.
almost all the data on the stack at one time is:
The experimental labels, which use the syntax $LabelName
, implement this feature.
Especially when modifying a complex function, it can become easy to mix up stack values. This is made much worse by some functions where most values are the same shape. It can be easy to be left with a stack of values that are too big to print (or even worse, not very meaningful if printed), that are the same shape, and that are accidentally out of order. The only visible symptom is the final output being wrong.
Being able to somehow annotate a stack value with a name that will flow it around as it is moved and duplicated on the stack would be very useful. The name would clear whenever doing any modifying operation (I think that would be most ergonomic). Then a parallel to
dump
could be addeddumpnames
. Not sure on best names, but could theoretically work like this: