ToSlice returns the (possibly partially known) shape represented by s as a slice, or an error if the number of dimensions is not known.
()
| 82 | // ToSlice returns the (possibly partially known) shape represented by s as a |
| 83 | // slice, or an error if the number of dimensions is not known. |
| 84 | func (s Shape) ToSlice() ([]int64, error) { |
| 85 | if s.dims == nil { |
| 86 | return nil, fmt.Errorf("cannot create a slice for a Shape with an unknown number of dimensions") |
| 87 | } |
| 88 | cpy := make([]int64, len(s.dims)) |
| 89 | copy(cpy, s.dims) |
| 90 | return cpy, nil |
| 91 | } |
| 92 | |
| 93 | func (s Shape) String() string { |
| 94 | if s.dims == nil { |