示例#1
0
        public long ElementCount()
        {
            if (elementCount.HasValue)
            {
                return(elementCount.Value);
            }

            elementCount = TensorDimensionHelpers.ElementCount(sizes);
            return(elementCount.Value);
        }
示例#2
0
        public long ElementCount()
        {
            if (this.elementCount.HasValue)
            {
                return(this.elementCount.Value);
            }

            this.elementCount = TensorDimensionHelpers.ElementCount(this.Sizes);
            return(this.elementCount.Value);
        }
示例#3
0
        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));
        }