Source code compiles.  Start from this commit.
Adding total_sum so I can reduce a tensor to a scalar.