Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x86_hard_swish_layer_acc.cc AVX2指令崩溃 #1967

Open
AndroidPhoenix opened this issue Nov 3, 2023 · 0 comments
Open

x86_hard_swish_layer_acc.cc AVX2指令崩溃 #1967

AndroidPhoenix opened this issue Nov 3, 2023 · 0 comments

Comments

@AndroidPhoenix
Copy link

AndroidPhoenix commented Nov 3, 2023

hello TNN team,
我们在使用tnn进行本地OCR推理。在上线了之后发生异常崩溃。
经过dump分析该崩溃发生在AVX2指令中,具体在 x86_hard_swish_layer_acc.cc 的 _mm256_set1_ps 调用上。
目前该崩溃仅存在线上 环境,本地模拟无法重现。
在搜索了TNN所有Issue后没有发现类似问题,查看x 86_hard_swish_layer_acc的历史记录也没有和问题相关的修复修改。
以下是详细崩溃信息以及相关的崩溃dump文件。
tnn_dump.zip

1. 环境(environment)

  • Build OS and Version: Windows 10
  • RunTime OS Version: Windows 32bit
  • RunTime DEVICE: X86 win32

2. Github版本

  • branch:master
  • commit(optional):aff287b9afac32bd46c322e29598cab1a38ba30b

3. 编译方式(compile method)
CMake完整编译参数(full cmake arguments)
cmake %TNN_SRC_DIR% ^
-DCMAKE_GENERATOR_PLATFORM=Win32 ^
-DCMAKE_BUILD_TYPE=Release^
-DCMAKE_SYSTEM_NAME=Windows ^
-DTNN_CPU_ENABLE=ON ^
-DTNN_X86_ENABLE=ON ^
-DTNN_TEST_ENABLE=OFF ^
-DTNN_LIB_PATH=%TNN_LIB_PATH% ^
-DINTTYPES_FORMAT=C99

4. 编译日志(build log)

"build tnn static"
A subdirectory or file build_tnn_win32 already exists.
-- Selecting Windows SDK version 10.0.18362.0 to target Windows .
F:/Project/KAIProject/CV-AI/TNN
F:/Project/KAIProject/CV-AI/TNN
-- >>>>>>>>>>>>>
-- TNN BUILD INFO:
--      System: Windows
--      Processor:
--      Cpu:    ON
--      X86:    ON
--      Arm:    OFF
--      Arm82:  OFF
--      Metal:  OFF
--      OpenCL: OFF
--      CUDA:   OFF
--      DSP:    OFF
--      Atlas:  OFF
--      TensorRT:       OFF
--      AppleNPU:       OFF
--      HuaweiNPU:      OFF
--      RKNPU:  OFF
--      Jetson Nano:    OFF
--      OpenVINO:       OFF
--      OpenMP: OFF
--      TEST:   OFF
--      --Unit Test:    OFF
--      Quantization:   OFF
--      ModelCheck:     OFF
--      DEBUG:
--      PROFILE:        OFF
--      BENCHMARK:      OFF
--      BENCHMARK Layer:        OFF
--      Model Converter:        OFF
--      ONNX2TNN Converter:     OFF
--      TNN2MEM:        OFF
--      BENCHMARK Test Lib:     OFF
--      Dynamic Range Quantization:     OFF
--      SHARING_MEM_WITH_OPENGL:
-- Configuring done
-- Generating done
-- Build files have been written to: F:/Project/KAIProject/CV-AI/build/build_tnn_win32
用于 .NET Framework 的 Microsoft (R) 生成引擎版本 16.4.0+e901037fe
版权所有(C) Microsoft Corporation。保留所有权利。

 TNNCpu.vcxproj -> F:\Project\KAIProject\CV-AI\build\build_tnn_win32\source\tnn\device\cpu\TNNCpu.dir\Debug\TNNCpu.lib
 TNNX86.vcxproj -> F:\Project\KAIProject\CV-AI\build\build_tnn_win32\source\tnn\device\x86\TNNX86.dir\Debug\TNNX86.lib
 TNNX86ACC.vcxproj -> F:\Project\KAIProject\CV-AI\build\build_tnn_win32\source\tnn\device\x86\TNNX86ACC.dir\Debug\TNNX
 86ACC.lib
 TNN.vcxproj -> F:\Project\KAIProject\CV-AI\build\build_tnn_win32\Debug\TNN.lib
"build_win"
A subdirectory or file build_win32 already exists.
-- Selecting Windows SDK version 10.0.18362.0 to target Windows .
-- F:\Project\KAIProject\CV-AI\script\..\build\build_tnn_win32\
-- >>> 1
-- OpenCV ARCH: x86
-- OpenCV RUNTIME: vc16
-- OpenCV STATIC: OFF
-- Found OpenCV 4.1.0 in F:/Project/KAIProject/CV-AI/demo/third_party/opencv/libs/win/win32/x86/vc16/lib
-- You might need to add F:\Project\KAIProject\CV-AI\demo\third_party\opencv\libs\win\win32\x86\vc16\bin to your PATH to be able to run your applications.
-- Configuring done
-- Generating done
-- Build files have been written to: F:/Project/KAIProject/CV-AI/build/build_win32
用于 .NET Framework 的 Microsoft (R) 生成引擎版本 16.4.0+e901037fe
版权所有(C) Microsoft Corporation。保留所有权利。

 ktnn_engine.vcxproj -> F:\Project\KAIProject\CV-AI\build\build_win32\Debug\ktnn_engine.dll

5. 详细描述bug 情况 (Describe the bug)
基于TNN封装了自研的OCR模型,在线上发生偶现崩溃。崩溃位置在 x86_hard_swish_layer_acc的代码

alpha_ = _mm256_set1_ps(alpha);

崩溃信息

异常代码 0xC000001D
异常信息 该线程尝试执行无效的指令

该异常在本地不能重现,尝试intel的SDE进行CPU模拟,也不能重现问题。怀疑是AMD CPU环境导致崩溃。

6. 运行日志(runtime log)
崩溃堆栈信息

![image](https://github.com/Tencent/TNN/assets/37130296/bc0d7c21-491b-46ab-9608-59476c8afc23)

7. 截图(Screenshots)
崩溃汇编位置

![image](https://github.com/Tencent/TNN/assets/37130296/937ecc01-ac72-4b11-856a-b17707736b3c)
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

No branches or pull requests

1 participant