Fix CUDA output tensor for metric learning model - #94
Conversation
…ceModel IoBinding
| [[nodiscard]] std::vector<Ort::Value> runInference(const T& inputData, bool runOnCuda = false, | ||
| std::size_t cudaDeviceIndex = 0); |
There was a problem hiding this comment.
Sorry, this is rather late in the whole process. Could we tie runOnCuda to the cudaDeviceIndex, e.g. by using a negative index as a false-y value for that? Or do other inference wrappers generally also do a flag and an index?
There was a problem hiding this comment.
No, we can do that! I checked again how this is done in ACTS.
In ACTS the device is just picked up from e.g. the tensor argument tensor.device (device.type, device.index, etc.)
Maybe something similar would work here, for example passing a device as single argument to runInference: this would require includes from ACTS in ONNXInferenceModel or overloading the method, e.g. like
std::vector<Ort::Value> ONNXInferenceModel::runInference(const T& inputData, const DeviceT& device) {
return runInference(inputData, device.isCuda(), static_cast<std::size_t>(device.index));
}
Or instead a combination (cudaDeviceIndex as int, where <0 means CPU):
std::vector<Ort::Value> ONNXInferenceModel::runInference(const T& inputData, const DeviceT& device) {
const int cudaDeviceIndex = device.isCuda() ? static_cast<int>(device.index) : -1;
return runInference(inputData, cudaDeviceIndex);
}
Let me know what you think.
There was a problem hiding this comment.
I think at least for now, we could just include the ACTS header in the ONNXInferenceModel. That would make the whole inference a bit harder to lift out of here, but in the end, that should be a fairly small dependency to remove if we ever get to a more generic solution.
tmadlener
left a comment
There was a problem hiding this comment.
The formatting that pre-commit complains about is pre-existing (due to the switch to LLVM 22 for the nightlies stack). (see e.g. #96)
@jmcarcell is there anything we can do to the .clang-format to retain the LLVM 20 behavior? Otherwise we will have quite some formatting in the next few days / weeks.
BEGINRELEASENOTES
ENDRELEASENOTES