Skip to content

Commit 09ccd47

Browse files
committed
review feedback
1 parent f98ca7d commit 09ccd47

File tree

6 files changed

+74
-35
lines changed

6 files changed

+74
-35
lines changed

csharp/src/Microsoft.ML.OnnxRuntime/NativeMethods.shared.cs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -929,17 +929,25 @@ private static IntPtr DllImportResolver(string libraryName, Assembly assembly, D
929929
string assemblyDir = System.IO.Path.GetDirectoryName(assemblyLocation);
930930
string rid = RuntimeInformation.RuntimeIdentifier;
931931

932-
// We no longer support osx-x64 after 1.24
933-
string[] ridsToTry = { rid, "win-x64", "win-arm64", "linux-x64", "linux-arm64", "osx-arm64"};
932+
// Probe the specific RID first, then common fallbacks for the current OS
933+
string[] ridsToTry;
934+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
935+
ridsToTry = new[] { rid, "win-x64", "win-arm64" };
936+
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
937+
ridsToTry = new[] { rid, "linux-x64", "linux-arm64" };
938+
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
939+
// We no longer provide osx-x64 in official package since 1.24.
940+
// However, we keep it in the list for build-from-source users.
941+
ridsToTry = new[] { rid, "osx-arm64", "osx-x64" };
942+
else
943+
ridsToTry = new[] { rid };
944+
934945
foreach (var tryRid in ridsToTry)
935946
{
936947
string probePath = System.IO.Path.Combine(assemblyDir, "runtimes", tryRid, "native", mappedName);
937-
if (System.IO.File.Exists(probePath))
948+
if (System.IO.File.Exists(probePath) && NativeLibrary.TryLoad(probePath, assembly, searchPath, out handle))
938949
{
939-
if (NativeLibrary.TryLoad(probePath, assembly, searchPath, out handle))
940-
{
941-
return handle;
942-
}
950+
return handle;
943951
}
944952
}
945953
}
@@ -962,7 +970,9 @@ private static IntPtr DllImportResolver(string libraryName, Assembly assembly, D
962970
}
963971
}
964972

973+
#if DEBUG
965974
System.Console.WriteLine($"[DllImportResolver] Failed loading {mappedName} (RID: {RuntimeInformation.RuntimeIdentifier}, Assembly: {assemblyLocation})");
975+
#endif
966976
}
967977
}
968978

csharp/test/Microsoft.ML.OnnxRuntime.Tests.NetCoreApp/InferenceTest.netcore.cs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,29 @@ private static Dictionary<string, string> GetSkippedModels(DirectoryInfo modelsD
601601
skipModels["VGG 16-fp32"] = "bad allocation";
602602
}
603603

604+
// The following models are from onnx repo and fail on MacOS nuget test pipeline.
605+
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
606+
{
607+
var macOSSkips = new[]
608+
{
609+
"test_castlike_FLOAT_to_STRING_expanded",
610+
"test_castlike_FLOAT_to_BFLOAT16_expanded",
611+
"test_castlike_BFLOAT16_to_FLOAT",
612+
"test_cast_FLOAT_to_STRING",
613+
"test_castlike_FLOAT_to_BFLOAT16",
614+
"test_castlike_STRING_to_FLOAT_expanded",
615+
"test_castlike_STRING_to_FLOAT",
616+
"test_cast_STRING_to_FLOAT",
617+
"test_castlike_BFLOAT16_to_FLOAT_expanded",
618+
"test_cast_BFLOAT16_to_FLOAT",
619+
"test_castlike_FLOAT_to_STRING"
620+
};
621+
foreach (var model in macOSSkips)
622+
{
623+
skipModels[model] = "Skipped on macOS due to flakes or lack of support";
624+
}
625+
}
626+
604627
return skipModels;
605628
}
606629

