daphne-eu / daphne

DAPHNE: An Open and Extensible System Infrastructure for Integrated Data Analysis Pipelines
Apache License 2.0
67 stars 62 forks source link

Inconsistent results for mod 0 operation #801

Open Garic152 opened 3 months ago

Garic152 commented 3 months ago

Description:

When using the outerMod function on matrices filled with zeros, the result is unexpected large negative values, to be exact the minimum signed 64-bit integer value. We get -nan when doing the same for zero floats. When using mod on two 0 scalars, we get an error message as expected.

Examples:

  1. Using the outerMod function with two matrices filled with zero integers:

    X = [0, 0];
    Y = [0, 0];
    result = outerMod(X, Y);
    print(result);

    Output:

    DenseMatrix(2x2, int64_t)
    -9223372036854775808 -9223372036854775808
    -9223372036854775808 -9223372036854775808
  2. Using the outerMod function with two matrices filled with zero floats:

    X = [0.0, 0.0];
    Y = [0.0, 0.0];
    result = outerMod(X, Y);
    print(result);

    Output:

    DenseMatrix(2x2, int64_t)
    -nan -nan
    -nan -nan
  3. Using the mod functionality with two scalar zeros:

    X = 0;
    Y = 0;
    result = X % Y;
    print(result);

    Output:

    [error]: Lowering pipeline error. CanonicalizerPass (mlir::daphne::EwModOp::fold) failed with the following message [ Can't compute mod 0 ]

To my knowledge, all of these mod usecases should return an error message like in the third example.