Skip to content

Layer dev#2406

Closed
walrusmcd wants to merge 43 commits intowindowsaifrom
layer_dev
Closed

Layer dev#2406
walrusmcd wants to merge 43 commits intowindowsaifrom
layer_dev

Conversation

@walrusmcd
Copy link
Contributor

temp

Ryan Lai and others added 7 commits November 7, 2019 16:50
* Task 23998197: add winml_lib_core into onnnxruntime.dll

* PR feedback
build break on perf_test
#2382)

this is a big PR.    we are going to move it up to layer_dev , which is still a L3 so we are still safe to do work there agile.

we are going to move this into the L3 so that ryan can start doing intergration testing.   

we will pause for a full code review and integration test result prior to going into the L2.

>>>> raw comments from previous commits >>> 

* LearningModelSession is cleaned up to use the adapter, and parts of binding are.
* moved everything in the winmladapter
made it all nano-com using, WRL to construct objects in the ORT side.
base interfaces for everythign for winml to call
cleaned up a bunch of winml to use the base interfaces.
* more pieces
* GetData across the abi.
* renamed some namepsace
cleaned up OrtValue
cleaned up Tensor
cleaned up custom ops.
everything *but* learnignmodel should be clean
* make sure it's building.   winml.dll is still a monolith.
everything builds clean.
step !
@walrusmcd walrusmcd requested a review from a team as a code owner November 15, 2019 19:27
set(CMAKE_${type}_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_${type}_LINKER_FLAGS_RELWITHDEBINFO} /OPT:REF,ICF,LBR")
set(CMAKE_${type}_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_${type}_LINKER_FLAGS_RELWITHDEBINFO} /INCREMENTAL:NO")
foreach(type EXE STATIC SHARED)
if (NOT type MATCHES STATIC)
Copy link
Contributor

@martinb35 martinb35 Nov 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

STATIC [](start = 29, length = 6)

does this affect other binaries or just ours? #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding the STATIC in here makes it affect all static link libs. it seemed to make sense to apply everywhere. the problem is the linker has to take 2 passes if it needs to use LTCG and you didn't tell it before hand. so all the static link libs where starting their link phase, then resetting once they realized they needed LTCG.


In reply to: 347038839 [](ancestors = 347038839)

${PROVIDERS_NUPHAR}
${PROVIDERS_DML}
${PROVIDERS_ACL}
${onnxruntime_winml}
Copy link
Contributor

@martinb35 martinb35 Nov 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[](start = 0, length = 1)

spaces #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch !


In reply to: 347039014 [](ancestors = 347039014)

# add it to the onnxruntime shared library
set(onnxruntime_winml windowsapp.lib -WHOLEARCHIVE:$<TARGET_FILE:winml_lib_core>)
list(APPEND onnxruntime_EXTERNAL_DEPENDENCIES winml_lib_core)

Copy link
Contributor

@martinb35 martinb35 Nov 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this going to live here in the final version? seems odd to add things to a different project #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that was the idea. onnxruntime_EXTERNAL_DEPENDENCIES is a property setup just for this purpose. for other cmake files to add things to the the final shared_lib


In reply to: 347039511 [](ancestors = 347039511)

#target_link_libraries(winml_dll PRIVATE onnxruntime_providers_dml)
#target_link_libraries(winml_dll PRIVATE onnxruntime_session)
#target_link_libraries(winml_dll PRIVATE onnxruntime_util)
#target_link_libraries(winml_dll PRIVATE onnx_proto)
Copy link
Contributor

@martinb35 martinb35 Nov 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just delete these instead of commenting? #Closed

target_link_libraries(winml_dll PRIVATE windowsapp.lib)
target_link_libraries(winml_dll PRIVATE winml_lib_api)
target_link_libraries(winml_dll PRIVATE winml_lib_core)
#target_link_libraries(winml_dll PRIVATE winml_lib_core)
Copy link
Contributor

@martinb35 martinb35 Nov 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete #Closed

#target_link_libraries(winml_dll PRIVATE winml_lib_core)
target_link_libraries(winml_dll PRIVATE winml_lib_image)
target_link_libraries(winml_dll PRIVATE winml_lib_telemetry)
target_link_libraries(winml_dll PRIVATE onecoreuap_apiset.lib)
Copy link
Contributor

@martinb35 martinb35 Nov 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onecoreuap_apiset [](start = 40, length = 17)

intentional? you replaced onecoreuap_apiset.lib with windowsapp.lib

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, not sure why i did that.


In reply to: 347039801 [](ancestors = 347039801)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't seem resolved yet...


In reply to: 347539379 [](ancestors = 347539379,347039801)

