diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi/CXX_Api_Sample.cpp b/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi/CXX_Api_Sample.cpp deleted file mode 100644 index 397552efdb..0000000000 --- a/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi/CXX_Api_Sample.cpp +++ /dev/null @@ -1,129 +0,0 @@ -// Copyright(c) Microsoft Corporation.All rights reserved. -// Licensed under the MIT License. -// - -#include -#include -#include - -int main(int argc, char* argv[]) { - //************************************************************************* - // initialize enviroment...one enviroment per process - // enviroment maintains thread pools and other state info - Ort::Env env(ORT_LOGGING_LEVEL_WARNING, "test"); - - // initialize session options if needed - Ort::SessionOptions session_options; - session_options.SetIntraOpNumThreads(1); - - // If onnxruntime.dll is built with CUDA enabled, we can uncomment out this line to use CUDA for this session - // OrtSessionOptionsAppendExecutionProvider_CUDA(session_options, 1); - - // Sets graph optimization level - // Available levels are - // ORT_DISABLE_ALL -> To disable all optimizations - // ORT_ENABLE_BASIC -> To enable basic optimizations (Such as redundant node removals) - // ORT_ENABLE_EXTENDED -> To enable extended optimizations (Includes level 1 + more complex optimizations like node fusions) - // ORT_ENABLE_ALL -> To Enable All possible opitmizations - session_options.SetGraphOptimizationLevel(GraphOptimizationLevel::ORT_ENABLE_EXTENDED); - - //************************************************************************* - // create session and load model into memory - // using squeezenet version 1.3 - // URL = https://github.com/onnx/models/tree/master/squeezenet -#ifdef _WIN32 - const wchar_t* model_path = L"squeezenet.onnx"; -#else - const char* model_path = "squeezenet.onnx"; -#endif - - printf("Using Onnxruntime C++ API\n"); - Ort::Session session(env, model_path, session_options); - - //************************************************************************* - // print model input layer (node names, types, shape etc.) - Ort::AllocatorWithDefaultOptions allocator; - - // print number of model input nodes - size_t num_input_nodes = session.GetInputCount(); - std::vector input_node_names(num_input_nodes); - std::vector input_node_dims; // simplify... this model has only 1 input node {1, 3, 224, 224}. - // Otherwise need vector> - - printf("Number of inputs = %zu\n", num_input_nodes); - - // iterate over all input nodes - for (int i = 0; i < num_input_nodes; i++) { - // print input node names - char* input_name = session.GetInputName(i, allocator); - printf("Input %d : name=%s\n", i, input_name); - input_node_names[i] = input_name; - - // print input node types - Ort::TypeInfo type_info = session.GetInputTypeInfo(i); - auto tensor_info = type_info.GetTensorTypeAndShapeInfo(); - - ONNXTensorElementDataType type = tensor_info.GetElementType(); - printf("Input %d : type=%d\n", i, type); - - // print input shapes/dims - input_node_dims = tensor_info.GetShape(); - printf("Input %d : num_dims=%zu\n", i, input_node_dims.size()); - for (int j = 0; j < input_node_dims.size(); j++) - printf("Input %d : dim %d=%jd\n", i, j, input_node_dims[j]); - } - - // Results should be... - // Number of inputs = 1 - // Input 0 : name = data_0 - // Input 0 : type = 1 - // Input 0 : num_dims = 4 - // Input 0 : dim 0 = 1 - // Input 0 : dim 1 = 3 - // Input 0 : dim 2 = 224 - // Input 0 : dim 3 = 224 - - //************************************************************************* - // Similar operations to get output node information. - // Use OrtSessionGetOutputCount(), OrtSessionGetOutputName() - // OrtSessionGetOutputTypeInfo() as shown above. - - //************************************************************************* - // Score the model using sample data, and inspect values - - size_t input_tensor_size = 224 * 224 * 3; // simplify ... using known dim values to calculate size - // use OrtGetTensorShapeElementCount() to get official size! - - std::vector input_tensor_values(input_tensor_size); - std::vector output_node_names = {"softmaxout_1"}; - - // initialize input data with values in [0.0, 1.0] - for (unsigned int i = 0; i < input_tensor_size; i++) - input_tensor_values[i] = (float)i / (input_tensor_size + 1); - - // create input tensor object from data values - auto memory_info = Ort::MemoryInfo::CreateCpu(OrtArenaAllocator, OrtMemTypeDefault); - Ort::Value input_tensor = Ort::Value::CreateTensor(memory_info, input_tensor_values.data(), input_tensor_size, input_node_dims.data(), 4); - assert(input_tensor.IsTensor()); - - // score model & input tensor, get back output tensor - auto output_tensors = session.Run(Ort::RunOptions{nullptr}, input_node_names.data(), &input_tensor, 1, output_node_names.data(), 1); - assert(output_tensors.size() == 1 && output_tensors.front().IsTensor()); - - // Get pointer to output tensor float values - float* floatarr = output_tensors.front().GetTensorMutableData(); - assert(abs(floatarr[0] - 0.000045) < 1e-6); - - // score the model, and print scores for first 5 classes - for (int i = 0; i < 5; i++) - printf("Score for class [%d] = %f\n", i, floatarr[i]); - - // Results should be as below... - // Score for class[0] = 0.000045 - // Score for class[1] = 0.003846 - // Score for class[2] = 0.000125 - // Score for class[3] = 0.001180 - // Score for class[4] = 0.001317 - printf("Done!\n"); - return 0; -} diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi/C_Api_Sample.cpp b/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi/C_Api_Sample.cpp deleted file mode 100644 index b910ea11c2..0000000000 --- a/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi/C_Api_Sample.cpp +++ /dev/null @@ -1,170 +0,0 @@ -// Copyright(c) Microsoft Corporation.All rights reserved. -// Licensed under the MIT License. -// - -#include -#include -#include -#include -#include -#include - -const OrtApi* g_ort = OrtGetApiBase()->GetApi(ORT_API_VERSION); - -//***************************************************************************** -// helper function to check for status -void CheckStatus(OrtStatus* status) -{ - if (status != NULL) { - const char* msg = g_ort->GetErrorMessage(status); - fprintf(stderr, "%s\n", msg); - g_ort->ReleaseStatus(status); - exit(1); - } -} - -int main(int argc, char* argv[]) { - //************************************************************************* - // initialize enviroment...one enviroment per process - // enviroment maintains thread pools and other state info - OrtEnv* env; - CheckStatus(g_ort->CreateEnv(ORT_LOGGING_LEVEL_WARNING, "test", &env)); - - // initialize session options if needed - OrtSessionOptions* session_options; - CheckStatus(g_ort->CreateSessionOptions(&session_options)); - g_ort->SetIntraOpNumThreads(session_options, 1); - - // Sets graph optimization level - g_ort->SetSessionGraphOptimizationLevel(session_options, ORT_ENABLE_BASIC); - - // Optionally add more execution providers via session_options - // E.g. for CUDA uncomment the following line: - // OrtSessionOptionsAppendExecutionProvider_CUDA(sessionOptions, 0); - - //************************************************************************* - // create session and load model into memory - // using squeezenet version 1.3 - // URL = https://github.com/onnx/models/tree/master/squeezenet - OrtSession* session; -#ifdef _WIN32 - const wchar_t* model_path = L"squeezenet.onnx"; -#else - const char* model_path = "squeezenet.onnx"; -#endif - - printf("Using Onnxruntime C API\n"); - CheckStatus(g_ort->CreateSession(env, model_path, session_options, &session)); - - //************************************************************************* - // print model input layer (node names, types, shape etc.) - size_t num_input_nodes; - OrtStatus* status; - OrtAllocator* allocator; - CheckStatus(g_ort->GetAllocatorWithDefaultOptions(&allocator)); - - // print number of model input nodes - status = g_ort->SessionGetInputCount(session, &num_input_nodes); - std::vector input_node_names(num_input_nodes); - std::vector input_node_dims; // simplify... this model has only 1 input node {1, 3, 224, 224}. - // Otherwise need vector> - - printf("Number of inputs = %zu\n", num_input_nodes); - - // iterate over all input nodes - for (size_t i = 0; i < num_input_nodes; i++) { - // print input node names - char* input_name; - status = g_ort->SessionGetInputName(session, i, allocator, &input_name); - printf("Input %zu : name=%s\n", i, input_name); - input_node_names[i] = input_name; - - // print input node types - OrtTypeInfo* typeinfo; - status = g_ort->SessionGetInputTypeInfo(session, i, &typeinfo); - const OrtTensorTypeAndShapeInfo* tensor_info; - CheckStatus(g_ort->CastTypeInfoToTensorInfo(typeinfo, &tensor_info)); - ONNXTensorElementDataType type; - CheckStatus(g_ort->GetTensorElementType(tensor_info, &type)); - printf("Input %zu : type=%d\n", i, type); - - // print input shapes/dims - size_t num_dims; - CheckStatus(g_ort->GetDimensionsCount(tensor_info, &num_dims)); - printf("Input %zu : num_dims=%zu\n", i, num_dims); - input_node_dims.resize(num_dims); - g_ort->GetDimensions(tensor_info, (int64_t*)input_node_dims.data(), num_dims); - for (size_t j = 0; j < num_dims; j++) - printf("Input %zu : dim %zu=%jd\n", i, j, input_node_dims[j]); - - g_ort->ReleaseTypeInfo(typeinfo); - } - - // Results should be... - // Number of inputs = 1 - // Input 0 : name = data_0 - // Input 0 : type = 1 - // Input 0 : num_dims = 4 - // Input 0 : dim 0 = 1 - // Input 0 : dim 1 = 3 - // Input 0 : dim 2 = 224 - // Input 0 : dim 3 = 224 - - //************************************************************************* - // Similar operations to get output node information. - // Use OrtSessionGetOutputCount(), OrtSessionGetOutputName() - // OrtSessionGetOutputTypeInfo() as shown above. - - //************************************************************************* - // Score the model using sample data, and inspect values - - size_t input_tensor_size = 224 * 224 * 3; // simplify ... using known dim values to calculate size - // use OrtGetTensorShapeElementCount() to get official size! - - std::vector input_tensor_values(input_tensor_size); - std::vector output_node_names = {"softmaxout_1"}; - - // initialize input data with values in [0.0, 1.0] - for (size_t i = 0; i < input_tensor_size; i++) - input_tensor_values[i] = (float)i / (input_tensor_size + 1); - - // create input tensor object from data values - OrtMemoryInfo* memory_info; - CheckStatus(g_ort->CreateCpuMemoryInfo(OrtArenaAllocator, OrtMemTypeDefault, &memory_info)); - OrtValue* input_tensor = NULL; - CheckStatus(g_ort->CreateTensorWithDataAsOrtValue(memory_info, input_tensor_values.data(), input_tensor_size * sizeof(float), input_node_dims.data(), 4, ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT, &input_tensor)); - int is_tensor; - CheckStatus(g_ort->IsTensor(input_tensor, &is_tensor)); - assert(is_tensor); - g_ort->ReleaseMemoryInfo(memory_info); - - // score model & input tensor, get back output tensor - OrtValue* output_tensor = NULL; - CheckStatus(g_ort->Run(session, NULL, input_node_names.data(), (const OrtValue* const*)&input_tensor, 1, output_node_names.data(), 1, &output_tensor)); - CheckStatus(g_ort->IsTensor(output_tensor, &is_tensor)); - assert(is_tensor); - - // Get pointer to output tensor float values - float* floatarr; - CheckStatus(g_ort->GetTensorMutableData(output_tensor, (void**)&floatarr)); - assert(std::abs(floatarr[0] - 0.000045) < 1e-6); - - // score the model, and print scores for first 5 classes - for (int i = 0; i < 5; i++) - printf("Score for class [%d] = %f\n", i, floatarr[i]); - - // Results should be as below... - // Score for class[0] = 0.000045 - // Score for class[1] = 0.003846 - // Score for class[2] = 0.000125 - // Score for class[3] = 0.001180 - // Score for class[4] = 0.001317 - - g_ort->ReleaseValue(output_tensor); - g_ort->ReleaseValue(input_tensor); - g_ort->ReleaseSession(session); - g_ort->ReleaseSessionOptions(session_options); - g_ort->ReleaseEnv(env); - printf("Done!\n"); - return 0; -} diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi/InferenceTestCapi.cpp b/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi/InferenceTestCapi.cpp deleted file mode 100644 index b8fe4b7922..0000000000 --- a/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi/InferenceTestCapi.cpp +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. -// -#include "CppUnitTest.h" -#include -#include - -wchar_t* GetWideString(const char* c) { - const size_t cSize = strlen(c) + 1; - wchar_t* wc = new wchar_t[cSize]; - mbstowcs(wc, c, cSize); - - return wc; -} - -#define ORT_ABORT_ON_ERROR(expr) \ - { \ - OrtStatus* onnx_status = (expr); \ - if (onnx_status != NULL) { \ - const char* msg = OrtGetErrorMessage(onnx_status); \ - fprintf(stderr, "%s\n", msg); \ - OrtReleaseStatus(onnx_status); \ - wchar_t* wmsg = GetWideString(msg); \ - Assert::Fail(L"Failed on ORT_ABORT_ON_ERROR"); \ - free(wmsg); \ - } \ - } - -using namespace Microsoft::VisualStudio::CppUnitTestFramework; - -namespace UnitTest1 { -TEST_CLASS(UnitTest1){ - public : - - int run_inference(OrtSession * session){ - size_t input_height = 224; -size_t input_width = 224; -float* model_input = (float*)malloc(sizeof(float) * 224 * 224 * 3); -size_t model_input_ele_count = 224 * 224 * 3; - -// initialize to values between 0.0 and 1.0 -for (unsigned int i = 0; i < model_input_ele_count; i++) - model_input[i] = (float)i / (float)(model_input_ele_count + 1); - -OrtMemoryInfo* memory_info; -ORT_ABORT_ON_ERROR(OrtCreateCpuMemoryInfo(OrtArenaAllocator, OrtMemTypeDefault, &memory_info)); -const size_t input_shape[] = {1, 3, 224, 224}; -const size_t input_shape_len = sizeof(input_shape) / sizeof(input_shape[0]); -const size_t model_input_len = model_input_ele_count * sizeof(float); - -OrtValue* input_tensor = NULL; -ORT_ABORT_ON_ERROR(OrtCreateTensorWithDataAsOrtValue(memory_info, model_input, model_input_len, input_shape, input_shape_len, ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT, &input_tensor)); -assert(input_tensor != NULL); -assert(OrtIsTensor(input_tensor)); -OrtReleaseMemoryInfo(memory_info); -const char* input_names[] = {"data_0"}; -const char* output_names[] = {"softmaxout_1"}; -OrtValue* output_tensor = NULL; -ORT_ABORT_ON_ERROR(OrtRun(session, NULL, input_names, (const OrtValue* const*)&input_tensor, 1, output_names, 1, &output_tensor)); -assert(output_tensor != NULL); -assert(OrtIsTensor(output_tensor)); - -OrtReleaseValue(output_tensor); -OrtReleaseValue(input_tensor); -free(model_input); -return 0; -} // namespace UnitTest1 - -int test() { - const wchar_t* model_path = L"squeezenet.onnx"; - OrtEnv* env; - ORT_ABORT_ON_ERROR(OrtCreateEnv(ORT_LOGGING_LEVEL_WARNING, "test", &env)); - OrtSessionOptions* session_option = OrtCreateSessionOptions(); - OrtSession* session; - OrtSetIntraOpNumThreads(session_option, 1); - ORT_ABORT_ON_ERROR(OrtCreateSession(env, model_path, session_option, &session)); - OrtReleaseSessionOptions(session_option); - - int result = run_inference(session); - - OrtReleaseSession(session); - OrtReleaseEnv(env); -} - -TEST_METHOD(TestMethod1) { - int res = test(); - Assert::AreEqual(res, 0); -} -} -; -} diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi/Microsoft.ML.OnnxRuntime.EndToEndTests.RunCapi.vcxproj b/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi/Microsoft.ML.OnnxRuntime.EndToEndTests.RunCapi.vcxproj deleted file mode 100644 index 3fb20d386b..0000000000 --- a/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi/Microsoft.ML.OnnxRuntime.EndToEndTests.RunCapi.vcxproj +++ /dev/null @@ -1,130 +0,0 @@ - - - - $(MSBuildThisFileDirectory)..\.. - Microsoft.ML.OnnxRuntime - C_Api_Sample.cpp - - - - - Debug - x64 - - - Release - x64 - - - Debug - x86 - - - Release - x86 - - - - 15.0 - {B8CA7F10-0171-4EA5-8662-5A9942DDF415} - Win32Proj - MicrosoftMLOnnxRuntimeEndToEndTestsRunCapi - - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - - - false - - - true - - - false - - - - NotUsing - Level3 - Disabled - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - NotUsing - Level3 - MaxSpeed - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - Always - false - - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - \ No newline at end of file diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi/Microsoft.ML.OnnxRuntime.Gpu.EndToEndTests.RunCapi.vcxproj b/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi/Microsoft.ML.OnnxRuntime.Gpu.EndToEndTests.RunCapi.vcxproj deleted file mode 100644 index ea4701e9fe..0000000000 --- a/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi/Microsoft.ML.OnnxRuntime.Gpu.EndToEndTests.RunCapi.vcxproj +++ /dev/null @@ -1,108 +0,0 @@ - - - - $(MSBuildThisFileDirectory)..\.. - - - - - Debug - x64 - - - Release - x64 - - - - 15.0 - {B8CA7F10-0171-4EA5-8662-5A9942DDF415} - Win32Proj - MicrosoftMLOnnxRuntimeEndToEndTestsRunCapi - - - - Application - true - v142 - Unicode - - - Application - false - v142 - true - Unicode - - - - - - - - - - - - - - - true - - - false - - - - NotUsing - Level3 - Disabled - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - NotUsing - Level3 - MaxSpeed - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - Always - false - - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - \ No newline at end of file diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi/packages-gpu.conf b/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi/packages-gpu.conf deleted file mode 100644 index 0750d83815..0000000000 --- a/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi/packages-gpu.conf +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi/packages.conf b/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi/packages.conf deleted file mode 100644 index e9a91f917d..0000000000 --- a/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi/packages.conf +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi/runtest-gpu.bat b/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi/runtest-gpu.bat deleted file mode 100644 index 4e9eb77561..0000000000 --- a/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi/runtest-gpu.bat +++ /dev/null @@ -1,60 +0,0 @@ -REM Copyright (c) Microsoft Corporation. All rights reserved. -REM Licensed under the MIT License. -echo on - -set LocalNuGetRepo=%1 -SET CurrentOnnxRuntimeVersion=%2 -setlocal enableextensions disabledelayedexpansion - -@echo %CurrentOnnxRuntimeVersion% - -pushd test\Microsoft.ML.OnnxRuntime.EndToEndTests.Capi - -REM Set up VS envvars -REM call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat" - -REM Generate packages.config with version -echo off -set "token=CurrentOnnxRuntimeVersion" -set "replace=%CurrentOnnxRuntimeVersion%" -set "templateFile=packages-gpu.conf" -for /f "delims=" %%i in ('type "%templateFile%" ^& break ^> "packages.config" ') do ( - set "line=%%i" - setlocal enabledelayedexpansion - >>"packages.config" echo(!line:%token%=%replace%! - endlocal -) -echo on - -REM Restore NuGet Packages -nuget restore -PackagesDirectory ..\packages -Source %LocalNuGetRepo% Microsoft.ML.OnnxRuntime.Gpu.EndToEndTests.RunCapi.vcxproj -if NOT %ERRORLEVEL% EQU 0 ( - echo "Error:Nuget restore failed" - popd - EXIT /B 1 -) - -REM Build Native project -msbuild Microsoft.ML.OnnxRuntime.Gpu.EndToEndTests.RunCapi.vcxproj -if NOT %ERRORLEVEL% EQU 0 ( - echo "Error:MSBuild failed to compile project" - popd - EXIT /B 1 -) - - -REM Run Unit Tests -pushd x64\Debug -REM vstest.console.exe /platform:x64 Microsoft.ML.OnnxRuntime.EndToEndTests.Capi.dll -.\Microsoft.ML.OnnxRuntime.Gpu.EndToEndTests.RunCapi.exe -if NOT %ERRORLEVEL% EQU 0 ( - echo "Unit test failure: %ERRORLEVEL%" - popd - popd - EXIT /B 1 -) - -popd -popd - -EXIT /B 0 diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi/runtest.bat b/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi/runtest.bat deleted file mode 100644 index e889bd3adb..0000000000 --- a/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi/runtest.bat +++ /dev/null @@ -1,85 +0,0 @@ -REM Copyright (c) Microsoft Corporation. All rights reserved. -REM Licensed under the MIT License. -ECHO on - -SET LocalNuGetRepo=%1 -SET TargetArch=x64 -IF NOT "%2"=="" (SET TargetArch=%2) -SET CurrentOnnxRuntimeVersion=%3 - -SETLOCAL enableextensions disabledelayedexpansion - -@ECHO %CurrentOnnxRuntimeVersion% - -PUSHD test\Microsoft.ML.OnnxRuntime.EndToEndTests.Capi - -REM SET up VS envvars -REM call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat" - -REM Generate packages.config with version -ECHO off -SET "token=CurrentOnnxRuntimeVersion" -SET "replace=%CurrentOnnxRuntimeVersion%" -SET "templateFile=packages.conf" -for /f "delims=" %%i in ('type "%templateFile%" ^& break ^> "packages.config" ') do ( - SET "line=%%i" - SETLOCAL enabledelayedexpansion - >>"packages.config" ECHO(!line:%token%=%replace%! - ENDLOCAL -) -ECHO on - -REM Update project file with package name (e.g. Microsoft.ML.OnnxRuntime.Gpu) -IF "%PackageName%"=="" goto :skip -@ECHO off -SETLOCAL EnableExtensions DisableDelayedExpansion -SET "search="Microsoft.ML.OnnxRuntime"" -SET "replace="%PackageName%"" -SET "projfile="packages.config"" -FOR /f "delims=" %%i in ('type "packages.config" ^& break ^> "packages.config" ') do ( - SET "line=%%i" - SETLOCAL enabledelayedexpansion - >>"packages.config" ECHO(!line:%search%=%replace%! - ENDLOCAL - ) -:skip - - -REM Restore NuGet Packages -nuget restore -PackagesDirectory ..\packages -Source %LocalNuGetRepo% Microsoft.ML.OnnxRuntime.EndToEndTests.RunCapi.vcxproj -if NOT %ERRORLEVEL% EQU 0 ( - ECHO "Error:Nuget restore failed" - POPD - EXIT /B 1 -) - - -IF "%TargetArch%"=="x86" ( - SET OutputDir="Debug" -) ELSE ( - SET OutputDir="x64\Debug" -) - -REM Build Native project -msbuild /p:Platform=%TargetArch% Microsoft.ML.OnnxRuntime.EndToEndTests.RunCapi.vcxproj -if NOT %ERRORLEVEL% EQU 0 ( - ECHO "Error:MSBuild failed to compile project" - POPD - EXIT /B 1 -) - -REM Run Unit Tests -PUSHD %OutputDir% -REM vstest.console.exe /platform:x64 Microsoft.ML.OnnxRuntime.EndToEndTests.Capi.dll -.\Microsoft.ML.OnnxRuntime.EndToEndTests.RunCapi.exe -if NOT %ERRORLEVEL% EQU 0 ( - ECHO "Unit test failure: %ERRORLEVEL%" - POPD - POPD - EXIT /B 1 -) - -POPD -POPD - -EXIT /B 0 diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh b/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh index 7e2ff0ea64..0cb2fba7b9 100755 --- a/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh +++ b/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh @@ -11,7 +11,7 @@ RunTestNative=${RunTestNative:-true} set -x -e -OldDir=`pwd` +pushd . cd $BUILD_SOURCESDIRECTORY echo "Current NuGet package version is $CurrentOnnxRuntimeVersion" @@ -39,39 +39,5 @@ if [ $RunTestCsharp = "true" ]; then fi fi -if [ $RunTestNative = "true" ]; then - # Run Native shared object test - # PACKAGENAME is passed in environment (e.g. Microsoft.ML.OnnxRuntime) - PACKAGENAME="$PACKAGENAME.$CurrentOnnxRuntimeVersion.nupkg" - cd $LocalNuGetRepo - TempDir=_tmp - mkdir -p $TempDir && pushd $TempDir - unzip ../$PACKAGENAME - - inc="-I build/native/include" - - if [[ $IsMacOS == "True" || $IsMacOS == "true" ]]; then - export DYLD_FALLBACK_LIBRARY_PATH=$LocalNuGetRepo/_tmp:${DYLD_FALLBACK_LIBRARY_PATH} - libs="-L runtimes/osx-x64/native -l onnxruntime" - g++ -std=c++11 $BUILD_SOURCESDIRECTORY/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi/C_Api_Sample.cpp $inc $libs -Wunused-result -Wformat=0 -o sampletest - libName=$(otool -L ./sampletest | grep onnxruntime | xargs | cut -d' ' -f1 | cut -d'/' -f2) - ln -sf runtimes/osx-x64/native/libonnxruntime.dylib $libName - else - export LD_LIBRARY_PATH=$LocalNuGetRepo/_tmp:${LD_LIBRARY_PATH} - libs="-L runtimes/linux-x86/native -L runtimes/linux-x64/native -l onnxruntime" - g++ -std=c++11 $BUILD_SOURCESDIRECTORY/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests.Capi/C_Api_Sample.cpp $inc $libs -Wunused-result -o sampletest - # Create link to versioned shared object required at runtime - libname=`ldd sampletest | grep onnxruntime | xargs | cut -d" " -f1` - ln -sf runtimes/linux-x64/native/libonnxruntime.so $libname - fi - - # Copy Sample Model - cp $BUILD_SOURCESDIRECTORY/csharp/testdata/squeezenet.onnx . - - # Run the sample model - ./sampletest - popd - rm -rf $TempDir -fi cd $OldDir - +popd \ No newline at end of file