Skip to content

Commit

Permalink
Cherry-pick tagged commits to 1.12.0 release candidate (#12097)
Browse files Browse the repository at this point in the history
* Update ONNX to 1.12 (#11924)

Follow-ups that need to happen after this and before the next ORT release:
* Support SequenceMap with #11731
* Support signal ops with #11778

Follow-ups that need to happen after this but don't necessarily need to happen before the release:
* Implement LayerNormalization kernel for opset version 17: #11916

Fixes #11640

* Dll version fix ovep4.1 (#11953)

* Setting default version values for ovep dlls as well

* Update backend_manager.cc

Co-authored-by: mayavijx <mayax.vijayan@intel.com>
Co-authored-by: mohsin <mohsinx.mohammad@intel.com>

* Optimize t5 encoder in beam search (#11926)

* ooptimize t5 encoder

* update

* update

* update

* refactor expand impl

* cuda tests passed

* update

* alignment

* more alignments

* review comments

* Allow saving on CPU usage for infrequent inference requests by reducing thread spinning (#11841)

Introduce Start/Stop threadpool spinning switch
Add a session config option to force spinning stop at the end of the Run()

* Restructure function inliner (#11731)

* Add nested function call tests

* Add overload for Specialize

* Pass symboltable to onnx shape inference

* Avoid renaming empty names

* Enable sequence_map tests which failed before this change

* Deprecate APIs returning raw ptrs and provide replacements (#11922)

Provider better documentation

* register signal ops for opset 17 (#11778)

* Register signal ops for op set 17

Note code is mostly being moved, not added. These ops were previously
only registered as Microsoft contrib ops and only built if
`BUILD_MS_EXPERIMENTAL_OPS=1`. They've been added to the ai.onnx
standard op set in version 17.

Main components of this change:

* Move the kernels from the conrib_ops directory to the
  core directory.
* Add function bodies for ms experimental ops. This will allow
  old models that use the contrib ops to continue to function.
  All the function bodies consist of a single op (the
  new standard op), so performance overhead should be minimal.

Minor clean-up also in this change:

* De-duplicate get_scalar_value_from_tensor: put it in a new utils.h.
* Fix some bugs that caused compilation errors with the experimental
  ops. Tested with `build.sh --ms_experimental`
* Fix some spelling errors and lint violations.
* Replace a couple of switch statements with `MLTypeCallDispatcher`.
* Use `InlineVector` instead of `std::vector`.

Unblocks #11640

* Include opset 15 in Conv+BatchNormalization fusion (#11960)

* Fix WinML Tests are still targetting deprecated (deleted) experimental signal op definitions (#12006)

* fix winml tests

* remove legacy test

* switch idft -> dft+inverse attr

* upgrade opset 13->17 for signal ops tests

* [C# Tests] Add support for double tensor output in TestPreTrainedModels. (#12008)

Add support for double tensor output in TestPreTrainedModels.

* DML EP ResNet50 opset 15 fails in ONNX checker for FusedBatchNormalization lacking training_mode attribute (#12010)

FusedBatchNormalization include training_mode attribute

* Generalize native op creation (#11539)

* create op from ep

* read input count from context

* create holder to host nodes

* fix typo

* cast type before comparison

* throw error on API fail

* silence warning from minimal build

* switch to unique_ptr with deleter to host nodes

* fix typo

* fix build err for minimal

* fix build err for minimal

* add UT for conv

* enable test on CUDA

* add comment

* fix typo

* use gsl::span and string view for Node constructor

* Added two APIs - CopyKernelInfo and ReleaseKernelInfo

* pass gsl::span by value

* switch to span<NodeArg* const> to allow for reference to const containers

* fix typo

* fix reduced build err

* fix reduced build err

* refactoring node construction logic

* rename exceptions

* add input and output count as arguments for op creation

* refactor static member

* use ORT_CATCH instead of catch

* cancel try catch

* add static value name map

* format input definition and set err code

* fix comments

* fix typo

* [DML EP] Pad operator: Handle negative pad counts (#11974)

* Pad fallback to CPU

* Added queryPad in operatorRegistration.cpp

* Acknowledged PR comments

* Used any_of

* used none_of instead of any_of

Co-authored-by: Sumit Agarwal <sumitagarwal@microsoft.com>

* Add warning about future computation change for ConvTranspose with auto_pad (#11984)

* Add warning about future computation change for Convtranspose with auto_pad

* improve msg

* update TODO to make lint happy

* update more contents for warning and add if

* valid was not infected

* move it into kernel registration

* parse auto_pad myself

* try to use conv_transpose_attrs_.auto_pad directly

* update roialign cuda impl to onnx opset16 (#12036)

* roialign opset16

* fix

* fix

* Fix windows eager build break by pinning to torch version 1.11.0 (#12033)

Fix windows and linux eager build to torch 1.11.0.

* Skip Constant Folding for ops producing an optional type output (#11839)

* Disable sequence-type tests since C# infra doesn't support well (#12037)

* Extend lifetime of KernelDef when creating a standalone op (#12057)

place tmp kernel def as local variable to cover the lifetime of kernel creation

* Add targets files for new .net6 frameworks (#12016)

* Add net6 targets.
Remove maccatalyst as we don't have a native build targetting that.

* Set platform in macos targets

* Add targetFramework entries

* Move NativeLib.DllName definition and set using preprocessor values for simplicity. Couldn't get it to build with the preprocessor based setup when it was in a separate file.

Update the nuspec generation to set platform version for .net6 targets. TODO: Validate versions. I copied them from the managed nuget package the packaging pipeline generated prior to adding targets. Possibly w could/should lower some of the versions.

Hopefully the need to specify a version goes away when the release version of VS2022 supports .net6.

* Try android 31.1 as https://github.com/actions/virtual-environments/blob/main/images/win/Windows2022-Readme.md suggests that should be available on the CI machines

* Fix patch version mismatch
Add some extra debug info in case it helps

* Debug nuget location in CI

* Add workspace entry back in

* Add steps

* One more attempt with hardcoded nuget.exe path and original android31.0 version

* Better fix - found explicit nuget download and updated version there.

* flake8 fixes

* Fix black complaints.

* Exit Microsoft_ML_OnnxRuntime_CheckPrerequisites for net6 iOS.

* Removed outdated comment

* Fix DML custom operators which set descriptor heap to command list (#12059)

* Make C# runtest.sh automatically set latest opset (#12039)

* Update C# runtest.sh for opset 17

Should have been part of #11924

* get appropriate opset version from onnx doc

* use absolute rather than relative path

* fix typo in var name

* Disable DML command list reuse for Xbox (#12063)

disable cl reuse for xbox

* Add data type check in ConvAddRelu fusion (#12058)

* Add undocumented attribute to disable generation of Java bindings from the Android AAR. (#12075)

The generated bindings causes C# build errors that require workaround code. Disabling generation should avoid the need for any workarounds.

As the user has the C# ORT package with the C# to C bindings there's no need for binding generation that calls the ORT Java API (which is C# -> Java ->C).

* enable the extensions custom build for java and android (#11823)

* generate quantization parameter for outputs (#12089)

* DML EP Update to DML 1.9 (#12090)

* Update to DML 1.9

* Appease obnoxious Python formatting tool

* Fix orttraining-linux-ci-pipeline - Symbolic shape infer (#11965)

fix symbolic shape error due to upgraded numpy + legacy sympy

* check consumers of dq node before swap dq and transpose (#12099)

* check consumers of dq node before swap dq and transpose

* add unit test

Co-authored-by: Gary Miguel <garymiguel@microsoft.com>
Co-authored-by: Preetha Veeramalai <preetha.veeramalai@intel.com>
Co-authored-by: mayavijx <mayax.vijayan@intel.com>
Co-authored-by: mohsin <mohsinx.mohammad@intel.com>
Co-authored-by: Ye Wang <52801275+wangyems@users.noreply.github.com>
Co-authored-by: Dmitri Smirnov <yuslepukhin@users.noreply.github.com>
Co-authored-by: G. Ramalingam <grama@microsoft.com>
Co-authored-by: Dwayne Robinson <dwayner@microsoft.com>
Co-authored-by: Sheil Kumar <smk2007@gmail.com>
Co-authored-by: Edward Chen <18449977+edgchen1@users.noreply.github.com>
Co-authored-by: sumitsays <sumitagarwal330@gmail.com>
Co-authored-by: Sumit Agarwal <sumitagarwal@microsoft.com>
Co-authored-by: Chun-Wei Chen <jacky82226@gmail.com>
Co-authored-by: George Wu <jywu@microsoft.com>
Co-authored-by: Wil Brady <25513670+WilBrady@users.noreply.github.com>
Co-authored-by: Hariharan Seshadri <shariharan91@gmail.com>
Co-authored-by: Wei-Sheng Chin <wschin@outlook.com>
Co-authored-by: Scott McKay <skottmckay@gmail.com>
Co-authored-by: Jeff Bloomfield <38966965+jeffbloo@users.noreply.github.com>
Co-authored-by: Justin Stoecker <justoeck@microsoft.com>
Co-authored-by: Wenbing Li <10278425+wenbingl@users.noreply.github.com>
Co-authored-by: Yufeng Li <liyufeng1987@gmail.com>
Co-authored-by: pengwa <pengwa@microsoft.com>
  • Loading branch information
1 parent 64f95d4 commit 62226d0
Show file tree
Hide file tree
Showing 128 changed files with 4,892 additions and 3,591 deletions.
2 changes: 1 addition & 1 deletion .pipelines/nuget_config/x64/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="python" version="3.7.9" targetFramework="native" />
<package id="Microsoft.AI.DirectML.Preview" version="1.9.0-devb9b146539f535988728c8eb4791840db54add4a7" targetFramework="native" />
<package id="Microsoft.AI.DirectML" version="1.9.0" targetFramework="native" />
<package id="Microsoft.Windows.CppWinRT" version="2.0.201201.7" targetFramework="native" />
</packages>
2 changes: 1 addition & 1 deletion .pipelines/nuget_config/x86/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="pythonx86" version="3.7.9" targetFramework="native" />
<package id="Microsoft.AI.DirectML.Preview" version="1.9.0-devb9b146539f535988728c8eb4791840db54add4a7" targetFramework="native" />
<package id="Microsoft.AI.DirectML" version="1.9.0" targetFramework="native" />
<package id="Microsoft.Windows.CppWinRT" version="2.0.201201.7" targetFramework="native" />
</packages>
14 changes: 7 additions & 7 deletions cgmanifests/generated/cgmanifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@
"type": "git",
"git": {
"commitHash": "db78ac1d7716f56fc9f1b030b715f872f93964e4",
"repositoryUrl": "https://github.com/nlohmann/json.git"
"repositoryUrl": "https://github.com/nlohmann/json"
},
"comments": "git submodule at cmake/external/json"
}
Expand Down Expand Up @@ -265,7 +265,7 @@
"type": "git",
"git": {
"commitHash": "436617053d0f39a1019a371c3a9aa599b3cb2cea",
"repositoryUrl": "https://github.com/google/nsync.git"
"repositoryUrl": "https://github.com/google/nsync"
},
"comments": "git submodule at cmake/external/nsync"
}
Expand All @@ -274,8 +274,8 @@
"component": {
"type": "git",
"git": {
"commitHash": "850a81b0b77786bf99ea90580242b084f86a6235",
"repositoryUrl": "https://github.com/onnx/onnx.git"
"commitHash": "f7ee1ac60d06abe8e26c9b6bbe1e3db5286b614b",
"repositoryUrl": "https://github.com/onnx/onnx"
},
"comments": "git submodule at cmake/external/onnx"
}
Expand All @@ -284,7 +284,7 @@
"component": {
"type": "git",
"git": {
"commitHash": "e776aa0275e293707b6a0901e0e8d8a8a3679508",
"commitHash": "0d98dba29d66e93259db7daa53a9327df767a415",
"repositoryUrl": "https://github.com/google/benchmark.git"
},
"comments": "git submodule at cmake/external/onnx/third_party/benchmark"
Expand All @@ -294,7 +294,7 @@
"component": {
"type": "git",
"git": {
"commitHash": "59a2ac2745d8a57ac94c6accced73620d59fb844",
"commitHash": "ffa346860b306c9bbfb341aed9c14c067751feb8",
"repositoryUrl": "https://github.com/pybind/pybind11.git"
},
"comments": "git submodule at cmake/external/onnx/third_party/pybind11"
Expand Down Expand Up @@ -425,7 +425,7 @@
"type": "git",
"git": {
"commitHash": "e8c599bca6c56c44b6730ad93f6abbc9ecd60fc1",
"repositoryUrl": "https://github.com/microsoft/wil.git"
"repositoryUrl": "https://github.com/microsoft/wil"
},
"comments": "git submodule at cmake/external/wil"
}
Expand Down
12 changes: 6 additions & 6 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1968,6 +1968,12 @@ if (onnxruntime_ENABLE_TRAINING)
set(onnxruntime_ENABLE_ATEN ON)
endif()

# Default version parts for Microsoft.AI.MachineLearning.dll, onnxruntime.dll, onnxruntime_providers_openvino.dll and onnxruntime_providers_shared.dll in non-ADO pipeline local builds
set(VERSION_MAJOR_PART 0 CACHE STRING "First part of numeric file/product version.")
set(VERSION_MINOR_PART 0 CACHE STRING "Second part of numeric file/product version.")
set(VERSION_BUILD_PART 0 CACHE STRING "Third part of numeric file/product version.")
set(VERSION_PRIVATE_PART 0 CACHE STRING "Fourth part of numeric file/product version.")
set(VERSION_STRING "Internal Build" CACHE STRING "String representation of file/product version.")

set(ONNXRUNTIME_TARGETS onnxruntime_common onnxruntime_graph onnxruntime_framework onnxruntime_util onnxruntime_providers onnxruntime_optimizer onnxruntime_session onnxruntime_mlas onnxruntime_flatbuffers)
if (onnxruntime_USE_NUPHAR_TVM)
Expand Down Expand Up @@ -2016,12 +2022,6 @@ if (WIN32 AND NOT GDK_PLATFORM)
endif()
endif()

# Default version parts for Microsoft.AI.MachineLearning.dll and onnxruntime.dll in non-ADO pipeline local builds
set(VERSION_MAJOR_PART 0 CACHE STRING "First part of numeric file/product version.")
set(VERSION_MINOR_PART 0 CACHE STRING "Second part of numeric file/product version.")
set(VERSION_BUILD_PART 0 CACHE STRING "Third part of numeric file/product version.")
set(VERSION_PRIVATE_PART 0 CACHE STRING "Fourth part of numeric file/product version.")
set(VERSION_STRING "Internal Build" CACHE STRING "String representation of file/product version.")
include(wil.cmake)

if (onnxruntime_USE_WINML)
Expand Down
2 changes: 1 addition & 1 deletion cmake/external/dml.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ if (NOT onnxruntime_USE_CUSTOM_DIRECTML)
set(NUGET_CONFIG ${PROJECT_SOURCE_DIR}/../NuGet.config)
set(PACKAGES_CONFIG ${PROJECT_SOURCE_DIR}/../packages.config)
get_filename_component(PACKAGES_DIR ${CMAKE_CURRENT_BINARY_DIR}/../packages ABSOLUTE)
set(DML_PACKAGE_DIR ${PACKAGES_DIR}/Microsoft.AI.DirectML.Preview.1.9.0-devb9b146539f535988728c8eb4791840db54add4a7)
set(DML_PACKAGE_DIR ${PACKAGES_DIR}/Microsoft.AI.DirectML.1.9.0)
set(DML_SHARED_LIB DirectML.dll)

# Restore nuget packages, which will pull down the DirectML redist package.
Expand Down
3 changes: 2 additions & 1 deletion cmake/external/extensions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ endif()

# when onnxruntime-extensions is not a subdirectory of onnxruntime,
# output binary directory must be explicitly specified.
add_subdirectory(${onnxruntime_EXTENSIONS_PATH} ${onnxruntime_EXTENSIONS_PATH}/_subbuild EXCLUDE_FROM_ALL)
# and the output binary path is the same as CMake FetchContent pattern
add_subdirectory(${onnxruntime_EXTENSIONS_PATH} ${CMAKE_BINARY_DIR}/_deps/extensions-subbuild EXCLUDE_FROM_ALL)

# target library or executable are defined in CMakeLists.txt of onnxruntime-extensions
target_include_directories(ocos_operators PRIVATE ${RE2_INCLUDE_DIR} external/json/include)
Expand Down
2 changes: 1 addition & 1 deletion cmake/external/onnx
Submodule onnx updated 1757 files
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
we can add .net6 support to other packages later as needed -->
<PropertyGroup Condition="('$(OrtPackageId)' == 'Microsoft.ML.OnnxRuntime' OR
'$(OrtPackageId)' == 'Microsoft.ML.OnnxRuntime.Gpu')">
<Net6Targets>net6.0;net6.0-android;net6.0-ios;net6.0-maccatalyst;net6.0-macos</Net6Targets>
<Net6Targets>net6.0;net6.0-android;net6.0-ios;net6.0-macos</Net6Targets>
</PropertyGroup>

<PropertyGroup Condition="'$(SelectedTargets)'=='PreNet6'">
Expand Down
8 changes: 0 additions & 8 deletions csharp/src/Microsoft.ML.OnnxRuntime/NativeLib.android.cs

This file was deleted.

8 changes: 0 additions & 8 deletions csharp/src/Microsoft.ML.OnnxRuntime/NativeLib.ios.cs

This file was deleted.

8 changes: 0 additions & 8 deletions csharp/src/Microsoft.ML.OnnxRuntime/NativeLib.net.cs

This file was deleted.

8 changes: 0 additions & 8 deletions csharp/src/Microsoft.ML.OnnxRuntime/NativeLib.netstandard.cs

This file was deleted.

15 changes: 15 additions & 0 deletions csharp/src/Microsoft.ML.OnnxRuntime/NativeMethods.shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,21 @@ static NativeMethods()
typeof(DSessionOptionsAppendExecutionProvider));
}

internal class NativeLib
{
#if __ANDROID__
// define the library name required for android
internal const string DllName = "libonnxruntime.so";
#elif __IOS__
// define the library name required for iOS
internal const string DllName = "__Internal";
#else
internal const string DllName = "onnxruntime";
#endif
// TODO: Does macos need special handling or will 'onnxruntime' -> libonnxruntime.dylib?
}


[DllImport(NativeLib.DllName, CharSet = CharSet.Ansi)]
public static extern ref OrtApiBase OrtGetApiBase();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Condition=" '$(AndroidApplication)'=='true' ">
<AndroidLibrary Bind="false" Include="$(MSBuildThisFileDirectory)..\..\runtimes\android\native\*">
<Link>%(Filename)%(Extension)</Link>
</AndroidLibrary>
</ItemGroup>
</Project>
21 changes: 21 additions & 0 deletions csharp/src/Microsoft.ML.OnnxRuntime/targets/net6.0-ios/targets.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Condition="('$(OutputType)'!='Library' OR '$(IsAppExtension)'=='True')">
<NativeReference Condition="'$(Platform)' == 'iPhoneSimulator'" Include="$(MSBuildThisFileDirectory)..\..\runtimes\ios\native\onnxruntime.xcframework\ios-arm64_x86_64-simulator\onnxruntime.framework">
<Kind>Framework</Kind>
<IsCxx>True</IsCxx>
<SmartLink>True</SmartLink>
<ForceLoad>True</ForceLoad>
<LinkerFlags>-lc++</LinkerFlags>
<WeakFrameworks>CoreML</WeakFrameworks>
</NativeReference>
<NativeReference Condition="'$(Platform)' == 'iPhone'" Include="$(MSBuildThisFileDirectory)..\..\runtimes\ios\native\onnxruntime.xcframework\ios-arm64\onnxruntime.framework">
<Kind>Framework</Kind>
<IsCxx>True</IsCxx>
<SmartLink>True</SmartLink>
<ForceLoad>True</ForceLoad>
<LinkerFlags>-lc++</LinkerFlags>
<WeakFrameworks>CoreML</WeakFrameworks>
</NativeReference>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Condition="('$(OutputType)'!='Library' OR '$(IsAppExtension)'=='True')">
<NativeReference Condition="'$(Platform)' == 'arm64'" Include="$(MSBuildThisFileDirectory)..\..\runtimes\osx.10.14-arm64\native\libonnxruntime.dylib">
<Kind>Framework</Kind>
<IsCxx>True</IsCxx>
<SmartLink>True</SmartLink>
<ForceLoad>True</ForceLoad>
<LinkerFlags>-lc++</LinkerFlags>
<WeakFrameworks>CoreML</WeakFrameworks>
</NativeReference>
<NativeReference Condition="'$(Platform)' == 'x64'" Include="$(MSBuildThisFileDirectory)..\..\runtimes\osx.10.14-x64\native\libonnxruntime.dylib">
<Kind>Framework</Kind>
<IsCxx>True</IsCxx>
<SmartLink>True</SmartLink>
<ForceLoad>True</ForceLoad>
<LinkerFlags>-lc++</LinkerFlags>
<WeakFrameworks>CoreML</WeakFrameworks>
</NativeReference>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
<Error Condition="('$(PlatformTarget)' != 'x64' AND '$(PlatformTarget)' != 'x86' AND '$(PlatformTarget)' != 'AnyCPU') AND
('$(OutputType)' == 'Exe' OR '$(OutputType)'=='WinExe') AND
!('$(TargetFrameworkIdentifier)' == '.NETCoreApp' AND '$(PlatformTarget)' == '') AND
'$(TargetFrameworkIdentifier)' != 'Xamarin.iOS' AND
('$(TargetFrameworkIdentifier)' != 'Xamarin.iOS' AND
$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) != 'ios') AND
'$(SuppressOnnxRuntimePlatformCompatibilityError)' != 'true'"
Text="Microsoft.ML.OnnxRuntime only supports the AnyCPU, x64, and x86 platforms at this time."/>
</Target>
Expand Down
10 changes: 7 additions & 3 deletions csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ echo "Current NuGet package version is $CurrentOnnxRuntimeVersion"

if [ $RunTestCsharp = "true" ]; then
if [[ $IsMacOS == "True" || $IsMacOS == "true" ]]; then
mkdir -p $BUILD_BINARIESDIRECTORY/models
ln -s $BUILD_SOURCESDIRECTORY/cmake/external/onnx/onnx/backend/test/data/node $BUILD_BINARIESDIRECTORY/models/opset16
# TODO(#12040): The test should figure out the opset version from the model file. Remove it from the path.
ONNX_DIR="${BUILD_SOURCESDIRECTORY}/cmake/external/onnx"
ONNX_VERSION_NUMBER=$(cat "${ONNX_DIR}/VERSION_NUMBER" | sed -E 's/([0-9]+\.[0-9]+\.[0-9]+).*/\1/')
OPSET_VERSION=$(grep "${ONNX_VERSION_NUMBER}" "${ONNX_DIR}/docs/Versioning.md" | sed -E "s/${ONNX_VERSION_NUMBER}\|[^|]+\|([0-9]+)\|.*/\1/")
mkdir -p "${BUILD_BINARIESDIRECTORY}/models"
ln -s "${ONNX_DIR}/onnx/backend/test/data/node" "${BUILD_BINARIESDIRECTORY}/models/opset${OPSET_VERSION}"
fi
# Run C# tests
dotnet restore $BUILD_SOURCESDIRECTORY/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/Microsoft.ML.OnnxRuntime.EndToEndTests.csproj -s $LocalNuGetRepo -s https://api.nuget.org/v3/index.json
Expand All @@ -29,7 +33,7 @@ if [ $RunTestCsharp = "true" ]; then
fi

if [ $PACKAGENAME = "Microsoft.ML.OnnxRuntime.Gpu" ]; then
export TESTONGPU=ON
export TESTONGPU=ON
dotnet test -p:DefineConstants=USE_CUDA $BUILD_SOURCESDIRECTORY/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/Microsoft.ML.OnnxRuntime.EndToEndTests.csproj --no-restore --verbosity detailed
if [ $? -ne 0 ]; then
echo "Failed to build or execute the end-to-end test"
Expand Down
21 changes: 18 additions & 3 deletions csharp/test/Microsoft.ML.OnnxRuntime.Tests.Common/InferenceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public InferenceTest(ITestOutputHelper o)
[Fact(DisplayName = "TestSessionOptions")]
public void TestSessionOptions()
{
// get instance to setup logging
// get instance to setup logging
var ortEnvInstance = OrtEnv.Instance();

using (SessionOptions opt = new SessionOptions())
Expand Down Expand Up @@ -1938,7 +1938,7 @@ private void TestSharedAllocatorUsingCreateAndRegisterAllocator()
var session = (deviceId.HasValue)
? new InferenceSession(model, option)
: new InferenceSession(model);
float[] inputData = TestDataLoader.LoadTensorFromEmbeddedResource("bench.in");
float[] inputData = TestDataLoader.LoadTensorFromEmbeddedResource("bench.in");
float[] expectedOutput = TestDataLoader.LoadTensorFromEmbeddedResource("bench.expected_out");
var inputMeta = session.InputMetadata;
var tensor = new DenseTensor<float>(inputData, inputMeta["data_0"].Dimensions);
Expand All @@ -1961,6 +1961,21 @@ public int GetHashCode(float x)
}
}

internal class DoubleComparer : IEqualityComparer<double>
{
private double atol = 1e-3;
private double rtol = 1.7e-2;

public bool Equals(double x, double y)
{
return Math.Abs(x - y) <= (atol + rtol * Math.Abs(y));
}
public int GetHashCode(double x)
{
return x.GetHashCode();
}
}

class ExactComparer<T> : IEqualityComparer<T>
{
public bool Equals(T x, T y)
Expand Down Expand Up @@ -2069,4 +2084,4 @@ public void Dispose()
}
#endregion
}
}
}
Loading

0 comments on commit 62226d0

Please sign in to comment.