Skip to content

Commit

Permalink
Update seq_tensor.nim
Browse files Browse the repository at this point in the history
a rank proc was required but missing when I tried running the simple test.
  • Loading branch information
quimt authored Feb 16, 2024
1 parent eee6352 commit f416341
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/datamancer/seq_tensor.nim
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ proc toSeq1D*[T](x: Tensor[T]): seq[T] =
result[i] = el
proc clone*[T](t: Tensor[T]): Tensor[T] = t
proc size*[T](t: Tensor[T]): int = t.len
proc rank*[T](t: Tensor[T]): int =
result = 1
var tchild: T ## we need to work with a concrete var since T is a typedesc, and can't use t[0] because tensor may not have any concrete elements
when T is Tensor:
result = 1 + rank(tchild)

proc astype*[T; U](t: Tensor[T], dtype: typedesc[U]): Tensor[U] = t.mapIt(it.dtype)
proc map*[T; U](t: Tensor[T], fn: proc(x: T): U): Tensor[U] = t.mapIt(fn(it))
template map_inline*(t: untyped, body: untyped): untyped =
Expand Down

0 comments on commit f416341

Please sign in to comment.