Solved by ptrblck in post #2 
              
              
                You could get the shape of the input via: x.size() or x.shape and use the functional API via out = F.adaptive_max_pool2d(out, output_size=...).