Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing putmask logic for scalar inputs #980

Merged
merged 3 commits into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/cunumeric/index/putmask_template.inl
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ static void putmask_template(TaskContext& context)
{
auto& inputs = context.inputs();
PutmaskArgs args{context.outputs()[0], inputs[1], inputs[2]};
double_dispatch(args.input.dim(), args.input.code(), PutmaskImpl<KIND>{}, args);
int dim = std::max(1, args.input.dim());
double_dispatch(dim, args.input.code(), PutmaskImpl<KIND>{}, args);
}

} // namespace cunumeric
6 changes: 6 additions & 0 deletions tests/integration/test_putmask.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ def test_scalar():
num.putmask(x_num, mask_num, values_num[:1])
assert np.array_equal(x_num, x)

# the case when every input is a scalar
x = num.random.rand(3, 3)
s = x.sum()
num.putmask(s, True, 1.0)
assert s == 1.0


def test_type_convert():
x = mk_seq_array(np, (3, 4, 5))
Expand Down