@@ -24,34 +24,42 @@ class ProximalAdagradOp : public framework::OperatorWithKernel {
24
24
25
25
protected:
26
26
void InferShape (framework::InferShapeContext *ctx) const override {
27
- PADDLE_ENFORCE (ctx->HasInput (" Param" ),
28
- " Input(Param) of ProximalAdagradOp should not be null." );
29
- PADDLE_ENFORCE (ctx->HasInput (" Moment" ),
30
- " Input(Moment) of ProximalAdagradOp should not be null." );
31
- PADDLE_ENFORCE (ctx->HasInput (" Grad" ),
32
- " Input(Grad) of ProximalAdagradOp should not be null." );
33
- PADDLE_ENFORCE (
34
- ctx->HasInput (" LearningRate" ),
35
- " Input(LearningRate) of ProximalAdagradOp should not be null." );
36
-
37
- PADDLE_ENFORCE (ctx->HasOutput (" ParamOut" ),
38
- " Output(ParamOut) of ProximalAdagradOp should not be null." );
39
- PADDLE_ENFORCE (
40
- ctx->HasOutput (" MomentOut" ),
41
- " Output(MomentOut) of ProximalAdagradOp should not be null." );
27
+ OP_INOUT_CHECK (ctx->HasInput (" Param" ), " Input" , " Param" ,
28
+ " ProximalAdagradOp" );
29
+ OP_INOUT_CHECK (ctx->HasInput (" Moment" ), " Input" , " Moment" ,
30
+ " ProximalAdagradOp" );
31
+ OP_INOUT_CHECK (ctx->HasInput (" Grad" ), " Input" , " Grad" , " ProximalAdagradOp" );
32
+ OP_INOUT_CHECK (ctx->HasInput (" LearningRate" ), " Input" , " LearningRate" ,
33
+ " ProximalAdagradOp" );
34
+
35
+ OP_INOUT_CHECK (ctx->HasOutput (" ParamOut" ), " Output" , " ParamOut" ,
36
+ " ProximalAdagradOp" );
37
+ OP_INOUT_CHECK (ctx->HasOutput (" MomentOut" ), " Output" , " MomentOut" ,
38
+ " ProximalAdagradOp" );
42
39
43
40
auto param_dim = ctx->GetInputDim (" Param" );
44
- PADDLE_ENFORCE_EQ (
45
- param_dim, ctx->GetInputDim (" Grad" ),
46
- " Param and Grad of ProximalAdagrad Op must have same dimension." );
47
-
48
- PADDLE_ENFORCE_EQ (
49
- param_dim, ctx->GetInputDim (" Moment" ),
50
- " Param and Moment of ProximalAdagrad Op must have same dimension." );
41
+ PADDLE_ENFORCE_EQ (param_dim, ctx->GetInputDim (" Grad" ),
42
+ platform::errors::InvalidArgument (
43
+ " The shape of Intput(Param) should be equal to the "
44
+ " Input(Grad) of ProximalAdagrad Op. But received "
45
+ " Input(Param).dimensions=[%s], "
46
+ " Input(Grad).dimensions=[%s]" ,
47
+ param_dim, ctx->GetInputDim (" Grad" )));
48
+
49
+ PADDLE_ENFORCE_EQ (param_dim, ctx->GetInputDim (" Moment" ),
50
+ platform::errors::InvalidArgument (
51
+ " The shape of Intput(Param) should be equal to the "
52
+ " Input(Moment) of ProximalAdagrad Op. But received "
53
+ " Input(Param).dimensions=[%s], "
54
+ " Input(Moment).dimensions=[%s]" ,
55
+ param_dim, ctx->GetInputDim (" Moment" )));
51
56
52
57
auto lr_dim = ctx->GetInputDim (" LearningRate" );
53
- PADDLE_ENFORCE_EQ (framework::product (lr_dim), 1 ,
54
- " Learning Rate should be a scalar." );
58
+ PADDLE_ENFORCE_EQ (
59
+ framework::product (lr_dim), 1 ,
60
+ platform::errors::InvalidArgument (
61
+ " Learning Rate should be a scalar. But received dimension[%s]" ,
62
+ lr_dim));
55
63
56
64
ctx->SetOutputDim (" ParamOut" , param_dim);
57
65
ctx->SetOutputDim (" MomentOut" , param_dim);
0 commit comments