-
For code management/organization reasons, we started using classes to create HCL models. For simply creating the schedule, building and running the model, it seems to be working fine. For example (using the two_stage example in the documentation), when defined the "normal" way:
I can refer to stage "B" as two_stage.B. And indeed I see attributes 'B' and 'C':
But if we define it in a class like:
I no longer see the 'B' and 'C' attributes. This is true for both two_stage (normal method) and two_stage_static (which should look like a regular function).
Any recommendations/ideas ? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
The following seems to work (note the wrapper for the member function version): A = hcl.placeholder((10,10), "A")
def two_stage(A):
B = hcl.compute(A.shape, lambda x, y: A[x, y] + 1, "B")
C = hcl.compute(A.shape, lambda x, y: B[x, y] + 1, "C")
return C
class testme:
def __init__(self):
pass
def two_stage(self, A):
B = hcl.compute(A.shape, lambda x, y: A[x, y] + 1, "B")
C = hcl.compute(A.shape, lambda x, y: B[x, y] + 1, "C")
return C
@staticmethod
def two_stage_static(A):
B = hcl.compute(A.shape, lambda x, y: A[x, y] + 1, "B")
C = hcl.compute(A.shape, lambda x, y: B[x, y] + 1, "C")
return C
t = testme()
def two_stage_member(*i):
t.two_stage(*i)
s1 = hcl.create_schedule([A], two_stage)
dir(two_stage)
s2 = hcl.create_schedule([A], testme.two_stage_static)
dir(testme.two_stage_static)
s3 = hcl.create_schedule([A], two_stage_member)
dir(t.two_stage) |
Beta Was this translation helpful? Give feedback.
-
The members are associated when |
Beta Was this translation helpful? Give feedback.
The following seems to work (note the wrapper for the member function version):