public long ElementCount() { if (elementCount.HasValue) { return(elementCount.Value); } elementCount = TensorDimensionHelpers.ElementCount(sizes); return(elementCount.Value); }
public long ElementCount() { if (this.elementCount.HasValue) { return(this.elementCount.Value); } this.elementCount = TensorDimensionHelpers.ElementCount(this.Sizes); return(this.elementCount.Value); }
public Tensor View(params long[] sizes) { if (!this.IsContiguous()) { throw new InvalidOperationException("Cannot use View on a non-contiguous tensor"); } if (this.ElementCount() != TensorDimensionHelpers.ElementCount(sizes)) { throw new InvalidOperationException("Output tensor must have the same number of elements as the input"); } return(new Tensor(sizes, TensorDimensionHelpers.GetContiguousStride(sizes), this.storage, this.storageOffset)); }