提交 3ec48480 编写于 作者: D dangqingqing

Fix bug

上级 39cf2e21
...@@ -55,15 +55,15 @@ class AccuracyOpMaker : public framework::OpProtoAndCheckerMaker { ...@@ -55,15 +55,15 @@ class AccuracyOpMaker : public framework::OpProtoAndCheckerMaker {
// TODO(typhoonzero): AddInput("Weight", ... // TODO(typhoonzero): AddInput("Weight", ...
AddOutput("Accuracy", "The accuracy of current batch"); AddOutput("Accuracy", "The accuracy of current batch");
AddComment( AddComment(R"DOC(
R"DOC(Accuracy. It will print accuracy rate for classification. Accuracy. It will print accuracy rate for classification.
The accuracy is: The accuracy is:
.. math:: .. math::
accuracy = \\frac{NumOfCorrectPredicts}{NumOfAllSamples}) accuracy = \\frac{NumOfCorrectPredicts}{NumOfAllSamples})
Both the input `Inference` and `Label` can carry the LoD (Level of Details) Both the input `Inference` and `Label` can carry the LoD (Level of Details)
information, or not. But the output only shares the LoD with input `Inference`. information, or not. But the output only shares the LoD with input `Inference`.
DOC"); )DOC");
} }
}; };
......
...@@ -38,6 +38,7 @@ class DropoutOp : public framework::OperatorWithKernel { ...@@ -38,6 +38,7 @@ class DropoutOp : public framework::OperatorWithKernel {
if (ctx.Attr<int>("is_training") == 1) { if (ctx.Attr<int>("is_training") == 1) {
ctx.Output<LoDTensor>("Mask")->Resize(dims); ctx.Output<LoDTensor>("Mask")->Resize(dims);
} }
ctx.ShareLoD("X", "Out");
} }
}; };
......
...@@ -189,7 +189,6 @@ Activation type can be set to `identity` (default), `sigmoid` or `softmax`. ...@@ -189,7 +189,6 @@ Activation type can be set to `identity` (default), `sigmoid` or `softmax`.
All the inputs can carry the LoD (Level of Details) information, All the inputs can carry the LoD (Level of Details) information,
or not. But the output only shares the LoD with first input (`X[0]`). or not. But the output only shares the LoD with first input (`X[0]`).
)DOC");
)DOC"); )DOC");
} }
}; };
......
...@@ -41,6 +41,11 @@ class PadOp : public framework::OperatorWithKernel { ...@@ -41,6 +41,11 @@ class PadOp : public framework::OperatorWithKernel {
} }
ctx.Output<framework::LoDTensor>("Out")->Resize( ctx.Output<framework::LoDTensor>("Out")->Resize(
framework::make_ddim(out_dims)); framework::make_ddim(out_dims));
if (out_dims[0] == x_dim[0]) {
// Only pass LoD when the first dimension is equal between
// output and input.
ctx.ShareLoD("X", "Out");
}
} }
}; };
......
...@@ -51,6 +51,11 @@ class ReshapeOp : public framework::OperatorWithKernel { ...@@ -51,6 +51,11 @@ class ReshapeOp : public framework::OperatorWithKernel {
[](int a) { return static_cast<int64_t>(a); }); [](int a) { return static_cast<int64_t>(a); });
auto out_dims = framework::make_ddim(shape_int64); auto out_dims = framework::make_ddim(shape_int64);
ctx.Output<framework::LoDTensor>("Out")->Resize(out_dims); ctx.Output<framework::LoDTensor>("Out")->Resize(out_dims);
if (shape[0] == in->dims()[0]) {
// Only pass LoD when the first dimension is equal between
// output and input.
ctx.ShareLoD("X", "Out");
}
} }
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册