1 #include <gtest/gtest.h> 6 void TestSimpleCase(
Type&
T) {
7 auto a = randn({2, 3, 4, 5}, T);
8 ASSERT_TRUE(a.prod(-4).equal(a.prod(0)));
9 ASSERT_TRUE(a.prod(3).equal(a.prod(-1)));
12 void TestExpressionSpecification(
Type& T) {
13 auto a = randn({2, 3, 4, 5}, T);
14 ASSERT_TRUE(a.unsqueeze(-5).equal(a.unsqueeze(0)));
15 ASSERT_TRUE(a.unsqueeze(4).equal(a.unsqueeze(-1)));
19 b.unsafeGetTensorImpl()->maybe_zero_dim(
true);
20 ASSERT_TRUE(b.unsqueeze(0).equal(b.unsqueeze(-1)));
23 void TestEmptyTensor(
Type& T) {
25 ASSERT_TRUE(a.prod(0).equal(at::ones({}, T)));
28 void TestScalarVs1Dim1Size(
Type& T) {
30 ASSERT_TRUE(a.prod(0).equal(a.prod(-1)));
31 a.unsafeGetTensorImpl()->maybe_zero_dim(
true);
32 ASSERT_EQ(a.dim(), 0);
33 ASSERT_TRUE(a.prod(0).equal(a.prod(-1)));
36 TEST(TestWrapdim, TestWrapdim) {
38 Type& T = CPU(kFloat);
42 TestScalarVs1Dim1Size(T);
43 TestExpressionSpecification(T);
Flush-To-Zero and Denormals-Are-Zero mode.