# How to fully optimize a custom convolution layer?

**URL:** <https://discuss.pytorch.org/t/how-to-fully-optimize-a-custom-convolution-layer/129785>\
**Category:** Uncategorized\
**Created:** [August 19, 2021, 5:22pm UTC](https://discuss.pytorch.org/t/how-to-fully-optimize-a-custom-convolution-layer/129785 "2021-08-19T17:22:00Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![arman-yekkehkhani](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/arman-yekkehkhani/32/32661_2.png) [@arman-yekkehkhani](https://discuss.pytorch.org/u/arman-yekkehkhani)\
**Post date:** [August 22, 2021, 6:57pm UTC](https://discuss.pytorch.org/t/how-to-fully-optimize-a-custom-convolution-layer/129785/5 "2021-08-22T18:57:31Z")

</div>

@ptrblck Thanks! I followed the link and it was helpful. However, I have another idea for the optimization of memory consumption. In this [code](https://discuss.pytorch.org/t/implementing-a-custom-convolution-using-conv2d-input-and-conv2d-weight/18556/24), we save `input, weight, bias` in the `ctx` for backward pass computations, which is supposedly the source of huge memory consumption. Since we have already allocated these tensors elsewhere(e.g. `weight` is th the torch.Parameter in a conv layer). I wonder how we can avoid this redundancy. At least we know that the native PyTorch implementation of Conv layer has already solved this problem. Do you know any alternates for this purpose?

---

_[View the full topic](https://discuss.pytorch.org/t/how-to-fully-optimize-a-custom-convolution-layer/129785)._
