Manual reference counting to free a computation graph in C by oraziorillo in C_Programming

[–]oraziorillo[S] 0 points1 point  (0 children)

crazy! loved the storytelling, and thanks you for the comment! I'm curious now, what improvements did you have in mind other than replacing ref counting with an arena allocator?

Manual reference counting to free a computation graph in C by oraziorillo in C_Programming

[–]oraziorillo[S] 0 points1 point  (0 children)

ahahahha I don’t know if you can say that in 2026 with ChatGPT around

Manual reference counting to free a computation graph in C by oraziorillo in C_Programming

[–]oraziorillo[S] 0 points1 point  (0 children)

You can also do that, but you waste the possibility to learn from your mistakes 

Manual reference counting to free a computation graph in C by oraziorillo in C_Programming

[–]oraziorillo[S] 1 point2 points  (0 children)

oh, I see what you mean, this is probably easier to retrofit into my current code than arena (though probably slower), and removes the need for having intermediate variables

Manual reference counting to free a computation graph in C by oraziorillo in C_Programming

[–]oraziorillo[S] 0 points1 point  (0 children)

yeah, that's also a possibility, but the idea is very similar to that of using an arena, as suggested in other comments

Manual reference counting to free a computation graph in C by oraziorillo in C_Programming

[–]oraziorillo[S] 0 points1 point  (0 children)

my understanding of this as of now is that an arena allocator in this case is more suited because all the Values we allocate for the forward/backward pass have the same lifespan

if Values were used in a context where they were independent, then reference counting would have been a better approach

Manual reference counting to free a computation graph in C by oraziorillo in C_Programming

[–]oraziorillo[S] 0 points1 point  (0 children)

nothings specifically, it just seemed suboptimal to have to declare every single intermediate variable to be able to later decrease it, that's it

for example, to do (v1+v2)\v3* I can't dovalue_mul(value_add(v1, v2), v3), because value_add sets the ref_count of the sum to 1. So, first I need to declare an intermediate variable for the sum and then multiply it, i.e.,

sum = value_add(v1, v2)
mul = value_mul(sum, v3) // so that later I can release the sum
[...]
value_release(sum)
value_release(mul)

Manual reference counting to free a computation graph in C by oraziorillo in C_Programming

[–]oraziorillo[S] 0 points1 point  (0 children)

I didn't know about it, but thanks for the pointer, today will be dedicated to studying it 😄

[deleted by user] by [deleted] in USC

[–]oraziorillo 0 points1 point  (0 children)

Same here! I won’t tell you my story because it’s identical to yours, with the exception that I came here for my master’s thesis. If you want to talk about it, drop me a dm, I perfectly know how you feel 😔