Len returns the total length of elements in the tensor (i.e., the product of the shape sizes)
()
| 56 | // Len returns the total length of elements in the tensor |
| 57 | // (i.e., the product of the shape sizes) |
| 58 | func (sh *Shape) Len() int { |
| 59 | if len(sh.Sizes) == 0 { |
| 60 | return 0 |
| 61 | } |
| 62 | o := int(1) |
| 63 | for _, v := range sh.Sizes { |
| 64 | o *= v |
| 65 | } |
| 66 | return int(o) |
| 67 | } |
| 68 | |
| 69 | // NumDims returns the total number of dimensions. |
| 70 | func (sh *Shape) NumDims() int { return len(sh.Sizes) } |
no outgoing calls
no test coverage detected