weld icon indicating copy to clipboard operation
weld copied to clipboard

Cast and literal

Open radujica opened this issue 7 years ago • 2 comments

This produces wrong result on evaluation:

|_inp0: vec[i64]|
map(
    _inp0,
    |a: i64| 
        a < 3L
) {'_inp0': array([0,  1,  2,  3,  4])} []

=> [True False False False False]

However with casting it works:

|_inp0: vec[i64]|
map(
    _inp0,
    |a: i64| 
        a < i64(3L)
) {'_inp0': array([0,  1,  2,  3,  4])} []

=> [True True True False False]

The first Weld code works on length < 4 though.

There was an issue showing there's no vectorization when using casts; well it seems that it's actually broken? Maybe some special case/problem with booleans?

When combined with a filter it does seem to work correctly (pre-optimizations):

|_inp0: vec[i64]| 
let obj101 = (map(
    _inp0,
    |a: i64| 
        a < i64(3L)
));

result(
    for(
        zip(_inp0, obj101),
        appender[i64],
        |b: appender[i64], i: i64, e: {i64, bool}| 
            if (e.$1, 
                merge(b, e.$0), 
                b)
    )
)

=> [0 1 2]

radujica avatar Sep 03 '18 12:09 radujica

Hey Radu, is this using the new or old backend?

Shoumik

On Mon, Sep 3, 2018 at 5:52 AM Radu [email protected] wrote:

This produces wrong result on evaluation:

|_inp0: vec[i64]| map( _inp0, |a: i64| a < 3L ) {'_inp0': array([0, 1, 2, 3, 4])} []

=> [True False False False False]

However with casting it works:

|_inp0: vec[i64]| map( _inp0, |a: i64| a < i64(3L) ) {'_inp0': array([0, 1, 2, 3, 4])} []

=> [True True True False False]

The first Weld code works on length < 4 though.

There was an issue showing there's no vectorization when using casts; well it seems that it's actually broken? Maybe some special case/problem with booleans?

When combined with a filter it does seem to work correctly (pre-optimizations):

|_inp0: vec[i64]| let obj101 = (map( _inp0, |a: i64| a < i64(3L) ));

result( for( zip(_inp0, obj101), appender[i64], |b: appender[i64], i: i64, e: {i64, bool}| if (e.$1, merge(b, e.$0), b) ) )

=> [0 1 2]

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/weld-project/weld/issues/389, or mute the thread https://github.com/notifications/unsubscribe-auth/ABTCY6cNuunZGm5YGttUoXIUm531ZBAwks5uXSYfgaJpZM4WXkT5 .

-- Shoumik

sppalkia avatar Sep 03 '18 15:09 sppalkia

Just re-built both latest master and llvm-st and both have the same output with/out casting.

radujica avatar Sep 03 '18 16:09 radujica