-
Notifications
You must be signed in to change notification settings - Fork 23
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
Alternative solution to representation caching #431
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #431 +/- ##
===========================================
+ Coverage 87.80% 87.87% +0.06%
===========================================
Files 81 81
Lines 6230 6282 +52
===========================================
+ Hits 5470 5520 +50
- Misses 760 762 +2
Continue to review full report in Codecov by Sentry.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beautiful concept, I really like it! Before we lock it in could we keep A,b,c in the init of Bargmann
, and have a separate class method that takes fn, **kwargs
instead? (it's a bit odd to have A,b,c
and (e.g.) cov, means
as arguments of the init)
Opening for discussion
Context: This PR is meant as a proposed alternative to representation caching. By using 'lazy evaluation' in representation/ansatz we can avoid having potentially costly computations just to initialize the representation for calls such as
obj.representation.__class__
.Description of the Change: Ansatz no longer calls backend methods in the init. Instead, the original parameters are stored (
mat
,vec
,array
forPolyExpAnsatz
orarray
forArrayAnsatz
) and backend methods such asastensor
andat_least3d
are only called when the property itself is called (then subsequently stored to avoid repeat calls). In addition to this the representation/ansatz can now also accept a function and some kwargs in substitution of specifying an(A, b, c)
through afrom_generator
class method.Benefits: Based on some initial profiling initializing a representation/ansatz is more efficient.