Skip to content

Feature/dlpack #682

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Dec 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ per-file-ignores =
dpctl/memory/_memory.pyx: E999, E225, E226, E227
dpctl/program/_program.pyx: E999, E225, E226, E227
dpctl/tensor/_usmarray.pyx: E999, E225, E226, E227
dpctl/tensor/_dlpack.pyx: E999, E225, E226, E227
dpctl/tensor/numpy_usm_shared.py: F821
dpctl/tests/_cython_api.pyx: E999, E225, E227, E402
dpctl/utils/_compute_follows_data.pyx: E999, E225, E227
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added
- `dpctl.tensor.asarray`, `dpctl.tensor.empty` implemented (#646).
- `dpctl.tensor.usm_ndarray` adds support for DLPack protocol. `dpctl.tensor.from_dlpack` implemented (#682).

### Changed
- dpctl-capi is now renamed to `libsyclinterface` (#666).
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
include versioneer.py
recursive-include dpctl/include *.h
recursive-include dpctl/tensor/include *
recursive-include dpctl *.pxd
include dpctl/_sycl_context.h
include dpctl/_sycl_context_api.h
Expand Down
2 changes: 2 additions & 0 deletions dpctl/tensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
from dpctl.tensor._copy_utils import copy_to_numpy as asnumpy
from dpctl.tensor._copy_utils import copy_to_numpy as to_numpy
from dpctl.tensor._ctors import asarray, empty
from dpctl.tensor._dlpack import from_dlpack
from dpctl.tensor._reshape import reshape
from dpctl.tensor._usmarray import usm_ndarray

Expand All @@ -47,4 +48,5 @@
"from_numpy",
"to_numpy",
"asnumpy",
"from_dlpack",
]
41 changes: 41 additions & 0 deletions dpctl/tensor/_dlpack.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Data Parallel Control (dpctl)
#
# Copyright 2020-2021 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# distutils: language = c++
# cython: language_level=3
# cython: linetrace=True

from ._usmarray cimport usm_ndarray


cdef extern from './include/dlpack/dlpack.h' nogil:
int device_CPU 'kDLCPU'
int device_oneAPI 'kDLOneAPI'
int device_OpenCL 'kDLOpenCL'


cpdef object to_dlpack_capsule(usm_ndarray array) except +
cpdef usm_ndarray from_dlpack_capsule(object dltensor) except +

cpdef from_dlpack(array)

cdef class DLPackCreationError(Exception):
"""
A DLPackCreateError exception is raised when constructing
DLPack capsule from `usm_ndarray` based on a USM allocation
on a partitioned SYCL device.
"""
pass
Loading