Repository: pytorch
Issue: '_mm256_extract_epi64' was not declared in this scope when compiling on Debian 32-bit
Labels: module: build,triaged

## 🐛 Bug

I am attempting to compile pytorch on Debian 32-bit VM. Compilation errors about AVX have been mentioned before #17901, but I still came across similar errors mentioning `_mm256_extract_epi64`, and they seemed to come from ATen not Caffe2.

## To Reproduce

Steps to reproduce the behavior:

1. Debian 32-bit install miniconda, create python 3.6 environment
1. Follow https://github.com/pytorch/pytorch#from-source to compile
1. Using flags USE_CUDA=0; USE_DISTRIBUTED=0; USE_MKLDNN=0; USE_NNPACK=0; USE_QNNPACK=0; USE_FBGEMM=0

```
[2394/3508] Building CXX object caffe2...ve/cpu/batch_norm_kernel.cpp.AVX.cpp.o
FAILED: caffe2/CMakeFiles/torch_cpu.dir/__/aten/src/ATen/native/cpu/batch_norm_kernel.cpp.AVX.cpp.o 
/usr/bin/c++  -DCPUINFO_SUPPORTED_PLATFORM=1 -DFMT_HEADER_ONLY=1 -DFXDIV_USE_INLINE_ASSEMBLY=0 -DHAVE_MALLOC_USABLE_SIZE=1 -DHAVE_MMAP=1 -DHAVE_SHM_OPEN=1 -DHAVE_SHM_UNLINK=1 -DMINIZ_DISABLE_ZIP_READER_CRC32_CHECKS -DONNXIFI_ENABLE_EXT=1 -DONNX_ML=1 -DONNX_NAMESPACE=onnx_torch -DTH_BLAS_MKL -DUSE_EXTERNAL_MZCRC -D_FILE_OFFSET_BITS=64 -Dtorch_cpu_EXPORTS -Iaten/src -I../aten/src -I. -I../ -I../cmake/../third_party/benchmark/include -Icaffe2/contrib/aten -I../third_party/onnx -Ithird_party/onnx -I../third_party/foxi -Ithird_party/foxi -I../caffe2/../torch/csrc/api -I../caffe2/../torch/csrc/api/include -I../caffe2/aten/src/TH -Icaffe2/aten/src/TH -I../caffe2/../torch/../aten/src -Icaffe2/aten/src -Icaffe2/../aten/src -Icaffe2/../aten/src/ATen -I../caffe2/../torch/csrc -I../caffe2/../torch/../third_party/miniz-2.0.8 -I../aten/src/TH -I../aten/../third_party/catch/single_include -I../aten/src/ATen/.. -Icaffe2/aten/src/ATen -I../third_party/miniz-2.0.8 -I../caffe2/core/nomnigraph/include -I../third_party/FXdiv/include -I../c10/.. -I../third_party/pthreadpool/include -I../third_party/cpuinfo/include -I../aten/src/ATen/native/quantized/cpu/qnnpack/include -I../aten/src/ATen/native/quantized/cpu/qnnpack/src -I../third_party/cpuinfo/deps/clog/include -I../third_party/FP16/include -I../third_party/fmt/include -isystem ../cmake/../third_party/googletest/googlemock/include -isystem ../cmake/../third_party/googletest/googletest/include -isystem ../third_party/protobuf/src -isystem /home/pi/miniconda3/envs/py36/include -isystem ../third_party/XNNPACK/include -isystem ../cmake/../third_party/eigen -isystem /home/pi/miniconda3/envs/py36/include/python3.6m -isystem /home/pi/miniconda3/envs/py36/lib/python3.6/site-packages/numpy/core/include -isystem ../cmake/../third_party/pybind11/include -isystem include -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -DNDEBUG -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DUSE_VULKAN_WRAPPER -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-result -Wno-unused-local-typedefs -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-stringop-overflow -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Wno-stringop-overflow -DHAVE_AVX_CPU_DEFINITION -O3 -DNDEBUG -DNDEBUG -fPIC   -DHAVE_GCC_GET_CPUID -DUSE_AVX -DTH_HAVE_THREAD -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -Wno-write-strings -Wno-unknown-pragmas -Wno-missing-braces -Wno-maybe-uninitialized -fvisibility=hidden -O2 -fopenmp -DCAFFE2_BUILD_MAIN_LIB -pthread -std=gnu++14 -O3  -mavx -DCPU_CAPABILITY=AVX -DCPU_CAPABILITY_AVX -MD -MT caffe2/CMakeFiles/torch_cpu.dir/__/aten/src/ATen/native/cpu/batch_norm_kernel.cpp.AVX.cpp.o -MF caffe2/CMakeFiles/torch_cpu.dir/__/aten/src/ATen/native/cpu/batch_norm_kernel.cpp.AVX.cpp.o.d -o caffe2/CMakeFiles/torch_cpu.dir/__/aten/src/ATen/native/cpu/batch_norm_kernel.cpp.AVX.cpp.o -c aten/src/ATen/native/cpu/batch_norm_kernel.cpp.AVX.cpp
In file included from ../aten/src/ATen/cpu/vec256/vec256.h:13,
                 from ../aten/src/ATen/native/cpu/Loops.h:35,
                 from aten/src/ATen/native/cpu/batch_norm_kernel.cpp.AVX.cpp:7:
../aten/src/ATen/cpu/vec256/vec256_qint.h: In member function ‘at::vec256::{anonymous}::Vec256<c10::qint8>::float_vec_return_type at::vec256::{anonymous}::Vec256<c10::qint8>::dequantize(at::vec256::{anonymous}::Vec256<float>, at::vec256::{anonymous}::Vec256<float>, at::vec256::{anonymous}::Vec256<float>) const’:
../aten/src/ATen/cpu/vec256/vec256_qint.h:567:40: error: ‘_mm256_extract_epi64’ was not declared in this scope
     __m128i int_val0 = _mm_set1_epi64x(_mm256_extract_epi64(vals, 0));
                                        ^~~~~~~~~~~~~~~~~~~~
../aten/src/ATen/cpu/vec256/vec256_qint.h:567:40: note: suggested alternative: ‘_mm256_extract_epi8’
     __m128i int_val0 = _mm_set1_epi64x(_mm256_extract_epi64(vals, 0));
                                        ^~~~~~~~~~~~~~~~~~~~
                                        _mm256_extract_epi8
../aten/src/ATen/cpu/vec256/vec256_qint.h: In member function ‘at::vec256::{anonymous}::Vec256<c10::quint8>::float_vec_return_type at::vec256::{anonymous}::Vec256<c10::quint8>::dequantize(at::vec256::{anonymous}::Vec256<float>, at::vec256::{anonymous}::Vec256<float>, at::vec256::{anonymous}::Vec256<float>) const’:
../aten/src/ATen/cpu/vec256/vec256_qint.h:838:40: error: ‘_mm256_extract_epi64’ was not declared in this scope
     __m128i int_val0 = _mm_set1_epi64x(_mm256_extract_epi64(vals, 0));
                                        ^~~~~~~~~~~~~~~~~~~~
../aten/src/ATen/cpu/vec256/vec256_qint.h:838:40: note: suggested alternative: ‘_mm256_extract_epi8’
     __m128i int_val0 = _mm_set1_epi64x(_mm256_extract_epi64(vals, 0));
                                        ^~~~~~~~~~~~~~~~~~~~
                                        _mm256_extract_epi8
ninja: build stopped: subcommand failed.
Traceback (most recent call last):
  File "setup.py", line 734, in <module>
    build_deps()
  File "setup.py", line 318, in build_deps
    cmake=cmake)
  File "/home/pi/pytorch/tools/build_pytorch_libs.py", line 62, in build_caffe2
    cmake.build(my_env)
  File "/home/pi/pytorch/tools/setup_helpers/cmake.py", line 345, in build
    self.run(build_args, my_env)
  File "/home/pi/pytorch/tools/setup_helpers/cmake.py", line 141, in run
    check_call(command, cwd=self.build_dir, env=env)
  File "/home/pi/miniconda3/envs/py36/lib/python3.6/subprocess.py", line 291, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '--build', '.', '--target', 'install', '--config', 'Release', '--', '-j', '1']' returned non-zero exit status 1.
```

## Expected behavior

Expected no compilation error regarding AVX on 32-bit system

## Environment
PyTorch version: latest
Is debug build: N/A
CUDA used to build PyTorch: N/A

OS: Debian GNU/Linux 10 (buster)
GCC version: (Debian 8.3.0-6) 8.3.0
CMake version: version 3.12.2

Python version: 3.6
Is CUDA available: N/A
CUDA runtime version: Could not collect
GPU models and configuration: Could not collect
Nvidia driver version: Could not collect
cuDNN version: Could not collect

Versions of relevant libraries:
[pip] numpy==1.15.4
[conda] blas                      1.0                         mkl  
[conda] mkl                       2019.1                      144  
[conda] mkl-include               2019.1                      144  
[conda] mkl_fft                   1.0.6            py36hd81dba3_0  
[conda] mkl_random                1.0.2            py36hd81dba3_0  
[conda] numpy                     1.15.4           py36h7e9f1db_0  
[conda] numpy-base                1.15.4           py36hde5b4d6_0



cc @malfet