'Using optional inputs with java onnxruntime 1.10.0

It looks like recently ONNX introduced optional input parameters that can be processed inside the model.

In python, the model input data can be specified like this and it works as expected

test_input_data = {'optional_input': np.array([1], dtype='int32')}
test_input_data = {'optional_input': None}

However, when I switched to java, it seems like there is no way to create an OnnxTensor based on a null value.

OnnxTensor interface: https://javadoc.io/static/com.microsoft.onnxruntime/onnxruntime/1.10.0/ai/onnxruntime/OnnxTensor.html#createTensor(ai.onnxruntime.OrtEnvironment,java.lang.Object)

OrtSeesion interface: https://javadoc.io/static/com.microsoft.onnxruntime/onnxruntime/1.10.0/ai/onnxruntime/OrtSession.html#run(java.util.Map)

Does anyone know how I can pass a null input parameter to the onnx model in java?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source