Skip to content

_empty_like_pair_orderK in BinaryElementwiseFunc allocates the wrong result shape #1222

Closed
@vlad-perevezentsev

Description

@vlad-perevezentsev

When we pass differently shaped arrays to binary functions with the same size without out parameter, _empty_like_pair_orderK allocates memory for the resulting array using return dpt.empty_like(X1, dtype=dt, usm_type=usm_type...) for F,C contiguous and for strided arrays. This size is wrong if we use broadcasting for the resulting size so we got ValueError: Array shapes are not the same
For example:

>>> import dpctl.tensor as dpt
>>> a = dpt.ones((6,1))
>>> b = dpt.ones((1,6))
>>> dpt.multiply(a,b)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/vperevez/work/dpctl/dpctl/tensor/_elementwise_common.py", line 467, in __call__
    ht_, _ = self.binary_fn_(
ValueError: Array shapes are not the same
#print in BinaryElementwiseFunc 
print('src1', src1.shape)
print('src2', src2.shape)
print('out', out.shape)
print('res_shape', res_shape)

src1 (6, 1)
src2 (1, 6)
out (6, 1)
res_shape (6, 6)

Metadata

Metadata

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