Skip to content

Commit

Permalink
[tensor] avoid usage of SomeSet in toTensor for sets
Browse files Browse the repository at this point in the history
The generic + generic type class leads the compiler to become drunk
and chooses to compile code that really does not belong in there.

We might further want to restrict `T` as well, but I don't want to be
too restrictive for now.
  • Loading branch information
Vindaar committed Jun 16, 2024
1 parent 28b73d7 commit 5b3c84c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/arraymancer/laser/tensor/initialization.nim
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ proc toTensor*[T; U](a: openArray[T], typ: typedesc[U]): Tensor[U] {.inline.} =
else:
toTensor(a).asType(typ)

proc toTensor*[T](a: SomeSet[T]): auto =
proc toTensor*[T](a: HashSet[T] | OrderedSet[T]): Tensor[T] =
## Convert a HashSet or an OrderedSet into a Tensor
##
## Input:
Expand All @@ -288,7 +288,7 @@ proc toTensor*[T](a: SomeSet[T]): auto =
let data = toSeq(a)
result = toTensor(data, shape)

proc toTensor*[T; U](a: SomeSet[T], typ: typedesc[U]): Tensor[U] {.inline.} =
proc toTensor*[T; U](a: HashSet[T] | OrderedSet[T], typ: typedesc[U]): Tensor[U] {.inline.} =
## Convert a HashSet or an OrderedSet into a Tensor of type `typ`
##
## This is a convenience function which given an input `a` is equivalent to
Expand Down

0 comments on commit 5b3c84c

Please sign in to comment.