Skip to content

dpnp.erf function does not support compute follows data #1192

@diptorupd

Description

@diptorupd

The dpnp black_scholes implementation throws an exception and fails to execute:

Traceback (most recent call last):
  File "/dpbench/dpbench/infrastructure/benchmark.py", line 379, in _exec
    warmup(self.impl_fn, inputs)
  File "/dpbench/dpbench/infrastructure/timeout_decorator.py", line 65, in inner
    result = fn(*args, **kwargs)
  File "/dpbench/dpbench/infrastructure/benchmark.py", line 375, in warmup
    self.fmwrk.execute(impl_fn, inputs)
  File "/dpbench/dpbench/infrastructure/framework.py", line 123, in execute
    return impl_fn(**input_args)
  File "/dpbench/dpbench/benchmarks/black_scholes/black_scholes_dpnp.py", line 28, in black_scholes
    d1 = 0.5 + 0.5 * np.erf(w1)
  File "/.conda/envs/dpbench-devel/lib/python3.9/site-packages/dpnp/dpnp_iface_libmath.py", line 80, in erf
    x1_desc = dpnp.get_dpnp_descriptor(in_array1, copy_when_strides=False)
  File "/.conda/envs/dpbench-devel/lib/python3.9/site-packages/dpnp/dpnp_iface.py", line 234, in get_dpnp_descriptor
    ext_obj = array(arr_obj, sycl_queue=default_queue)
  File "/.conda/envs/dpbench-devel/lib/python3.9/site-packages/dpnp/dpnp_iface_arraycreation.py", line 217, in array
    return dpnp_container.asarray(x1,
  File "/.conda/envs/dpbench-devel/lib/python3.9/site-packages/dpnp/dpnp_container.py", line 81, in asarray
    array_obj = dpt.asarray(x1_obj,
  File "/.conda/envs/dpbench-devel/lib/python3.9/site-packages/dpctl/tensor/_ctors.py", line 328, in asarray
    return _asarray_from_usm_ndarray(
  File "/.conda/envs/dpbench-devel/lib/python3.9/site-packages/dpctl/tensor/_ctors.py", line 188, in _asarray_from_usm_ndarray
    res[(slice(None, None, None),) * res.ndim] = usm_ndary
  File "dpctl/tensor/_usmarray.pyx", line 921, in dpctl.tensor._usmarray.usm_ndarray.__setitem__
  File "/.conda/envs/dpbench-devel/lib/python3.9/site-packages/dpctl/tensor/_copy_utils.py", line 199, in _copy_from_usm_ndarray_to_usm_ndarray
    _copy_same_shape(dst, src)
  File "/.conda/envs/dpbench-devel/lib/python3.9/site-packages/dpctl/tensor/_copy_utils.py", line 169, in _copy_same_shape
    hev, ev = ti._copy_usm_ndarray_into_usm_ndarray(
ValueError: Execution queue context is not the same as allocation contexts

On investigating, I found that the dpnp implementation of erf does not yet support the compute follows data programming mode. Here is a reproducer:

>>> import dpnp
>>> 
>>> 
>>> 
>>> a = dpnp.ones(100)
>>> b = dpnp.erf(a)
>>> a.sycl_queue
<dpctl.SyclQueue at 0x7f537d3fbc40>
>>> b.sycl_queue
<dpctl.SyclQueue at 0x7f53b21f0f00>
>>> a.sycl_queue == b.sycl_queue
False

It is expected that the output of erf should be on the same queue as the input array. But, that is not the case.

Metadata

Metadata

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