@@ -934,29 +957,6 @@ public void TestPretrainedModelsWithOrtValue(string opsetDir, string modelName)
934957
[MemberData(nameof(GetSkippedModelForTest), Skip = "Skipped due to Error, please fix the error and enable the test")]
935958
private void TestPreTrainedModels(string opsetDir, string modelName, bool useOrtValueAPIs = false)
936959
{
937-
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
938-
{
939-
var skipModels = new HashSet<string>
940-
{
941-
"test_castlike_FLOAT_to_STRING_expanded",
942-
"test_castlike_FLOAT_to_BFLOAT16_expanded",
943-
"test_castlike_BFLOAT16_to_FLOAT",
944-
"test_cast_FLOAT_to_STRING",
945-
"test_castlike_FLOAT_to_BFLOAT16",
946-
"test_castlike_STRING_to_FLOAT_expanded",
947-
"test_castlike_STRING_to_FLOAT",
948-
"test_cast_STRING_to_FLOAT",
949-
"test_castlike_BFLOAT16_to_FLOAT_expanded",
950-
"test_cast_BFLOAT16_to_FLOAT",
951-
"test_castlike_FLOAT_to_STRING"
952-
};
953-
954-
if (skipModels.Contains(modelName))
955-
{
956-
output.WriteLine($"Skipping {modelName} on macOS");
957-
return;
958-
}
959-
}
960960

961961
var opsetDirInfo = new DirectoryInfo(opsetDir);
962962
var opset = opsetDirInfo.Name;

tools/ci_build/github/azure-pipelines/c-api-noopenmp-test-pipelines.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,17 @@ stages:
105105
- template: nuget/templates/test_macos.yml
106106
parameters:
107107
AgentPool: 'AcesShared'
108+
UseHostedVmImage: 'false'
108109
PoolDemands: 'ImageOverride -equals ACES_VM_SharedPool_Sequoia'
109110
ArtifactSuffix: 'CPU'
110111

112+
- template: nodejs/templates/test_macos.yml
113+
parameters:
114+
AgentPool: 'AcesShared'
115+
UseHostedVmImage: 'false'
116+
PoolDemands: 'ImageOverride -equals ACES_VM_SharedPool_Sequoia'
117+
StageSuffix: 'MacOS_ARM64'
118+
111119
- template: nodejs/templates/test_win.yml
112120
parameters:
113121
AgentPool: 'onnxruntime-Win-CPU-VS2022-Latest'

tools/ci_build/github/azure-pipelines/nodejs/templates/test.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,20 @@ steps:
66

77

88
- task: PowerShell@2
9-
displayName: 'Move Artifact Directory'
9+
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
10+
displayName: 'Move Artifact Directory (Windows)'
1011
inputs:
1112
targetType: 'inline'
1213
script: |
1314
Move-Item -Path "$(Pipeline.Workspace)/build/NPM_packages" -Destination "$(Build.BinariesDirectory)/nodejs-artifact"
1415
16+
- task: CmdLine@2
17+
condition: and(succeeded(), ne(variables['Agent.OS'], 'Windows_NT'))
18+
displayName: 'Move Artifact Directory (POSIX)'
19+
inputs:
20+
script: |
21+
mv "$(Pipeline.Workspace)/build/NPM_packages" "$(Build.BinariesDirectory)/nodejs-artifact"
22+
1523
- script: mkdir e2e_test
1624
workingDirectory: '$(Build.BinariesDirectory)'
1725

@@ -38,4 +46,4 @@ steps:
3846
npm init -y
3947
npm install $(NpmPackageFilesForTest) --onnxruntime-node-install-cuda=skip
4048
node -p "require('onnxruntime-node')"
41-
workingDirectory: '$(Build.BinariesDirectory)/e2e_test'
49+
workingDirectory: '$(Build.BinariesDirectory)/e2e_test'

tools/ci_build/github/azure-pipelines/nodejs/templates/test_macos.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
parameters:
22
StageSuffix: ''
3+
AgentPool : 'macOS-15'
4+
UseHostedVmImage: 'true'
5+
PoolDemands: ''
6+
37
stages:
48
- stage: Nodejs_Test_MacOS_${{ parameters.StageSuffix }}
59
dependsOn:
@@ -11,7 +15,12 @@ stages:
1115
clean: all
1216
timeoutInMinutes: 120
1317
pool:
14-
vmImage: 'macOS-15'
18+
${{ if eq(parameters.UseHostedVmImage, 'true') }}:
19+
vmImage: ${{ parameters.AgentPool }}
20+
${{ else }}:
21+
name: ${{ parameters.AgentPool }}
22+
${{ if ne(parameters.PoolDemands, '') }}:
23+
demands: ${{ parameters.PoolDemands }}
1524

1625
variables:
1726
- name: OnnxRuntimeBuildDirectory

tools/ci_build/github/azure-pipelines/nuget/templates/test_macos.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
parameters:
22
AgentPool : 'macOS-15'
3+
UseHostedVmImage: 'true'
34
IsMacOS : 'true'
45
ArtifactSuffix: ''
56
PoolDemands: ''
@@ -14,7 +15,7 @@ stages:
1415
workspace:
1516
clean: all
1617
pool:
17-
${{ if contains(parameters.AgentPool, '-') }}:
18+
${{ if eq(parameters.UseHostedVmImage, 'true') }}:
1819
vmImage: ${{ parameters.AgentPool }}
1920
${{ else }}:
2021
name: ${{ parameters.AgentPool }}
@@ -38,7 +39,9 @@ stages:
3839
3940
# Artifact is a folder containing tgz. Extract it to testdata.
4041
mkdir -p $(Build.BinariesDirectory)/testdata
41-
tar -xzf $(Pipeline.Workspace)/build/onnxruntime-osx/*.tgz -C $(Build.BinariesDirectory)/testdata
42+
for archive in $(Pipeline.Workspace)/build/onnxruntime-osx/*.tgz; do
43+
tar -xzf "$archive" -C $(Build.BinariesDirectory)/testdata
44+
done
4245
4346
# Ensure libcustom_op_library.dylib is where EndToEndTests expects it (testdata/testdata)
4447
mkdir -p $(Build.BinariesDirectory)/testdata/testdata
@@ -52,6 +55,7 @@ stages:
5255
- script: |
5356
git submodule update --init cmake/external/onnx
5457
cd cmake/external/onnx
58+
git fetch origin v1.13.1 --depth=1
5559
git checkout v1.13.1
5660
cd ../../..
5761
displayName: 'Initialize ONNX submodule for test data (pinned to v1.13.1 since new data types like float8 is not supported in nuget)'

0 commit comments

Comments
 (0)