Skip to content

Python API for HOST_ACCESSIBLE OrtValue allocation#28038

Draft
ericcraw wants to merge 1 commit intomicrosoft:mainfrom
ericcraw:python-host-accessible-api
Draft

Python API for HOST_ACCESSIBLE OrtValue allocation#28038
ericcraw wants to merge 1 commit intomicrosoft:mainfrom
ericcraw:python-host-accessible-api

Conversation

@ericcraw
Copy link
Copy Markdown
Contributor

Description

Adds memory_info= parameter to OrtValue.ortvalue_from_shape_and_type(), backed by two new C-level factory methods that look up the registered shared allocator via the full OrtMemoryInfo (including mem_type).

This is required because the current shared allocator query doesn't include the memory type making HOST_ACCESSIBLE invisible to python. UsesCpuMemory() is used in GetPyObjFromTensor so that tensors in HOST_ACCESSIBLE memory are returned as zero-copy numpy views.

Motivation and Context

Enable zero copy interop between numpy and ortvalue.

Adds memory_info= parameter to OrtValue.ortvalue_from_shape_and_type(),
backed by two new C-level factory methods that look up the registered
shared allocator via the full OrtMemoryInfo (including mem_type).

This is required because the current shared allocator query doesn't
include the memory type making HOST_ACCESSIBLE invisible to python.
UsesCpuMemory() is used in GetPyObjFromTensor so that tensors in
HOST_ACCESSIBLE memory are returned as zero-copy numpy views.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant