Shadowrocket-ADBlock-Rules icon indicating copy to clipboard operation
Shadowrocket-ADBlock-Rules copied to clipboard

Error handling

Open go-dockly opened this issue 4 years ago • 1 comments

Hey Guys, I saw that there are 227 uses of panic in 87 files and I do understand your motivation behind it. Go's implicit error returns stand in the way of function chaining youd like to achieve eg gx := r.x1.Value().(*mat.Dense).MulT(gy) Let's assume MulT can panic inside the backward scope but that panic should recover in eg the graph wrapper scope This should explain bit better what I mean What are your thoughts on this?

go-dockly avatar Dec 15 '20 14:12 go-dockly

I actually think there's a lot of room for improvement on that front! However, I wonder how to recover an error in case of a size mismatch, for example.

If I understand you correctly, you want to recover the panics generated inside the auto-grad functions (and in turn by mathematical functions) at the ag.Graph level.

Would you like to try to write some pseudo-code below for the solution you have in mind?

matteo-grella avatar Dec 20 '20 23:12 matteo-grella