|
2 | 2 | # distutils: language = c++
|
3 | 3 | # -*- coding: utf-8 -*-
|
4 | 4 | # *****************************************************************************
|
5 |
| -# Copyright (c) 2016-2022, Intel Corporation |
| 5 | +# Copyright (c) 2016-2023, Intel Corporation |
6 | 6 | # All rights reserved.
|
7 | 7 | #
|
8 | 8 | # Redistribution and use in source and binary forms, with or without
|
|
61 | 61 | "asnumpy",
|
62 | 62 | "astype",
|
63 | 63 | "convert_single_elem_array_to_scalar",
|
| 64 | + "default_float_type", |
64 | 65 | "dpnp_queue_initialize",
|
65 | 66 | "dpnp_queue_is_cpu",
|
66 | 67 | "get_dpnp_descriptor",
|
|
69 | 70 | ]
|
70 | 71 |
|
71 | 72 | from dpnp import (
|
72 |
| - isscalar |
| 73 | + isscalar, |
| 74 | + float64 |
73 | 75 | )
|
74 | 76 |
|
75 | 77 | from dpnp.dpnp_iface_arraycreation import *
|
@@ -191,6 +193,35 @@ def convert_single_elem_array_to_scalar(obj, keepdims=False):
|
191 | 193 | return obj
|
192 | 194 |
|
193 | 195 |
|
| 196 | +def default_float_type(device=None, sycl_queue=None): |
| 197 | + """ |
| 198 | + Return a floating type used by default in DPNP depending on device capabilities. |
| 199 | +
|
| 200 | + Parameters |
| 201 | + ---------- |
| 202 | + device : {None, string, SyclDevice, SyclQueue}, optional |
| 203 | + An array API concept of device where an array of default floating type might be created. |
| 204 | + The `device` can be ``None`` (the default), an OneAPI filter selector string, |
| 205 | + an instance of :class:`dpctl.SyclDevice` corresponding to a non-partitioned SYCL device, |
| 206 | + an instance of :class:`dpctl.SyclQueue`, or a `Device` object returned by |
| 207 | + :obj:`dpnp.dpnp_array.dpnp_array.device` property. |
| 208 | + The value ``None`` is interpreted as to use a default device. |
| 209 | + sycl_queue : {None, SyclQueue}, optional |
| 210 | + A SYCL queue which might be used to create an array of default floating type. |
| 211 | + The `sycl_queue` can be ``None`` (the default), which is interpreted as |
| 212 | + to get the SYCL queue from `device` keyword if present or to use a default queue. |
| 213 | +
|
| 214 | + Returns |
| 215 | + ------- |
| 216 | + dt : dtype |
| 217 | + A default DPNP floating type. |
| 218 | +
|
| 219 | + """ |
| 220 | + |
| 221 | + _sycl_queue = get_normalized_queue_device(device=device, sycl_queue=sycl_queue) |
| 222 | + return map_dtype_to_device(float64, _sycl_queue.sycl_device) |
| 223 | + |
| 224 | + |
194 | 225 | def get_dpnp_descriptor(ext_obj,
|
195 | 226 | copy_when_strides=True,
|
196 | 227 | copy_when_nondefault_queue=True,
|
|
0 commit comments