mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-27 20:02:15 +00:00
Fix C API tests for centos and mac (#2544)
* change c++14 to c++11 * add ld lib path for centos * enable csharp tests on macos * fix C API test on MacOS + fix manylinux dotnet install * fix manylinux dotnet install * fix lib link
This commit is contained in:
parent
d34fb62012
commit
281933fa1c
4 changed files with 33 additions and 13 deletions
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include <assert.h>
|
||||
#include <onnxruntime_c_api.h>
|
||||
#include <cmath>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <vector>
|
||||
|
|
@ -146,7 +147,7 @@ int main(int argc, char* argv[]) {
|
|||
// Get pointer to output tensor float values
|
||||
float* floatarr;
|
||||
CheckStatus(g_ort->GetTensorMutableData(output_tensor, (void**)&floatarr));
|
||||
assert(abs(floatarr[0] - 0.000045) < 1e-6);
|
||||
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++)
|
||||
|
|
|
|||
|
|
@ -6,6 +6,11 @@ LocalNuGetRepo=$1
|
|||
SourceRoot=$2
|
||||
BuildDir=$3
|
||||
export CurrentOnnxRuntimeVersion=$4
|
||||
IsMacOS=${5:-false}
|
||||
PackageName=${PACKAGENAME:-Microsoft.ML.OnnxRuntime}
|
||||
RunTestCsharp=${RunTestCsharp:-true}
|
||||
RunTestNative=${RunTestNative:-true}
|
||||
|
||||
set -x
|
||||
|
||||
OldDir=`pwd`
|
||||
|
|
@ -36,13 +41,23 @@ if [ $RunTestNative = "true" ]; then
|
|||
TempDir=_tmp
|
||||
mkdir -p $TempDir && pushd $TempDir
|
||||
unzip ../$PackageName
|
||||
libs="-L runtimes/linux-x86/native -L runtimes/linux-x64/native -l onnxruntime"
|
||||
inc="-I build/native/include"
|
||||
g++ -std=c++14 $SourceRoot/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
|
||||
inc="-I build/native/include"
|
||||
|
||||
if [ $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 $SourceRoot/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 $SourceRoot/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 $SourceRoot/csharp/testdata/squeezenet.onnx .
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
parameters:
|
||||
AgentPool : 'Hosted macOS High Sierra'
|
||||
IsMacOS : 'true'
|
||||
|
||||
jobs:
|
||||
- job: NuGet_Test_MacOS
|
||||
|
|
@ -38,7 +39,8 @@ jobs:
|
|||
$(Build.BinariesDirectory)/nuget-artifact \
|
||||
$(Build.SourcesDirectory) \
|
||||
$(Build.BinariesDirectory) \
|
||||
$(NuGetPackageVersionNumber)
|
||||
$(NuGetPackageVersionNumber) \
|
||||
${{ parameters.IsMacOS }}
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failed to run test"
|
||||
|
|
|
|||
|
|
@ -21,12 +21,14 @@ elif [ "$os_major_version" == "6" ] && [ ! -d "/opt/python/cp35-cp35m" ]; then
|
|||
/usr/bin/python3.6 -m pip install --upgrade pip
|
||||
else
|
||||
yum install -y redhat-lsb-core expat-devel libcurl-devel tar unzip curl zlib-devel make libunwind icu aria2 rsync bzip2 git bzip2-devel
|
||||
# install dotnet core dependencies
|
||||
yum install -y lttng-ust openssl-libs krb5-libs libicu libuuid
|
||||
# install dotnet runtimes
|
||||
yum install -y https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
|
||||
yum install -y dotnet-sdk-2.2
|
||||
|
||||
if [ "$os_major_version" == "7" ]; then
|
||||
# install dotnet core dependencies
|
||||
yum install -y lttng-ust openssl-libs krb5-libs libicu libuuid
|
||||
# install dotnet runtimes
|
||||
yum install -y https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
|
||||
yum install -y dotnet-sdk-2.2
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue