Masking layers that are not RNNs

Is there a way to mask inputs in Convolutions or Linear layers like it is done in RNNs with pack_padded_sequence and pad_packed_sequence?