How to compute per-channel sum fast?

glad it worked,
Actually, there is no built-in function for max or argmax like sum. But you can do the trick something similar to this post: