Maxpool2d never considers the channel dimension in the Max operation as said in the docs. Instead it goes over each channel in each sample in the mini batch. Thus, For an input of (N, C, H, W), maxpool2d will give you (N, C, Hout, Wout), where Hout, Wout are calculated from the parameters to the maxpool2d function. Well it did say 2D in the name, didn’t it.
If you can be a bit more specific in what you are want to do, someone might be able to help you out.
If you want to do over channels as well, maybe you can try maxpool3d with an added dummy dimension.
Or if it is going to be only max over channel dimension only, you can also try using max operation along that dimension. But you won’t be able to backpropagate as max is non differentiable.
References