diff --git a/src/transformers/models/layoutlmv2/modeling_layoutlmv2.py b/src/transformers/models/layoutlmv2/modeling_layoutlmv2.py index 1ce330760e7802..269e951ea00de4 100755 --- a/src/transformers/models/layoutlmv2/modeling_layoutlmv2.py +++ b/src/transformers/models/layoutlmv2/modeling_layoutlmv2.py @@ -32,7 +32,7 @@ TokenClassifierOutput, ) from ...modeling_utils import PreTrainedModel -from ...pytorch_utils import apply_chunking_to_forward +from ...pytorch_utils import apply_chunking_to_forward, torch_int_div from ...utils import ( add_start_docstrings, add_start_docstrings_to_model_forward, @@ -770,25 +770,25 @@ def _calc_img_embeddings(self, image, bbox, position_ids): return embeddings def _calc_visual_bbox(self, image_feature_pool_shape, bbox, device, final_shape): - visual_bbox_x = ( + visual_bbox_x = torch_int_div( torch.arange( 0, 1000 * (image_feature_pool_shape[1] + 1), 1000, device=device, dtype=bbox.dtype, - ) - // self.config.image_feature_pool_shape[1] + ), + self.config.image_feature_pool_shape[1], ) - visual_bbox_y = ( + visual_bbox_y = torch_int_div( torch.arange( 0, 1000 * (self.config.image_feature_pool_shape[0] + 1), 1000, device=device, dtype=bbox.dtype, - ) - // self.config.image_feature_pool_shape[0] + ), + self.config.image_feature_pool_shape[0], ) visual_bbox = torch.stack( [