Finch.jl icon indicating copy to clipboard operation
Finch.jl copied to clipboard

Exception when negating a fiber

Open mtsokol opened this issue 1 year ago • 7 comments

Hi @willow-ahrens,

While running different configurations of levels I noticed that for negation I get an exception. Here's a code where I could reproduce it:

using Finch

A = [0.0 0.0 4.4; 1.1 0.0 0.0; 2.2 0.0 5.5; 3.3 0.0 0.0]
A_fbr = Tensor(Dense(Dense(Element(0.0))), A)

-A  # works
-A_fbr # fails
ERROR: Finch.FinchProtocolError("Cannot initialize Element Levels to non-default values (have literal(0.0) expected -0.0)")

Is negation for sparse fibers done differently or is it a bug?

mtsokol avatar Jan 19 '24 14:01 mtsokol

Oh, interesting. Here's my question: Should the fill value of -A be 0.0 or -0.0?

willow-ahrens avatar Jan 19 '24 14:01 willow-ahrens

because

julia> A = [0.0 0.0 4.4; 1.1 0.0 0.0; 2.2 0.0 5.5; 3.3 0.0 0.0]
4×3 Matrix{Float64}:
 0.0  0.0  4.4
 1.1  0.0  0.0
 2.2  0.0  5.5
 3.3  0.0  0.0

julia> -A
4×3 Matrix{Float64}:
 -0.0  -0.0  -4.4
 -1.1  -0.0  -0.0
 -2.2  -0.0  -5.5
 -3.3  -0.0  -0.0

willow-ahrens avatar Jan 19 '24 14:01 willow-ahrens

Somehow, it looks like the fill value isn't getting set correctly.

willow-ahrens avatar Jan 19 '24 14:01 willow-ahrens

Could you work around this for now? I'm completely reorganizing these convenience functions to follow a different codepath (for the @compile macro), so this may magically get fixed in the future.

willow-ahrens avatar Jan 19 '24 14:01 willow-ahrens

Sure! It isn't a blocker for me, just wanted to share.

mtsokol avatar Jan 19 '24 14:01 mtsokol

Thanks for filing the issue! I'll double check that it's fixed once I'm done.

willow-ahrens avatar Jan 19 '24 17:01 willow-ahrens

Mateusz, I think the approach to try to fix this is to remove https://github.com/willow-ahrens/Finch.jl/blob/e6544d80f3da3973614634236cede0c360b0b493/src/symbolic/simplify_program.jl#L73C1-L73C50 and see if anything breaks terribly.

willow-ahrens avatar Mar 07 '24 16:03 willow-ahrens