@@ -1518,6 +1518,74 @@ def meshgrid(*arrays, indexing="xy"):
15181518 return output
15191519
15201520
1521+ def ones (
1522+ shape ,
1523+ * ,
1524+ dtype = None ,
1525+ order = "C" ,
1526+ device = None ,
1527+ usm_type = "device" ,
1528+ sycl_queue = None ,
1529+ ):
1530+ """ones(shape, dtype=None, order="C", \
1531+ device=None, usm_type="device", sycl_queue=None)
1532+
1533+ Returns a new :class:`dpctl.tensor.usm_ndarray` having a specified
1534+ shape and filled with ones.
1535+
1536+ Args:
1537+ shape (Tuple[int], int):
1538+ Dimensions of the array to be created.
1539+ dtype (optional):
1540+ data type of the array. Can be typestring,
1541+ a :class:`numpy.dtype` object, :mod:`numpy` char string,
1542+ or a NumPy scalar type. Default: ``None``
1543+ order ("C", or "F"): memory layout for the array. Default: ``"C"``
1544+ device (optional): array API concept of device where the output array
1545+ is created. ``device`` can be ``None``, a oneAPI filter selector
1546+ string, an instance of :class:`dpctl.SyclDevice` corresponding to
1547+ a non-partitioned SYCL device, an instance of
1548+ :class:`dpctl.SyclQueue`, or a :class:`dpctl.tensor.Device` object
1549+ returned by :attr:`dpctl.tensor.usm_ndarray.device`.
1550+ Default: ``None``
1551+ usm_type (``"device"``, ``"shared"``, ``"host"``, optional):
1552+ The type of SYCL USM allocation for the output array.
1553+ Default: ``"device"``
1554+ sycl_queue (:class:`dpctl.SyclQueue`, optional):
1555+ The SYCL queue to use
1556+ for output array allocation and copying. ``sycl_queue`` and
1557+ ``device`` are complementary arguments, i.e. use one or another.
1558+ If both are specified, a :exc:`TypeError` is raised unless both
1559+ imply the same underlying SYCL queue to be used. If both are
1560+ ``None``, a cached queue targeting default-selected device is
1561+ used for allocation and population. Default: ``None``
1562+
1563+ Returns:
1564+ usm_ndarray:
1565+ Created array initialized with ones.
1566+ """
1567+ if not isinstance (order , str ) or len (order ) == 0 or order [0 ] not in "CcFf" :
1568+ raise ValueError (
1569+ "Unrecognized order keyword value, expecting 'F' or 'C'."
1570+ )
1571+ order = order [0 ].upper ()
1572+ dpctl .utils .validate_usm_type (usm_type , allow_none = False )
1573+ sycl_queue = normalize_queue_device (sycl_queue = sycl_queue , device = device )
1574+ dtype = _get_dtype (dtype , sycl_queue )
1575+ res = dpt .usm_ndarray (
1576+ shape ,
1577+ dtype = dtype ,
1578+ buffer = usm_type ,
1579+ order = order ,
1580+ buffer_ctor_kwargs = {"queue" : sycl_queue },
1581+ )
1582+ _manager = dpctl .utils .SequentialOrderManager [sycl_queue ]
1583+ # populating new allocation, no dependent events
1584+ hev , full_ev = ti ._full_usm_ndarray (1 , res , sycl_queue )
1585+ _manager .add_event_pair (hev , full_ev )
1586+ return res
1587+
1588+
15211589def tril (x , / , * , k = 0 ):
15221590 """
15231591 Returns the lower triangular part of a matrix (or a stack of matrices)
0 commit comments