it’s hard to understand what your padding does, but as for mask, you can just do mask with 1 and 0, then element-wise multiplication. Yet, why can’t you skip padding and mask if you have kernel size 1?