Skip to content

Ryanunderhill/mkldnn dll#2114

Closed
RyanUnderhill wants to merge 14 commits intomasterfrom
ryanunderhill/mkldnn_dll
Closed

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

Conversation

@RyanUnderhill
Copy link
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-msft
Copy link
Member

note this PR: #2102

@snnn
Copy link
Contributor

snnn commented Oct 22, 2019

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

# list(APPEND onnxruntime_EXTERNAL_LIBRARIES mkldnn)
# list(APPEND onnxruntime_EXTERNAL_DEPENDENCIES project_mkldnn)
# link_directories(${MKLDNN_LIB_DIR})
#endif()
Copy link
Member

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
Member

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
Member

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
Member

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); }
Copy link
Member

@yuslepukhin yuslepukhin Jan 2, 2020

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
Member

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
Member

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
Member

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
Member

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
Member

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
Member

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
Member

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
Member

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
Member

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
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