From dc7b6f0226b7534aac694a76ef4b0f19dcf87d5f Mon Sep 17 00:00:00 2001 From: Donggeun Yu Date: Wed, 22 May 2024 11:13:56 +0900 Subject: [PATCH 1/6] Update modeling_deformable_detr.py --- .../models/deformable_detr/modeling_deformable_detr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/transformers/models/deformable_detr/modeling_deformable_detr.py b/src/transformers/models/deformable_detr/modeling_deformable_detr.py index b77ae4f8f8be55..93974c9efaec04 100755 --- a/src/transformers/models/deformable_detr/modeling_deformable_detr.py +++ b/src/transformers/models/deformable_detr/modeling_deformable_detr.py @@ -1582,7 +1582,7 @@ def get_proposal_pos_embed(self, proposals): temperature = 10000 scale = 2 * math.pi - dim_t = torch.arange(num_pos_feats, dtype=torch.int64, device=proposals.device).float() + dim_t = torch.arange(num_pos_feats, dtype=torch.int64, device=proposals.device).to(proposals.dtype) dim_t = temperature ** (2 * torch.div(dim_t, 2, rounding_mode="floor") / num_pos_feats) # batch_size, num_queries, 4 proposals = proposals.sigmoid() * scale From a7fad5453ed98ddd656707050b153384d37d9be9 Mon Sep 17 00:00:00 2001 From: Donggeun Yu Date: Wed, 22 May 2024 20:04:39 +0900 Subject: [PATCH 2/6] Update src/transformers/models/deformable_detr/modeling_deformable_detr.py Co-authored-by: amyeroberts <22614925+amyeroberts@users.noreply.github.com> --- .../models/deformable_detr/modeling_deformable_detr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/transformers/models/deformable_detr/modeling_deformable_detr.py b/src/transformers/models/deformable_detr/modeling_deformable_detr.py index 93974c9efaec04..2845a5b7f7119a 100755 --- a/src/transformers/models/deformable_detr/modeling_deformable_detr.py +++ b/src/transformers/models/deformable_detr/modeling_deformable_detr.py @@ -1582,7 +1582,7 @@ def get_proposal_pos_embed(self, proposals): temperature = 10000 scale = 2 * math.pi - dim_t = torch.arange(num_pos_feats, dtype=torch.int64, device=proposals.device).to(proposals.dtype) + dim_t = torch.arange(num_pos_feats, dtype=proposals.dtype, device=proposals.device) dim_t = temperature ** (2 * torch.div(dim_t, 2, rounding_mode="floor") / num_pos_feats) # batch_size, num_queries, 4 proposals = proposals.sigmoid() * scale From 19689d164cb1eabe44b04a0a2686ad3d07ddefe1 Mon Sep 17 00:00:00 2001 From: Donggeun Yu Date: Wed, 21 Aug 2024 15:51:41 +0900 Subject: [PATCH 3/6] Update ms_deform_attn_cuda.cu --- .../kernels/deformable_detr/cuda/ms_deform_attn_cuda.cu | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/transformers/kernels/deformable_detr/cuda/ms_deform_attn_cuda.cu b/src/transformers/kernels/deformable_detr/cuda/ms_deform_attn_cuda.cu index a9bf01d56ac4c6..0cd34f5df8b7dc 100644 --- a/src/transformers/kernels/deformable_detr/cuda/ms_deform_attn_cuda.cu +++ b/src/transformers/kernels/deformable_detr/cuda/ms_deform_attn_cuda.cu @@ -28,6 +28,8 @@ at::Tensor ms_deform_attn_cuda_forward( const at::Tensor &attn_weight, const int im2col_step) { + at::DeviceGuard guard(value.device()); + AT_ASSERTM(value.is_contiguous(), "value tensor has to be contiguous"); AT_ASSERTM(spatial_shapes.is_contiguous(), "spatial_shapes tensor has to be contiguous"); AT_ASSERTM(level_start_index.is_contiguous(), "level_start_index tensor has to be contiguous"); @@ -92,6 +94,7 @@ std::vector ms_deform_attn_cuda_backward( const at::Tensor &grad_output, const int im2col_step) { + at::DeviceGuard guard(value.device()); AT_ASSERTM(value.is_contiguous(), "value tensor has to be contiguous"); AT_ASSERTM(spatial_shapes.is_contiguous(), "spatial_shapes tensor has to be contiguous"); From beccfc9535ba038e897e86696b96a21dd6308448 Mon Sep 17 00:00:00 2001 From: Donggeun Yu Date: Wed, 21 Aug 2024 16:04:24 +0900 Subject: [PATCH 4/6] Update modeling_deformable_detr.py --- .../models/deformable_detr/modeling_deformable_detr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/transformers/models/deformable_detr/modeling_deformable_detr.py b/src/transformers/models/deformable_detr/modeling_deformable_detr.py index a4c639ba607c17..f2e114ff27342d 100755 --- a/src/transformers/models/deformable_detr/modeling_deformable_detr.py +++ b/src/transformers/models/deformable_detr/modeling_deformable_detr.py @@ -1589,7 +1589,7 @@ def get_proposal_pos_embed(self, proposals): temperature = 10000 scale = 2 * math.pi - dim_t = torch.arange(num_pos_feats, dtype=proposals.dtype, device=proposals.device) + dim_t = torch.arange(num_pos_feats, dtype=torch.int64, device=proposals.device).to(proposals.dtype) dim_t = temperature ** (2 * torch.div(dim_t, 2, rounding_mode="floor") / num_pos_feats) # batch_size, num_queries, 4 proposals = proposals.sigmoid() * scale From 94747d4345d63caadce73e60e1cdb859595c5528 Mon Sep 17 00:00:00 2001 From: Donggeun Yu Date: Wed, 21 Aug 2024 16:05:10 +0900 Subject: [PATCH 5/6] Update modeling_deformable_detr.py --- .../models/deformable_detr/modeling_deformable_detr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/transformers/models/deformable_detr/modeling_deformable_detr.py b/src/transformers/models/deformable_detr/modeling_deformable_detr.py index f2e114ff27342d..46e00787baf618 100755 --- a/src/transformers/models/deformable_detr/modeling_deformable_detr.py +++ b/src/transformers/models/deformable_detr/modeling_deformable_detr.py @@ -1589,7 +1589,7 @@ def get_proposal_pos_embed(self, proposals): temperature = 10000 scale = 2 * math.pi - dim_t = torch.arange(num_pos_feats, dtype=torch.int64, device=proposals.device).to(proposals.dtype) + dim_t = torch.arange(num_pos_feats, dtype=torch.int64, device=proposals.device).float() dim_t = temperature ** (2 * torch.div(dim_t, 2, rounding_mode="floor") / num_pos_feats) # batch_size, num_queries, 4 proposals = proposals.sigmoid() * scale From 2544d7f45a1017df14cd91cdd8c180b54f20ef7b Mon Sep 17 00:00:00 2001 From: donggeunyu Date: Fri, 23 Aug 2024 09:49:39 +0900 Subject: [PATCH 6/6] [empty] this is a empty commit