[code-reflection] RFR: Model lifetimes of onnx session-related objects more explicitly [v2]
Maurizio Cimadamore
mcimadamore at openjdk.org
Mon Mar 3 14:31:17 UTC 2025
On Mon, 3 Mar 2025 13:10:50 GMT, Adam Pocock <duke at openjdk.org> wrote:
> Releasing the ONNX environment will cause it to crash the next time one is created when certain kinds of sessions are created. It needs to be created at most once per JVM instantiation.
OK - this is not documented anywhere though. Is it a bug in the C impl? I've tested my toy API with an autocloseable environment and I have no problem creating a new environment and disposing it after each new model execution in the MNIST demo (I repeated 10K times). Is there some high-level documentation which explains how these various abstractions are meant to be used?
If environment really has to be global -- that leaves us again with the problem of needed to have a lifetime per session (because a session can create a lot of resources that you don't want to just keep accumulating -- which is fine, but then the API would look more similar to the Python one (e.g. if there's only one environment, then having it implicit seems like a good 80/20 compromise to me).
-------------
PR Comment: https://git.openjdk.org/babylon/pull/332#issuecomment-2694582050
More information about the babylon-dev
mailing list