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

Matrix broadcasting not working for 1x1 ∘ 1xn / nx1 matrices #803

Open Garic152 opened 3 months ago

Garic152 commented 3 months ago

Description:

When using the broadcast functionality with a 1x1 matrix and an arbitrary 1xn or nx1 matrix, we don't get a broadcasted matrix as a result but a 1x1 matrix which is the operation applied just to the first elements in the matrices.

Example:

  1. Using the broadcast functionality with two matrices:
    X = [1];
    Y = [1, 2, 3](1,);
    print(X + Y);

    Output:

    DenseMatrix(1x1, int64_t)
    2

    Expected Output:

    DenseMatrix(1x3, int64_t)
    2 3 4
corepointer commented 3 months ago

I recently came across the CUDA version of this problem. We just did not consider a 1x1 matrix as this is supposed to be a case for the EwBinaryObjSca kernel. Maybe a cast of that 1x1 to scalar is a quick fix for now?

corepointer commented 3 months ago

Looking at the source code again it seems that we only support having the broadcast input on the right of the binary operation (see src/ir/daphneir/DaphneInferShapeOpInterface.cpp:710). Not changing this behavior for 0.3 anymore.