default:
return E_FAIL;
}
}
Copy link
Contributor

@martinb35 martinb35 Nov 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this exists somewhere else, too right? in winml somewhere. can we share it instead of copying it? #Closed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nm. I see now that you removed it from the winml spot


In reply to: 347040246 [](ancestors = 347040246)

TensorKind KeyKind,
ILearningModelFeatureDescriptor ValueDescriptor
);
}
Copy link
Contributor

@martinb35 martinb35 Nov 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to do API review? #Closed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also can you explain what these new methods are for?


In reply to: 347040835 [](ancestors = 347040835)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep. we will need an API review. these new methogs allow creation of feature descriptors outside the runtime (the code comment there). basically before this change you could never create these on their own but had to have the runtime make then inside of models and return them. this change adds a factory so that other people can create them. ORT creates them in this PR. and in the future people like Vision Skills could create then also. it makes them reusable currencies.


In reply to: 347040969 [](ancestors = 347040969,347040835)

bool& use_fp16);

void
OverrideShapeInferenceMethods();
Copy link
Contributor

@martinb35 martinb35 Nov 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OverrideShapeInferenceMethods [](start = 2, length = 29)

where did this method go? #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IWinMLAdapter::OverrideSchemaInferenceFunctions()


In reply to: 347041742 [](ancestors = 347041742)

