Skip to content

metatensor/ctypes-dlpack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ctypes-dlpack

tests status documentation

The DLPack standard allows to share arrays/tensors data between different frameworks. It is defined as a C API, and the standard way to use it from Python is the __dlpack__ protocol defined in the array api, which relies on PyCapsule to pass the pointer around through Python code.

However, there might be times where one does not have a PyCapsule but just a raw pointer to the DLPack C struct. In particular, this might be the case when adding bindings to a C library through ctypes instead of going through a CPython extension module. This library is here to bridge this gap, creating ctypes pointers from the __dlpack__ protocol, and making existing pointers compatible with this protocol.

This library exposes both the C structs/enums/constants from the DLPack C header as ctypes types (containing among other the version of the DLPack library that was used to generate the ctypes declarations), and a Python API to convert between DLPack pointers and Python objects. See the documentation for more details.

You can install the code with pip install ctypes-dlpack.

License and contributions

This project is distributed under the terms of the BSD license, and maintained by @Luthaf, who will reply to issues and pull requests opened on this repository as soon as possible. You can mention them directly if you did not receive an answer after a couple of days.

About

Compatibility layer for dlpack in ctypes

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages