Why does quantized tensor * 2 returns error?

username: dalseeroh
cooked: <p>I just recently figured out this simple operation returns error.</p>
<pre><code class="lang-auto">class QNet(nn.Module):
    def __init__(self):
        super(QNet, self).__init__()
        self.quant = QuantStub()
        self.dequant = DeQuantStub()
        self.conv = nn.Conv2d(1, 1, 1)
        self.bn = nn.BatchNorm2d(1)
        self.relu = nn.ReLU()

    def forward(self, x):
        x = self.quant(x)
        x = self.conv(x)
        x = x * 2           # &lt;&lt;&lt;&lt; Error
        x = self.bn(x)
        x = self.relu(x)
        x = self.dequant(x)
        return x

NotImplementedError: Could not run 'aten::empty_strided' with arguments from the 'QuantizedCPU' backend. This could be because the operator doesn't exist for this backend, or was omitted during the selective/custom build process (if using custom build). If you are a Facebook employee using PyTorch on mobile, please visit https://fburl.com/ptmfixes for possible resolutions. 'aten::empty_strided' is only available for these backends: [CPU, CUDA, Meta, BackendSelect, Python, Named, Conjugate, ADInplaceOrView, AutogradOther, AutogradCPU, AutogradCUDA, AutogradXLA, UNKNOWN_TENSOR_TYPE_ID, AutogradMLC, AutogradHPU, AutogradNestedTensor, AutogradPrivateUse1, AutogradPrivateUse2, AutogradPrivateUse3, Tracer, UNKNOWN_TENSOR_TYPE_ID, Autocast, Batched, VmapMode].

</code></pre>
<p>Is this because quantized tensor only operates with quantized objects?</p>

username: jerryzh168
cooked: <p>please take a look at the response here: <a href="https://discuss.pytorch.org/t/notimplementederror-could-not-run-aten-empty-memory-format-with-arguments-from-the-quantizedcpu-backend/138618/3" class="inline-onebox">NotImplementedError: Could not run 'aten::empty.memory_format' with arguments from the 'QuantizedCPU' backend - #3 by jerryzh168</a></p>

username: dalseeroh
cooked: <p>I really appreciated your reply! However, I realized some FloatFunctional() ops are slower than FP32?</p>
<aside class="quote quote-modified" data-post="1" data-topic="139239">
  <div class="title">
    <div class="quote-controls"></div>
    <img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/dalseeroh/48/29798_2.png" class="avatar">
    <a href="https://discuss.pytorch.org/t/slower-ops-in-quantized-mul-quantized-cat/139239">Slower ops in quantized::mul, quantized::cat</a> <a class="badge-category__wrapper " href="/c/quantization/17"><span data-category-id="17" data-drop-close="true" class="badge-category " title="This category is for questions, discussion and issues related to PyTorch’s quantization feature."><span class="badge-category__name">quantization</span></span></a>
  </div>
  <blockquote>
    Hello, 
During quantization, I realized quantized operations such as quantized::mul, quantized::cat are x10 slower than fp32 ops. 
Is the only workaround wrapping those functions with dequant() and quant()? Please refer to the profiling below… 
FP32 Profiling (CPU)
--------------------------------  ------------  ------------  ------------  ------------  ------------  ------------  ------------  ------------  
                            Name    Self CPU %      Self CPU   CPU total %     CPU tota…
  </blockquote>
</aside>