File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -70,7 +70,14 @@ TEST(SaveFP16Op, CPU) {
70
70
auto var = scope.Var (" test_var" );
71
71
auto tensor = var->GetMutable <paddle::framework::LoDTensor>();
72
72
tensor->Resize ({3 , 10 });
73
+ paddle::framework::LoD expect_lod;
74
+ expect_lod.resize (1 );
75
+ expect_lod[0 ].push_back (0 );
76
+ expect_lod[0 ].push_back (1 );
77
+ expect_lod[0 ].push_back (2 );
78
+ expect_lod[0 ].push_back (3 );
73
79
80
+ tensor->set_lod (expect_lod);
74
81
float * expect = tensor->mutable_data <float >(place);
75
82
for (int64_t i = 0 ; i < tensor->numel (); ++i) {
76
83
expect[i] = static_cast <float >(paddle::platform::float16 (i));
@@ -93,6 +100,13 @@ TEST(SaveFP16Op, CPU) {
93
100
for (int64_t i = 0 ; i < tensor->numel (); ++i) {
94
101
EXPECT_EQ (expect[i], static_cast <float >(actual[i]));
95
102
}
103
+ auto & actual_lod = target->lod ();
104
+ EXPECT_EQ (expect_lod.size (), actual_lod.size ());
105
+ for (size_t i = 0 ; i < expect_lod.size (); ++i) {
106
+ for (size_t j = 0 ; j < expect_lod[i].size (); ++j) {
107
+ EXPECT_EQ (expect_lod[i][j], actual_lod[i][j]);
108
+ }
109
+ }
96
110
}
97
111
98
112
TEST (LoadFP16Op, CPU) {
You can’t perform that action at this time.
0 commit comments