Build (aarch64)
Browse files- build/torch26-cxx11-cu126-aarch64-linux/deformable_detr/__init__.py +46 -0
- build/torch26-cxx11-cu126-aarch64-linux/deformable_detr/_deformable_detr_4f82c9e.abi3.so +3 -0
- build/torch26-cxx11-cu126-aarch64-linux/deformable_detr/_ops.py +9 -0
- build/torch26-cxx11-cu126-aarch64-linux/deformable_detr/layers.py +84 -0
- build/torch26-cxx98-cu126-aarch64-linux/deformable_detr/__init__.py +46 -0
- build/torch26-cxx98-cu126-aarch64-linux/deformable_detr/_deformable_detr_4f82c9e.abi3.so +3 -0
- build/torch26-cxx98-cu126-aarch64-linux/deformable_detr/_ops.py +9 -0
- build/torch26-cxx98-cu126-aarch64-linux/deformable_detr/layers.py +84 -0
- build/torch27-cxx11-cu126-aarch64-linux/deformable_detr/__init__.py +46 -0
- build/torch27-cxx11-cu126-aarch64-linux/deformable_detr/_deformable_detr_4f82c9e.abi3.so +3 -0
- build/torch27-cxx11-cu126-aarch64-linux/deformable_detr/_ops.py +9 -0
- build/torch27-cxx11-cu126-aarch64-linux/deformable_detr/layers.py +84 -0
- build/torch27-cxx11-cu128-aarch64-linux/deformable_detr/__init__.py +46 -0
- build/torch27-cxx11-cu128-aarch64-linux/deformable_detr/_deformable_detr_4f82c9e.abi3.so +3 -0
- build/torch27-cxx11-cu128-aarch64-linux/deformable_detr/_ops.py +9 -0
- build/torch27-cxx11-cu128-aarch64-linux/deformable_detr/layers.py +84 -0
build/torch26-cxx11-cu126-aarch64-linux/deformable_detr/__init__.py
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from typing import List
|
2 |
+
import torch
|
3 |
+
|
4 |
+
from ._ops import ops
|
5 |
+
from . import layers
|
6 |
+
|
7 |
+
|
8 |
+
def ms_deform_attn_backward(
|
9 |
+
value: torch.Tensor,
|
10 |
+
spatial_shapes: torch.Tensor,
|
11 |
+
level_start_index: torch.Tensor,
|
12 |
+
sampling_loc: torch.Tensor,
|
13 |
+
attn_weight: torch.Tensor,
|
14 |
+
grad_output: torch.Tensor,
|
15 |
+
im2col_step: int,
|
16 |
+
) -> List[torch.Tensor]:
|
17 |
+
return ops.ms_deform_attn_backward(
|
18 |
+
value,
|
19 |
+
spatial_shapes,
|
20 |
+
level_start_index,
|
21 |
+
sampling_loc,
|
22 |
+
attn_weight,
|
23 |
+
grad_output,
|
24 |
+
im2col_step,
|
25 |
+
)
|
26 |
+
|
27 |
+
|
28 |
+
def ms_deform_attn_forward(
|
29 |
+
value: torch.Tensor,
|
30 |
+
spatial_shapes: torch.Tensor,
|
31 |
+
level_start_index: torch.Tensor,
|
32 |
+
sampling_loc: torch.Tensor,
|
33 |
+
attn_weight: torch.Tensor,
|
34 |
+
im2col_step: int,
|
35 |
+
) -> torch.Tensor:
|
36 |
+
return ops.ms_deform_attn_forward(
|
37 |
+
value,
|
38 |
+
spatial_shapes,
|
39 |
+
level_start_index,
|
40 |
+
sampling_loc,
|
41 |
+
attn_weight,
|
42 |
+
im2col_step,
|
43 |
+
)
|
44 |
+
|
45 |
+
|
46 |
+
__all__ = ["layers", "ms_deform_attn_forward", "ms_deform_attn_backward"]
|
build/torch26-cxx11-cu126-aarch64-linux/deformable_detr/_deformable_detr_4f82c9e.abi3.so
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:486d6b3700e5d789c1d8d3225b9c681db33436d19341899e72a81f4675eb9a55
|
3 |
+
size 6112328
|
build/torch26-cxx11-cu126-aarch64-linux/deformable_detr/_ops.py
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch
|
2 |
+
from . import _deformable_detr_4f82c9e
|
3 |
+
ops = torch.ops._deformable_detr_4f82c9e
|
4 |
+
|
5 |
+
def add_op_namespace_prefix(op_name: str):
|
6 |
+
"""
|
7 |
+
Prefix op by namespace.
|
8 |
+
"""
|
9 |
+
return f"_deformable_detr_4f82c9e::{op_name}"
|
build/torch26-cxx11-cu126-aarch64-linux/deformable_detr/layers.py
ADDED
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from typing import List, Union, Tuple
|
2 |
+
|
3 |
+
from torch import Tensor
|
4 |
+
from torch.autograd import Function
|
5 |
+
from torch.autograd.function import once_differentiable
|
6 |
+
import torch.nn as nn
|
7 |
+
|
8 |
+
from ._ops import ops
|
9 |
+
|
10 |
+
|
11 |
+
class MultiScaleDeformableAttentionFunction(Function):
|
12 |
+
@staticmethod
|
13 |
+
def forward(
|
14 |
+
context,
|
15 |
+
value: Tensor,
|
16 |
+
value_spatial_shapes: Tensor,
|
17 |
+
value_level_start_index: Tensor,
|
18 |
+
sampling_locations: Tensor,
|
19 |
+
attention_weights: Tensor,
|
20 |
+
im2col_step: int,
|
21 |
+
):
|
22 |
+
context.im2col_step = im2col_step
|
23 |
+
output = ops.ms_deform_attn_forward(
|
24 |
+
value,
|
25 |
+
value_spatial_shapes,
|
26 |
+
value_level_start_index,
|
27 |
+
sampling_locations,
|
28 |
+
attention_weights,
|
29 |
+
context.im2col_step,
|
30 |
+
)
|
31 |
+
context.save_for_backward(
|
32 |
+
value,
|
33 |
+
value_spatial_shapes,
|
34 |
+
value_level_start_index,
|
35 |
+
sampling_locations,
|
36 |
+
attention_weights,
|
37 |
+
)
|
38 |
+
return output
|
39 |
+
|
40 |
+
@staticmethod
|
41 |
+
@once_differentiable
|
42 |
+
def backward(context, grad_output):
|
43 |
+
(
|
44 |
+
value,
|
45 |
+
value_spatial_shapes,
|
46 |
+
value_level_start_index,
|
47 |
+
sampling_locations,
|
48 |
+
attention_weights,
|
49 |
+
) = context.saved_tensors
|
50 |
+
grad_value, grad_sampling_loc, grad_attn_weight = ops.ms_deform_attn_backward(
|
51 |
+
value,
|
52 |
+
value_spatial_shapes,
|
53 |
+
value_level_start_index,
|
54 |
+
sampling_locations,
|
55 |
+
attention_weights,
|
56 |
+
grad_output,
|
57 |
+
context.im2col_step,
|
58 |
+
)
|
59 |
+
|
60 |
+
return grad_value, None, None, grad_sampling_loc, grad_attn_weight, None
|
61 |
+
|
62 |
+
|
63 |
+
class MultiScaleDeformableAttention(nn.Module):
|
64 |
+
def forward(
|
65 |
+
self,
|
66 |
+
value: Tensor,
|
67 |
+
value_spatial_shapes: Tensor,
|
68 |
+
value_spatial_shapes_list: List[Tuple],
|
69 |
+
level_start_index: Tensor,
|
70 |
+
sampling_locations: Tensor,
|
71 |
+
attention_weights: Tensor,
|
72 |
+
im2col_step: int,
|
73 |
+
):
|
74 |
+
return MultiScaleDeformableAttentionFunction.apply(
|
75 |
+
value,
|
76 |
+
value_spatial_shapes,
|
77 |
+
level_start_index,
|
78 |
+
sampling_locations,
|
79 |
+
attention_weights,
|
80 |
+
im2col_step,
|
81 |
+
)
|
82 |
+
|
83 |
+
|
84 |
+
__all__ = ["MultiScaleDeformableAttention"]
|
build/torch26-cxx98-cu126-aarch64-linux/deformable_detr/__init__.py
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from typing import List
|
2 |
+
import torch
|
3 |
+
|
4 |
+
from ._ops import ops
|
5 |
+
from . import layers
|
6 |
+
|
7 |
+
|
8 |
+
def ms_deform_attn_backward(
|
9 |
+
value: torch.Tensor,
|
10 |
+
spatial_shapes: torch.Tensor,
|
11 |
+
level_start_index: torch.Tensor,
|
12 |
+
sampling_loc: torch.Tensor,
|
13 |
+
attn_weight: torch.Tensor,
|
14 |
+
grad_output: torch.Tensor,
|
15 |
+
im2col_step: int,
|
16 |
+
) -> List[torch.Tensor]:
|
17 |
+
return ops.ms_deform_attn_backward(
|
18 |
+
value,
|
19 |
+
spatial_shapes,
|
20 |
+
level_start_index,
|
21 |
+
sampling_loc,
|
22 |
+
attn_weight,
|
23 |
+
grad_output,
|
24 |
+
im2col_step,
|
25 |
+
)
|
26 |
+
|
27 |
+
|
28 |
+
def ms_deform_attn_forward(
|
29 |
+
value: torch.Tensor,
|
30 |
+
spatial_shapes: torch.Tensor,
|
31 |
+
level_start_index: torch.Tensor,
|
32 |
+
sampling_loc: torch.Tensor,
|
33 |
+
attn_weight: torch.Tensor,
|
34 |
+
im2col_step: int,
|
35 |
+
) -> torch.Tensor:
|
36 |
+
return ops.ms_deform_attn_forward(
|
37 |
+
value,
|
38 |
+
spatial_shapes,
|
39 |
+
level_start_index,
|
40 |
+
sampling_loc,
|
41 |
+
attn_weight,
|
42 |
+
im2col_step,
|
43 |
+
)
|
44 |
+
|
45 |
+
|
46 |
+
__all__ = ["layers", "ms_deform_attn_forward", "ms_deform_attn_backward"]
|
build/torch26-cxx98-cu126-aarch64-linux/deformable_detr/_deformable_detr_4f82c9e.abi3.so
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:34d28a81c3b5ae1fcb58583681644cf66072b67844bc21fe4649c17d01f4fce7
|
3 |
+
size 6108976
|
build/torch26-cxx98-cu126-aarch64-linux/deformable_detr/_ops.py
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch
|
2 |
+
from . import _deformable_detr_4f82c9e
|
3 |
+
ops = torch.ops._deformable_detr_4f82c9e
|
4 |
+
|
5 |
+
def add_op_namespace_prefix(op_name: str):
|
6 |
+
"""
|
7 |
+
Prefix op by namespace.
|
8 |
+
"""
|
9 |
+
return f"_deformable_detr_4f82c9e::{op_name}"
|
build/torch26-cxx98-cu126-aarch64-linux/deformable_detr/layers.py
ADDED
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from typing import List, Union, Tuple
|
2 |
+
|
3 |
+
from torch import Tensor
|
4 |
+
from torch.autograd import Function
|
5 |
+
from torch.autograd.function import once_differentiable
|
6 |
+
import torch.nn as nn
|
7 |
+
|
8 |
+
from ._ops import ops
|
9 |
+
|
10 |
+
|
11 |
+
class MultiScaleDeformableAttentionFunction(Function):
|
12 |
+
@staticmethod
|
13 |
+
def forward(
|
14 |
+
context,
|
15 |
+
value: Tensor,
|
16 |
+
value_spatial_shapes: Tensor,
|
17 |
+
value_level_start_index: Tensor,
|
18 |
+
sampling_locations: Tensor,
|
19 |
+
attention_weights: Tensor,
|
20 |
+
im2col_step: int,
|
21 |
+
):
|
22 |
+
context.im2col_step = im2col_step
|
23 |
+
output = ops.ms_deform_attn_forward(
|
24 |
+
value,
|
25 |
+
value_spatial_shapes,
|
26 |
+
value_level_start_index,
|
27 |
+
sampling_locations,
|
28 |
+
attention_weights,
|
29 |
+
context.im2col_step,
|
30 |
+
)
|
31 |
+
context.save_for_backward(
|
32 |
+
value,
|
33 |
+
value_spatial_shapes,
|
34 |
+
value_level_start_index,
|
35 |
+
sampling_locations,
|
36 |
+
attention_weights,
|
37 |
+
)
|
38 |
+
return output
|
39 |
+
|
40 |
+
@staticmethod
|
41 |
+
@once_differentiable
|
42 |
+
def backward(context, grad_output):
|
43 |
+
(
|
44 |
+
value,
|
45 |
+
value_spatial_shapes,
|
46 |
+
value_level_start_index,
|
47 |
+
sampling_locations,
|
48 |
+
attention_weights,
|
49 |
+
) = context.saved_tensors
|
50 |
+
grad_value, grad_sampling_loc, grad_attn_weight = ops.ms_deform_attn_backward(
|
51 |
+
value,
|
52 |
+
value_spatial_shapes,
|
53 |
+
value_level_start_index,
|
54 |
+
sampling_locations,
|
55 |
+
attention_weights,
|
56 |
+
grad_output,
|
57 |
+
context.im2col_step,
|
58 |
+
)
|
59 |
+
|
60 |
+
return grad_value, None, None, grad_sampling_loc, grad_attn_weight, None
|
61 |
+
|
62 |
+
|
63 |
+
class MultiScaleDeformableAttention(nn.Module):
|
64 |
+
def forward(
|
65 |
+
self,
|
66 |
+
value: Tensor,
|
67 |
+
value_spatial_shapes: Tensor,
|
68 |
+
value_spatial_shapes_list: List[Tuple],
|
69 |
+
level_start_index: Tensor,
|
70 |
+
sampling_locations: Tensor,
|
71 |
+
attention_weights: Tensor,
|
72 |
+
im2col_step: int,
|
73 |
+
):
|
74 |
+
return MultiScaleDeformableAttentionFunction.apply(
|
75 |
+
value,
|
76 |
+
value_spatial_shapes,
|
77 |
+
level_start_index,
|
78 |
+
sampling_locations,
|
79 |
+
attention_weights,
|
80 |
+
im2col_step,
|
81 |
+
)
|
82 |
+
|
83 |
+
|
84 |
+
__all__ = ["MultiScaleDeformableAttention"]
|
build/torch27-cxx11-cu126-aarch64-linux/deformable_detr/__init__.py
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from typing import List
|
2 |
+
import torch
|
3 |
+
|
4 |
+
from ._ops import ops
|
5 |
+
from . import layers
|
6 |
+
|
7 |
+
|
8 |
+
def ms_deform_attn_backward(
|
9 |
+
value: torch.Tensor,
|
10 |
+
spatial_shapes: torch.Tensor,
|
11 |
+
level_start_index: torch.Tensor,
|
12 |
+
sampling_loc: torch.Tensor,
|
13 |
+
attn_weight: torch.Tensor,
|
14 |
+
grad_output: torch.Tensor,
|
15 |
+
im2col_step: int,
|
16 |
+
) -> List[torch.Tensor]:
|
17 |
+
return ops.ms_deform_attn_backward(
|
18 |
+
value,
|
19 |
+
spatial_shapes,
|
20 |
+
level_start_index,
|
21 |
+
sampling_loc,
|
22 |
+
attn_weight,
|
23 |
+
grad_output,
|
24 |
+
im2col_step,
|
25 |
+
)
|
26 |
+
|
27 |
+
|
28 |
+
def ms_deform_attn_forward(
|
29 |
+
value: torch.Tensor,
|
30 |
+
spatial_shapes: torch.Tensor,
|
31 |
+
level_start_index: torch.Tensor,
|
32 |
+
sampling_loc: torch.Tensor,
|
33 |
+
attn_weight: torch.Tensor,
|
34 |
+
im2col_step: int,
|
35 |
+
) -> torch.Tensor:
|
36 |
+
return ops.ms_deform_attn_forward(
|
37 |
+
value,
|
38 |
+
spatial_shapes,
|
39 |
+
level_start_index,
|
40 |
+
sampling_loc,
|
41 |
+
attn_weight,
|
42 |
+
im2col_step,
|
43 |
+
)
|
44 |
+
|
45 |
+
|
46 |
+
__all__ = ["layers", "ms_deform_attn_forward", "ms_deform_attn_backward"]
|
build/torch27-cxx11-cu126-aarch64-linux/deformable_detr/_deformable_detr_4f82c9e.abi3.so
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:197a33ee4fd5ea29cb197a84d93eaa4cd9c852233b2ad5870337263c80c74b89
|
3 |
+
size 6112552
|
build/torch27-cxx11-cu126-aarch64-linux/deformable_detr/_ops.py
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch
|
2 |
+
from . import _deformable_detr_4f82c9e
|
3 |
+
ops = torch.ops._deformable_detr_4f82c9e
|
4 |
+
|
5 |
+
def add_op_namespace_prefix(op_name: str):
|
6 |
+
"""
|
7 |
+
Prefix op by namespace.
|
8 |
+
"""
|
9 |
+
return f"_deformable_detr_4f82c9e::{op_name}"
|
build/torch27-cxx11-cu126-aarch64-linux/deformable_detr/layers.py
ADDED
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from typing import List, Union, Tuple
|
2 |
+
|
3 |
+
from torch import Tensor
|
4 |
+
from torch.autograd import Function
|
5 |
+
from torch.autograd.function import once_differentiable
|
6 |
+
import torch.nn as nn
|
7 |
+
|
8 |
+
from ._ops import ops
|
9 |
+
|
10 |
+
|
11 |
+
class MultiScaleDeformableAttentionFunction(Function):
|
12 |
+
@staticmethod
|
13 |
+
def forward(
|
14 |
+
context,
|
15 |
+
value: Tensor,
|
16 |
+
value_spatial_shapes: Tensor,
|
17 |
+
value_level_start_index: Tensor,
|
18 |
+
sampling_locations: Tensor,
|
19 |
+
attention_weights: Tensor,
|
20 |
+
im2col_step: int,
|
21 |
+
):
|
22 |
+
context.im2col_step = im2col_step
|
23 |
+
output = ops.ms_deform_attn_forward(
|
24 |
+
value,
|
25 |
+
value_spatial_shapes,
|
26 |
+
value_level_start_index,
|
27 |
+
sampling_locations,
|
28 |
+
attention_weights,
|
29 |
+
context.im2col_step,
|
30 |
+
)
|
31 |
+
context.save_for_backward(
|
32 |
+
value,
|
33 |
+
value_spatial_shapes,
|
34 |
+
value_level_start_index,
|
35 |
+
sampling_locations,
|
36 |
+
attention_weights,
|
37 |
+
)
|
38 |
+
return output
|
39 |
+
|
40 |
+
@staticmethod
|
41 |
+
@once_differentiable
|
42 |
+
def backward(context, grad_output):
|
43 |
+
(
|
44 |
+
value,
|
45 |
+
value_spatial_shapes,
|
46 |
+
value_level_start_index,
|
47 |
+
sampling_locations,
|
48 |
+
attention_weights,
|
49 |
+
) = context.saved_tensors
|
50 |
+
grad_value, grad_sampling_loc, grad_attn_weight = ops.ms_deform_attn_backward(
|
51 |
+
value,
|
52 |
+
value_spatial_shapes,
|
53 |
+
value_level_start_index,
|
54 |
+
sampling_locations,
|
55 |
+
attention_weights,
|
56 |
+
grad_output,
|
57 |
+
context.im2col_step,
|
58 |
+
)
|
59 |
+
|
60 |
+
return grad_value, None, None, grad_sampling_loc, grad_attn_weight, None
|
61 |
+
|
62 |
+
|
63 |
+
class MultiScaleDeformableAttention(nn.Module):
|
64 |
+
def forward(
|
65 |
+
self,
|
66 |
+
value: Tensor,
|
67 |
+
value_spatial_shapes: Tensor,
|
68 |
+
value_spatial_shapes_list: List[Tuple],
|
69 |
+
level_start_index: Tensor,
|
70 |
+
sampling_locations: Tensor,
|
71 |
+
attention_weights: Tensor,
|
72 |
+
im2col_step: int,
|
73 |
+
):
|
74 |
+
return MultiScaleDeformableAttentionFunction.apply(
|
75 |
+
value,
|
76 |
+
value_spatial_shapes,
|
77 |
+
level_start_index,
|
78 |
+
sampling_locations,
|
79 |
+
attention_weights,
|
80 |
+
im2col_step,
|
81 |
+
)
|
82 |
+
|
83 |
+
|
84 |
+
__all__ = ["MultiScaleDeformableAttention"]
|
build/torch27-cxx11-cu128-aarch64-linux/deformable_detr/__init__.py
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from typing import List
|
2 |
+
import torch
|
3 |
+
|
4 |
+
from ._ops import ops
|
5 |
+
from . import layers
|
6 |
+
|
7 |
+
|
8 |
+
def ms_deform_attn_backward(
|
9 |
+
value: torch.Tensor,
|
10 |
+
spatial_shapes: torch.Tensor,
|
11 |
+
level_start_index: torch.Tensor,
|
12 |
+
sampling_loc: torch.Tensor,
|
13 |
+
attn_weight: torch.Tensor,
|
14 |
+
grad_output: torch.Tensor,
|
15 |
+
im2col_step: int,
|
16 |
+
) -> List[torch.Tensor]:
|
17 |
+
return ops.ms_deform_attn_backward(
|
18 |
+
value,
|
19 |
+
spatial_shapes,
|
20 |
+
level_start_index,
|
21 |
+
sampling_loc,
|
22 |
+
attn_weight,
|
23 |
+
grad_output,
|
24 |
+
im2col_step,
|
25 |
+
)
|
26 |
+
|
27 |
+
|
28 |
+
def ms_deform_attn_forward(
|
29 |
+
value: torch.Tensor,
|
30 |
+
spatial_shapes: torch.Tensor,
|
31 |
+
level_start_index: torch.Tensor,
|
32 |
+
sampling_loc: torch.Tensor,
|
33 |
+
attn_weight: torch.Tensor,
|
34 |
+
im2col_step: int,
|
35 |
+
) -> torch.Tensor:
|
36 |
+
return ops.ms_deform_attn_forward(
|
37 |
+
value,
|
38 |
+
spatial_shapes,
|
39 |
+
level_start_index,
|
40 |
+
sampling_loc,
|
41 |
+
attn_weight,
|
42 |
+
im2col_step,
|
43 |
+
)
|
44 |
+
|
45 |
+
|
46 |
+
__all__ = ["layers", "ms_deform_attn_forward", "ms_deform_attn_backward"]
|
build/torch27-cxx11-cu128-aarch64-linux/deformable_detr/_deformable_detr_4f82c9e.abi3.so
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:57aa50c458c3b61fdbcf7f64f7c3e70a9c78302fe4c72eff3f35e9a65edbf5d9
|
3 |
+
size 5326200
|
build/torch27-cxx11-cu128-aarch64-linux/deformable_detr/_ops.py
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch
|
2 |
+
from . import _deformable_detr_4f82c9e
|
3 |
+
ops = torch.ops._deformable_detr_4f82c9e
|
4 |
+
|
5 |
+
def add_op_namespace_prefix(op_name: str):
|
6 |
+
"""
|
7 |
+
Prefix op by namespace.
|
8 |
+
"""
|
9 |
+
return f"_deformable_detr_4f82c9e::{op_name}"
|
build/torch27-cxx11-cu128-aarch64-linux/deformable_detr/layers.py
ADDED
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from typing import List, Union, Tuple
|
2 |
+
|
3 |
+
from torch import Tensor
|
4 |
+
from torch.autograd import Function
|
5 |
+
from torch.autograd.function import once_differentiable
|
6 |
+
import torch.nn as nn
|
7 |
+
|
8 |
+
from ._ops import ops
|
9 |
+
|
10 |
+
|
11 |
+
class MultiScaleDeformableAttentionFunction(Function):
|
12 |
+
@staticmethod
|
13 |
+
def forward(
|
14 |
+
context,
|
15 |
+
value: Tensor,
|
16 |
+
value_spatial_shapes: Tensor,
|
17 |
+
value_level_start_index: Tensor,
|
18 |
+
sampling_locations: Tensor,
|
19 |
+
attention_weights: Tensor,
|
20 |
+
im2col_step: int,
|
21 |
+
):
|
22 |
+
context.im2col_step = im2col_step
|
23 |
+
output = ops.ms_deform_attn_forward(
|
24 |
+
value,
|
25 |
+
value_spatial_shapes,
|
26 |
+
value_level_start_index,
|
27 |
+
sampling_locations,
|
28 |
+
attention_weights,
|
29 |
+
context.im2col_step,
|
30 |
+
)
|
31 |
+
context.save_for_backward(
|
32 |
+
value,
|
33 |
+
value_spatial_shapes,
|
34 |
+
value_level_start_index,
|
35 |
+
sampling_locations,
|
36 |
+
attention_weights,
|
37 |
+
)
|
38 |
+
return output
|
39 |
+
|
40 |
+
@staticmethod
|
41 |
+
@once_differentiable
|
42 |
+
def backward(context, grad_output):
|
43 |
+
(
|
44 |
+
value,
|
45 |
+
value_spatial_shapes,
|
46 |
+
value_level_start_index,
|
47 |
+
sampling_locations,
|
48 |
+
attention_weights,
|
49 |
+
) = context.saved_tensors
|
50 |
+
grad_value, grad_sampling_loc, grad_attn_weight = ops.ms_deform_attn_backward(
|
51 |
+
value,
|
52 |
+
value_spatial_shapes,
|
53 |
+
value_level_start_index,
|
54 |
+
sampling_locations,
|
55 |
+
attention_weights,
|
56 |
+
grad_output,
|
57 |
+
context.im2col_step,
|
58 |
+
)
|
59 |
+
|
60 |
+
return grad_value, None, None, grad_sampling_loc, grad_attn_weight, None
|
61 |
+
|
62 |
+
|
63 |
+
class MultiScaleDeformableAttention(nn.Module):
|
64 |
+
def forward(
|
65 |
+
self,
|
66 |
+
value: Tensor,
|
67 |
+
value_spatial_shapes: Tensor,
|
68 |
+
value_spatial_shapes_list: List[Tuple],
|
69 |
+
level_start_index: Tensor,
|
70 |
+
sampling_locations: Tensor,
|
71 |
+
attention_weights: Tensor,
|
72 |
+
im2col_step: int,
|
73 |
+
):
|
74 |
+
return MultiScaleDeformableAttentionFunction.apply(
|
75 |
+
value,
|
76 |
+
value_spatial_shapes,
|
77 |
+
level_start_index,
|
78 |
+
sampling_locations,
|
79 |
+
attention_weights,
|
80 |
+
im2col_step,
|
81 |
+
)
|
82 |
+
|
83 |
+
|
84 |
+
__all__ = ["MultiScaleDeformableAttention"]
|