* Assign a new `tf.Tensor` to this variable. The new `tf.Tensor` must have * the same shape and dtype as the old `tf.Tensor`. * * @param newValue New tensor to be assigned to this variable. * * @doc {heading: 'Tensors', subheading: 'Classes'}
(newValue: Tensor<R>)
| 581 | * @doc {heading: 'Tensors', subheading: 'Classes'} |
| 582 | */ |
| 583 | assign(newValue: Tensor<R>): void { |
| 584 | if (newValue.dtype !== this.dtype) { |
| 585 | throw new Error( |
| 586 | `dtype of the new value (${newValue.dtype}) and ` + |
| 587 | `previous value (${this.dtype}) must match`); |
| 588 | } |
| 589 | if (!util.arraysEqual(newValue.shape, this.shape)) { |
| 590 | throw new Error( |
| 591 | `shape of the new value (${newValue.shape}) and ` + |
| 592 | `previous value (${this.shape}) must match`); |
| 593 | } |
| 594 | trackerFn().disposeTensor(this); |
| 595 | this.dataId = newValue.dataId; |
| 596 | trackerFn().incRef(this, null /* backend */); |
| 597 | } |
| 598 | |
| 599 | override dispose(): void { |
| 600 | trackerFn().disposeVariable(this); |
no test coverage detected