Skip to content

Ryanunderhill/mkldnn dll - #2114

Closed
RyanUnderhill wants to merge 14 commits into
masterfrom
ryanunderhill/mkldnn_dll
Closed

Ryanunderhill/mkldnn dll#2114
RyanUnderhill wants to merge 14 commits into
masterfrom
ryanunderhill/mkldnn_dll

Conversation

@RyanUnderhill

Copy link
Copy Markdown
Contributor

Description: Initial test layer to make mkldnn provider build as a shared library

NOTE: This is still a test, talk to me if you want to seriously review it

@RyanUnderhill
RyanUnderhill requested a review from a team as a code owner October 12, 2019 03:14
@jywu-mysoft

Copy link
Copy Markdown
Contributor

note this PR: #2102

@snnn

snnn commented Oct 22, 2019

Copy link
Copy Markdown
Contributor

I think we should build protobuf and onnx as shared library, it will ease the effort of sharing them between DLLs.

Comment thread cmake/CMakeLists.txt
# list(APPEND onnxruntime_EXTERNAL_LIBRARIES mkldnn)
# list(APPEND onnxruntime_EXTERNAL_DEPENDENCIES project_mkldnn)
# link_directories(${MKLDNN_LIB_DIR})
#endif()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do you plan on keeping it?

@yuslepukhin

Copy link
Copy Markdown
Contributor

You know it is not possible to export STL components.


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

const int default_max_vlog_level_;
bool owns_default_logger_;

public: // TODO: Made public only for the provider bridge. Should be changed to a method to get this instead

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

hould be changed to a method to get this instea [](start = 62, length = 47)

Any reason not to do it in this PR?

template <>
MLDataType DataTypeImpl::GetType<bool>() {
return nullptr;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's remove TABs everywhere.

}

// Override default new/delete so that we match the host's allocator
void* operator new(size_t n) { return g_host->HeapAllocate(n); }

@yuslepukhin yuslepukhin Jan 2, 2020

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You need to add array versions of these and I would add nothrow overloads too so we do not scratch our heads when debugging. Add noexcept to all of delete as well per C++11.

}

struct Provider {
virtual std::shared_ptr<IExecutionProviderFactory> CreateExecutionProviderFactory(int device_id) = 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

std::shared_ptr [](start = 10, length = 15)

Can we return this as unique_ptr and whoever needs can convert that unique_ptr to shared?

// a specific implementation of a virtual class member. Trying to get a pointer to member of a virtual function will return a thunk that
// calls the virtual function (which will lead to infinite recursion in the bridge). There is no known way to get the non virtual member
// function pointer implementation in this case.
struct ProviderHost {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ProviderHost [](start = 7, length = 12)

This struct needs a virtual destructor

onnx::TensorProto* (*google_protobuf_Arena_CreateMaybeMessage_onnx_TensorProto)(google::protobuf::Arena*);

// Special functions in bridge_special.h that route through these
virtual void onnx_AttributeProto_constructor(void* _this) = 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

_this [](start = 53, length = 5)

All leading underscores are not per standard. Someone actually opened an issue on GH

// calls the virtual function (which will lead to infinite recursion in the bridge). There is no known way to get the non virtual member
// function pointer implementation in this case.
struct ProviderHost {
virtual logging::Logger* LoggingManager_GetDefaultLogger() = 0;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

_G [](start = 41, length = 2)

Underscore followed by a capital character are all reserved by the implementation no matter where occurs.


inline int
ToIntSize(size_t size) {
return static_cast<int>(size);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

return static_cast(size); [](start = 2, length = 30)

The value of this function might be greater if in DEBUG builds it could check if the the value of size does not exceed std::numeric_limits::max().

@@ -0,0 +1,11 @@
void onnx_AttributeProto_constructor(void* _this);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

onnx_AttributeProto [](start = 4, length = 20)

Header?

@@ -0,0 +1,84 @@
#include <string>
#include "bridge_special.h"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Header

@@ -0,0 +1,18 @@
#include <string>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Header


std::shared_ptr<IExecutionProviderFactory> CreateExecutionProviderFactory_Mkldnn(int device_id) {
void* handle;
Env::Default().LoadDynamicLibrary("C:\\code\\github\\onnxrt\\build\\windows\\debug\\debug\\onnxruntime_providers_mkldnn.dll", &handle);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

"C:\code\github\onnxrt\build\windows\de [](start = 36, length = 45)

Needs to be addressed.

@RyanUnderhill
RyanUnderhill deleted the ryanunderhill/mkldnn_dll branch January 6, 2020 21:20
yuslepukhin pushed a commit that referenced this pull request Mar 17, 2026
## Describe your changes

## Checklist before requesting a review
- [ ] Add unit tests for this change.
- [ ] Make sure all tests can pass.
- [ ] Update documents if necessary.
- [ ] Lint and apply fixes to your code by running `lintrunner -a`
- [ ] Is this a user-facing change? If yes, give a description of this
change to be included in the release notes.
- [ ] Is this PR including examples changes? If yes, please remember to
update [example
documentation](https://github.com/microsoft/Olive/blob/main/docs/source/examples.md)
in a follow-up PR.

## (Optional) Issue link
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