Description
Issue
We need a test for OnnxTransform that uses variable length vectors as input.
Details
The OnnxTransform does not allow for input that is of variable length vector type, however variable length vectors are supported in ONNX. This check could be removed if we have tests that use a model that has a variable length vector.
I initially tried via sci-kit learn to create an onnx model using the CountVectorizer which would result in variable length vectors, however loading this model in ml.net failed due to missing string support.
Next attempt is to create a simple ONNX model using argmax and have it take multiple inputs, script is here for reference:
import onnx
from onnx import helper
from onnx import AttributeProto, TensorProto, GraphProto
height=1
width=1
isize = height * width
input = helper.make_tensor_value_info('input', TensorProto.FLOAT , [-1, -1])
argmax = helper.make_tensor_value_info('argmax', TensorProto.INT64, [-1])
nodea = helper.make_node(
'ArgMax', # node name
['input'], # inputs
['argmax'], # outputs
axis = 1,
keepdims = 0
)
# Create the graph (GraphProto)
graph_def = helper.make_graph(
[nodea],
'argmax',
[input],
[argmax]
)
# Create the model (ModelProto)
model_def = helper.make_model(graph_def, producer_name='AIInfra')
#
#print('The model is:\n{}'.format(model_def))
onnx.save(model_def, 'test_unknowndimensions_float.onnx')
If this does work, we will need to add the ONNX model to https://github.com/dotnet/machinelearning-testdata
As this generates the nuget file that contains our onnx test models.
CC @jignparm