Merge remote-tracking branch 'upstream/master' into DmlDev

This commit is contained in:
ISS Build Account 2020-06-09 17:59:03 +00:00
commit 559d2c0c9c
17 changed files with 156 additions and 50 deletions

View file

@ -138,5 +138,5 @@ CMake creates a target to this project
<Output TaskParameter="ConsoleOutput" PropertyName="OutputOfExec" />
</Exec>
</Target>
</Project>

View file

@ -0,0 +1 @@
Generated Files

View file

@ -0,0 +1,48 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectName>Microsoft.AI.MachineLearning.Interop</ProjectName>
<TargetFramework>netstandard2.0</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Platform>Any CPU</Platform>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<OnnxRuntimeBuildDirectory Condition="'$(OnnxRuntimeBuildDirectory)'==''">..\..\..\build\Windows</OnnxRuntimeBuildDirectory>
<BuildOutputDir>$(OnnxRuntimeBuildDirectory)\$(Configuration)\$(Configuration)</BuildOutputDir>
<WindowsAIInteropOutputDir>$(BuildOutputDir)\Microsoft.AI.MachineLearning.Interop</WindowsAIInteropOutputDir>
<OutputPath>$(WindowsAIInteropOutputDir)</OutputPath>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="0.1.0-prerelease.200512.7" targetFramework="net46" />
<PackageReference Include="Microsoft.Windows.SDK.NET" Version="10.0.18362.3-preview" />
</ItemGroup>
<ItemGroup>
<Folder Include="Generated Files\" />
</ItemGroup>
<Target Name="GenerateProjection" BeforeTargets="DispatchToInnerBuilds;Build;CoreCompile">
<ConvertToAbsolutePath Paths="$(OnnxRuntimeBuildDirectory)">
<Output TaskParameter="AbsolutePaths" PropertyName="OnnxRuntimeBuildDirectoryAbs"/>
</ConvertToAbsolutePath>
<ItemGroup>
<WindowsAIsWinMDs Include="$(OnnxRuntimeBuildDirectoryAbs)\$(Configuration)\Microsoft.AI.MachineLearning.winmd" />
</ItemGroup>
<PropertyGroup>
<CsWinRTCommand>$(CsWinRTPath)cswinrt.exe -verbose -in local -in @(WindowsAIsWinMDs->'"%(FullPath)"', ' ') -out "$(ProjectDir)Generated Files" -include Microsoft.AI.MachineLearning</CsWinRTCommand>
</PropertyGroup>
<Message Text="Generating $(ProjectName) CS projection sources with command:"/>
<Message Text="$(CsWinRTCommand)"/>
<Exec Command="$(CsWinRTCommand)" />
<ItemGroup>
<Compile Include="$(ProjectDir)Generated Files/*.cs" Exclude="@(Compile)" />
</ItemGroup>
</Target>
</Project>

