onnxruntime icon indicating copy to clipboard operation
onnxruntime copied to clipboard

Refine ONNX model path in Nuget CI

Open wschin opened this issue 3 years ago • 4 comments

Fix #12040. This PR removes most of the opset uses in C# test code. The only use of opset now is to workaround a special filename only used in a opset9 test.

if (onnxModelFileName.Contains("opset9") && onnxModelFileName.Contains("LSTM_Seq_lens_unpacked"))
  {
    Console.WriteLine($"Change data folder's pattern for LSTM_Seq_lens_unpacked in opset 9.");
    testDataDirNamePattern = "seq_lens*"; // discrepancy in data directory
}

After this PR, we can expose opset from InferenceSesson and completely remove opset in C# test code; for example,

if (session.GetOpSet("onnx") == 9 && onnxModelFileName.Contains("LSTM_Seq_lens_unpacked"))
  {
    Console.WriteLine($"Change data folder's pattern for LSTM_Seq_lens_unpacked in opset 9.");
    testDataDirNamePattern = "seq_lens*"; // discrepancy in data directory
}

It also adds a new environment variable to define model path to test Nuget packages, so it's more explicit to see where the test models come from.

wschin avatar Jun 30 '22 00:06 wschin

It seems the missing opset from the file path is causing problems: https://aiinfra.visualstudio.com/Lotus/_build/results?buildId=216306&view=logs&j=91a8ea80-f671-5bc1-2729-69581be48524&t=6dd1ca96-d683-54be-88cc-0ee3472572fe

garymm avatar Jun 30 '22 16:06 garymm

My intention was to remove "opset" in whole test code and pass in model folder path as environment variable. The "opset" is only used to display error message...

wschin avatar Jul 01 '22 18:07 wschin

Sure. For this comment, I will do

                    if (onnxModelFileName.Contains("opset9") && onnxModelFileName.Contains("LSTM_Seq_lens_unpacked");
                    {
                        Console.WriteLine($"Change data folder's pattern for LSTM_Seq_lens_unpacked in opset 9.");
                        testDataDirNamePattern = "seq_lens*"; // discrepancy in data directory
                    }

wschin avatar Jul 06 '22 00:07 wschin

Sure. For this comment, I will do

                    if (onnxModelFileName.Contains("opset9") && onnxModelFileName.Contains("LSTM_Seq_lens_unpacked");
                    {
                        Console.WriteLine($"Change data folder's pattern for LSTM_Seq_lens_unpacked in opset 9.");
                        testDataDirNamePattern = "seq_lens*"; // discrepancy in data directory
                    }

or maybe get the two ancestor directories (e.g. with Path.GetDirectoryName) to match more exactly

edgchen1 avatar Jul 06 '22 00:07 edgchen1