[code-reflection] RFR: Model lifetimes of onnx session-related objects more explicitly
Maurizio Cimadamore
mcimadamore at openjdk.org
Mon Mar 3 14:37:04 UTC 2025
On Mon, 3 Mar 2025 13:50:39 GMT, Adam Pocock <duke at openjdk.org> wrote:
> There is an allocator concept too which I've ignored in the Java API but have had several requests to expose (it'll allow things like allocating directly onto the GPU, which is more useful when you can express GPU memory segments, not sure how to do that in the existing JNI based API), that maps more directly onto the arenas and I'd base the API around that if I was writing it today.
I see - I have seen allocators on the C API. I'm not sure those needs to be exposed -- I'd assume these are mostly there to allow e.g. allocating a tensor on the GPU (probably in a transparent fashion). For the Java API, it seems to me that the capabilities exposed by an ORTAllocator can be emulated by using memory segment + arena + reinterpret, and then use the tensor factory that accepts existing data:
https://onnxruntime.ai/docs/api/c/struct_ort_api.html#a2aad3ccd68c66d0b38bdb966467d9324
-------------
PR Comment: https://git.openjdk.org/babylon/pull/332#issuecomment-2694607649
More information about the babylon-dev
mailing list