import dpctl, dpctl.tensor as dpt
dpctl.__version__
# Out: '0.22.0dev0+114.g0797836be2'
# create a buffer with ones
buf = dpt.ones(24, dtype=np.float64)
# new array points outside the buffer memory:
a = dpt.usm_ndarray((2, 3, 4), strides=(1, 16, 128), dtype=buf.dtype)
a
# Out:
# usm_ndarray([[[0., 0., 0., 0.],
# [0., 0., 0., 0.],
# [0., 0., 0., 0.]],
#
# [[0., 0., 0., 0.],
# [0., 0., 0., 0.],
# [0., 0., 0., 0.]]])
# new array points outside the buffer memory:
a = dpt.usm_ndarray((2, 3, 4), strides=(-1, 1, 1), dtype=buf.dtype)
a
# Out:
# usm_ndarray([[[0., 0., 0., 0.],
# [0., 0., 0., 0.],
# [0., 0., 0., 0.]],
#
# [[0., 0., 0., 0.],
# [0., 0., 0., 0.],
# [0., 0., 0., 0.]]])