apache / tvm

Open deep learning compiler stack for cpu, gpu and specialized accelerators
https://tvm.apache.org/
Apache License 2.0
11.82k stars 3.48k forks source link

[Bug] Building for qualcomm hexagon dsp V66 architeture #17163

Open chayliu-ecarx opened 4 months ago

chayliu-ecarx commented 4 months ago

TVM Commit id: d0cbb02e1db32faaae2b6ea6e729829bd019aeb6 Qualcomm Hexagon SDK version: V5.5

building as following: cd apps/hexagon_api/build cmake -DANDROID_ABI=arm64-v8a \ -DANDROID_PLATFORM=android-28 \ -DUSE_ANDROID_TOOLCHAIN=Hexagon_SDK_5_5/tools/android-ndk-r25c/build/cmake/android.toolchain.cmake \ -DUSE_HEXAGON_ARCH=v66 \ -DUSE_HEXAGON_SDK=Hexagon_SDK_5_5 \ -DUSE_HEXAGON_TOOLCHAIN=Hexagon_SDK_5_5/tools/HEXAGON_Tools/8.7.06/Tools \ -DUSE_OUTPUT_BINARY_DIR=hexagon_api_build_output/ ..

with error message: /qhl_hvx/inc/internal/qhmath_hvx_vector.h:910:40: error: use of undeclared identifier 'Q6_Vqf16_vadd_Vqf16Vhf' /qhl_hvx/inc/internal/qhmath_hvx_vector.h:912:66: error: use of undeclared identifier 'Q6_Vhf_equals_Vqf16' ...

runtime/hexagon/ops/conv2d_fp16_hvx.cc:142:26: error: use of undeclared identifier 'Q6_Vqf16_vadd_Vqf16Vqf16' HVX_Vector v_reduced = Q6_Vqf16_vadd_Vqf16Vqf16(v_res, v_rot); runtime/hexagon/ops/conv2d_fp16_hvx.cc:345:39: error: use of undeclared identifier 'Q6_Vqf16_vadd_VhfVhf' HVX_Vector out_vec_qf16 = Q6_Vqf16_vadd_VhfVhf(out_final, existing_out_vec); ...

chayliu-ecarx commented 4 months ago

@quic-sanirudh @abhikran-quic @kparzysz-quic @sdalvi-quic

anyone can share some ideas?

quic-sanirudh commented 4 months ago

@chayliu-ecarx Those errors are because there are fp16/fp32 HVX vector instructions introduced starting from v68 and Hexagon SDK 5.5. If possible try with an architecture >= v68 and the build should work.

If you would really want to support v66, there might be some CMake changes needed to support that, I'll try to push them as soon as possible so that the files that need the newer architecture features are not built when the architecture passed is v66.

chayliu-ecarx commented 4 months ago

@quic-sanirudh thanks for your reply. Building with SDK5.5 and V68 succeed!. However, I do really need V66 supported.

I have test with SDK 4.5 the following errors is gone: /qhl_hvx/inc/internal/qhmath_hvx_vector.h:910:40: error: use of undeclared identifier 'Q6_Vqf16_vadd_Vqf16Vhf' /qhl_hvx/inc/internal/qhmath_hvx_vector.h:912:66: error: use of undeclared identifier 'Q6_Vhf_equals_Vqf16'

but the following errors still exist: runtime/hexagon/ops/conv2d_fp16_hvx.cc:142:26: error: use of undeclared identifier 'Q6_Vqf16_vadd_Vqf16Vqf16' HVX_Vector v_reduced = Q6_Vqf16_vadd_Vqf16Vqf16(v_res, v_rot); runtime/hexagon/ops/conv2d_fp16_hvx.cc:345:39: error: use of undeclared identifier 'Q6_Vqf16_vadd_VhfVhf' HVX_Vector out_vec_qf16 = Q6_Vqf16_vadd_VhfVhf(out_final, existing_out_vec);

quic-sanirudh commented 4 months ago

@quic-sanirudh thanks for your reply. Building with SDK5.5 and V68 succeed!. However, I do really need V66 supported.

I have test with SDK 4.5 the following errors is gone: /qhl_hvx/inc/internal/qhmath_hvx_vector.h:910:40: error: use of undeclared identifier 'Q6_Vqf16_vadd_Vqf16Vhf' /qhl_hvx/inc/internal/qhmath_hvx_vector.h:912:66: error: use of undeclared identifier 'Q6_Vhf_equals_Vqf16'

but the following errors still exist: runtime/hexagon/ops/conv2d_fp16_hvx.cc:142:26: error: use of undeclared identifier 'Q6_Vqf16_vadd_Vqf16Vqf16' HVX_Vector v_reduced = Q6_Vqf16_vadd_Vqf16Vqf16(v_res, v_rot); runtime/hexagon/ops/conv2d_fp16_hvx.cc:345:39: error: use of undeclared identifier 'Q6_Vqf16_vadd_VhfVhf' HVX_Vector out_vec_qf16 = Q6_Vqf16_vadd_VhfVhf(out_final, existing_out_vec);

Yes, SDK 4.5 is a better support for that. The errors that exist is again because those files are linked into the runtime regardless of the architecture, which is a mistake and needs to be fixed in CMake. I'll push a patch to fix that.

quic-sanirudh commented 4 months ago

@chayliu-ecarx I've raised the patch #17169 to fix this issue. If possible, please try it out in your setup and let me know if it works