@@ -56,8 +56,8 @@ void MatchMatrixTensorOP::InferShape(framework::InferShapeContext* ctx) const {
56
56
PADDLE_ENFORCE_EQ (w_dims[2 ], y_dims[1 ],
57
57
" W 's shape must satisfy: W[2] = Y[1]" );
58
58
59
- int out_dim_0 = -1 ;
60
- int tmp_dim_0 = -1 ;
59
+ int64_t out_dim_0 = -1 ;
60
+ int64_t tmp_dim_0 = -1 ;
61
61
if (ctx->IsRuntime ()) {
62
62
framework::Variable* x_var =
63
63
boost::get<framework::Variable*>(ctx->GetInputVarPtrs (" X" )[0 ]);
@@ -86,8 +86,8 @@ void MatchMatrixTensorOP::InferShape(framework::InferShapeContext* ctx) const {
86
86
87
87
out_dim_0 = 0 ;
88
88
for (size_t i = 1 ; i < x_lod_0.size (); i++) {
89
- int x_len = x_lod_0[i] - x_lod_0[i - 1 ];
90
- int y_len = y_lod_0[i] - y_lod_0[i - 1 ];
89
+ int64_t x_len = x_lod_0[i] - x_lod_0[i - 1 ];
90
+ int64_t y_len = y_lod_0[i] - y_lod_0[i - 1 ];
91
91
out_dim_0 += (x_len * y_len);
92
92
}
93
93
out_dim_0 *= dim_t ;
@@ -173,17 +173,17 @@ class CPUMatchMatrixTensorOPKernel : public framework::OpKernel<T> {
173
173
auto * tmp = ctx.Output <LoDTensor>(" Tmp" );
174
174
175
175
int dim_t = ctx.Attr <int >(" dim_t" );
176
- int dim_in = x->dims ()[1 ];
176
+ int64_t dim_in = x->dims ()[1 ];
177
177
178
178
const auto & offset_l = x->lod ()[0 ];
179
179
const auto & offset_r = y->lod ()[0 ];
180
180
181
181
std::vector<size_t > top_offset;
182
- int top_size = 0 ;
182
+ size_t top_size = 0 ;
183
183
top_offset.push_back (top_size);
184
184
for (size_t b = 0 ; b < x->lod ()[0 ].size () - 1 ; b++) {
185
- int len_l = offset_l[b + 1 ] - offset_l[b];
186
- int len_r = offset_r[b + 1 ] - offset_r[b];
185
+ size_t len_l = offset_l[b + 1 ] - offset_l[b];
186
+ size_t len_r = offset_r[b + 1 ] - offset_r[b];
187
187
top_size += dim_t * len_l * len_r;
188
188
top_offset.push_back (top_size);
189
189
}
@@ -204,8 +204,8 @@ class CPUMatchMatrixTensorOPKernel : public framework::OpKernel<T> {
204
204
205
205
for (size_t b = 0 ; b < x->lod ()[0 ].size () - 1 ; b++) {
206
206
for (int t = 0 ; t < dim_t ; t++) {
207
- int len_l = offset_l[b + 1 ] - offset_l[b];
208
- int len_r = offset_r[b + 1 ] - offset_r[b];
207
+ size_t len_l = offset_l[b + 1 ] - offset_l[b];
208
+ size_t len_r = offset_r[b + 1 ] - offset_r[b];
209
209
auto * top_data = out_data + top_offset[b] + t * len_l * len_r;
210
210
const auto * l_t_data =
211
211
bottom_l_trans_data + offset_l[b] * dim_t * dim_in + t * dim_in;
@@ -234,16 +234,16 @@ class CPUMatchMatrixTensorOPGradKernel : public framework::OpKernel<T> {
234
234
auto * tmp = ctx.Input <LoDTensor>(" Tmp" );
235
235
236
236
int dim_t = ctx.Attr <int >(" dim_t" );
237
- int dim_in = x->dims ()[1 ];
237
+ int64_t dim_in = x->dims ()[1 ];
238
238
239
239
const auto & offset_l = x->lod ()[0 ];
240
240
const auto & offset_r = y->lod ()[0 ];
241
- std::vector<int > top_offset;
242
- int top_size = 0 ;
241
+ std::vector<size_t > top_offset;
242
+ size_t top_size = 0 ;
243
243
top_offset.push_back (top_size);
244
244
for (size_t b = 0 ; b < x->lod ()[0 ].size () - 1 ; b++) {
245
- int len_l = offset_l[b + 1 ] - offset_l[b];
246
- int len_r = offset_r[b + 1 ] - offset_r[b];
245
+ size_t len_l = offset_l[b + 1 ] - offset_l[b];
246
+ size_t len_r = offset_r[b + 1 ] - offset_r[b];
247
247
top_size += dim_t * len_l * len_r;
248
248
top_offset.push_back (top_size);
249
249
}
@@ -270,11 +270,11 @@ class CPUMatchMatrixTensorOPGradKernel : public framework::OpKernel<T> {
270
270
271
271
for (size_t b = 0 ; b < x->lod ()[0 ].size () - 1 ; b++) {
272
272
for (int t = 0 ; t < dim_t ; t++) {
273
- int len_l = offset_l[b + 1 ] - offset_l[b];
274
- int len_r = offset_r[b + 1 ] - offset_r[b];
273
+ size_t len_l = offset_l[b + 1 ] - offset_l[b];
274
+ size_t len_r = offset_r[b + 1 ] - offset_r[b];
275
275
276
- for (int i = 0 ; i < len_l; i++) {
277
- for (int j = 0 ; j < len_r; j++) {
276
+ for (size_t i = 0 ; i < len_l; i++) {
277
+ for (size_t j = 0 ; j < len_r; j++) {
278
278
auto diff =
279
279
top_diff[top_offset[b] + t * len_l * len_r + i * len_r + j];
280
280
auto * l_trans_data = bottom_l_trans_data +
@@ -324,11 +324,7 @@ REGISTER_OPERATOR(match_matrix_tensor_grad, ops::MatchMatrixTensorOpGrad);
324
324
REGISTER_OP_CPU_KERNEL (match_matrix_tensor,
325
325
ops::CPUMatchMatrixTensorOPKernel<
326
326
paddle::platform::CPUDeviceContext, float >);
327
- // ops::CPUMatchMatrixTensorOPKernel<paddle::platform::CPUDeviceContext,
328
- // double>
329
327
330
328
REGISTER_OP_CPU_KERNEL (match_matrix_tensor_grad,
331
329
ops::CPUMatchMatrixTensorOPGradKernel<
332
330
paddle::platform::CPUDeviceContext, float >);
333
- // ops::CPUMatchMatrixTensorOPGradKernel<paddle::platform::CPUDeviceContext,
334
- // double>
0 commit comments