Skip to content

Commit 54ffafa

Browse files
authored
use context to get attribute (#4997)
1 parent e7f6270 commit 54ffafa

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

paddle/operators/clip_op.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ class ClipOp : public framework::OperatorWithKernel {
2727
PADDLE_ENFORCE(ctx->HasOutput("Out"),
2828
"Output(Out) of ClipOp should not be null.");
2929
auto x_dims = ctx->GetInputDim("X");
30-
auto max = Attr<float>("max");
31-
auto min = Attr<float>("min");
30+
auto max = ctx->Attrs().Get<float>("max");
31+
auto min = ctx->Attrs().Get<float>("min");
3232
PADDLE_ENFORCE_LT(min, max, "max should be greater than min.");
3333
ctx->SetOutputDim("Out", x_dims);
3434
ctx->ShareLoD("X", /*->*/ "Out");

paddle/operators/gaussian_random_op.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class GaussianRandomOp : public framework::OperatorWithKernel {
5959
protected:
6060
framework::DataType IndicateDataType(
6161
const framework::ExecutionContext& ctx) const override {
62-
return static_cast<framework::DataType>(Attr<int>("data_type"));
62+
return static_cast<framework::DataType>(ctx.Attr<int>("data_type"));
6363
}
6464
};
6565

paddle/operators/uniform_random_op.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class UniformRandomOp : public framework::OperatorWithKernel {
6565
protected:
6666
framework::DataType IndicateDataType(
6767
const framework::ExecutionContext& ctx) const override {
68-
return static_cast<framework::DataType>(Attr<int>("data_type"));
68+
return static_cast<framework::DataType>(ctx.Attr<int>("data_type"));
6969
}
7070
};
7171

0 commit comments

Comments
 (0)