Unary Tensor Operations
-
Book Excerpt from "Generative AI in C++" (full text online)
-
by David Spuler, Ph.D.
Unary Tensor Operations
Like a 2-D matrix, there are various simple operations we can define on a single tensor. The various element-wise operations apply individually to each tensor item.
- Clear or set to a value
- Add or subtract a scalar
- Multiply or divide by a scalar
Similarly, we could apply a particular unary mathematical function to each element separately: square root, exponentiation, natural logarithm, and more.