-
-
Notifications
You must be signed in to change notification settings - Fork 154
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
Base core graph classes on attrs or dataclasses #72
Comments
Q: is it possible to keep treating these classes like data ('fix' the attribs?)? Over time, classes tend to acquire attribute-like methods. |
Thought: ImO, the core graph objects would have to be pretty abstract... no theano-specifics like is_somethingrelatedtoexecution(). |
#37 is related right? attrs has built in mgt for eq. |
Yes, it could be related, but it's likely that we'll need/want custom
It looks like you might be referring to a requirement that we need to implement: i.e. immutability of the core graph classes. That is a motivating factor behind the interest in We can impose some immutability constraints using Symbolic PyMC uses If you look at Both of those metaclasses do things similar to what |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
In line with #37, we should consider basing the core graph objects (e.g.
theano.gof.graph.[Node, Variable, Apply]
,theano.gof.op.[PureOp, Op]
, and all their subclasses) on some form of flexible, (relatively) immutable, easily convertible data type. The packagesattrs
and the newly built-indataclasses
provide much—if not all—of what we need.Specifically, both packages provide automatic recursive conversion into
tuple
s anddict
s and easily configurable defaults for things like equality, ordering,repr
, hashing, etc. Theattrs
goes a little further and can perform automatic input validation and conversion, as well as use__slots__
for a relative performance gain.More importantly, both provide convenient mutation functions (i.e.
dataclasses.replace
andattrs.evolve
) that fit well with the existing object identity model and the pervasive requirement for object cloning. In this setting, graph object mutation could be turned into a considerably easier—and universal—process!The text was updated successfully, but these errors were encountered: