You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
error in mojograd/utils.mojo:9:45: error: 'DynamicVector' parameter #0 has 'CollectionElement' type, but value has type 'Pointer[Value, 0]'
@staticmethodPointer
fn build_topo(inout ptr_v: Pointer[Value], inout visited: DynamicVector[Pointer[Value]], inout topo: DynamicVector[Pointer[Value]]):
if ptr_v == Pointer[Value].get_null():
return
var is_visited: Bool = False
let size: Int = len(visited)
for i in range(size):
if ptr_v == visited[i]:
is_visited = True
if not is_visited:
visited.push_back(ptr_v)
# Make sure we don't try to access null pointers (e.g. on pow
# where we don't have the right child)
if ptr_v.load().l != Pointer[Int].get_null():
var ptr_l: Pointer[Value] = ptr_v.load().l.bitcast[Value]()
if ptr_l != Pointer[Value].get_null():
Value.build_topo(ptr_l, visited, topo)
if ptr_v.load().r != Pointer[Int].get_null():
var ptr_r: Pointer[Value] = ptr_v.load().r.bitcast[Value]()
if ptr_r != Pointer[Value].get_null():
Value.build_topo(ptr_r, visited, topo)
topo.push_back(ptr_v)
@always_inline
fn backward(inout self):
var visited: DynamicVector[Pointer[Value]] = DynamicVector[Pointer[Value]]()
var topo: DynamicVector[Pointer[Value]] = DynamicVector[Pointer[Value]]()
var ptr_self: Pointer[Value] = Pointer[Value].alloc(1)
ptr_self.store(self)
Value.build_topo(ptr_self, visited, topo)
self.grad.store(1.0)
var reversed: DynamicVector[Pointer[Value]] = reverse(topo)
for i in range(len(reversed)):
Value._backward(reversed[i])
visited.clear()
topo.clear()
reversed.clear()
ptr_self.free()
The text was updated successfully, but these errors were encountered:
Thanks for reporting. I'm finally getting back to development of mojograd. I hope to get it updated to latest Mojo and will check those issues while doing it.
error in mojograd/utils.mojo:9:45: error: 'DynamicVector' parameter #0 has 'CollectionElement' type, but value has type 'Pointer[Value, 0]'
The text was updated successfully, but these errors were encountered: