Browse Source

Fix ut.

tags/v1.3.0
zhaozhixuan 3 years ago
parent
commit
ddee5049b0
2 changed files with 0 additions and 44 deletions
  1. +0
    -32
      tests/ut/common/graph/testcase/ge_graph/ge_def_type_unittest.cc
  2. +0
    -12
      tests/ut/common/graph/testcase/ge_graph/ge_tensor_unittest.cc

+ 0
- 32
tests/ut/common/graph/testcase/ge_graph/ge_def_type_unittest.cc View File

@@ -32,14 +32,6 @@ class UtestGeTestDefType : public testing::Test {
void TearDown() {}
};

TEST_F(UtestGeTestDefType, base) {
CompressInfo com1;
com1.set_blockrow(1);
int32_t a = com1.blockrow;
EXPECT_EQ(a, 1);

}

TEST_F(UtestGeTestDefType, quant) {
OpDescPtr desc_ptr1 = std::make_shared<OpDesc>("name1", "type1");
EXPECT_EQ(desc_ptr1->AddInputDesc("x", GeTensorDesc(GeShape({1, 16, 16, 16}), FORMAT_NCHW)), GRAPH_SUCCESS);
@@ -48,28 +40,4 @@ TEST_F(UtestGeTestDefType, quant) {

EXPECT_EQ(OpDescUtils::HasQuantizeFactorParams(desc_ptr1), false);
EXPECT_EQ(OpDescUtils::HasQuantizeFactorParams(*desc_ptr1), false);
QuantizeFactorParams q1;
EXPECT_EQ(q1.has_quantize_param(), false);
QuantizeFactor *qf1 = q1.mutable_quantize_param();
EXPECT_EQ(q1.has_quantize_param(), true);

string s1 = "value1";
q1.quantize_param.set_scale_value(s1.data(), s1.size());
EXPECT_EQ(OpDescUtils::SetQuantizeFactorParams(desc_ptr1, q1), GRAPH_SUCCESS);
QuantizeFactorParams q2;
EXPECT_EQ(OpDescUtils::GetQuantizeFactorParams(desc_ptr1, q2), GRAPH_SUCCESS);
string s2((char *)q2.quantize_param.scale_value.GetData(), q2.quantize_param.scale_value.GetSize());
EXPECT_EQ(s2, "value1");

float f[2] = {1, 2};
string s(static_cast<char *>(static_cast<void *>(f)), 2 * sizeof(float));
q1.quantize_param.set_scale_value(f, 2 * sizeof(float));
EXPECT_EQ(OpDescUtils::SetQuantizeFactorParams(*desc_ptr1, q1), GRAPH_SUCCESS);
QuantizeFactorParams q3;
EXPECT_EQ(OpDescUtils::GetQuantizeFactorParams(*desc_ptr1, q3), GRAPH_SUCCESS);
Buffer &b = q3.quantize_param.scale_value;
float f1[2];
memcpy(f1, b.GetData(), b.GetSize());
EXPECT_EQ(f1[0], 1);
EXPECT_EQ(f1[1], 2);
}

+ 0
- 12
tests/ut/common/graph/testcase/ge_graph/ge_tensor_unittest.cc View File

@@ -209,18 +209,6 @@ TEST_F(UtestGeTensor, test_tensor_desc_invalid_null) {
tensor_desc2.SetDataType(DT_DUAL_SUB_INT8);
EXPECT_EQ(tensor_desc2.GetDataType(), DT_DUAL_SUB_INT8);

CompressInfo info;
EXPECT_EQ(TensorUtils::GetCmpsInfo(tensor_desc2, info), GRAPH_FAILED);
TensorUtils::SetCmpsInfo(tensor_desc2, info);
EXPECT_EQ(TensorUtils::GetCmpsInfo(tensor_desc2, info), GRAPH_SUCCESS);

AllOffsetQuantizeInfo quantize_info;
EXPECT_FALSE(TensorUtils::HasAlloffsetQuantizeInfo(tensor_desc2));
EXPECT_EQ(TensorUtils::GetAlloffsetQuantizeInfo(tensor_desc2, quantize_info), GRAPH_FAILED);
TensorUtils::SetAlloffsetQuantizeInfo(tensor_desc2, quantize_info);
EXPECT_EQ(TensorUtils::GetAlloffsetQuantizeInfo(tensor_desc2, quantize_info), GRAPH_SUCCESS);
EXPECT_TRUE(TensorUtils::HasAlloffsetQuantizeInfo(tensor_desc2));

TensorUtils::SetWeightSize(tensor_desc, 100);
EXPECT_EQ(TensorUtils::GetWeightSize(tensor_desc), 0);
}


Loading…
Cancel
Save