"...git@developer.sourcefind.cn:chenpangpang/transformers.git" did not exist on "024acd271b60568bba214901a9e71d67c44353dc"
Unverified Commit fa322474 authored by Manuel's avatar Manuel Committed by GitHub
Browse files

apply torch int div to layoutlmv2 (#15457)

* apply torch int div

* black linting fixup

* update path to torch_int_div

* clarify imports
parent 344b9fb0
......@@ -32,7 +32,7 @@ from ...modeling_outputs import (
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 @@ class LayoutLMv2Model(LayoutLMv2PreTrainedModel):
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(
[
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment