File: README.md

package info (click to toggle)
dlpack 1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 472 kB
  • sloc: python: 277; ansic: 97; cpp: 64; makefile: 42; sh: 24
file content (23 lines) | stat: -rw-r--r-- 1,103 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Numpy DLPack Array Conversion Example

This example demonstrates how a underlying array memory can be handed off between
two DLPack compatible frameworks without requiring any copies. In this case,
we demonstrate how to convert numpy to TVM's NDArray and vice-versa with proper
memory handling. We hope that not only is this directly useful for TVM users, but
also a solid example for how similar efficient copies can be implemented in other
array frameworks.

## File Breakdown

[dlpack.py](dlpack/dlpack.py): Contains the definition of common DLPack structures shared between frameworks. Mirrors the official C++ definitions.

[from_numpy.py](dlpack/from_numpy.py): Demonstrates how to convert a numpy array into a PyCapsule containing a DLPack Tensor.

[to_numpy.py](dlpack/to_numpy.py): Demonstrates how to take a PyCapsule with a DLPack Tensor and convert it into a numpy array.

[test.py](dlpack/test.py): Shows how to_numpy and from_numpy can be used to convert tensor formats without copies.

## Authors
[Josh Fromm](https://github.com/jwfromm)

[Junru Shao](https://github.com/junrushao1994)