resize method
For dynamic buffer, resize the memory if needed. For fixed-size buffer, check if the
shape
of src fits the buffer size.
Implementation
@protected
void resize(List<int> shape) {
if (_isDynamic) {
_allocateMemory(shape);
} else {
// Make sure the new shape fits the buffer size when TensorBuffer has fixed size.
SupportPreconditions.checkArgument(
(computeFlatSize(shape) == computeFlatSize(this.shape)));
this.shape = List<int>.from(shape);
}
}