From f416341547cbe48a25bcf515cfdcaa3ccb685ecf Mon Sep 17 00:00:00 2001 From: quimt <126020181+quimt@users.noreply.github.com> Date: Thu, 15 Feb 2024 19:37:04 -0500 Subject: [PATCH] Update seq_tensor.nim a rank proc was required but missing when I tried running the simple test. --- src/datamancer/seq_tensor.nim | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/datamancer/seq_tensor.nim b/src/datamancer/seq_tensor.nim index 0dbd74a..711331a 100644 --- a/src/datamancer/seq_tensor.nim +++ b/src/datamancer/seq_tensor.nim @@ -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 =