Skip to content

Using default OnnxSequenceType attribute throws meaningless exception #4120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
eerhardt opened this issue Aug 16, 2019 · 0 comments · Fixed by #4272
Closed

Using default OnnxSequenceType attribute throws meaningless exception #4120

eerhardt opened this issue Aug 16, 2019 · 0 comments · Fixed by #4272
Assignees
Labels
P0 Priority of the issue for triage purpose: IMPORTANT, needs to be fixed right away.

Comments

@eerhardt
Copy link
Member

Pull the code at this commit and run the application - https://github.com/sethjuarez/SeeSharp/tree/b6a7e8a0094b99af05bc72528a2c6e306abbf7cd

The code of interest is:

    public class ImagePrediction
    {
        [ColumnName("classLabel")]
        [VectorType]
        public string[] Prediction;


        [ColumnName("loss")]
        [OnnxSequenceType]
        public List<float> Loss;
    }

You get the following error:

Unhandled Exception: System.ArgumentNullException: Value cannot be null.
   at System.RuntimeType.MakeGenericType(Type[] instantiation)
   at Microsoft.ML.Transforms.Onnx.OnnxSequenceTypeAttribute.Register()
   at Microsoft.ML.Data.SchemaDefinition.Create(Type userType, Direction direction)
   at Microsoft.ML.Data.TypedCursorable`1.Create(IHostEnvironment env, IDataView data, Boolean ignoreMissingColumns, SchemaDefinition schemaDefinition)
   at Microsoft.ML.PredictionEngineBase`2.PredictionEngineCore(IHostEnvironment env, InputRow`1 inputRow, IRowToRowMapper mapper, Boolean ignoreMissingColumns, SchemaDefinition outputSchemaDefinition, Action& disposer, IRowReadableAs`1& outputRow)
   at Microsoft.ML.PredictionEngineBase`2..ctor(IHostEnvironment env, ITransformer transformer, Boolean ignoreMissingColumns, SchemaDefinition inputSchemaDefinition, SchemaDefinition outputSchemaDefinition)
   at Microsoft.ML.PredictionEngineExtensions.CreatePredictionEngine[TSrc,TDst](ITransformer transformer, IHostEnvironment env, Boolean ignoreMissingColumns, SchemaDefinition inputSchemaDefinition, SchemaDefinition outputSchemaDefinition)
   at SeeSharp.Program.LoadModel(String onnxModelFilePath) in /Users/eerhardt/git/SeeSharp/SeeSharp/Program.cs:line 70
   at SeeSharp.Program.Main(String[] args) in /Users/eerhardt/git/SeeSharp/SeeSharp/Program.cs:line 39

It looks like the code here:

public override void Register()
{
var enumerableType = typeof(IEnumerable<>);
var type = enumerableType.MakeGenericType(_elemType);
DataViewTypeManager.Register(new OnnxSequenceType(_elemType), type, new[] { this });
}

Is expecting _elemType to never be null. However, that is exactly what happens when you use the default attribute:

private Type _elemType;
/// <summary>
/// Create a sequence type.
/// </summary>
public OnnxSequenceTypeAttribute()
{
}

I don't think having a default constructor is right with this attribute - you can't use this sequence attribute without specifying an element type.

/cc @wschin

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P0 Priority of the issue for triage purpose: IMPORTANT, needs to be fixed right away.
Projects
None yet
3 participants