Refine ONNX model path in Nuget CI
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.
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
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...
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
}
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