提交 9a8b6c69 编写于 作者: J junjun315

fix bug in save, select-row save bug. test=release/1.4

上级 82410cc2
...@@ -31,8 +31,8 @@ class SaveOp : public framework::OperatorWithKernel { ...@@ -31,8 +31,8 @@ class SaveOp : public framework::OperatorWithKernel {
protected: protected:
framework::OpKernelType GetExpectedKernelType( framework::OpKernelType GetExpectedKernelType(
const framework::ExecutionContext &ctx) const override { const framework::ExecutionContext &ctx) const override {
return framework::OpKernelType(ctx.Input<framework::LoDTensor>("X")->type(), auto data_type = framework::GetDataTypeOfVar(ctx.InputVar("X"));
ctx.GetPlace()); return framework::OpKernelType(data_type, ctx.device_context());
} }
}; };
......
...@@ -103,12 +103,21 @@ class SaveOpKernel : public framework::OpKernel<T> { ...@@ -103,12 +103,21 @@ class SaveOpKernel : public framework::OpKernel<T> {
const platform::Place &place, const platform::Place &place,
const framework::Variable *var) const { const framework::Variable *var) const {
framework::Variable *out_put_var = ctx.OutputVar(LOOKUP_TABLE_PATH); framework::Variable *out_put_var = ctx.OutputVar(LOOKUP_TABLE_PATH);
PADDLE_ENFORCE( auto file_path = ctx.Attr<std::string>("file_path");
out_put_var != nullptr, auto overwrite = ctx.Attr<bool>("overwrite");
"Can not find variable kLookupTablePath for SaveSelectedRows");
auto *lt_var = out_put_var->GetMutable<std::string>(); std::string filename = file_path;
if (out_put_var != nullptr) {
auto *lt_var = out_put_var->GetMutable<std::string>();
filename = *lt_var;
}
if (FileExists(filename) && !overwrite) {
PADDLE_THROW("%s is existed, cannot save to it when overwrite=false",
filename, overwrite);
}
std::string filename = lt_var->data();
VLOG(4) << "SaveSelectedRows get File name: " << filename; VLOG(4) << "SaveSelectedRows get File name: " << filename;
MkDirRecursively(DirName(filename).c_str()); MkDirRecursively(DirName(filename).c_str());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册