r/Compilers • u/ccannedbeansoupp • Oct 06 '26
I'm building a tensor graph compiler
I crossposted from r/Zig here before, but removed it quickly and decided this deserved it's own post. Earlier this year, I began work on representing the forward step for a neural network graph defined by the user as a standalone, optimized binary, with no allocations, shape, or validation checks at runtime and through a series of trials and pivots wound up here.
I wasn't necessarily intending to build a compiler from the start, but the problem quickly became compiler shaped, and I've learned a lot while seeing it through. It's coming to a stage where I'd like to share the work, and get feedback from others. The Zig language made this kind of idea fairly direct and simple for me to implement through its use of comptime. So if it interests you, or anything stands out, comments and questions are welcome.
project here: https://github.com/krypticlogan/zig-graph-compiler
Thanks for the read!
View all comments
Show parent comment
2
u/ccannedbeansoupp Oct 09 '26
Hey u/fernando_quintao, thanks for looking into it. That's interesting, yeah I did start with first-fit for the memory planner, but I switched to best-fit since, based on my understanding it should generally produce better space efficiency with better usage across the span. I wasn't aware of the research or the 'shaving' effect, so thanks for pointing that out. But I figure for this kind of problem, where the intention is that entire memory space is known ahead of time can't it actually be optimal? Plus, the time for allocation doesn't matter *as* much since it gets rolled into compile time and there's nothing actually going on at runtime. Thanks again for the new info, I'll keep looking into it.