# ‘qnnp\_setup\_add\_nc\_q8’ was not declared in this scope

**URL:** <https://discuss.pytorch.org/t/qnnp-setup-add-nc-q8-was-not-declared-in-this-scope/30245>\
**Category:** Uncategorized\
**Created:** [November 22, 2018, 4:15am UTC](https://discuss.pytorch.org/t/qnnp-setup-add-nc-q8-was-not-declared-in-this-scope/30245 "2018-11-22T04:15:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![promach](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/promach/32/22571_2.png) [@promach](https://discuss.pytorch.org/u/promach)\
**Post date:** [November 22, 2018, 4:15am UTC](https://discuss.pytorch.org/t/qnnp-setup-add-nc-q8-was-not-declared-in-this-scope/30245/1 "2018-11-22T04:15:58Z")

</div>

I have the following pytorch installation error. Could anyone help ?

**‘qnnp\_setup\_add\_nc\_q8’ was not declared in this scope**

> [49%] Building CXX object caffe2/CMakeFiles/caffe2.dir/operators/rnn/recurrent\_network\_blob\_fetcher\_op.cc.o  
> [49%] Building CXX object caffe2/CMakeFiles/caffe2.dir/operators/rnn/recurrent\_network\_executor.cc.o  
> [49%] Building CXX object caffe2/CMakeFiles/caffe2.dir/operators/rnn/recurrent\_network\_op.cc.o  
> [49%] Building CXX object caffe2/CMakeFiles/caffe2.dir/operators/quantized/init\_qnnpack.cc.o  
> [50%] Building CXX object caffe2/CMakeFiles/caffe2.dir/operators/quantized/int8\_add\_op.cc.o  
> [50%] Building CXX object caffe2/CMakeFiles/caffe2.dir/operators/quantized/int8\_average\_pool\_op.cc.o  
> [50%] Building CXX object caffe2/CMakeFiles/caffe2.dir/operators/quantized/int8\_channel\_shuffle\_op.cc.o  
> [50%] Building CXX object caffe2/CMakeFiles/caffe2.dir/operators/quantized/int8\_concat\_op.cc.o  
> [50%] Building CXX object caffe2/CMakeFiles/caffe2.dir/operators/quantized/int8\_conv\_op.cc.o  
> [50%] Building CXX object caffe2/CMakeFiles/caffe2.dir/operators/quantized/int8\_conv\_transpose\_op.cc.o  
> In file included from /home/phung/Downloads/pytorch/caffe2/operators/quantized/int8\_add\_op.cc:3:0:  
> /home/phung/Downloads/pytorch/caffe2/operators/quantized/int8\_add\_op.h: In member function ‘bool caffe2::int8::Int8AddOp::RunOnDevice()’:  
> /home/phung/Downloads/pytorch/caffe2/operators/quantized/int8\_add\_op.h:59:40: error: there are no arguments to ‘qnnp\_create\_add\_nc\_q8’ that depend on a template parameter, so a declaration of ‘qnnp\_create\_add\_nc\_q8’ must be available [-fpermissive]  
> const qnnp\_status createStatus = qnnp\_create\_add\_nc\_q8(  
> ^ ~~~~~~~~~~~~~~~~~~~~  
> /home/phung/Downloads/pytorch/caffe2/operators/quantized/int8\_add\_op.h:59:40: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)  
> /home/phung/Downloads/pytorch/caffe2/operators/quantized/int8\_add\_op.h:73:37: error: there are no arguments to ‘qnnp\_setup\_add\_nc\_q8’ that depend on a template parameter, so a declaration of ‘qnnp\_setup\_add\_nc\_q8’ must be available [-fpermissive]  
> const qnnp\_status setupStatus = qnnp\_setup\_add\_nc\_q8(  
> ^ ~~~~~~~~~~~~~~~~~~~  
> [50%] Building CXX object caffe2/CMakeFiles/caffe2.dir/operators/quantized/int8\_dequantize\_op.cc.o  
> /home/phung/Downloads/pytorch/caffe2/operators/quantized/int8\_add\_op.h: In instantiation of ‘bool caffe2::int8::Int8AddOp::RunOnDevice() [with caffe2::int8::Activation Ac = (caffe2::int8::Activation)1]’:  
> /home/phung/Downloads/pytorch/caffe2/operators/quantized/int8\_add\_op.cc:68:1: required from here  
> /home/phung/Downloads/pytorch/caffe2/operators/quantized/int8\_add\_op.h:59:61: error: ‘qnnp\_create\_add\_nc\_q8’ was not declared in this scope  
> const qnnp\_status createStatus = qnnp\_create\_add\_nc\_q8(  
> ~~~~~~~~~~~~~~~~~~~~~ ^  
> 1 /\* channels _/,  
> ~~~~~~~~~~~~~~~~~  
> A\_zero\_point, A\_scale,  
> ~~~~~~~~~~~~~~~~~~~~~~  
> B\_zero\_point, B\_scale,  
> ~~~~~~~~~~~~~~~~~~~~~~  
> static\_cast\<uint8\_t\>(Y\_zero\_point), Y\_scale,  
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
> activationLimits(Y\_scale, Y\_zero\_point, Ac).first,  
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
> activationLimits(Y\_scale, Y\_zero\_point, Ac).second,  
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
> &qnnpackOperator\_);  
> ~~~~~~~~~~~~~~~~~~  
> /home/phung/Downloads/pytorch/caffe2/operators/quantized/int8\_add\_op.h:73:57: error: ‘qnnp\_setup\_add\_nc\_q8’ was not declared in this scope  
> const qnnp\_status setupStatus = qnnp\_setup\_add\_nc\_q8(  
> ~~~~~~~~~~~~~~~~~~~~ ^  
> this-\>qnnpackOperator\_,  
> ~~~~~~~~~~~~~~~~~~~~~~~  
> A.t.numel() /_ batch size _/,  
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
> A.t.template data\<uint8\_t\>(),  
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
> 1 /_ A stride _/,  
> ~~~~~~~~~~~~~~~~~  
> B.t.template data\<uint8\_t\>(),  
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
> 1 /_ B stride _/,  
> ~~~~~~~~~~~~~~~~~  
> Y-\>t.template mutable\_data\<uint8\_t\>(),  
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
> 1 /_ Y stride _/);  
> ~~~~~~~~~~~~~~~~~  
> [50%] Building CXX object caffe2/CMakeFiles/caffe2.dir/operators/quantized/int8\_fc\_op.cc.o  
> /home/phung/Downloads/pytorch/caffe2/operators/quantized/int8\_add\_op.h: In instantiation of ‘bool caffe2::int8::Int8AddOp::RunOnDevice() [with caffe2::int8::Activation Ac = (caffe2::int8::Activation)0]’:  
> /home/phung/Downloads/pytorch/caffe2/operators/quantized/int8\_add\_op.cc:68:1: required from here  
> /home/phung/Downloads/pytorch/caffe2/operators/quantized/int8\_add\_op.h:59:61: error: ‘qnnp\_create\_add\_nc\_q8’ was not declared in this scope  
> const qnnp\_status createStatus = qnnp\_create\_add\_nc\_q8(  
> ~~~~~~~~~~~~~~~~~~~~~ ^  
> 1 /_ channels _/,  
> ~~~~~~~~~~~~~~~~~  
> A\_zero\_point, A\_scale,  
> ~~~~~~~~~~~~~~~~~~~~~~  
> B\_zero\_point, B\_scale,  
> ~~~~~~~~~~~~~~~~~~~~~~  
> static\_cast\<uint8\_t\>(Y\_zero\_point), Y\_scale,  
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
> activationLimits(Y\_scale, Y\_zero\_point, Ac).first,  
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
> activationLimits(Y\_scale, Y\_zero\_point, Ac).second,  
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
> &qnnpackOperator\_);  
> ~~~~~~~~~~~~~~~~~~  
> /home/phung/Downloads/pytorch/caffe2/operators/quantized/int8\_add\_op.h:73:57: error: ‘qnnp\_setup\_add\_nc\_q8’ was not declared in this scope  
> const qnnp\_status setupStatus = qnnp\_setup\_add\_nc\_q8(  
> ~~~~~~~~~~~~~~~~~~~~ ^  
> this-\>qnnpackOperator\_,  
> ~~~~~~~~~~~~~~~~~~~~~~~  
> A.t.numel() /_ batch size _/,  
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
> A.t.template data\<uint8\_t\>(),  
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
> 1 /_ A stride _/,  
> ~~~~~~~~~~~~~~~~~  
> B.t.template data\<uint8\_t\>(),  
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
> 1 /_ B stride _/,  
> ~~~~~~~~~~~~~~~~~  
> Y-\>t.template mutable\_data\<uint8\_t\>(),  
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
> 1 /_ Y stride \*/);  
> ~~~~~~~~~~~~~~~~~  
> caffe2/CMakeFiles/caffe2.dir/build.make:12990: recipe for target ‘caffe2/CMakeFiles/caffe2.dir/operators/quantized/int8\_add\_op.cc.o’ failed  
> make[2]: \*\*\* [caffe2/CMakeFiles/caffe2.dir/operators/quantized/int8\_add\_op.cc.o] Error 1  
> make[2]: \*\*\* Waiting for unfinished jobs…  
> CMakeFiles/Makefile2:4589: recipe for target ‘caffe2/CMakeFiles/caffe2.dir/all’ failed  
> make[1]: \*\*\* [caffe2/CMakeFiles/caffe2.dir/all] Error 2  
> Makefile:140: recipe for target ‘all’ failed  
> make: \*\*\* [all] Error 2  
> Failed to run ‘bash …/tools/build\_pytorch\_libs.sh --use-cuda --use-nnpack --use-mkldnn --use-qnnpack caffe2’  
> phung@UbuntuHW15:~/Downloads/pytorch$

---

<div class="post-metadata">

**Author:** ![Laurent](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/laurent/32/7439_2.png) [@Laurent](https://discuss.pytorch.org/u/Laurent)\
**Post date:** [November 25, 2018, 4:33pm UTC](https://discuss.pytorch.org/t/qnnp-setup-add-nc-q8-was-not-declared-in-this-scope/30245/2 "2018-11-25T16:33:55Z")

</div>

I encountered the same issue today and got around it by updating my qnnpack submodule.

```auto
cd third_party/QNNPACK
git pull origin master

```

As it worked with the current master branch I haven’t spent more time thinking about which version qnnpack should be updated to.

If this does not work, you may also consider disabling qnnpack build, there is a NO\_QNNPACK option but I haven’t tried it.

---

<div class="post-metadata">

**Author:** ![promach](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/promach/32/22571_2.png) [@promach](https://discuss.pytorch.org/u/promach)\
**Post date:** [December 3, 2018, 4:01am UTC](https://discuss.pytorch.org/t/qnnp-setup-add-nc-q8-was-not-declared-in-this-scope/30245/3 "2018-12-03T04:01:22Z")

</div>

I have followed your suggestion regarding QNNPACK , but I faced some other error as follows:

Do you have any idea ?

```auto
[56%] Building CXX object caffe2/CMakeFiles/caffe2_pybind11_state.dir/python/pybind_state_dlpack.cc.o
[56%] Building NVCC (Device) object caffe2/CMakeFiles/caffe2_gpu.dir/__/aten/src/THC/caffe2_gpu_generated_THCTensorMath.cu.o
[56%] Building CXX object caffe2/torch/lib/THD/CMakeFiles/THD.dir/base/Cuda.cpp.o
[56%] Building NVCC (Device) object caffe2/CMakeFiles/caffe2_gpu.dir/__/aten/src/THC/caffe2_gpu_generated_THCTensorMathBlas.cu.o
/home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc: In lambda function:
/home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc:346:32: error: ‘const class pybind11::object’ has no member named ‘is’
             if (!device_option.is(py::none())) {
                                ^~
/home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc: In function ‘void caffe2::python::addObjectMethods(pybind11::module&)’:
/home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc:682:8: error: no matching function for call to ‘init(caffe2::python::addObjectMethods(pybind11::module&)::<lambda(const std::vector<pybind11::bytes>&, const std::vector<pybind11::bytes>&, const std::vector<std::__cxx11::basic_string<char> >&)>)’
       }));
        ^
In file included from /home/phung/Downloads/pytorch/caffe2/python/pybind_state_dlpack.h:9:0,
                 from /home/phung/Downloads/pytorch/caffe2/python/pybind_state.h:16,
                 from /home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc:1:
/usr/include/pybind11/pybind11.h:1418:51: note: candidate: template<class ... Args> pybind11::detail::init<Args ...> pybind11::init()
 template <typename... Args> detail::init<Args...> init() { return detail::init<Args...>(); }
                                                   ^~~~
/usr/include/pybind11/pybind11.h:1418:51: note: template argument deduction/substitution failed:
/home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc:682:8: note: candidate expects 0 arguments, 1 provided
       }));
        ^
/home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc: In lambda function:
/home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc:689:22: error: ‘const class pybind11::object’ has no member named ‘is’
             if (args.is(py::none())) {
                      ^~
/home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc: In function ‘void caffe2::python::addObjectMethods(pybind11::module&)’:
/home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc:884:12: error: no matching function for call to ‘init(caffe2::python::addObjectMethods(pybind11::module&)::<lambda(pybind11::bytes, pybind11::bytes)>)’
           }))
            ^
In file included from /home/phung/Downloads/pytorch/caffe2/python/pybind_state_dlpack.h:9:0,
                 from /home/phung/Downloads/pytorch/caffe2/python/pybind_state.h:16,
                 from /home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc:1:
/usr/include/pybind11/pybind11.h:1418:51: note: candidate: template<class ... Args> pybind11::detail::init<Args ...> pybind11::init()
 template <typename... Args> detail::init<Args...> init() { return detail::init<Args...>(); }
                                                   ^~~~
/usr/include/pybind11/pybind11.h:1418:51: note: template argument deduction/substitution failed:
/home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc:884:12: note: candidate expects 0 arguments, 1 provided
           }))
            ^
[56%] Building CXX object modules/observers/CMakeFiles/caffe2_observers.dir/observer_config.cc.o
/home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc: In lambda function:
/home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc:1053:31: error: ‘const class pybind11::object’ has no member named ‘is’
         if (create_if_missing.is(py::none())) {
                               ^~
/home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc: In lambda function:
/home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc:1065:25: error: ‘const class pybind11::object’ has no member named ‘is’
         if (root_folder.is(py::none())) {
                         ^~
[56%] Linking CXX shared library ../../lib/libcaffe2_module_test_dynamic.so
/home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc: In lambda function:
/home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc:1438:28: error: ‘class pybind11::object’ has no member named ‘is’
         if (!device_option.is(py::none())) {
                            ^~
In file included from /home/phung/Downloads/pytorch/caffe2/core/logging.h:2:0,
                 from /home/phung/Downloads/pytorch/caffe2/core/allocator.h:8,
                 from /home/phung/Downloads/pytorch/caffe2/core/context.h:9,
                 from /home/phung/Downloads/pytorch/caffe2/python/pybind_state.h:5,
                 from /home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc:1:
/home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc: In lambda function:
/home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc:1492:29: error: ‘class pybind11::object’ has no member named ‘is’
         CAFFE_ENFORCE(!func.is(py::none()));
                             ^
/home/phung/Downloads/pytorch/c10/util/Logging.h:82:11: note: in definition of macro ‘CAFFE_ENFORCE’
     if (!(condition)) { \
           ^ ~~~~~~~~
/home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc: In lambda function:
/home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc:1508:29: error: ‘class pybind11::object’ has no member named ‘is’
         CAFFE_ENFORCE(!func.is(py::none()));
                             ^
/home/phung/Downloads/pytorch/c10/util/Logging.h:82:11: note: in definition of macro ‘CAFFE_ENFORCE’
     if (!(condition)) { \
           ^ ~~~~~~~~
[56%] Built target caffe2_module_test_dynamic
[56%] Building CXX object modules/observers/CMakeFiles/caffe2_observers.dir/perf_observer.cc.o
/home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc: At global scope:
/home/phung/Downloads/pytorch/caffe2/python/pybind_state.cc:1769:16: error: expected constructor, destructor, or type conversion before ‘(’ token
 PYBIND11_MODULE(caffe2_pybind11_state, m) {
                ^
[56%] Building CXX object caffe2/CMakeFiles/caffe2_pybind11_state.dir/python/pybind_state_nomni.cc.o

```

---

<div class="post-metadata">

**Author:** ![Laurent](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/laurent/32/7439_2.png) [@Laurent](https://discuss.pytorch.org/u/Laurent)\
**Post date:** [December 3, 2018, 8:44am UTC](https://discuss.pytorch.org/t/qnnp-setup-add-nc-q8-was-not-declared-in-this-scope/30245/4 "2018-12-03T08:44:34Z")

</div>

I didn’t have this problem. pybind11 is also a submodule of pytorch so it may be worth trying to update it too ?  
The following command will update all submodules

```auto
git submodule update --recursive

```

---

<div class="post-metadata">

**Author:** ![promach](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/promach/32/22571_2.png) [@promach](https://discuss.pytorch.org/u/promach)\
**Post date:** [December 4, 2018, 6:02am UTC](https://discuss.pytorch.org/t/qnnp-setup-add-nc-q8-was-not-declared-in-this-scope/30245/5 "2018-12-04T06:02:36Z")

</div>

I have pulled the latest commit for pybind11 , but the problem still persists. Why ?