View file

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WindowsAI-Platform Condition="'$(PlatformTarget)' == 'x64' OR ('$(PlatformTarget)' == 'AnyCPU' AND '$(Prefer32Bit)' != 'true')">x64</WindowsAI-Platform>
<WindowsAI-Platform Condition="'$(PlatformTarget)' == 'x86' OR ('$(PlatformTarget)' == 'AnyCPU' AND '$(Prefer32Bit)' == 'true')">x86</WindowsAI-Platform>
<WindowsAI-Platform Condition="'$(WindowsAI-Platform)' == ''">$(PlatformTarget)</WindowsAI-Platform>
</PropertyGroup>
<PropertyGroup>
<WindowsAIBinary>$(MSBuildThisFileDirectory)..\..\runtimes\win-$(WindowsAI-Platform)\native\Microsoft.AI.MachineLearning.dll</WindowsAIBinary>
<OnnxRuntimeBinary>$(MSBuildThisFileDirectory)..\..\runtimes\win-$(WindowsAI-Platform)\native\onnxruntime.dll</OnnxRuntimeBinary>
<DirectMLBinary>$(MSBuildThisFileDirectory)..\..\runtimes\win-$(WindowsAI-Platform)\native\directml.dll</DirectMLBinary>
</PropertyGroup>
<PropertyGroup>
<MLBinaries>$(WindowsAIBinary);$(OnnxRuntimeBinary);$(DirectMLBinary)</MLBinaries>
</PropertyGroup>
<PropertyGroup Condition="'$(WindowsAI-Platform)' == x64 OR '$(WindowsAI-Platform)' == x86">
<MLBinaries>$(WindowsAIBinary);$(OnnxRuntimeBinary);$(DirectMLBinary)</MLBinaries>
</PropertyGroup>
<PropertyGroup Condition="'$(WindowsAI-Platform)' == arm OR '$(WindowsAI-Platform)' == arm64">
<MLBinaries>$(WindowsAIBinary);$(OnnxRuntimeBinary)</MLBinaries>
</PropertyGroup>
<Target Name="CopyMLBinaries" BeforeTargets="CoreBuild">
<PropertyGroup>
<WindowsAIBinplaceMessage>Binplacing WindowsAI binaries: {0} and {1}.</WindowsAIBinplaceMessage>
</PropertyGroup>
<Message Text="$([System.String]::Format('$(WindowsAIBinplaceMessage)', '$(WindowsAIBinary)', '$(OnnxRuntimeBinary)'))" />
<Copy SkipUnchangedFiles="True" SourceFiles="$(MLBinaries)" DestinationFolder="$(OutDir)" />
</Target>
</Project>

View file

@ -576,6 +576,7 @@ namespace Microsoft.ML.OnnxRuntime.Tests
skipModels["tf_nasnet_large"] = "Get preallocated buffer for initializer ConvBnFusion_BN_B_cell_11/beginning_bn/beta:0_331 failed";
skipModels["test_zfnet512"] = "System out of memory";
skipModels["test_bvlc_reference_caffenet"] = "System out of memory";
skipModels["coreml_VGG16_ImageNet"] = "System out of memory";
}
return skipModels;
@ -1745,9 +1746,13 @@ namespace Microsoft.ML.OnnxRuntime.Tests
}
static NamedOnnxValue LoadTensorFromFilePb(string filename, IReadOnlyDictionary<string, NodeMetadata> nodeMetaDict)
{
var file = File.OpenRead(filename);
var tensor = Onnx.TensorProto.Parser.ParseFrom(file);
file.Close();
//Set buffer size to 4MB
int readBufferSize = 4194304;
Onnx.TensorProto tensor = null;
using (var file = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read, readBufferSize))
{
tensor = Onnx.TensorProto.Parser.ParseFrom(file);
}
Type tensorElemType = null;
int width = 0;

View file