_winmla::IIOBinding* LearningModelBinding::BindingCollection() {
_winmla::IIOBinding* p;
m_lotusBinding.copy_to(&p);
return p;
Copy link
Contributor

@martinb35 martinb35 Nov 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this a copy or an add-ref? #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copy_to bumps the ref, so it is returning a strong ref. the caller needs to handle it. in this case there is one caller, in learningmodelsession.cpp line #206


In reply to: 347042063 [](ancestors = 347042063)

auto& io_binding = binding_impl->BindingCollection();
auto& bound_output_names = io_binding.GetOutputNames();
com_ptr<_winmla::IIOBinding> io_binding;
io_binding.attach(binding_impl->BindingCollection());
Copy link
Contributor

@martinb35 martinb35 Nov 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spacing #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch !


In reply to: 347042505 [](ancestors = 347042505)


// Invoke run on the ORT session.
WINML_THROW_IF_NOT_OK(inference_session_->Run(run_options, io_binding));
WINML_THROW_IF_FAILED(inference_session_->Run(&run_options, io_binding.get()));
Copy link
Contributor

@martinb35 martinb35 Nov 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WINML_THROW_IF_FAILED [](start = 2, length = 21)

NOT_OK is not the same as FAILED - why this change? #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope. not the same. NOT_OK is for status.IsOK() checks. This moved from an InferenceSession (ort type) to a IInferenceSession (com_ptr) and uses HRESULTS now across the ABI. So it had to change from NOT_OK to FAILED.


In reply to: 347042739 [](ancestors = 347042739)


// class AbiSafeTensor
//
class AbiSafeTensor : public Microsoft::WRL::RuntimeClass <
Copy link
Contributor

@martinb35 martinb35 Nov 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AbiSafe [](start = 6, length = 7)

are these names temporary? I don't love the "ABISafe" prefix... #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

temporary.


In reply to: 347043931 [](ancestors = 347043931)

ITensor> {
private:
onnxruntime::Tensor& tensor_; // weak ref
ComPtr<IOrtValue> value_; // strong ref
Copy link
Contributor

@martinb35 martinb35 Nov 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe our code convention puts data members at the end of a class, right? #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably. i changed it to the top when the classes are coded inside the CPP file (also not something we normally do) . when you put them at the bottom they are much harder to find.


In reply to: 347044267 [](ancestors = 347044267)

THROW_HR_IF_MSG(
E_FAIL,
0 > file_descriptor,
"Failed"); //errno
Copy link
Contributor

@martinb35 martinb35 Nov 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you integrate the file not found change I just made? #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how do i do that?


In reply to: 347044532 [](ancestors = 347044532)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HRESULT STDMETHODCALLTYPE OrtGetWinMLAdapter(IWinMLAdapter** adapter) {
// make an adapter instance
Microsoft::WRL::ComPtr<WinMLAdapter> adapterptr = wil::MakeOrThrow<WinMLAdapter>();
return adapterptr.CopyTo(__uuidof(IWinMLAdapter), (void **)adapter);
Copy link
Contributor

@martinb35 martinb35 Nov 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(void **) [](start = 54, length = 9)

static_cast? #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static_cast doesn't work to void ** . fun, right?

https://stackoverflow.com/questions/3625410/c-static-cast-from-float-to-void


In reply to: 347044742 [](ancestors = 347044742)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reinterpret! that's what I meant. my bad.


In reply to: 347542211 [](ancestors = 347542211,347044742)

Copy link
Contributor

@martinb35 martinb35 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🕐

* model moved over.
everything builds clean.
step !

* weak ref comment

* added a wrapper for RoGetActivationFactory to hook back into winml for creating winml objects.
fixes model load.
${PROVIDERS_NUPHAR}
${PROVIDERS_DML}
${PROVIDERS_ACL}
${onnxruntime_winml}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onnxruntime_winml [](start = 6, length = 17)

Should the naming have adapter / core in there? I had to check in winml.cmake to double check which lib(s) were getting included

}
std::vector<IOrtValue*>& STDMETHODCALLTYPE GetOutputs() override {
auto output_inner = binding_->GetOutputs();
outputs_.clear();
Copy link
Contributor

@ryanlai2 ryanlai2 Nov 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also need to clear outputs_weak vector holding a vector of weak ptrs :) #Closed

* model moved over.
everything builds clean.
step !

* weak ref comment

* added a wrapper for RoGetActivationFactory to hook back into winml for creating winml objects.
fixes model load.

* fixed some lifetime management.
fixed the debug build.
squeezenet passes using winmlrunner for CPU and GPU

* PR feedback.

* couple of fixes and coded getmutabledata()
* model moved over.
everything builds clean.
step !

* weak ref comment

* added a wrapper for RoGetActivationFactory to hook back into winml for creating winml objects.
fixes model load.

* fixed some lifetime management.
fixed the debug build.
squeezenet passes using winmlrunner for CPU and GPU

* PR feedback.

* couple of fixes and coded getmutabledata()

* fixed 2 more heap corruptions
found a leak in nvidia driver, but skipped it.
all winmlapitests pass now
#include "ImageFeatureDescriptor.h"
#include "api.image/inc/D3DDeviceCache.h"

#include "PheonixSingleton.h"
Copy link
Contributor

@ryanlai2 ryanlai2 Nov 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already included "PheonixSingleton.h" up above #Closed

ryanlai2 and others added 17 commits November 22, 2019 07:23
* Register WinML TraceLogging provider on Onnxruntime.dll

* Add ifdef to make sure trace logging provider has telemetry option when LAYERING_DONE

* No need for ifdef for TraceLoggingOptionMicrosoftTelemetry

* PR feedback

* Move etw registration into lotus environment constructor and deresgister in lotus environment destructor
* allow building winml cpu without dml.
* fix some more breaks

* learning model doesn't need lotusEnvironment and CPU shouldn't include dmlEP headers

* move dml checks out of winml and into the adapter

* better error handling
* learning model doesn't need lotusEnvironment and CPU shouldn't include dmlEP headers

* User/xianz/win ml telemetry (#2410)

* add option to enable winml telemetry

* add option to enable winml telemetry

* clean logs while developping

* clean the log of GUID

* compile onnxruntime_common with winml telemetry

* use option for use_telemetry

* rename option winml_use_telemetry to onnxruntime_use_telemetry

* little change

* Add opset and IR check when loading model (#2413)

* Add opset and IR check.
* Add test case for future opsets.

#2371

* WinML CI (#2412)

* Pass flags to build/test WinML in CI

* Add initial CMake config for unit tests in WinML

* Set winml_unittests standard to C++17

* Add WinML API tests and port them to googletest

* Install WinML test collateral

* Add LearningModelSessionAPITests ported to googletest

* Fix WinML test files encoding

* Add GPU tests

* Add parameterized test, skip GPU tests

* Enable precompiled header

* Remove unused code and collateral

* Remove brand images

* Add dllload.cpp

* Remove images not used in API tests

* Add LICENSE.md to image collaterals

* Add models with licenses

* Remove FNS Candy tests

* Add API test models

* Add ModelInSubdirectory

* Install collaterals post-build with copy_if_different, split common lib

* fix warnings

* Link to gtest_main

* fix bad merge
* add missing ir version to dictvectorizer-string.onnx

* add missing ir version to relu.onnx

* add missing ir version to zipmap*onnx

* add IR version to manually generated models

* remove an unnecessary ifdef dml
* Add scenario tests

* Remove TODO from model license

* Add winml_api test dependency
* commetns for dml graph transformer
fixed ort value passing using the allocatir info

* fixed and coded maps and sequences across the abi
* Support test parameters through CLI arguments

* Add WinML do Windows x86/ARM CI builds

* Code style fixes

* Update googletest

Remove GPUTEST macros everywhere now that GTEST_SKIP is supported

* Refactor main.cpp

* Build scenario tests without DML
@walrusmcd walrusmcd closed this Nov 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants