Skip to content
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

Add support for converting DLTensor for NPU device type #14878

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
9 changes: 9 additions & 0 deletions onnxruntime/core/dlpack/dlpack_converter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ OrtDevice GetOrtDevice(const DLDevice& device) {
case DLDeviceType::kDLCUDA:
case DLDeviceType::kDLROCM:
return OrtDevice(OrtDevice::GPU, OrtDevice::MemType::DEFAULT, static_cast<OrtDevice::DeviceId>(device.device_id));
case DLDeviceType::kDLMAIA:
return OrtDevice(OrtDevice::NPU, OrtDevice::MemType::DEFAULT, static_cast<OrtDevice::DeviceId>(device.device_id));
default:
ORT_THROW("Unsupported device type");
}
Expand Down Expand Up @@ -149,6 +151,10 @@ const char* GetOrtDeviceName(const OrtDevice& device) {
return CPU;
case OrtDevice::GPU:
return CUDA;
case OrtDevice::FPGA:
return "fpga";
case OrtDevice::NPU:
return "npu";
default:
ORT_THROW("Unknown device type: ", device.Type());
}
Expand Down Expand Up @@ -194,6 +200,9 @@ DLDevice GetDlpackDevice(const OrtValue& ort_value, const int64_t& device_id) {
device.device_type = DLDeviceType::kDLCUDA;
#endif
break;
case OrtDevice::FPGA:
case OrtDevice::NPU:
device.device_type = DLDeviceType::kDLMAIA;
default:
ORT_THROW("Cannot pack tensors on this device.");
}
Expand Down
Loading