Esempio n. 1
0
        public Tensor(int[] shape, float[] data = null)
        {
            Shape = shape;

            var total = shape.Aggregate(1, (acc, x) => acc * x);

            Buffer = GpuBackend.AllocateBuffer(total);

            if (data != null)
            {
                UnityEngine.Debug.Assert(data.Length == total);
                Buffer.SetData(data);
            }
        }
Esempio n. 2
0
        public Tensor(Shape shape, float[] data = null)
        {
            Shape = shape;

            var total = shape.ElementCount;

            Buffer = GpuBackend.AllocateBuffer(total);

            if (data != null)
            {
                UnityEngine.Debug.Assert(data.Length == total);
                Buffer.SetData(data);
            }
        }
Esempio n. 3
0
        public void Reset(Shape shape)
        {
            Shape = shape;

            var total = shape.ElementCount;

            if (Buffer != null && total != Buffer.count)
            {
                GpuBackend.ReleaseBuffer(Buffer);
                Buffer = null;
            }

            if (Buffer == null && total > 0)
            {
                Buffer = GpuBackend.AllocateBuffer(total);
            }
        }