mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-26 19:52:38 +00:00
Remove mkldnn_sgemm from math_util.cc
If it is needed, it can be used explicitly in mkldnn provider.
This commit is contained in:
parent
ffd9071168
commit
867e961ee8
5 changed files with 14 additions and 36 deletions
|
|
@ -467,7 +467,6 @@ if (onnxruntime_USE_MKLML)
|
|||
endif()
|
||||
|
||||
if (onnxruntime_USE_MKLDNN)
|
||||
add_definitions(-DUSE_MKLDNN=1)
|
||||
list(APPEND onnxruntime_EXTERNAL_LIBRARIES mkldnn)
|
||||
list(APPEND onnxruntime_EXTERNAL_DEPENDENCIES project_mkldnn)
|
||||
link_directories(${MKLDNN_LIB_DIR})
|
||||
|
|
|
|||
|
|
@ -48,6 +48,10 @@ if(onnxruntime_PYBIND_EXPORT_OPSCHEMA)
|
|||
target_compile_definitions(onnxruntime_pybind11_state PRIVATE onnxruntime_PYBIND_EXPORT_OPSCHEMA)
|
||||
endif()
|
||||
|
||||
if (onnxruntime_USE_MKLDNN)
|
||||
target_compile_definitions(onnxruntime_pybind11_state PRIVATE USE_MKLDNN=1)
|
||||
endif()
|
||||
|
||||
target_include_directories(onnxruntime_pybind11_state PRIVATE ${ONNXRUNTIME_ROOT} ${PYTHON_INCLUDE_DIR} ${NUMPY_INCLUDE_DIR})
|
||||
target_include_directories(onnxruntime_pybind11_state PRIVATE ${pybind11_INCLUDE_DIRS})
|
||||
onnxruntime_add_include_to_target(onnxruntime_pybind11_state gsl)
|
||||
|
|
|
|||
|
|
@ -219,6 +219,9 @@ file(GLOB onnxruntime_test_framework_src ${onnxruntime_test_framework_src_patter
|
|||
#with auto initialize onnxruntime
|
||||
add_library(onnxruntime_test_utils_for_framework ${onnxruntime_test_utils_src})
|
||||
onnxruntime_add_include_to_target(onnxruntime_test_utils_for_framework onnxruntime_framework gtest gsl onnx onnx_proto)
|
||||
if (onnxruntime_USE_MKLDNN)
|
||||
target_compile_definitions(onnxruntime_test_utils_for_framework PUBLIC USE_MKLDNN=1)
|
||||
endif()
|
||||
add_dependencies(onnxruntime_test_utils_for_framework ${onnxruntime_EXTERNAL_DEPENDENCIES} eigen)
|
||||
target_include_directories(onnxruntime_test_utils_for_framework PUBLIC "${TEST_SRC_DIR}/util/include" PRIVATE ${eigen_INCLUDE_DIRS} ${ONNXRUNTIME_ROOT})
|
||||
# Add the define for conditionally using the framework Environment class in TestEnvironment
|
||||
|
|
@ -228,6 +231,9 @@ set_target_properties(onnxruntime_test_utils_for_framework PROPERTIES FOLDER "ON
|
|||
#without auto initialize onnxruntime
|
||||
add_library(onnxruntime_test_utils ${onnxruntime_test_utils_src})
|
||||
onnxruntime_add_include_to_target(onnxruntime_test_utils onnxruntime_framework gtest gsl onnx onnx_proto)
|
||||
if (onnxruntime_USE_MKLDNN)
|
||||
target_compile_definitions(onnxruntime_test_utils PUBLIC USE_MKLDNN=1)
|
||||
endif()
|
||||
add_dependencies(onnxruntime_test_utils ${onnxruntime_EXTERNAL_DEPENDENCIES} eigen)
|
||||
target_include_directories(onnxruntime_test_utils PUBLIC "${TEST_SRC_DIR}/util/include" PRIVATE ${eigen_INCLUDE_DIRS} ${ONNXRUNTIME_ROOT})
|
||||
set_target_properties(onnxruntime_test_utils PROPERTIES FOLDER "ONNXRuntimeTest")
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ file(GLOB_RECURSE onnxruntime_util_srcs
|
|||
source_group(TREE ${ONNXRUNTIME_ROOT}/core FILES ${onnxruntime_util_srcs})
|
||||
|
||||
add_library(onnxruntime_util ${onnxruntime_util_srcs})
|
||||
target_include_directories(onnxruntime_util PRIVATE ${ONNXRUNTIME_ROOT} ${eigen_INCLUDE_DIRS} ${MKLDNN_INCLUDE_DIR} ${MKLML_INCLUDE_DIR})
|
||||
target_include_directories(onnxruntime_util PRIVATE ${ONNXRUNTIME_ROOT} ${eigen_INCLUDE_DIRS} ${MKLML_INCLUDE_DIR})
|
||||
onnxruntime_add_include_to_target(onnxruntime_util onnxruntime_common onnxruntime_framework gsl onnx onnx_proto protobuf::libprotobuf)
|
||||
if(UNIX)
|
||||
target_compile_options(onnxruntime_util PUBLIC "-Wno-error=comment")
|
||||
|
|
|
|||
|
|
@ -44,10 +44,6 @@
|
|||
#include "core/mlas/inc/mlas.h"
|
||||
#endif
|
||||
|
||||
#ifdef USE_MKLDNN
|
||||
#include "mkldnn.h"
|
||||
#endif
|
||||
|
||||
namespace onnxruntime {
|
||||
namespace math {
|
||||
|
||||
|
|
@ -110,7 +106,7 @@ void GemmEigen(
|
|||
// will delegate the Caffe math functions that are BLAS-related to either the
|
||||
// CBLAS call or the Eigen implementation.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// when USE_MKLDNN and USE_MKLML are defined, use cblas APIs for MKLML
|
||||
// when USE_MKLML is defined, use cblas APIs for MKLML
|
||||
#if defined(USE_EIGEN_FOR_BLAS) && !defined(USE_MKLML_FOR_BLAS)
|
||||
|
||||
// Caffe2 gemm provides a simpler interface to the gemm functions, with the
|
||||
|
|
@ -142,23 +138,7 @@ void Gemm<float, CPUMathUtil>(
|
|||
float* C,
|
||||
CPUMathUtil* /*provider*/,
|
||||
MLDataType /*math_type*/) {
|
||||
#if defined(USE_MKLDNN)
|
||||
int lda = (int)((TransA == CblasTrans) ? M : K);
|
||||
int ldb = (int)((TransB == CblasTrans) ? K : N);
|
||||
int M_ = (int)M;
|
||||
int N_ = (int)N;
|
||||
int K_ = (int)K;
|
||||
// mkldnn_sgemm expects col major matrices, so we need to swap the operands A and B
|
||||
auto status = mkldnn_sgemm(TransB == CblasNoTrans ? "N" : "T",
|
||||
TransA == CblasNoTrans ? "N" : "T",
|
||||
&N_, &M_, &K_,
|
||||
&alpha, B, &ldb,
|
||||
A, &lda,
|
||||
&beta, C, &N_);
|
||||
if (status != mkldnn_success) {
|
||||
ORT_THROW("mkldnn_sgemm failed with status: ", status);
|
||||
}
|
||||
#elif defined(USE_MLAS)
|
||||
#if defined(USE_MLAS)
|
||||
int lda = (int)((TransA == CblasNoTrans) ? K : M);
|
||||
int ldb = (int)((TransB == CblasNoTrans) ? N : K);
|
||||
MlasSgemm(TransA, TransB, M, N, K, alpha, A, lda, B, ldb, beta, C, N);
|
||||
|
|
@ -273,18 +253,7 @@ void GemmEx<float, CPUMathUtil>(
|
|||
float* C,
|
||||
const int ldc,
|
||||
CPUMathUtil*) {
|
||||
#if defined(USE_MKLDNN)
|
||||
// mkldnn_sgemm expects col major matrices, so we need to swap the operands A and B
|
||||
auto status = mkldnn_sgemm(TransB == CblasNoTrans ? "N" : "T",
|
||||
TransA == CblasNoTrans ? "N" : "T",
|
||||
&N, &M, &K,
|
||||
&alpha, B, &ldb,
|
||||
A, &lda,
|
||||
&beta, C, &ldc);
|
||||
if (status != mkldnn_success) {
|
||||
ORT_THROW("mkldnn_sgemm failed with status: ", status);
|
||||
}
|
||||
#elif defined(USE_MLAS)
|
||||
#if defined(USE_MLAS)
|
||||
MlasSgemm(TransA, TransB, M, N, K, alpha, A, lda, B, ldb, beta, C, ldc);
|
||||
#else
|
||||
using OuterStride = Eigen::OuterStride<Eigen::Dynamic>;
|
||||
|
|
|
|||
Loading…
Reference in a new issue