MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / TEST

Function TEST

tensorflow/core/util/sparse/sparse_tensor_test.cc:59–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57}
58
59TEST(SparseTensorTest, DimComparatorSorts) {
60 int64 N = 5;
61 const int NDIM = 3;
62 auto ix = GetSimpleIndexTensor(N, NDIM);
63 TTypes<int64>::Matrix map(ix.data(), N, NDIM);
64
65 std::vector<int64> sorting(N);
66 for (std::size_t n = 0; n < N; ++n) sorting[n] = n;
67
68 // new order should be: {0, 4, 3, 2, 1}
69 std::vector<int64> order{0, 1, 2};
70 std::vector<int64> shape{N, N, N};
71 DimComparator sorter(map, order, shape);
72 std::sort(sorting.begin(), sorting.end(), sorter);
73 EXPECT_EQ(sorting, std::vector<int64>({0, 4, 3, 2, 1}));
74
75 FixedDimComparator<3> sorter_fixed(map, order, shape);
76 std::sort(sorting.begin(), sorting.end(), sorter_fixed);
77 EXPECT_EQ(sorting, std::vector<int64>({0, 4, 3, 2, 1}));
78
79 // new order should be: {0, 3, 2, 1, 4}
80 std::vector<int64> order1{2, 0, 1};
81 DimComparator sorter1(map, order1, shape);
82 for (std::size_t n = 0; n < N; ++n) sorting[n] = n;
83 std::sort(sorting.begin(), sorting.end(), sorter1);
84 EXPECT_EQ(sorting, std::vector<int64>({0, 3, 2, 1, 4}));
85
86 FixedDimComparator<3> sorter1_fixed(map, order1, shape);
87 for (std::size_t n = 0; n < N; ++n) sorting[n] = n;
88 std::sort(sorting.begin(), sorting.end(), sorter1_fixed);
89 EXPECT_EQ(sorting, std::vector<int64>({0, 3, 2, 1, 4}));
90}
91
92TEST(SparseTensorTest, SparseTensorInvalidIndicesType) {
93 int N = 5;

Callers

nothing calls this directly

Calls 15

GetSimpleIndexTensorFunction · 0.85
sortFunction · 0.85
CreateFunction · 0.70
TensorShapeClass · 0.50
evalFunction · 0.50
dataMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
codeMethod · 0.45
okMethod · 0.45
groupMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected