Torch.onnx.export for nn.LocalResponseNorm

tom7: <p>When I converted nn.LocalResponseNorm(size=5, alpha=1e-4, beta=0.75, k=2.) to onnx using torch.onnx.export, lots of layers are generated, and consume time more in inference. The code and onnx model are shown below.</p>
<pre><code class="lang-auto">class AlexNetADDCStandard_LRN(nn.Module):
    def __init__(self, num_classes: int = 1000, dropout: float = 0.5):
    #def __init__(self, num_classes=1000):
        super(AlexNetADDCStandardLRN, self).__init__()

        self.features = nn.Sequential(
            #nn.Conv2d( 3,  96, kernel_size=11, stride=4, padding=2),
            nn.Conv2d( 3,  96, kernel_size=11, stride=4, padding=0),
            nn.ReLU(inplace=True),
            nn.LocalResponseNorm(size=5, alpha=1e-4, beta=0.75, k=2.), # add LRN
            #nn.MaxPool2d(kernel_size=3, stride=2),

            nn.Conv2d(96, 256, kernel_size=5, padding=2),
            ...
</code></pre>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/1/f/1f2f0cb156593b69b99e4cc00b865c2a6b6dfa22.png" data-download-href="https://discuss.pytorch.org/uploads/default/1f2f0cb156593b69b99e4cc00b865c2a6b6dfa22" title="コメント 2023-02-20 172016"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/1/f/1f2f0cb156593b69b99e4cc00b865c2a6b6dfa22_2_369x500.png" alt="コメント 2023-02-20 172016" data-base62-sha1="4rRBv1MQK2UUfLGBwRtQ2BoXkOK" width="369" height="500" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/1/f/1f2f0cb156593b69b99e4cc00b865c2a6b6dfa22_2_369x500.png, https://discuss.pytorch.org/uploads/default/optimized/3X/1/f/1f2f0cb156593b69b99e4cc00b865c2a6b6dfa22_2_553x750.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/1/f/1f2f0cb156593b69b99e4cc00b865c2a6b6dfa22.png 2x" data-dominant-color="F0F0F0"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">コメント 2023-02-20 172016</span><span class="informations">622×841 37.6 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>
<p>However, onnx suppotrs a LRN operation layer independently, and I found that below model is possble. Can torch.onnx.export generate just one LRN layer ??</p>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/1/b/1b169772a294d9d862526942ea6048d9df4653a5.png" data-download-href="https://discuss.pytorch.org/uploads/default/1b169772a294d9d862526942ea6048d9df4653a5" title="コメント 2023-02-20 172457"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/1/b/1b169772a294d9d862526942ea6048d9df4653a5_2_270x500.png" alt="コメント 2023-02-20 172457" data-base62-sha1="3RDie0vQ6VUViOYkf4EcR1h1Qfb" width="270" height="500" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/1/b/1b169772a294d9d862526942ea6048d9df4653a5_2_270x500.png, https://discuss.pytorch.org/uploads/default/optimized/3X/1/b/1b169772a294d9d862526942ea6048d9df4653a5_2_405x750.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/1/b/1b169772a294d9d862526942ea6048d9df4653a5.png 2x" data-dominant-color="E5E5E5"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">コメント 2023-02-20 172457</span><span class="informations">420×777 17.9 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>