Skip to content

Commit

Permalink
refinements
Browse files Browse the repository at this point in the history
  • Loading branch information
lehner committed Jul 11, 2024
1 parent 3bace57 commit 15c2451
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/gpt/ad/reverse/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,10 @@ def get_grid(self):
return self.value.grid

def get_otype(self):
return self.value.otype
return self._container.get_otype()

def set_otype(self, v):
self._container.set_otype(v)

def get_real(self):
def getter(y):
Expand All @@ -371,7 +374,7 @@ def setter(y, z):
return self.project(getter, setter)

grid = property(get_grid)
otype = property(get_otype)
otype = property(get_otype, set_otype)
real = property(get_real)


Expand Down
11 changes: 11 additions & 0 deletions lib/gpt/ad/reverse/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,17 @@ def lattice_to_tensor(self):
assert self.tag[0] == g.lattice
return container(g.tensor, self.tag[2])

def get_otype(self):
if len(self.tag) > 1:
return self.tag[-1]
raise Exception("Container does not have an otype")

def set_otype(self, otype):
if len(self.tag) > 1:
self.tag[-1] = otype
else:
raise Exception("Container does not have an otype")

def zero(self):
r = self.representative()
if isinstance(r, g.lattice):
Expand Down

0 comments on commit 15c2451

Please sign in to comment.