willow-ahrens / Finch.jl

Sparse tensors in Julia and more! Datastructure-driven array programing language.
http://willowahrens.io/Finch.jl/
MIT License
159 stars 15 forks source link

Fix empty COO segfault #512

Closed mtsokol closed 5 months ago

mtsokol commented 5 months ago

Fixes #511

willow-ahrens commented 5 months ago

I don't think this function was supposed to create an initialized tensor, and corresponding versions in other levels also will not. This also won't fix the case where we have Dense(SparseCOO(...)), since you would need an array of n ones. I think it might be misleading to try to fix just this one case, so I'd rather close this if you're okay with it.

Zooming out, I'm okay with changing all of the tensor constructors to always initialize tensors, but it is often useful to be able to construct a tensor from it's fields without initializing it, maybe that should be a separate and larger discussion.

mtsokol commented 5 months ago

Thank you for an explanation - now I have the right semantics.