GPU Calc: add an inline function to legalize inputs for reduction.

Change-Id: Ibcede4a33d7b8b1073d6ecfb49abbc78b31a2f35