Layer dev paulm (#2567)

* commetns for dml graph transformer
fixed ort value passing using the allocatir info

* fixed and coded maps and sequences across the abi

* cleaned up w4's
cleaned up the model info ABI
delayload directml.dll from winml

* cleaned up namepsace aliases.
renamed _winmla to winmla
this was good PR feedback from tiago a while back.

* moved files from inc to lib\api.core
cleaned up some of the cmake

* staged changes

* making windowsAI azure dev ops work.

* code review comments.

* revert changes
This commit is contained in:
Paul McDaniel 2019-12-05 18:14:20 -08:00 committed by GitHub
parent 9933b8a5d6
commit 56cbd82c71
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 15 additions and 40 deletions

View file

@ -75,7 +75,9 @@ ORT_DEFINE_RELEASE(Value);
// This is used internally by the C++ API. This is the common base class used by the wrapper objects.
template <typename T>
struct Base {
Base() = default;
Base() {
p_ = nullptr;
}
Base(T* p) : p_{p} {
if (!p) throw Ort::Exception("Allocation failure", ORT_FAIL);
}
@ -95,7 +97,7 @@ struct Base {
}
T** put() noexcept {
//ASSERT(p_ == nullptr);
assert(p_ == nullptr);
return &p_;
}

View file

@ -10,8 +10,6 @@
#include "core/framework/op_kernel.h"
#include <DirectML.h>
struct AbstractOperatorDesc;
interface IMLOperatorTensor;

View file

@ -8,11 +8,6 @@
#include "core/framework/utils.h"
namespace onnxruntime {
IOBinding::~IOBinding() {
feeds_.clear();
outputs_.clear();
}
IOBinding::IOBinding(const SessionState& session_state) : session_state_(session_state) {
}

View file

@ -38,7 +38,6 @@ class SessionState;
*/
class IOBinding {
public:
~IOBinding();
/**
* Call repeatedly to bind as many inputs as required.
* If called again for the same name will replace an existing value.

View file

@ -1,7 +0,0 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#pragma once
namespace Windows::AI::MachineLearning {
} // namespace Windows::AI::MachineLearning

View file

@ -1,8 +0,0 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#pragma once
namespace Windows::AI::MachineLearning {
} // namespace Windows::AI::MachineLearning

View file

@ -15,7 +15,7 @@ using namespace WinML;
namespace winrt::Windows::AI::MachineLearning::implementation {
LearningModelBinding::LearningModelBinding(
Windows::AI::MachineLearning::LearningModelSession const& session) try : m_session(session) {
Windows::AI::MachineLearning::LearningModelSession const& session) try : m_session(session) {
session.as<winmlp::LearningModelSession>()->CheckClosed();
WINML_THROW_IF_FAILED(OrtGetWinMLAdapter(adapter_.put()));
}
@ -219,12 +219,12 @@ bool LearningModelBinding::HasKey(hstring const& key) {
void LearningModelBinding::Split(
Windows::Foundation::Collections::IMapView<hstring, Windows::Foundation::IInspectable>& first,
Windows::Foundation::Collections::IMapView<hstring, Windows::Foundation::IInspectable>& second) {
ORT_UNUSED_PARAMETER(first);
ORT_UNUSED_PARAMETER(second);
throw hresult_not_implemented();
// the winrt api guide states:
// If the IMapView instance cannot be split, then both the first and second parameters are null when the method returns.
first = nullptr;
second = nullptr;
}
ONNXTensorElementDataType STDMETHODCALLTYPE GetONNXTensorElementDataType(winml::TensorKind kind) {
if (kind == TensorKind::Float) {
return ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT;
@ -275,7 +275,6 @@ bool LearningModelBinding::IsOfMapType(const Ort::Value& ort_value, TensorKind k
};
bool LearningModelBinding::IsOfVectorMapType(const Ort::Value& ort_value, TensorKind key_kind, TensorKind value_kind) {
if (ort_value.GetTypeInfo().GetONNXType() != ONNX_TYPE_SEQUENCE)
return false;
@ -305,7 +304,7 @@ ILearningModelFeatureValue LearningModelBinding::CreateUnboundOuputFeatureValue(
if (descriptor.Kind() == LearningModelFeatureKind::Image) {
using namespace Windows::Graphics::Imaging;
// TODO: this format for unbound output needs more discussion
BitmapPixelFormat format = descriptor.as<ImageFeatureDescriptor>()->BitmapPixelFormat();
BitmapPixelFormat format = descriptor.as<ImageFeatureDescriptor>()->BitmapPixelFormat();
uint32_t width = static_cast<uint32_t>(ort_value.GetTensorTypeAndShapeInfo().GetShape()[3]);
uint32_t height = static_cast<uint32_t>(ort_value.GetTensorTypeAndShapeInfo().GetShape()[2]);
uint32_t batchSize = static_cast<uint32_t>(ort_value.GetTensorTypeAndShapeInfo().GetShape()[0]);
@ -388,7 +387,7 @@ ILearningModelFeatureValue LearningModelBinding::CreateUnboundOuputFeatureValue(
Windows::Foundation::IInspectable LearningModelBinding::CreateUnboundOutput(
const std::string& name,
Ort::Value& ort_value) {
Ort::Value& ort_value) {
// Find valid binding port
auto bindingPort = FindValidBinding(
m_session.Model(),
@ -539,8 +538,8 @@ HRESULT LearningModelBinding::BindInput(const std::string& name, Ort::Value& ml_
if (ml_value.IsTensor()) {
Ort::Value new_mlvalue = Ort::Value(nullptr);
WINML_THROW_IF_FAILED(m_session.as<LearningModelSession>()
->GetIInferenceSession()
->CopyOneInputAcrossDevices(name.c_str(), ml_value, new_mlvalue.put()));
->GetIInferenceSession()
->CopyOneInputAcrossDevices(name.c_str(), ml_value, new_mlvalue.put()));
add_or_replace(rc.first, rc.second, new_mlvalue);
} else {
add_or_replace(rc.first, rc.second, ml_value);
@ -574,8 +573,7 @@ const std::vector<std::string>& LearningModelBinding::GetInputNames() const {
const std::vector<Ort::Value>& LearningModelBinding::GetInputs() const { return inputs_; }
void LearningModelBinding::BindUnboundOutputs()
{
void LearningModelBinding::BindUnboundOutputs() {
auto& bound_output_names = GetOutputNames();
std::unordered_set<std::string> bound_output_names_set(
bound_output_names.begin(),

View file

@ -109,7 +109,7 @@ void LearningModelSession::Initialize() {
device_impl->GetDeviceQueue(),
session_builder.put()));
Ort::SessionOptions options;
Ort::SessionOptions options(nullptr);
WINML_THROW_IF_FAILED(session_builder->CreateSessionOptions(options.put()));
// Make onnxruntime apply the batch size override, if any

View file

@ -47,7 +47,6 @@ struct MapBase : winrt::implements<
using LotusKey = typename ValidLotusType<TKey>::Type;
using LotusValue = typename ValidLotusType<TValue>::Type;
//using LotusMap = std::map<LotusKey, LotusValue>;
using LotusMap = std::pair<std::vector<LotusKey>, std::vector<LotusValue>>;
using ABIMap = ::winrt::Windows::Foundation::Collections::IMap<TKey, TValue>;
using ABIMapView = ::winrt::Windows::Foundation::Collections::IMapView<TKey, TValue>;

View file

@ -4,7 +4,6 @@
#pragma once
#include "TensorBuffer.h"
#include "MLValueHelpers.h"
// we further specialize these base types for a couple of extra tensor element types
namespace Ort {