Assume that a convolutional layer consists of a single 3x3 kernel and the depth of input is 5. In this case, the kernel is in fact a 3x3x5 filter where the dot product of inputs and the filter is added to bias to generate a single output. How can I modify this in PyTorch to implement something like:

find the dot product of each filter for different input channels separately.
connect the output of each channel to another neuron with trainable weights and a bias.

In other words, instead of summing the output of different input channels, I would like to find a weighted sum of these dot products.
Using groups was one of the solutions I thought of, but I think the outputs are concatenated automatically, so I will not have access to outputs in order to feed them to learnable weights in the next layer.
Is it possible to implement this structure using basic operations in PyTorch?
If yes, how could the answer be generalized to k nxnxd kernels?