diff -Naur oneDNN-2.6.bak/cmake/platform.cmake oneDNN-2.6/cmake/platform.cmake
--- oneDNN-2.6.bak/cmake/platform.cmake	2024-05-16 19:21:17.453108850 +0800
+++ oneDNN-2.6/cmake/platform.cmake	2024-05-16 19:38:59.705108850 +0800
@@ -195,8 +195,10 @@
              if (CMAKE_SYSTEM_PROCESSOR STREQUAL CMAKE_HOST_SYSTEM_PROCESSOR)
                  append(DEF_ARCH_OPT_FLAGS "-march=native")
              endif()
-        elseif(DNNL_TARGET_ARCH STREQUAL "X64")
-             set(DEF_ARCH_OPT_FLAGS "-msse4.1")
+        elseif(DNNL_TARGET_ARCH STREQUAL "LOONGARCH64")
+	    set(DEF_ARCH_OPT_FLAGS "-O3")
+	elseif(DNNL_TARGET_ARCH STREQUAL "X64")
+            set(DEF_ARCH_OPT_FLAGS "-msse4.1")
         endif()
         # Clang cannot vectorize some loops with #pragma omp simd and gets
         # very upset. Tell it that it's okay and that we love it
@@ -297,7 +299,16 @@
         elseif(DNNL_TARGET_ARCH STREQUAL "RV64")
             # G = General-purpose extensions, C = Compression extension (very common).
             append(DEF_ARCH_OPT_FLAGS "-march=rv64gc")
-        elseif(DNNL_TARGET_ARCH STREQUAL "X64")
+        elseif(DNNL_TARGET_ARCH STREQUAL "LOONGARCH64")
+	    if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
+		set(DEF_ARCH_OPT_FLAGS "-O3")
+	    endif()
+	    # In GCC, -ftree-vectorize is turned on under -O3 since 2007.
+            # For native compilation tune for the host processor
+            if (CMAKE_SYSTEM_PROCESSOR STREQUAL CMAKE_HOST_SYSTEM_PROCESSOR)
+                append(DEF_ARCH_OPT_FLAGS "-march=native")
+            endif()
+	elseif(DNNL_TARGET_ARCH STREQUAL "X64")
             platform_gnu_x64_arch_ccxx_flags(DEF_ARCH_OPT_FLAGS)
         endif()
         platform_gnu_nowarn_ccxx_flags(CMAKE_CCXX_NOWARN_FLAGS ${CMAKE_CXX_COMPILER_VERSION})
diff -Naur oneDNN-2.6.bak/CMakeLists.txt oneDNN-2.6/CMakeLists.txt
--- oneDNN-2.6.bak/CMakeLists.txt	2024-05-16 19:21:17.449108850 +0800
+++ oneDNN-2.6/CMakeLists.txt	2024-05-16 19:33:40.165108850 +0800
@@ -95,6 +95,8 @@
         set(DNNL_TARGET_ARCH "S390X")
     elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(rv.*|RV.*|riscv.*|RISCV.*)")
         set(DNNL_TARGET_ARCH "RV64")
+    elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(larch64.*|loongarch64.*|loongarch64-64.*)")
+        set(DNNL_TARGET_ARCH "LOONGARCH64")
     else()
         set(DNNL_TARGET_ARCH "X64")
     endif()
