Shape returns the shape of the Tensor referenced by th.
()
| 73 | |
| 74 | // Shape returns the shape of the Tensor referenced by th. |
| 75 | func (th *TensorHandle) Shape() ([]int64, error) { |
| 76 | n, err := th.numDims() |
| 77 | if err != nil { |
| 78 | return nil, err |
| 79 | } |
| 80 | r := make([]int64, n) |
| 81 | for i := 0; i < n; i++ { |
| 82 | if r[i], err = th.dim(i); err != nil { |
| 83 | return nil, err |
| 84 | } |
| 85 | } |
| 86 | return r, nil |
| 87 | } |
| 88 | |
| 89 | // numDims returns the number of dimensions of the TensorHandle. It blocks |
| 90 | // until the operation that produces the handle has completed. |