[Java] CheckpointState AddProperty & GetProperty support #15730
[Java] CheckpointState AddProperty & GetProperty support #15730baijumeswani merged 2 commits intomicrosoft:mainfrom
Conversation
|
/azp run Linux CPU CI Pipeline, Linux CPU Minimal Build E2E CI Pipeline, Linux GPU CI Pipeline, Linux GPU TensorRT CI Pipeline, Linux OpenVINO CI Pipeline, MacOS CI Pipeline, ONNX Runtime Web CI Pipeline, onnxruntime-binary-size-checks-ci-pipeline, Linux QNN CI Pipeline |
|
/azp run Windows CPU CI Pipeline, Windows GPU CI Pipeline, Windows GPU TensorRT CI Pipeline, Windows ARM64 QNN CI Pipeline, orttraining-linux-ci-pipeline, orttraining-linux-gpu-ci-pipeline, orttraining-ortmodule-distributed, ONNX Runtime React Native CI Pipeline |
|
Azure Pipelines successfully started running 9 pipeline(s). |
|
Azure Pipelines successfully started running 8 pipeline(s). |
| Assertions.assertEquals(7, value); | ||
|
|
||
| try { | ||
| String strVal = ckpt.getStringProperty(env.defaultAllocator, propertyName); |
Check notice
Code scanning / CodeQL
Unread local variable
| } | ||
|
|
||
| try { | ||
| float floatVal = ckpt.getFloatProperty(env.defaultAllocator, propertyName); |
Check notice
Code scanning / CodeQL
Unread local variable
| Assertions.assertEquals(3.14f, value); | ||
|
|
||
| try { | ||
| String strVal = ckpt.getStringProperty(env.defaultAllocator, propertyName); |
Check notice
Code scanning / CodeQL
Unread local variable
| } | ||
|
|
||
| try { | ||
| int intVal = ckpt.getIntProperty(env.defaultAllocator, propertyName); |
Check notice
Code scanning / CodeQL
Unread local variable
| Assertions.assertEquals("onnxruntime", value); | ||
|
|
||
| try { | ||
| float floatVal = ckpt.getFloatProperty(env.defaultAllocator, propertyName); |
Check notice
Code scanning / CodeQL
Unread local variable
| } | ||
|
|
||
| try { | ||
| int intVal = ckpt.getIntProperty(env.defaultAllocator, propertyName); |
Check notice
Code scanning / CodeQL
Unread local variable
|
The unused local variables are to trigger exceptions, so they need to stay. Dunno what the Windows CI failures are, they don't look related to my code. |
| * @return The property value. | ||
| * @throws OrtException If the property does not exist, or is of the wrong type. | ||
| */ | ||
| public int getIntProperty(String name) throws OrtException { |
There was a problem hiding this comment.
I kind of struggled with this myself.
I was trying to find a C# data type that resembled C++'s std::variant, but was not able to find one. I ended up using the dynamic type in the end.
We should see if this is something we can revisit later on.
There was a problem hiding this comment.
In Java I can return boxed types and make a single method that returns Object, but it seemed better to have it be typesafe. The boxed types are a bit nasty to work with on the JNI side, and we needed it done quickly.
baijumeswani
left a comment
There was a problem hiding this comment.
Thanks for the prompt help with this pull request Adam. :)
Description
Adds the Java side methods for CheckpointState AddProperty and GetProperty, mirroring #15720. Also ports across the relevant C# tests from #15720.
Motivation and Context
Java side support for the new training APIs.
cc @baijumeswani