From 9638e34ab054b9499875ec9ecdde7b4cfa907677 Mon Sep 17 00:00:00 2001 From: Zihao Mu Date: Sat, 27 Aug 2022 07:42:38 +0800 Subject: [PATCH] reuse WORDS_BIGENDIAN. --- modules/dnn/src/onnx/onnx_graph_simplifier.cpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/modules/dnn/src/onnx/onnx_graph_simplifier.cpp b/modules/dnn/src/onnx/onnx_graph_simplifier.cpp index c787c0a..d115e57 100644 --- a/modules/dnn/src/onnx/onnx_graph_simplifier.cpp +++ b/modules/dnn/src/onnx/onnx_graph_simplifier.cpp @@ -18,17 +18,6 @@ CV__DNN_INLINE_NS_BEGIN extern bool DNN_DIAGNOSTICS_RUN; -static int isLittleEndianCPU() -{ - int x = 7; - char *ptr = (char *)&x; - - if(ptr[0] == 0) - return 0; - else - return 1; -} - // This wrapper can behave differently for fake input nodes and real graph nodes. class ONNXNodeWrapper : public ImportNodeWrapper { @@ -787,7 +776,10 @@ Mat getMatFromTensor(const opencv_onnx::TensorProto& tensor_proto) // Link: https://github.com/onnx/onnx/issues/4460#issuecomment-1224373746 if (!tensor_proto.int32_data().empty()) { - const int offset = isLittleEndianCPU() ? 0 : 1; + int offset = 0; +#ifdef WORDS_BIGENDIAN + offset = 1; +#endif const ::google::protobuf::RepeatedField field = tensor_proto.int32_data(); AutoBuffer aligned_val; -- 2.7.4