Skip to content

[wasm] TensorPrimitives.Tan returns +0.0 for range-reduced Half inputs when Vector128 is accelerated without FMA #135117

Description

@lewing

Description

TensorPrimitives.Tan for Half returns +0.0 for inputs that need range reduction on WebAssembly when Vector128 is hardware accelerated (seen in the CoreCLR WASI composite ReadyToRun lane; the WASI interpreter lane, where Vector128 isn't accelerated, passes).

This lines up with #134914, which rewrote Tan range reduction and added these tests. When neither Fma.IsSupported nor AdvSimd.Arm64.IsSupported, the new path does the non-fused multiply-adds and, if |f| < dn * TanNonFusedReductionThreshold, falls back to ApplyScalar<TanOperatorSingle>(x). WebAssembly has accelerated Vector128 but no FMA, so it's essentially the only configuration that takes this branch (x64 with FMA and Arm64 take the fused path; non-accelerated configurations take the scalar path). Half is widened to float and goes through TanOperator<float>. Only the Half instantiations fail; float/double pass.

cc @tannergooding

[FAIL] System.Numerics.Tensors.Tests.HalfGenericTensorPrimitives.Tan_RangeReduction(length: 2, inputKind: 0)
Expected: -407.25
Actual:    +0.0
[FAIL] System.Numerics.Tensors.Tests.TensorTests.TensorTanPreservesScalarAccuracy(layout: 2, columns: 33)
Expected: -407.25
Actual:    +0.0
[FAIL] System.Numerics.Tensors.Tests.HalfGenericTensorPrimitives.SpanDestinationFunctions_InPlace(... Tan ...)
Assert.All() Failure: 6 out of 257 items in the collection did not pass.
Expected: -0.92969
Actual:    +0.0

34 failures in System.Numerics.Tensors.Tests (Helix jobs e1cac54a-421c-439e-b0cd-8d98aff74c83 and eccd7d69-de48-4cc1-87fd-6036eb264d50, #134813). Tan_RangeReduction, SpanDestinationFunctions_InPlace and TensorTanPreservesScalarAccuracy are disabled via ActiveIssue on wasm with accelerated Vector128 (all element types) in #134813; the right scoping or fix is left to the area owner.

Note

This issue was drafted with GitHub Copilot.

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions