static OrderedTensorType typeFrom(Onnx.TypeProto type) {
        String dimensionPrefix = "d"; // standard naming convention: d0, d1, ...
        Onnx.TensorShapeProto shape = type.getTensorType().getShape();
        var elemType = Onnx.TensorProto.DataType.forNumber(type.getTensorType().getElemType());
        OrderedTensorType.Builder builder = new OrderedTensorType.Builder(toValueType(elemType));
        for (int i = 0; i < shape.getDimCount(); ++ i) {
            String dimensionName = dimensionPrefix + i;
            Onnx.TensorShapeProto.Dimension onnxDimension = shape.getDim(i);
            long onnxDimensionSize = onnxDimension.getDimValue() == 0 ? 1 : onnxDimension.getDimValue();
            if (onnxDimensionSize >= 0) {
                builder.add(TensorType.Dimension.indexed(dimensionName, onnxDimensionSize));
            } else {
                builder.add(TensorType.Dimension.indexed(dimensionName));
            }
        }
        return builder.build();
    }
Converts and verifies ONNX tensor types into Vespa tensor types.

@author lesters
model-integration/src/main/java/ai/vespa/rankingexpression/importer/onnx/TypeConverter.java