Skip to content

mod is JIT-ed to HLO operator with the semantic of Julia's rem #755

Closed
@giordano

Description

@giordano

The fact that Base.mod and Base.rem both are lowered to the same HLO operator looks very fishy since they have different semantics in Julia.

https://openxla.org/xla/operation_semantics#element-wise_binary_arithmetic_operations

When Op is Rem, the sign of the result is taken from the dividend, and the absolute value of the result is always less than the divisor's absolute value.

This is the semantic of Julia's rem, the opposite of mod. See also https://openxla.org/stablehlo/spec#remainder for more details about the operator.

Originally posted by @giordano in #754 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions