Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

toNdArray does not support string tensor #7

Open
arkanoid87 opened this issue Nov 28, 2021 · 1 comment
Open

toNdArray does not support string tensor #7

arkanoid87 opened this issue Nov 28, 2021 · 1 comment

Comments

@arkanoid87
Copy link

@[1,2,3,4,5].toTensor.toNdArray # OK

@["a","b","c"].toTensor.toNdArray # KO

Error: type mismatch: got <Tensor[system.string]>
but expected one of:
func toUnsafeView[T: KnownSupportsCopyMem](t: Tensor[T];
    aligned: static bool = true): ptr UncheckedArray[T]
  first type mismatch at position: 1
  required type for t: Tensor[toUnsafeView.T]
  but expression 't' is of type: Tensor[system.string]
proc toUnsafeView[T](ndArray: NumpyArray[T]): ptr UncheckedArray[T]
  first type mismatch at position: 1
  required type for ndArray: NumpyArray[toUnsafeView.T]
  but expression 't' is of type: Tensor[system.string]
@Clonkk
Copy link
Member

Clonkk commented Nov 29, 2021

Indeed, the current implementation focuses on numerical data, char, bool, int*, uint*, float, complex.

Problem with Tensor[string] is that string are gc-allocated in Nim which means the Tensor is not going to be contiguous so you cannot copyMem it - therefore all you can do is loop over the datas - which is not efficient.

Tensor[string] is really just storing string with fancy indexing on top of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants