Skip to content

Commit 409893d

Browse files
committed
Fixed problem with sequences
1 parent 5329386 commit 409893d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Microsoft.ML.OnnxTransformer/OnnxTypeParser.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,13 @@ private class CastHelper
267267

268268
public static IEnumerable<TDst> CastOnnxSequenceToIEnumerable<TSrc, TDst>(IEnumerable<TSrc> o, Func<TSrc, object> caster)
269269
{
270-
return o.Select(v => (TDst)caster(v));
270+
// Since now we're disposing the NamedOnnxValue objects
271+
// after running inference on each output, we need
272+
// to copy (enumerate) the output through ".ToList()"
273+
// else, if our users try the keep the past sequence
274+
// outputs of their OnnxTransformer, they would
275+
// end up with empty sequences.
276+
return o.Select(v => (TDst)caster(v)).ToList();
271277
}
272278
}
273279

0 commit comments

Comments
 (0)