mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-23 19:32:23 +00:00
Fix inefficiencies in the mkldnn kernels. Some of these were (unfortunately) getting replicated in the new kernels. (#241)
This commit is contained in:
parent
7af1887b33
commit
3875511f9e
6 changed files with 16 additions and 17 deletions
|
|
@ -68,7 +68,7 @@ class ConvPrimitive : public PrimitiveBase {
|
|||
~ConvPrimitive() = default;
|
||||
|
||||
void Compute(const T* src_data, const T* filter_data,
|
||||
const T* dst_data, const T* bias_data = nullptr) {
|
||||
T* dst_data, const T* bias_data = nullptr) {
|
||||
context_.src_mem->set_data_handle(
|
||||
static_cast<void*>(const_cast<T*>(src_data)));
|
||||
context_.filter_mem->set_data_handle(
|
||||
|
|
@ -78,7 +78,7 @@ class ConvPrimitive : public PrimitiveBase {
|
|||
static_cast<void*>(const_cast<T*>(bias_data)));
|
||||
}
|
||||
context_.dst_mem->set_data_handle(
|
||||
static_cast<void*>(const_cast<T*>(dst_data)));
|
||||
static_cast<void*>(dst_data));
|
||||
context_.stream->submit(context_.net);
|
||||
|
||||
context_.src_mem->set_data_handle(nullptr);
|
||||
|
|
@ -437,7 +437,7 @@ Status Conv<T>::Compute(OpKernelContext* context) const {
|
|||
DoReorder<T>(params);
|
||||
}
|
||||
|
||||
} catch (mkldnn::error& e) {
|
||||
} catch (const mkldnn::error& e) {
|
||||
return ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, "Status: ", e.status, ", message: ", e.message.c_str());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ namespace mkl_dnn {
|
|||
template <typename T>
|
||||
class Conv final : public onnxruntime::Conv<T> {
|
||||
public:
|
||||
Conv(const OpKernelInfo& info) : onnxruntime::Conv<T>(info) {
|
||||
explicit Conv(const OpKernelInfo& info) : onnxruntime::Conv<T>(info) {
|
||||
}
|
||||
|
||||
Status Compute(OpKernelContext* context) const override;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
|
|
@ -25,13 +24,13 @@ ONNX_OPERATOR_TYPED_KERNEL_EX(
|
|||
namespace {
|
||||
// Struct which encapsulates parameters for MKLDNN LRN primitive.
|
||||
struct LRNParams {
|
||||
mkldnn::memory::dims& dims_;
|
||||
const mkldnn::memory::dims& dims_;
|
||||
float alpha_;
|
||||
float beta_;
|
||||
float bias_;
|
||||
int size_;
|
||||
|
||||
LRNParams(mkldnn::memory::dims& dims, float alpha, float beta, float bias, int size)
|
||||
LRNParams(const mkldnn::memory::dims& dims, float alpha, float beta, float bias, int size)
|
||||
: dims_(dims), alpha_(alpha), beta_(beta), bias_(bias), size_(size) {}
|
||||
|
||||
// Used as the key for LRN Primitive Reuse LRN.
|
||||
|
|
@ -62,9 +61,9 @@ class LRNPrimitive : public PrimitiveBase {
|
|||
|
||||
~LRNPrimitive() = default;
|
||||
|
||||
void Compute(const T* src_data, const T* dst_data) {
|
||||
void Compute(const T* src_data, T* dst_data) {
|
||||
context_.src_mem->set_data_handle(static_cast<void*>(const_cast<T*>(src_data)));
|
||||
context_.dst_mem->set_data_handle(static_cast<void*>(const_cast<T*>(dst_data)));
|
||||
context_.dst_mem->set_data_handle(static_cast<void*>(dst_data));
|
||||
context_.stream->submit(context_.net);
|
||||
|
||||
context_.src_mem->set_data_handle(nullptr);
|
||||
|
|
@ -231,7 +230,7 @@ Status LRN<T>::Compute(OpKernelContext* context) const {
|
|||
MemoryReorderParams params(src, dst);
|
||||
DoReorder<T>(params);
|
||||
}
|
||||
} catch (mkldnn::error& e) {
|
||||
} catch (const mkldnn::error& e) {
|
||||
return ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, "Status: ", e.status, ", message: ", e.message.c_str());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,10 +11,10 @@ namespace mkl_dnn {
|
|||
template <typename T>
|
||||
class LRN final : public onnxruntime::LRN<T> {
|
||||
public:
|
||||
LRN(const OpKernelInfo& info) : onnxruntime::LRN<T>(info) {}
|
||||
explicit LRN(const OpKernelInfo& info) : onnxruntime::LRN<T>(info) {}
|
||||
|
||||
Status Compute(OpKernelContext* p_op_kernel_context) const override;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ struct PoolParams {
|
|||
mkldnn::memory::dims& padding_right;
|
||||
bool count_include_pad;
|
||||
|
||||
PoolParams(std::string op_name, std::string version,
|
||||
PoolParams(const std::string& op_name, const std::string& version,
|
||||
mkldnn::memory::dims& src_dims, mkldnn::memory::dims& dst_dims,
|
||||
mkldnn::memory::dims& kernel, mkldnn::memory::dims& strides,
|
||||
mkldnn::memory::dims& padding_left, mkldnn::memory::dims& padding_right,
|
||||
|
|
@ -90,9 +90,9 @@ class PoolPrimitive : public PrimitiveBase {
|
|||
|
||||
~PoolPrimitive() = default;
|
||||
|
||||
void Compute(const T* src_data, const T* dst_data) {
|
||||
void Compute(const T* src_data, T* dst_data) {
|
||||
context_.src_mem->set_data_handle(static_cast<void*>(const_cast<T*>(src_data)));
|
||||
context_.dst_mem->set_data_handle(static_cast<void*>(const_cast<T*>(dst_data)));
|
||||
context_.dst_mem->set_data_handle(static_cast<void*>(dst_data));
|
||||
context_.stream->submit(context_.net);
|
||||
|
||||
context_.src_mem->set_data_handle(nullptr);
|
||||
|
|
@ -326,7 +326,7 @@ Status Pool<T, PoolType>::Compute(OpKernelContext* context) const {
|
|||
MemoryReorderParams params(src, dst);
|
||||
DoReorder<T>(params);
|
||||
}
|
||||
} catch (mkldnn::error& e) {
|
||||
} catch (const mkldnn::error& e) {
|
||||
return ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, "Status: ", e.status, ", message: ", e.message.c_str());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace mkl_dnn {
|
|||
template <typename T, typename PoolType>
|
||||
class Pool final : public onnxruntime::Pool<T, PoolType> {
|
||||
public:
|
||||
Pool(const OpKernelInfo& info) : onnxruntime::Pool<T, PoolType>(info) {
|
||||
explicit Pool(const OpKernelInfo& info) : onnxruntime::Pool<T, PoolType>(info) {
|
||||
// Since there are multiple versions of Pooling kernels, we need to use
|
||||
// the opset version as part of the key for caching Pooling Primitives.
|
||||
int start, end;
|
||||
|
|
|
|||
Loading…
Reference in a new issue