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

Function TEST

tensorflow/core/kernels/tensor_flag_utils_test.cc:38–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36using tensorflow::tensor_flag_utils::ValidateSparseMatrixShardingConfig;
37
38TEST(SparseUtilsTest, ValidateSparseMatrixShardingConfig) {
39 // Only a default is specified.
40 {
41 Tensor t(DataType::DT_FLOAT, {});
42 t.scalar<float>()() = 0.7;
43 EXPECT_TRUE(ValidateSparseMatrixShardingConfig(t).ok());
44 }
45 {
46 Tensor t(DataType::DT_FLOAT, {});
47 t.scalar<float>()() = 1.0;
48 EXPECT_TRUE(ValidateSparseMatrixShardingConfig(t).ok());
49 }
50
51 // Misshapen.
52 {
53 Tensor t(DataType::DT_FLOAT, {1, 1});
54 int indx = 0;
55 for (const float v : {60.0}) {
56 t.flat<float>()(indx++) = v;
57 }
58 EXPECT_EQ(INVALID_ARGUMENT, ValidateSparseMatrixShardingConfig(t).code());
59 }
60 {
61 Tensor t(DataType::DT_FLOAT, {1, 2});
62 int indx = 0;
63 for (const float v : {
64 60.0,
65 50.0,
66 }) {
67 t.flat<float>()(indx++) = v;
68 }
69 EXPECT_EQ(INVALID_ARGUMENT, ValidateSparseMatrixShardingConfig(t).code());
70 }
71
72 // Only one key is specified.
73 {
74 Tensor t(DataType::DT_FLOAT, {1, 3});
75 int indx = 0;
76 for (const float v : {30.0, 20.0, 1.0}) {
77 t.flat<float>()(indx++) = v;
78 }
79 EXPECT_TRUE(ValidateSparseMatrixShardingConfig(t).ok());
80 }
81
82 // Two keys are specified.
83 {
84 Tensor t(DataType::DT_FLOAT, {2, 3});
85 int indx = 0;
86 for (const float v : {60.0, 50.0, 0.41, 30.0, 20.0, 0.7}) {
87 t.flat<float>()(indx++) = v;
88 }
89 EXPECT_TRUE(ValidateSparseMatrixShardingConfig(t).ok());
90 }
91
92 // Out of range.
93 {
94 Tensor t(DataType::DT_FLOAT, {2, 3});
95 int indx = 0;

Callers

nothing calls this directly

Calls 6

GetLinearBucketFunction · 0.85
GetPowerBucketFunction · 0.85
okMethod · 0.45
codeMethod · 0.45

Tested by

no test coverage detected