-
Notifications
You must be signed in to change notification settings - Fork 16
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
Copying swizzles #609
Comments
I think you can use |
@willow-ahrens Thank you! With using Finch
arr = [0 1 0; 2 3 0]
tns = Tensor(arr)
sw = swizzle(tns, 1, 2)
copyto!(swizzle(Tensor(Dense(SparseList(Element(0)))), 1, 2), sw)
SwizzleArray (1, 2)
└─ 2×3-Tensor
└─ Dense [:,1:3]
├─ [:, 1]: SparseList (0) [1:2]
│ ├─ [1]: 0
│ └─ [2]: 2
├─ [:, 2]: SparseList (0) [1:2]
│ ├─ [1]: 1
│ └─ [2]: 3
└─ [:, 3]: SparseList (0) [1:2]
├─ [1]: 0
└─ [2]: 0 |
I also managed to avoid copying fill-values with
using Finch
arr = [0 1 0; 2 3 0]
tns = Tensor(arr)
sw = swizzle(tns, 1, 2)
dropfills!(swizzle(Tensor(Dense(SparseList(Element(0)))), 2, 1), sw) |
note: I have made a fix so that dropfills works like copyto. However, dropfills will always make a copy. You must still check for the cases where you can zero-copy during asarray. |
Hi @willow-ahrens,
I'm writing with one question regarding
Tensor
andSwizzleArray
.When I want to convert one format to another we have:
Which copies Tensor to the new format (and discards order of unwrapped
tensor
and setsorder
). This requires thatorder
argument matchestensors
's order.I can also pass
tensor
's SwizzleArray that returns a Tensor with default F-major order:I would like a new
copy_swizzle(dest::SwizzleArray, src::SwizzleArray)
function, which returns a SwizzleArray (orTensor(dest::SwizzleArray, src::SwizzleArray)
if it's more coherent).This would allow me to pass CSC tensor and get a CSR array easily:
WDYT?
The text was updated successfully, but these errors were encountered: