@@ -29,11 +29,23 @@ class DensityPriorBoxOp : public framework::OperatorWithKernel {
29
29
PADDLE_ENFORCE (image_dims.size () == 4 , " The layout of image is NCHW." );
30
30
PADDLE_ENFORCE (input_dims.size () == 4 , " The layout of input is NCHW." );
31
31
32
- PADDLE_ENFORCE_LT (input_dims[2 ], image_dims[2 ],
33
- " The height of input must smaller than image." );
34
-
35
- PADDLE_ENFORCE_LT (input_dims[3 ], image_dims[3 ],
36
- " The width of input must smaller than image." );
32
+ if (ctx->IsRuntime ()) {
33
+ PADDLE_ENFORCE_LT (
34
+ input_dims[2 ], image_dims[2 ],
35
+ platform::errors::InvalidArgument (
36
+ " The input tensor Input's height"
37
+ " of DensityPriorBoxOp should be smaller than input tensor Image's"
38
+ " hight. But received Input's height = %d, Image's height = %d" ,
39
+ input_dims[2 ], image_dims[2 ]));
40
+
41
+ PADDLE_ENFORCE_LT (
42
+ input_dims[3 ], image_dims[3 ],
43
+ platform::errors::InvalidArgument (
44
+ " The input tensor Input's width"
45
+ " of DensityPriorBoxOp should be smaller than input tensor Image's"
46
+ " width. But received Input's width = %d, Image's width = %d" ,
47
+ input_dims[3 ], image_dims[3 ]));
48
+ }
37
49
auto variances = ctx->Attrs ().Get <std::vector<float >>(" variances" );
38
50
39
51
auto fixed_sizes = ctx->Attrs ().Get <std::vector<float >>(" fixed_sizes" );
@@ -55,10 +67,13 @@ class DensityPriorBoxOp : public framework::OperatorWithKernel {
55
67
dim_vec[3 ] = 4 ;
56
68
ctx->SetOutputDim (" Boxes" , framework::make_ddim (dim_vec));
57
69
ctx->SetOutputDim (" Variances" , framework::make_ddim (dim_vec));
58
- } else {
70
+ } else if (ctx-> IsRuntime ()) {
59
71
int64_t dim0 = input_dims[2 ] * input_dims[3 ] * num_priors;
60
72
ctx->SetOutputDim (" Boxes" , {dim0, 4 });
61
73
ctx->SetOutputDim (" Variances" , {dim0, 4 });
74
+ } else {
75
+ ctx->SetOutputDim (" Boxes" , {-1 , 4 });
76
+ ctx->SetOutputDim (" Variances" , {-1 , 4 });
62
77
}
63
78
}
64
79
0 commit comments