* Push a tensor to the end of the list. * @param tensor Tensor to be pushed.
(tensor: Tensor)
| 156 | * @param tensor Tensor to be pushed. |
| 157 | */ |
| 158 | pushBack(tensor: Tensor) { |
| 159 | if (tensor.dtype !== this.elementDtype) { |
| 160 | throw new Error(`Invalid data types; op elements ${ |
| 161 | tensor.dtype}, but list elements ${this.elementDtype}`); |
| 162 | } |
| 163 | |
| 164 | assertShapesMatchAllowUndefinedSize( |
| 165 | tensor.shape, this.elementShape, 'TensorList shape mismatch: '); |
| 166 | |
| 167 | if (this.maxNumElements === this.size()) { |
| 168 | throw new Error(`Trying to push element into a full list.`); |
| 169 | } |
| 170 | keep(tensor); |
| 171 | this.tensors.push(tensor); |
| 172 | } |
| 173 | |
| 174 | /** |
| 175 | * Update the size of the list. |
no test coverage detected