@ -1425,7 +1425,7 @@ public class InferenceTest {
private static StringTensorPair loadTensorFromFilePb(
OrtEnvironment env, File filename, Map<String, NodeInfo> nodeMetaDict)
throws IOException, OrtException {
InputStream is = new BufferedInputStream(new FileInputStream(filename));
InputStream is = new BufferedInputStream(new FileInputStream(filename), 1024 * 1024 * 4);
OnnxMl.TensorProto tensor = OnnxMl.TensorProto.parseFrom(is);
is.close();

View file

@ -24,7 +24,9 @@
using namespace ONNX_NAMESPACE;
using namespace onnxruntime;
using namespace ::onnxruntime::common;
using namespace onnxruntime::common;
static constexpr int protobuf_block_size_in_bytes = 4 * 1024 * 1024;
namespace onnxruntime {
Model::Model(const std::string& graph_name,
@ -237,7 +239,7 @@ Status Model::Load(std::istream& model_istream, ModelProto* p_model_proto) {
if (!p_model_proto) {
return Status(ONNXRUNTIME, INVALID_ARGUMENT, "Null model_proto ptr.");
}
google::protobuf::io::IstreamInputStream zero_copy_input(&model_istream, 1 << 20);
google::protobuf::io::IstreamInputStream zero_copy_input(&model_istream, protobuf_block_size_in_bytes);
const bool result = p_model_proto->ParseFromZeroCopyStream(&zero_copy_input) && model_istream.eof();
if (!result) {
return Status(ONNXRUNTIME, INVALID_PROTOBUF, "Failed to load model because protobuf parsing failed.");
@ -447,7 +449,7 @@ Status Model::Load(int fd, ONNX_NAMESPACE::ModelProto& model_proto) {
}
#if GOOGLE_PROTOBUF_VERSION >= 3002000
FileInputStream input(fd, 1 << 20);
FileInputStream input(fd, protobuf_block_size_in_bytes);
const bool result = model_proto.ParseFromZeroCopyStream(&input) && input.GetErrno() == 0;
if (!result) {
return Status(ONNXRUNTIME, INVALID_PROTOBUF, "Protobuf parsing failed.");

View file

@ -27,7 +27,7 @@ using namespace onnxruntime;
using namespace onnxruntime::common;
using google::protobuf::RepeatedPtrField;
static constexpr int protobuf_block_size_in_bytes = 1 << 20;
static constexpr int protobuf_block_size_in_bytes = 4 * 1024 * 1024;
using ORT_VALUE_HOLDER = std::unique_ptr<OrtValue, decltype(Ort::GetApi().ReleaseValue)>;

View file

@ -451,7 +451,7 @@ int real_main(int argc, char* argv[], Ort::Env& env) {
}
#if !defined(__amd64__) && !defined(_M_AMD64)
//out of memory
static const ORTCHAR_T* x86_disabled_tests[] = {ORT_TSTR("mlperf_ssd_resnet34_1200"), ORT_TSTR("mask_rcnn_keras"), ORT_TSTR("mask_rcnn"), ORT_TSTR("faster_rcnn"), ORT_TSTR("vgg19")};
static const ORTCHAR_T* x86_disabled_tests[] = {ORT_TSTR("mlperf_ssd_resnet34_1200"), ORT_TSTR("mask_rcnn_keras"), ORT_TSTR("mask_rcnn"), ORT_TSTR("faster_rcnn"), ORT_TSTR("vgg19"), ORT_TSTR("coreml_VGG16_ImageNet")};
all_disabled_tests.insert(std::begin(x86_disabled_tests), std::end(x86_disabled_tests));
#endif

View file

@ -8,8 +8,10 @@
#include <core/platform/env.h>
std::unique_ptr<TestModelInfo> TFModelInfo::Create(_In_ const PATH_CHAR_TYPE* model_url) {
auto ret = std::unique_ptr<TFModelInfo>(new TFModelInfo{});
ret->model_url_ = model_url;
auto* model_info = new TFModelInfo{};
std::unique_ptr<TestModelInfo> ret(model_info);
model_info->model_url_ = model_url;
std::basic_string<PATH_CHAR_TYPE> meta_file_path = model_url;
meta_file_path.append(ORT_TSTR(".meta"));
const onnxruntime::Env& env = onnxruntime::Env::Default();
@ -40,15 +42,15 @@ std::unique_ptr<TestModelInfo> TFModelInfo::Create(_In_ const PATH_CHAR_TYPE* mo
}
if (line.empty()) continue;
if (line.compare(0, 6, "input=") == 0) {
ret->input_names_.push_back(line.substr(6));
model_info->input_names_.push_back(line.substr(6));
} else if (line.compare(0, 7, "output=") == 0) {
ret->output_names_.push_back(line.substr(7));
model_info->output_names_.push_back(line.substr(7));
} else {
ORT_THROW("unknown line:", line.size());
}
}
return std::move(ret);
return ret;
}
int TFModelInfo::GetInputCount() const { return static_cast<int>(input_names_.size()); }

View file

@ -43,7 +43,7 @@ For a list of available dockerfiles and published images to help with getting st
* [ONNX Runtime with Azure ML](https://github.com/Azure-Samples/onnxruntime-iot-edge/blob/master/AzureML-OpenVINO/README.md)
**Other**
* [Running ONNX model tests](./docs/Model_Test.md)
* [Running ONNX model tests](../docs/Model_Test.md)
* [Common Errors with explanations](https://microsoft.github.io/onnxruntime/python/auto_examples/plot_common_errors.html#sphx-glr-auto-examples-plot-common-errors-py)
## C#

View file

@ -20,22 +20,6 @@ jobs:
script: sudo docker build --pull -t onnxruntime-server-ubuntu16.04 --build-arg BUILD_USER=onnxruntimedev --build-arg BUILD_UID=$(id -u) --build-arg OS_VERSION=16.04 --build-arg PYTHON_VERSION=3.5 -f Dockerfile.ubuntu_server .
workingDirectory: $(Build.SourcesDirectory)/tools/ci_build/github/linux/docker
- task: CmdLine@2
displayName: 'Download azcopy'
inputs:
script: |
curl -so azcopy.tar.gz -L 'https://aka.ms/downloadazcopy-v10-linux'
tar -zxvf azcopy.tar.gz --strip 1
workingDirectory: $(Build.BinariesDirectory)
- task: PythonScript@0
displayName: 'Download test data'
inputs:
scriptPath: '$(Build.SourcesDirectory)/tools/ci_build/github/download_test_data.py'
arguments: --test_data_url $(TestDataUrl) --build_dir $(Build.BinariesDirectory)
pythonInterpreter: '/usr/bin/python3'
workingDirectory: $(Build.BinariesDirectory)
- task: CmdLine@2
displayName: 'Run docker image'
inputs:

View file

@ -135,6 +135,10 @@ steps:
arguments: 'x64'
modifyEnvironment: true
- script: msbuild Microsoft.AI.MachineLearning.Interop.csproj /p:Configuration=RelWithDebInfo /p:Platform="Any CPU" /p:OnnxRuntimeBuildDirectory=$(Build.BinariesDirectory) -restore
workingDirectory: '$(Build.SourcesDirectory)\csharp\src\Microsoft.AI.MachineLearning.Interop'
displayName: 'Build Microsoft.AI.MachineLearning.Interop.dll'
# Esrp signing
- template: win-esrp-dll.yml
parameters:

View file

@ -71,7 +71,24 @@ def generate_repo_url(list, repo_url, commit_id):
def generate_dependencies(list, package_name, version):
if (package_name != 'Microsoft.AI.MachineLearning'):
if (package_name == 'Microsoft.AI.MachineLearning'):
list.append('<dependencies>')
# Support .Net Core
list.append('<group targetFramework="NETCOREAPP">')
list.append('<dependency id="Microsoft.Windows.SDK.NET"' + ' version="10.0.18362.3-preview"/>')
list.append('</group>')
# Support .Net Standard
list.append('<group targetFramework="NETSTANDARD">')
list.append('<dependency id="Microsoft.Windows.SDK.NET"' + ' version="10.0.18362.3-preview"/>')
list.append('</group>')
# Support .Net Framework
list.append('<group targetFramework="NETFRAMEWORK">')
list.append('<dependency id="Microsoft.Windows.SDK.NET"' + ' version="10.0.18362.3-preview"/>')
list.append('</group>')
list.append('</dependencies>')
else:
list.append('<dependencies>')
# Support .Net Core
list.append('<group targetFramework="NETCOREAPP">')
@ -167,7 +184,6 @@ def generate_files(list, args):
'" target="build\\native\\include" />')
if includes_winml:
mlop_path = 'onnxruntime\\core\\providers\\dml\\dmlexecutionprovider\\inc\\mloperatorauthor.h'
# Add microsoft.ai.machinelearning headers
files_list.append('<file src=' + '"' + os.path.join(args.ort_build_path, args.build_config,
'microsoft.ai.machinelearning.h') +
@ -178,14 +194,20 @@ def generate_files(list, args):
files_list.append('<file src=' + '"' + os.path.join(args.ort_build_path, args.build_config,
'microsoft.ai.machinelearning.native.h') +
'" target="build\\native\\include\\Microsoft.AI.MachineLearning.Native.h" />')
# Add custom operator headers
mlop_path = 'onnxruntime\\core\\providers\\dml\\dmlexecutionprovider\\inc\\mloperatorauthor.h'
files_list.append('<file src=' + '"' + os.path.join(args.sources_path, mlop_path) +
'" target="build\\native\\include" />')
# Process microsoft.ai.machinelearning.winmd
files_list.append('<file src=' + '"' + os.path.join(args.ort_build_path, args.build_config,
'microsoft.ai.machinelearning.winmd') +
'" target="lib\\uap10.0\\Microsoft.AI.MachineLearning.winmd" />')
# Add custom operator headers
files_list.append('<file src=' + '"' +
os.path.join(args.sources_path, mlop_path) +
'" target="build\\native\\include" />')
interop_dll = 'Microsoft.AI.MachineLearning.Interop\\netstandard2.0\\Microsoft.AI.MachineLearning.Interop.dll'
files_list.append('<file src=' + '"' + os.path.join(args.native_build_path, interop_dll) +
'" target="lib\\netstandard2.0\\Microsoft.AI.MachineLearning.Interop.dll" />')
interop_pdb = 'Microsoft.AI.MachineLearning.Interop\\netstandard2.0\\Microsoft.AI.MachineLearning.Interop.pdb'
files_list.append('<file src=' + '"' + os.path.join(args.native_build_path, interop_pdb) +
'" target="lib\\netstandard2.0\\Microsoft.AI.MachineLearning.Interop.pdb" />')
# Process runtimes
# Process onnxruntime import lib, dll, and pdb
@ -254,18 +276,24 @@ def generate_files(list, args):
# Process props and targets files
if is_windowsai_package:
# Process props file
windowsai_props = os.path.join(args.sources_path, 'csharp', 'src', 'Microsoft.ML.OnnxRuntime',
'Microsoft.AI.MachineLearning.props')
files_list.append('<file src=' + '"' + windowsai_props + '" target="build\\native" />')
# Process targets files
windowsai_targets = os.path.join(args.sources_path, 'csharp', 'src', 'Microsoft.ML.OnnxRuntime',
'Microsoft.AI.MachineLearning.targets')
files_list.append('<file src=' + '"' + windowsai_targets + '" target="build\\native" />')
# Process rules files
windowsai_rules = os.path.join(args.sources_path, 'csharp', 'src', 'Microsoft.ML.OnnxRuntime',
'Microsoft.AI.MachineLearning.Rules.Project.xml')
files_list.append('<file src=' + '"' + windowsai_rules + '" target="build\\native" />')
windowsai_src = 'Microsoft.AI.MachineLearning'
# Process native props
windowsai_props = 'Microsoft.AI.MachineLearning.props'
windowsai_native_props = os.path.join(args.sources_path, 'csharp', 'src', windowsai_src, windowsai_props)
files_list.append('<file src=' + '"' + windowsai_native_props + '" target="build\\native" />')
# Process native targets
windowsai_targets = 'Microsoft.AI.MachineLearning.targets'
windowsai_native_targets = os.path.join(args.sources_path, 'csharp', 'src', windowsai_src, windowsai_targets)
files_list.append('<file src=' + '"' + windowsai_native_targets + '" target="build\\native" />')
# Process native rules
windowsai_rules = 'Microsoft.AI.MachineLearning.Rules.Project.xml'
windowsai_native_rules = os.path.join(args.sources_path, 'csharp', 'src', windowsai_src, windowsai_rules)
files_list.append('<file src=' + '"' + windowsai_native_rules + '" target="build\\native" />')
# Process .net standard 2.0 targets
interop_src = 'Microsoft.AI.MachineLearning.Interop'
interop_targets = 'Microsoft.AI.MachineLearning.targets'
windowsai_net20_targets = os.path.join(args.sources_path, 'csharp', 'src', interop_src, interop_targets)
files_list.append('<file src=' + '"' + windowsai_net20_targets + '" target="build\\netstandard2.0" />')
if is_cpu_package or is_cuda_gpu_package or is_dml_package or is_mklml_package:
# Process props file