enable training tests for csharp bindings (#15513)

### Description
Simple fix to enable training tests in csharp through build.py script.
This commit is contained in:
Ashwini Khade 2023-04-17 09:57:23 -07:00 committed by GitHub
parent 7ed3bfde51
commit 8fa65aba0e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 5 deletions

View file

@ -130,8 +130,7 @@
</PropertyGroup>
<!-- Enable training APIs for the build. The native package must be
a training build with build flags 'enable_training' and
'enable_training_apis' set.
a training build with build flag 'enable_training_apis'.
-->
<PropertyGroup Condition="'$(EnableTrainingApis)'=='true'">
<OrtConstants>$(OrtConstants);__ENABLE_TRAINING_APIS__</OrtConstants>

View file

@ -19,7 +19,9 @@
<!-- end -->
<!-- Training build property.
Should be set to true when training is enabled in onnxruntime native binary -->
Should be set to true when training is enabled in onnxruntime native binary
Note: This property should be set when building the csharp solution independently.
When building using the build.py script, setting the necessary properties is handled by the script. -->
<TrainingEnabledNativeBuild Condition="'$(TrainingEnabledNativeBuild)' == ''">false</TrainingEnabledNativeBuild>
</PropertyGroup>

View file

@ -2000,7 +2000,9 @@ def build_nuget_package(
target_name = "/t:CreatePackage"
execution_provider = '/p:ExecutionProvider="None"'
package_name = '/p:OrtPackageId="Microsoft.ML.OnnxRuntime"'
enable_training_tests = '/p:TrainingEnabledNativeBuild="false"'
if enable_training_apis:
enable_training_tests = '/p:TrainingEnabledNativeBuild="true"'
if use_cuda:
package_name = '/p:OrtPackageId="Microsoft.ML.OnnxRuntime.Training.Gpu"'
else:
@ -2047,7 +2049,16 @@ def build_nuget_package(
configuration = '/p:Configuration="' + config + '"'
if not use_winml:
cmd_args = ["dotnet", "msbuild", sln, configuration, package_name, is_linux_build, ort_build_dir]
cmd_args = [
"dotnet",
"msbuild",
sln,
configuration,
package_name,
is_linux_build,
ort_build_dir,
enable_training_tests,
]
run_subprocess(cmd_args, cwd=csharp_build_dir)
else:
winml_interop_dir = os.path.join(source_dir, "csharp", "src", "Microsoft.AI.MachineLearning.Interop")
@ -2109,7 +2120,7 @@ def run_csharp_tests(source_dir, build_dir, use_cuda, use_openvino, use_tensorrt
if use_cuda:
macros += "USE_CUDA;"
if enable_training_apis:
macros += "__TRAINING_ENABLED_NATIVE_BUILD__;"
macros += "__TRAINING_ENABLED_NATIVE_BUILD__;__ENABLE_TRAINING_APIS__"
define_constants = ""
if macros != "":