Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

dpctl does not return a zero-length array when no reduction is going to be done #1456

Copy link
Copy link
@antonwolfy

Description

@antonwolfy
Issue body actions

The below example behaves differently between dcptl and numpy:

import numpy, dpctl, dpctl.tensor as dpt

dpctl.__version__
# Out: '0.15.1dev0+63.g03fd73794'

a = numpy.ones((0, 2), dtype='f4')
numpy.min(a, axis=(1,))
# Out: array([], dtype=float32)

b = dpt.ones((0, 2), dtype='f4')
dpt.min(b, axis=(1,))
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[15], line 1
----> 1 dpt.min(b, axis=(1,))

File ~/miniconda3/envs/dpnp_dev/lib/python3.9/site-packages/dpctl/tensor/_reduction.py:499, in min(x, axis, keepdims)
    474 def min(x, axis=None, keepdims=False):
    475     """min(x, axis=None, dtype=None, keepdims=False)
    476
    477     Calculates the minimum value of the input array `x`.
   (...)
    497             array has the same data type as `x`.
    498     """
--> 499     return _comparison_over_axis(x, axis, keepdims, ti._min_over_axis)

File ~/miniconda3/envs/dpnp_dev/lib/python3.9/site-packages/dpctl/tensor/_reduction.py:421, in _comparison_over_axis(x, axis, keepdims, _reduction_fn)
    419 res_usm_type = x.usm_type
    420 if x.size == 0:
--> 421     raise ValueError("reduction does not support zero-size arrays")
    422 if red_nd == 0:
    423     return x

ValueError: reduction does not support zero-size arrays

As I can see python Array API notes the use case as implementation-defined. Should dpctl align the behavior with numpy here?

Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.