[JVM] Align Java GraphModule Initialization with Python API #17464
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Java API is still using the outdated initialization method for
GraphModule, which has led to issues where the old API no longer works as expected.This PR updates the Java API for
GraphModuleinitialization to match the simplified method used in the Python API.Background
In the Python API,
GraphModulecan be initialized in a more concise way:However, the Java API still uses the older approach:
The old API is not only more verbose (two additional files need to be saved and loaded), but also appears to no longer be functional as expected.
Here is an example of deploying DepthAnything where the ONNX frontend of Relay is used to create the IRModule before compiling and exporting. During deployment, the old initialization method seems no longer works (top: new method, bottom: old method):
To address these, this PR introduces a new initialization method for GraphModule in the Java API, aligning it with the simplified Python API.
Usage Example
Java:
equivalent Python: