Optimization of input tensors

For completeness: also partially answered here.