public void TestReshapeShort1DFail()
        {
            Tensor <short> x = ShortTorchTensor.Create(10);

            x.Fill((short)1);

            Assert.Throws <ArgumentException>(() => x.Reshape(new int[] { 9 }));
        }
        public void TestShapeAndStridesShort4D()
        {
            var x = ShortTorchTensor.Create(10, 10, 3, 10);

            for (int i = 0; i < 4; i++)
            {
                Assert.Equal(x.Dimensions[0], (int)x.TorchSharpTensor.GetTensorDimension(0));
                Assert.Equal(x.Strides[0], (int)x.TorchSharpTensor.GetTensorStride(0));
            }
        }
        public void TestFillShort1D()
        {
            Tensor <short> x = ShortTorchTensor.Create(10);

            x.Fill((short)30);

            for (int i = 0; i < x.Dimensions[0]; i++)
            {
                Assert.Equal(30, x[i]);
            }
        }
        public void TestFillBySetShort1D()
        {
            Tensor <short> x = ShortTorchTensor.Create(10);

            for (int i = 0; i < x.Dimensions[0]; i++)
            {
                x[i] = (short)30;
            }

            for (int i = 0; i < x.Dimensions[0]; i++)
            {
                Assert.Equal(x[i], (short)30);
            }
        }
        public void TestCloneEmptyShort1D()
        {
            Tensor <short> x = ShortTorchTensor.Create(10);

            x.Fill((short)1);

            Tensor <short> y = x.CloneEmpty();

            Assert.Equal(y.Dimensions.ToArray(), x.Dimensions.ToArray());

            for (int i = 0; i < x.Dimensions[0]; i++)
            {
                Assert.Equal(y[i], (short)0);
            }
        }
        public void TestDanglingMemoryShort()
        {
            Memory <short> buffer;

            using (var x = ShortTorchTensor.Create(10))
            {
                x.Fill(33);
                buffer = x.Buffer;
            }

            var arr = buffer.ToArray();

            for (int i = 0; i < 10; i++)
            {
                Assert.Equal(33, arr[i]);
            }
        }
        public void TestReshapeShort2D()
        {
            var x = ShortTorchTensor.Create(5, 10);

            var y = x.Reshape(new int[] { 10, 5 });

            for (int i = 0; i < 2; i++)
            {
                Assert.Equal(x.Dimensions[0], (int)x.TorchSharpTensor.GetTensorDimension(0));
                Assert.Equal(x.Strides[0], (int)x.TorchSharpTensor.GetTensorStride(0));
            }

            Equals(x.Dimensions.ToArray(), new int[] { 5, 10 });
            Equals(x.Strides.ToArray(), new int[] { 1, 10 });
            Equals(y.Dimensions.ToArray(), new int[] { 10, 5 });
            Equals(y.Strides.ToArray(), new int[] { 1, 5 });
        }
        public void TestReshapeShort1D()
        {
            Tensor <short> x = ShortTorchTensor.Create(10);

            for (int i = 0; i < x.Dimensions[0]; i++)
            {
                x[i] = (short)i;
            }

            Tensor <short> y = x.Reshape(new int[] { 10 });

            for (int i = 0; i < x.Dimensions[0]; i++)
            {
                Assert.Equal(y[i], (short)i);
                Assert.Equal(x[i], (short)i);
            }
        }
        public void TestCloneShort1D()
        {
            Tensor <short> x = ShortTorchTensor.Create(10);

            x.Fill((short)1);

            Tensor <short> y = x.Clone();

            for (int i = 0; i < x.Dimensions[0]; i++)
            {
                Assert.Equal(x[i], y[i]);
            }

            y[5] = (short)0;

            Assert.NotEqual(x[5], y[5]);
        }
        public void TestReshapeShort1DPointToTheSameStorage()
        {
            Tensor <short> x = ShortTorchTensor.Create(10);

            for (int i = 0; i < x.Dimensions[0]; i++)
            {
                x[i] = (short)i;
            }

            Tensor <short> y = x.Reshape(new int[] { 10 });

            y[5] = (short)0;

            for (int i = 0; i < x.Dimensions[0]; i++)
            {
                Assert.Equal(y[i], x[i]);
            }
        }
        public void TestFillBySetShort2D()
        {
            Tensor <short> x = ShortTorchTensor.Create(10, 10);

            for (int i = 0; i < x.Dimensions[0]; i++)
            {
                for (int j = 0; j < x.Dimensions[1]; j++)
                {
                    x[i, j] = (short)30;
                }
            }

            for (int i = 0; i < x.Dimensions[0]; i++)
            {
                for (int j = 0; j < x.Dimensions[1]; j++)
                {
                    Assert.Equal(x[i, j], (short)30);
                }
            }
        }
        public void TestFillEquivalanceShort2D()
        {
            var x = ShortTorchTensor.Create(10, 10);

            for (int i = 0; i < x.Dimensions[0]; i++)
            {
                for (int j = 0; j < x.Dimensions[1]; j++)
                {
                    short tmp = (short)(i + j);
                    x[i, j] = tmp;
                }
            }

            for (int i = 0; i < x.Dimensions[0]; i++)
            {
                for (int j = 0; j < x.Dimensions[1]; j++)
                {
                    Assert.Equal(x[i, j], x.TorchSharpTensor[i, j]);
                }
            }
        }
        public void TestReshape2ShortD2()
        {
            var x = ShortTorchTensor.Create(5, 10);

            for (int i = 0; i < x.Dimensions[0]; i++)
            {
                for (int j = 0; j < x.Dimensions[1]; j++)
                {
                    short tmp = (short)(i + j);
                    x[i, j] = tmp;
                }
            }

            Tensor <short> y = x.Reshape(new int[] { 10, 5 });

            for (int i = 0; i < 1; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    Assert.Equal(x[i, j], y[i * 2 + j / 5, j % 5]);
                }
            }
        }
 public void TestCreationShort0D()
 {
     Assert.Throws <ArgumentOutOfRangeException>(() => ShortTorchTensor.Create());
 }
        public void TestCreationShort4D()
        {
            Tensor <short> x = ShortTorchTensor.Create(10, 10, 3, 10);

            Assert.NotNull(x);
        }