提交 cbf502e5 编写于 作者: K Kexin Zhao

fix error

上级 270a87fb
...@@ -125,21 +125,21 @@ TEST(LoadFP16Op, CPU) { ...@@ -125,21 +125,21 @@ TEST(LoadFP16Op, CPU) {
save_op->Run(scope, place); save_op->Run(scope, place);
auto load_var = scope.Var("out_var"); auto load_var = scope.Var("out_var");
auto target = load_var->GetMutable<paddle::framework::LoDTensor>();
auto load_op = paddle::framework::OpRegistry::CreateOp( auto load_op = paddle::framework::OpRegistry::CreateOp(
"load", {}, {{"Out", {"out_var"}}}, attrs); "load", {}, {{"Out", {"out_var"}}}, attrs);
LOG(INFO) << "before load op run"; LOG(INFO) << "before load op run";
load_op->Run(scope, place); load_op->Run(scope, place);
LOG(INFO) << "after load op run"; LOG(INFO) << "after load op run";
paddle::platform::float16* actual = target->data<paddle::platform::float16>(); auto target = load_var->Get<paddle::framework::LoDTensor>();
paddle::platform::float16* actual = target.data<paddle::platform::float16>();
LOG(INFO) << "after target->data"; LOG(INFO) << "after target->data";
for (int64_t i = 0; i < tensor->numel(); ++i) { for (int64_t i = 0; i < tensor->numel(); ++i) {
EXPECT_EQ(expect[i], static_cast<float>(actual[i])); EXPECT_EQ(expect[i], static_cast<float>(actual[i]));
} }
LOG(INFO) << "after expect equal"; LOG(INFO) << "after expect equal";
auto& actual_lod = target->lod(); auto& actual_lod = target.lod();
EXPECT_EQ(expect_lod.size(), actual_lod.size()); EXPECT_EQ(expect_lod.size(), actual_lod.size());
for (size_t i = 0; i < expect_lod.size(); ++i) { for (size_t i = 0; i < expect_lod.size(); ++i) {
for (size_t j = 0; j < expect_lod[i].size(); ++j) { for (size_t j = 0; j < expect_lod[i].size(); ++j) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册