* @brief Returns the number of elements in a tensor with the given shape, * which is equal to the product of the dimensions. * @param[in] shape Shape of the tensor * @return Number of elements in the tensor * * @code * size({256, 256}) -> 65536 * @endcode */
| 84 | * @endcode |
| 85 | */ |
| 86 | inline size_t size(const Shape &shape) { |
| 87 | size_t numels = 1; |
| 88 | for (size_t i = 0; i < shape.rank; i++) { |
| 89 | numels *= shape.data[i]; |
| 90 | } |
| 91 | return numels; |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * @brief Represents a tensor on the GPU, which is a buffer of values with a |
no outgoing calls
no test coverage detected