diff --git a/.gitattributes b/.gitattributes index 9f4d0879fb82dc82189c99450584f1537b6d8a7b..c3ad15cdd70cd708e0e9f2892a249b53bffc7169 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1 @@ *.so filter=lfs diff=lfs merge=lfs -text -build/torch210-cu128-x86_64-windows/_deformable_detr_cuda_d8a6191.pyd filter=lfs diff=lfs merge=lfs -text -build/torch211-cu128-x86_64-windows/_deformable_detr_cuda_ff2cd18.pyd filter=lfs diff=lfs merge=lfs -text -build/torch211-cu128-x86_64-windows/_deformable_detr_cuda_a4c5c25.pyd filter=lfs diff=lfs merge=lfs -text diff --git a/README.md b/README.md index f7abb7d42376ab69df7fc8bf7f5b7b2692eef223..bf9f2ddd7ef78ebf080e4e4cefae031874c39667 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,6 @@ --- -library_name: kernels license: apache-2.0 +tags: + - kernel --- -This is the repository card of kernels-community/deformable-detr that has been pushed on the Hub. It was built to be used with the [`kernels` library](https://github.com/huggingface/kernels). This card was automatically generated. - -## How to use - -```python -# make sure `kernels` is installed: `pip install -U kernels` -from kernels import get_kernel - -kernel_module = get_kernel("kernels-community/deformable-detr") -ms_deform_attn_forward = kernel_module.ms_deform_attn_forward - -ms_deform_attn_forward(...) -``` - -## Available functions -- `ms_deform_attn_forward` -- `ms_deform_attn_backward` - -## Benchmarks - -Benchmarking script is available for this kernel. Run `kernels benchmark kernels-community/deformable-detr`. diff --git a/benchmarks/benchmark.py b/benchmarks/benchmark.py deleted file mode 100644 index d1fdbecaf7a5dbdaa4cf316e3a72778fc9da5589..0000000000000000000000000000000000000000 --- a/benchmarks/benchmark.py +++ /dev/null @@ -1,250 +0,0 @@ -import torch -import torch.nn.functional as F - -from kernels.benchmark import Benchmark - - -def ms_deform_attn_reference( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_locations: torch.Tensor, - attention_weights: torch.Tensor, -) -> torch.Tensor: - batch, _, num_heads, channels = value.shape - _, num_query, _, num_levels, num_points, _ = sampling_locations.shape - - # Split value by levels - value_list = [] - for level_id in range(num_levels): - H, W = spatial_shapes[level_id] - start_idx = level_start_index[level_id] - end_idx = ( - level_start_index[level_id + 1] - if level_id < num_levels - 1 - else value.shape[1] - ) - # (batch, H*W, num_heads, channels) -> (batch, num_heads, channels, H, W) - value_level = value[:, start_idx:end_idx, :, :].view( - batch, H, W, num_heads, channels - ) - value_level = value_level.permute(0, 3, 4, 1, 2).contiguous() - value_list.append(value_level) - - # Sample from each level - output = torch.zeros( - batch, num_query, num_heads, channels, device=value.device, dtype=value.dtype - ) - - for level_id in range(num_levels): - H, W = spatial_shapes[level_id] - value_level = value_list[level_id] # (batch, num_heads, channels, H, W) - - # Get sampling locations for this level: (batch, num_query, num_heads, num_points, 2) - sampling_loc_level = sampling_locations[:, :, :, level_id, :, :] - - # Convert from [0, 1] to [-1, 1] for grid_sample - grid = ( - 2.0 * sampling_loc_level - 1.0 - ) # (batch, num_query, num_heads, num_points, 2) - - # Reshape for grid_sample: need (batch * num_heads, channels, H, W) and (batch * num_heads, num_query, num_points, 2) - value_level = value_level.view(batch * num_heads, channels, H.item(), W.item()) - grid = grid.permute( - 0, 2, 1, 3, 4 - ).contiguous() # (batch, num_heads, num_query, num_points, 2) - grid = grid.view(batch * num_heads, num_query, num_points, 2) - - # Sample: output is (batch * num_heads, channels, num_query, num_points) - sampled = F.grid_sample( - value_level, - grid, - mode="bilinear", - padding_mode="zeros", - align_corners=False, - ) - - # Reshape back: (batch, num_heads, channels, num_query, num_points) - sampled = sampled.view(batch, num_heads, channels, num_query, num_points) - # -> (batch, num_query, num_heads, num_points, channels) - sampled = sampled.permute(0, 3, 1, 4, 2).contiguous() - - # Get attention weights for this level: (batch, num_query, num_heads, num_points) - attn_level = attention_weights[:, :, :, level_id, :] - - # Weighted sum over points: (batch, num_query, num_heads, channels) - output += (sampled * attn_level.unsqueeze(-1)).sum(dim=3) - - # Reshape to (batch, num_query, num_heads * channels) - output = output.view(batch, num_query, num_heads * channels) - return output - - -class MSDeformAttnBenchmark(Benchmark): - seed: int = 42 - - def setup(self): - batch = 2 - num_heads = 8 - channels = 32 # embed_dim = num_heads * channels = 256 - num_levels = 4 - num_query = 300 - num_points = 4 - im2col_step = 64 - - # Spatial shapes for 4 levels: 64x64, 32x32, 16x16, 8x8 - spatial_shapes = torch.tensor( - [[64, 64], [32, 32], [16, 16], [8, 8]], - dtype=torch.int64, - device=self.device, - ) - # Calculate spatial_size = sum of H*W for all levels - spatial_size = (64 * 64) + (32 * 32) + (16 * 16) + (8 * 8) # 5440 - - # Level start indices - level_start_index = torch.tensor( - [0, 64 * 64, 64 * 64 + 32 * 32, 64 * 64 + 32 * 32 + 16 * 16], - dtype=torch.int64, - device=self.device, - ) - - self.value = torch.randn( - batch, - spatial_size, - num_heads, - channels, - device=self.device, - dtype=torch.float32, - ) - self.spatial_shapes = spatial_shapes - self.level_start_index = level_start_index - self.sampling_loc = torch.rand( - batch, - num_query, - num_heads, - num_levels, - num_points, - 2, - device=self.device, - dtype=torch.float32, - ) - self.attn_weight = torch.rand( - batch, - num_query, - num_heads, - num_levels, - num_points, - device=self.device, - dtype=torch.float32, - ) - # Normalize attention weights - self.attn_weight = self.attn_weight / self.attn_weight.sum(-1, keepdim=True) - self.im2col_step = im2col_step - - self.out = torch.empty( - batch, - num_query, - num_heads * channels, - device=self.device, - dtype=torch.float32, - ) - - def benchmark_forward(self): - self.out = self.kernel.ms_deform_attn_forward( - self.value, - self.spatial_shapes, - self.level_start_index, - self.sampling_loc, - self.attn_weight, - self.im2col_step, - ) - - def verify_forward(self) -> torch.Tensor: - return ms_deform_attn_reference( - self.value, - self.spatial_shapes, - self.level_start_index, - self.sampling_loc, - self.attn_weight, - ) - - def setup_large(self): - batch = 8 - num_heads = 8 - channels = 32 - num_levels = 4 - num_query = 900 - num_points = 4 - im2col_step = 64 - - spatial_shapes = torch.tensor( - [[64, 64], [32, 32], [16, 16], [8, 8]], - dtype=torch.int64, - device=self.device, - ) - spatial_size = (64 * 64) + (32 * 32) + (16 * 16) + (8 * 8) - - level_start_index = torch.tensor( - [0, 64 * 64, 64 * 64 + 32 * 32, 64 * 64 + 32 * 32 + 16 * 16], - dtype=torch.int64, - device=self.device, - ) - - self.value = torch.randn( - batch, - spatial_size, - num_heads, - channels, - device=self.device, - dtype=torch.float32, - ) - self.spatial_shapes = spatial_shapes - self.level_start_index = level_start_index - self.sampling_loc = torch.rand( - batch, - num_query, - num_heads, - num_levels, - num_points, - 2, - device=self.device, - dtype=torch.float32, - ) - self.attn_weight = torch.rand( - batch, - num_query, - num_heads, - num_levels, - num_points, - device=self.device, - dtype=torch.float32, - ) - self.attn_weight = self.attn_weight / self.attn_weight.sum(-1, keepdim=True) - self.im2col_step = im2col_step - - self.out = torch.empty( - batch, - num_query, - num_heads * channels, - device=self.device, - dtype=torch.float32, - ) - - def benchmark_large(self): - self.out = self.kernel.ms_deform_attn_forward( - self.value, - self.spatial_shapes, - self.level_start_index, - self.sampling_loc, - self.attn_weight, - self.im2col_step, - ) - - def verify_large(self) -> torch.Tensor: - return ms_deform_attn_reference( - self.value, - self.spatial_shapes, - self.level_start_index, - self.sampling_loc, - self.attn_weight, - ) diff --git a/build.toml b/build.toml new file mode 100644 index 0000000000000000000000000000000000000000..09496f4d32b405396fab6b6aba45e3a1e51402b5 --- /dev/null +++ b/build.toml @@ -0,0 +1,19 @@ +[general] +name = "deformable_detr" + +[torch] +src = [ + "torch-ext/torch_binding.cpp", + "torch-ext/torch_binding.h" +] + +[kernel.activation] +cuda-capabilities = [ "7.0", "7.2", "7.5", "8.0", "8.6", "8.7", "8.9", "9.0" ] +src = [ + "deformable_detr/ms_deform_attn_cuda.cu", + "deformable_detr/ms_deform_im2col_cuda.cuh", + "deformable_detr/ms_deform_attn_cuda.cuh", + "deformable_detr/ms_deform_attn_cuda.h", +] +include = ["."] +depends = [ "torch" ] diff --git a/build/torch210-cu128-x86_64-windows/__init__.py b/build/torch210-cu128-x86_64-windows/__init__.py deleted file mode 100644 index 7082e931a91c42eef91df9cfac9d908b919a0443..0000000000000000000000000000000000000000 --- a/build/torch210-cu128-x86_64-windows/__init__.py +++ /dev/null @@ -1,46 +0,0 @@ -from typing import List -import torch - -from ._ops import ops -from . import layers - - -def ms_deform_attn_backward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - grad_output: torch.Tensor, - im2col_step: int, -) -> List[torch.Tensor]: - return ops.ms_deform_attn_backward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - grad_output, - im2col_step, - ) - - -def ms_deform_attn_forward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - im2col_step: int, -) -> torch.Tensor: - return ops.ms_deform_attn_forward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - im2col_step, - ) - - -__all__ = ["layers", "ms_deform_attn_forward", "ms_deform_attn_backward"] diff --git a/build/torch210-cu128-x86_64-windows/_deformable_detr_cuda_d8a6191.pyd b/build/torch210-cu128-x86_64-windows/_deformable_detr_cuda_d8a6191.pyd deleted file mode 100644 index e190d75a9838ac1220cfa79b38eddf4794533c64..0000000000000000000000000000000000000000 --- a/build/torch210-cu128-x86_64-windows/_deformable_detr_cuda_d8a6191.pyd +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f94825a148a77c630ae4f24f75f65e96dd6e3379653643aa2e81420ba61a9db3 -size 9546240 diff --git a/build/torch210-cu128-x86_64-windows/_ops.py b/build/torch210-cu128-x86_64-windows/_ops.py deleted file mode 100644 index b4d286912955f247852eaaf90a1f579c28c2079f..0000000000000000000000000000000000000000 --- a/build/torch210-cu128-x86_64-windows/_ops.py +++ /dev/null @@ -1,9 +0,0 @@ -import torch -from . import _deformable_detr_cuda_d8a6191 -ops = torch.ops._deformable_detr_cuda_d8a6191 - -def add_op_namespace_prefix(op_name: str): - """ - Prefix op by namespace. - """ - return f"_deformable_detr_cuda_d8a6191::{op_name}" diff --git a/build/torch210-cu128-x86_64-windows/deformable_detr/__init__.py b/build/torch210-cu128-x86_64-windows/deformable_detr/__init__.py deleted file mode 100644 index bc434ef44e63409acb52a8f3fff54a4adc46ed6a..0000000000000000000000000000000000000000 --- a/build/torch210-cu128-x86_64-windows/deformable_detr/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -import ctypes -import sys - -import importlib -from pathlib import Path -from types import ModuleType - -def _import_from_path(file_path: Path) -> ModuleType: - # We cannot use the module name as-is, after adding it to `sys.modules`, - # it would also be used for other imports. So, we make a module name that - # depends on the path for it to be unique using the hex-encoded hash of - # the path. - path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value) - module_name = path_hash - spec = importlib.util.spec_from_file_location(module_name, file_path) - if spec is None: - raise ImportError(f"Cannot load spec for {module_name} from {file_path}") - module = importlib.util.module_from_spec(spec) - if module is None: - raise ImportError(f"Cannot load module {module_name} from spec") - sys.modules[module_name] = module - spec.loader.exec_module(module) # type: ignore - return module - - -globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py"))) diff --git a/build/torch210-cu128-x86_64-windows/layers.py b/build/torch210-cu128-x86_64-windows/layers.py deleted file mode 100644 index 1e682577b15f8985c02cb017a7a1f501f9d912aa..0000000000000000000000000000000000000000 --- a/build/torch210-cu128-x86_64-windows/layers.py +++ /dev/null @@ -1,84 +0,0 @@ -from typing import List, Union, Tuple - -from torch import Tensor -from torch.autograd import Function -from torch.autograd.function import once_differentiable -import torch.nn as nn - -from ._ops import ops - - -class MultiScaleDeformableAttentionFunction(Function): - @staticmethod - def forward( - context, - value: Tensor, - value_spatial_shapes: Tensor, - value_level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - context.im2col_step = im2col_step - output = ops.ms_deform_attn_forward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - context.im2col_step, - ) - context.save_for_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) - return output - - @staticmethod - @once_differentiable - def backward(context, grad_output): - ( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) = context.saved_tensors - grad_value, grad_sampling_loc, grad_attn_weight = ops.ms_deform_attn_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - grad_output, - context.im2col_step, - ) - - return grad_value, None, None, grad_sampling_loc, grad_attn_weight, None - - -class MultiScaleDeformableAttention(nn.Module): - def forward( - self, - value: Tensor, - value_spatial_shapes: Tensor, - value_spatial_shapes_list: List[Tuple], - level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - return MultiScaleDeformableAttentionFunction.apply( - value, - value_spatial_shapes, - level_start_index, - sampling_locations, - attention_weights, - im2col_step, - ) - - -__all__ = ["MultiScaleDeformableAttention"] diff --git a/build/torch210-cu128-x86_64-windows/metadata.json b/build/torch210-cu128-x86_64-windows/metadata.json deleted file mode 100644 index 7ddf5ff75a35f315c1398fff49390f17fd4e0ee9..0000000000000000000000000000000000000000 --- a/build/torch210-cu128-x86_64-windows/metadata.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "version": 1, - "license": "Apache-2.0", - "python-depends": [], - "backend": { - "type": "cuda", - "archs": [ - "10.0", - "10.1", - "12.0+PTX", - "7.0", - "7.2", - "7.5", - "8.0", - "8.6", - "8.7", - "8.9", - "9.0" - ] - } -} diff --git a/build/torch210-cxx11-cu126-aarch64-linux/_deformable_detr_cuda_5129df0.abi3.so b/build/torch210-cxx11-cu126-aarch64-linux/_deformable_detr_cuda_5129df0.abi3.so deleted file mode 100644 index 220bc52c3312138f8a98da0d4ad4636e7348bdf0..0000000000000000000000000000000000000000 --- a/build/torch210-cxx11-cu126-aarch64-linux/_deformable_detr_cuda_5129df0.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:66cd5232eb1176d043825bb7465727f7989e34deda4b3bc25d71dbd8dfd45178 -size 8606368 diff --git a/build/torch210-cxx11-cu126-aarch64-linux/_ops.py b/build/torch210-cxx11-cu126-aarch64-linux/_ops.py deleted file mode 100644 index 783ce5bea1df5ca480d0b45081055c75218172a9..0000000000000000000000000000000000000000 --- a/build/torch210-cxx11-cu126-aarch64-linux/_ops.py +++ /dev/null @@ -1,9 +0,0 @@ -import torch -from . import _deformable_detr_cuda_5129df0 -ops = torch.ops._deformable_detr_cuda_5129df0 - -def add_op_namespace_prefix(op_name: str): - """ - Prefix op by namespace. - """ - return f"_deformable_detr_cuda_5129df0::{op_name}" diff --git a/build/torch210-cxx11-cu126-aarch64-linux/deformable_detr/__init__.py b/build/torch210-cxx11-cu126-aarch64-linux/deformable_detr/__init__.py deleted file mode 100644 index a9b2672c1cd85b74c1b3ded0fc0b2100e1aeac23..0000000000000000000000000000000000000000 --- a/build/torch210-cxx11-cu126-aarch64-linux/deformable_detr/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -import ctypes -import importlib.util -import sys -from pathlib import Path -from types import ModuleType - - -def _import_from_path(file_path: Path) -> ModuleType: - # We cannot use the module name as-is, after adding it to `sys.modules`, - # it would also be used for other imports. So, we make a module name that - # depends on the path for it to be unique using the hex-encoded hash of - # the path. - path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value) - module_name = path_hash - spec = importlib.util.spec_from_file_location(module_name, file_path) - if spec is None: - raise ImportError(f"Cannot load spec for {module_name} from {file_path}") - module = importlib.util.module_from_spec(spec) - if module is None: - raise ImportError(f"Cannot load module {module_name} from spec") - sys.modules[module_name] = module - spec.loader.exec_module(module) # type: ignore - return module - - -globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py"))) diff --git a/build/torch210-cxx11-cu126-aarch64-linux/metadata.json b/build/torch210-cxx11-cu126-aarch64-linux/metadata.json deleted file mode 100644 index bb0c165adbb04b11681952cc8aa2a5fae882f72c..0000000000000000000000000000000000000000 --- a/build/torch210-cxx11-cu126-aarch64-linux/metadata.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "deformable-detr", - "id": "_deformable_detr_cuda_5129df0", - "version": 1, - "license": "Apache-2.0", - "python-depends": [], - "backend": { - "type": "cuda", - "archs": [ - "7.0", - "7.2", - "7.5", - "8.0", - "8.6", - "8.7", - "8.9", - "9.0+PTX" - ] - } -} diff --git a/build/torch210-cxx11-cu126-x86_64-linux/__init__.py b/build/torch210-cxx11-cu126-x86_64-linux/__init__.py deleted file mode 100644 index 33db73ca6e361af4707ba5bb5f55bf0e7c3005a4..0000000000000000000000000000000000000000 --- a/build/torch210-cxx11-cu126-x86_64-linux/__init__.py +++ /dev/null @@ -1,46 +0,0 @@ -from typing import List -import torch - -from ._ops import ops -from . import layers - - -def ms_deform_attn_backward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - grad_output: torch.Tensor, - im2col_step: int, -) -> List[torch.Tensor]: - return ops.ms_deform_attn_backward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - grad_output, - im2col_step, - ) - - -def ms_deform_attn_forward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - im2col_step: int, -) -> torch.Tensor: - return ops.ms_deform_attn_forward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - im2col_step, - ) - - -__all__ = ["layers", "ms_deform_attn_forward", "ms_deform_attn_backward"] diff --git a/build/torch210-cxx11-cu126-x86_64-linux/_deformable_detr_cuda_5129df0.abi3.so b/build/torch210-cxx11-cu126-x86_64-linux/_deformable_detr_cuda_5129df0.abi3.so deleted file mode 100644 index 8908484364186cb4bd4a2b0b850de2e8d1dfe6f3..0000000000000000000000000000000000000000 --- a/build/torch210-cxx11-cu126-x86_64-linux/_deformable_detr_cuda_5129df0.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:1a5053e022f3e5840ca9f40d361b5356ef0beeefdd8686029378dd4a7284b959 -size 8541080 diff --git a/build/torch210-cxx11-cu126-x86_64-linux/_ops.py b/build/torch210-cxx11-cu126-x86_64-linux/_ops.py deleted file mode 100644 index 783ce5bea1df5ca480d0b45081055c75218172a9..0000000000000000000000000000000000000000 --- a/build/torch210-cxx11-cu126-x86_64-linux/_ops.py +++ /dev/null @@ -1,9 +0,0 @@ -import torch -from . import _deformable_detr_cuda_5129df0 -ops = torch.ops._deformable_detr_cuda_5129df0 - -def add_op_namespace_prefix(op_name: str): - """ - Prefix op by namespace. - """ - return f"_deformable_detr_cuda_5129df0::{op_name}" diff --git a/build/torch210-cxx11-cu126-x86_64-linux/deformable_detr/__init__.py b/build/torch210-cxx11-cu126-x86_64-linux/deformable_detr/__init__.py deleted file mode 100644 index a9b2672c1cd85b74c1b3ded0fc0b2100e1aeac23..0000000000000000000000000000000000000000 --- a/build/torch210-cxx11-cu126-x86_64-linux/deformable_detr/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -import ctypes -import importlib.util -import sys -from pathlib import Path -from types import ModuleType - - -def _import_from_path(file_path: Path) -> ModuleType: - # We cannot use the module name as-is, after adding it to `sys.modules`, - # it would also be used for other imports. So, we make a module name that - # depends on the path for it to be unique using the hex-encoded hash of - # the path. - path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value) - module_name = path_hash - spec = importlib.util.spec_from_file_location(module_name, file_path) - if spec is None: - raise ImportError(f"Cannot load spec for {module_name} from {file_path}") - module = importlib.util.module_from_spec(spec) - if module is None: - raise ImportError(f"Cannot load module {module_name} from spec") - sys.modules[module_name] = module - spec.loader.exec_module(module) # type: ignore - return module - - -globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py"))) diff --git a/build/torch210-cxx11-cu126-x86_64-linux/layers.py b/build/torch210-cxx11-cu126-x86_64-linux/layers.py deleted file mode 100644 index db94032dea3d445f27017f923ae80468e18d2d77..0000000000000000000000000000000000000000 --- a/build/torch210-cxx11-cu126-x86_64-linux/layers.py +++ /dev/null @@ -1,84 +0,0 @@ -from typing import List, Union, Tuple - -from torch import Tensor -from torch.autograd import Function -from torch.autograd.function import once_differentiable -import torch.nn as nn - -from ._ops import ops - - -class MultiScaleDeformableAttentionFunction(Function): - @staticmethod - def forward( - context, - value: Tensor, - value_spatial_shapes: Tensor, - value_level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - context.im2col_step = im2col_step - output = ops.ms_deform_attn_forward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - context.im2col_step, - ) - context.save_for_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) - return output - - @staticmethod - @once_differentiable - def backward(context, grad_output): - ( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) = context.saved_tensors - grad_value, grad_sampling_loc, grad_attn_weight = ops.ms_deform_attn_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - grad_output, - context.im2col_step, - ) - - return grad_value, None, None, grad_sampling_loc, grad_attn_weight, None - - -class MultiScaleDeformableAttention(nn.Module): - def forward( - self, - value: Tensor, - value_spatial_shapes: Tensor, - value_spatial_shapes_list: List[Tuple], - level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - return MultiScaleDeformableAttentionFunction.apply( - value, - value_spatial_shapes, - level_start_index, - sampling_locations, - attention_weights, - im2col_step, - ) - - -__all__ = ["MultiScaleDeformableAttention"] diff --git a/build/torch210-cxx11-cu126-x86_64-linux/metadata.json b/build/torch210-cxx11-cu126-x86_64-linux/metadata.json deleted file mode 100644 index bb0c165adbb04b11681952cc8aa2a5fae882f72c..0000000000000000000000000000000000000000 --- a/build/torch210-cxx11-cu126-x86_64-linux/metadata.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "deformable-detr", - "id": "_deformable_detr_cuda_5129df0", - "version": 1, - "license": "Apache-2.0", - "python-depends": [], - "backend": { - "type": "cuda", - "archs": [ - "7.0", - "7.2", - "7.5", - "8.0", - "8.6", - "8.7", - "8.9", - "9.0+PTX" - ] - } -} diff --git a/build/torch210-cxx11-cu128-aarch64-linux/__init__.py b/build/torch210-cxx11-cu128-aarch64-linux/__init__.py deleted file mode 100644 index 33db73ca6e361af4707ba5bb5f55bf0e7c3005a4..0000000000000000000000000000000000000000 --- a/build/torch210-cxx11-cu128-aarch64-linux/__init__.py +++ /dev/null @@ -1,46 +0,0 @@ -from typing import List -import torch - -from ._ops import ops -from . import layers - - -def ms_deform_attn_backward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - grad_output: torch.Tensor, - im2col_step: int, -) -> List[torch.Tensor]: - return ops.ms_deform_attn_backward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - grad_output, - im2col_step, - ) - - -def ms_deform_attn_forward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - im2col_step: int, -) -> torch.Tensor: - return ops.ms_deform_attn_forward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - im2col_step, - ) - - -__all__ = ["layers", "ms_deform_attn_forward", "ms_deform_attn_backward"] diff --git a/build/torch210-cxx11-cu128-aarch64-linux/_deformable_detr_cuda_5129df0.abi3.so b/build/torch210-cxx11-cu128-aarch64-linux/_deformable_detr_cuda_5129df0.abi3.so deleted file mode 100644 index 60f445b2f884c2a15abc527520d85ab4102b6564..0000000000000000000000000000000000000000 --- a/build/torch210-cxx11-cu128-aarch64-linux/_deformable_detr_cuda_5129df0.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:7e47fb27665b884b9862ad0c7b172c518e858894ab76aa850b35456c2aaeefc7 -size 11621120 diff --git a/build/torch210-cxx11-cu128-aarch64-linux/_ops.py b/build/torch210-cxx11-cu128-aarch64-linux/_ops.py deleted file mode 100644 index 783ce5bea1df5ca480d0b45081055c75218172a9..0000000000000000000000000000000000000000 --- a/build/torch210-cxx11-cu128-aarch64-linux/_ops.py +++ /dev/null @@ -1,9 +0,0 @@ -import torch -from . import _deformable_detr_cuda_5129df0 -ops = torch.ops._deformable_detr_cuda_5129df0 - -def add_op_namespace_prefix(op_name: str): - """ - Prefix op by namespace. - """ - return f"_deformable_detr_cuda_5129df0::{op_name}" diff --git a/build/torch210-cxx11-cu128-aarch64-linux/deformable_detr/__init__.py b/build/torch210-cxx11-cu128-aarch64-linux/deformable_detr/__init__.py deleted file mode 100644 index a9b2672c1cd85b74c1b3ded0fc0b2100e1aeac23..0000000000000000000000000000000000000000 --- a/build/torch210-cxx11-cu128-aarch64-linux/deformable_detr/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -import ctypes -import importlib.util -import sys -from pathlib import Path -from types import ModuleType - - -def _import_from_path(file_path: Path) -> ModuleType: - # We cannot use the module name as-is, after adding it to `sys.modules`, - # it would also be used for other imports. So, we make a module name that - # depends on the path for it to be unique using the hex-encoded hash of - # the path. - path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value) - module_name = path_hash - spec = importlib.util.spec_from_file_location(module_name, file_path) - if spec is None: - raise ImportError(f"Cannot load spec for {module_name} from {file_path}") - module = importlib.util.module_from_spec(spec) - if module is None: - raise ImportError(f"Cannot load module {module_name} from spec") - sys.modules[module_name] = module - spec.loader.exec_module(module) # type: ignore - return module - - -globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py"))) diff --git a/build/torch210-cxx11-cu128-aarch64-linux/layers.py b/build/torch210-cxx11-cu128-aarch64-linux/layers.py deleted file mode 100644 index db94032dea3d445f27017f923ae80468e18d2d77..0000000000000000000000000000000000000000 --- a/build/torch210-cxx11-cu128-aarch64-linux/layers.py +++ /dev/null @@ -1,84 +0,0 @@ -from typing import List, Union, Tuple - -from torch import Tensor -from torch.autograd import Function -from torch.autograd.function import once_differentiable -import torch.nn as nn - -from ._ops import ops - - -class MultiScaleDeformableAttentionFunction(Function): - @staticmethod - def forward( - context, - value: Tensor, - value_spatial_shapes: Tensor, - value_level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - context.im2col_step = im2col_step - output = ops.ms_deform_attn_forward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - context.im2col_step, - ) - context.save_for_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) - return output - - @staticmethod - @once_differentiable - def backward(context, grad_output): - ( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) = context.saved_tensors - grad_value, grad_sampling_loc, grad_attn_weight = ops.ms_deform_attn_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - grad_output, - context.im2col_step, - ) - - return grad_value, None, None, grad_sampling_loc, grad_attn_weight, None - - -class MultiScaleDeformableAttention(nn.Module): - def forward( - self, - value: Tensor, - value_spatial_shapes: Tensor, - value_spatial_shapes_list: List[Tuple], - level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - return MultiScaleDeformableAttentionFunction.apply( - value, - value_spatial_shapes, - level_start_index, - sampling_locations, - attention_weights, - im2col_step, - ) - - -__all__ = ["MultiScaleDeformableAttention"] diff --git a/build/torch210-cxx11-cu128-aarch64-linux/metadata.json b/build/torch210-cxx11-cu128-aarch64-linux/metadata.json deleted file mode 100644 index 0fcb20719e2ac4d44873f57ed7289ea0994d6e6c..0000000000000000000000000000000000000000 --- a/build/torch210-cxx11-cu128-aarch64-linux/metadata.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "deformable-detr", - "id": "_deformable_detr_cuda_5129df0", - "version": 1, - "license": "Apache-2.0", - "python-depends": [], - "backend": { - "type": "cuda", - "archs": [ - "10.0", - "10.1", - "12.0+PTX", - "7.0", - "7.2", - "7.5", - "8.0", - "8.6", - "8.7", - "8.9", - "9.0" - ] - } -} diff --git a/build/torch210-cxx11-cu128-x86_64-linux/__init__.py b/build/torch210-cxx11-cu128-x86_64-linux/__init__.py deleted file mode 100644 index 33db73ca6e361af4707ba5bb5f55bf0e7c3005a4..0000000000000000000000000000000000000000 --- a/build/torch210-cxx11-cu128-x86_64-linux/__init__.py +++ /dev/null @@ -1,46 +0,0 @@ -from typing import List -import torch - -from ._ops import ops -from . import layers - - -def ms_deform_attn_backward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - grad_output: torch.Tensor, - im2col_step: int, -) -> List[torch.Tensor]: - return ops.ms_deform_attn_backward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - grad_output, - im2col_step, - ) - - -def ms_deform_attn_forward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - im2col_step: int, -) -> torch.Tensor: - return ops.ms_deform_attn_forward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - im2col_step, - ) - - -__all__ = ["layers", "ms_deform_attn_forward", "ms_deform_attn_backward"] diff --git a/build/torch210-cxx11-cu128-x86_64-linux/_deformable_detr_cuda_5129df0.abi3.so b/build/torch210-cxx11-cu128-x86_64-linux/_deformable_detr_cuda_5129df0.abi3.so deleted file mode 100644 index 9be8e640dc1e3772314fa9a68549903eab85444f..0000000000000000000000000000000000000000 --- a/build/torch210-cxx11-cu128-x86_64-linux/_deformable_detr_cuda_5129df0.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f6144f094d925d8d1f187bef56134f21353df4b62e5cf3ba9c6a60a059630400 -size 11524560 diff --git a/build/torch210-cxx11-cu128-x86_64-linux/_ops.py b/build/torch210-cxx11-cu128-x86_64-linux/_ops.py deleted file mode 100644 index 783ce5bea1df5ca480d0b45081055c75218172a9..0000000000000000000000000000000000000000 --- a/build/torch210-cxx11-cu128-x86_64-linux/_ops.py +++ /dev/null @@ -1,9 +0,0 @@ -import torch -from . import _deformable_detr_cuda_5129df0 -ops = torch.ops._deformable_detr_cuda_5129df0 - -def add_op_namespace_prefix(op_name: str): - """ - Prefix op by namespace. - """ - return f"_deformable_detr_cuda_5129df0::{op_name}" diff --git a/build/torch210-cxx11-cu128-x86_64-linux/deformable_detr/__init__.py b/build/torch210-cxx11-cu128-x86_64-linux/deformable_detr/__init__.py deleted file mode 100644 index a9b2672c1cd85b74c1b3ded0fc0b2100e1aeac23..0000000000000000000000000000000000000000 --- a/build/torch210-cxx11-cu128-x86_64-linux/deformable_detr/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -import ctypes -import importlib.util -import sys -from pathlib import Path -from types import ModuleType - - -def _import_from_path(file_path: Path) -> ModuleType: - # We cannot use the module name as-is, after adding it to `sys.modules`, - # it would also be used for other imports. So, we make a module name that - # depends on the path for it to be unique using the hex-encoded hash of - # the path. - path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value) - module_name = path_hash - spec = importlib.util.spec_from_file_location(module_name, file_path) - if spec is None: - raise ImportError(f"Cannot load spec for {module_name} from {file_path}") - module = importlib.util.module_from_spec(spec) - if module is None: - raise ImportError(f"Cannot load module {module_name} from spec") - sys.modules[module_name] = module - spec.loader.exec_module(module) # type: ignore - return module - - -globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py"))) diff --git a/build/torch210-cxx11-cu128-x86_64-linux/layers.py b/build/torch210-cxx11-cu128-x86_64-linux/layers.py deleted file mode 100644 index db94032dea3d445f27017f923ae80468e18d2d77..0000000000000000000000000000000000000000 --- a/build/torch210-cxx11-cu128-x86_64-linux/layers.py +++ /dev/null @@ -1,84 +0,0 @@ -from typing import List, Union, Tuple - -from torch import Tensor -from torch.autograd import Function -from torch.autograd.function import once_differentiable -import torch.nn as nn - -from ._ops import ops - - -class MultiScaleDeformableAttentionFunction(Function): - @staticmethod - def forward( - context, - value: Tensor, - value_spatial_shapes: Tensor, - value_level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - context.im2col_step = im2col_step - output = ops.ms_deform_attn_forward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - context.im2col_step, - ) - context.save_for_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) - return output - - @staticmethod - @once_differentiable - def backward(context, grad_output): - ( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) = context.saved_tensors - grad_value, grad_sampling_loc, grad_attn_weight = ops.ms_deform_attn_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - grad_output, - context.im2col_step, - ) - - return grad_value, None, None, grad_sampling_loc, grad_attn_weight, None - - -class MultiScaleDeformableAttention(nn.Module): - def forward( - self, - value: Tensor, - value_spatial_shapes: Tensor, - value_spatial_shapes_list: List[Tuple], - level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - return MultiScaleDeformableAttentionFunction.apply( - value, - value_spatial_shapes, - level_start_index, - sampling_locations, - attention_weights, - im2col_step, - ) - - -__all__ = ["MultiScaleDeformableAttention"] diff --git a/build/torch210-cxx11-cu128-x86_64-linux/metadata.json b/build/torch210-cxx11-cu128-x86_64-linux/metadata.json deleted file mode 100644 index 0fcb20719e2ac4d44873f57ed7289ea0994d6e6c..0000000000000000000000000000000000000000 --- a/build/torch210-cxx11-cu128-x86_64-linux/metadata.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "deformable-detr", - "id": "_deformable_detr_cuda_5129df0", - "version": 1, - "license": "Apache-2.0", - "python-depends": [], - "backend": { - "type": "cuda", - "archs": [ - "10.0", - "10.1", - "12.0+PTX", - "7.0", - "7.2", - "7.5", - "8.0", - "8.6", - "8.7", - "8.9", - "9.0" - ] - } -} diff --git a/build/torch210-cxx11-cu130-aarch64-linux/__init__.py b/build/torch210-cxx11-cu130-aarch64-linux/__init__.py deleted file mode 100644 index 33db73ca6e361af4707ba5bb5f55bf0e7c3005a4..0000000000000000000000000000000000000000 --- a/build/torch210-cxx11-cu130-aarch64-linux/__init__.py +++ /dev/null @@ -1,46 +0,0 @@ -from typing import List -import torch - -from ._ops import ops -from . import layers - - -def ms_deform_attn_backward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - grad_output: torch.Tensor, - im2col_step: int, -) -> List[torch.Tensor]: - return ops.ms_deform_attn_backward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - grad_output, - im2col_step, - ) - - -def ms_deform_attn_forward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - im2col_step: int, -) -> torch.Tensor: - return ops.ms_deform_attn_forward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - im2col_step, - ) - - -__all__ = ["layers", "ms_deform_attn_forward", "ms_deform_attn_backward"] diff --git a/build/torch210-cxx11-cu130-aarch64-linux/_deformable_detr_cuda_5129df0.abi3.so b/build/torch210-cxx11-cu130-aarch64-linux/_deformable_detr_cuda_5129df0.abi3.so deleted file mode 100644 index e6e2b50dea52ae57de4582c22497bbe61b5e8687..0000000000000000000000000000000000000000 --- a/build/torch210-cxx11-cu130-aarch64-linux/_deformable_detr_cuda_5129df0.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:5e8ec89df6277fe4f2ff232f4d6140a7a9b9fd25ddb1c1241c11fad8423a3a59 -size 9825896 diff --git a/build/torch210-cxx11-cu130-aarch64-linux/_ops.py b/build/torch210-cxx11-cu130-aarch64-linux/_ops.py deleted file mode 100644 index 783ce5bea1df5ca480d0b45081055c75218172a9..0000000000000000000000000000000000000000 --- a/build/torch210-cxx11-cu130-aarch64-linux/_ops.py +++ /dev/null @@ -1,9 +0,0 @@ -import torch -from . import _deformable_detr_cuda_5129df0 -ops = torch.ops._deformable_detr_cuda_5129df0 - -def add_op_namespace_prefix(op_name: str): - """ - Prefix op by namespace. - """ - return f"_deformable_detr_cuda_5129df0::{op_name}" diff --git a/build/torch210-cxx11-cu130-aarch64-linux/deformable_detr/__init__.py b/build/torch210-cxx11-cu130-aarch64-linux/deformable_detr/__init__.py deleted file mode 100644 index a9b2672c1cd85b74c1b3ded0fc0b2100e1aeac23..0000000000000000000000000000000000000000 --- a/build/torch210-cxx11-cu130-aarch64-linux/deformable_detr/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -import ctypes -import importlib.util -import sys -from pathlib import Path -from types import ModuleType - - -def _import_from_path(file_path: Path) -> ModuleType: - # We cannot use the module name as-is, after adding it to `sys.modules`, - # it would also be used for other imports. So, we make a module name that - # depends on the path for it to be unique using the hex-encoded hash of - # the path. - path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value) - module_name = path_hash - spec = importlib.util.spec_from_file_location(module_name, file_path) - if spec is None: - raise ImportError(f"Cannot load spec for {module_name} from {file_path}") - module = importlib.util.module_from_spec(spec) - if module is None: - raise ImportError(f"Cannot load module {module_name} from spec") - sys.modules[module_name] = module - spec.loader.exec_module(module) # type: ignore - return module - - -globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py"))) diff --git a/build/torch210-cxx11-cu130-aarch64-linux/layers.py b/build/torch210-cxx11-cu130-aarch64-linux/layers.py deleted file mode 100644 index db94032dea3d445f27017f923ae80468e18d2d77..0000000000000000000000000000000000000000 --- a/build/torch210-cxx11-cu130-aarch64-linux/layers.py +++ /dev/null @@ -1,84 +0,0 @@ -from typing import List, Union, Tuple - -from torch import Tensor -from torch.autograd import Function -from torch.autograd.function import once_differentiable -import torch.nn as nn - -from ._ops import ops - - -class MultiScaleDeformableAttentionFunction(Function): - @staticmethod - def forward( - context, - value: Tensor, - value_spatial_shapes: Tensor, - value_level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - context.im2col_step = im2col_step - output = ops.ms_deform_attn_forward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - context.im2col_step, - ) - context.save_for_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) - return output - - @staticmethod - @once_differentiable - def backward(context, grad_output): - ( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) = context.saved_tensors - grad_value, grad_sampling_loc, grad_attn_weight = ops.ms_deform_attn_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - grad_output, - context.im2col_step, - ) - - return grad_value, None, None, grad_sampling_loc, grad_attn_weight, None - - -class MultiScaleDeformableAttention(nn.Module): - def forward( - self, - value: Tensor, - value_spatial_shapes: Tensor, - value_spatial_shapes_list: List[Tuple], - level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - return MultiScaleDeformableAttentionFunction.apply( - value, - value_spatial_shapes, - level_start_index, - sampling_locations, - attention_weights, - im2col_step, - ) - - -__all__ = ["MultiScaleDeformableAttention"] diff --git a/build/torch210-cxx11-cu130-aarch64-linux/metadata.json b/build/torch210-cxx11-cu130-aarch64-linux/metadata.json deleted file mode 100644 index 3e52e107268791850ad981c36776d2fa3f01cf61..0000000000000000000000000000000000000000 --- a/build/torch210-cxx11-cu130-aarch64-linux/metadata.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "deformable-detr", - "id": "_deformable_detr_cuda_5129df0", - "version": 1, - "license": "Apache-2.0", - "python-depends": [], - "backend": { - "type": "cuda", - "archs": [ - "10.0", - "11.0", - "12.0+PTX", - "7.5", - "8.0", - "8.6", - "8.7", - "8.9", - "9.0" - ] - } -} diff --git a/build/torch210-cxx11-cu130-x86_64-linux/__init__.py b/build/torch210-cxx11-cu130-x86_64-linux/__init__.py deleted file mode 100644 index 33db73ca6e361af4707ba5bb5f55bf0e7c3005a4..0000000000000000000000000000000000000000 --- a/build/torch210-cxx11-cu130-x86_64-linux/__init__.py +++ /dev/null @@ -1,46 +0,0 @@ -from typing import List -import torch - -from ._ops import ops -from . import layers - - -def ms_deform_attn_backward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - grad_output: torch.Tensor, - im2col_step: int, -) -> List[torch.Tensor]: - return ops.ms_deform_attn_backward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - grad_output, - im2col_step, - ) - - -def ms_deform_attn_forward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - im2col_step: int, -) -> torch.Tensor: - return ops.ms_deform_attn_forward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - im2col_step, - ) - - -__all__ = ["layers", "ms_deform_attn_forward", "ms_deform_attn_backward"] diff --git a/build/torch210-cxx11-cu130-x86_64-linux/_deformable_detr_cuda_5129df0.abi3.so b/build/torch210-cxx11-cu130-x86_64-linux/_deformable_detr_cuda_5129df0.abi3.so deleted file mode 100644 index ee26198405da35282a453dfeeff2b55ccfe08f2a..0000000000000000000000000000000000000000 --- a/build/torch210-cxx11-cu130-x86_64-linux/_deformable_detr_cuda_5129df0.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:dc924d4f8fa8b6375abed86185db3e07118fdc9387fde2faa6199c0af810476a -size 9809000 diff --git a/build/torch210-cxx11-cu130-x86_64-linux/_ops.py b/build/torch210-cxx11-cu130-x86_64-linux/_ops.py deleted file mode 100644 index 783ce5bea1df5ca480d0b45081055c75218172a9..0000000000000000000000000000000000000000 --- a/build/torch210-cxx11-cu130-x86_64-linux/_ops.py +++ /dev/null @@ -1,9 +0,0 @@ -import torch -from . import _deformable_detr_cuda_5129df0 -ops = torch.ops._deformable_detr_cuda_5129df0 - -def add_op_namespace_prefix(op_name: str): - """ - Prefix op by namespace. - """ - return f"_deformable_detr_cuda_5129df0::{op_name}" diff --git a/build/torch210-cxx11-cu130-x86_64-linux/deformable_detr/__init__.py b/build/torch210-cxx11-cu130-x86_64-linux/deformable_detr/__init__.py deleted file mode 100644 index a9b2672c1cd85b74c1b3ded0fc0b2100e1aeac23..0000000000000000000000000000000000000000 --- a/build/torch210-cxx11-cu130-x86_64-linux/deformable_detr/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -import ctypes -import importlib.util -import sys -from pathlib import Path -from types import ModuleType - - -def _import_from_path(file_path: Path) -> ModuleType: - # We cannot use the module name as-is, after adding it to `sys.modules`, - # it would also be used for other imports. So, we make a module name that - # depends on the path for it to be unique using the hex-encoded hash of - # the path. - path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value) - module_name = path_hash - spec = importlib.util.spec_from_file_location(module_name, file_path) - if spec is None: - raise ImportError(f"Cannot load spec for {module_name} from {file_path}") - module = importlib.util.module_from_spec(spec) - if module is None: - raise ImportError(f"Cannot load module {module_name} from spec") - sys.modules[module_name] = module - spec.loader.exec_module(module) # type: ignore - return module - - -globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py"))) diff --git a/build/torch210-cxx11-cu130-x86_64-linux/layers.py b/build/torch210-cxx11-cu130-x86_64-linux/layers.py deleted file mode 100644 index db94032dea3d445f27017f923ae80468e18d2d77..0000000000000000000000000000000000000000 --- a/build/torch210-cxx11-cu130-x86_64-linux/layers.py +++ /dev/null @@ -1,84 +0,0 @@ -from typing import List, Union, Tuple - -from torch import Tensor -from torch.autograd import Function -from torch.autograd.function import once_differentiable -import torch.nn as nn - -from ._ops import ops - - -class MultiScaleDeformableAttentionFunction(Function): - @staticmethod - def forward( - context, - value: Tensor, - value_spatial_shapes: Tensor, - value_level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - context.im2col_step = im2col_step - output = ops.ms_deform_attn_forward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - context.im2col_step, - ) - context.save_for_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) - return output - - @staticmethod - @once_differentiable - def backward(context, grad_output): - ( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) = context.saved_tensors - grad_value, grad_sampling_loc, grad_attn_weight = ops.ms_deform_attn_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - grad_output, - context.im2col_step, - ) - - return grad_value, None, None, grad_sampling_loc, grad_attn_weight, None - - -class MultiScaleDeformableAttention(nn.Module): - def forward( - self, - value: Tensor, - value_spatial_shapes: Tensor, - value_spatial_shapes_list: List[Tuple], - level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - return MultiScaleDeformableAttentionFunction.apply( - value, - value_spatial_shapes, - level_start_index, - sampling_locations, - attention_weights, - im2col_step, - ) - - -__all__ = ["MultiScaleDeformableAttention"] diff --git a/build/torch210-cxx11-cu130-x86_64-linux/metadata.json b/build/torch210-cxx11-cu130-x86_64-linux/metadata.json deleted file mode 100644 index 3e52e107268791850ad981c36776d2fa3f01cf61..0000000000000000000000000000000000000000 --- a/build/torch210-cxx11-cu130-x86_64-linux/metadata.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "deformable-detr", - "id": "_deformable_detr_cuda_5129df0", - "version": 1, - "license": "Apache-2.0", - "python-depends": [], - "backend": { - "type": "cuda", - "archs": [ - "10.0", - "11.0", - "12.0+PTX", - "7.5", - "8.0", - "8.6", - "8.7", - "8.9", - "9.0" - ] - } -} diff --git a/build/torch211-cu128-x86_64-windows/__init__.py b/build/torch211-cu128-x86_64-windows/__init__.py deleted file mode 100644 index 7082e931a91c42eef91df9cfac9d908b919a0443..0000000000000000000000000000000000000000 --- a/build/torch211-cu128-x86_64-windows/__init__.py +++ /dev/null @@ -1,46 +0,0 @@ -from typing import List -import torch - -from ._ops import ops -from . import layers - - -def ms_deform_attn_backward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - grad_output: torch.Tensor, - im2col_step: int, -) -> List[torch.Tensor]: - return ops.ms_deform_attn_backward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - grad_output, - im2col_step, - ) - - -def ms_deform_attn_forward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - im2col_step: int, -) -> torch.Tensor: - return ops.ms_deform_attn_forward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - im2col_step, - ) - - -__all__ = ["layers", "ms_deform_attn_forward", "ms_deform_attn_backward"] diff --git a/build/torch211-cu128-x86_64-windows/_deformable_detr_cuda_a4c5c25.pyd b/build/torch211-cu128-x86_64-windows/_deformable_detr_cuda_a4c5c25.pyd deleted file mode 100644 index e79d5439ea738cf223f14115234dc92d0fe14fbf..0000000000000000000000000000000000000000 --- a/build/torch211-cu128-x86_64-windows/_deformable_detr_cuda_a4c5c25.pyd +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:6901592b0cde22932ed33bd9357fdbff9747d916c56fc25ffa455d7bb575bef5 -size 9546240 diff --git a/build/torch211-cu128-x86_64-windows/_ops.py b/build/torch211-cu128-x86_64-windows/_ops.py deleted file mode 100644 index c4c3b54981bc3b54a96f0585fe9bb0b91106060b..0000000000000000000000000000000000000000 --- a/build/torch211-cu128-x86_64-windows/_ops.py +++ /dev/null @@ -1,9 +0,0 @@ -import torch -from . import _deformable_detr_cuda_a4c5c25 -ops = torch.ops._deformable_detr_cuda_a4c5c25 - -def add_op_namespace_prefix(op_name: str): - """ - Prefix op by namespace. - """ - return f"_deformable_detr_cuda_a4c5c25::{op_name}" diff --git a/build/torch211-cu128-x86_64-windows/deformable_detr/__init__.py b/build/torch211-cu128-x86_64-windows/deformable_detr/__init__.py deleted file mode 100644 index d259f9535943d5617b4906d784ecd93a9d6dff82..0000000000000000000000000000000000000000 --- a/build/torch211-cu128-x86_64-windows/deformable_detr/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -import ctypes -import importlib.util -import sys -from pathlib import Path -from types import ModuleType - - -def _import_from_path(file_path: Path) -> ModuleType: - # We cannot use the module name as-is, after adding it to `sys.modules`, - # it would also be used for other imports. So, we make a module name that - # depends on the path for it to be unique using the hex-encoded hash of - # the path. - path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value) - module_name = path_hash - spec = importlib.util.spec_from_file_location(module_name, file_path) - if spec is None: - raise ImportError(f"Cannot load spec for {module_name} from {file_path}") - module = importlib.util.module_from_spec(spec) - if module is None: - raise ImportError(f"Cannot load module {module_name} from spec") - sys.modules[module_name] = module - spec.loader.exec_module(module) # type: ignore - return module - - -globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py"))) diff --git a/build/torch211-cu128-x86_64-windows/layers.py b/build/torch211-cu128-x86_64-windows/layers.py deleted file mode 100644 index 1e682577b15f8985c02cb017a7a1f501f9d912aa..0000000000000000000000000000000000000000 --- a/build/torch211-cu128-x86_64-windows/layers.py +++ /dev/null @@ -1,84 +0,0 @@ -from typing import List, Union, Tuple - -from torch import Tensor -from torch.autograd import Function -from torch.autograd.function import once_differentiable -import torch.nn as nn - -from ._ops import ops - - -class MultiScaleDeformableAttentionFunction(Function): - @staticmethod - def forward( - context, - value: Tensor, - value_spatial_shapes: Tensor, - value_level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - context.im2col_step = im2col_step - output = ops.ms_deform_attn_forward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - context.im2col_step, - ) - context.save_for_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) - return output - - @staticmethod - @once_differentiable - def backward(context, grad_output): - ( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) = context.saved_tensors - grad_value, grad_sampling_loc, grad_attn_weight = ops.ms_deform_attn_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - grad_output, - context.im2col_step, - ) - - return grad_value, None, None, grad_sampling_loc, grad_attn_weight, None - - -class MultiScaleDeformableAttention(nn.Module): - def forward( - self, - value: Tensor, - value_spatial_shapes: Tensor, - value_spatial_shapes_list: List[Tuple], - level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - return MultiScaleDeformableAttentionFunction.apply( - value, - value_spatial_shapes, - level_start_index, - sampling_locations, - attention_weights, - im2col_step, - ) - - -__all__ = ["MultiScaleDeformableAttention"] diff --git a/build/torch211-cu128-x86_64-windows/metadata.json b/build/torch211-cu128-x86_64-windows/metadata.json deleted file mode 100644 index 7ddf5ff75a35f315c1398fff49390f17fd4e0ee9..0000000000000000000000000000000000000000 --- a/build/torch211-cu128-x86_64-windows/metadata.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "version": 1, - "license": "Apache-2.0", - "python-depends": [], - "backend": { - "type": "cuda", - "archs": [ - "10.0", - "10.1", - "12.0+PTX", - "7.0", - "7.2", - "7.5", - "8.0", - "8.6", - "8.7", - "8.9", - "9.0" - ] - } -} diff --git a/build/torch211-cxx11-cu126-aarch64-linux/__init__.py b/build/torch211-cxx11-cu126-aarch64-linux/__init__.py deleted file mode 100644 index 33db73ca6e361af4707ba5bb5f55bf0e7c3005a4..0000000000000000000000000000000000000000 --- a/build/torch211-cxx11-cu126-aarch64-linux/__init__.py +++ /dev/null @@ -1,46 +0,0 @@ -from typing import List -import torch - -from ._ops import ops -from . import layers - - -def ms_deform_attn_backward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - grad_output: torch.Tensor, - im2col_step: int, -) -> List[torch.Tensor]: - return ops.ms_deform_attn_backward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - grad_output, - im2col_step, - ) - - -def ms_deform_attn_forward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - im2col_step: int, -) -> torch.Tensor: - return ops.ms_deform_attn_forward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - im2col_step, - ) - - -__all__ = ["layers", "ms_deform_attn_forward", "ms_deform_attn_backward"] diff --git a/build/torch211-cxx11-cu126-aarch64-linux/_deformable_detr_cuda_5129df0.abi3.so b/build/torch211-cxx11-cu126-aarch64-linux/_deformable_detr_cuda_5129df0.abi3.so deleted file mode 100644 index 95ff3553b7a79022fd1129b431eadda9201310e1..0000000000000000000000000000000000000000 --- a/build/torch211-cxx11-cu126-aarch64-linux/_deformable_detr_cuda_5129df0.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:cb34add17209b87b62eb02c5d67e67cc566779a48bfe31080fa48f59c3102052 -size 8606480 diff --git a/build/torch211-cxx11-cu126-aarch64-linux/_ops.py b/build/torch211-cxx11-cu126-aarch64-linux/_ops.py deleted file mode 100644 index 783ce5bea1df5ca480d0b45081055c75218172a9..0000000000000000000000000000000000000000 --- a/build/torch211-cxx11-cu126-aarch64-linux/_ops.py +++ /dev/null @@ -1,9 +0,0 @@ -import torch -from . import _deformable_detr_cuda_5129df0 -ops = torch.ops._deformable_detr_cuda_5129df0 - -def add_op_namespace_prefix(op_name: str): - """ - Prefix op by namespace. - """ - return f"_deformable_detr_cuda_5129df0::{op_name}" diff --git a/build/torch211-cxx11-cu126-aarch64-linux/deformable_detr/__init__.py b/build/torch211-cxx11-cu126-aarch64-linux/deformable_detr/__init__.py deleted file mode 100644 index a9b2672c1cd85b74c1b3ded0fc0b2100e1aeac23..0000000000000000000000000000000000000000 --- a/build/torch211-cxx11-cu126-aarch64-linux/deformable_detr/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -import ctypes -import importlib.util -import sys -from pathlib import Path -from types import ModuleType - - -def _import_from_path(file_path: Path) -> ModuleType: - # We cannot use the module name as-is, after adding it to `sys.modules`, - # it would also be used for other imports. So, we make a module name that - # depends on the path for it to be unique using the hex-encoded hash of - # the path. - path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value) - module_name = path_hash - spec = importlib.util.spec_from_file_location(module_name, file_path) - if spec is None: - raise ImportError(f"Cannot load spec for {module_name} from {file_path}") - module = importlib.util.module_from_spec(spec) - if module is None: - raise ImportError(f"Cannot load module {module_name} from spec") - sys.modules[module_name] = module - spec.loader.exec_module(module) # type: ignore - return module - - -globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py"))) diff --git a/build/torch211-cxx11-cu126-aarch64-linux/layers.py b/build/torch211-cxx11-cu126-aarch64-linux/layers.py deleted file mode 100644 index db94032dea3d445f27017f923ae80468e18d2d77..0000000000000000000000000000000000000000 --- a/build/torch211-cxx11-cu126-aarch64-linux/layers.py +++ /dev/null @@ -1,84 +0,0 @@ -from typing import List, Union, Tuple - -from torch import Tensor -from torch.autograd import Function -from torch.autograd.function import once_differentiable -import torch.nn as nn - -from ._ops import ops - - -class MultiScaleDeformableAttentionFunction(Function): - @staticmethod - def forward( - context, - value: Tensor, - value_spatial_shapes: Tensor, - value_level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - context.im2col_step = im2col_step - output = ops.ms_deform_attn_forward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - context.im2col_step, - ) - context.save_for_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) - return output - - @staticmethod - @once_differentiable - def backward(context, grad_output): - ( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) = context.saved_tensors - grad_value, grad_sampling_loc, grad_attn_weight = ops.ms_deform_attn_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - grad_output, - context.im2col_step, - ) - - return grad_value, None, None, grad_sampling_loc, grad_attn_weight, None - - -class MultiScaleDeformableAttention(nn.Module): - def forward( - self, - value: Tensor, - value_spatial_shapes: Tensor, - value_spatial_shapes_list: List[Tuple], - level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - return MultiScaleDeformableAttentionFunction.apply( - value, - value_spatial_shapes, - level_start_index, - sampling_locations, - attention_weights, - im2col_step, - ) - - -__all__ = ["MultiScaleDeformableAttention"] diff --git a/build/torch211-cxx11-cu126-aarch64-linux/metadata.json b/build/torch211-cxx11-cu126-aarch64-linux/metadata.json deleted file mode 100644 index bb0c165adbb04b11681952cc8aa2a5fae882f72c..0000000000000000000000000000000000000000 --- a/build/torch211-cxx11-cu126-aarch64-linux/metadata.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "deformable-detr", - "id": "_deformable_detr_cuda_5129df0", - "version": 1, - "license": "Apache-2.0", - "python-depends": [], - "backend": { - "type": "cuda", - "archs": [ - "7.0", - "7.2", - "7.5", - "8.0", - "8.6", - "8.7", - "8.9", - "9.0+PTX" - ] - } -} diff --git a/build/torch211-cxx11-cu126-x86_64-linux/__init__.py b/build/torch211-cxx11-cu126-x86_64-linux/__init__.py deleted file mode 100644 index 33db73ca6e361af4707ba5bb5f55bf0e7c3005a4..0000000000000000000000000000000000000000 --- a/build/torch211-cxx11-cu126-x86_64-linux/__init__.py +++ /dev/null @@ -1,46 +0,0 @@ -from typing import List -import torch - -from ._ops import ops -from . import layers - - -def ms_deform_attn_backward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - grad_output: torch.Tensor, - im2col_step: int, -) -> List[torch.Tensor]: - return ops.ms_deform_attn_backward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - grad_output, - im2col_step, - ) - - -def ms_deform_attn_forward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - im2col_step: int, -) -> torch.Tensor: - return ops.ms_deform_attn_forward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - im2col_step, - ) - - -__all__ = ["layers", "ms_deform_attn_forward", "ms_deform_attn_backward"] diff --git a/build/torch211-cxx11-cu126-x86_64-linux/_deformable_detr_cuda_5129df0.abi3.so b/build/torch211-cxx11-cu126-x86_64-linux/_deformable_detr_cuda_5129df0.abi3.so deleted file mode 100644 index e3aa1855de6c3bad8ec58cdc5e970de9ebe8be06..0000000000000000000000000000000000000000 --- a/build/torch211-cxx11-cu126-x86_64-linux/_deformable_detr_cuda_5129df0.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:76c05f842304fdb9c3d318f8e658c198229042606eedc15f4cce2f92b87abb10 -size 8541176 diff --git a/build/torch211-cxx11-cu126-x86_64-linux/_ops.py b/build/torch211-cxx11-cu126-x86_64-linux/_ops.py deleted file mode 100644 index 783ce5bea1df5ca480d0b45081055c75218172a9..0000000000000000000000000000000000000000 --- a/build/torch211-cxx11-cu126-x86_64-linux/_ops.py +++ /dev/null @@ -1,9 +0,0 @@ -import torch -from . import _deformable_detr_cuda_5129df0 -ops = torch.ops._deformable_detr_cuda_5129df0 - -def add_op_namespace_prefix(op_name: str): - """ - Prefix op by namespace. - """ - return f"_deformable_detr_cuda_5129df0::{op_name}" diff --git a/build/torch211-cxx11-cu126-x86_64-linux/deformable_detr/__init__.py b/build/torch211-cxx11-cu126-x86_64-linux/deformable_detr/__init__.py deleted file mode 100644 index a9b2672c1cd85b74c1b3ded0fc0b2100e1aeac23..0000000000000000000000000000000000000000 --- a/build/torch211-cxx11-cu126-x86_64-linux/deformable_detr/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -import ctypes -import importlib.util -import sys -from pathlib import Path -from types import ModuleType - - -def _import_from_path(file_path: Path) -> ModuleType: - # We cannot use the module name as-is, after adding it to `sys.modules`, - # it would also be used for other imports. So, we make a module name that - # depends on the path for it to be unique using the hex-encoded hash of - # the path. - path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value) - module_name = path_hash - spec = importlib.util.spec_from_file_location(module_name, file_path) - if spec is None: - raise ImportError(f"Cannot load spec for {module_name} from {file_path}") - module = importlib.util.module_from_spec(spec) - if module is None: - raise ImportError(f"Cannot load module {module_name} from spec") - sys.modules[module_name] = module - spec.loader.exec_module(module) # type: ignore - return module - - -globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py"))) diff --git a/build/torch211-cxx11-cu126-x86_64-linux/layers.py b/build/torch211-cxx11-cu126-x86_64-linux/layers.py deleted file mode 100644 index db94032dea3d445f27017f923ae80468e18d2d77..0000000000000000000000000000000000000000 --- a/build/torch211-cxx11-cu126-x86_64-linux/layers.py +++ /dev/null @@ -1,84 +0,0 @@ -from typing import List, Union, Tuple - -from torch import Tensor -from torch.autograd import Function -from torch.autograd.function import once_differentiable -import torch.nn as nn - -from ._ops import ops - - -class MultiScaleDeformableAttentionFunction(Function): - @staticmethod - def forward( - context, - value: Tensor, - value_spatial_shapes: Tensor, - value_level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - context.im2col_step = im2col_step - output = ops.ms_deform_attn_forward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - context.im2col_step, - ) - context.save_for_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) - return output - - @staticmethod - @once_differentiable - def backward(context, grad_output): - ( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) = context.saved_tensors - grad_value, grad_sampling_loc, grad_attn_weight = ops.ms_deform_attn_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - grad_output, - context.im2col_step, - ) - - return grad_value, None, None, grad_sampling_loc, grad_attn_weight, None - - -class MultiScaleDeformableAttention(nn.Module): - def forward( - self, - value: Tensor, - value_spatial_shapes: Tensor, - value_spatial_shapes_list: List[Tuple], - level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - return MultiScaleDeformableAttentionFunction.apply( - value, - value_spatial_shapes, - level_start_index, - sampling_locations, - attention_weights, - im2col_step, - ) - - -__all__ = ["MultiScaleDeformableAttention"] diff --git a/build/torch211-cxx11-cu126-x86_64-linux/metadata.json b/build/torch211-cxx11-cu126-x86_64-linux/metadata.json deleted file mode 100644 index bb0c165adbb04b11681952cc8aa2a5fae882f72c..0000000000000000000000000000000000000000 --- a/build/torch211-cxx11-cu126-x86_64-linux/metadata.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "deformable-detr", - "id": "_deformable_detr_cuda_5129df0", - "version": 1, - "license": "Apache-2.0", - "python-depends": [], - "backend": { - "type": "cuda", - "archs": [ - "7.0", - "7.2", - "7.5", - "8.0", - "8.6", - "8.7", - "8.9", - "9.0+PTX" - ] - } -} diff --git a/build/torch211-cxx11-cu128-aarch64-linux/__init__.py b/build/torch211-cxx11-cu128-aarch64-linux/__init__.py deleted file mode 100644 index 33db73ca6e361af4707ba5bb5f55bf0e7c3005a4..0000000000000000000000000000000000000000 --- a/build/torch211-cxx11-cu128-aarch64-linux/__init__.py +++ /dev/null @@ -1,46 +0,0 @@ -from typing import List -import torch - -from ._ops import ops -from . import layers - - -def ms_deform_attn_backward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - grad_output: torch.Tensor, - im2col_step: int, -) -> List[torch.Tensor]: - return ops.ms_deform_attn_backward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - grad_output, - im2col_step, - ) - - -def ms_deform_attn_forward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - im2col_step: int, -) -> torch.Tensor: - return ops.ms_deform_attn_forward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - im2col_step, - ) - - -__all__ = ["layers", "ms_deform_attn_forward", "ms_deform_attn_backward"] diff --git a/build/torch211-cxx11-cu128-aarch64-linux/_deformable_detr_cuda_5129df0.abi3.so b/build/torch211-cxx11-cu128-aarch64-linux/_deformable_detr_cuda_5129df0.abi3.so deleted file mode 100644 index d1776169e9b6e659af42f363be38a7cff20c7d46..0000000000000000000000000000000000000000 --- a/build/torch211-cxx11-cu128-aarch64-linux/_deformable_detr_cuda_5129df0.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:3ca889e76443b8eb1dc0fdb10d3e271ae478467d7724634960e8c78e888856c0 -size 11621232 diff --git a/build/torch211-cxx11-cu128-aarch64-linux/_ops.py b/build/torch211-cxx11-cu128-aarch64-linux/_ops.py deleted file mode 100644 index 783ce5bea1df5ca480d0b45081055c75218172a9..0000000000000000000000000000000000000000 --- a/build/torch211-cxx11-cu128-aarch64-linux/_ops.py +++ /dev/null @@ -1,9 +0,0 @@ -import torch -from . import _deformable_detr_cuda_5129df0 -ops = torch.ops._deformable_detr_cuda_5129df0 - -def add_op_namespace_prefix(op_name: str): - """ - Prefix op by namespace. - """ - return f"_deformable_detr_cuda_5129df0::{op_name}" diff --git a/build/torch211-cxx11-cu128-aarch64-linux/deformable_detr/__init__.py b/build/torch211-cxx11-cu128-aarch64-linux/deformable_detr/__init__.py deleted file mode 100644 index a9b2672c1cd85b74c1b3ded0fc0b2100e1aeac23..0000000000000000000000000000000000000000 --- a/build/torch211-cxx11-cu128-aarch64-linux/deformable_detr/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -import ctypes -import importlib.util -import sys -from pathlib import Path -from types import ModuleType - - -def _import_from_path(file_path: Path) -> ModuleType: - # We cannot use the module name as-is, after adding it to `sys.modules`, - # it would also be used for other imports. So, we make a module name that - # depends on the path for it to be unique using the hex-encoded hash of - # the path. - path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value) - module_name = path_hash - spec = importlib.util.spec_from_file_location(module_name, file_path) - if spec is None: - raise ImportError(f"Cannot load spec for {module_name} from {file_path}") - module = importlib.util.module_from_spec(spec) - if module is None: - raise ImportError(f"Cannot load module {module_name} from spec") - sys.modules[module_name] = module - spec.loader.exec_module(module) # type: ignore - return module - - -globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py"))) diff --git a/build/torch211-cxx11-cu128-aarch64-linux/layers.py b/build/torch211-cxx11-cu128-aarch64-linux/layers.py deleted file mode 100644 index db94032dea3d445f27017f923ae80468e18d2d77..0000000000000000000000000000000000000000 --- a/build/torch211-cxx11-cu128-aarch64-linux/layers.py +++ /dev/null @@ -1,84 +0,0 @@ -from typing import List, Union, Tuple - -from torch import Tensor -from torch.autograd import Function -from torch.autograd.function import once_differentiable -import torch.nn as nn - -from ._ops import ops - - -class MultiScaleDeformableAttentionFunction(Function): - @staticmethod - def forward( - context, - value: Tensor, - value_spatial_shapes: Tensor, - value_level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - context.im2col_step = im2col_step - output = ops.ms_deform_attn_forward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - context.im2col_step, - ) - context.save_for_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) - return output - - @staticmethod - @once_differentiable - def backward(context, grad_output): - ( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) = context.saved_tensors - grad_value, grad_sampling_loc, grad_attn_weight = ops.ms_deform_attn_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - grad_output, - context.im2col_step, - ) - - return grad_value, None, None, grad_sampling_loc, grad_attn_weight, None - - -class MultiScaleDeformableAttention(nn.Module): - def forward( - self, - value: Tensor, - value_spatial_shapes: Tensor, - value_spatial_shapes_list: List[Tuple], - level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - return MultiScaleDeformableAttentionFunction.apply( - value, - value_spatial_shapes, - level_start_index, - sampling_locations, - attention_weights, - im2col_step, - ) - - -__all__ = ["MultiScaleDeformableAttention"] diff --git a/build/torch211-cxx11-cu128-aarch64-linux/metadata.json b/build/torch211-cxx11-cu128-aarch64-linux/metadata.json deleted file mode 100644 index 0fcb20719e2ac4d44873f57ed7289ea0994d6e6c..0000000000000000000000000000000000000000 --- a/build/torch211-cxx11-cu128-aarch64-linux/metadata.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "deformable-detr", - "id": "_deformable_detr_cuda_5129df0", - "version": 1, - "license": "Apache-2.0", - "python-depends": [], - "backend": { - "type": "cuda", - "archs": [ - "10.0", - "10.1", - "12.0+PTX", - "7.0", - "7.2", - "7.5", - "8.0", - "8.6", - "8.7", - "8.9", - "9.0" - ] - } -} diff --git a/build/torch211-cxx11-cu128-x86_64-linux/__init__.py b/build/torch211-cxx11-cu128-x86_64-linux/__init__.py deleted file mode 100644 index 33db73ca6e361af4707ba5bb5f55bf0e7c3005a4..0000000000000000000000000000000000000000 --- a/build/torch211-cxx11-cu128-x86_64-linux/__init__.py +++ /dev/null @@ -1,46 +0,0 @@ -from typing import List -import torch - -from ._ops import ops -from . import layers - - -def ms_deform_attn_backward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - grad_output: torch.Tensor, - im2col_step: int, -) -> List[torch.Tensor]: - return ops.ms_deform_attn_backward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - grad_output, - im2col_step, - ) - - -def ms_deform_attn_forward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - im2col_step: int, -) -> torch.Tensor: - return ops.ms_deform_attn_forward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - im2col_step, - ) - - -__all__ = ["layers", "ms_deform_attn_forward", "ms_deform_attn_backward"] diff --git a/build/torch211-cxx11-cu128-x86_64-linux/_deformable_detr_cuda_5129df0.abi3.so b/build/torch211-cxx11-cu128-x86_64-linux/_deformable_detr_cuda_5129df0.abi3.so deleted file mode 100644 index 9d30d5b99d74a140f76df517bb411f58004f6ace..0000000000000000000000000000000000000000 --- a/build/torch211-cxx11-cu128-x86_64-linux/_deformable_detr_cuda_5129df0.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:e1e7ac327b918f3b58b78b89b439a6e25643da82c703ff7dba859b4c9b1b0372 -size 11528752 diff --git a/build/torch211-cxx11-cu128-x86_64-linux/_ops.py b/build/torch211-cxx11-cu128-x86_64-linux/_ops.py deleted file mode 100644 index 783ce5bea1df5ca480d0b45081055c75218172a9..0000000000000000000000000000000000000000 --- a/build/torch211-cxx11-cu128-x86_64-linux/_ops.py +++ /dev/null @@ -1,9 +0,0 @@ -import torch -from . import _deformable_detr_cuda_5129df0 -ops = torch.ops._deformable_detr_cuda_5129df0 - -def add_op_namespace_prefix(op_name: str): - """ - Prefix op by namespace. - """ - return f"_deformable_detr_cuda_5129df0::{op_name}" diff --git a/build/torch211-cxx11-cu128-x86_64-linux/deformable_detr/__init__.py b/build/torch211-cxx11-cu128-x86_64-linux/deformable_detr/__init__.py deleted file mode 100644 index a9b2672c1cd85b74c1b3ded0fc0b2100e1aeac23..0000000000000000000000000000000000000000 --- a/build/torch211-cxx11-cu128-x86_64-linux/deformable_detr/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -import ctypes -import importlib.util -import sys -from pathlib import Path -from types import ModuleType - - -def _import_from_path(file_path: Path) -> ModuleType: - # We cannot use the module name as-is, after adding it to `sys.modules`, - # it would also be used for other imports. So, we make a module name that - # depends on the path for it to be unique using the hex-encoded hash of - # the path. - path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value) - module_name = path_hash - spec = importlib.util.spec_from_file_location(module_name, file_path) - if spec is None: - raise ImportError(f"Cannot load spec for {module_name} from {file_path}") - module = importlib.util.module_from_spec(spec) - if module is None: - raise ImportError(f"Cannot load module {module_name} from spec") - sys.modules[module_name] = module - spec.loader.exec_module(module) # type: ignore - return module - - -globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py"))) diff --git a/build/torch211-cxx11-cu128-x86_64-linux/layers.py b/build/torch211-cxx11-cu128-x86_64-linux/layers.py deleted file mode 100644 index db94032dea3d445f27017f923ae80468e18d2d77..0000000000000000000000000000000000000000 --- a/build/torch211-cxx11-cu128-x86_64-linux/layers.py +++ /dev/null @@ -1,84 +0,0 @@ -from typing import List, Union, Tuple - -from torch import Tensor -from torch.autograd import Function -from torch.autograd.function import once_differentiable -import torch.nn as nn - -from ._ops import ops - - -class MultiScaleDeformableAttentionFunction(Function): - @staticmethod - def forward( - context, - value: Tensor, - value_spatial_shapes: Tensor, - value_level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - context.im2col_step = im2col_step - output = ops.ms_deform_attn_forward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - context.im2col_step, - ) - context.save_for_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) - return output - - @staticmethod - @once_differentiable - def backward(context, grad_output): - ( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) = context.saved_tensors - grad_value, grad_sampling_loc, grad_attn_weight = ops.ms_deform_attn_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - grad_output, - context.im2col_step, - ) - - return grad_value, None, None, grad_sampling_loc, grad_attn_weight, None - - -class MultiScaleDeformableAttention(nn.Module): - def forward( - self, - value: Tensor, - value_spatial_shapes: Tensor, - value_spatial_shapes_list: List[Tuple], - level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - return MultiScaleDeformableAttentionFunction.apply( - value, - value_spatial_shapes, - level_start_index, - sampling_locations, - attention_weights, - im2col_step, - ) - - -__all__ = ["MultiScaleDeformableAttention"] diff --git a/build/torch211-cxx11-cu128-x86_64-linux/metadata.json b/build/torch211-cxx11-cu128-x86_64-linux/metadata.json deleted file mode 100644 index 0fcb20719e2ac4d44873f57ed7289ea0994d6e6c..0000000000000000000000000000000000000000 --- a/build/torch211-cxx11-cu128-x86_64-linux/metadata.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "deformable-detr", - "id": "_deformable_detr_cuda_5129df0", - "version": 1, - "license": "Apache-2.0", - "python-depends": [], - "backend": { - "type": "cuda", - "archs": [ - "10.0", - "10.1", - "12.0+PTX", - "7.0", - "7.2", - "7.5", - "8.0", - "8.6", - "8.7", - "8.9", - "9.0" - ] - } -} diff --git a/build/torch211-cxx11-cu130-aarch64-linux/__init__.py b/build/torch211-cxx11-cu130-aarch64-linux/__init__.py deleted file mode 100644 index 33db73ca6e361af4707ba5bb5f55bf0e7c3005a4..0000000000000000000000000000000000000000 --- a/build/torch211-cxx11-cu130-aarch64-linux/__init__.py +++ /dev/null @@ -1,46 +0,0 @@ -from typing import List -import torch - -from ._ops import ops -from . import layers - - -def ms_deform_attn_backward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - grad_output: torch.Tensor, - im2col_step: int, -) -> List[torch.Tensor]: - return ops.ms_deform_attn_backward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - grad_output, - im2col_step, - ) - - -def ms_deform_attn_forward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - im2col_step: int, -) -> torch.Tensor: - return ops.ms_deform_attn_forward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - im2col_step, - ) - - -__all__ = ["layers", "ms_deform_attn_forward", "ms_deform_attn_backward"] diff --git a/build/torch211-cxx11-cu130-aarch64-linux/_deformable_detr_cuda_5129df0.abi3.so b/build/torch211-cxx11-cu130-aarch64-linux/_deformable_detr_cuda_5129df0.abi3.so deleted file mode 100644 index 8c8c6e49eb515118a16d67baaa45388349733aa2..0000000000000000000000000000000000000000 --- a/build/torch211-cxx11-cu130-aarch64-linux/_deformable_detr_cuda_5129df0.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:bf06210184e878faaacee9dbce3d1ae188aedb3d6f704a73f5741052d0e5906e -size 9891552 diff --git a/build/torch211-cxx11-cu130-aarch64-linux/_ops.py b/build/torch211-cxx11-cu130-aarch64-linux/_ops.py deleted file mode 100644 index 783ce5bea1df5ca480d0b45081055c75218172a9..0000000000000000000000000000000000000000 --- a/build/torch211-cxx11-cu130-aarch64-linux/_ops.py +++ /dev/null @@ -1,9 +0,0 @@ -import torch -from . import _deformable_detr_cuda_5129df0 -ops = torch.ops._deformable_detr_cuda_5129df0 - -def add_op_namespace_prefix(op_name: str): - """ - Prefix op by namespace. - """ - return f"_deformable_detr_cuda_5129df0::{op_name}" diff --git a/build/torch211-cxx11-cu130-aarch64-linux/deformable_detr/__init__.py b/build/torch211-cxx11-cu130-aarch64-linux/deformable_detr/__init__.py deleted file mode 100644 index a9b2672c1cd85b74c1b3ded0fc0b2100e1aeac23..0000000000000000000000000000000000000000 --- a/build/torch211-cxx11-cu130-aarch64-linux/deformable_detr/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -import ctypes -import importlib.util -import sys -from pathlib import Path -from types import ModuleType - - -def _import_from_path(file_path: Path) -> ModuleType: - # We cannot use the module name as-is, after adding it to `sys.modules`, - # it would also be used for other imports. So, we make a module name that - # depends on the path for it to be unique using the hex-encoded hash of - # the path. - path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value) - module_name = path_hash - spec = importlib.util.spec_from_file_location(module_name, file_path) - if spec is None: - raise ImportError(f"Cannot load spec for {module_name} from {file_path}") - module = importlib.util.module_from_spec(spec) - if module is None: - raise ImportError(f"Cannot load module {module_name} from spec") - sys.modules[module_name] = module - spec.loader.exec_module(module) # type: ignore - return module - - -globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py"))) diff --git a/build/torch211-cxx11-cu130-aarch64-linux/layers.py b/build/torch211-cxx11-cu130-aarch64-linux/layers.py deleted file mode 100644 index db94032dea3d445f27017f923ae80468e18d2d77..0000000000000000000000000000000000000000 --- a/build/torch211-cxx11-cu130-aarch64-linux/layers.py +++ /dev/null @@ -1,84 +0,0 @@ -from typing import List, Union, Tuple - -from torch import Tensor -from torch.autograd import Function -from torch.autograd.function import once_differentiable -import torch.nn as nn - -from ._ops import ops - - -class MultiScaleDeformableAttentionFunction(Function): - @staticmethod - def forward( - context, - value: Tensor, - value_spatial_shapes: Tensor, - value_level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - context.im2col_step = im2col_step - output = ops.ms_deform_attn_forward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - context.im2col_step, - ) - context.save_for_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) - return output - - @staticmethod - @once_differentiable - def backward(context, grad_output): - ( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) = context.saved_tensors - grad_value, grad_sampling_loc, grad_attn_weight = ops.ms_deform_attn_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - grad_output, - context.im2col_step, - ) - - return grad_value, None, None, grad_sampling_loc, grad_attn_weight, None - - -class MultiScaleDeformableAttention(nn.Module): - def forward( - self, - value: Tensor, - value_spatial_shapes: Tensor, - value_spatial_shapes_list: List[Tuple], - level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - return MultiScaleDeformableAttentionFunction.apply( - value, - value_spatial_shapes, - level_start_index, - sampling_locations, - attention_weights, - im2col_step, - ) - - -__all__ = ["MultiScaleDeformableAttention"] diff --git a/build/torch211-cxx11-cu130-aarch64-linux/metadata.json b/build/torch211-cxx11-cu130-aarch64-linux/metadata.json deleted file mode 100644 index 3e52e107268791850ad981c36776d2fa3f01cf61..0000000000000000000000000000000000000000 --- a/build/torch211-cxx11-cu130-aarch64-linux/metadata.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "deformable-detr", - "id": "_deformable_detr_cuda_5129df0", - "version": 1, - "license": "Apache-2.0", - "python-depends": [], - "backend": { - "type": "cuda", - "archs": [ - "10.0", - "11.0", - "12.0+PTX", - "7.5", - "8.0", - "8.6", - "8.7", - "8.9", - "9.0" - ] - } -} diff --git a/build/torch211-cxx11-cu130-x86_64-linux/__init__.py b/build/torch211-cxx11-cu130-x86_64-linux/__init__.py deleted file mode 100644 index 33db73ca6e361af4707ba5bb5f55bf0e7c3005a4..0000000000000000000000000000000000000000 --- a/build/torch211-cxx11-cu130-x86_64-linux/__init__.py +++ /dev/null @@ -1,46 +0,0 @@ -from typing import List -import torch - -from ._ops import ops -from . import layers - - -def ms_deform_attn_backward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - grad_output: torch.Tensor, - im2col_step: int, -) -> List[torch.Tensor]: - return ops.ms_deform_attn_backward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - grad_output, - im2col_step, - ) - - -def ms_deform_attn_forward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - im2col_step: int, -) -> torch.Tensor: - return ops.ms_deform_attn_forward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - im2col_step, - ) - - -__all__ = ["layers", "ms_deform_attn_forward", "ms_deform_attn_backward"] diff --git a/build/torch211-cxx11-cu130-x86_64-linux/_deformable_detr_cuda_5129df0.abi3.so b/build/torch211-cxx11-cu130-x86_64-linux/_deformable_detr_cuda_5129df0.abi3.so deleted file mode 100644 index 200dcb5c4daf07ec12c940ccd8c960b113e382de..0000000000000000000000000000000000000000 --- a/build/torch211-cxx11-cu130-x86_64-linux/_deformable_detr_cuda_5129df0.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b80725ee4801451e93ff247405c4d670ca8e525c4135d4fc4a19333a17456537 -size 9809096 diff --git a/build/torch211-cxx11-cu130-x86_64-linux/_ops.py b/build/torch211-cxx11-cu130-x86_64-linux/_ops.py deleted file mode 100644 index 783ce5bea1df5ca480d0b45081055c75218172a9..0000000000000000000000000000000000000000 --- a/build/torch211-cxx11-cu130-x86_64-linux/_ops.py +++ /dev/null @@ -1,9 +0,0 @@ -import torch -from . import _deformable_detr_cuda_5129df0 -ops = torch.ops._deformable_detr_cuda_5129df0 - -def add_op_namespace_prefix(op_name: str): - """ - Prefix op by namespace. - """ - return f"_deformable_detr_cuda_5129df0::{op_name}" diff --git a/build/torch211-cxx11-cu130-x86_64-linux/deformable_detr/__init__.py b/build/torch211-cxx11-cu130-x86_64-linux/deformable_detr/__init__.py deleted file mode 100644 index a9b2672c1cd85b74c1b3ded0fc0b2100e1aeac23..0000000000000000000000000000000000000000 --- a/build/torch211-cxx11-cu130-x86_64-linux/deformable_detr/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -import ctypes -import importlib.util -import sys -from pathlib import Path -from types import ModuleType - - -def _import_from_path(file_path: Path) -> ModuleType: - # We cannot use the module name as-is, after adding it to `sys.modules`, - # it would also be used for other imports. So, we make a module name that - # depends on the path for it to be unique using the hex-encoded hash of - # the path. - path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value) - module_name = path_hash - spec = importlib.util.spec_from_file_location(module_name, file_path) - if spec is None: - raise ImportError(f"Cannot load spec for {module_name} from {file_path}") - module = importlib.util.module_from_spec(spec) - if module is None: - raise ImportError(f"Cannot load module {module_name} from spec") - sys.modules[module_name] = module - spec.loader.exec_module(module) # type: ignore - return module - - -globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py"))) diff --git a/build/torch211-cxx11-cu130-x86_64-linux/layers.py b/build/torch211-cxx11-cu130-x86_64-linux/layers.py deleted file mode 100644 index db94032dea3d445f27017f923ae80468e18d2d77..0000000000000000000000000000000000000000 --- a/build/torch211-cxx11-cu130-x86_64-linux/layers.py +++ /dev/null @@ -1,84 +0,0 @@ -from typing import List, Union, Tuple - -from torch import Tensor -from torch.autograd import Function -from torch.autograd.function import once_differentiable -import torch.nn as nn - -from ._ops import ops - - -class MultiScaleDeformableAttentionFunction(Function): - @staticmethod - def forward( - context, - value: Tensor, - value_spatial_shapes: Tensor, - value_level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - context.im2col_step = im2col_step - output = ops.ms_deform_attn_forward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - context.im2col_step, - ) - context.save_for_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) - return output - - @staticmethod - @once_differentiable - def backward(context, grad_output): - ( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) = context.saved_tensors - grad_value, grad_sampling_loc, grad_attn_weight = ops.ms_deform_attn_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - grad_output, - context.im2col_step, - ) - - return grad_value, None, None, grad_sampling_loc, grad_attn_weight, None - - -class MultiScaleDeformableAttention(nn.Module): - def forward( - self, - value: Tensor, - value_spatial_shapes: Tensor, - value_spatial_shapes_list: List[Tuple], - level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - return MultiScaleDeformableAttentionFunction.apply( - value, - value_spatial_shapes, - level_start_index, - sampling_locations, - attention_weights, - im2col_step, - ) - - -__all__ = ["MultiScaleDeformableAttention"] diff --git a/build/torch211-cxx11-cu130-x86_64-linux/metadata.json b/build/torch211-cxx11-cu130-x86_64-linux/metadata.json deleted file mode 100644 index 3e52e107268791850ad981c36776d2fa3f01cf61..0000000000000000000000000000000000000000 --- a/build/torch211-cxx11-cu130-x86_64-linux/metadata.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "deformable-detr", - "id": "_deformable_detr_cuda_5129df0", - "version": 1, - "license": "Apache-2.0", - "python-depends": [], - "backend": { - "type": "cuda", - "archs": [ - "10.0", - "11.0", - "12.0+PTX", - "7.5", - "8.0", - "8.6", - "8.7", - "8.9", - "9.0" - ] - } -} diff --git a/build/torch212-cxx11-cu126-aarch64-linux/__init__.py b/build/torch212-cxx11-cu126-aarch64-linux/__init__.py deleted file mode 100644 index 33db73ca6e361af4707ba5bb5f55bf0e7c3005a4..0000000000000000000000000000000000000000 --- a/build/torch212-cxx11-cu126-aarch64-linux/__init__.py +++ /dev/null @@ -1,46 +0,0 @@ -from typing import List -import torch - -from ._ops import ops -from . import layers - - -def ms_deform_attn_backward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - grad_output: torch.Tensor, - im2col_step: int, -) -> List[torch.Tensor]: - return ops.ms_deform_attn_backward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - grad_output, - im2col_step, - ) - - -def ms_deform_attn_forward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - im2col_step: int, -) -> torch.Tensor: - return ops.ms_deform_attn_forward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - im2col_step, - ) - - -__all__ = ["layers", "ms_deform_attn_forward", "ms_deform_attn_backward"] diff --git a/build/torch212-cxx11-cu126-aarch64-linux/_deformable_detr_cuda_5129df0.abi3.so b/build/torch212-cxx11-cu126-aarch64-linux/_deformable_detr_cuda_5129df0.abi3.so deleted file mode 100644 index 21ee2be620a055ce18fbe0bf19f4bf8b10fe430c..0000000000000000000000000000000000000000 --- a/build/torch212-cxx11-cu126-aarch64-linux/_deformable_detr_cuda_5129df0.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:6d734bf2fc6c4eda5df9e1e7bd27263a1e206de5a1e3f28afbb4215626f112cc -size 8606640 diff --git a/build/torch212-cxx11-cu126-aarch64-linux/_ops.py b/build/torch212-cxx11-cu126-aarch64-linux/_ops.py deleted file mode 100644 index 783ce5bea1df5ca480d0b45081055c75218172a9..0000000000000000000000000000000000000000 --- a/build/torch212-cxx11-cu126-aarch64-linux/_ops.py +++ /dev/null @@ -1,9 +0,0 @@ -import torch -from . import _deformable_detr_cuda_5129df0 -ops = torch.ops._deformable_detr_cuda_5129df0 - -def add_op_namespace_prefix(op_name: str): - """ - Prefix op by namespace. - """ - return f"_deformable_detr_cuda_5129df0::{op_name}" diff --git a/build/torch212-cxx11-cu126-aarch64-linux/deformable_detr/__init__.py b/build/torch212-cxx11-cu126-aarch64-linux/deformable_detr/__init__.py deleted file mode 100644 index a9b2672c1cd85b74c1b3ded0fc0b2100e1aeac23..0000000000000000000000000000000000000000 --- a/build/torch212-cxx11-cu126-aarch64-linux/deformable_detr/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -import ctypes -import importlib.util -import sys -from pathlib import Path -from types import ModuleType - - -def _import_from_path(file_path: Path) -> ModuleType: - # We cannot use the module name as-is, after adding it to `sys.modules`, - # it would also be used for other imports. So, we make a module name that - # depends on the path for it to be unique using the hex-encoded hash of - # the path. - path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value) - module_name = path_hash - spec = importlib.util.spec_from_file_location(module_name, file_path) - if spec is None: - raise ImportError(f"Cannot load spec for {module_name} from {file_path}") - module = importlib.util.module_from_spec(spec) - if module is None: - raise ImportError(f"Cannot load module {module_name} from spec") - sys.modules[module_name] = module - spec.loader.exec_module(module) # type: ignore - return module - - -globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py"))) diff --git a/build/torch212-cxx11-cu126-aarch64-linux/layers.py b/build/torch212-cxx11-cu126-aarch64-linux/layers.py deleted file mode 100644 index db94032dea3d445f27017f923ae80468e18d2d77..0000000000000000000000000000000000000000 --- a/build/torch212-cxx11-cu126-aarch64-linux/layers.py +++ /dev/null @@ -1,84 +0,0 @@ -from typing import List, Union, Tuple - -from torch import Tensor -from torch.autograd import Function -from torch.autograd.function import once_differentiable -import torch.nn as nn - -from ._ops import ops - - -class MultiScaleDeformableAttentionFunction(Function): - @staticmethod - def forward( - context, - value: Tensor, - value_spatial_shapes: Tensor, - value_level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - context.im2col_step = im2col_step - output = ops.ms_deform_attn_forward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - context.im2col_step, - ) - context.save_for_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) - return output - - @staticmethod - @once_differentiable - def backward(context, grad_output): - ( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) = context.saved_tensors - grad_value, grad_sampling_loc, grad_attn_weight = ops.ms_deform_attn_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - grad_output, - context.im2col_step, - ) - - return grad_value, None, None, grad_sampling_loc, grad_attn_weight, None - - -class MultiScaleDeformableAttention(nn.Module): - def forward( - self, - value: Tensor, - value_spatial_shapes: Tensor, - value_spatial_shapes_list: List[Tuple], - level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - return MultiScaleDeformableAttentionFunction.apply( - value, - value_spatial_shapes, - level_start_index, - sampling_locations, - attention_weights, - im2col_step, - ) - - -__all__ = ["MultiScaleDeformableAttention"] diff --git a/build/torch212-cxx11-cu126-aarch64-linux/metadata.json b/build/torch212-cxx11-cu126-aarch64-linux/metadata.json deleted file mode 100644 index bb0c165adbb04b11681952cc8aa2a5fae882f72c..0000000000000000000000000000000000000000 --- a/build/torch212-cxx11-cu126-aarch64-linux/metadata.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "deformable-detr", - "id": "_deformable_detr_cuda_5129df0", - "version": 1, - "license": "Apache-2.0", - "python-depends": [], - "backend": { - "type": "cuda", - "archs": [ - "7.0", - "7.2", - "7.5", - "8.0", - "8.6", - "8.7", - "8.9", - "9.0+PTX" - ] - } -} diff --git a/build/torch212-cxx11-cu126-x86_64-linux/__init__.py b/build/torch212-cxx11-cu126-x86_64-linux/__init__.py deleted file mode 100644 index 33db73ca6e361af4707ba5bb5f55bf0e7c3005a4..0000000000000000000000000000000000000000 --- a/build/torch212-cxx11-cu126-x86_64-linux/__init__.py +++ /dev/null @@ -1,46 +0,0 @@ -from typing import List -import torch - -from ._ops import ops -from . import layers - - -def ms_deform_attn_backward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - grad_output: torch.Tensor, - im2col_step: int, -) -> List[torch.Tensor]: - return ops.ms_deform_attn_backward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - grad_output, - im2col_step, - ) - - -def ms_deform_attn_forward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - im2col_step: int, -) -> torch.Tensor: - return ops.ms_deform_attn_forward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - im2col_step, - ) - - -__all__ = ["layers", "ms_deform_attn_forward", "ms_deform_attn_backward"] diff --git a/build/torch212-cxx11-cu126-x86_64-linux/_deformable_detr_cuda_5129df0.abi3.so b/build/torch212-cxx11-cu126-x86_64-linux/_deformable_detr_cuda_5129df0.abi3.so deleted file mode 100644 index a170405dcbf6df2418007785dda13e8d15a06436..0000000000000000000000000000000000000000 --- a/build/torch212-cxx11-cu126-x86_64-linux/_deformable_detr_cuda_5129df0.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:7c2550b814c770e8a68b9cc9317345c5a9b7e6a2bc00168cc2082427817112ae -size 8536248 diff --git a/build/torch212-cxx11-cu126-x86_64-linux/_ops.py b/build/torch212-cxx11-cu126-x86_64-linux/_ops.py deleted file mode 100644 index 783ce5bea1df5ca480d0b45081055c75218172a9..0000000000000000000000000000000000000000 --- a/build/torch212-cxx11-cu126-x86_64-linux/_ops.py +++ /dev/null @@ -1,9 +0,0 @@ -import torch -from . import _deformable_detr_cuda_5129df0 -ops = torch.ops._deformable_detr_cuda_5129df0 - -def add_op_namespace_prefix(op_name: str): - """ - Prefix op by namespace. - """ - return f"_deformable_detr_cuda_5129df0::{op_name}" diff --git a/build/torch212-cxx11-cu126-x86_64-linux/deformable_detr/__init__.py b/build/torch212-cxx11-cu126-x86_64-linux/deformable_detr/__init__.py deleted file mode 100644 index a9b2672c1cd85b74c1b3ded0fc0b2100e1aeac23..0000000000000000000000000000000000000000 --- a/build/torch212-cxx11-cu126-x86_64-linux/deformable_detr/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -import ctypes -import importlib.util -import sys -from pathlib import Path -from types import ModuleType - - -def _import_from_path(file_path: Path) -> ModuleType: - # We cannot use the module name as-is, after adding it to `sys.modules`, - # it would also be used for other imports. So, we make a module name that - # depends on the path for it to be unique using the hex-encoded hash of - # the path. - path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value) - module_name = path_hash - spec = importlib.util.spec_from_file_location(module_name, file_path) - if spec is None: - raise ImportError(f"Cannot load spec for {module_name} from {file_path}") - module = importlib.util.module_from_spec(spec) - if module is None: - raise ImportError(f"Cannot load module {module_name} from spec") - sys.modules[module_name] = module - spec.loader.exec_module(module) # type: ignore - return module - - -globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py"))) diff --git a/build/torch212-cxx11-cu126-x86_64-linux/layers.py b/build/torch212-cxx11-cu126-x86_64-linux/layers.py deleted file mode 100644 index db94032dea3d445f27017f923ae80468e18d2d77..0000000000000000000000000000000000000000 --- a/build/torch212-cxx11-cu126-x86_64-linux/layers.py +++ /dev/null @@ -1,84 +0,0 @@ -from typing import List, Union, Tuple - -from torch import Tensor -from torch.autograd import Function -from torch.autograd.function import once_differentiable -import torch.nn as nn - -from ._ops import ops - - -class MultiScaleDeformableAttentionFunction(Function): - @staticmethod - def forward( - context, - value: Tensor, - value_spatial_shapes: Tensor, - value_level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - context.im2col_step = im2col_step - output = ops.ms_deform_attn_forward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - context.im2col_step, - ) - context.save_for_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) - return output - - @staticmethod - @once_differentiable - def backward(context, grad_output): - ( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) = context.saved_tensors - grad_value, grad_sampling_loc, grad_attn_weight = ops.ms_deform_attn_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - grad_output, - context.im2col_step, - ) - - return grad_value, None, None, grad_sampling_loc, grad_attn_weight, None - - -class MultiScaleDeformableAttention(nn.Module): - def forward( - self, - value: Tensor, - value_spatial_shapes: Tensor, - value_spatial_shapes_list: List[Tuple], - level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - return MultiScaleDeformableAttentionFunction.apply( - value, - value_spatial_shapes, - level_start_index, - sampling_locations, - attention_weights, - im2col_step, - ) - - -__all__ = ["MultiScaleDeformableAttention"] diff --git a/build/torch212-cxx11-cu126-x86_64-linux/metadata.json b/build/torch212-cxx11-cu126-x86_64-linux/metadata.json deleted file mode 100644 index bb0c165adbb04b11681952cc8aa2a5fae882f72c..0000000000000000000000000000000000000000 --- a/build/torch212-cxx11-cu126-x86_64-linux/metadata.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "deformable-detr", - "id": "_deformable_detr_cuda_5129df0", - "version": 1, - "license": "Apache-2.0", - "python-depends": [], - "backend": { - "type": "cuda", - "archs": [ - "7.0", - "7.2", - "7.5", - "8.0", - "8.6", - "8.7", - "8.9", - "9.0+PTX" - ] - } -} diff --git a/build/torch212-cxx11-cu130-aarch64-linux/__init__.py b/build/torch212-cxx11-cu130-aarch64-linux/__init__.py deleted file mode 100644 index 33db73ca6e361af4707ba5bb5f55bf0e7c3005a4..0000000000000000000000000000000000000000 --- a/build/torch212-cxx11-cu130-aarch64-linux/__init__.py +++ /dev/null @@ -1,46 +0,0 @@ -from typing import List -import torch - -from ._ops import ops -from . import layers - - -def ms_deform_attn_backward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - grad_output: torch.Tensor, - im2col_step: int, -) -> List[torch.Tensor]: - return ops.ms_deform_attn_backward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - grad_output, - im2col_step, - ) - - -def ms_deform_attn_forward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - im2col_step: int, -) -> torch.Tensor: - return ops.ms_deform_attn_forward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - im2col_step, - ) - - -__all__ = ["layers", "ms_deform_attn_forward", "ms_deform_attn_backward"] diff --git a/build/torch212-cxx11-cu130-aarch64-linux/_deformable_detr_cuda_5129df0.abi3.so b/build/torch212-cxx11-cu130-aarch64-linux/_deformable_detr_cuda_5129df0.abi3.so deleted file mode 100644 index 86a1da1ea1e03d249f6e4d904ffcdb681b200e3f..0000000000000000000000000000000000000000 --- a/build/torch212-cxx11-cu130-aarch64-linux/_deformable_detr_cuda_5129df0.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:36e7df1baa3c8f4200a4d7e7ec2b5e0618362d39076848b69f83cbacc512c7f8 -size 9891672 diff --git a/build/torch212-cxx11-cu130-aarch64-linux/_ops.py b/build/torch212-cxx11-cu130-aarch64-linux/_ops.py deleted file mode 100644 index 783ce5bea1df5ca480d0b45081055c75218172a9..0000000000000000000000000000000000000000 --- a/build/torch212-cxx11-cu130-aarch64-linux/_ops.py +++ /dev/null @@ -1,9 +0,0 @@ -import torch -from . import _deformable_detr_cuda_5129df0 -ops = torch.ops._deformable_detr_cuda_5129df0 - -def add_op_namespace_prefix(op_name: str): - """ - Prefix op by namespace. - """ - return f"_deformable_detr_cuda_5129df0::{op_name}" diff --git a/build/torch212-cxx11-cu130-aarch64-linux/deformable_detr/__init__.py b/build/torch212-cxx11-cu130-aarch64-linux/deformable_detr/__init__.py deleted file mode 100644 index a9b2672c1cd85b74c1b3ded0fc0b2100e1aeac23..0000000000000000000000000000000000000000 --- a/build/torch212-cxx11-cu130-aarch64-linux/deformable_detr/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -import ctypes -import importlib.util -import sys -from pathlib import Path -from types import ModuleType - - -def _import_from_path(file_path: Path) -> ModuleType: - # We cannot use the module name as-is, after adding it to `sys.modules`, - # it would also be used for other imports. So, we make a module name that - # depends on the path for it to be unique using the hex-encoded hash of - # the path. - path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value) - module_name = path_hash - spec = importlib.util.spec_from_file_location(module_name, file_path) - if spec is None: - raise ImportError(f"Cannot load spec for {module_name} from {file_path}") - module = importlib.util.module_from_spec(spec) - if module is None: - raise ImportError(f"Cannot load module {module_name} from spec") - sys.modules[module_name] = module - spec.loader.exec_module(module) # type: ignore - return module - - -globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py"))) diff --git a/build/torch212-cxx11-cu130-aarch64-linux/layers.py b/build/torch212-cxx11-cu130-aarch64-linux/layers.py deleted file mode 100644 index db94032dea3d445f27017f923ae80468e18d2d77..0000000000000000000000000000000000000000 --- a/build/torch212-cxx11-cu130-aarch64-linux/layers.py +++ /dev/null @@ -1,84 +0,0 @@ -from typing import List, Union, Tuple - -from torch import Tensor -from torch.autograd import Function -from torch.autograd.function import once_differentiable -import torch.nn as nn - -from ._ops import ops - - -class MultiScaleDeformableAttentionFunction(Function): - @staticmethod - def forward( - context, - value: Tensor, - value_spatial_shapes: Tensor, - value_level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - context.im2col_step = im2col_step - output = ops.ms_deform_attn_forward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - context.im2col_step, - ) - context.save_for_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) - return output - - @staticmethod - @once_differentiable - def backward(context, grad_output): - ( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) = context.saved_tensors - grad_value, grad_sampling_loc, grad_attn_weight = ops.ms_deform_attn_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - grad_output, - context.im2col_step, - ) - - return grad_value, None, None, grad_sampling_loc, grad_attn_weight, None - - -class MultiScaleDeformableAttention(nn.Module): - def forward( - self, - value: Tensor, - value_spatial_shapes: Tensor, - value_spatial_shapes_list: List[Tuple], - level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - return MultiScaleDeformableAttentionFunction.apply( - value, - value_spatial_shapes, - level_start_index, - sampling_locations, - attention_weights, - im2col_step, - ) - - -__all__ = ["MultiScaleDeformableAttention"] diff --git a/build/torch212-cxx11-cu130-aarch64-linux/metadata.json b/build/torch212-cxx11-cu130-aarch64-linux/metadata.json deleted file mode 100644 index 3e52e107268791850ad981c36776d2fa3f01cf61..0000000000000000000000000000000000000000 --- a/build/torch212-cxx11-cu130-aarch64-linux/metadata.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "deformable-detr", - "id": "_deformable_detr_cuda_5129df0", - "version": 1, - "license": "Apache-2.0", - "python-depends": [], - "backend": { - "type": "cuda", - "archs": [ - "10.0", - "11.0", - "12.0+PTX", - "7.5", - "8.0", - "8.6", - "8.7", - "8.9", - "9.0" - ] - } -} diff --git a/build/torch212-cxx11-cu130-x86_64-linux/__init__.py b/build/torch212-cxx11-cu130-x86_64-linux/__init__.py deleted file mode 100644 index 33db73ca6e361af4707ba5bb5f55bf0e7c3005a4..0000000000000000000000000000000000000000 --- a/build/torch212-cxx11-cu130-x86_64-linux/__init__.py +++ /dev/null @@ -1,46 +0,0 @@ -from typing import List -import torch - -from ._ops import ops -from . import layers - - -def ms_deform_attn_backward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - grad_output: torch.Tensor, - im2col_step: int, -) -> List[torch.Tensor]: - return ops.ms_deform_attn_backward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - grad_output, - im2col_step, - ) - - -def ms_deform_attn_forward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - im2col_step: int, -) -> torch.Tensor: - return ops.ms_deform_attn_forward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - im2col_step, - ) - - -__all__ = ["layers", "ms_deform_attn_forward", "ms_deform_attn_backward"] diff --git a/build/torch212-cxx11-cu130-x86_64-linux/_deformable_detr_cuda_5129df0.abi3.so b/build/torch212-cxx11-cu130-x86_64-linux/_deformable_detr_cuda_5129df0.abi3.so deleted file mode 100644 index e75d9f1a1a8b3d3fb94daa81eb630cf22c58be06..0000000000000000000000000000000000000000 --- a/build/torch212-cxx11-cu130-x86_64-linux/_deformable_detr_cuda_5129df0.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:020e455cb9cc00f0d4902be10b5979285fcc6eb6af86e29a28a0ab731460e6e3 -size 9804120 diff --git a/build/torch212-cxx11-cu130-x86_64-linux/_ops.py b/build/torch212-cxx11-cu130-x86_64-linux/_ops.py deleted file mode 100644 index 783ce5bea1df5ca480d0b45081055c75218172a9..0000000000000000000000000000000000000000 --- a/build/torch212-cxx11-cu130-x86_64-linux/_ops.py +++ /dev/null @@ -1,9 +0,0 @@ -import torch -from . import _deformable_detr_cuda_5129df0 -ops = torch.ops._deformable_detr_cuda_5129df0 - -def add_op_namespace_prefix(op_name: str): - """ - Prefix op by namespace. - """ - return f"_deformable_detr_cuda_5129df0::{op_name}" diff --git a/build/torch212-cxx11-cu130-x86_64-linux/deformable_detr/__init__.py b/build/torch212-cxx11-cu130-x86_64-linux/deformable_detr/__init__.py deleted file mode 100644 index a9b2672c1cd85b74c1b3ded0fc0b2100e1aeac23..0000000000000000000000000000000000000000 --- a/build/torch212-cxx11-cu130-x86_64-linux/deformable_detr/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -import ctypes -import importlib.util -import sys -from pathlib import Path -from types import ModuleType - - -def _import_from_path(file_path: Path) -> ModuleType: - # We cannot use the module name as-is, after adding it to `sys.modules`, - # it would also be used for other imports. So, we make a module name that - # depends on the path for it to be unique using the hex-encoded hash of - # the path. - path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value) - module_name = path_hash - spec = importlib.util.spec_from_file_location(module_name, file_path) - if spec is None: - raise ImportError(f"Cannot load spec for {module_name} from {file_path}") - module = importlib.util.module_from_spec(spec) - if module is None: - raise ImportError(f"Cannot load module {module_name} from spec") - sys.modules[module_name] = module - spec.loader.exec_module(module) # type: ignore - return module - - -globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py"))) diff --git a/build/torch212-cxx11-cu130-x86_64-linux/layers.py b/build/torch212-cxx11-cu130-x86_64-linux/layers.py deleted file mode 100644 index db94032dea3d445f27017f923ae80468e18d2d77..0000000000000000000000000000000000000000 --- a/build/torch212-cxx11-cu130-x86_64-linux/layers.py +++ /dev/null @@ -1,84 +0,0 @@ -from typing import List, Union, Tuple - -from torch import Tensor -from torch.autograd import Function -from torch.autograd.function import once_differentiable -import torch.nn as nn - -from ._ops import ops - - -class MultiScaleDeformableAttentionFunction(Function): - @staticmethod - def forward( - context, - value: Tensor, - value_spatial_shapes: Tensor, - value_level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - context.im2col_step = im2col_step - output = ops.ms_deform_attn_forward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - context.im2col_step, - ) - context.save_for_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) - return output - - @staticmethod - @once_differentiable - def backward(context, grad_output): - ( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) = context.saved_tensors - grad_value, grad_sampling_loc, grad_attn_weight = ops.ms_deform_attn_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - grad_output, - context.im2col_step, - ) - - return grad_value, None, None, grad_sampling_loc, grad_attn_weight, None - - -class MultiScaleDeformableAttention(nn.Module): - def forward( - self, - value: Tensor, - value_spatial_shapes: Tensor, - value_spatial_shapes_list: List[Tuple], - level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - return MultiScaleDeformableAttentionFunction.apply( - value, - value_spatial_shapes, - level_start_index, - sampling_locations, - attention_weights, - im2col_step, - ) - - -__all__ = ["MultiScaleDeformableAttention"] diff --git a/build/torch212-cxx11-cu130-x86_64-linux/metadata.json b/build/torch212-cxx11-cu130-x86_64-linux/metadata.json deleted file mode 100644 index 3e52e107268791850ad981c36776d2fa3f01cf61..0000000000000000000000000000000000000000 --- a/build/torch212-cxx11-cu130-x86_64-linux/metadata.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "deformable-detr", - "id": "_deformable_detr_cuda_5129df0", - "version": 1, - "license": "Apache-2.0", - "python-depends": [], - "backend": { - "type": "cuda", - "archs": [ - "10.0", - "11.0", - "12.0+PTX", - "7.5", - "8.0", - "8.6", - "8.7", - "8.9", - "9.0" - ] - } -} diff --git a/build/torch212-cxx11-cu132-aarch64-linux/__init__.py b/build/torch212-cxx11-cu132-aarch64-linux/__init__.py deleted file mode 100644 index 33db73ca6e361af4707ba5bb5f55bf0e7c3005a4..0000000000000000000000000000000000000000 --- a/build/torch212-cxx11-cu132-aarch64-linux/__init__.py +++ /dev/null @@ -1,46 +0,0 @@ -from typing import List -import torch - -from ._ops import ops -from . import layers - - -def ms_deform_attn_backward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - grad_output: torch.Tensor, - im2col_step: int, -) -> List[torch.Tensor]: - return ops.ms_deform_attn_backward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - grad_output, - im2col_step, - ) - - -def ms_deform_attn_forward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - im2col_step: int, -) -> torch.Tensor: - return ops.ms_deform_attn_forward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - im2col_step, - ) - - -__all__ = ["layers", "ms_deform_attn_forward", "ms_deform_attn_backward"] diff --git a/build/torch212-cxx11-cu132-aarch64-linux/_deformable_detr_cuda_5129df0.abi3.so b/build/torch212-cxx11-cu132-aarch64-linux/_deformable_detr_cuda_5129df0.abi3.so deleted file mode 100644 index 3b8a84fb4df5120482fcc52a2b84d5813db3f3e9..0000000000000000000000000000000000000000 --- a/build/torch212-cxx11-cu132-aarch64-linux/_deformable_detr_cuda_5129df0.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:fd70a7cf5b0e56bf4a1fafa30cba36cd8c6e628e27c19d20dd2f9f480f678255 -size 9959808 diff --git a/build/torch212-cxx11-cu132-aarch64-linux/_ops.py b/build/torch212-cxx11-cu132-aarch64-linux/_ops.py deleted file mode 100644 index 783ce5bea1df5ca480d0b45081055c75218172a9..0000000000000000000000000000000000000000 --- a/build/torch212-cxx11-cu132-aarch64-linux/_ops.py +++ /dev/null @@ -1,9 +0,0 @@ -import torch -from . import _deformable_detr_cuda_5129df0 -ops = torch.ops._deformable_detr_cuda_5129df0 - -def add_op_namespace_prefix(op_name: str): - """ - Prefix op by namespace. - """ - return f"_deformable_detr_cuda_5129df0::{op_name}" diff --git a/build/torch212-cxx11-cu132-aarch64-linux/deformable_detr/__init__.py b/build/torch212-cxx11-cu132-aarch64-linux/deformable_detr/__init__.py deleted file mode 100644 index a9b2672c1cd85b74c1b3ded0fc0b2100e1aeac23..0000000000000000000000000000000000000000 --- a/build/torch212-cxx11-cu132-aarch64-linux/deformable_detr/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -import ctypes -import importlib.util -import sys -from pathlib import Path -from types import ModuleType - - -def _import_from_path(file_path: Path) -> ModuleType: - # We cannot use the module name as-is, after adding it to `sys.modules`, - # it would also be used for other imports. So, we make a module name that - # depends on the path for it to be unique using the hex-encoded hash of - # the path. - path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value) - module_name = path_hash - spec = importlib.util.spec_from_file_location(module_name, file_path) - if spec is None: - raise ImportError(f"Cannot load spec for {module_name} from {file_path}") - module = importlib.util.module_from_spec(spec) - if module is None: - raise ImportError(f"Cannot load module {module_name} from spec") - sys.modules[module_name] = module - spec.loader.exec_module(module) # type: ignore - return module - - -globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py"))) diff --git a/build/torch212-cxx11-cu132-aarch64-linux/layers.py b/build/torch212-cxx11-cu132-aarch64-linux/layers.py deleted file mode 100644 index db94032dea3d445f27017f923ae80468e18d2d77..0000000000000000000000000000000000000000 --- a/build/torch212-cxx11-cu132-aarch64-linux/layers.py +++ /dev/null @@ -1,84 +0,0 @@ -from typing import List, Union, Tuple - -from torch import Tensor -from torch.autograd import Function -from torch.autograd.function import once_differentiable -import torch.nn as nn - -from ._ops import ops - - -class MultiScaleDeformableAttentionFunction(Function): - @staticmethod - def forward( - context, - value: Tensor, - value_spatial_shapes: Tensor, - value_level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - context.im2col_step = im2col_step - output = ops.ms_deform_attn_forward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - context.im2col_step, - ) - context.save_for_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) - return output - - @staticmethod - @once_differentiable - def backward(context, grad_output): - ( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) = context.saved_tensors - grad_value, grad_sampling_loc, grad_attn_weight = ops.ms_deform_attn_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - grad_output, - context.im2col_step, - ) - - return grad_value, None, None, grad_sampling_loc, grad_attn_weight, None - - -class MultiScaleDeformableAttention(nn.Module): - def forward( - self, - value: Tensor, - value_spatial_shapes: Tensor, - value_spatial_shapes_list: List[Tuple], - level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - return MultiScaleDeformableAttentionFunction.apply( - value, - value_spatial_shapes, - level_start_index, - sampling_locations, - attention_weights, - im2col_step, - ) - - -__all__ = ["MultiScaleDeformableAttention"] diff --git a/build/torch212-cxx11-cu132-aarch64-linux/metadata.json b/build/torch212-cxx11-cu132-aarch64-linux/metadata.json deleted file mode 100644 index 3e52e107268791850ad981c36776d2fa3f01cf61..0000000000000000000000000000000000000000 --- a/build/torch212-cxx11-cu132-aarch64-linux/metadata.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "deformable-detr", - "id": "_deformable_detr_cuda_5129df0", - "version": 1, - "license": "Apache-2.0", - "python-depends": [], - "backend": { - "type": "cuda", - "archs": [ - "10.0", - "11.0", - "12.0+PTX", - "7.5", - "8.0", - "8.6", - "8.7", - "8.9", - "9.0" - ] - } -} diff --git a/build/torch212-cxx11-cu132-x86_64-linux/__init__.py b/build/torch212-cxx11-cu132-x86_64-linux/__init__.py deleted file mode 100644 index 33db73ca6e361af4707ba5bb5f55bf0e7c3005a4..0000000000000000000000000000000000000000 --- a/build/torch212-cxx11-cu132-x86_64-linux/__init__.py +++ /dev/null @@ -1,46 +0,0 @@ -from typing import List -import torch - -from ._ops import ops -from . import layers - - -def ms_deform_attn_backward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - grad_output: torch.Tensor, - im2col_step: int, -) -> List[torch.Tensor]: - return ops.ms_deform_attn_backward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - grad_output, - im2col_step, - ) - - -def ms_deform_attn_forward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - im2col_step: int, -) -> torch.Tensor: - return ops.ms_deform_attn_forward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - im2col_step, - ) - - -__all__ = ["layers", "ms_deform_attn_forward", "ms_deform_attn_backward"] diff --git a/build/torch212-cxx11-cu132-x86_64-linux/_deformable_detr_cuda_5129df0.abi3.so b/build/torch212-cxx11-cu132-x86_64-linux/_deformable_detr_cuda_5129df0.abi3.so deleted file mode 100644 index 607996d3ddcd78bdb1b4ea9eefc44d4bf36632c4..0000000000000000000000000000000000000000 --- a/build/torch212-cxx11-cu132-x86_64-linux/_deformable_detr_cuda_5129df0.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:6f436baac9298dd7f90f6ac290376d7d6dab52987fb9fccdfa19edd6efad5a91 -size 9900584 diff --git a/build/torch212-cxx11-cu132-x86_64-linux/_ops.py b/build/torch212-cxx11-cu132-x86_64-linux/_ops.py deleted file mode 100644 index 783ce5bea1df5ca480d0b45081055c75218172a9..0000000000000000000000000000000000000000 --- a/build/torch212-cxx11-cu132-x86_64-linux/_ops.py +++ /dev/null @@ -1,9 +0,0 @@ -import torch -from . import _deformable_detr_cuda_5129df0 -ops = torch.ops._deformable_detr_cuda_5129df0 - -def add_op_namespace_prefix(op_name: str): - """ - Prefix op by namespace. - """ - return f"_deformable_detr_cuda_5129df0::{op_name}" diff --git a/build/torch212-cxx11-cu132-x86_64-linux/deformable_detr/__init__.py b/build/torch212-cxx11-cu132-x86_64-linux/deformable_detr/__init__.py deleted file mode 100644 index a9b2672c1cd85b74c1b3ded0fc0b2100e1aeac23..0000000000000000000000000000000000000000 --- a/build/torch212-cxx11-cu132-x86_64-linux/deformable_detr/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -import ctypes -import importlib.util -import sys -from pathlib import Path -from types import ModuleType - - -def _import_from_path(file_path: Path) -> ModuleType: - # We cannot use the module name as-is, after adding it to `sys.modules`, - # it would also be used for other imports. So, we make a module name that - # depends on the path for it to be unique using the hex-encoded hash of - # the path. - path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value) - module_name = path_hash - spec = importlib.util.spec_from_file_location(module_name, file_path) - if spec is None: - raise ImportError(f"Cannot load spec for {module_name} from {file_path}") - module = importlib.util.module_from_spec(spec) - if module is None: - raise ImportError(f"Cannot load module {module_name} from spec") - sys.modules[module_name] = module - spec.loader.exec_module(module) # type: ignore - return module - - -globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py"))) diff --git a/build/torch212-cxx11-cu132-x86_64-linux/layers.py b/build/torch212-cxx11-cu132-x86_64-linux/layers.py deleted file mode 100644 index db94032dea3d445f27017f923ae80468e18d2d77..0000000000000000000000000000000000000000 --- a/build/torch212-cxx11-cu132-x86_64-linux/layers.py +++ /dev/null @@ -1,84 +0,0 @@ -from typing import List, Union, Tuple - -from torch import Tensor -from torch.autograd import Function -from torch.autograd.function import once_differentiable -import torch.nn as nn - -from ._ops import ops - - -class MultiScaleDeformableAttentionFunction(Function): - @staticmethod - def forward( - context, - value: Tensor, - value_spatial_shapes: Tensor, - value_level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - context.im2col_step = im2col_step - output = ops.ms_deform_attn_forward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - context.im2col_step, - ) - context.save_for_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) - return output - - @staticmethod - @once_differentiable - def backward(context, grad_output): - ( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) = context.saved_tensors - grad_value, grad_sampling_loc, grad_attn_weight = ops.ms_deform_attn_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - grad_output, - context.im2col_step, - ) - - return grad_value, None, None, grad_sampling_loc, grad_attn_weight, None - - -class MultiScaleDeformableAttention(nn.Module): - def forward( - self, - value: Tensor, - value_spatial_shapes: Tensor, - value_spatial_shapes_list: List[Tuple], - level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - return MultiScaleDeformableAttentionFunction.apply( - value, - value_spatial_shapes, - level_start_index, - sampling_locations, - attention_weights, - im2col_step, - ) - - -__all__ = ["MultiScaleDeformableAttention"] diff --git a/build/torch212-cxx11-cu132-x86_64-linux/metadata.json b/build/torch212-cxx11-cu132-x86_64-linux/metadata.json deleted file mode 100644 index 3e52e107268791850ad981c36776d2fa3f01cf61..0000000000000000000000000000000000000000 --- a/build/torch212-cxx11-cu132-x86_64-linux/metadata.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "deformable-detr", - "id": "_deformable_detr_cuda_5129df0", - "version": 1, - "license": "Apache-2.0", - "python-depends": [], - "backend": { - "type": "cuda", - "archs": [ - "10.0", - "11.0", - "12.0+PTX", - "7.5", - "8.0", - "8.6", - "8.7", - "8.9", - "9.0" - ] - } -} diff --git a/build/torch25-cxx11-cu118-x86_64-linux/deformable_detr/_deformable_detr_7c33cbe.abi3.so b/build/torch25-cxx11-cu118-x86_64-linux/deformable_detr/_deformable_detr_7c33cbe.abi3.so deleted file mode 100755 index f622604e89058689647ba41b3c71ccbd3aa68ae7..0000000000000000000000000000000000000000 --- a/build/torch25-cxx11-cu118-x86_64-linux/deformable_detr/_deformable_detr_7c33cbe.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:ae00c12295a458e2534149aea16da0289541447123c19fae59baaf6d6d2752f1 -size 6693656 diff --git a/build/torch25-cxx11-cu118-x86_64-linux/deformable_detr/_deformable_detr_cxy6p3o2latjs.abi3.so b/build/torch25-cxx11-cu118-x86_64-linux/deformable_detr/_deformable_detr_cxy6p3o2latjs.abi3.so new file mode 100755 index 0000000000000000000000000000000000000000..4e4da3ee7fdd606fe0498f09c1eb4d758861af5e --- /dev/null +++ b/build/torch25-cxx11-cu118-x86_64-linux/deformable_detr/_deformable_detr_cxy6p3o2latjs.abi3.so @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1cf71a0243675c22ba3207a6f895a907b0699f964575088e054220cea5e2fb2e +size 5870376 diff --git a/build/torch25-cxx11-cu118-x86_64-linux/deformable_detr/_ops.py b/build/torch25-cxx11-cu118-x86_64-linux/deformable_detr/_ops.py index 676ee6fea64b714dedb7ccd1d54148dcf75575a6..ffb73bc1bbd96dfb75a830b83b58676cd1377989 100644 --- a/build/torch25-cxx11-cu118-x86_64-linux/deformable_detr/_ops.py +++ b/build/torch25-cxx11-cu118-x86_64-linux/deformable_detr/_ops.py @@ -1,9 +1,9 @@ import torch -from . import _deformable_detr_7c33cbe -ops = torch.ops._deformable_detr_7c33cbe +from . import _deformable_detr_cxy6p3o2latjs +ops = torch.ops._deformable_detr_cxy6p3o2latjs def add_op_namespace_prefix(op_name: str): """ Prefix op by namespace. """ - return f"_deformable_detr_7c33cbe::{op_name}" \ No newline at end of file + return f"_deformable_detr_cxy6p3o2latjs::{op_name}" \ No newline at end of file diff --git a/build/torch25-cxx11-cu121-x86_64-linux/deformable_detr/_deformable_detr_7c33cbe.abi3.so b/build/torch25-cxx11-cu121-x86_64-linux/deformable_detr/_deformable_detr_7c33cbe.abi3.so deleted file mode 100755 index 25768c52fa2f7041778baad9b1beaaee6772e8d3..0000000000000000000000000000000000000000 --- a/build/torch25-cxx11-cu121-x86_64-linux/deformable_detr/_deformable_detr_7c33cbe.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:4ab8cf59779b768359df0fa268b6cd52be2f518dd4fafdd61baec31c64f44813 -size 6679440 diff --git a/build/torch25-cxx11-cu121-x86_64-linux/deformable_detr/_deformable_detr_esifsbuexbtbw.abi3.so b/build/torch25-cxx11-cu121-x86_64-linux/deformable_detr/_deformable_detr_esifsbuexbtbw.abi3.so new file mode 100755 index 0000000000000000000000000000000000000000..dd7fd6ca351b521f64a078d315551edad1f02f8b --- /dev/null +++ b/build/torch25-cxx11-cu121-x86_64-linux/deformable_detr/_deformable_detr_esifsbuexbtbw.abi3.so @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:79dce2e84e09fb2a5bf1b47441b226343494807687d8829f141682af9b78e361 +size 5856160 diff --git a/build/torch25-cxx11-cu121-x86_64-linux/deformable_detr/_ops.py b/build/torch25-cxx11-cu121-x86_64-linux/deformable_detr/_ops.py index 676ee6fea64b714dedb7ccd1d54148dcf75575a6..7272205607f6b6db5e3f6aa7673bc77798647317 100644 --- a/build/torch25-cxx11-cu121-x86_64-linux/deformable_detr/_ops.py +++ b/build/torch25-cxx11-cu121-x86_64-linux/deformable_detr/_ops.py @@ -1,9 +1,9 @@ import torch -from . import _deformable_detr_7c33cbe -ops = torch.ops._deformable_detr_7c33cbe +from . import _deformable_detr_esifsbuexbtbw +ops = torch.ops._deformable_detr_esifsbuexbtbw def add_op_namespace_prefix(op_name: str): """ Prefix op by namespace. """ - return f"_deformable_detr_7c33cbe::{op_name}" \ No newline at end of file + return f"_deformable_detr_esifsbuexbtbw::{op_name}" \ No newline at end of file diff --git a/build/torch25-cxx11-cu124-x86_64-linux/deformable_detr/_deformable_detr_7c33cbe.abi3.so b/build/torch25-cxx11-cu124-x86_64-linux/deformable_detr/_deformable_detr_7c33cbe.abi3.so deleted file mode 100755 index a574c7a01d734f9f4fb7210058d3064c280c5564..0000000000000000000000000000000000000000 --- a/build/torch25-cxx11-cu124-x86_64-linux/deformable_detr/_deformable_detr_7c33cbe.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:5cdcd6902a03140074cff4cd44bf6b47dc27a32e13e0515a93929c66be186cab -size 6652680 diff --git a/build/torch25-cxx11-cu124-x86_64-linux/deformable_detr/_deformable_detr_cuzn3o54ku5iq.abi3.so b/build/torch25-cxx11-cu124-x86_64-linux/deformable_detr/_deformable_detr_cuzn3o54ku5iq.abi3.so new file mode 100755 index 0000000000000000000000000000000000000000..1792ad2bb4c1dc835a4fdf2e54a4d9b0ad354ec9 --- /dev/null +++ b/build/torch25-cxx11-cu124-x86_64-linux/deformable_detr/_deformable_detr_cuzn3o54ku5iq.abi3.so @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:825c7cb6f9a4350bdcdffa4383d7a527d5fa7b0d9d83222f5d1e72f1c6087841 +size 5841688 diff --git a/build/torch25-cxx11-cu124-x86_64-linux/deformable_detr/_ops.py b/build/torch25-cxx11-cu124-x86_64-linux/deformable_detr/_ops.py index 676ee6fea64b714dedb7ccd1d54148dcf75575a6..3534aa4eb5695150d1dd7d8c0f439fb6452edca9 100644 --- a/build/torch25-cxx11-cu124-x86_64-linux/deformable_detr/_ops.py +++ b/build/torch25-cxx11-cu124-x86_64-linux/deformable_detr/_ops.py @@ -1,9 +1,9 @@ import torch -from . import _deformable_detr_7c33cbe -ops = torch.ops._deformable_detr_7c33cbe +from . import _deformable_detr_cuzn3o54ku5iq +ops = torch.ops._deformable_detr_cuzn3o54ku5iq def add_op_namespace_prefix(op_name: str): """ Prefix op by namespace. """ - return f"_deformable_detr_7c33cbe::{op_name}" \ No newline at end of file + return f"_deformable_detr_cuzn3o54ku5iq::{op_name}" \ No newline at end of file diff --git a/build/torch25-cxx98-cu118-x86_64-linux/deformable_detr/_deformable_detr_7c33cbe.abi3.so b/build/torch25-cxx98-cu118-x86_64-linux/deformable_detr/_deformable_detr_7c33cbe.abi3.so deleted file mode 100755 index 6360ed5a03fd9fbe757e8b7c1816f9935b13764f..0000000000000000000000000000000000000000 --- a/build/torch25-cxx98-cu118-x86_64-linux/deformable_detr/_deformable_detr_7c33cbe.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:82174ec2812ee672a447b94fb5ec907e348eb3d0be338daddf145a1d74969a6f -size 6686592 diff --git a/build/torch25-cxx98-cu118-x86_64-linux/deformable_detr/_deformable_detr_gom2c5vfrl2ic.abi3.so b/build/torch25-cxx98-cu118-x86_64-linux/deformable_detr/_deformable_detr_gom2c5vfrl2ic.abi3.so new file mode 100755 index 0000000000000000000000000000000000000000..95c51f0c1f8a7e90e248bc945259220e468dfd91 --- /dev/null +++ b/build/torch25-cxx98-cu118-x86_64-linux/deformable_detr/_deformable_detr_gom2c5vfrl2ic.abi3.so @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dbe4c67fc885df711581660f72d86dbd0a237c7f106308e55a484725c88e9927 +size 5863312 diff --git a/build/torch25-cxx98-cu118-x86_64-linux/deformable_detr/_ops.py b/build/torch25-cxx98-cu118-x86_64-linux/deformable_detr/_ops.py index 676ee6fea64b714dedb7ccd1d54148dcf75575a6..734f23a0e93ba1c1e7e8bf8501df925bebdee046 100644 --- a/build/torch25-cxx98-cu118-x86_64-linux/deformable_detr/_ops.py +++ b/build/torch25-cxx98-cu118-x86_64-linux/deformable_detr/_ops.py @@ -1,9 +1,9 @@ import torch -from . import _deformable_detr_7c33cbe -ops = torch.ops._deformable_detr_7c33cbe +from . import _deformable_detr_gom2c5vfrl2ic +ops = torch.ops._deformable_detr_gom2c5vfrl2ic def add_op_namespace_prefix(op_name: str): """ Prefix op by namespace. """ - return f"_deformable_detr_7c33cbe::{op_name}" \ No newline at end of file + return f"_deformable_detr_gom2c5vfrl2ic::{op_name}" \ No newline at end of file diff --git a/build/torch25-cxx98-cu121-x86_64-linux/deformable_detr/_deformable_detr_7c33cbe.abi3.so b/build/torch25-cxx98-cu121-x86_64-linux/deformable_detr/_deformable_detr_7c33cbe.abi3.so deleted file mode 100755 index d23c2f012773987542cbcab34a84e3eb240bdff9..0000000000000000000000000000000000000000 --- a/build/torch25-cxx98-cu121-x86_64-linux/deformable_detr/_deformable_detr_7c33cbe.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c9d8540a4ffa00d331f60204fe6baf543a45667d6bba2c0a0b23aca9202b6233 -size 6672464 diff --git a/build/torch25-cxx98-cu121-x86_64-linux/deformable_detr/_deformable_detr_a7sajsuqrick6.abi3.so b/build/torch25-cxx98-cu121-x86_64-linux/deformable_detr/_deformable_detr_a7sajsuqrick6.abi3.so new file mode 100755 index 0000000000000000000000000000000000000000..0bd1ef4078bb421da435e98a7bb2f9311eda0739 --- /dev/null +++ b/build/torch25-cxx98-cu121-x86_64-linux/deformable_detr/_deformable_detr_a7sajsuqrick6.abi3.so @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:56b4c64eb7931a6f580bd5b806eae1aea43b3bb8c0f115d5d202f151974a5e7b +size 5853280 diff --git a/build/torch25-cxx98-cu121-x86_64-linux/deformable_detr/_ops.py b/build/torch25-cxx98-cu121-x86_64-linux/deformable_detr/_ops.py index 676ee6fea64b714dedb7ccd1d54148dcf75575a6..4531116c7e3fbc3258dcd23ebdbe22768a8d566a 100644 --- a/build/torch25-cxx98-cu121-x86_64-linux/deformable_detr/_ops.py +++ b/build/torch25-cxx98-cu121-x86_64-linux/deformable_detr/_ops.py @@ -1,9 +1,9 @@ import torch -from . import _deformable_detr_7c33cbe -ops = torch.ops._deformable_detr_7c33cbe +from . import _deformable_detr_a7sajsuqrick6 +ops = torch.ops._deformable_detr_a7sajsuqrick6 def add_op_namespace_prefix(op_name: str): """ Prefix op by namespace. """ - return f"_deformable_detr_7c33cbe::{op_name}" \ No newline at end of file + return f"_deformable_detr_a7sajsuqrick6::{op_name}" \ No newline at end of file diff --git a/build/torch25-cxx98-cu124-x86_64-linux/deformable_detr/_deformable_detr_7c33cbe.abi3.so b/build/torch25-cxx98-cu124-x86_64-linux/deformable_detr/_deformable_detr_7c33cbe.abi3.so deleted file mode 100755 index aaa5548734ba34766edf646277e25b48752d6b7f..0000000000000000000000000000000000000000 --- a/build/torch25-cxx98-cu124-x86_64-linux/deformable_detr/_deformable_detr_7c33cbe.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:fa748a4de72c06de09f46b4af4fec7f23cb2c76eb8683c117fefd20833cd3fd8 -size 6649800 diff --git a/build/torch25-cxx98-cu124-x86_64-linux/deformable_detr/_deformable_detr_tyogxwmtolvok.abi3.so b/build/torch25-cxx98-cu124-x86_64-linux/deformable_detr/_deformable_detr_tyogxwmtolvok.abi3.so new file mode 100755 index 0000000000000000000000000000000000000000..b53558717a3608677dd75c82cdc027ab1374179d --- /dev/null +++ b/build/torch25-cxx98-cu124-x86_64-linux/deformable_detr/_deformable_detr_tyogxwmtolvok.abi3.so @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7eef07a96ddf574e5b1e07476089a62659a70faa33c82fc79987c54fecb2711f +size 5834712 diff --git a/build/torch25-cxx98-cu124-x86_64-linux/deformable_detr/_ops.py b/build/torch25-cxx98-cu124-x86_64-linux/deformable_detr/_ops.py index 676ee6fea64b714dedb7ccd1d54148dcf75575a6..b3c0318eaacce12db912a3c5e91ad578adbe74ca 100644 --- a/build/torch25-cxx98-cu124-x86_64-linux/deformable_detr/_ops.py +++ b/build/torch25-cxx98-cu124-x86_64-linux/deformable_detr/_ops.py @@ -1,9 +1,9 @@ import torch -from . import _deformable_detr_7c33cbe -ops = torch.ops._deformable_detr_7c33cbe +from . import _deformable_detr_tyogxwmtolvok +ops = torch.ops._deformable_detr_tyogxwmtolvok def add_op_namespace_prefix(op_name: str): """ Prefix op by namespace. """ - return f"_deformable_detr_7c33cbe::{op_name}" \ No newline at end of file + return f"_deformable_detr_tyogxwmtolvok::{op_name}" \ No newline at end of file diff --git a/build/torch26-cxx11-cu118-x86_64-linux/deformable_detr/_deformable_detr_5kxpyt5yogkv2.abi3.so b/build/torch26-cxx11-cu118-x86_64-linux/deformable_detr/_deformable_detr_5kxpyt5yogkv2.abi3.so new file mode 100755 index 0000000000000000000000000000000000000000..11b825669658ee3d1a209111ce5c954f47627b64 --- /dev/null +++ b/build/torch26-cxx11-cu118-x86_64-linux/deformable_detr/_deformable_detr_5kxpyt5yogkv2.abi3.so @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d1c5bb5376002363e2008eb6db64ebe0c9f6c31f9a635b7420ddfb46dce16b02 +size 5870352 diff --git a/build/torch26-cxx11-cu118-x86_64-linux/deformable_detr/_deformable_detr_7c33cbe.abi3.so b/build/torch26-cxx11-cu118-x86_64-linux/deformable_detr/_deformable_detr_7c33cbe.abi3.so deleted file mode 100755 index 64ea4bcc2dfb73951fa3315247c594ea5b6aee1c..0000000000000000000000000000000000000000 --- a/build/torch26-cxx11-cu118-x86_64-linux/deformable_detr/_deformable_detr_7c33cbe.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:57e38bac3087c1446307e504b1e22e61ae584d1de7f5b3d15bd7a60780c3431c -size 6693632 diff --git a/build/torch26-cxx11-cu118-x86_64-linux/deformable_detr/_ops.py b/build/torch26-cxx11-cu118-x86_64-linux/deformable_detr/_ops.py index 676ee6fea64b714dedb7ccd1d54148dcf75575a6..68d3b35da5c2af46145714ea08cdb287d2a50d5d 100644 --- a/build/torch26-cxx11-cu118-x86_64-linux/deformable_detr/_ops.py +++ b/build/torch26-cxx11-cu118-x86_64-linux/deformable_detr/_ops.py @@ -1,9 +1,9 @@ import torch -from . import _deformable_detr_7c33cbe -ops = torch.ops._deformable_detr_7c33cbe +from . import _deformable_detr_5kxpyt5yogkv2 +ops = torch.ops._deformable_detr_5kxpyt5yogkv2 def add_op_namespace_prefix(op_name: str): """ Prefix op by namespace. """ - return f"_deformable_detr_7c33cbe::{op_name}" \ No newline at end of file + return f"_deformable_detr_5kxpyt5yogkv2::{op_name}" \ No newline at end of file diff --git a/build/torch26-cxx11-cu124-x86_64-linux/deformable_detr/_deformable_detr_7c33cbe.abi3.so b/build/torch26-cxx11-cu124-x86_64-linux/deformable_detr/_deformable_detr_7c33cbe.abi3.so deleted file mode 100755 index 658ac25c98e67be8affb211b20fc2af46efcbca2..0000000000000000000000000000000000000000 --- a/build/torch26-cxx11-cu124-x86_64-linux/deformable_detr/_deformable_detr_7c33cbe.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:1d7c09d3bedd89d7119e7023a07784724d3a3f79664b75fce37b778ef3bcfe52 -size 6648656 diff --git a/build/torch26-cxx11-cu124-x86_64-linux/deformable_detr/_deformable_detr_titoehueyfqjg.abi3.so b/build/torch26-cxx11-cu124-x86_64-linux/deformable_detr/_deformable_detr_titoehueyfqjg.abi3.so new file mode 100755 index 0000000000000000000000000000000000000000..b64a727062504abecbb7bd162d6f8c6848de3b53 --- /dev/null +++ b/build/torch26-cxx11-cu124-x86_64-linux/deformable_detr/_deformable_detr_titoehueyfqjg.abi3.so @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:76b74d4bdbb1f562474b987fd23430d12b9f033183198f35a7dfd21fcc8ce4e1 +size 5837664 diff --git a/build/torch26-cxx11-cu124-x86_64-linux/deformable_detr/_ops.py b/build/torch26-cxx11-cu124-x86_64-linux/deformable_detr/_ops.py index 676ee6fea64b714dedb7ccd1d54148dcf75575a6..0df7bff1cf00c94ce4da6eee12f6e49f513bc3b8 100644 --- a/build/torch26-cxx11-cu124-x86_64-linux/deformable_detr/_ops.py +++ b/build/torch26-cxx11-cu124-x86_64-linux/deformable_detr/_ops.py @@ -1,9 +1,9 @@ import torch -from . import _deformable_detr_7c33cbe -ops = torch.ops._deformable_detr_7c33cbe +from . import _deformable_detr_titoehueyfqjg +ops = torch.ops._deformable_detr_titoehueyfqjg def add_op_namespace_prefix(op_name: str): """ Prefix op by namespace. """ - return f"_deformable_detr_7c33cbe::{op_name}" \ No newline at end of file + return f"_deformable_detr_titoehueyfqjg::{op_name}" \ No newline at end of file diff --git a/build/torch26-cxx11-cu126-aarch64-linux/deformable_detr/__init__.py b/build/torch26-cxx11-cu126-aarch64-linux/deformable_detr/__init__.py deleted file mode 100644 index 33db73ca6e361af4707ba5bb5f55bf0e7c3005a4..0000000000000000000000000000000000000000 --- a/build/torch26-cxx11-cu126-aarch64-linux/deformable_detr/__init__.py +++ /dev/null @@ -1,46 +0,0 @@ -from typing import List -import torch - -from ._ops import ops -from . import layers - - -def ms_deform_attn_backward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - grad_output: torch.Tensor, - im2col_step: int, -) -> List[torch.Tensor]: - return ops.ms_deform_attn_backward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - grad_output, - im2col_step, - ) - - -def ms_deform_attn_forward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - im2col_step: int, -) -> torch.Tensor: - return ops.ms_deform_attn_forward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - im2col_step, - ) - - -__all__ = ["layers", "ms_deform_attn_forward", "ms_deform_attn_backward"] diff --git a/build/torch26-cxx11-cu126-aarch64-linux/deformable_detr/_deformable_detr_7c33cbe.abi3.so b/build/torch26-cxx11-cu126-aarch64-linux/deformable_detr/_deformable_detr_7c33cbe.abi3.so deleted file mode 100755 index d1b1fe211439d00ca4681305f56e91b4027fe45e..0000000000000000000000000000000000000000 --- a/build/torch26-cxx11-cu126-aarch64-linux/deformable_detr/_deformable_detr_7c33cbe.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:6856b6efe5130f019f6cb7f964d7a2073f1ecc5cd7afc850334e64798f871dae -size 6833224 diff --git a/build/torch26-cxx11-cu126-aarch64-linux/deformable_detr/_ops.py b/build/torch26-cxx11-cu126-aarch64-linux/deformable_detr/_ops.py deleted file mode 100644 index 676ee6fea64b714dedb7ccd1d54148dcf75575a6..0000000000000000000000000000000000000000 --- a/build/torch26-cxx11-cu126-aarch64-linux/deformable_detr/_ops.py +++ /dev/null @@ -1,9 +0,0 @@ -import torch -from . import _deformable_detr_7c33cbe -ops = torch.ops._deformable_detr_7c33cbe - -def add_op_namespace_prefix(op_name: str): - """ - Prefix op by namespace. - """ - return f"_deformable_detr_7c33cbe::{op_name}" \ No newline at end of file diff --git a/build/torch26-cxx11-cu126-aarch64-linux/deformable_detr/layers.py b/build/torch26-cxx11-cu126-aarch64-linux/deformable_detr/layers.py deleted file mode 100644 index db94032dea3d445f27017f923ae80468e18d2d77..0000000000000000000000000000000000000000 --- a/build/torch26-cxx11-cu126-aarch64-linux/deformable_detr/layers.py +++ /dev/null @@ -1,84 +0,0 @@ -from typing import List, Union, Tuple - -from torch import Tensor -from torch.autograd import Function -from torch.autograd.function import once_differentiable -import torch.nn as nn - -from ._ops import ops - - -class MultiScaleDeformableAttentionFunction(Function): - @staticmethod - def forward( - context, - value: Tensor, - value_spatial_shapes: Tensor, - value_level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - context.im2col_step = im2col_step - output = ops.ms_deform_attn_forward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - context.im2col_step, - ) - context.save_for_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) - return output - - @staticmethod - @once_differentiable - def backward(context, grad_output): - ( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) = context.saved_tensors - grad_value, grad_sampling_loc, grad_attn_weight = ops.ms_deform_attn_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - grad_output, - context.im2col_step, - ) - - return grad_value, None, None, grad_sampling_loc, grad_attn_weight, None - - -class MultiScaleDeformableAttention(nn.Module): - def forward( - self, - value: Tensor, - value_spatial_shapes: Tensor, - value_spatial_shapes_list: List[Tuple], - level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - return MultiScaleDeformableAttentionFunction.apply( - value, - value_spatial_shapes, - level_start_index, - sampling_locations, - attention_weights, - im2col_step, - ) - - -__all__ = ["MultiScaleDeformableAttention"] diff --git a/build/torch26-cxx11-cu126-x86_64-linux/deformable_detr/_deformable_detr_7c33cbe.abi3.so b/build/torch26-cxx11-cu126-x86_64-linux/deformable_detr/_deformable_detr_7c33cbe.abi3.so deleted file mode 100755 index 10bcc5c4bad459abe354c507166121a5a47d5d74..0000000000000000000000000000000000000000 --- a/build/torch26-cxx11-cu126-x86_64-linux/deformable_detr/_deformable_detr_7c33cbe.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c76ad874b78882d3108a7fdaf49f8c00b6a6a7dceec63912118f8fa7d07e5f30 -size 6800656 diff --git a/build/torch26-cxx11-cu126-x86_64-linux/deformable_detr/_deformable_detr_imqt5tuqtmyt4.abi3.so b/build/torch26-cxx11-cu126-x86_64-linux/deformable_detr/_deformable_detr_imqt5tuqtmyt4.abi3.so new file mode 100755 index 0000000000000000000000000000000000000000..61011f23d656b543339a1eb2e1481684e3d66e10 --- /dev/null +++ b/build/torch26-cxx11-cu126-x86_64-linux/deformable_detr/_deformable_detr_imqt5tuqtmyt4.abi3.so @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1acd032c2f3bc530872e0839d8bec8950b01668c913539a2e14008a1e652560f +size 5944608 diff --git a/build/torch26-cxx11-cu126-x86_64-linux/deformable_detr/_ops.py b/build/torch26-cxx11-cu126-x86_64-linux/deformable_detr/_ops.py index 676ee6fea64b714dedb7ccd1d54148dcf75575a6..4ea7469cf391720f056311bda128fbec93749437 100644 --- a/build/torch26-cxx11-cu126-x86_64-linux/deformable_detr/_ops.py +++ b/build/torch26-cxx11-cu126-x86_64-linux/deformable_detr/_ops.py @@ -1,9 +1,9 @@ import torch -from . import _deformable_detr_7c33cbe -ops = torch.ops._deformable_detr_7c33cbe +from . import _deformable_detr_imqt5tuqtmyt4 +ops = torch.ops._deformable_detr_imqt5tuqtmyt4 def add_op_namespace_prefix(op_name: str): """ Prefix op by namespace. """ - return f"_deformable_detr_7c33cbe::{op_name}" \ No newline at end of file + return f"_deformable_detr_imqt5tuqtmyt4::{op_name}" \ No newline at end of file diff --git a/build/torch26-cxx98-cu118-x86_64-linux/deformable_detr/_deformable_detr_7c33cbe.abi3.so b/build/torch26-cxx98-cu118-x86_64-linux/deformable_detr/_deformable_detr_7c33cbe.abi3.so deleted file mode 100755 index a15ec9d8735e3de07ebd3bfaae1b2ded8de87447..0000000000000000000000000000000000000000 --- a/build/torch26-cxx98-cu118-x86_64-linux/deformable_detr/_deformable_detr_7c33cbe.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:d1fb3a24fd95c1cc3cba080ae1c9d4217f377435770c7e423de53b11ecc437dc -size 6686600 diff --git a/build/torch26-cxx98-cu118-x86_64-linux/deformable_detr/_deformable_detr_qbnaho3zp2d3o.abi3.so b/build/torch26-cxx98-cu118-x86_64-linux/deformable_detr/_deformable_detr_qbnaho3zp2d3o.abi3.so new file mode 100755 index 0000000000000000000000000000000000000000..353504e4fa52b281748f32dfcee02781e450794a --- /dev/null +++ b/build/torch26-cxx98-cu118-x86_64-linux/deformable_detr/_deformable_detr_qbnaho3zp2d3o.abi3.so @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b9e5074a5afdb137688e20182cf4c9f7cbb1e8a69651c08a570076aeedc8c76b +size 5863320 diff --git a/build/torch26-cxx98-cu118-x86_64-linux/deformable_detr/_ops.py b/build/torch26-cxx98-cu118-x86_64-linux/deformable_detr/_ops.py index 676ee6fea64b714dedb7ccd1d54148dcf75575a6..ed42e13a067a186a1f701cec376afa3194956f6b 100644 --- a/build/torch26-cxx98-cu118-x86_64-linux/deformable_detr/_ops.py +++ b/build/torch26-cxx98-cu118-x86_64-linux/deformable_detr/_ops.py @@ -1,9 +1,9 @@ import torch -from . import _deformable_detr_7c33cbe -ops = torch.ops._deformable_detr_7c33cbe +from . import _deformable_detr_qbnaho3zp2d3o +ops = torch.ops._deformable_detr_qbnaho3zp2d3o def add_op_namespace_prefix(op_name: str): """ Prefix op by namespace. """ - return f"_deformable_detr_7c33cbe::{op_name}" \ No newline at end of file + return f"_deformable_detr_qbnaho3zp2d3o::{op_name}" \ No newline at end of file diff --git a/build/torch26-cxx98-cu124-x86_64-linux/deformable_detr/_deformable_detr_5oxft6tr6jbvu.abi3.so b/build/torch26-cxx98-cu124-x86_64-linux/deformable_detr/_deformable_detr_5oxft6tr6jbvu.abi3.so new file mode 100755 index 0000000000000000000000000000000000000000..e799c57967e1132680a7e360d5cb6b197932b787 --- /dev/null +++ b/build/torch26-cxx98-cu124-x86_64-linux/deformable_detr/_deformable_detr_5oxft6tr6jbvu.abi3.so @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bd4d0f47c165b9ce95c0328cb7a52e331e4c698746ea8e4d43c7d09c193e34bd +size 5834720 diff --git a/build/torch26-cxx98-cu124-x86_64-linux/deformable_detr/_deformable_detr_7c33cbe.abi3.so b/build/torch26-cxx98-cu124-x86_64-linux/deformable_detr/_deformable_detr_7c33cbe.abi3.so deleted file mode 100755 index 63c34c123c4b78349bc1a2bb92b0614c4b689a13..0000000000000000000000000000000000000000 --- a/build/torch26-cxx98-cu124-x86_64-linux/deformable_detr/_deformable_detr_7c33cbe.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:d5a455975be5790964cc95c6813d293b1aba581f5c2dc132c9a08690bf6e5cad -size 6649808 diff --git a/build/torch26-cxx98-cu124-x86_64-linux/deformable_detr/_ops.py b/build/torch26-cxx98-cu124-x86_64-linux/deformable_detr/_ops.py index 676ee6fea64b714dedb7ccd1d54148dcf75575a6..bb7524858e03d0f913bd747f4c79db60d2737aa2 100644 --- a/build/torch26-cxx98-cu124-x86_64-linux/deformable_detr/_ops.py +++ b/build/torch26-cxx98-cu124-x86_64-linux/deformable_detr/_ops.py @@ -1,9 +1,9 @@ import torch -from . import _deformable_detr_7c33cbe -ops = torch.ops._deformable_detr_7c33cbe +from . import _deformable_detr_5oxft6tr6jbvu +ops = torch.ops._deformable_detr_5oxft6tr6jbvu def add_op_namespace_prefix(op_name: str): """ Prefix op by namespace. """ - return f"_deformable_detr_7c33cbe::{op_name}" \ No newline at end of file + return f"_deformable_detr_5oxft6tr6jbvu::{op_name}" \ No newline at end of file diff --git a/build/torch26-cxx98-cu126-aarch64-linux/deformable_detr/__init__.py b/build/torch26-cxx98-cu126-aarch64-linux/deformable_detr/__init__.py deleted file mode 100644 index 33db73ca6e361af4707ba5bb5f55bf0e7c3005a4..0000000000000000000000000000000000000000 --- a/build/torch26-cxx98-cu126-aarch64-linux/deformable_detr/__init__.py +++ /dev/null @@ -1,46 +0,0 @@ -from typing import List -import torch - -from ._ops import ops -from . import layers - - -def ms_deform_attn_backward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - grad_output: torch.Tensor, - im2col_step: int, -) -> List[torch.Tensor]: - return ops.ms_deform_attn_backward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - grad_output, - im2col_step, - ) - - -def ms_deform_attn_forward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - im2col_step: int, -) -> torch.Tensor: - return ops.ms_deform_attn_forward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - im2col_step, - ) - - -__all__ = ["layers", "ms_deform_attn_forward", "ms_deform_attn_backward"] diff --git a/build/torch26-cxx98-cu126-aarch64-linux/deformable_detr/_deformable_detr_7c33cbe.abi3.so b/build/torch26-cxx98-cu126-aarch64-linux/deformable_detr/_deformable_detr_7c33cbe.abi3.so deleted file mode 100755 index 6740aef68abf0d71d0756d6b2f78fc2da67c6752..0000000000000000000000000000000000000000 --- a/build/torch26-cxx98-cu126-aarch64-linux/deformable_detr/_deformable_detr_7c33cbe.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:2c13dce2b080676eb192d87ba83df6ef1f6d0f1101727f4b29185d48dec7281d -size 6829872 diff --git a/build/torch26-cxx98-cu126-aarch64-linux/deformable_detr/_ops.py b/build/torch26-cxx98-cu126-aarch64-linux/deformable_detr/_ops.py deleted file mode 100644 index 676ee6fea64b714dedb7ccd1d54148dcf75575a6..0000000000000000000000000000000000000000 --- a/build/torch26-cxx98-cu126-aarch64-linux/deformable_detr/_ops.py +++ /dev/null @@ -1,9 +0,0 @@ -import torch -from . import _deformable_detr_7c33cbe -ops = torch.ops._deformable_detr_7c33cbe - -def add_op_namespace_prefix(op_name: str): - """ - Prefix op by namespace. - """ - return f"_deformable_detr_7c33cbe::{op_name}" \ No newline at end of file diff --git a/build/torch26-cxx98-cu126-aarch64-linux/deformable_detr/layers.py b/build/torch26-cxx98-cu126-aarch64-linux/deformable_detr/layers.py deleted file mode 100644 index db94032dea3d445f27017f923ae80468e18d2d77..0000000000000000000000000000000000000000 --- a/build/torch26-cxx98-cu126-aarch64-linux/deformable_detr/layers.py +++ /dev/null @@ -1,84 +0,0 @@ -from typing import List, Union, Tuple - -from torch import Tensor -from torch.autograd import Function -from torch.autograd.function import once_differentiable -import torch.nn as nn - -from ._ops import ops - - -class MultiScaleDeformableAttentionFunction(Function): - @staticmethod - def forward( - context, - value: Tensor, - value_spatial_shapes: Tensor, - value_level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - context.im2col_step = im2col_step - output = ops.ms_deform_attn_forward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - context.im2col_step, - ) - context.save_for_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) - return output - - @staticmethod - @once_differentiable - def backward(context, grad_output): - ( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) = context.saved_tensors - grad_value, grad_sampling_loc, grad_attn_weight = ops.ms_deform_attn_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - grad_output, - context.im2col_step, - ) - - return grad_value, None, None, grad_sampling_loc, grad_attn_weight, None - - -class MultiScaleDeformableAttention(nn.Module): - def forward( - self, - value: Tensor, - value_spatial_shapes: Tensor, - value_spatial_shapes_list: List[Tuple], - level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - return MultiScaleDeformableAttentionFunction.apply( - value, - value_spatial_shapes, - level_start_index, - sampling_locations, - attention_weights, - im2col_step, - ) - - -__all__ = ["MultiScaleDeformableAttention"] diff --git a/build/torch26-cxx98-cu126-x86_64-linux/deformable_detr/_deformable_detr_7c33cbe.abi3.so b/build/torch26-cxx98-cu126-x86_64-linux/deformable_detr/_deformable_detr_7c33cbe.abi3.so deleted file mode 100755 index f3ce58cab856be1f382aa9f3cf1bb0b1ec06d41d..0000000000000000000000000000000000000000 --- a/build/torch26-cxx98-cu126-x86_64-linux/deformable_detr/_deformable_detr_7c33cbe.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c6ad344319579f0abef7fe1a9d3f479f1c8737994f563a540815a1445020959e -size 6797712 diff --git a/build/torch26-cxx98-cu126-x86_64-linux/deformable_detr/_deformable_detr_po264mz2i2ffg.abi3.so b/build/torch26-cxx98-cu126-x86_64-linux/deformable_detr/_deformable_detr_po264mz2i2ffg.abi3.so new file mode 100755 index 0000000000000000000000000000000000000000..952c1115177dbfead31b4cfe79df0fe6175b0fe1 --- /dev/null +++ b/build/torch26-cxx98-cu126-x86_64-linux/deformable_detr/_deformable_detr_po264mz2i2ffg.abi3.so @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:129844ba533ee201cd3f2bb0e17a354ee8aa35176c10896454926485acdacdac +size 5945760 diff --git a/build/torch26-cxx98-cu126-x86_64-linux/deformable_detr/_ops.py b/build/torch26-cxx98-cu126-x86_64-linux/deformable_detr/_ops.py index 676ee6fea64b714dedb7ccd1d54148dcf75575a6..c411feebca4fae25684ed9b07abfdc21f1c55488 100644 --- a/build/torch26-cxx98-cu126-x86_64-linux/deformable_detr/_ops.py +++ b/build/torch26-cxx98-cu126-x86_64-linux/deformable_detr/_ops.py @@ -1,9 +1,9 @@ import torch -from . import _deformable_detr_7c33cbe -ops = torch.ops._deformable_detr_7c33cbe +from . import _deformable_detr_po264mz2i2ffg +ops = torch.ops._deformable_detr_po264mz2i2ffg def add_op_namespace_prefix(op_name: str): """ Prefix op by namespace. """ - return f"_deformable_detr_7c33cbe::{op_name}" \ No newline at end of file + return f"_deformable_detr_po264mz2i2ffg::{op_name}" \ No newline at end of file diff --git a/build/torch27-cxx11-cu118-x86_64-linux/deformable_detr/__init__.py b/build/torch27-cxx11-cu118-x86_64-linux/deformable_detr/__init__.py deleted file mode 100644 index 33db73ca6e361af4707ba5bb5f55bf0e7c3005a4..0000000000000000000000000000000000000000 --- a/build/torch27-cxx11-cu118-x86_64-linux/deformable_detr/__init__.py +++ /dev/null @@ -1,46 +0,0 @@ -from typing import List -import torch - -from ._ops import ops -from . import layers - - -def ms_deform_attn_backward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - grad_output: torch.Tensor, - im2col_step: int, -) -> List[torch.Tensor]: - return ops.ms_deform_attn_backward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - grad_output, - im2col_step, - ) - - -def ms_deform_attn_forward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - im2col_step: int, -) -> torch.Tensor: - return ops.ms_deform_attn_forward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - im2col_step, - ) - - -__all__ = ["layers", "ms_deform_attn_forward", "ms_deform_attn_backward"] diff --git a/build/torch27-cxx11-cu118-x86_64-linux/deformable_detr/__pycache__/__init__.cpython-313.pyc b/build/torch27-cxx11-cu118-x86_64-linux/deformable_detr/__pycache__/__init__.cpython-313.pyc deleted file mode 100644 index a18bf078a3920470e28c50b9bc3b7efffad37d72..0000000000000000000000000000000000000000 Binary files a/build/torch27-cxx11-cu118-x86_64-linux/deformable_detr/__pycache__/__init__.cpython-313.pyc and /dev/null differ diff --git a/build/torch27-cxx11-cu118-x86_64-linux/deformable_detr/__pycache__/_ops.cpython-313.pyc b/build/torch27-cxx11-cu118-x86_64-linux/deformable_detr/__pycache__/_ops.cpython-313.pyc deleted file mode 100644 index 8a6f280954dd80fbb6d49390c446f50f2924d3fd..0000000000000000000000000000000000000000 Binary files a/build/torch27-cxx11-cu118-x86_64-linux/deformable_detr/__pycache__/_ops.cpython-313.pyc and /dev/null differ diff --git a/build/torch27-cxx11-cu118-x86_64-linux/deformable_detr/__pycache__/layers.cpython-313.pyc b/build/torch27-cxx11-cu118-x86_64-linux/deformable_detr/__pycache__/layers.cpython-313.pyc deleted file mode 100644 index 097f24d7bc07674acd326d3a99991123d90a5838..0000000000000000000000000000000000000000 Binary files a/build/torch27-cxx11-cu118-x86_64-linux/deformable_detr/__pycache__/layers.cpython-313.pyc and /dev/null differ diff --git a/build/torch27-cxx11-cu118-x86_64-linux/deformable_detr/_deformable_detr_57c3d32.abi3.so b/build/torch27-cxx11-cu118-x86_64-linux/deformable_detr/_deformable_detr_57c3d32.abi3.so deleted file mode 100644 index f7dc97abb0f55df13905e5275d76fa859beb7a30..0000000000000000000000000000000000000000 --- a/build/torch27-cxx11-cu118-x86_64-linux/deformable_detr/_deformable_detr_57c3d32.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:9293f97cc6b06bc3ba5e57cfd084abb252c287f4518935208e67e126e7cbd19b -size 6800224 diff --git a/build/torch27-cxx11-cu118-x86_64-linux/deformable_detr/_ops.py b/build/torch27-cxx11-cu118-x86_64-linux/deformable_detr/_ops.py deleted file mode 100644 index 39c2aa7875432779e86612a0e56271fe32133953..0000000000000000000000000000000000000000 --- a/build/torch27-cxx11-cu118-x86_64-linux/deformable_detr/_ops.py +++ /dev/null @@ -1,9 +0,0 @@ -import torch -from . import _deformable_detr_57c3d32 -ops = torch.ops._deformable_detr_57c3d32 - -def add_op_namespace_prefix(op_name: str): - """ - Prefix op by namespace. - """ - return f"_deformable_detr_57c3d32::{op_name}" \ No newline at end of file diff --git a/build/torch27-cxx11-cu118-x86_64-linux/deformable_detr/layers.py b/build/torch27-cxx11-cu118-x86_64-linux/deformable_detr/layers.py deleted file mode 100644 index db94032dea3d445f27017f923ae80468e18d2d77..0000000000000000000000000000000000000000 --- a/build/torch27-cxx11-cu118-x86_64-linux/deformable_detr/layers.py +++ /dev/null @@ -1,84 +0,0 @@ -from typing import List, Union, Tuple - -from torch import Tensor -from torch.autograd import Function -from torch.autograd.function import once_differentiable -import torch.nn as nn - -from ._ops import ops - - -class MultiScaleDeformableAttentionFunction(Function): - @staticmethod - def forward( - context, - value: Tensor, - value_spatial_shapes: Tensor, - value_level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - context.im2col_step = im2col_step - output = ops.ms_deform_attn_forward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - context.im2col_step, - ) - context.save_for_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) - return output - - @staticmethod - @once_differentiable - def backward(context, grad_output): - ( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) = context.saved_tensors - grad_value, grad_sampling_loc, grad_attn_weight = ops.ms_deform_attn_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - grad_output, - context.im2col_step, - ) - - return grad_value, None, None, grad_sampling_loc, grad_attn_weight, None - - -class MultiScaleDeformableAttention(nn.Module): - def forward( - self, - value: Tensor, - value_spatial_shapes: Tensor, - value_spatial_shapes_list: List[Tuple], - level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - return MultiScaleDeformableAttentionFunction.apply( - value, - value_spatial_shapes, - level_start_index, - sampling_locations, - attention_weights, - im2col_step, - ) - - -__all__ = ["MultiScaleDeformableAttention"] diff --git a/build/torch27-cxx11-cu126-aarch64-linux/deformable_detr/__init__.py b/build/torch27-cxx11-cu126-aarch64-linux/deformable_detr/__init__.py deleted file mode 100644 index 33db73ca6e361af4707ba5bb5f55bf0e7c3005a4..0000000000000000000000000000000000000000 --- a/build/torch27-cxx11-cu126-aarch64-linux/deformable_detr/__init__.py +++ /dev/null @@ -1,46 +0,0 @@ -from typing import List -import torch - -from ._ops import ops -from . import layers - - -def ms_deform_attn_backward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - grad_output: torch.Tensor, - im2col_step: int, -) -> List[torch.Tensor]: - return ops.ms_deform_attn_backward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - grad_output, - im2col_step, - ) - - -def ms_deform_attn_forward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - im2col_step: int, -) -> torch.Tensor: - return ops.ms_deform_attn_forward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - im2col_step, - ) - - -__all__ = ["layers", "ms_deform_attn_forward", "ms_deform_attn_backward"] diff --git a/build/torch27-cxx11-cu126-aarch64-linux/deformable_detr/_deformable_detr_7c33cbe.abi3.so b/build/torch27-cxx11-cu126-aarch64-linux/deformable_detr/_deformable_detr_7c33cbe.abi3.so deleted file mode 100755 index 63b666838685ae29d11438e79273b09b38f9df39..0000000000000000000000000000000000000000 --- a/build/torch27-cxx11-cu126-aarch64-linux/deformable_detr/_deformable_detr_7c33cbe.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:af2831b68229a910e8703cae2c9e720ded825e401745d38923548c444e56c37b -size 6833456 diff --git a/build/torch27-cxx11-cu126-aarch64-linux/deformable_detr/_ops.py b/build/torch27-cxx11-cu126-aarch64-linux/deformable_detr/_ops.py deleted file mode 100644 index 676ee6fea64b714dedb7ccd1d54148dcf75575a6..0000000000000000000000000000000000000000 --- a/build/torch27-cxx11-cu126-aarch64-linux/deformable_detr/_ops.py +++ /dev/null @@ -1,9 +0,0 @@ -import torch -from . import _deformable_detr_7c33cbe -ops = torch.ops._deformable_detr_7c33cbe - -def add_op_namespace_prefix(op_name: str): - """ - Prefix op by namespace. - """ - return f"_deformable_detr_7c33cbe::{op_name}" \ No newline at end of file diff --git a/build/torch27-cxx11-cu126-aarch64-linux/deformable_detr/layers.py b/build/torch27-cxx11-cu126-aarch64-linux/deformable_detr/layers.py deleted file mode 100644 index db94032dea3d445f27017f923ae80468e18d2d77..0000000000000000000000000000000000000000 --- a/build/torch27-cxx11-cu126-aarch64-linux/deformable_detr/layers.py +++ /dev/null @@ -1,84 +0,0 @@ -from typing import List, Union, Tuple - -from torch import Tensor -from torch.autograd import Function -from torch.autograd.function import once_differentiable -import torch.nn as nn - -from ._ops import ops - - -class MultiScaleDeformableAttentionFunction(Function): - @staticmethod - def forward( - context, - value: Tensor, - value_spatial_shapes: Tensor, - value_level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - context.im2col_step = im2col_step - output = ops.ms_deform_attn_forward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - context.im2col_step, - ) - context.save_for_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) - return output - - @staticmethod - @once_differentiable - def backward(context, grad_output): - ( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) = context.saved_tensors - grad_value, grad_sampling_loc, grad_attn_weight = ops.ms_deform_attn_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - grad_output, - context.im2col_step, - ) - - return grad_value, None, None, grad_sampling_loc, grad_attn_weight, None - - -class MultiScaleDeformableAttention(nn.Module): - def forward( - self, - value: Tensor, - value_spatial_shapes: Tensor, - value_spatial_shapes_list: List[Tuple], - level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - return MultiScaleDeformableAttentionFunction.apply( - value, - value_spatial_shapes, - level_start_index, - sampling_locations, - attention_weights, - im2col_step, - ) - - -__all__ = ["MultiScaleDeformableAttention"] diff --git a/build/torch27-cxx11-cu126-x86_64-linux/deformable_detr/__init__.py b/build/torch27-cxx11-cu126-x86_64-linux/deformable_detr/__init__.py deleted file mode 100644 index 33db73ca6e361af4707ba5bb5f55bf0e7c3005a4..0000000000000000000000000000000000000000 --- a/build/torch27-cxx11-cu126-x86_64-linux/deformable_detr/__init__.py +++ /dev/null @@ -1,46 +0,0 @@ -from typing import List -import torch - -from ._ops import ops -from . import layers - - -def ms_deform_attn_backward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - grad_output: torch.Tensor, - im2col_step: int, -) -> List[torch.Tensor]: - return ops.ms_deform_attn_backward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - grad_output, - im2col_step, - ) - - -def ms_deform_attn_forward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - im2col_step: int, -) -> torch.Tensor: - return ops.ms_deform_attn_forward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - im2col_step, - ) - - -__all__ = ["layers", "ms_deform_attn_forward", "ms_deform_attn_backward"] diff --git a/build/torch27-cxx11-cu126-x86_64-linux/deformable_detr/__pycache__/__init__.cpython-313.pyc b/build/torch27-cxx11-cu126-x86_64-linux/deformable_detr/__pycache__/__init__.cpython-313.pyc deleted file mode 100644 index 03f23b4fd38706ba1888acf199b905f851d2b024..0000000000000000000000000000000000000000 Binary files a/build/torch27-cxx11-cu126-x86_64-linux/deformable_detr/__pycache__/__init__.cpython-313.pyc and /dev/null differ diff --git a/build/torch27-cxx11-cu126-x86_64-linux/deformable_detr/__pycache__/_ops.cpython-313.pyc b/build/torch27-cxx11-cu126-x86_64-linux/deformable_detr/__pycache__/_ops.cpython-313.pyc deleted file mode 100644 index cca62822318d51b9dbb51466f3e0a6d5fd388306..0000000000000000000000000000000000000000 Binary files a/build/torch27-cxx11-cu126-x86_64-linux/deformable_detr/__pycache__/_ops.cpython-313.pyc and /dev/null differ diff --git a/build/torch27-cxx11-cu126-x86_64-linux/deformable_detr/__pycache__/layers.cpython-313.pyc b/build/torch27-cxx11-cu126-x86_64-linux/deformable_detr/__pycache__/layers.cpython-313.pyc deleted file mode 100644 index 7dfb8dda54ffc9062a129331374926b1fe104ecd..0000000000000000000000000000000000000000 Binary files a/build/torch27-cxx11-cu126-x86_64-linux/deformable_detr/__pycache__/layers.cpython-313.pyc and /dev/null differ diff --git a/build/torch27-cxx11-cu126-x86_64-linux/deformable_detr/_deformable_detr_57c3d32.abi3.so b/build/torch27-cxx11-cu126-x86_64-linux/deformable_detr/_deformable_detr_57c3d32.abi3.so deleted file mode 100644 index abe151e58a46c02191f11213027731ed26b7a182..0000000000000000000000000000000000000000 --- a/build/torch27-cxx11-cu126-x86_64-linux/deformable_detr/_deformable_detr_57c3d32.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:df54f46f59b5b78b15314cb0825d8f1f34c7a3198e9d62ca2a65a8ca72ea79a4 -size 6911280 diff --git a/build/torch27-cxx11-cu126-x86_64-linux/deformable_detr/_ops.py b/build/torch27-cxx11-cu126-x86_64-linux/deformable_detr/_ops.py deleted file mode 100644 index 39c2aa7875432779e86612a0e56271fe32133953..0000000000000000000000000000000000000000 --- a/build/torch27-cxx11-cu126-x86_64-linux/deformable_detr/_ops.py +++ /dev/null @@ -1,9 +0,0 @@ -import torch -from . import _deformable_detr_57c3d32 -ops = torch.ops._deformable_detr_57c3d32 - -def add_op_namespace_prefix(op_name: str): - """ - Prefix op by namespace. - """ - return f"_deformable_detr_57c3d32::{op_name}" \ No newline at end of file diff --git a/build/torch27-cxx11-cu126-x86_64-linux/deformable_detr/layers.py b/build/torch27-cxx11-cu126-x86_64-linux/deformable_detr/layers.py deleted file mode 100644 index db94032dea3d445f27017f923ae80468e18d2d77..0000000000000000000000000000000000000000 --- a/build/torch27-cxx11-cu126-x86_64-linux/deformable_detr/layers.py +++ /dev/null @@ -1,84 +0,0 @@ -from typing import List, Union, Tuple - -from torch import Tensor -from torch.autograd import Function -from torch.autograd.function import once_differentiable -import torch.nn as nn - -from ._ops import ops - - -class MultiScaleDeformableAttentionFunction(Function): - @staticmethod - def forward( - context, - value: Tensor, - value_spatial_shapes: Tensor, - value_level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - context.im2col_step = im2col_step - output = ops.ms_deform_attn_forward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - context.im2col_step, - ) - context.save_for_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) - return output - - @staticmethod - @once_differentiable - def backward(context, grad_output): - ( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) = context.saved_tensors - grad_value, grad_sampling_loc, grad_attn_weight = ops.ms_deform_attn_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - grad_output, - context.im2col_step, - ) - - return grad_value, None, None, grad_sampling_loc, grad_attn_weight, None - - -class MultiScaleDeformableAttention(nn.Module): - def forward( - self, - value: Tensor, - value_spatial_shapes: Tensor, - value_spatial_shapes_list: List[Tuple], - level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - return MultiScaleDeformableAttentionFunction.apply( - value, - value_spatial_shapes, - level_start_index, - sampling_locations, - attention_weights, - im2col_step, - ) - - -__all__ = ["MultiScaleDeformableAttention"] diff --git a/build/torch27-cxx11-cu128-aarch64-linux/deformable_detr/__init__.py b/build/torch27-cxx11-cu128-aarch64-linux/deformable_detr/__init__.py deleted file mode 100644 index 33db73ca6e361af4707ba5bb5f55bf0e7c3005a4..0000000000000000000000000000000000000000 --- a/build/torch27-cxx11-cu128-aarch64-linux/deformable_detr/__init__.py +++ /dev/null @@ -1,46 +0,0 @@ -from typing import List -import torch - -from ._ops import ops -from . import layers - - -def ms_deform_attn_backward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - grad_output: torch.Tensor, - im2col_step: int, -) -> List[torch.Tensor]: - return ops.ms_deform_attn_backward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - grad_output, - im2col_step, - ) - - -def ms_deform_attn_forward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - im2col_step: int, -) -> torch.Tensor: - return ops.ms_deform_attn_forward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - im2col_step, - ) - - -__all__ = ["layers", "ms_deform_attn_forward", "ms_deform_attn_backward"] diff --git a/build/torch27-cxx11-cu128-aarch64-linux/deformable_detr/__pycache__/__init__.cpython-313.pyc b/build/torch27-cxx11-cu128-aarch64-linux/deformable_detr/__pycache__/__init__.cpython-313.pyc deleted file mode 100644 index 2c7fa735b9a5720691a5ed6c31e566b5bc81dd77..0000000000000000000000000000000000000000 Binary files a/build/torch27-cxx11-cu128-aarch64-linux/deformable_detr/__pycache__/__init__.cpython-313.pyc and /dev/null differ diff --git a/build/torch27-cxx11-cu128-aarch64-linux/deformable_detr/__pycache__/_ops.cpython-313.pyc b/build/torch27-cxx11-cu128-aarch64-linux/deformable_detr/__pycache__/_ops.cpython-313.pyc deleted file mode 100644 index 499ecc259157bcef7916fea79bdd097407854ba3..0000000000000000000000000000000000000000 Binary files a/build/torch27-cxx11-cu128-aarch64-linux/deformable_detr/__pycache__/_ops.cpython-313.pyc and /dev/null differ diff --git a/build/torch27-cxx11-cu128-aarch64-linux/deformable_detr/__pycache__/layers.cpython-313.pyc b/build/torch27-cxx11-cu128-aarch64-linux/deformable_detr/__pycache__/layers.cpython-313.pyc deleted file mode 100644 index 5483ccd7f0aaaeffd23797fbec5d47f3e8f49080..0000000000000000000000000000000000000000 Binary files a/build/torch27-cxx11-cu128-aarch64-linux/deformable_detr/__pycache__/layers.cpython-313.pyc and /dev/null differ diff --git a/build/torch27-cxx11-cu128-aarch64-linux/deformable_detr/_deformable_detr_320b408.abi3.so b/build/torch27-cxx11-cu128-aarch64-linux/deformable_detr/_deformable_detr_320b408.abi3.so deleted file mode 100644 index 0c564ee29cec2888bffa2ce31732d90efb502625..0000000000000000000000000000000000000000 --- a/build/torch27-cxx11-cu128-aarch64-linux/deformable_detr/_deformable_detr_320b408.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:8926ca42814a03cdbac750f3a0cd3e3cbc28614a58e1ca5a77e82b3ad0148043 -size 9979264 diff --git a/build/torch27-cxx11-cu128-aarch64-linux/deformable_detr/_ops.py b/build/torch27-cxx11-cu128-aarch64-linux/deformable_detr/_ops.py deleted file mode 100644 index 155c52bfca54e55425b639314b289e668c5a6ec2..0000000000000000000000000000000000000000 --- a/build/torch27-cxx11-cu128-aarch64-linux/deformable_detr/_ops.py +++ /dev/null @@ -1,9 +0,0 @@ -import torch -from . import _deformable_detr_320b408 -ops = torch.ops._deformable_detr_320b408 - -def add_op_namespace_prefix(op_name: str): - """ - Prefix op by namespace. - """ - return f"_deformable_detr_320b408::{op_name}" \ No newline at end of file diff --git a/build/torch27-cxx11-cu128-aarch64-linux/deformable_detr/layers.py b/build/torch27-cxx11-cu128-aarch64-linux/deformable_detr/layers.py deleted file mode 100644 index db94032dea3d445f27017f923ae80468e18d2d77..0000000000000000000000000000000000000000 --- a/build/torch27-cxx11-cu128-aarch64-linux/deformable_detr/layers.py +++ /dev/null @@ -1,84 +0,0 @@ -from typing import List, Union, Tuple - -from torch import Tensor -from torch.autograd import Function -from torch.autograd.function import once_differentiable -import torch.nn as nn - -from ._ops import ops - - -class MultiScaleDeformableAttentionFunction(Function): - @staticmethod - def forward( - context, - value: Tensor, - value_spatial_shapes: Tensor, - value_level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - context.im2col_step = im2col_step - output = ops.ms_deform_attn_forward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - context.im2col_step, - ) - context.save_for_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) - return output - - @staticmethod - @once_differentiable - def backward(context, grad_output): - ( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) = context.saved_tensors - grad_value, grad_sampling_loc, grad_attn_weight = ops.ms_deform_attn_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - grad_output, - context.im2col_step, - ) - - return grad_value, None, None, grad_sampling_loc, grad_attn_weight, None - - -class MultiScaleDeformableAttention(nn.Module): - def forward( - self, - value: Tensor, - value_spatial_shapes: Tensor, - value_spatial_shapes_list: List[Tuple], - level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - return MultiScaleDeformableAttentionFunction.apply( - value, - value_spatial_shapes, - level_start_index, - sampling_locations, - attention_weights, - im2col_step, - ) - - -__all__ = ["MultiScaleDeformableAttention"] diff --git a/build/torch27-cxx11-cu128-x86_64-linux/deformable_detr/__init__.py b/build/torch27-cxx11-cu128-x86_64-linux/deformable_detr/__init__.py deleted file mode 100644 index 33db73ca6e361af4707ba5bb5f55bf0e7c3005a4..0000000000000000000000000000000000000000 --- a/build/torch27-cxx11-cu128-x86_64-linux/deformable_detr/__init__.py +++ /dev/null @@ -1,46 +0,0 @@ -from typing import List -import torch - -from ._ops import ops -from . import layers - - -def ms_deform_attn_backward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - grad_output: torch.Tensor, - im2col_step: int, -) -> List[torch.Tensor]: - return ops.ms_deform_attn_backward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - grad_output, - im2col_step, - ) - - -def ms_deform_attn_forward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - im2col_step: int, -) -> torch.Tensor: - return ops.ms_deform_attn_forward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - im2col_step, - ) - - -__all__ = ["layers", "ms_deform_attn_forward", "ms_deform_attn_backward"] diff --git a/build/torch27-cxx11-cu128-x86_64-linux/deformable_detr/__pycache__/__init__.cpython-313.pyc b/build/torch27-cxx11-cu128-x86_64-linux/deformable_detr/__pycache__/__init__.cpython-313.pyc deleted file mode 100644 index 381ef42a3282d0c2787e94f3c29d999e4736d7c8..0000000000000000000000000000000000000000 Binary files a/build/torch27-cxx11-cu128-x86_64-linux/deformable_detr/__pycache__/__init__.cpython-313.pyc and /dev/null differ diff --git a/build/torch27-cxx11-cu128-x86_64-linux/deformable_detr/__pycache__/_ops.cpython-313.pyc b/build/torch27-cxx11-cu128-x86_64-linux/deformable_detr/__pycache__/_ops.cpython-313.pyc deleted file mode 100644 index 9291f79801323c5a3efc995f9c90ffa6cc35a50c..0000000000000000000000000000000000000000 Binary files a/build/torch27-cxx11-cu128-x86_64-linux/deformable_detr/__pycache__/_ops.cpython-313.pyc and /dev/null differ diff --git a/build/torch27-cxx11-cu128-x86_64-linux/deformable_detr/__pycache__/layers.cpython-313.pyc b/build/torch27-cxx11-cu128-x86_64-linux/deformable_detr/__pycache__/layers.cpython-313.pyc deleted file mode 100644 index 94595475894bf15ef880e78d37ec23bca83bed08..0000000000000000000000000000000000000000 Binary files a/build/torch27-cxx11-cu128-x86_64-linux/deformable_detr/__pycache__/layers.cpython-313.pyc and /dev/null differ diff --git a/build/torch27-cxx11-cu128-x86_64-linux/deformable_detr/_deformable_detr_57c3d32.abi3.so b/build/torch27-cxx11-cu128-x86_64-linux/deformable_detr/_deformable_detr_57c3d32.abi3.so deleted file mode 100644 index 2f388366cf92d9a815c26db28ca4a855f8e713ba..0000000000000000000000000000000000000000 --- a/build/torch27-cxx11-cu128-x86_64-linux/deformable_detr/_deformable_detr_57c3d32.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:6f389536870cd4acf36ab8f12d3b0bf9f847ec06e2cfc25905420796884b614e -size 9907368 diff --git a/build/torch27-cxx11-cu128-x86_64-linux/deformable_detr/_ops.py b/build/torch27-cxx11-cu128-x86_64-linux/deformable_detr/_ops.py deleted file mode 100644 index 39c2aa7875432779e86612a0e56271fe32133953..0000000000000000000000000000000000000000 --- a/build/torch27-cxx11-cu128-x86_64-linux/deformable_detr/_ops.py +++ /dev/null @@ -1,9 +0,0 @@ -import torch -from . import _deformable_detr_57c3d32 -ops = torch.ops._deformable_detr_57c3d32 - -def add_op_namespace_prefix(op_name: str): - """ - Prefix op by namespace. - """ - return f"_deformable_detr_57c3d32::{op_name}" \ No newline at end of file diff --git a/build/torch27-cxx11-cu128-x86_64-linux/deformable_detr/layers.py b/build/torch27-cxx11-cu128-x86_64-linux/deformable_detr/layers.py deleted file mode 100644 index db94032dea3d445f27017f923ae80468e18d2d77..0000000000000000000000000000000000000000 --- a/build/torch27-cxx11-cu128-x86_64-linux/deformable_detr/layers.py +++ /dev/null @@ -1,84 +0,0 @@ -from typing import List, Union, Tuple - -from torch import Tensor -from torch.autograd import Function -from torch.autograd.function import once_differentiable -import torch.nn as nn - -from ._ops import ops - - -class MultiScaleDeformableAttentionFunction(Function): - @staticmethod - def forward( - context, - value: Tensor, - value_spatial_shapes: Tensor, - value_level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - context.im2col_step = im2col_step - output = ops.ms_deform_attn_forward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - context.im2col_step, - ) - context.save_for_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) - return output - - @staticmethod - @once_differentiable - def backward(context, grad_output): - ( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) = context.saved_tensors - grad_value, grad_sampling_loc, grad_attn_weight = ops.ms_deform_attn_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - grad_output, - context.im2col_step, - ) - - return grad_value, None, None, grad_sampling_loc, grad_attn_weight, None - - -class MultiScaleDeformableAttention(nn.Module): - def forward( - self, - value: Tensor, - value_spatial_shapes: Tensor, - value_spatial_shapes_list: List[Tuple], - level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - return MultiScaleDeformableAttentionFunction.apply( - value, - value_spatial_shapes, - level_start_index, - sampling_locations, - attention_weights, - im2col_step, - ) - - -__all__ = ["MultiScaleDeformableAttention"] diff --git a/build/torch28-cxx11-cu126-aarch64-linux/deformable_detr/__init__.py b/build/torch28-cxx11-cu126-aarch64-linux/deformable_detr/__init__.py deleted file mode 100644 index 33db73ca6e361af4707ba5bb5f55bf0e7c3005a4..0000000000000000000000000000000000000000 --- a/build/torch28-cxx11-cu126-aarch64-linux/deformable_detr/__init__.py +++ /dev/null @@ -1,46 +0,0 @@ -from typing import List -import torch - -from ._ops import ops -from . import layers - - -def ms_deform_attn_backward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - grad_output: torch.Tensor, - im2col_step: int, -) -> List[torch.Tensor]: - return ops.ms_deform_attn_backward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - grad_output, - im2col_step, - ) - - -def ms_deform_attn_forward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - im2col_step: int, -) -> torch.Tensor: - return ops.ms_deform_attn_forward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - im2col_step, - ) - - -__all__ = ["layers", "ms_deform_attn_forward", "ms_deform_attn_backward"] diff --git a/build/torch28-cxx11-cu126-aarch64-linux/deformable_detr/__pycache__/__init__.cpython-313.pyc b/build/torch28-cxx11-cu126-aarch64-linux/deformable_detr/__pycache__/__init__.cpython-313.pyc deleted file mode 100644 index 664a914e405aa872821d228b552f22a99cb39d97..0000000000000000000000000000000000000000 Binary files a/build/torch28-cxx11-cu126-aarch64-linux/deformable_detr/__pycache__/__init__.cpython-313.pyc and /dev/null differ diff --git a/build/torch28-cxx11-cu126-aarch64-linux/deformable_detr/__pycache__/_ops.cpython-313.pyc b/build/torch28-cxx11-cu126-aarch64-linux/deformable_detr/__pycache__/_ops.cpython-313.pyc deleted file mode 100644 index 273cdfd52347ebcf0e0c050945d37c5dc5094a9a..0000000000000000000000000000000000000000 Binary files a/build/torch28-cxx11-cu126-aarch64-linux/deformable_detr/__pycache__/_ops.cpython-313.pyc and /dev/null differ diff --git a/build/torch28-cxx11-cu126-aarch64-linux/deformable_detr/__pycache__/layers.cpython-313.pyc b/build/torch28-cxx11-cu126-aarch64-linux/deformable_detr/__pycache__/layers.cpython-313.pyc deleted file mode 100644 index 082d05eb36d7ef831ca076e3e7d2eb070130c2ec..0000000000000000000000000000000000000000 Binary files a/build/torch28-cxx11-cu126-aarch64-linux/deformable_detr/__pycache__/layers.cpython-313.pyc and /dev/null differ diff --git a/build/torch28-cxx11-cu126-aarch64-linux/deformable_detr/_deformable_detr_a92c8ea_dirty.abi3.so b/build/torch28-cxx11-cu126-aarch64-linux/deformable_detr/_deformable_detr_a92c8ea_dirty.abi3.so deleted file mode 100755 index 3d206228684c315eb04160dc62c8a7cb6811156a..0000000000000000000000000000000000000000 --- a/build/torch28-cxx11-cu126-aarch64-linux/deformable_detr/_deformable_detr_a92c8ea_dirty.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:b4a5665b05309312200ca97a80cc61340c0f5de123ab33254e5307a5ec4ed2a0 -size 6901024 diff --git a/build/torch28-cxx11-cu126-aarch64-linux/deformable_detr/_ops.py b/build/torch28-cxx11-cu126-aarch64-linux/deformable_detr/_ops.py deleted file mode 100644 index 019cf7ce30dc11d9b791075404417b1ac47500e7..0000000000000000000000000000000000000000 --- a/build/torch28-cxx11-cu126-aarch64-linux/deformable_detr/_ops.py +++ /dev/null @@ -1,9 +0,0 @@ -import torch -from . import _deformable_detr_a92c8ea_dirty -ops = torch.ops._deformable_detr_a92c8ea_dirty - -def add_op_namespace_prefix(op_name: str): - """ - Prefix op by namespace. - """ - return f"_deformable_detr_a92c8ea_dirty::{op_name}" \ No newline at end of file diff --git a/build/torch28-cxx11-cu126-aarch64-linux/deformable_detr/layers.py b/build/torch28-cxx11-cu126-aarch64-linux/deformable_detr/layers.py deleted file mode 100644 index db94032dea3d445f27017f923ae80468e18d2d77..0000000000000000000000000000000000000000 --- a/build/torch28-cxx11-cu126-aarch64-linux/deformable_detr/layers.py +++ /dev/null @@ -1,84 +0,0 @@ -from typing import List, Union, Tuple - -from torch import Tensor -from torch.autograd import Function -from torch.autograd.function import once_differentiable -import torch.nn as nn - -from ._ops import ops - - -class MultiScaleDeformableAttentionFunction(Function): - @staticmethod - def forward( - context, - value: Tensor, - value_spatial_shapes: Tensor, - value_level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - context.im2col_step = im2col_step - output = ops.ms_deform_attn_forward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - context.im2col_step, - ) - context.save_for_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) - return output - - @staticmethod - @once_differentiable - def backward(context, grad_output): - ( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) = context.saved_tensors - grad_value, grad_sampling_loc, grad_attn_weight = ops.ms_deform_attn_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - grad_output, - context.im2col_step, - ) - - return grad_value, None, None, grad_sampling_loc, grad_attn_weight, None - - -class MultiScaleDeformableAttention(nn.Module): - def forward( - self, - value: Tensor, - value_spatial_shapes: Tensor, - value_spatial_shapes_list: List[Tuple], - level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - return MultiScaleDeformableAttentionFunction.apply( - value, - value_spatial_shapes, - level_start_index, - sampling_locations, - attention_weights, - im2col_step, - ) - - -__all__ = ["MultiScaleDeformableAttention"] diff --git a/build/torch28-cxx11-cu126-x86_64-linux/__init__.py b/build/torch28-cxx11-cu126-x86_64-linux/__init__.py deleted file mode 100644 index 33db73ca6e361af4707ba5bb5f55bf0e7c3005a4..0000000000000000000000000000000000000000 --- a/build/torch28-cxx11-cu126-x86_64-linux/__init__.py +++ /dev/null @@ -1,46 +0,0 @@ -from typing import List -import torch - -from ._ops import ops -from . import layers - - -def ms_deform_attn_backward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - grad_output: torch.Tensor, - im2col_step: int, -) -> List[torch.Tensor]: - return ops.ms_deform_attn_backward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - grad_output, - im2col_step, - ) - - -def ms_deform_attn_forward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - im2col_step: int, -) -> torch.Tensor: - return ops.ms_deform_attn_forward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - im2col_step, - ) - - -__all__ = ["layers", "ms_deform_attn_forward", "ms_deform_attn_backward"] diff --git a/build/torch28-cxx11-cu126-x86_64-linux/_deformable_detr_d7966ee.abi3.so b/build/torch28-cxx11-cu126-x86_64-linux/_deformable_detr_d7966ee.abi3.so deleted file mode 100644 index 818f37b941ec19250adbb6feb357a0ec81c67b2a..0000000000000000000000000000000000000000 --- a/build/torch28-cxx11-cu126-x86_64-linux/_deformable_detr_d7966ee.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f8e98e8cdd688603d90d9bbc9fc7fd093d7c8f098ae239b33d59db563ca20d3f -size 8535712 diff --git a/build/torch28-cxx11-cu126-x86_64-linux/_ops.py b/build/torch28-cxx11-cu126-x86_64-linux/_ops.py deleted file mode 100644 index b498ff9a9fd0bc22a42440001932cf97a8a9e955..0000000000000000000000000000000000000000 --- a/build/torch28-cxx11-cu126-x86_64-linux/_ops.py +++ /dev/null @@ -1,9 +0,0 @@ -import torch -from . import _deformable_detr_d7966ee -ops = torch.ops._deformable_detr_d7966ee - -def add_op_namespace_prefix(op_name: str): - """ - Prefix op by namespace. - """ - return f"_deformable_detr_d7966ee::{op_name}" \ No newline at end of file diff --git a/build/torch28-cxx11-cu126-x86_64-linux/deformable_detr/__init__.py b/build/torch28-cxx11-cu126-x86_64-linux/deformable_detr/__init__.py deleted file mode 100644 index 03dbc1afe1cf156661a2b1b22003cd5f599a0309..0000000000000000000000000000000000000000 --- a/build/torch28-cxx11-cu126-x86_64-linux/deformable_detr/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -import ctypes -import sys - -import importlib -from pathlib import Path -from types import ModuleType - -def _import_from_path(file_path: Path) -> ModuleType: - # We cannot use the module name as-is, after adding it to `sys.modules`, - # it would also be used for other imports. So, we make a module name that - # depends on the path for it to be unique using the hex-encoded hash of - # the path. - path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value) - module_name = path_hash - spec = importlib.util.spec_from_file_location(module_name, file_path) - if spec is None: - raise ImportError(f"Cannot load spec for {module_name} from {file_path}") - module = importlib.util.module_from_spec(spec) - if module is None: - raise ImportError(f"Cannot load module {module_name} from spec") - sys.modules[module_name] = module - spec.loader.exec_module(module) # type: ignore - return module - - -globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py"))) diff --git a/build/torch28-cxx11-cu126-x86_64-linux/layers.py b/build/torch28-cxx11-cu126-x86_64-linux/layers.py deleted file mode 100644 index db94032dea3d445f27017f923ae80468e18d2d77..0000000000000000000000000000000000000000 --- a/build/torch28-cxx11-cu126-x86_64-linux/layers.py +++ /dev/null @@ -1,84 +0,0 @@ -from typing import List, Union, Tuple - -from torch import Tensor -from torch.autograd import Function -from torch.autograd.function import once_differentiable -import torch.nn as nn - -from ._ops import ops - - -class MultiScaleDeformableAttentionFunction(Function): - @staticmethod - def forward( - context, - value: Tensor, - value_spatial_shapes: Tensor, - value_level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - context.im2col_step = im2col_step - output = ops.ms_deform_attn_forward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - context.im2col_step, - ) - context.save_for_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) - return output - - @staticmethod - @once_differentiable - def backward(context, grad_output): - ( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) = context.saved_tensors - grad_value, grad_sampling_loc, grad_attn_weight = ops.ms_deform_attn_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - grad_output, - context.im2col_step, - ) - - return grad_value, None, None, grad_sampling_loc, grad_attn_weight, None - - -class MultiScaleDeformableAttention(nn.Module): - def forward( - self, - value: Tensor, - value_spatial_shapes: Tensor, - value_spatial_shapes_list: List[Tuple], - level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - return MultiScaleDeformableAttentionFunction.apply( - value, - value_spatial_shapes, - level_start_index, - sampling_locations, - attention_weights, - im2col_step, - ) - - -__all__ = ["MultiScaleDeformableAttention"] diff --git a/build/torch28-cxx11-cu126-x86_64-linux/metadata.json b/build/torch28-cxx11-cu126-x86_64-linux/metadata.json deleted file mode 100644 index 9cf5deed9898dce769f4cc73913d3530b92a0bd8..0000000000000000000000000000000000000000 --- a/build/torch28-cxx11-cu126-x86_64-linux/metadata.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "version": 1, - "python-depends": [] -} \ No newline at end of file diff --git a/build/torch28-cxx11-cu128-aarch64-linux/deformable_detr/__init__.py b/build/torch28-cxx11-cu128-aarch64-linux/deformable_detr/__init__.py deleted file mode 100644 index 33db73ca6e361af4707ba5bb5f55bf0e7c3005a4..0000000000000000000000000000000000000000 --- a/build/torch28-cxx11-cu128-aarch64-linux/deformable_detr/__init__.py +++ /dev/null @@ -1,46 +0,0 @@ -from typing import List -import torch - -from ._ops import ops -from . import layers - - -def ms_deform_attn_backward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - grad_output: torch.Tensor, - im2col_step: int, -) -> List[torch.Tensor]: - return ops.ms_deform_attn_backward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - grad_output, - im2col_step, - ) - - -def ms_deform_attn_forward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - im2col_step: int, -) -> torch.Tensor: - return ops.ms_deform_attn_forward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - im2col_step, - ) - - -__all__ = ["layers", "ms_deform_attn_forward", "ms_deform_attn_backward"] diff --git a/build/torch28-cxx11-cu128-aarch64-linux/deformable_detr/__pycache__/__init__.cpython-313.pyc b/build/torch28-cxx11-cu128-aarch64-linux/deformable_detr/__pycache__/__init__.cpython-313.pyc deleted file mode 100644 index 28a5933156ae99fa286e692f8e98dd04e50f5174..0000000000000000000000000000000000000000 Binary files a/build/torch28-cxx11-cu128-aarch64-linux/deformable_detr/__pycache__/__init__.cpython-313.pyc and /dev/null differ diff --git a/build/torch28-cxx11-cu128-aarch64-linux/deformable_detr/__pycache__/_ops.cpython-313.pyc b/build/torch28-cxx11-cu128-aarch64-linux/deformable_detr/__pycache__/_ops.cpython-313.pyc deleted file mode 100644 index 0009fad4a606c6aacd228a2d7af5e6263d47d861..0000000000000000000000000000000000000000 Binary files a/build/torch28-cxx11-cu128-aarch64-linux/deformable_detr/__pycache__/_ops.cpython-313.pyc and /dev/null differ diff --git a/build/torch28-cxx11-cu128-aarch64-linux/deformable_detr/__pycache__/layers.cpython-313.pyc b/build/torch28-cxx11-cu128-aarch64-linux/deformable_detr/__pycache__/layers.cpython-313.pyc deleted file mode 100644 index 18befc2ceb219257a717fe3c9800618101a3904c..0000000000000000000000000000000000000000 Binary files a/build/torch28-cxx11-cu128-aarch64-linux/deformable_detr/__pycache__/layers.cpython-313.pyc and /dev/null differ diff --git a/build/torch28-cxx11-cu128-aarch64-linux/deformable_detr/_deformable_detr_a92c8ea_dirty.abi3.so b/build/torch28-cxx11-cu128-aarch64-linux/deformable_detr/_deformable_detr_a92c8ea_dirty.abi3.so deleted file mode 100755 index 7a0b563d8285a538c60f993ba90ffee3d5b49ec6..0000000000000000000000000000000000000000 --- a/build/torch28-cxx11-cu128-aarch64-linux/deformable_detr/_deformable_detr_a92c8ea_dirty.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:3f4a0a7850968822e26e3a59c801fd711231d5294193155efbf9583761e114ef -size 9849688 diff --git a/build/torch28-cxx11-cu128-aarch64-linux/deformable_detr/_ops.py b/build/torch28-cxx11-cu128-aarch64-linux/deformable_detr/_ops.py deleted file mode 100644 index 019cf7ce30dc11d9b791075404417b1ac47500e7..0000000000000000000000000000000000000000 --- a/build/torch28-cxx11-cu128-aarch64-linux/deformable_detr/_ops.py +++ /dev/null @@ -1,9 +0,0 @@ -import torch -from . import _deformable_detr_a92c8ea_dirty -ops = torch.ops._deformable_detr_a92c8ea_dirty - -def add_op_namespace_prefix(op_name: str): - """ - Prefix op by namespace. - """ - return f"_deformable_detr_a92c8ea_dirty::{op_name}" \ No newline at end of file diff --git a/build/torch28-cxx11-cu128-aarch64-linux/deformable_detr/layers.py b/build/torch28-cxx11-cu128-aarch64-linux/deformable_detr/layers.py deleted file mode 100644 index db94032dea3d445f27017f923ae80468e18d2d77..0000000000000000000000000000000000000000 --- a/build/torch28-cxx11-cu128-aarch64-linux/deformable_detr/layers.py +++ /dev/null @@ -1,84 +0,0 @@ -from typing import List, Union, Tuple - -from torch import Tensor -from torch.autograd import Function -from torch.autograd.function import once_differentiable -import torch.nn as nn - -from ._ops import ops - - -class MultiScaleDeformableAttentionFunction(Function): - @staticmethod - def forward( - context, - value: Tensor, - value_spatial_shapes: Tensor, - value_level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - context.im2col_step = im2col_step - output = ops.ms_deform_attn_forward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - context.im2col_step, - ) - context.save_for_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) - return output - - @staticmethod - @once_differentiable - def backward(context, grad_output): - ( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) = context.saved_tensors - grad_value, grad_sampling_loc, grad_attn_weight = ops.ms_deform_attn_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - grad_output, - context.im2col_step, - ) - - return grad_value, None, None, grad_sampling_loc, grad_attn_weight, None - - -class MultiScaleDeformableAttention(nn.Module): - def forward( - self, - value: Tensor, - value_spatial_shapes: Tensor, - value_spatial_shapes_list: List[Tuple], - level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - return MultiScaleDeformableAttentionFunction.apply( - value, - value_spatial_shapes, - level_start_index, - sampling_locations, - attention_weights, - im2col_step, - ) - - -__all__ = ["MultiScaleDeformableAttention"] diff --git a/build/torch28-cxx11-cu128-x86_64-linux/__init__.py b/build/torch28-cxx11-cu128-x86_64-linux/__init__.py deleted file mode 100644 index 33db73ca6e361af4707ba5bb5f55bf0e7c3005a4..0000000000000000000000000000000000000000 --- a/build/torch28-cxx11-cu128-x86_64-linux/__init__.py +++ /dev/null @@ -1,46 +0,0 @@ -from typing import List -import torch - -from ._ops import ops -from . import layers - - -def ms_deform_attn_backward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - grad_output: torch.Tensor, - im2col_step: int, -) -> List[torch.Tensor]: - return ops.ms_deform_attn_backward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - grad_output, - im2col_step, - ) - - -def ms_deform_attn_forward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - im2col_step: int, -) -> torch.Tensor: - return ops.ms_deform_attn_forward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - im2col_step, - ) - - -__all__ = ["layers", "ms_deform_attn_forward", "ms_deform_attn_backward"] diff --git a/build/torch28-cxx11-cu128-x86_64-linux/_deformable_detr_d7966ee.abi3.so b/build/torch28-cxx11-cu128-x86_64-linux/_deformable_detr_d7966ee.abi3.so deleted file mode 100644 index 2118be1b65bcb2c028582b19fa63835513865bf1..0000000000000000000000000000000000000000 --- a/build/torch28-cxx11-cu128-x86_64-linux/_deformable_detr_d7966ee.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:615c916fe00481be53757d381f62c663c3519bf5d0dda09514b13bf9e493b807 -size 11523184 diff --git a/build/torch28-cxx11-cu128-x86_64-linux/_ops.py b/build/torch28-cxx11-cu128-x86_64-linux/_ops.py deleted file mode 100644 index b498ff9a9fd0bc22a42440001932cf97a8a9e955..0000000000000000000000000000000000000000 --- a/build/torch28-cxx11-cu128-x86_64-linux/_ops.py +++ /dev/null @@ -1,9 +0,0 @@ -import torch -from . import _deformable_detr_d7966ee -ops = torch.ops._deformable_detr_d7966ee - -def add_op_namespace_prefix(op_name: str): - """ - Prefix op by namespace. - """ - return f"_deformable_detr_d7966ee::{op_name}" \ No newline at end of file diff --git a/build/torch28-cxx11-cu128-x86_64-linux/deformable_detr/__init__.py b/build/torch28-cxx11-cu128-x86_64-linux/deformable_detr/__init__.py deleted file mode 100644 index 03dbc1afe1cf156661a2b1b22003cd5f599a0309..0000000000000000000000000000000000000000 --- a/build/torch28-cxx11-cu128-x86_64-linux/deformable_detr/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -import ctypes -import sys - -import importlib -from pathlib import Path -from types import ModuleType - -def _import_from_path(file_path: Path) -> ModuleType: - # We cannot use the module name as-is, after adding it to `sys.modules`, - # it would also be used for other imports. So, we make a module name that - # depends on the path for it to be unique using the hex-encoded hash of - # the path. - path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value) - module_name = path_hash - spec = importlib.util.spec_from_file_location(module_name, file_path) - if spec is None: - raise ImportError(f"Cannot load spec for {module_name} from {file_path}") - module = importlib.util.module_from_spec(spec) - if module is None: - raise ImportError(f"Cannot load module {module_name} from spec") - sys.modules[module_name] = module - spec.loader.exec_module(module) # type: ignore - return module - - -globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py"))) diff --git a/build/torch28-cxx11-cu128-x86_64-linux/layers.py b/build/torch28-cxx11-cu128-x86_64-linux/layers.py deleted file mode 100644 index db94032dea3d445f27017f923ae80468e18d2d77..0000000000000000000000000000000000000000 --- a/build/torch28-cxx11-cu128-x86_64-linux/layers.py +++ /dev/null @@ -1,84 +0,0 @@ -from typing import List, Union, Tuple - -from torch import Tensor -from torch.autograd import Function -from torch.autograd.function import once_differentiable -import torch.nn as nn - -from ._ops import ops - - -class MultiScaleDeformableAttentionFunction(Function): - @staticmethod - def forward( - context, - value: Tensor, - value_spatial_shapes: Tensor, - value_level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - context.im2col_step = im2col_step - output = ops.ms_deform_attn_forward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - context.im2col_step, - ) - context.save_for_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) - return output - - @staticmethod - @once_differentiable - def backward(context, grad_output): - ( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) = context.saved_tensors - grad_value, grad_sampling_loc, grad_attn_weight = ops.ms_deform_attn_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - grad_output, - context.im2col_step, - ) - - return grad_value, None, None, grad_sampling_loc, grad_attn_weight, None - - -class MultiScaleDeformableAttention(nn.Module): - def forward( - self, - value: Tensor, - value_spatial_shapes: Tensor, - value_spatial_shapes_list: List[Tuple], - level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - return MultiScaleDeformableAttentionFunction.apply( - value, - value_spatial_shapes, - level_start_index, - sampling_locations, - attention_weights, - im2col_step, - ) - - -__all__ = ["MultiScaleDeformableAttention"] diff --git a/build/torch28-cxx11-cu128-x86_64-linux/metadata.json b/build/torch28-cxx11-cu128-x86_64-linux/metadata.json deleted file mode 100644 index 9cf5deed9898dce769f4cc73913d3530b92a0bd8..0000000000000000000000000000000000000000 --- a/build/torch28-cxx11-cu128-x86_64-linux/metadata.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "version": 1, - "python-depends": [] -} \ No newline at end of file diff --git a/build/torch28-cxx11-cu129-aarch64-linux/deformable_detr/__init__.py b/build/torch28-cxx11-cu129-aarch64-linux/deformable_detr/__init__.py deleted file mode 100644 index 33db73ca6e361af4707ba5bb5f55bf0e7c3005a4..0000000000000000000000000000000000000000 --- a/build/torch28-cxx11-cu129-aarch64-linux/deformable_detr/__init__.py +++ /dev/null @@ -1,46 +0,0 @@ -from typing import List -import torch - -from ._ops import ops -from . import layers - - -def ms_deform_attn_backward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - grad_output: torch.Tensor, - im2col_step: int, -) -> List[torch.Tensor]: - return ops.ms_deform_attn_backward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - grad_output, - im2col_step, - ) - - -def ms_deform_attn_forward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - im2col_step: int, -) -> torch.Tensor: - return ops.ms_deform_attn_forward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - im2col_step, - ) - - -__all__ = ["layers", "ms_deform_attn_forward", "ms_deform_attn_backward"] diff --git a/build/torch28-cxx11-cu129-aarch64-linux/deformable_detr/__pycache__/__init__.cpython-313.pyc b/build/torch28-cxx11-cu129-aarch64-linux/deformable_detr/__pycache__/__init__.cpython-313.pyc deleted file mode 100644 index 3455ebe146d88ed909d4d3a22cbafdb7062e1a5c..0000000000000000000000000000000000000000 Binary files a/build/torch28-cxx11-cu129-aarch64-linux/deformable_detr/__pycache__/__init__.cpython-313.pyc and /dev/null differ diff --git a/build/torch28-cxx11-cu129-aarch64-linux/deformable_detr/__pycache__/_ops.cpython-313.pyc b/build/torch28-cxx11-cu129-aarch64-linux/deformable_detr/__pycache__/_ops.cpython-313.pyc deleted file mode 100644 index 6d0da2a8b90739e30e9e2787462994764ddd0e6b..0000000000000000000000000000000000000000 Binary files a/build/torch28-cxx11-cu129-aarch64-linux/deformable_detr/__pycache__/_ops.cpython-313.pyc and /dev/null differ diff --git a/build/torch28-cxx11-cu129-aarch64-linux/deformable_detr/__pycache__/layers.cpython-313.pyc b/build/torch28-cxx11-cu129-aarch64-linux/deformable_detr/__pycache__/layers.cpython-313.pyc deleted file mode 100644 index f35af2756ff4a30e7bd8d95092215bc26766097d..0000000000000000000000000000000000000000 Binary files a/build/torch28-cxx11-cu129-aarch64-linux/deformable_detr/__pycache__/layers.cpython-313.pyc and /dev/null differ diff --git a/build/torch28-cxx11-cu129-aarch64-linux/deformable_detr/_deformable_detr_320b408.abi3.so b/build/torch28-cxx11-cu129-aarch64-linux/deformable_detr/_deformable_detr_320b408.abi3.so deleted file mode 100644 index fe1c2e4e6b379f20da5c38cee026aac074b71fb4..0000000000000000000000000000000000000000 --- a/build/torch28-cxx11-cu129-aarch64-linux/deformable_detr/_deformable_detr_320b408.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c7f99924b14f0522d25c5f0a307ab1364a3f76d9ecf29684f80aa388f6bd443b -size 10047704 diff --git a/build/torch28-cxx11-cu129-aarch64-linux/deformable_detr/_ops.py b/build/torch28-cxx11-cu129-aarch64-linux/deformable_detr/_ops.py deleted file mode 100644 index 155c52bfca54e55425b639314b289e668c5a6ec2..0000000000000000000000000000000000000000 --- a/build/torch28-cxx11-cu129-aarch64-linux/deformable_detr/_ops.py +++ /dev/null @@ -1,9 +0,0 @@ -import torch -from . import _deformable_detr_320b408 -ops = torch.ops._deformable_detr_320b408 - -def add_op_namespace_prefix(op_name: str): - """ - Prefix op by namespace. - """ - return f"_deformable_detr_320b408::{op_name}" \ No newline at end of file diff --git a/build/torch28-cxx11-cu129-aarch64-linux/deformable_detr/layers.py b/build/torch28-cxx11-cu129-aarch64-linux/deformable_detr/layers.py deleted file mode 100644 index db94032dea3d445f27017f923ae80468e18d2d77..0000000000000000000000000000000000000000 --- a/build/torch28-cxx11-cu129-aarch64-linux/deformable_detr/layers.py +++ /dev/null @@ -1,84 +0,0 @@ -from typing import List, Union, Tuple - -from torch import Tensor -from torch.autograd import Function -from torch.autograd.function import once_differentiable -import torch.nn as nn - -from ._ops import ops - - -class MultiScaleDeformableAttentionFunction(Function): - @staticmethod - def forward( - context, - value: Tensor, - value_spatial_shapes: Tensor, - value_level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - context.im2col_step = im2col_step - output = ops.ms_deform_attn_forward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - context.im2col_step, - ) - context.save_for_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) - return output - - @staticmethod - @once_differentiable - def backward(context, grad_output): - ( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) = context.saved_tensors - grad_value, grad_sampling_loc, grad_attn_weight = ops.ms_deform_attn_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - grad_output, - context.im2col_step, - ) - - return grad_value, None, None, grad_sampling_loc, grad_attn_weight, None - - -class MultiScaleDeformableAttention(nn.Module): - def forward( - self, - value: Tensor, - value_spatial_shapes: Tensor, - value_spatial_shapes_list: List[Tuple], - level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - return MultiScaleDeformableAttentionFunction.apply( - value, - value_spatial_shapes, - level_start_index, - sampling_locations, - attention_weights, - im2col_step, - ) - - -__all__ = ["MultiScaleDeformableAttention"] diff --git a/build/torch28-cxx11-cu129-x86_64-linux/__init__.py b/build/torch28-cxx11-cu129-x86_64-linux/__init__.py deleted file mode 100644 index 33db73ca6e361af4707ba5bb5f55bf0e7c3005a4..0000000000000000000000000000000000000000 --- a/build/torch28-cxx11-cu129-x86_64-linux/__init__.py +++ /dev/null @@ -1,46 +0,0 @@ -from typing import List -import torch - -from ._ops import ops -from . import layers - - -def ms_deform_attn_backward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - grad_output: torch.Tensor, - im2col_step: int, -) -> List[torch.Tensor]: - return ops.ms_deform_attn_backward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - grad_output, - im2col_step, - ) - - -def ms_deform_attn_forward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - im2col_step: int, -) -> torch.Tensor: - return ops.ms_deform_attn_forward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - im2col_step, - ) - - -__all__ = ["layers", "ms_deform_attn_forward", "ms_deform_attn_backward"] diff --git a/build/torch28-cxx11-cu129-x86_64-linux/_deformable_detr_d7966ee.abi3.so b/build/torch28-cxx11-cu129-x86_64-linux/_deformable_detr_d7966ee.abi3.so deleted file mode 100644 index be60b895fec86b2ac0f8f4387d10002f63cf4c8f..0000000000000000000000000000000000000000 --- a/build/torch28-cxx11-cu129-x86_64-linux/_deformable_detr_d7966ee.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:4b38ea9a577233aee07a6417d5651076d27940a1a5b9b7edb89d1745a885b071 -size 11581544 diff --git a/build/torch28-cxx11-cu129-x86_64-linux/_ops.py b/build/torch28-cxx11-cu129-x86_64-linux/_ops.py deleted file mode 100644 index b498ff9a9fd0bc22a42440001932cf97a8a9e955..0000000000000000000000000000000000000000 --- a/build/torch28-cxx11-cu129-x86_64-linux/_ops.py +++ /dev/null @@ -1,9 +0,0 @@ -import torch -from . import _deformable_detr_d7966ee -ops = torch.ops._deformable_detr_d7966ee - -def add_op_namespace_prefix(op_name: str): - """ - Prefix op by namespace. - """ - return f"_deformable_detr_d7966ee::{op_name}" \ No newline at end of file diff --git a/build/torch28-cxx11-cu129-x86_64-linux/deformable_detr/__init__.py b/build/torch28-cxx11-cu129-x86_64-linux/deformable_detr/__init__.py deleted file mode 100644 index 03dbc1afe1cf156661a2b1b22003cd5f599a0309..0000000000000000000000000000000000000000 --- a/build/torch28-cxx11-cu129-x86_64-linux/deformable_detr/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -import ctypes -import sys - -import importlib -from pathlib import Path -from types import ModuleType - -def _import_from_path(file_path: Path) -> ModuleType: - # We cannot use the module name as-is, after adding it to `sys.modules`, - # it would also be used for other imports. So, we make a module name that - # depends on the path for it to be unique using the hex-encoded hash of - # the path. - path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value) - module_name = path_hash - spec = importlib.util.spec_from_file_location(module_name, file_path) - if spec is None: - raise ImportError(f"Cannot load spec for {module_name} from {file_path}") - module = importlib.util.module_from_spec(spec) - if module is None: - raise ImportError(f"Cannot load module {module_name} from spec") - sys.modules[module_name] = module - spec.loader.exec_module(module) # type: ignore - return module - - -globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py"))) diff --git a/build/torch28-cxx11-cu129-x86_64-linux/layers.py b/build/torch28-cxx11-cu129-x86_64-linux/layers.py deleted file mode 100644 index db94032dea3d445f27017f923ae80468e18d2d77..0000000000000000000000000000000000000000 --- a/build/torch28-cxx11-cu129-x86_64-linux/layers.py +++ /dev/null @@ -1,84 +0,0 @@ -from typing import List, Union, Tuple - -from torch import Tensor -from torch.autograd import Function -from torch.autograd.function import once_differentiable -import torch.nn as nn - -from ._ops import ops - - -class MultiScaleDeformableAttentionFunction(Function): - @staticmethod - def forward( - context, - value: Tensor, - value_spatial_shapes: Tensor, - value_level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - context.im2col_step = im2col_step - output = ops.ms_deform_attn_forward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - context.im2col_step, - ) - context.save_for_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) - return output - - @staticmethod - @once_differentiable - def backward(context, grad_output): - ( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) = context.saved_tensors - grad_value, grad_sampling_loc, grad_attn_weight = ops.ms_deform_attn_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - grad_output, - context.im2col_step, - ) - - return grad_value, None, None, grad_sampling_loc, grad_attn_weight, None - - -class MultiScaleDeformableAttention(nn.Module): - def forward( - self, - value: Tensor, - value_spatial_shapes: Tensor, - value_spatial_shapes_list: List[Tuple], - level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - return MultiScaleDeformableAttentionFunction.apply( - value, - value_spatial_shapes, - level_start_index, - sampling_locations, - attention_weights, - im2col_step, - ) - - -__all__ = ["MultiScaleDeformableAttention"] diff --git a/build/torch28-cxx11-cu129-x86_64-linux/metadata.json b/build/torch28-cxx11-cu129-x86_64-linux/metadata.json deleted file mode 100644 index 9cf5deed9898dce769f4cc73913d3530b92a0bd8..0000000000000000000000000000000000000000 --- a/build/torch28-cxx11-cu129-x86_64-linux/metadata.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "version": 1, - "python-depends": [] -} \ No newline at end of file diff --git a/build/torch29-cxx11-cu126-aarch64-linux/__init__.py b/build/torch29-cxx11-cu126-aarch64-linux/__init__.py deleted file mode 100644 index 33db73ca6e361af4707ba5bb5f55bf0e7c3005a4..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu126-aarch64-linux/__init__.py +++ /dev/null @@ -1,46 +0,0 @@ -from typing import List -import torch - -from ._ops import ops -from . import layers - - -def ms_deform_attn_backward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - grad_output: torch.Tensor, - im2col_step: int, -) -> List[torch.Tensor]: - return ops.ms_deform_attn_backward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - grad_output, - im2col_step, - ) - - -def ms_deform_attn_forward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - im2col_step: int, -) -> torch.Tensor: - return ops.ms_deform_attn_forward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - im2col_step, - ) - - -__all__ = ["layers", "ms_deform_attn_forward", "ms_deform_attn_backward"] diff --git a/build/torch29-cxx11-cu126-aarch64-linux/_deformable_detr_cuda_a06632f.abi3.so b/build/torch29-cxx11-cu126-aarch64-linux/_deformable_detr_cuda_a06632f.abi3.so deleted file mode 100644 index 097315236d6852aa1cf13eef398aafa6258dac7e..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu126-aarch64-linux/_deformable_detr_cuda_a06632f.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:e699c1c6b8c41b718c233089e16c5683fa782dd1b87e61e954941ab5f47d8341 -size 8604944 diff --git a/build/torch29-cxx11-cu126-aarch64-linux/_ops.py b/build/torch29-cxx11-cu126-aarch64-linux/_ops.py deleted file mode 100644 index b150fa4c35414012586d1ba33daac6779a49d93a..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu126-aarch64-linux/_ops.py +++ /dev/null @@ -1,9 +0,0 @@ -import torch -from . import _deformable_detr_cuda_a06632f -ops = torch.ops._deformable_detr_cuda_a06632f - -def add_op_namespace_prefix(op_name: str): - """ - Prefix op by namespace. - """ - return f"_deformable_detr_cuda_a06632f::{op_name}" diff --git a/build/torch29-cxx11-cu126-aarch64-linux/deformable_detr/__init__.py b/build/torch29-cxx11-cu126-aarch64-linux/deformable_detr/__init__.py deleted file mode 100644 index 03dbc1afe1cf156661a2b1b22003cd5f599a0309..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu126-aarch64-linux/deformable_detr/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -import ctypes -import sys - -import importlib -from pathlib import Path -from types import ModuleType - -def _import_from_path(file_path: Path) -> ModuleType: - # We cannot use the module name as-is, after adding it to `sys.modules`, - # it would also be used for other imports. So, we make a module name that - # depends on the path for it to be unique using the hex-encoded hash of - # the path. - path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value) - module_name = path_hash - spec = importlib.util.spec_from_file_location(module_name, file_path) - if spec is None: - raise ImportError(f"Cannot load spec for {module_name} from {file_path}") - module = importlib.util.module_from_spec(spec) - if module is None: - raise ImportError(f"Cannot load module {module_name} from spec") - sys.modules[module_name] = module - spec.loader.exec_module(module) # type: ignore - return module - - -globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py"))) diff --git a/build/torch29-cxx11-cu126-aarch64-linux/layers.py b/build/torch29-cxx11-cu126-aarch64-linux/layers.py deleted file mode 100644 index db94032dea3d445f27017f923ae80468e18d2d77..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu126-aarch64-linux/layers.py +++ /dev/null @@ -1,84 +0,0 @@ -from typing import List, Union, Tuple - -from torch import Tensor -from torch.autograd import Function -from torch.autograd.function import once_differentiable -import torch.nn as nn - -from ._ops import ops - - -class MultiScaleDeformableAttentionFunction(Function): - @staticmethod - def forward( - context, - value: Tensor, - value_spatial_shapes: Tensor, - value_level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - context.im2col_step = im2col_step - output = ops.ms_deform_attn_forward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - context.im2col_step, - ) - context.save_for_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) - return output - - @staticmethod - @once_differentiable - def backward(context, grad_output): - ( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) = context.saved_tensors - grad_value, grad_sampling_loc, grad_attn_weight = ops.ms_deform_attn_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - grad_output, - context.im2col_step, - ) - - return grad_value, None, None, grad_sampling_loc, grad_attn_weight, None - - -class MultiScaleDeformableAttention(nn.Module): - def forward( - self, - value: Tensor, - value_spatial_shapes: Tensor, - value_spatial_shapes_list: List[Tuple], - level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - return MultiScaleDeformableAttentionFunction.apply( - value, - value_spatial_shapes, - level_start_index, - sampling_locations, - attention_weights, - im2col_step, - ) - - -__all__ = ["MultiScaleDeformableAttention"] diff --git a/build/torch29-cxx11-cu126-aarch64-linux/metadata.json b/build/torch29-cxx11-cu126-aarch64-linux/metadata.json deleted file mode 100644 index f5902b55ab0b2b561c0cf97567c9806c60839c7f..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu126-aarch64-linux/metadata.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "version": 1, - "license": "Apache-2.0", - "python-depends": [], - "backend": { - "type": "cuda", - "archs": [ - "7.0", - "7.2", - "7.5", - "8.0", - "8.6", - "8.7", - "8.9", - "9.0+PTX" - ] - } -} diff --git a/build/torch29-cxx11-cu126-x86_64-linux/__init__.py b/build/torch29-cxx11-cu126-x86_64-linux/__init__.py deleted file mode 100644 index 33db73ca6e361af4707ba5bb5f55bf0e7c3005a4..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu126-x86_64-linux/__init__.py +++ /dev/null @@ -1,46 +0,0 @@ -from typing import List -import torch - -from ._ops import ops -from . import layers - - -def ms_deform_attn_backward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - grad_output: torch.Tensor, - im2col_step: int, -) -> List[torch.Tensor]: - return ops.ms_deform_attn_backward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - grad_output, - im2col_step, - ) - - -def ms_deform_attn_forward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - im2col_step: int, -) -> torch.Tensor: - return ops.ms_deform_attn_forward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - im2col_step, - ) - - -__all__ = ["layers", "ms_deform_attn_forward", "ms_deform_attn_backward"] diff --git a/build/torch29-cxx11-cu126-x86_64-linux/_deformable_detr_cuda_a06632f.abi3.so b/build/torch29-cxx11-cu126-x86_64-linux/_deformable_detr_cuda_a06632f.abi3.so deleted file mode 100644 index a404f522dd98443c7f9f6d2fb9df13ca99433b0c..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu126-x86_64-linux/_deformable_detr_cuda_a06632f.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c3165afbd76a4a3cdb1d23f014e551cb7d4a43286bbb4d356148f4efc232f6d2 -size 8535888 diff --git a/build/torch29-cxx11-cu126-x86_64-linux/_ops.py b/build/torch29-cxx11-cu126-x86_64-linux/_ops.py deleted file mode 100644 index b150fa4c35414012586d1ba33daac6779a49d93a..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu126-x86_64-linux/_ops.py +++ /dev/null @@ -1,9 +0,0 @@ -import torch -from . import _deformable_detr_cuda_a06632f -ops = torch.ops._deformable_detr_cuda_a06632f - -def add_op_namespace_prefix(op_name: str): - """ - Prefix op by namespace. - """ - return f"_deformable_detr_cuda_a06632f::{op_name}" diff --git a/build/torch29-cxx11-cu126-x86_64-linux/deformable_detr/__init__.py b/build/torch29-cxx11-cu126-x86_64-linux/deformable_detr/__init__.py deleted file mode 100644 index 03dbc1afe1cf156661a2b1b22003cd5f599a0309..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu126-x86_64-linux/deformable_detr/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -import ctypes -import sys - -import importlib -from pathlib import Path -from types import ModuleType - -def _import_from_path(file_path: Path) -> ModuleType: - # We cannot use the module name as-is, after adding it to `sys.modules`, - # it would also be used for other imports. So, we make a module name that - # depends on the path for it to be unique using the hex-encoded hash of - # the path. - path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value) - module_name = path_hash - spec = importlib.util.spec_from_file_location(module_name, file_path) - if spec is None: - raise ImportError(f"Cannot load spec for {module_name} from {file_path}") - module = importlib.util.module_from_spec(spec) - if module is None: - raise ImportError(f"Cannot load module {module_name} from spec") - sys.modules[module_name] = module - spec.loader.exec_module(module) # type: ignore - return module - - -globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py"))) diff --git a/build/torch29-cxx11-cu126-x86_64-linux/layers.py b/build/torch29-cxx11-cu126-x86_64-linux/layers.py deleted file mode 100644 index db94032dea3d445f27017f923ae80468e18d2d77..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu126-x86_64-linux/layers.py +++ /dev/null @@ -1,84 +0,0 @@ -from typing import List, Union, Tuple - -from torch import Tensor -from torch.autograd import Function -from torch.autograd.function import once_differentiable -import torch.nn as nn - -from ._ops import ops - - -class MultiScaleDeformableAttentionFunction(Function): - @staticmethod - def forward( - context, - value: Tensor, - value_spatial_shapes: Tensor, - value_level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - context.im2col_step = im2col_step - output = ops.ms_deform_attn_forward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - context.im2col_step, - ) - context.save_for_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) - return output - - @staticmethod - @once_differentiable - def backward(context, grad_output): - ( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) = context.saved_tensors - grad_value, grad_sampling_loc, grad_attn_weight = ops.ms_deform_attn_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - grad_output, - context.im2col_step, - ) - - return grad_value, None, None, grad_sampling_loc, grad_attn_weight, None - - -class MultiScaleDeformableAttention(nn.Module): - def forward( - self, - value: Tensor, - value_spatial_shapes: Tensor, - value_spatial_shapes_list: List[Tuple], - level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - return MultiScaleDeformableAttentionFunction.apply( - value, - value_spatial_shapes, - level_start_index, - sampling_locations, - attention_weights, - im2col_step, - ) - - -__all__ = ["MultiScaleDeformableAttention"] diff --git a/build/torch29-cxx11-cu126-x86_64-linux/metadata.json b/build/torch29-cxx11-cu126-x86_64-linux/metadata.json deleted file mode 100644 index f5902b55ab0b2b561c0cf97567c9806c60839c7f..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu126-x86_64-linux/metadata.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "version": 1, - "license": "Apache-2.0", - "python-depends": [], - "backend": { - "type": "cuda", - "archs": [ - "7.0", - "7.2", - "7.5", - "8.0", - "8.6", - "8.7", - "8.9", - "9.0+PTX" - ] - } -} diff --git a/build/torch29-cxx11-cu128-aarch64-linux/__init__.py b/build/torch29-cxx11-cu128-aarch64-linux/__init__.py deleted file mode 100644 index 33db73ca6e361af4707ba5bb5f55bf0e7c3005a4..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu128-aarch64-linux/__init__.py +++ /dev/null @@ -1,46 +0,0 @@ -from typing import List -import torch - -from ._ops import ops -from . import layers - - -def ms_deform_attn_backward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - grad_output: torch.Tensor, - im2col_step: int, -) -> List[torch.Tensor]: - return ops.ms_deform_attn_backward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - grad_output, - im2col_step, - ) - - -def ms_deform_attn_forward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - im2col_step: int, -) -> torch.Tensor: - return ops.ms_deform_attn_forward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - im2col_step, - ) - - -__all__ = ["layers", "ms_deform_attn_forward", "ms_deform_attn_backward"] diff --git a/build/torch29-cxx11-cu128-aarch64-linux/_deformable_detr_cuda_a06632f.abi3.so b/build/torch29-cxx11-cu128-aarch64-linux/_deformable_detr_cuda_a06632f.abi3.so deleted file mode 100644 index c35d7e717a3c4a8dc01bc49ee48ebe22d0899a68..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu128-aarch64-linux/_deformable_detr_cuda_a06632f.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:ee686cad364dc6a654fe2b43da0bf46fc1df3f3156dc1865a7e4811d811686e8 -size 11619232 diff --git a/build/torch29-cxx11-cu128-aarch64-linux/_ops.py b/build/torch29-cxx11-cu128-aarch64-linux/_ops.py deleted file mode 100644 index b150fa4c35414012586d1ba33daac6779a49d93a..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu128-aarch64-linux/_ops.py +++ /dev/null @@ -1,9 +0,0 @@ -import torch -from . import _deformable_detr_cuda_a06632f -ops = torch.ops._deformable_detr_cuda_a06632f - -def add_op_namespace_prefix(op_name: str): - """ - Prefix op by namespace. - """ - return f"_deformable_detr_cuda_a06632f::{op_name}" diff --git a/build/torch29-cxx11-cu128-aarch64-linux/deformable_detr/__init__.py b/build/torch29-cxx11-cu128-aarch64-linux/deformable_detr/__init__.py deleted file mode 100644 index 03dbc1afe1cf156661a2b1b22003cd5f599a0309..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu128-aarch64-linux/deformable_detr/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -import ctypes -import sys - -import importlib -from pathlib import Path -from types import ModuleType - -def _import_from_path(file_path: Path) -> ModuleType: - # We cannot use the module name as-is, after adding it to `sys.modules`, - # it would also be used for other imports. So, we make a module name that - # depends on the path for it to be unique using the hex-encoded hash of - # the path. - path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value) - module_name = path_hash - spec = importlib.util.spec_from_file_location(module_name, file_path) - if spec is None: - raise ImportError(f"Cannot load spec for {module_name} from {file_path}") - module = importlib.util.module_from_spec(spec) - if module is None: - raise ImportError(f"Cannot load module {module_name} from spec") - sys.modules[module_name] = module - spec.loader.exec_module(module) # type: ignore - return module - - -globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py"))) diff --git a/build/torch29-cxx11-cu128-aarch64-linux/layers.py b/build/torch29-cxx11-cu128-aarch64-linux/layers.py deleted file mode 100644 index db94032dea3d445f27017f923ae80468e18d2d77..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu128-aarch64-linux/layers.py +++ /dev/null @@ -1,84 +0,0 @@ -from typing import List, Union, Tuple - -from torch import Tensor -from torch.autograd import Function -from torch.autograd.function import once_differentiable -import torch.nn as nn - -from ._ops import ops - - -class MultiScaleDeformableAttentionFunction(Function): - @staticmethod - def forward( - context, - value: Tensor, - value_spatial_shapes: Tensor, - value_level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - context.im2col_step = im2col_step - output = ops.ms_deform_attn_forward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - context.im2col_step, - ) - context.save_for_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) - return output - - @staticmethod - @once_differentiable - def backward(context, grad_output): - ( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) = context.saved_tensors - grad_value, grad_sampling_loc, grad_attn_weight = ops.ms_deform_attn_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - grad_output, - context.im2col_step, - ) - - return grad_value, None, None, grad_sampling_loc, grad_attn_weight, None - - -class MultiScaleDeformableAttention(nn.Module): - def forward( - self, - value: Tensor, - value_spatial_shapes: Tensor, - value_spatial_shapes_list: List[Tuple], - level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - return MultiScaleDeformableAttentionFunction.apply( - value, - value_spatial_shapes, - level_start_index, - sampling_locations, - attention_weights, - im2col_step, - ) - - -__all__ = ["MultiScaleDeformableAttention"] diff --git a/build/torch29-cxx11-cu128-aarch64-linux/metadata.json b/build/torch29-cxx11-cu128-aarch64-linux/metadata.json deleted file mode 100644 index 8b796af185fbbd8594fcd846949aa5fadc0ccdda..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu128-aarch64-linux/metadata.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "version": 1, - "license": "Apache-2.0", - "python-depends": [], - "backend": { - "type": "cuda", - "archs": [ - "10.0", - "10.1", - "12.0+PTX", - "7.0", - "7.2", - "7.5", - "8.0", - "8.6", - "8.7", - "8.9", - "9.0" - ] - } -} diff --git a/build/torch29-cxx11-cu128-x86_64-linux/__init__.py b/build/torch29-cxx11-cu128-x86_64-linux/__init__.py deleted file mode 100644 index 33db73ca6e361af4707ba5bb5f55bf0e7c3005a4..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu128-x86_64-linux/__init__.py +++ /dev/null @@ -1,46 +0,0 @@ -from typing import List -import torch - -from ._ops import ops -from . import layers - - -def ms_deform_attn_backward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - grad_output: torch.Tensor, - im2col_step: int, -) -> List[torch.Tensor]: - return ops.ms_deform_attn_backward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - grad_output, - im2col_step, - ) - - -def ms_deform_attn_forward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - im2col_step: int, -) -> torch.Tensor: - return ops.ms_deform_attn_forward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - im2col_step, - ) - - -__all__ = ["layers", "ms_deform_attn_forward", "ms_deform_attn_backward"] diff --git a/build/torch29-cxx11-cu128-x86_64-linux/_deformable_detr_cuda_a06632f.abi3.so b/build/torch29-cxx11-cu128-x86_64-linux/_deformable_detr_cuda_a06632f.abi3.so deleted file mode 100644 index c66150f385ca1e7073cae942add6b6fceadd27d6..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu128-x86_64-linux/_deformable_detr_cuda_a06632f.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c851c52dba9eb591cfd264a8764b1880149fc40a94781c1e5bba5f3702b0cc22 -size 11519264 diff --git a/build/torch29-cxx11-cu128-x86_64-linux/_ops.py b/build/torch29-cxx11-cu128-x86_64-linux/_ops.py deleted file mode 100644 index b150fa4c35414012586d1ba33daac6779a49d93a..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu128-x86_64-linux/_ops.py +++ /dev/null @@ -1,9 +0,0 @@ -import torch -from . import _deformable_detr_cuda_a06632f -ops = torch.ops._deformable_detr_cuda_a06632f - -def add_op_namespace_prefix(op_name: str): - """ - Prefix op by namespace. - """ - return f"_deformable_detr_cuda_a06632f::{op_name}" diff --git a/build/torch29-cxx11-cu128-x86_64-linux/deformable_detr/__init__.py b/build/torch29-cxx11-cu128-x86_64-linux/deformable_detr/__init__.py deleted file mode 100644 index 03dbc1afe1cf156661a2b1b22003cd5f599a0309..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu128-x86_64-linux/deformable_detr/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -import ctypes -import sys - -import importlib -from pathlib import Path -from types import ModuleType - -def _import_from_path(file_path: Path) -> ModuleType: - # We cannot use the module name as-is, after adding it to `sys.modules`, - # it would also be used for other imports. So, we make a module name that - # depends on the path for it to be unique using the hex-encoded hash of - # the path. - path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value) - module_name = path_hash - spec = importlib.util.spec_from_file_location(module_name, file_path) - if spec is None: - raise ImportError(f"Cannot load spec for {module_name} from {file_path}") - module = importlib.util.module_from_spec(spec) - if module is None: - raise ImportError(f"Cannot load module {module_name} from spec") - sys.modules[module_name] = module - spec.loader.exec_module(module) # type: ignore - return module - - -globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py"))) diff --git a/build/torch29-cxx11-cu128-x86_64-linux/layers.py b/build/torch29-cxx11-cu128-x86_64-linux/layers.py deleted file mode 100644 index db94032dea3d445f27017f923ae80468e18d2d77..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu128-x86_64-linux/layers.py +++ /dev/null @@ -1,84 +0,0 @@ -from typing import List, Union, Tuple - -from torch import Tensor -from torch.autograd import Function -from torch.autograd.function import once_differentiable -import torch.nn as nn - -from ._ops import ops - - -class MultiScaleDeformableAttentionFunction(Function): - @staticmethod - def forward( - context, - value: Tensor, - value_spatial_shapes: Tensor, - value_level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - context.im2col_step = im2col_step - output = ops.ms_deform_attn_forward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - context.im2col_step, - ) - context.save_for_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) - return output - - @staticmethod - @once_differentiable - def backward(context, grad_output): - ( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) = context.saved_tensors - grad_value, grad_sampling_loc, grad_attn_weight = ops.ms_deform_attn_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - grad_output, - context.im2col_step, - ) - - return grad_value, None, None, grad_sampling_loc, grad_attn_weight, None - - -class MultiScaleDeformableAttention(nn.Module): - def forward( - self, - value: Tensor, - value_spatial_shapes: Tensor, - value_spatial_shapes_list: List[Tuple], - level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - return MultiScaleDeformableAttentionFunction.apply( - value, - value_spatial_shapes, - level_start_index, - sampling_locations, - attention_weights, - im2col_step, - ) - - -__all__ = ["MultiScaleDeformableAttention"] diff --git a/build/torch29-cxx11-cu128-x86_64-linux/metadata.json b/build/torch29-cxx11-cu128-x86_64-linux/metadata.json deleted file mode 100644 index 8b796af185fbbd8594fcd846949aa5fadc0ccdda..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu128-x86_64-linux/metadata.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "version": 1, - "license": "Apache-2.0", - "python-depends": [], - "backend": { - "type": "cuda", - "archs": [ - "10.0", - "10.1", - "12.0+PTX", - "7.0", - "7.2", - "7.5", - "8.0", - "8.6", - "8.7", - "8.9", - "9.0" - ] - } -} diff --git a/build/torch29-cxx11-cu129-aarch64-linux/__init__.py b/build/torch29-cxx11-cu129-aarch64-linux/__init__.py deleted file mode 100644 index 33db73ca6e361af4707ba5bb5f55bf0e7c3005a4..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu129-aarch64-linux/__init__.py +++ /dev/null @@ -1,46 +0,0 @@ -from typing import List -import torch - -from ._ops import ops -from . import layers - - -def ms_deform_attn_backward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - grad_output: torch.Tensor, - im2col_step: int, -) -> List[torch.Tensor]: - return ops.ms_deform_attn_backward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - grad_output, - im2col_step, - ) - - -def ms_deform_attn_forward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - im2col_step: int, -) -> torch.Tensor: - return ops.ms_deform_attn_forward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - im2col_step, - ) - - -__all__ = ["layers", "ms_deform_attn_forward", "ms_deform_attn_backward"] diff --git a/build/torch29-cxx11-cu129-aarch64-linux/_deformable_detr_cuda_9bd354b.abi3.so b/build/torch29-cxx11-cu129-aarch64-linux/_deformable_detr_cuda_9bd354b.abi3.so deleted file mode 100644 index ecc5bc73aac5d662f3cf8eb1591974c9ee1694a3..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu129-aarch64-linux/_deformable_detr_cuda_9bd354b.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:88a428301732c37004a22a9f6c185186080ad9cc8227c2cb8df81ccbcbef3f4b -size 11686192 diff --git a/build/torch29-cxx11-cu129-aarch64-linux/_ops.py b/build/torch29-cxx11-cu129-aarch64-linux/_ops.py deleted file mode 100644 index a711b4a8404ad6b007a926f2d2ec7add724e5cef..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu129-aarch64-linux/_ops.py +++ /dev/null @@ -1,9 +0,0 @@ -import torch -from . import _deformable_detr_cuda_9bd354b -ops = torch.ops._deformable_detr_cuda_9bd354b - -def add_op_namespace_prefix(op_name: str): - """ - Prefix op by namespace. - """ - return f"_deformable_detr_cuda_9bd354b::{op_name}" diff --git a/build/torch29-cxx11-cu129-aarch64-linux/deformable_detr/__init__.py b/build/torch29-cxx11-cu129-aarch64-linux/deformable_detr/__init__.py deleted file mode 100644 index a9b2672c1cd85b74c1b3ded0fc0b2100e1aeac23..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu129-aarch64-linux/deformable_detr/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -import ctypes -import importlib.util -import sys -from pathlib import Path -from types import ModuleType - - -def _import_from_path(file_path: Path) -> ModuleType: - # We cannot use the module name as-is, after adding it to `sys.modules`, - # it would also be used for other imports. So, we make a module name that - # depends on the path for it to be unique using the hex-encoded hash of - # the path. - path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value) - module_name = path_hash - spec = importlib.util.spec_from_file_location(module_name, file_path) - if spec is None: - raise ImportError(f"Cannot load spec for {module_name} from {file_path}") - module = importlib.util.module_from_spec(spec) - if module is None: - raise ImportError(f"Cannot load module {module_name} from spec") - sys.modules[module_name] = module - spec.loader.exec_module(module) # type: ignore - return module - - -globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py"))) diff --git a/build/torch29-cxx11-cu129-aarch64-linux/layers.py b/build/torch29-cxx11-cu129-aarch64-linux/layers.py deleted file mode 100644 index db94032dea3d445f27017f923ae80468e18d2d77..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu129-aarch64-linux/layers.py +++ /dev/null @@ -1,84 +0,0 @@ -from typing import List, Union, Tuple - -from torch import Tensor -from torch.autograd import Function -from torch.autograd.function import once_differentiable -import torch.nn as nn - -from ._ops import ops - - -class MultiScaleDeformableAttentionFunction(Function): - @staticmethod - def forward( - context, - value: Tensor, - value_spatial_shapes: Tensor, - value_level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - context.im2col_step = im2col_step - output = ops.ms_deform_attn_forward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - context.im2col_step, - ) - context.save_for_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) - return output - - @staticmethod - @once_differentiable - def backward(context, grad_output): - ( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) = context.saved_tensors - grad_value, grad_sampling_loc, grad_attn_weight = ops.ms_deform_attn_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - grad_output, - context.im2col_step, - ) - - return grad_value, None, None, grad_sampling_loc, grad_attn_weight, None - - -class MultiScaleDeformableAttention(nn.Module): - def forward( - self, - value: Tensor, - value_spatial_shapes: Tensor, - value_spatial_shapes_list: List[Tuple], - level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - return MultiScaleDeformableAttentionFunction.apply( - value, - value_spatial_shapes, - level_start_index, - sampling_locations, - attention_weights, - im2col_step, - ) - - -__all__ = ["MultiScaleDeformableAttention"] diff --git a/build/torch29-cxx11-cu129-aarch64-linux/metadata.json b/build/torch29-cxx11-cu129-aarch64-linux/metadata.json deleted file mode 100644 index 8b796af185fbbd8594fcd846949aa5fadc0ccdda..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu129-aarch64-linux/metadata.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "version": 1, - "license": "Apache-2.0", - "python-depends": [], - "backend": { - "type": "cuda", - "archs": [ - "10.0", - "10.1", - "12.0+PTX", - "7.0", - "7.2", - "7.5", - "8.0", - "8.6", - "8.7", - "8.9", - "9.0" - ] - } -} diff --git a/build/torch29-cxx11-cu129-x86_64-linux/__init__.py b/build/torch29-cxx11-cu129-x86_64-linux/__init__.py deleted file mode 100644 index 33db73ca6e361af4707ba5bb5f55bf0e7c3005a4..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu129-x86_64-linux/__init__.py +++ /dev/null @@ -1,46 +0,0 @@ -from typing import List -import torch - -from ._ops import ops -from . import layers - - -def ms_deform_attn_backward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - grad_output: torch.Tensor, - im2col_step: int, -) -> List[torch.Tensor]: - return ops.ms_deform_attn_backward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - grad_output, - im2col_step, - ) - - -def ms_deform_attn_forward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - im2col_step: int, -) -> torch.Tensor: - return ops.ms_deform_attn_forward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - im2col_step, - ) - - -__all__ = ["layers", "ms_deform_attn_forward", "ms_deform_attn_backward"] diff --git a/build/torch29-cxx11-cu129-x86_64-linux/_deformable_detr_cuda_9bd354b.abi3.so b/build/torch29-cxx11-cu129-x86_64-linux/_deformable_detr_cuda_9bd354b.abi3.so deleted file mode 100644 index 7ca8ee3172faa5d278d1c1b53525034fcd0e821e..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu129-x86_64-linux/_deformable_detr_cuda_9bd354b.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:3f5d2d09cbd071e6631352f43dd8d8965e6977d65d9f575d3afae41ef81b4899 -size 11581720 diff --git a/build/torch29-cxx11-cu129-x86_64-linux/_ops.py b/build/torch29-cxx11-cu129-x86_64-linux/_ops.py deleted file mode 100644 index a711b4a8404ad6b007a926f2d2ec7add724e5cef..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu129-x86_64-linux/_ops.py +++ /dev/null @@ -1,9 +0,0 @@ -import torch -from . import _deformable_detr_cuda_9bd354b -ops = torch.ops._deformable_detr_cuda_9bd354b - -def add_op_namespace_prefix(op_name: str): - """ - Prefix op by namespace. - """ - return f"_deformable_detr_cuda_9bd354b::{op_name}" diff --git a/build/torch29-cxx11-cu129-x86_64-linux/deformable_detr/__init__.py b/build/torch29-cxx11-cu129-x86_64-linux/deformable_detr/__init__.py deleted file mode 100644 index a9b2672c1cd85b74c1b3ded0fc0b2100e1aeac23..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu129-x86_64-linux/deformable_detr/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -import ctypes -import importlib.util -import sys -from pathlib import Path -from types import ModuleType - - -def _import_from_path(file_path: Path) -> ModuleType: - # We cannot use the module name as-is, after adding it to `sys.modules`, - # it would also be used for other imports. So, we make a module name that - # depends on the path for it to be unique using the hex-encoded hash of - # the path. - path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value) - module_name = path_hash - spec = importlib.util.spec_from_file_location(module_name, file_path) - if spec is None: - raise ImportError(f"Cannot load spec for {module_name} from {file_path}") - module = importlib.util.module_from_spec(spec) - if module is None: - raise ImportError(f"Cannot load module {module_name} from spec") - sys.modules[module_name] = module - spec.loader.exec_module(module) # type: ignore - return module - - -globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py"))) diff --git a/build/torch29-cxx11-cu129-x86_64-linux/layers.py b/build/torch29-cxx11-cu129-x86_64-linux/layers.py deleted file mode 100644 index db94032dea3d445f27017f923ae80468e18d2d77..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu129-x86_64-linux/layers.py +++ /dev/null @@ -1,84 +0,0 @@ -from typing import List, Union, Tuple - -from torch import Tensor -from torch.autograd import Function -from torch.autograd.function import once_differentiable -import torch.nn as nn - -from ._ops import ops - - -class MultiScaleDeformableAttentionFunction(Function): - @staticmethod - def forward( - context, - value: Tensor, - value_spatial_shapes: Tensor, - value_level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - context.im2col_step = im2col_step - output = ops.ms_deform_attn_forward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - context.im2col_step, - ) - context.save_for_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) - return output - - @staticmethod - @once_differentiable - def backward(context, grad_output): - ( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) = context.saved_tensors - grad_value, grad_sampling_loc, grad_attn_weight = ops.ms_deform_attn_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - grad_output, - context.im2col_step, - ) - - return grad_value, None, None, grad_sampling_loc, grad_attn_weight, None - - -class MultiScaleDeformableAttention(nn.Module): - def forward( - self, - value: Tensor, - value_spatial_shapes: Tensor, - value_spatial_shapes_list: List[Tuple], - level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - return MultiScaleDeformableAttentionFunction.apply( - value, - value_spatial_shapes, - level_start_index, - sampling_locations, - attention_weights, - im2col_step, - ) - - -__all__ = ["MultiScaleDeformableAttention"] diff --git a/build/torch29-cxx11-cu129-x86_64-linux/metadata.json b/build/torch29-cxx11-cu129-x86_64-linux/metadata.json deleted file mode 100644 index 8b796af185fbbd8594fcd846949aa5fadc0ccdda..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu129-x86_64-linux/metadata.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "version": 1, - "license": "Apache-2.0", - "python-depends": [], - "backend": { - "type": "cuda", - "archs": [ - "10.0", - "10.1", - "12.0+PTX", - "7.0", - "7.2", - "7.5", - "8.0", - "8.6", - "8.7", - "8.9", - "9.0" - ] - } -} diff --git a/build/torch29-cxx11-cu130-aarch64-linux/__init__.py b/build/torch29-cxx11-cu130-aarch64-linux/__init__.py deleted file mode 100644 index 33db73ca6e361af4707ba5bb5f55bf0e7c3005a4..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu130-aarch64-linux/__init__.py +++ /dev/null @@ -1,46 +0,0 @@ -from typing import List -import torch - -from ._ops import ops -from . import layers - - -def ms_deform_attn_backward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - grad_output: torch.Tensor, - im2col_step: int, -) -> List[torch.Tensor]: - return ops.ms_deform_attn_backward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - grad_output, - im2col_step, - ) - - -def ms_deform_attn_forward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - im2col_step: int, -) -> torch.Tensor: - return ops.ms_deform_attn_forward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - im2col_step, - ) - - -__all__ = ["layers", "ms_deform_attn_forward", "ms_deform_attn_backward"] diff --git a/build/torch29-cxx11-cu130-aarch64-linux/_deformable_detr_cuda_a06632f.abi3.so b/build/torch29-cxx11-cu130-aarch64-linux/_deformable_detr_cuda_a06632f.abi3.so deleted file mode 100644 index 2404e808024343acd3462674651dcfcdf9146404..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu130-aarch64-linux/_deformable_detr_cuda_a06632f.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f0ab087e15a52004500698e23cb707eaec57fa16de384ea5388e0a396318f088 -size 9888904 diff --git a/build/torch29-cxx11-cu130-aarch64-linux/_ops.py b/build/torch29-cxx11-cu130-aarch64-linux/_ops.py deleted file mode 100644 index b150fa4c35414012586d1ba33daac6779a49d93a..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu130-aarch64-linux/_ops.py +++ /dev/null @@ -1,9 +0,0 @@ -import torch -from . import _deformable_detr_cuda_a06632f -ops = torch.ops._deformable_detr_cuda_a06632f - -def add_op_namespace_prefix(op_name: str): - """ - Prefix op by namespace. - """ - return f"_deformable_detr_cuda_a06632f::{op_name}" diff --git a/build/torch29-cxx11-cu130-aarch64-linux/deformable_detr/__init__.py b/build/torch29-cxx11-cu130-aarch64-linux/deformable_detr/__init__.py deleted file mode 100644 index 03dbc1afe1cf156661a2b1b22003cd5f599a0309..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu130-aarch64-linux/deformable_detr/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -import ctypes -import sys - -import importlib -from pathlib import Path -from types import ModuleType - -def _import_from_path(file_path: Path) -> ModuleType: - # We cannot use the module name as-is, after adding it to `sys.modules`, - # it would also be used for other imports. So, we make a module name that - # depends on the path for it to be unique using the hex-encoded hash of - # the path. - path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value) - module_name = path_hash - spec = importlib.util.spec_from_file_location(module_name, file_path) - if spec is None: - raise ImportError(f"Cannot load spec for {module_name} from {file_path}") - module = importlib.util.module_from_spec(spec) - if module is None: - raise ImportError(f"Cannot load module {module_name} from spec") - sys.modules[module_name] = module - spec.loader.exec_module(module) # type: ignore - return module - - -globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py"))) diff --git a/build/torch29-cxx11-cu130-aarch64-linux/layers.py b/build/torch29-cxx11-cu130-aarch64-linux/layers.py deleted file mode 100644 index db94032dea3d445f27017f923ae80468e18d2d77..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu130-aarch64-linux/layers.py +++ /dev/null @@ -1,84 +0,0 @@ -from typing import List, Union, Tuple - -from torch import Tensor -from torch.autograd import Function -from torch.autograd.function import once_differentiable -import torch.nn as nn - -from ._ops import ops - - -class MultiScaleDeformableAttentionFunction(Function): - @staticmethod - def forward( - context, - value: Tensor, - value_spatial_shapes: Tensor, - value_level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - context.im2col_step = im2col_step - output = ops.ms_deform_attn_forward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - context.im2col_step, - ) - context.save_for_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) - return output - - @staticmethod - @once_differentiable - def backward(context, grad_output): - ( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) = context.saved_tensors - grad_value, grad_sampling_loc, grad_attn_weight = ops.ms_deform_attn_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - grad_output, - context.im2col_step, - ) - - return grad_value, None, None, grad_sampling_loc, grad_attn_weight, None - - -class MultiScaleDeformableAttention(nn.Module): - def forward( - self, - value: Tensor, - value_spatial_shapes: Tensor, - value_spatial_shapes_list: List[Tuple], - level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - return MultiScaleDeformableAttentionFunction.apply( - value, - value_spatial_shapes, - level_start_index, - sampling_locations, - attention_weights, - im2col_step, - ) - - -__all__ = ["MultiScaleDeformableAttention"] diff --git a/build/torch29-cxx11-cu130-aarch64-linux/metadata.json b/build/torch29-cxx11-cu130-aarch64-linux/metadata.json deleted file mode 100644 index 66651b7d3f95ac9e5ce5fc2a641b6f0f50788f87..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu130-aarch64-linux/metadata.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "version": 1, - "license": "Apache-2.0", - "python-depends": [], - "backend": { - "type": "cuda", - "archs": [ - "10.0", - "11.0", - "12.0+PTX", - "7.5", - "8.0", - "8.6", - "8.7", - "8.9", - "9.0" - ] - } -} diff --git a/build/torch29-cxx11-cu130-x86_64-linux/__init__.py b/build/torch29-cxx11-cu130-x86_64-linux/__init__.py deleted file mode 100644 index 33db73ca6e361af4707ba5bb5f55bf0e7c3005a4..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu130-x86_64-linux/__init__.py +++ /dev/null @@ -1,46 +0,0 @@ -from typing import List -import torch - -from ._ops import ops -from . import layers - - -def ms_deform_attn_backward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - grad_output: torch.Tensor, - im2col_step: int, -) -> List[torch.Tensor]: - return ops.ms_deform_attn_backward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - grad_output, - im2col_step, - ) - - -def ms_deform_attn_forward( - value: torch.Tensor, - spatial_shapes: torch.Tensor, - level_start_index: torch.Tensor, - sampling_loc: torch.Tensor, - attn_weight: torch.Tensor, - im2col_step: int, -) -> torch.Tensor: - return ops.ms_deform_attn_forward( - value, - spatial_shapes, - level_start_index, - sampling_loc, - attn_weight, - im2col_step, - ) - - -__all__ = ["layers", "ms_deform_attn_forward", "ms_deform_attn_backward"] diff --git a/build/torch29-cxx11-cu130-x86_64-linux/_deformable_detr_cuda_a06632f.abi3.so b/build/torch29-cxx11-cu130-x86_64-linux/_deformable_detr_cuda_a06632f.abi3.so deleted file mode 100644 index 6c6e678cc4f728eabb7c7458f8e574884a33d02a..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu130-x86_64-linux/_deformable_detr_cuda_a06632f.abi3.so +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:40af5d2edddffdf5c91a80083c35ceaacdcc6d08e1208bd85c78b4b533e11643 -size 9803064 diff --git a/build/torch29-cxx11-cu130-x86_64-linux/_ops.py b/build/torch29-cxx11-cu130-x86_64-linux/_ops.py deleted file mode 100644 index b150fa4c35414012586d1ba33daac6779a49d93a..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu130-x86_64-linux/_ops.py +++ /dev/null @@ -1,9 +0,0 @@ -import torch -from . import _deformable_detr_cuda_a06632f -ops = torch.ops._deformable_detr_cuda_a06632f - -def add_op_namespace_prefix(op_name: str): - """ - Prefix op by namespace. - """ - return f"_deformable_detr_cuda_a06632f::{op_name}" diff --git a/build/torch29-cxx11-cu130-x86_64-linux/deformable_detr/__init__.py b/build/torch29-cxx11-cu130-x86_64-linux/deformable_detr/__init__.py deleted file mode 100644 index 03dbc1afe1cf156661a2b1b22003cd5f599a0309..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu130-x86_64-linux/deformable_detr/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -import ctypes -import sys - -import importlib -from pathlib import Path -from types import ModuleType - -def _import_from_path(file_path: Path) -> ModuleType: - # We cannot use the module name as-is, after adding it to `sys.modules`, - # it would also be used for other imports. So, we make a module name that - # depends on the path for it to be unique using the hex-encoded hash of - # the path. - path_hash = "{:x}".format(ctypes.c_size_t(hash(file_path.absolute())).value) - module_name = path_hash - spec = importlib.util.spec_from_file_location(module_name, file_path) - if spec is None: - raise ImportError(f"Cannot load spec for {module_name} from {file_path}") - module = importlib.util.module_from_spec(spec) - if module is None: - raise ImportError(f"Cannot load module {module_name} from spec") - sys.modules[module_name] = module - spec.loader.exec_module(module) # type: ignore - return module - - -globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py"))) diff --git a/build/torch29-cxx11-cu130-x86_64-linux/layers.py b/build/torch29-cxx11-cu130-x86_64-linux/layers.py deleted file mode 100644 index db94032dea3d445f27017f923ae80468e18d2d77..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu130-x86_64-linux/layers.py +++ /dev/null @@ -1,84 +0,0 @@ -from typing import List, Union, Tuple - -from torch import Tensor -from torch.autograd import Function -from torch.autograd.function import once_differentiable -import torch.nn as nn - -from ._ops import ops - - -class MultiScaleDeformableAttentionFunction(Function): - @staticmethod - def forward( - context, - value: Tensor, - value_spatial_shapes: Tensor, - value_level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - context.im2col_step = im2col_step - output = ops.ms_deform_attn_forward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - context.im2col_step, - ) - context.save_for_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) - return output - - @staticmethod - @once_differentiable - def backward(context, grad_output): - ( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - ) = context.saved_tensors - grad_value, grad_sampling_loc, grad_attn_weight = ops.ms_deform_attn_backward( - value, - value_spatial_shapes, - value_level_start_index, - sampling_locations, - attention_weights, - grad_output, - context.im2col_step, - ) - - return grad_value, None, None, grad_sampling_loc, grad_attn_weight, None - - -class MultiScaleDeformableAttention(nn.Module): - def forward( - self, - value: Tensor, - value_spatial_shapes: Tensor, - value_spatial_shapes_list: List[Tuple], - level_start_index: Tensor, - sampling_locations: Tensor, - attention_weights: Tensor, - im2col_step: int, - ): - return MultiScaleDeformableAttentionFunction.apply( - value, - value_spatial_shapes, - level_start_index, - sampling_locations, - attention_weights, - im2col_step, - ) - - -__all__ = ["MultiScaleDeformableAttention"] diff --git a/build/torch29-cxx11-cu130-x86_64-linux/metadata.json b/build/torch29-cxx11-cu130-x86_64-linux/metadata.json deleted file mode 100644 index 66651b7d3f95ac9e5ce5fc2a641b6f0f50788f87..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu130-x86_64-linux/metadata.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "version": 1, - "license": "Apache-2.0", - "python-depends": [], - "backend": { - "type": "cuda", - "archs": [ - "10.0", - "11.0", - "12.0+PTX", - "7.5", - "8.0", - "8.6", - "8.7", - "8.9", - "9.0" - ] - } -} diff --git a/deformable_detr/ms_deform_attn_cuda.cu b/deformable_detr/ms_deform_attn_cuda.cu new file mode 100644 index 0000000000000000000000000000000000000000..b9d6cc74146f22fa8cc0826ab1299a6c90c73014 --- /dev/null +++ b/deformable_detr/ms_deform_attn_cuda.cu @@ -0,0 +1,158 @@ +/*! +************************************************************************************************** +* Deformable DETR +* Copyright (c) 2020 SenseTime. All Rights Reserved. +* Licensed under the Apache License, Version 2.0 [see LICENSE for details] +************************************************************************************************** +* Modified from https://github.com/chengdazhi/Deformable-Convolution-V2-PyTorch/tree/pytorch_1.0.0 +************************************************************************************************** +*/ + +#include +#include "deformable_detr/ms_deform_im2col_cuda.cuh" + +#include +#include +#include +#include + +#include + + +at::Tensor ms_deform_attn_cuda_forward( + const at::Tensor &value, + const at::Tensor &spatial_shapes, + const at::Tensor &level_start_index, + const at::Tensor &sampling_loc, + const at::Tensor &attn_weight, + const int64_t 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"); + AT_ASSERTM(sampling_loc.is_contiguous(), "sampling_loc tensor has to be contiguous"); + AT_ASSERTM(attn_weight.is_contiguous(), "attn_weight tensor has to be contiguous"); + + AT_ASSERTM(value.is_cuda(), "value must be a CUDA tensor"); + AT_ASSERTM(spatial_shapes.is_cuda(), "spatial_shapes must be a CUDA tensor"); + AT_ASSERTM(level_start_index.is_cuda(), "level_start_index must be a CUDA tensor"); + AT_ASSERTM(sampling_loc.is_cuda(), "sampling_loc must be a CUDA tensor"); + AT_ASSERTM(attn_weight.is_cuda(), "attn_weight must be a CUDA tensor"); + + const int batch = value.size(0); + const int spatial_size = value.size(1); + const int num_heads = value.size(2); + const int channels = value.size(3); + + const int num_levels = spatial_shapes.size(0); + + const int num_query = sampling_loc.size(1); + const int num_point = sampling_loc.size(4); + + const int im2col_step_ = std::min(batch, static_cast(im2col_step)); + + AT_ASSERTM(batch % im2col_step_ == 0, "batch(%d) must divide im2col_step(%d)", batch, im2col_step_); + + auto output = at::zeros({batch, num_query, num_heads, channels}, value.options()); + + const int batch_n = im2col_step_; + auto output_n = output.view({batch/im2col_step_, batch_n, num_query, num_heads, channels}); + auto per_value_size = spatial_size * num_heads * channels; + auto per_sample_loc_size = num_query * num_heads * num_levels * num_point * 2; + auto per_attn_weight_size = num_query * num_heads * num_levels * num_point; + for (int n = 0; n < batch/im2col_step_; ++n) + { + auto columns = output_n.select(0, n); + AT_DISPATCH_FLOATING_TYPES_AND2(at::ScalarType::Half, at::ScalarType::BFloat16, value.scalar_type(), "ms_deform_attn_forward_cuda", ([&] { + ms_deformable_im2col_cuda(at::cuda::getCurrentCUDAStream(), + value.data_ptr() + n * im2col_step_ * per_value_size, + spatial_shapes.data_ptr(), + level_start_index.data_ptr(), + sampling_loc.data_ptr() + n * im2col_step_ * per_sample_loc_size, + attn_weight.data_ptr() + n * im2col_step_ * per_attn_weight_size, + batch_n, spatial_size, num_heads, channels, num_levels, num_query, num_point, + columns.data_ptr()); + + })); + } + + output = output.view({batch, num_query, num_heads*channels}); + + return output; +} + + +std::vector ms_deform_attn_cuda_backward( + const at::Tensor &value, + const at::Tensor &spatial_shapes, + const at::Tensor &level_start_index, + const at::Tensor &sampling_loc, + const at::Tensor &attn_weight, + const at::Tensor &grad_output, + const int64_t 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"); + AT_ASSERTM(sampling_loc.is_contiguous(), "sampling_loc tensor has to be contiguous"); + AT_ASSERTM(attn_weight.is_contiguous(), "attn_weight tensor has to be contiguous"); + AT_ASSERTM(grad_output.is_contiguous(), "grad_output tensor has to be contiguous"); + + AT_ASSERTM(value.is_cuda(), "value must be a CUDA tensor"); + AT_ASSERTM(spatial_shapes.is_cuda(), "spatial_shapes must be a CUDA tensor"); + AT_ASSERTM(level_start_index.is_cuda(), "level_start_index must be a CUDA tensor"); + AT_ASSERTM(sampling_loc.is_cuda(), "sampling_loc must be a CUDA tensor"); + AT_ASSERTM(attn_weight.is_cuda(), "attn_weight must be a CUDA tensor"); + AT_ASSERTM(grad_output.is_cuda(), "grad_output must be a CUDA tensor"); + + const int batch = value.size(0); + const int spatial_size = value.size(1); + const int num_heads = value.size(2); + const int channels = value.size(3); + + const int num_levels = spatial_shapes.size(0); + + const int num_query = sampling_loc.size(1); + const int num_point = sampling_loc.size(4); + + const int im2col_step_ = std::min(batch, static_cast(im2col_step)); + + AT_ASSERTM(batch % im2col_step_ == 0, "batch(%d) must divide im2col_step(%d)", batch, im2col_step_); + + auto grad_value = at::zeros_like(value); + auto grad_sampling_loc = at::zeros_like(sampling_loc); + auto grad_attn_weight = at::zeros_like(attn_weight); + + const int batch_n = im2col_step_; + auto per_value_size = spatial_size * num_heads * channels; + auto per_sample_loc_size = num_query * num_heads * num_levels * num_point * 2; + auto per_attn_weight_size = num_query * num_heads * num_levels * num_point; + auto grad_output_n = grad_output.view({batch/im2col_step_, batch_n, num_query, num_heads, channels}); + + for (int n = 0; n < batch/im2col_step_; ++n) + { + auto grad_output_g = grad_output_n.select(0, n); + AT_DISPATCH_FLOATING_TYPES_AND2(at::ScalarType::Half, at::ScalarType::BFloat16, value.scalar_type(), "ms_deform_attn_backward_cuda", ([&] { + ms_deformable_col2im_cuda(at::cuda::getCurrentCUDAStream(), + grad_output_g.data_ptr(), + value.data_ptr() + n * im2col_step_ * per_value_size, + spatial_shapes.data_ptr(), + level_start_index.data_ptr(), + sampling_loc.data_ptr() + n * im2col_step_ * per_sample_loc_size, + attn_weight.data_ptr() + n * im2col_step_ * per_attn_weight_size, + batch_n, spatial_size, num_heads, channels, num_levels, num_query, num_point, + grad_value.data_ptr() + n * im2col_step_ * per_value_size, + grad_sampling_loc.data_ptr() + n * im2col_step_ * per_sample_loc_size, + grad_attn_weight.data_ptr() + n * im2col_step_ * per_attn_weight_size); + + })); + } + + return { + grad_value, grad_sampling_loc, grad_attn_weight + }; +} diff --git a/deformable_detr/ms_deform_attn_cuda.cuh b/deformable_detr/ms_deform_attn_cuda.cuh new file mode 100644 index 0000000000000000000000000000000000000000..20ae6892e4b9881578a72aae27ddc4ec9f68ae1c --- /dev/null +++ b/deformable_detr/ms_deform_attn_cuda.cuh @@ -0,0 +1,1467 @@ +/*! +************************************************************************************************** +* Deformable DETR +* Copyright (c) 2020 SenseTime. All Rights Reserved. +* Licensed under the Apache License, Version 2.0 [see LICENSE for details] +************************************************************************************************** +* Modified from https://github.com/chengdazhi/Deformable-Convolution-V2-PyTorch/tree/pytorch_1.0.0 +************************************************************************************************** +*/ + +#include + +#include +#include + +#include +#include +#include + +#include +#include + +#include + +#define CUDA_KERNEL_LOOP(i, n) \ + for (int i = blockIdx.x * blockDim.x + threadIdx.x; \ + i < (n); \ + i += blockDim.x * gridDim.x) + + +at::Tensor ms_deform_attn_cuda_forward( + const at::Tensor &value, + const at::Tensor &spatial_shapes, + const at::Tensor &level_start_index, + const at::Tensor &sampling_loc, + const at::Tensor &attn_weight, + const int im2col_step) +{ + 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"); + AT_ASSERTM(sampling_loc.is_contiguous(), "sampling_loc tensor has to be contiguous"); + AT_ASSERTM(attn_weight.is_contiguous(), "attn_weight tensor has to be contiguous"); + + AT_ASSERTM(value.is_cuda(), "value must be a CUDA tensor"); + AT_ASSERTM(spatial_shapes.is_cuda(), "spatial_shapes must be a CUDA tensor"); + AT_ASSERTM(level_start_index.is_cuda(), "level_start_index must be a CUDA tensor"); + AT_ASSERTM(sampling_loc.is_cuda(), "sampling_loc must be a CUDA tensor"); + AT_ASSERTM(attn_weight.is_cuda(), "attn_weight must be a CUDA tensor"); + + const int batch = value.size(0); + const int spatial_size = value.size(1); + const int num_heads = value.size(2); + const int channels = value.size(3); + + const int num_levels = spatial_shapes.size(0); + + const int num_query = sampling_loc.size(1); + const int num_point = sampling_loc.size(4); + + const int im2col_step_ = std::min(batch, im2col_step); + + AT_ASSERTM(batch % im2col_step_ == 0, "batch(%d) must divide im2col_step(%d)", batch, im2col_step_); + + auto output = at::zeros({batch, num_query, num_heads, channels}, value.options()); + + const int batch_n = im2col_step_; + auto output_n = output.view({batch/im2col_step_, batch_n, num_query, num_heads, channels}); + auto per_value_size = spatial_size * num_heads * channels; + auto per_sample_loc_size = num_query * num_heads * num_levels * num_point * 2; + auto per_attn_weight_size = num_query * num_heads * num_levels * num_point; + for (int n = 0; n < batch/im2col_step_; ++n) + { + auto columns = output_n.select(0, n); + AT_DISPATCH_FLOATING_TYPES_AND2(at::ScalarType::Half, at::ScalarType::BFloat16, value.scalar_type(), "ms_deform_attn_forward_cuda", ([&] { + ms_deformable_im2col_cuda(at::cuda::getCurrentCUDAStream(), + value.data_ptr() + n * im2col_step_ * per_value_size, + spatial_shapes.data_ptr(), + level_start_index.data_ptr(), + sampling_loc.data_ptr() + n * im2col_step_ * per_sample_loc_size, + attn_weight.data_ptr() + n * im2col_step_ * per_attn_weight_size, + batch_n, spatial_size, num_heads, channels, num_levels, num_query, num_point, + columns.data_ptr()); + + })); + } + + output = output.view({batch, num_query, num_heads*channels}); + + return output; +} + + +std::vector ms_deform_attn_cuda_backward( + const at::Tensor &value, + const at::Tensor &spatial_shapes, + const at::Tensor &level_start_index, + const at::Tensor &sampling_loc, + const at::Tensor &attn_weight, + const at::Tensor &grad_output, + const int im2col_step) +{ + + 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"); + AT_ASSERTM(sampling_loc.is_contiguous(), "sampling_loc tensor has to be contiguous"); + AT_ASSERTM(attn_weight.is_contiguous(), "attn_weight tensor has to be contiguous"); + AT_ASSERTM(grad_output.is_contiguous(), "grad_output tensor has to be contiguous"); + + AT_ASSERTM(value.is_cuda(), "value must be a CUDA tensor"); + AT_ASSERTM(spatial_shapes.is_cuda(), "spatial_shapes must be a CUDA tensor"); + AT_ASSERTM(level_start_index.is_cuda(), "level_start_index must be a CUDA tensor"); + AT_ASSERTM(sampling_loc.is_cuda(), "sampling_loc must be a CUDA tensor"); + AT_ASSERTM(attn_weight.is_cuda(), "attn_weight must be a CUDA tensor"); + AT_ASSERTM(grad_output.is_cuda(), "grad_output must be a CUDA tensor"); + + const int batch = value.size(0); + const int spatial_size = value.size(1); + const int num_heads = value.size(2); + const int channels = value.size(3); + + const int num_levels = spatial_shapes.size(0); + + const int num_query = sampling_loc.size(1); + const int num_point = sampling_loc.size(4); + + const int im2col_step_ = std::min(batch, im2col_step); + + AT_ASSERTM(batch % im2col_step_ == 0, "batch(%d) must divide im2col_step(%d)", batch, im2col_step_); + + auto grad_value = at::zeros_like(value); + auto grad_sampling_loc = at::zeros_like(sampling_loc); + auto grad_attn_weight = at::zeros_like(attn_weight); + + const int batch_n = im2col_step_; + auto per_value_size = spatial_size * num_heads * channels; + auto per_sample_loc_size = num_query * num_heads * num_levels * num_point * 2; + auto per_attn_weight_size = num_query * num_heads * num_levels * num_point; + auto grad_output_n = grad_output.view({batch/im2col_step_, batch_n, num_query, num_heads, channels}); + + for (int n = 0; n < batch/im2col_step_; ++n) + { + auto grad_output_g = grad_output_n.select(0, n); + AT_DISPATCH_FLOATING_TYPES_AND2(at::ScalarType::Half, at::ScalarType::BFloat16, value.scalar_type(), "ms_deform_attn_backward_cuda", ([&] { + ms_deformable_col2im_cuda(at::cuda::getCurrentCUDAStream(), + grad_output_g.data_ptr(), + value.data_ptr() + n * im2col_step_ * per_value_size, + spatial_shapes.data_ptr(), + level_start_index.data_ptr(), + sampling_loc.data_ptr() + n * im2col_step_ * per_sample_loc_size, + attn_weight.data_ptr() + n * im2col_step_ * per_attn_weight_size, + batch_n, spatial_size, num_heads, channels, num_levels, num_query, num_point, + grad_value.data_ptr() + n * im2col_step_ * per_value_size, + grad_sampling_loc.data_ptr() + n * im2col_step_ * per_sample_loc_size, + grad_attn_weight.data_ptr() + n * im2col_step_ * per_attn_weight_size); + + })); + } + + return { + grad_value, grad_sampling_loc, grad_attn_weight + }; +} + +const int CUDA_NUM_THREADS = 1024; +inline int GET_BLOCKS(const int N, const int num_threads) +{ + return (N + num_threads - 1) / num_threads; +} + + +template +__device__ scalar_t ms_deform_attn_im2col_bilinear(const scalar_t* &bottom_data, + const int &height, const int &width, const int &nheads, const int &channels, + const scalar_t &h, const scalar_t &w, const int &m, const int &c) +{ + const int h_low = floor(h); + const int w_low = floor(w); + const int h_high = h_low + 1; + const int w_high = w_low + 1; + + const scalar_t lh = h - h_low; + const scalar_t lw = w - w_low; + const scalar_t hh = 1 - lh, hw = 1 - lw; + + const int w_stride = nheads * channels; + const int h_stride = width * w_stride; + const int h_low_ptr_offset = h_low * h_stride; + const int h_high_ptr_offset = h_low_ptr_offset + h_stride; + const int w_low_ptr_offset = w_low * w_stride; + const int w_high_ptr_offset = w_low_ptr_offset + w_stride; + const int base_ptr = m * channels + c; + + scalar_t v1 = 0; + if (h_low >= 0 && w_low >= 0) + { + const int ptr1 = h_low_ptr_offset + w_low_ptr_offset + base_ptr; + v1 = bottom_data[ptr1]; + } + scalar_t v2 = 0; + if (h_low >= 0 && w_high <= width - 1) + { + const int ptr2 = h_low_ptr_offset + w_high_ptr_offset + base_ptr; + v2 = bottom_data[ptr2]; + } + scalar_t v3 = 0; + if (h_high <= height - 1 && w_low >= 0) + { + const int ptr3 = h_high_ptr_offset + w_low_ptr_offset + base_ptr; + v3 = bottom_data[ptr3]; + } + scalar_t v4 = 0; + if (h_high <= height - 1 && w_high <= width - 1) + { + const int ptr4 = h_high_ptr_offset + w_high_ptr_offset + base_ptr; + v4 = bottom_data[ptr4]; + } + + const scalar_t w1 = hh * hw, w2 = hh * lw, w3 = lh * hw, w4 = lh * lw; + + const scalar_t val = (w1 * v1 + w2 * v2 + w3 * v3 + w4 * v4); + return val; +} + + +template +__device__ void ms_deform_attn_col2im_bilinear(const scalar_t* &bottom_data, + const int &height, const int &width, const int &nheads, const int &channels, + const scalar_t &h, const scalar_t &w, const int &m, const int &c, + const scalar_t &top_grad, + const scalar_t &attn_weight, + scalar_t* &grad_value, + scalar_t* grad_sampling_loc, + scalar_t* grad_attn_weight) +{ + const int h_low = floor(h); + const int w_low = floor(w); + const int h_high = h_low + 1; + const int w_high = w_low + 1; + + const scalar_t lh = h - h_low; + const scalar_t lw = w - w_low; + const scalar_t hh = 1 - lh, hw = 1 - lw; + + const int w_stride = nheads * channels; + const int h_stride = width * w_stride; + const int h_low_ptr_offset = h_low * h_stride; + const int h_high_ptr_offset = h_low_ptr_offset + h_stride; + const int w_low_ptr_offset = w_low * w_stride; + const int w_high_ptr_offset = w_low_ptr_offset + w_stride; + const int base_ptr = m * channels + c; + + const scalar_t w1 = hh * hw, w2 = hh * lw, w3 = lh * hw, w4 = lh * lw; + const scalar_t top_grad_value = top_grad * attn_weight; + scalar_t grad_h_weight = 0, grad_w_weight = 0; + + scalar_t v1 = 0; + if (h_low >= 0 && w_low >= 0) + { + const int ptr1 = h_low_ptr_offset + w_low_ptr_offset + base_ptr; + v1 = bottom_data[ptr1]; + grad_h_weight -= hw * v1; + grad_w_weight -= hh * v1; + atomicAdd(grad_value+ptr1, w1*top_grad_value); + } + scalar_t v2 = 0; + if (h_low >= 0 && w_high <= width - 1) + { + const int ptr2 = h_low_ptr_offset + w_high_ptr_offset + base_ptr; + v2 = bottom_data[ptr2]; + grad_h_weight -= lw * v2; + grad_w_weight += hh * v2; + atomicAdd(grad_value+ptr2, w2*top_grad_value); + } + scalar_t v3 = 0; + if (h_high <= height - 1 && w_low >= 0) + { + const int ptr3 = h_high_ptr_offset + w_low_ptr_offset + base_ptr; + v3 = bottom_data[ptr3]; + grad_h_weight += hw * v3; + grad_w_weight -= lh * v3; + atomicAdd(grad_value+ptr3, w3*top_grad_value); + } + scalar_t v4 = 0; + if (h_high <= height - 1 && w_high <= width - 1) + { + const int ptr4 = h_high_ptr_offset + w_high_ptr_offset + base_ptr; + v4 = bottom_data[ptr4]; + grad_h_weight += lw * v4; + grad_w_weight += lh * v4; + atomicAdd(grad_value+ptr4, w4*top_grad_value); + } + + const scalar_t val = (w1 * v1 + w2 * v2 + w3 * v3 + w4 * v4); + *grad_attn_weight = top_grad * val; + *grad_sampling_loc = width * grad_w_weight * top_grad_value; + *(grad_sampling_loc + 1) = height * grad_h_weight * top_grad_value; +} + + +template +__device__ void ms_deform_attn_col2im_bilinear_gm(const scalar_t* &bottom_data, + const int &height, const int &width, const int &nheads, const int &channels, + const scalar_t &h, const scalar_t &w, const int &m, const int &c, + const scalar_t &top_grad, + const scalar_t &attn_weight, + scalar_t* &grad_value, + scalar_t* grad_sampling_loc, + scalar_t* grad_attn_weight) +{ + const int h_low = floor(h); + const int w_low = floor(w); + const int h_high = h_low + 1; + const int w_high = w_low + 1; + + const scalar_t lh = h - h_low; + const scalar_t lw = w - w_low; + const scalar_t hh = 1 - lh, hw = 1 - lw; + + const int w_stride = nheads * channels; + const int h_stride = width * w_stride; + const int h_low_ptr_offset = h_low * h_stride; + const int h_high_ptr_offset = h_low_ptr_offset + h_stride; + const int w_low_ptr_offset = w_low * w_stride; + const int w_high_ptr_offset = w_low_ptr_offset + w_stride; + const int base_ptr = m * channels + c; + + const scalar_t w1 = hh * hw, w2 = hh * lw, w3 = lh * hw, w4 = lh * lw; + const scalar_t top_grad_value = top_grad * attn_weight; + scalar_t grad_h_weight = 0, grad_w_weight = 0; + + scalar_t v1 = 0; + if (h_low >= 0 && w_low >= 0) + { + const int ptr1 = h_low_ptr_offset + w_low_ptr_offset + base_ptr; + v1 = bottom_data[ptr1]; + grad_h_weight -= hw * v1; + grad_w_weight -= hh * v1; + atomicAdd(grad_value+ptr1, w1*top_grad_value); + } + scalar_t v2 = 0; + if (h_low >= 0 && w_high <= width - 1) + { + const int ptr2 = h_low_ptr_offset + w_high_ptr_offset + base_ptr; + v2 = bottom_data[ptr2]; + grad_h_weight -= lw * v2; + grad_w_weight += hh * v2; + atomicAdd(grad_value+ptr2, w2*top_grad_value); + } + scalar_t v3 = 0; + if (h_high <= height - 1 && w_low >= 0) + { + const int ptr3 = h_high_ptr_offset + w_low_ptr_offset + base_ptr; + v3 = bottom_data[ptr3]; + grad_h_weight += hw * v3; + grad_w_weight -= lh * v3; + atomicAdd(grad_value+ptr3, w3*top_grad_value); + } + scalar_t v4 = 0; + if (h_high <= height - 1 && w_high <= width - 1) + { + const int ptr4 = h_high_ptr_offset + w_high_ptr_offset + base_ptr; + v4 = bottom_data[ptr4]; + grad_h_weight += lw * v4; + grad_w_weight += lh * v4; + atomicAdd(grad_value+ptr4, w4*top_grad_value); + } + + const scalar_t val = (w1 * v1 + w2 * v2 + w3 * v3 + w4 * v4); + atomicAdd(grad_attn_weight, top_grad * val); + atomicAdd(grad_sampling_loc, width * grad_w_weight * top_grad_value); + atomicAdd(grad_sampling_loc + 1, height * grad_h_weight * top_grad_value); +} + + +template +__global__ void ms_deformable_im2col_gpu_kernel(const int n, + const scalar_t *data_value, + const int64_t *data_spatial_shapes, + const int64_t *data_level_start_index, + const scalar_t *data_sampling_loc, + const scalar_t *data_attn_weight, + const int batch_size, + const int spatial_size, + const int num_heads, + const int channels, + const int num_levels, + const int num_query, + const int num_point, + scalar_t *data_col) +{ + CUDA_KERNEL_LOOP(index, n) + { + int _temp = index; + const int c_col = _temp % channels; + _temp /= channels; + const int sampling_index = _temp; + const int m_col = _temp % num_heads; + _temp /= num_heads; + [[maybe_unused]] const int q_col = _temp % num_query; + _temp /= num_query; + const int b_col = _temp; + + scalar_t *data_col_ptr = data_col + index; + int data_weight_ptr = sampling_index * num_levels * num_point; + int data_loc_w_ptr = data_weight_ptr << 1; + const int qid_stride = num_heads * channels; + const int data_value_ptr_init_offset = b_col * spatial_size * qid_stride; + scalar_t col = 0; + + for (int l_col=0; l_col < num_levels; ++l_col) + { + const int level_start_id = data_level_start_index[l_col]; + const int spatial_h_ptr = l_col << 1; + const int spatial_h = data_spatial_shapes[spatial_h_ptr]; + const int spatial_w = data_spatial_shapes[spatial_h_ptr + 1]; + const scalar_t *data_value_ptr = data_value + (data_value_ptr_init_offset + level_start_id * qid_stride); + for (int p_col=0; p_col < num_point; ++p_col) + { + const scalar_t loc_w = data_sampling_loc[data_loc_w_ptr]; + const scalar_t loc_h = data_sampling_loc[data_loc_w_ptr + 1]; + const scalar_t weight = data_attn_weight[data_weight_ptr]; + + const scalar_t h_im = loc_h * spatial_h - 0.5; + const scalar_t w_im = loc_w * spatial_w - 0.5; + + if (h_im > -1 && w_im > -1 && h_im < spatial_h && w_im < spatial_w) + { + col += ms_deform_attn_im2col_bilinear(data_value_ptr, spatial_h, spatial_w, num_heads, channels, h_im, w_im, m_col, c_col) * weight; + } + + data_weight_ptr += 1; + data_loc_w_ptr += 2; + } + } + *data_col_ptr = col; + } +} + +template +__global__ void ms_deformable_col2im_gpu_kernel_shm_blocksize_aware_reduce_v1(const int n, + const scalar_t *grad_col, + const scalar_t *data_value, + const int64_t *data_spatial_shapes, + const int64_t *data_level_start_index, + const scalar_t *data_sampling_loc, + const scalar_t *data_attn_weight, + const int batch_size, + const int spatial_size, + const int num_heads, + const int channels, + const int num_levels, + const int num_query, + const int num_point, + scalar_t *grad_value, + scalar_t *grad_sampling_loc, + scalar_t *grad_attn_weight) +{ + CUDA_KERNEL_LOOP(index, n) + { + __shared__ scalar_t cache_grad_sampling_loc[blockSize * 2]; + __shared__ scalar_t cache_grad_attn_weight[blockSize]; + unsigned int tid = threadIdx.x; + int _temp = index; + const int c_col = _temp % channels; + _temp /= channels; + const int sampling_index = _temp; + const int m_col = _temp % num_heads; + _temp /= num_heads; + [[maybe_unused]] const int q_col = _temp % num_query; + _temp /= num_query; + const int b_col = _temp; + + const scalar_t top_grad = grad_col[index]; + + int data_weight_ptr = sampling_index * num_levels * num_point; + int data_loc_w_ptr = data_weight_ptr << 1; + const int grad_sampling_ptr = data_weight_ptr; + grad_sampling_loc += grad_sampling_ptr << 1; + grad_attn_weight += grad_sampling_ptr; + const int grad_weight_stride = 1; + const int grad_loc_stride = 2; + const int qid_stride = num_heads * channels; + const int data_value_ptr_init_offset = b_col * spatial_size * qid_stride; + + for (int l_col=0; l_col < num_levels; ++l_col) + { + const int level_start_id = data_level_start_index[l_col]; + const int spatial_h_ptr = l_col << 1; + const int spatial_h = data_spatial_shapes[spatial_h_ptr]; + const int spatial_w = data_spatial_shapes[spatial_h_ptr + 1]; + const int value_ptr_offset = data_value_ptr_init_offset + level_start_id * qid_stride; + const scalar_t *data_value_ptr = data_value + value_ptr_offset; + scalar_t *grad_value_ptr = grad_value + value_ptr_offset; + + for (int p_col=0; p_col < num_point; ++p_col) + { + const scalar_t loc_w = data_sampling_loc[data_loc_w_ptr]; + const scalar_t loc_h = data_sampling_loc[data_loc_w_ptr + 1]; + const scalar_t weight = data_attn_weight[data_weight_ptr]; + + const scalar_t h_im = loc_h * spatial_h - 0.5; + const scalar_t w_im = loc_w * spatial_w - 0.5; + *(cache_grad_sampling_loc+(threadIdx.x << 1)) = 0; + *(cache_grad_sampling_loc+((threadIdx.x << 1) + 1)) = 0; + *(cache_grad_attn_weight+threadIdx.x)=0; + if (h_im > -1 && w_im > -1 && h_im < spatial_h && w_im < spatial_w) + { + ms_deform_attn_col2im_bilinear( + data_value_ptr, spatial_h, spatial_w, num_heads, channels, h_im, w_im, m_col, c_col, + top_grad, weight, grad_value_ptr, + cache_grad_sampling_loc+(threadIdx.x << 1), cache_grad_attn_weight+threadIdx.x); + } + + __syncthreads(); + if (tid == 0) + { + scalar_t _grad_w=cache_grad_sampling_loc[0], _grad_h=cache_grad_sampling_loc[1], _grad_a=cache_grad_attn_weight[0]; + int sid=2; + for (unsigned int tid = 1; tid < blockSize; ++tid) + { + _grad_w += cache_grad_sampling_loc[sid]; + _grad_h += cache_grad_sampling_loc[sid + 1]; + _grad_a += cache_grad_attn_weight[tid]; + sid += 2; + } + + + *grad_sampling_loc = _grad_w; + *(grad_sampling_loc + 1) = _grad_h; + *grad_attn_weight = _grad_a; + } + __syncthreads(); + + data_weight_ptr += 1; + data_loc_w_ptr += 2; + grad_attn_weight += grad_weight_stride; + grad_sampling_loc += grad_loc_stride; + } + } + } +} + + +template +__global__ void ms_deformable_col2im_gpu_kernel_shm_blocksize_aware_reduce_v2(const int n, + const scalar_t *grad_col, + const scalar_t *data_value, + const int64_t *data_spatial_shapes, + const int64_t *data_level_start_index, + const scalar_t *data_sampling_loc, + const scalar_t *data_attn_weight, + const int batch_size, + const int spatial_size, + const int num_heads, + const int channels, + const int num_levels, + const int num_query, + const int num_point, + scalar_t *grad_value, + scalar_t *grad_sampling_loc, + scalar_t *grad_attn_weight) +{ + CUDA_KERNEL_LOOP(index, n) + { + __shared__ scalar_t cache_grad_sampling_loc[blockSize * 2]; + __shared__ scalar_t cache_grad_attn_weight[blockSize]; + unsigned int tid = threadIdx.x; + int _temp = index; + const int c_col = _temp % channels; + _temp /= channels; + const int sampling_index = _temp; + const int m_col = _temp % num_heads; + _temp /= num_heads; + [[maybe_unused]] const int q_col = _temp % num_query; + _temp /= num_query; + const int b_col = _temp; + + const scalar_t top_grad = grad_col[index]; + + int data_weight_ptr = sampling_index * num_levels * num_point; + int data_loc_w_ptr = data_weight_ptr << 1; + const int grad_sampling_ptr = data_weight_ptr; + grad_sampling_loc += grad_sampling_ptr << 1; + grad_attn_weight += grad_sampling_ptr; + const int grad_weight_stride = 1; + const int grad_loc_stride = 2; + const int qid_stride = num_heads * channels; + const int data_value_ptr_init_offset = b_col * spatial_size * qid_stride; + + for (int l_col=0; l_col < num_levels; ++l_col) + { + const int level_start_id = data_level_start_index[l_col]; + const int spatial_h_ptr = l_col << 1; + const int spatial_h = data_spatial_shapes[spatial_h_ptr]; + const int spatial_w = data_spatial_shapes[spatial_h_ptr + 1]; + const int value_ptr_offset = data_value_ptr_init_offset + level_start_id * qid_stride; + const scalar_t *data_value_ptr = data_value + value_ptr_offset; + scalar_t *grad_value_ptr = grad_value + value_ptr_offset; + + for (int p_col=0; p_col < num_point; ++p_col) + { + const scalar_t loc_w = data_sampling_loc[data_loc_w_ptr]; + const scalar_t loc_h = data_sampling_loc[data_loc_w_ptr + 1]; + const scalar_t weight = data_attn_weight[data_weight_ptr]; + + const scalar_t h_im = loc_h * spatial_h - 0.5; + const scalar_t w_im = loc_w * spatial_w - 0.5; + *(cache_grad_sampling_loc+(threadIdx.x << 1)) = 0; + *(cache_grad_sampling_loc+((threadIdx.x << 1) + 1)) = 0; + *(cache_grad_attn_weight+threadIdx.x)=0; + if (h_im > -1 && w_im > -1 && h_im < spatial_h && w_im < spatial_w) + { + ms_deform_attn_col2im_bilinear( + data_value_ptr, spatial_h, spatial_w, num_heads, channels, h_im, w_im, m_col, c_col, + top_grad, weight, grad_value_ptr, + cache_grad_sampling_loc+(threadIdx.x << 1), cache_grad_attn_weight+threadIdx.x); + } + + __syncthreads(); + + for (unsigned int s=blockSize/2; s>0; s>>=1) + { + if (tid < s) { + const unsigned int xid1 = tid << 1; + const unsigned int xid2 = (tid + s) << 1; + cache_grad_attn_weight[tid] += cache_grad_attn_weight[tid + s]; + cache_grad_sampling_loc[xid1] += cache_grad_sampling_loc[xid2]; + cache_grad_sampling_loc[xid1 + 1] += cache_grad_sampling_loc[xid2 + 1]; + } + __syncthreads(); + } + + if (tid == 0) + { + *grad_sampling_loc = cache_grad_sampling_loc[0]; + *(grad_sampling_loc + 1) = cache_grad_sampling_loc[1]; + *grad_attn_weight = cache_grad_attn_weight[0]; + } + __syncthreads(); + + data_weight_ptr += 1; + data_loc_w_ptr += 2; + grad_attn_weight += grad_weight_stride; + grad_sampling_loc += grad_loc_stride; + } + } + } +} + + +template +__global__ void ms_deformable_col2im_gpu_kernel_shm_reduce_v1(const int n, + const scalar_t *grad_col, + const scalar_t *data_value, + const int64_t *data_spatial_shapes, + const int64_t *data_level_start_index, + const scalar_t *data_sampling_loc, + const scalar_t *data_attn_weight, + const int batch_size, + const int spatial_size, + const int num_heads, + const int channels, + const int num_levels, + const int num_query, + const int num_point, + scalar_t *grad_value, + scalar_t *grad_sampling_loc, + scalar_t *grad_attn_weight) +{ + CUDA_KERNEL_LOOP(index, n) + { + extern __shared__ int _s[]; + scalar_t* cache_grad_sampling_loc = (scalar_t*)_s; + scalar_t* cache_grad_attn_weight = cache_grad_sampling_loc + 2 * blockDim.x; + unsigned int tid = threadIdx.x; + int _temp = index; + const int c_col = _temp % channels; + _temp /= channels; + const int sampling_index = _temp; + const int m_col = _temp % num_heads; + _temp /= num_heads; + [[maybe_unused]] const int q_col = _temp % num_query; + _temp /= num_query; + const int b_col = _temp; + + const scalar_t top_grad = grad_col[index]; + + int data_weight_ptr = sampling_index * num_levels * num_point; + int data_loc_w_ptr = data_weight_ptr << 1; + const int grad_sampling_ptr = data_weight_ptr; + grad_sampling_loc += grad_sampling_ptr << 1; + grad_attn_weight += grad_sampling_ptr; + const int grad_weight_stride = 1; + const int grad_loc_stride = 2; + const int qid_stride = num_heads * channels; + const int data_value_ptr_init_offset = b_col * spatial_size * qid_stride; + + for (int l_col=0; l_col < num_levels; ++l_col) + { + const int level_start_id = data_level_start_index[l_col]; + const int spatial_h_ptr = l_col << 1; + const int spatial_h = data_spatial_shapes[spatial_h_ptr]; + const int spatial_w = data_spatial_shapes[spatial_h_ptr + 1]; + const int value_ptr_offset = data_value_ptr_init_offset + level_start_id * qid_stride; + const scalar_t *data_value_ptr = data_value + value_ptr_offset; + scalar_t *grad_value_ptr = grad_value + value_ptr_offset; + + for (int p_col=0; p_col < num_point; ++p_col) + { + const scalar_t loc_w = data_sampling_loc[data_loc_w_ptr]; + const scalar_t loc_h = data_sampling_loc[data_loc_w_ptr + 1]; + const scalar_t weight = data_attn_weight[data_weight_ptr]; + + const scalar_t h_im = loc_h * spatial_h - 0.5; + const scalar_t w_im = loc_w * spatial_w - 0.5; + *(cache_grad_sampling_loc+(threadIdx.x << 1)) = 0; + *(cache_grad_sampling_loc+((threadIdx.x << 1) + 1)) = 0; + *(cache_grad_attn_weight+threadIdx.x)=0; + if (h_im > -1 && w_im > -1 && h_im < spatial_h && w_im < spatial_w) + { + ms_deform_attn_col2im_bilinear( + data_value_ptr, spatial_h, spatial_w, num_heads, channels, h_im, w_im, m_col, c_col, + top_grad, weight, grad_value_ptr, + cache_grad_sampling_loc+(threadIdx.x << 1), cache_grad_attn_weight+threadIdx.x); + } + + __syncthreads(); + if (tid == 0) + { + scalar_t _grad_w=cache_grad_sampling_loc[0], _grad_h=cache_grad_sampling_loc[1], _grad_a=cache_grad_attn_weight[0]; + int sid=2; + for (unsigned int tid = 1; tid < blockDim.x; ++tid) + { + _grad_w += cache_grad_sampling_loc[sid]; + _grad_h += cache_grad_sampling_loc[sid + 1]; + _grad_a += cache_grad_attn_weight[tid]; + sid += 2; + } + + + *grad_sampling_loc = _grad_w; + *(grad_sampling_loc + 1) = _grad_h; + *grad_attn_weight = _grad_a; + } + __syncthreads(); + + data_weight_ptr += 1; + data_loc_w_ptr += 2; + grad_attn_weight += grad_weight_stride; + grad_sampling_loc += grad_loc_stride; + } + } + } +} + +template +__global__ void ms_deformable_col2im_gpu_kernel_shm_reduce_v2(const int n, + const scalar_t *grad_col, + const scalar_t *data_value, + const int64_t *data_spatial_shapes, + const int64_t *data_level_start_index, + const scalar_t *data_sampling_loc, + const scalar_t *data_attn_weight, + const int batch_size, + const int spatial_size, + const int num_heads, + const int channels, + const int num_levels, + const int num_query, + const int num_point, + scalar_t *grad_value, + scalar_t *grad_sampling_loc, + scalar_t *grad_attn_weight) +{ + CUDA_KERNEL_LOOP(index, n) + { + extern __shared__ int _s[]; + scalar_t* cache_grad_sampling_loc = (scalar_t*)_s; + scalar_t* cache_grad_attn_weight = cache_grad_sampling_loc + 2 * blockDim.x; + unsigned int tid = threadIdx.x; + int _temp = index; + const int c_col = _temp % channels; + _temp /= channels; + const int sampling_index = _temp; + const int m_col = _temp % num_heads; + _temp /= num_heads; + [[maybe_unused]] const int q_col = _temp % num_query; + _temp /= num_query; + const int b_col = _temp; + + const scalar_t top_grad = grad_col[index]; + + int data_weight_ptr = sampling_index * num_levels * num_point; + int data_loc_w_ptr = data_weight_ptr << 1; + const int grad_sampling_ptr = data_weight_ptr; + grad_sampling_loc += grad_sampling_ptr << 1; + grad_attn_weight += grad_sampling_ptr; + const int grad_weight_stride = 1; + const int grad_loc_stride = 2; + const int qid_stride = num_heads * channels; + const int data_value_ptr_init_offset = b_col * spatial_size * qid_stride; + + for (int l_col=0; l_col < num_levels; ++l_col) + { + const int level_start_id = data_level_start_index[l_col]; + const int spatial_h_ptr = l_col << 1; + const int spatial_h = data_spatial_shapes[spatial_h_ptr]; + const int spatial_w = data_spatial_shapes[spatial_h_ptr + 1]; + const int value_ptr_offset = data_value_ptr_init_offset + level_start_id * qid_stride; + const scalar_t *data_value_ptr = data_value + value_ptr_offset; + scalar_t *grad_value_ptr = grad_value + value_ptr_offset; + + for (int p_col=0; p_col < num_point; ++p_col) + { + const scalar_t loc_w = data_sampling_loc[data_loc_w_ptr]; + const scalar_t loc_h = data_sampling_loc[data_loc_w_ptr + 1]; + const scalar_t weight = data_attn_weight[data_weight_ptr]; + + const scalar_t h_im = loc_h * spatial_h - 0.5; + const scalar_t w_im = loc_w * spatial_w - 0.5; + *(cache_grad_sampling_loc+(threadIdx.x << 1)) = 0; + *(cache_grad_sampling_loc+((threadIdx.x << 1) + 1)) = 0; + *(cache_grad_attn_weight+threadIdx.x)=0; + if (h_im > -1 && w_im > -1 && h_im < spatial_h && w_im < spatial_w) + { + ms_deform_attn_col2im_bilinear( + data_value_ptr, spatial_h, spatial_w, num_heads, channels, h_im, w_im, m_col, c_col, + top_grad, weight, grad_value_ptr, + cache_grad_sampling_loc+(threadIdx.x << 1), cache_grad_attn_weight+threadIdx.x); + } + + __syncthreads(); + + for (unsigned int s=blockDim.x/2, spre=blockDim.x; s>0; s>>=1, spre>>=1) + { + if (tid < s) { + const unsigned int xid1 = tid << 1; + const unsigned int xid2 = (tid + s) << 1; + cache_grad_attn_weight[tid] += cache_grad_attn_weight[tid + s]; + cache_grad_sampling_loc[xid1] += cache_grad_sampling_loc[xid2]; + cache_grad_sampling_loc[xid1 + 1] += cache_grad_sampling_loc[xid2 + 1]; + if (tid + (s << 1) < spre) + { + cache_grad_attn_weight[tid] += cache_grad_attn_weight[tid + (s << 1)]; + cache_grad_sampling_loc[xid1] += cache_grad_sampling_loc[xid2 + (s << 1)]; + cache_grad_sampling_loc[xid1 + 1] += cache_grad_sampling_loc[xid2 + 1 + (s << 1)]; + } + } + __syncthreads(); + } + + if (tid == 0) + { + *grad_sampling_loc = cache_grad_sampling_loc[0]; + *(grad_sampling_loc + 1) = cache_grad_sampling_loc[1]; + *grad_attn_weight = cache_grad_attn_weight[0]; + } + __syncthreads(); + + data_weight_ptr += 1; + data_loc_w_ptr += 2; + grad_attn_weight += grad_weight_stride; + grad_sampling_loc += grad_loc_stride; + } + } + } +} + +template +__global__ void ms_deformable_col2im_gpu_kernel_shm_reduce_v2_multi_blocks(const int n, + const scalar_t *grad_col, + const scalar_t *data_value, + const int64_t *data_spatial_shapes, + const int64_t *data_level_start_index, + const scalar_t *data_sampling_loc, + const scalar_t *data_attn_weight, + const int batch_size, + const int spatial_size, + const int num_heads, + const int channels, + const int num_levels, + const int num_query, + const int num_point, + scalar_t *grad_value, + scalar_t *grad_sampling_loc, + scalar_t *grad_attn_weight) +{ + CUDA_KERNEL_LOOP(index, n) + { + extern __shared__ int _s[]; + scalar_t* cache_grad_sampling_loc = (scalar_t*)_s; + scalar_t* cache_grad_attn_weight = cache_grad_sampling_loc + 2 * blockDim.x; + unsigned int tid = threadIdx.x; + int _temp = index; + const int c_col = _temp % channels; + _temp /= channels; + const int sampling_index = _temp; + const int m_col = _temp % num_heads; + _temp /= num_heads; + [[maybe_unused]] const int q_col = _temp % num_query; + _temp /= num_query; + const int b_col = _temp; + + const scalar_t top_grad = grad_col[index]; + + int data_weight_ptr = sampling_index * num_levels * num_point; + int data_loc_w_ptr = data_weight_ptr << 1; + const int grad_sampling_ptr = data_weight_ptr; + grad_sampling_loc += grad_sampling_ptr << 1; + grad_attn_weight += grad_sampling_ptr; + const int grad_weight_stride = 1; + const int grad_loc_stride = 2; + const int qid_stride = num_heads * channels; + const int data_value_ptr_init_offset = b_col * spatial_size * qid_stride; + + for (int l_col=0; l_col < num_levels; ++l_col) + { + const int level_start_id = data_level_start_index[l_col]; + const int spatial_h_ptr = l_col << 1; + const int spatial_h = data_spatial_shapes[spatial_h_ptr]; + const int spatial_w = data_spatial_shapes[spatial_h_ptr + 1]; + const int value_ptr_offset = data_value_ptr_init_offset + level_start_id * qid_stride; + const scalar_t *data_value_ptr = data_value + value_ptr_offset; + scalar_t *grad_value_ptr = grad_value + value_ptr_offset; + + for (int p_col=0; p_col < num_point; ++p_col) + { + const scalar_t loc_w = data_sampling_loc[data_loc_w_ptr]; + const scalar_t loc_h = data_sampling_loc[data_loc_w_ptr + 1]; + const scalar_t weight = data_attn_weight[data_weight_ptr]; + + const scalar_t h_im = loc_h * spatial_h - 0.5; + const scalar_t w_im = loc_w * spatial_w - 0.5; + *(cache_grad_sampling_loc+(threadIdx.x << 1)) = 0; + *(cache_grad_sampling_loc+((threadIdx.x << 1) + 1)) = 0; + *(cache_grad_attn_weight+threadIdx.x)=0; + if (h_im > -1 && w_im > -1 && h_im < spatial_h && w_im < spatial_w) + { + ms_deform_attn_col2im_bilinear( + data_value_ptr, spatial_h, spatial_w, num_heads, channels, h_im, w_im, m_col, c_col, + top_grad, weight, grad_value_ptr, + cache_grad_sampling_loc+(threadIdx.x << 1), cache_grad_attn_weight+threadIdx.x); + } + + __syncthreads(); + + for (unsigned int s=blockDim.x/2, spre=blockDim.x; s>0; s>>=1, spre>>=1) + { + if (tid < s) { + const unsigned int xid1 = tid << 1; + const unsigned int xid2 = (tid + s) << 1; + cache_grad_attn_weight[tid] += cache_grad_attn_weight[tid + s]; + cache_grad_sampling_loc[xid1] += cache_grad_sampling_loc[xid2]; + cache_grad_sampling_loc[xid1 + 1] += cache_grad_sampling_loc[xid2 + 1]; + if (tid + (s << 1) < spre) + { + cache_grad_attn_weight[tid] += cache_grad_attn_weight[tid + (s << 1)]; + cache_grad_sampling_loc[xid1] += cache_grad_sampling_loc[xid2 + (s << 1)]; + cache_grad_sampling_loc[xid1 + 1] += cache_grad_sampling_loc[xid2 + 1 + (s << 1)]; + } + } + __syncthreads(); + } + + if (tid == 0) + { + atomicAdd(grad_sampling_loc, cache_grad_sampling_loc[0]); + atomicAdd(grad_sampling_loc + 1, cache_grad_sampling_loc[1]); + atomicAdd(grad_attn_weight, cache_grad_attn_weight[0]); + } + __syncthreads(); + + data_weight_ptr += 1; + data_loc_w_ptr += 2; + grad_attn_weight += grad_weight_stride; + grad_sampling_loc += grad_loc_stride; + } + } + } +} + + +template +__global__ void ms_deformable_col2im_gpu_kernel_gm(const int n, + const scalar_t *grad_col, + const scalar_t *data_value, + const int64_t *data_spatial_shapes, + const int64_t *data_level_start_index, + const scalar_t *data_sampling_loc, + const scalar_t *data_attn_weight, + const int batch_size, + const int spatial_size, + const int num_heads, + const int channels, + const int num_levels, + const int num_query, + const int num_point, + scalar_t *grad_value, + scalar_t *grad_sampling_loc, + scalar_t *grad_attn_weight) +{ + CUDA_KERNEL_LOOP(index, n) + { + int _temp = index; + const int c_col = _temp % channels; + _temp /= channels; + const int sampling_index = _temp; + const int m_col = _temp % num_heads; + _temp /= num_heads; + [[maybe_unused]] const int q_col = _temp % num_query; + _temp /= num_query; + const int b_col = _temp; + + const scalar_t top_grad = grad_col[index]; + + int data_weight_ptr = sampling_index * num_levels * num_point; + int data_loc_w_ptr = data_weight_ptr << 1; + const int grad_sampling_ptr = data_weight_ptr; + grad_sampling_loc += grad_sampling_ptr << 1; + grad_attn_weight += grad_sampling_ptr; + const int grad_weight_stride = 1; + const int grad_loc_stride = 2; + const int qid_stride = num_heads * channels; + const int data_value_ptr_init_offset = b_col * spatial_size * qid_stride; + + for (int l_col=0; l_col < num_levels; ++l_col) + { + const int level_start_id = data_level_start_index[l_col]; + const int spatial_h_ptr = l_col << 1; + const int spatial_h = data_spatial_shapes[spatial_h_ptr]; + const int spatial_w = data_spatial_shapes[spatial_h_ptr + 1]; + const int value_ptr_offset = data_value_ptr_init_offset + level_start_id * qid_stride; + const scalar_t *data_value_ptr = data_value + value_ptr_offset; + scalar_t *grad_value_ptr = grad_value + value_ptr_offset; + + for (int p_col=0; p_col < num_point; ++p_col) + { + const scalar_t loc_w = data_sampling_loc[data_loc_w_ptr]; + const scalar_t loc_h = data_sampling_loc[data_loc_w_ptr + 1]; + const scalar_t weight = data_attn_weight[data_weight_ptr]; + + const scalar_t h_im = loc_h * spatial_h - 0.5; + const scalar_t w_im = loc_w * spatial_w - 0.5; + if (h_im > -1 && w_im > -1 && h_im < spatial_h && w_im < spatial_w) + { + ms_deform_attn_col2im_bilinear_gm( + data_value_ptr, spatial_h, spatial_w, num_heads, channels, h_im, w_im, m_col, c_col, + top_grad, weight, grad_value_ptr, + grad_sampling_loc, grad_attn_weight); + } + data_weight_ptr += 1; + data_loc_w_ptr += 2; + grad_attn_weight += grad_weight_stride; + grad_sampling_loc += grad_loc_stride; + } + } + } +} + + +template +void ms_deformable_im2col_cuda(cudaStream_t stream, + const scalar_t* data_value, + const int64_t* data_spatial_shapes, + const int64_t* data_level_start_index, + const scalar_t* data_sampling_loc, + const scalar_t* data_attn_weight, + const int batch_size, + const int spatial_size, + const int num_heads, + const int channels, + const int num_levels, + const int num_query, + const int num_point, + scalar_t* data_col) +{ + const int num_kernels = batch_size * num_query * num_heads * channels; + const int num_actual_kernels = batch_size * num_query * num_heads * channels; + const int num_threads = CUDA_NUM_THREADS; + ms_deformable_im2col_gpu_kernel + <<>>( + num_kernels, data_value, data_spatial_shapes, data_level_start_index, data_sampling_loc, data_attn_weight, + batch_size, spatial_size, num_heads, channels, num_levels, num_query, num_point, data_col); + + cudaError_t err = cudaGetLastError(); + if (err != cudaSuccess) + { + printf("error in ms_deformable_im2col_cuda: %s\n", cudaGetErrorString(err)); + } + +} + +template +void ms_deformable_col2im_cuda(cudaStream_t stream, + const scalar_t* grad_col, + const scalar_t* data_value, + const int64_t * data_spatial_shapes, + const int64_t * data_level_start_index, + const scalar_t * data_sampling_loc, + const scalar_t * data_attn_weight, + const int batch_size, + const int spatial_size, + const int num_heads, + const int channels, + const int num_levels, + const int num_query, + const int num_point, + scalar_t* grad_value, + scalar_t* grad_sampling_loc, + scalar_t* grad_attn_weight) +{ + const int num_threads = (channels > CUDA_NUM_THREADS)?CUDA_NUM_THREADS:channels; + const int num_kernels = batch_size * num_query * num_heads * channels; + const int num_actual_kernels = batch_size * num_query * num_heads * channels; + if (channels > 1024) + { + if ((channels & 1023) == 0) + { + ms_deformable_col2im_gpu_kernel_shm_reduce_v2_multi_blocks + <<>>( + num_kernels, + grad_col, + data_value, + data_spatial_shapes, + data_level_start_index, + data_sampling_loc, + data_attn_weight, + batch_size, + spatial_size, + num_heads, + channels, + num_levels, + num_query, + num_point, + grad_value, + grad_sampling_loc, + grad_attn_weight); + } + else + { + ms_deformable_col2im_gpu_kernel_gm + <<>>( + num_kernels, + grad_col, + data_value, + data_spatial_shapes, + data_level_start_index, + data_sampling_loc, + data_attn_weight, + batch_size, + spatial_size, + num_heads, + channels, + num_levels, + num_query, + num_point, + grad_value, + grad_sampling_loc, + grad_attn_weight); + } + } + else{ + switch(channels) + { + case 1: + ms_deformable_col2im_gpu_kernel_shm_blocksize_aware_reduce_v1 + <<>>( + num_kernels, + grad_col, + data_value, + data_spatial_shapes, + data_level_start_index, + data_sampling_loc, + data_attn_weight, + batch_size, + spatial_size, + num_heads, + channels, + num_levels, + num_query, + num_point, + grad_value, + grad_sampling_loc, + grad_attn_weight); + break; + case 2: + ms_deformable_col2im_gpu_kernel_shm_blocksize_aware_reduce_v1 + <<>>( + num_kernels, + grad_col, + data_value, + data_spatial_shapes, + data_level_start_index, + data_sampling_loc, + data_attn_weight, + batch_size, + spatial_size, + num_heads, + channels, + num_levels, + num_query, + num_point, + grad_value, + grad_sampling_loc, + grad_attn_weight); + break; + case 4: + ms_deformable_col2im_gpu_kernel_shm_blocksize_aware_reduce_v1 + <<>>( + num_kernels, + grad_col, + data_value, + data_spatial_shapes, + data_level_start_index, + data_sampling_loc, + data_attn_weight, + batch_size, + spatial_size, + num_heads, + channels, + num_levels, + num_query, + num_point, + grad_value, + grad_sampling_loc, + grad_attn_weight); + break; + case 8: + ms_deformable_col2im_gpu_kernel_shm_blocksize_aware_reduce_v1 + <<>>( + num_kernels, + grad_col, + data_value, + data_spatial_shapes, + data_level_start_index, + data_sampling_loc, + data_attn_weight, + batch_size, + spatial_size, + num_heads, + channels, + num_levels, + num_query, + num_point, + grad_value, + grad_sampling_loc, + grad_attn_weight); + break; + case 16: + ms_deformable_col2im_gpu_kernel_shm_blocksize_aware_reduce_v1 + <<>>( + num_kernels, + grad_col, + data_value, + data_spatial_shapes, + data_level_start_index, + data_sampling_loc, + data_attn_weight, + batch_size, + spatial_size, + num_heads, + channels, + num_levels, + num_query, + num_point, + grad_value, + grad_sampling_loc, + grad_attn_weight); + break; + case 32: + ms_deformable_col2im_gpu_kernel_shm_blocksize_aware_reduce_v1 + <<>>( + num_kernels, + grad_col, + data_value, + data_spatial_shapes, + data_level_start_index, + data_sampling_loc, + data_attn_weight, + batch_size, + spatial_size, + num_heads, + channels, + num_levels, + num_query, + num_point, + grad_value, + grad_sampling_loc, + grad_attn_weight); + break; + case 64: + ms_deformable_col2im_gpu_kernel_shm_blocksize_aware_reduce_v2 + <<>>( + num_kernels, + grad_col, + data_value, + data_spatial_shapes, + data_level_start_index, + data_sampling_loc, + data_attn_weight, + batch_size, + spatial_size, + num_heads, + channels, + num_levels, + num_query, + num_point, + grad_value, + grad_sampling_loc, + grad_attn_weight); + break; + case 128: + ms_deformable_col2im_gpu_kernel_shm_blocksize_aware_reduce_v2 + <<>>( + num_kernels, + grad_col, + data_value, + data_spatial_shapes, + data_level_start_index, + data_sampling_loc, + data_attn_weight, + batch_size, + spatial_size, + num_heads, + channels, + num_levels, + num_query, + num_point, + grad_value, + grad_sampling_loc, + grad_attn_weight); + break; + case 256: + ms_deformable_col2im_gpu_kernel_shm_blocksize_aware_reduce_v2 + <<>>( + num_kernels, + grad_col, + data_value, + data_spatial_shapes, + data_level_start_index, + data_sampling_loc, + data_attn_weight, + batch_size, + spatial_size, + num_heads, + channels, + num_levels, + num_query, + num_point, + grad_value, + grad_sampling_loc, + grad_attn_weight); + break; + case 512: + ms_deformable_col2im_gpu_kernel_shm_blocksize_aware_reduce_v2 + <<>>( + num_kernels, + grad_col, + data_value, + data_spatial_shapes, + data_level_start_index, + data_sampling_loc, + data_attn_weight, + batch_size, + spatial_size, + num_heads, + channels, + num_levels, + num_query, + num_point, + grad_value, + grad_sampling_loc, + grad_attn_weight); + break; + case 1024: + ms_deformable_col2im_gpu_kernel_shm_blocksize_aware_reduce_v2 + <<>>( + num_kernels, + grad_col, + data_value, + data_spatial_shapes, + data_level_start_index, + data_sampling_loc, + data_attn_weight, + batch_size, + spatial_size, + num_heads, + channels, + num_levels, + num_query, + num_point, + grad_value, + grad_sampling_loc, + grad_attn_weight); + break; + default: + if (channels < 64) + { + ms_deformable_col2im_gpu_kernel_shm_reduce_v1 + <<>>( + num_kernels, + grad_col, + data_value, + data_spatial_shapes, + data_level_start_index, + data_sampling_loc, + data_attn_weight, + batch_size, + spatial_size, + num_heads, + channels, + num_levels, + num_query, + num_point, + grad_value, + grad_sampling_loc, + grad_attn_weight); + } + else + { + ms_deformable_col2im_gpu_kernel_shm_reduce_v2 + <<>>( + num_kernels, + grad_col, + data_value, + data_spatial_shapes, + data_level_start_index, + data_sampling_loc, + data_attn_weight, + batch_size, + spatial_size, + num_heads, + channels, + num_levels, + num_query, + num_point, + grad_value, + grad_sampling_loc, + grad_attn_weight); + } + } + } + cudaError_t err = cudaGetLastError(); + if (err != cudaSuccess) + { + printf("error in ms_deformable_col2im_cuda: %s\n", cudaGetErrorString(err)); + } + +} diff --git a/deformable_detr/ms_deform_attn_cuda.h b/deformable_detr/ms_deform_attn_cuda.h new file mode 100644 index 0000000000000000000000000000000000000000..5bf596397916b099eb317114dc929720e0bed695 --- /dev/null +++ b/deformable_detr/ms_deform_attn_cuda.h @@ -0,0 +1,46 @@ +/*! +************************************************************************************************** +* Deformable DETR +* Copyright (c) 2020 SenseTime. All Rights Reserved. +* Licensed under the Apache License, Version 2.0 [see LICENSE for details] +************************************************************************************************** +* Modified from https://github.com/chengdazhi/Deformable-Convolution-V2-PyTorch/tree/pytorch_1.0.0 +************************************************************************************************** +*/ + +#pragma once +#include + +at::Tensor ms_deform_attn_cuda_forward( + const at::Tensor &value, + const at::Tensor &spatial_shapes, + const at::Tensor &level_start_index, + const at::Tensor &sampling_loc, + const at::Tensor &attn_weight, + const int im2col_step); + +at::Tensor ms_deform_attn_cuda_forward_bf16( + const at::Tensor &value, + const at::Tensor &spatial_shapes, + const at::Tensor &level_start_index, + const at::Tensor &sampling_loc, + const at::Tensor &attn_weight, + const int im2col_step); + +std::vector ms_deform_attn_cuda_backward( + const at::Tensor &value, + const at::Tensor &spatial_shapes, + const at::Tensor &level_start_index, + const at::Tensor &sampling_loc, + const at::Tensor &attn_weight, + const at::Tensor &grad_output, + const int im2col_step); + +std::vector ms_deform_attn_cuda_backward_bf16( + const at::Tensor &value, + const at::Tensor &spatial_shapes, + const at::Tensor &level_start_index, + const at::Tensor &sampling_loc, + const at::Tensor &attn_weight, + const at::Tensor &grad_output, + const int im2col_step); diff --git a/deformable_detr/ms_deform_im2col_cuda.cuh b/deformable_detr/ms_deform_im2col_cuda.cuh new file mode 100644 index 0000000000000000000000000000000000000000..4fb544bf791ddae79238924df591b7a33f3cccdd --- /dev/null +++ b/deformable_detr/ms_deform_im2col_cuda.cuh @@ -0,0 +1,1327 @@ +/*! +************************************************************************** +* Deformable DETR +* Copyright (c) 2020 SenseTime. All Rights Reserved. +* Licensed under the Apache License, Version 2.0 [see LICENSE for details] +************************************************************************** +* Modified from DCN (https://github.com/msracver/Deformable-ConvNets) +* Copyright (c) 2018 Microsoft +************************************************************************** +*/ + +#include +#include +#include + +#include +#include + +#include + +#define CUDA_KERNEL_LOOP(i, n) \ + for (int i = blockIdx.x * blockDim.x + threadIdx.x; \ + i < (n); \ + i += blockDim.x * gridDim.x) + +const int CUDA_NUM_THREADS = 1024; +inline int GET_BLOCKS(const int N, const int num_threads) +{ + return (N + num_threads - 1) / num_threads; +} + + +template +__device__ scalar_t ms_deform_attn_im2col_bilinear(const scalar_t* &bottom_data, + const int &height, const int &width, const int &nheads, const int &channels, + const scalar_t &h, const scalar_t &w, const int &m, const int &c) +{ + const int h_low = floor(h); + const int w_low = floor(w); + const int h_high = h_low + 1; + const int w_high = w_low + 1; + + const scalar_t lh = h - h_low; + const scalar_t lw = w - w_low; + const scalar_t hh = 1 - lh, hw = 1 - lw; + + const int w_stride = nheads * channels; + const int h_stride = width * w_stride; + const int h_low_ptr_offset = h_low * h_stride; + const int h_high_ptr_offset = h_low_ptr_offset + h_stride; + const int w_low_ptr_offset = w_low * w_stride; + const int w_high_ptr_offset = w_low_ptr_offset + w_stride; + const int base_ptr = m * channels + c; + + scalar_t v1 = 0; + if (h_low >= 0 && w_low >= 0) + { + const int ptr1 = h_low_ptr_offset + w_low_ptr_offset + base_ptr; + v1 = bottom_data[ptr1]; + } + scalar_t v2 = 0; + if (h_low >= 0 && w_high <= width - 1) + { + const int ptr2 = h_low_ptr_offset + w_high_ptr_offset + base_ptr; + v2 = bottom_data[ptr2]; + } + scalar_t v3 = 0; + if (h_high <= height - 1 && w_low >= 0) + { + const int ptr3 = h_high_ptr_offset + w_low_ptr_offset + base_ptr; + v3 = bottom_data[ptr3]; + } + scalar_t v4 = 0; + if (h_high <= height - 1 && w_high <= width - 1) + { + const int ptr4 = h_high_ptr_offset + w_high_ptr_offset + base_ptr; + v4 = bottom_data[ptr4]; + } + + const scalar_t w1 = hh * hw, w2 = hh * lw, w3 = lh * hw, w4 = lh * lw; + + const scalar_t val = (w1 * v1 + w2 * v2 + w3 * v3 + w4 * v4); + return val; +} + + +template +__device__ void ms_deform_attn_col2im_bilinear(const scalar_t* &bottom_data, + const int &height, const int &width, const int &nheads, const int &channels, + const scalar_t &h, const scalar_t &w, const int &m, const int &c, + const scalar_t &top_grad, + const scalar_t &attn_weight, + scalar_t* &grad_value, + scalar_t* grad_sampling_loc, + scalar_t* grad_attn_weight) +{ + const int h_low = floor(h); + const int w_low = floor(w); + const int h_high = h_low + 1; + const int w_high = w_low + 1; + + const scalar_t lh = h - h_low; + const scalar_t lw = w - w_low; + const scalar_t hh = 1 - lh, hw = 1 - lw; + + const int w_stride = nheads * channels; + const int h_stride = width * w_stride; + const int h_low_ptr_offset = h_low * h_stride; + const int h_high_ptr_offset = h_low_ptr_offset + h_stride; + const int w_low_ptr_offset = w_low * w_stride; + const int w_high_ptr_offset = w_low_ptr_offset + w_stride; + const int base_ptr = m * channels + c; + + const scalar_t w1 = hh * hw, w2 = hh * lw, w3 = lh * hw, w4 = lh * lw; + const scalar_t top_grad_value = top_grad * attn_weight; + scalar_t grad_h_weight = 0, grad_w_weight = 0; + + scalar_t v1 = 0; + if (h_low >= 0 && w_low >= 0) + { + const int ptr1 = h_low_ptr_offset + w_low_ptr_offset + base_ptr; + v1 = bottom_data[ptr1]; + grad_h_weight -= hw * v1; + grad_w_weight -= hh * v1; + atomicAdd(grad_value+ptr1, w1*top_grad_value); + } + scalar_t v2 = 0; + if (h_low >= 0 && w_high <= width - 1) + { + const int ptr2 = h_low_ptr_offset + w_high_ptr_offset + base_ptr; + v2 = bottom_data[ptr2]; + grad_h_weight -= lw * v2; + grad_w_weight += hh * v2; + atomicAdd(grad_value+ptr2, w2*top_grad_value); + } + scalar_t v3 = 0; + if (h_high <= height - 1 && w_low >= 0) + { + const int ptr3 = h_high_ptr_offset + w_low_ptr_offset + base_ptr; + v3 = bottom_data[ptr3]; + grad_h_weight += hw * v3; + grad_w_weight -= lh * v3; + atomicAdd(grad_value+ptr3, w3*top_grad_value); + } + scalar_t v4 = 0; + if (h_high <= height - 1 && w_high <= width - 1) + { + const int ptr4 = h_high_ptr_offset + w_high_ptr_offset + base_ptr; + v4 = bottom_data[ptr4]; + grad_h_weight += lw * v4; + grad_w_weight += lh * v4; + atomicAdd(grad_value+ptr4, w4*top_grad_value); + } + + const scalar_t val = (w1 * v1 + w2 * v2 + w3 * v3 + w4 * v4); + *grad_attn_weight = top_grad * val; + *grad_sampling_loc = width * grad_w_weight * top_grad_value; + *(grad_sampling_loc + 1) = height * grad_h_weight * top_grad_value; +} + + +template +__device__ void ms_deform_attn_col2im_bilinear_gm(const scalar_t* &bottom_data, + const int &height, const int &width, const int &nheads, const int &channels, + const scalar_t &h, const scalar_t &w, const int &m, const int &c, + const scalar_t &top_grad, + const scalar_t &attn_weight, + scalar_t* &grad_value, + scalar_t* grad_sampling_loc, + scalar_t* grad_attn_weight) +{ + const int h_low = floor(h); + const int w_low = floor(w); + const int h_high = h_low + 1; + const int w_high = w_low + 1; + + const scalar_t lh = h - h_low; + const scalar_t lw = w - w_low; + const scalar_t hh = 1 - lh, hw = 1 - lw; + + const int w_stride = nheads * channels; + const int h_stride = width * w_stride; + const int h_low_ptr_offset = h_low * h_stride; + const int h_high_ptr_offset = h_low_ptr_offset + h_stride; + const int w_low_ptr_offset = w_low * w_stride; + const int w_high_ptr_offset = w_low_ptr_offset + w_stride; + const int base_ptr = m * channels + c; + + const scalar_t w1 = hh * hw, w2 = hh * lw, w3 = lh * hw, w4 = lh * lw; + const scalar_t top_grad_value = top_grad * attn_weight; + scalar_t grad_h_weight = 0, grad_w_weight = 0; + + scalar_t v1 = 0; + if (h_low >= 0 && w_low >= 0) + { + const int ptr1 = h_low_ptr_offset + w_low_ptr_offset + base_ptr; + v1 = bottom_data[ptr1]; + grad_h_weight -= hw * v1; + grad_w_weight -= hh * v1; + atomicAdd(grad_value+ptr1, w1*top_grad_value); + } + scalar_t v2 = 0; + if (h_low >= 0 && w_high <= width - 1) + { + const int ptr2 = h_low_ptr_offset + w_high_ptr_offset + base_ptr; + v2 = bottom_data[ptr2]; + grad_h_weight -= lw * v2; + grad_w_weight += hh * v2; + atomicAdd(grad_value+ptr2, w2*top_grad_value); + } + scalar_t v3 = 0; + if (h_high <= height - 1 && w_low >= 0) + { + const int ptr3 = h_high_ptr_offset + w_low_ptr_offset + base_ptr; + v3 = bottom_data[ptr3]; + grad_h_weight += hw * v3; + grad_w_weight -= lh * v3; + atomicAdd(grad_value+ptr3, w3*top_grad_value); + } + scalar_t v4 = 0; + if (h_high <= height - 1 && w_high <= width - 1) + { + const int ptr4 = h_high_ptr_offset + w_high_ptr_offset + base_ptr; + v4 = bottom_data[ptr4]; + grad_h_weight += lw * v4; + grad_w_weight += lh * v4; + atomicAdd(grad_value+ptr4, w4*top_grad_value); + } + + const scalar_t val = (w1 * v1 + w2 * v2 + w3 * v3 + w4 * v4); + atomicAdd(grad_attn_weight, top_grad * val); + atomicAdd(grad_sampling_loc, width * grad_w_weight * top_grad_value); + atomicAdd(grad_sampling_loc + 1, height * grad_h_weight * top_grad_value); +} + + +template +__global__ void ms_deformable_im2col_gpu_kernel(const int n, + const scalar_t *data_value, + const int64_t *data_spatial_shapes, + const int64_t *data_level_start_index, + const scalar_t *data_sampling_loc, + const scalar_t *data_attn_weight, + const int batch_size, + const int spatial_size, + const int num_heads, + const int channels, + const int num_levels, + const int num_query, + const int num_point, + scalar_t *data_col) +{ + CUDA_KERNEL_LOOP(index, n) + { + int _temp = index; + const int c_col = _temp % channels; + _temp /= channels; + const int sampling_index = _temp; + const int m_col = _temp % num_heads; + _temp /= num_heads; + [[maybe_unused]] const int q_col = _temp % num_query; + _temp /= num_query; + const int b_col = _temp; + + scalar_t *data_col_ptr = data_col + index; + int data_weight_ptr = sampling_index * num_levels * num_point; + int data_loc_w_ptr = data_weight_ptr << 1; + const int qid_stride = num_heads * channels; + const int data_value_ptr_init_offset = b_col * spatial_size * qid_stride; + scalar_t col = 0; + + for (int l_col=0; l_col < num_levels; ++l_col) + { + const int level_start_id = data_level_start_index[l_col]; + const int spatial_h_ptr = l_col << 1; + const int spatial_h = data_spatial_shapes[spatial_h_ptr]; + const int spatial_w = data_spatial_shapes[spatial_h_ptr + 1]; + const scalar_t *data_value_ptr = data_value + (data_value_ptr_init_offset + level_start_id * qid_stride); + for (int p_col=0; p_col < num_point; ++p_col) + { + const scalar_t loc_w = data_sampling_loc[data_loc_w_ptr]; + const scalar_t loc_h = data_sampling_loc[data_loc_w_ptr + 1]; + const scalar_t weight = data_attn_weight[data_weight_ptr]; + + const scalar_t h_im = loc_h * spatial_h - 0.5; + const scalar_t w_im = loc_w * spatial_w - 0.5; + + if (h_im > -1 && w_im > -1 && h_im < spatial_h && w_im < spatial_w) + { + col += ms_deform_attn_im2col_bilinear(data_value_ptr, spatial_h, spatial_w, num_heads, channels, h_im, w_im, m_col, c_col) * weight; + } + + data_weight_ptr += 1; + data_loc_w_ptr += 2; + } + } + *data_col_ptr = col; + } +} + +template +__global__ void ms_deformable_col2im_gpu_kernel_shm_blocksize_aware_reduce_v1(const int n, + const scalar_t *grad_col, + const scalar_t *data_value, + const int64_t *data_spatial_shapes, + const int64_t *data_level_start_index, + const scalar_t *data_sampling_loc, + const scalar_t *data_attn_weight, + const int batch_size, + const int spatial_size, + const int num_heads, + const int channels, + const int num_levels, + const int num_query, + const int num_point, + scalar_t *grad_value, + scalar_t *grad_sampling_loc, + scalar_t *grad_attn_weight) +{ + CUDA_KERNEL_LOOP(index, n) + { + __shared__ scalar_t cache_grad_sampling_loc[blockSize * 2]; + __shared__ scalar_t cache_grad_attn_weight[blockSize]; + unsigned int tid = threadIdx.x; + int _temp = index; + const int c_col = _temp % channels; + _temp /= channels; + const int sampling_index = _temp; + const int m_col = _temp % num_heads; + _temp /= num_heads; + [[maybe_unused]] const int q_col = _temp % num_query; + _temp /= num_query; + const int b_col = _temp; + + const scalar_t top_grad = grad_col[index]; + + int data_weight_ptr = sampling_index * num_levels * num_point; + int data_loc_w_ptr = data_weight_ptr << 1; + const int grad_sampling_ptr = data_weight_ptr; + grad_sampling_loc += grad_sampling_ptr << 1; + grad_attn_weight += grad_sampling_ptr; + const int grad_weight_stride = 1; + const int grad_loc_stride = 2; + const int qid_stride = num_heads * channels; + const int data_value_ptr_init_offset = b_col * spatial_size * qid_stride; + + for (int l_col=0; l_col < num_levels; ++l_col) + { + const int level_start_id = data_level_start_index[l_col]; + const int spatial_h_ptr = l_col << 1; + const int spatial_h = data_spatial_shapes[spatial_h_ptr]; + const int spatial_w = data_spatial_shapes[spatial_h_ptr + 1]; + const int value_ptr_offset = data_value_ptr_init_offset + level_start_id * qid_stride; + const scalar_t *data_value_ptr = data_value + value_ptr_offset; + scalar_t *grad_value_ptr = grad_value + value_ptr_offset; + + for (int p_col=0; p_col < num_point; ++p_col) + { + const scalar_t loc_w = data_sampling_loc[data_loc_w_ptr]; + const scalar_t loc_h = data_sampling_loc[data_loc_w_ptr + 1]; + const scalar_t weight = data_attn_weight[data_weight_ptr]; + + const scalar_t h_im = loc_h * spatial_h - 0.5; + const scalar_t w_im = loc_w * spatial_w - 0.5; + *(cache_grad_sampling_loc+(threadIdx.x << 1)) = 0; + *(cache_grad_sampling_loc+((threadIdx.x << 1) + 1)) = 0; + *(cache_grad_attn_weight+threadIdx.x)=0; + if (h_im > -1 && w_im > -1 && h_im < spatial_h && w_im < spatial_w) + { + ms_deform_attn_col2im_bilinear( + data_value_ptr, spatial_h, spatial_w, num_heads, channels, h_im, w_im, m_col, c_col, + top_grad, weight, grad_value_ptr, + cache_grad_sampling_loc+(threadIdx.x << 1), cache_grad_attn_weight+threadIdx.x); + } + + __syncthreads(); + if (tid == 0) + { + scalar_t _grad_w=cache_grad_sampling_loc[0], _grad_h=cache_grad_sampling_loc[1], _grad_a=cache_grad_attn_weight[0]; + int sid=2; + for (unsigned int tid = 1; tid < blockSize; ++tid) + { + _grad_w += cache_grad_sampling_loc[sid]; + _grad_h += cache_grad_sampling_loc[sid + 1]; + _grad_a += cache_grad_attn_weight[tid]; + sid += 2; + } + + + *grad_sampling_loc = _grad_w; + *(grad_sampling_loc + 1) = _grad_h; + *grad_attn_weight = _grad_a; + } + __syncthreads(); + + data_weight_ptr += 1; + data_loc_w_ptr += 2; + grad_attn_weight += grad_weight_stride; + grad_sampling_loc += grad_loc_stride; + } + } + } +} + + +template +__global__ void ms_deformable_col2im_gpu_kernel_shm_blocksize_aware_reduce_v2(const int n, + const scalar_t *grad_col, + const scalar_t *data_value, + const int64_t *data_spatial_shapes, + const int64_t *data_level_start_index, + const scalar_t *data_sampling_loc, + const scalar_t *data_attn_weight, + const int batch_size, + const int spatial_size, + const int num_heads, + const int channels, + const int num_levels, + const int num_query, + const int num_point, + scalar_t *grad_value, + scalar_t *grad_sampling_loc, + scalar_t *grad_attn_weight) +{ + CUDA_KERNEL_LOOP(index, n) + { + __shared__ scalar_t cache_grad_sampling_loc[blockSize * 2]; + __shared__ scalar_t cache_grad_attn_weight[blockSize]; + unsigned int tid = threadIdx.x; + int _temp = index; + const int c_col = _temp % channels; + _temp /= channels; + const int sampling_index = _temp; + const int m_col = _temp % num_heads; + _temp /= num_heads; + [[maybe_unused]] const int q_col = _temp % num_query; + _temp /= num_query; + const int b_col = _temp; + + const scalar_t top_grad = grad_col[index]; + + int data_weight_ptr = sampling_index * num_levels * num_point; + int data_loc_w_ptr = data_weight_ptr << 1; + const int grad_sampling_ptr = data_weight_ptr; + grad_sampling_loc += grad_sampling_ptr << 1; + grad_attn_weight += grad_sampling_ptr; + const int grad_weight_stride = 1; + const int grad_loc_stride = 2; + const int qid_stride = num_heads * channels; + const int data_value_ptr_init_offset = b_col * spatial_size * qid_stride; + + for (int l_col=0; l_col < num_levels; ++l_col) + { + const int level_start_id = data_level_start_index[l_col]; + const int spatial_h_ptr = l_col << 1; + const int spatial_h = data_spatial_shapes[spatial_h_ptr]; + const int spatial_w = data_spatial_shapes[spatial_h_ptr + 1]; + const int value_ptr_offset = data_value_ptr_init_offset + level_start_id * qid_stride; + const scalar_t *data_value_ptr = data_value + value_ptr_offset; + scalar_t *grad_value_ptr = grad_value + value_ptr_offset; + + for (int p_col=0; p_col < num_point; ++p_col) + { + const scalar_t loc_w = data_sampling_loc[data_loc_w_ptr]; + const scalar_t loc_h = data_sampling_loc[data_loc_w_ptr + 1]; + const scalar_t weight = data_attn_weight[data_weight_ptr]; + + const scalar_t h_im = loc_h * spatial_h - 0.5; + const scalar_t w_im = loc_w * spatial_w - 0.5; + *(cache_grad_sampling_loc+(threadIdx.x << 1)) = 0; + *(cache_grad_sampling_loc+((threadIdx.x << 1) + 1)) = 0; + *(cache_grad_attn_weight+threadIdx.x)=0; + if (h_im > -1 && w_im > -1 && h_im < spatial_h && w_im < spatial_w) + { + ms_deform_attn_col2im_bilinear( + data_value_ptr, spatial_h, spatial_w, num_heads, channels, h_im, w_im, m_col, c_col, + top_grad, weight, grad_value_ptr, + cache_grad_sampling_loc+(threadIdx.x << 1), cache_grad_attn_weight+threadIdx.x); + } + + __syncthreads(); + + for (unsigned int s=blockSize/2; s>0; s>>=1) + { + if (tid < s) { + const unsigned int xid1 = tid << 1; + const unsigned int xid2 = (tid + s) << 1; + cache_grad_attn_weight[tid] += cache_grad_attn_weight[tid + s]; + cache_grad_sampling_loc[xid1] += cache_grad_sampling_loc[xid2]; + cache_grad_sampling_loc[xid1 + 1] += cache_grad_sampling_loc[xid2 + 1]; + } + __syncthreads(); + } + + if (tid == 0) + { + *grad_sampling_loc = cache_grad_sampling_loc[0]; + *(grad_sampling_loc + 1) = cache_grad_sampling_loc[1]; + *grad_attn_weight = cache_grad_attn_weight[0]; + } + __syncthreads(); + + data_weight_ptr += 1; + data_loc_w_ptr += 2; + grad_attn_weight += grad_weight_stride; + grad_sampling_loc += grad_loc_stride; + } + } + } +} + + +template +__global__ void ms_deformable_col2im_gpu_kernel_shm_reduce_v1(const int n, + const scalar_t *grad_col, + const scalar_t *data_value, + const int64_t *data_spatial_shapes, + const int64_t *data_level_start_index, + const scalar_t *data_sampling_loc, + const scalar_t *data_attn_weight, + const int batch_size, + const int spatial_size, + const int num_heads, + const int channels, + const int num_levels, + const int num_query, + const int num_point, + scalar_t *grad_value, + scalar_t *grad_sampling_loc, + scalar_t *grad_attn_weight) +{ + CUDA_KERNEL_LOOP(index, n) + { + extern __shared__ int _s[]; + scalar_t* cache_grad_sampling_loc = (scalar_t*)_s; + scalar_t* cache_grad_attn_weight = cache_grad_sampling_loc + 2 * blockDim.x; + unsigned int tid = threadIdx.x; + int _temp = index; + const int c_col = _temp % channels; + _temp /= channels; + const int sampling_index = _temp; + const int m_col = _temp % num_heads; + _temp /= num_heads; + [[maybe_unused]] const int q_col = _temp % num_query; + _temp /= num_query; + const int b_col = _temp; + + const scalar_t top_grad = grad_col[index]; + + int data_weight_ptr = sampling_index * num_levels * num_point; + int data_loc_w_ptr = data_weight_ptr << 1; + const int grad_sampling_ptr = data_weight_ptr; + grad_sampling_loc += grad_sampling_ptr << 1; + grad_attn_weight += grad_sampling_ptr; + const int grad_weight_stride = 1; + const int grad_loc_stride = 2; + const int qid_stride = num_heads * channels; + const int data_value_ptr_init_offset = b_col * spatial_size * qid_stride; + + for (int l_col=0; l_col < num_levels; ++l_col) + { + const int level_start_id = data_level_start_index[l_col]; + const int spatial_h_ptr = l_col << 1; + const int spatial_h = data_spatial_shapes[spatial_h_ptr]; + const int spatial_w = data_spatial_shapes[spatial_h_ptr + 1]; + const int value_ptr_offset = data_value_ptr_init_offset + level_start_id * qid_stride; + const scalar_t *data_value_ptr = data_value + value_ptr_offset; + scalar_t *grad_value_ptr = grad_value + value_ptr_offset; + + for (int p_col=0; p_col < num_point; ++p_col) + { + const scalar_t loc_w = data_sampling_loc[data_loc_w_ptr]; + const scalar_t loc_h = data_sampling_loc[data_loc_w_ptr + 1]; + const scalar_t weight = data_attn_weight[data_weight_ptr]; + + const scalar_t h_im = loc_h * spatial_h - 0.5; + const scalar_t w_im = loc_w * spatial_w - 0.5; + *(cache_grad_sampling_loc+(threadIdx.x << 1)) = 0; + *(cache_grad_sampling_loc+((threadIdx.x << 1) + 1)) = 0; + *(cache_grad_attn_weight+threadIdx.x)=0; + if (h_im > -1 && w_im > -1 && h_im < spatial_h && w_im < spatial_w) + { + ms_deform_attn_col2im_bilinear( + data_value_ptr, spatial_h, spatial_w, num_heads, channels, h_im, w_im, m_col, c_col, + top_grad, weight, grad_value_ptr, + cache_grad_sampling_loc+(threadIdx.x << 1), cache_grad_attn_weight+threadIdx.x); + } + + __syncthreads(); + if (tid == 0) + { + scalar_t _grad_w=cache_grad_sampling_loc[0], _grad_h=cache_grad_sampling_loc[1], _grad_a=cache_grad_attn_weight[0]; + int sid=2; + for (unsigned int tid = 1; tid < blockDim.x; ++tid) + { + _grad_w += cache_grad_sampling_loc[sid]; + _grad_h += cache_grad_sampling_loc[sid + 1]; + _grad_a += cache_grad_attn_weight[tid]; + sid += 2; + } + + + *grad_sampling_loc = _grad_w; + *(grad_sampling_loc + 1) = _grad_h; + *grad_attn_weight = _grad_a; + } + __syncthreads(); + + data_weight_ptr += 1; + data_loc_w_ptr += 2; + grad_attn_weight += grad_weight_stride; + grad_sampling_loc += grad_loc_stride; + } + } + } +} + +template +__global__ void ms_deformable_col2im_gpu_kernel_shm_reduce_v2(const int n, + const scalar_t *grad_col, + const scalar_t *data_value, + const int64_t *data_spatial_shapes, + const int64_t *data_level_start_index, + const scalar_t *data_sampling_loc, + const scalar_t *data_attn_weight, + const int batch_size, + const int spatial_size, + const int num_heads, + const int channels, + const int num_levels, + const int num_query, + const int num_point, + scalar_t *grad_value, + scalar_t *grad_sampling_loc, + scalar_t *grad_attn_weight) +{ + CUDA_KERNEL_LOOP(index, n) + { + extern __shared__ int _s[]; + scalar_t* cache_grad_sampling_loc = (scalar_t*)_s; + scalar_t* cache_grad_attn_weight = cache_grad_sampling_loc + 2 * blockDim.x; + unsigned int tid = threadIdx.x; + int _temp = index; + const int c_col = _temp % channels; + _temp /= channels; + const int sampling_index = _temp; + const int m_col = _temp % num_heads; + _temp /= num_heads; + [[maybe_unused]] const int q_col = _temp % num_query; + _temp /= num_query; + const int b_col = _temp; + + const scalar_t top_grad = grad_col[index]; + + int data_weight_ptr = sampling_index * num_levels * num_point; + int data_loc_w_ptr = data_weight_ptr << 1; + const int grad_sampling_ptr = data_weight_ptr; + grad_sampling_loc += grad_sampling_ptr << 1; + grad_attn_weight += grad_sampling_ptr; + const int grad_weight_stride = 1; + const int grad_loc_stride = 2; + const int qid_stride = num_heads * channels; + const int data_value_ptr_init_offset = b_col * spatial_size * qid_stride; + + for (int l_col=0; l_col < num_levels; ++l_col) + { + const int level_start_id = data_level_start_index[l_col]; + const int spatial_h_ptr = l_col << 1; + const int spatial_h = data_spatial_shapes[spatial_h_ptr]; + const int spatial_w = data_spatial_shapes[spatial_h_ptr + 1]; + const int value_ptr_offset = data_value_ptr_init_offset + level_start_id * qid_stride; + const scalar_t *data_value_ptr = data_value + value_ptr_offset; + scalar_t *grad_value_ptr = grad_value + value_ptr_offset; + + for (int p_col=0; p_col < num_point; ++p_col) + { + const scalar_t loc_w = data_sampling_loc[data_loc_w_ptr]; + const scalar_t loc_h = data_sampling_loc[data_loc_w_ptr + 1]; + const scalar_t weight = data_attn_weight[data_weight_ptr]; + + const scalar_t h_im = loc_h * spatial_h - 0.5; + const scalar_t w_im = loc_w * spatial_w - 0.5; + *(cache_grad_sampling_loc+(threadIdx.x << 1)) = 0; + *(cache_grad_sampling_loc+((threadIdx.x << 1) + 1)) = 0; + *(cache_grad_attn_weight+threadIdx.x)=0; + if (h_im > -1 && w_im > -1 && h_im < spatial_h && w_im < spatial_w) + { + ms_deform_attn_col2im_bilinear( + data_value_ptr, spatial_h, spatial_w, num_heads, channels, h_im, w_im, m_col, c_col, + top_grad, weight, grad_value_ptr, + cache_grad_sampling_loc+(threadIdx.x << 1), cache_grad_attn_weight+threadIdx.x); + } + + __syncthreads(); + + for (unsigned int s=blockDim.x/2, spre=blockDim.x; s>0; s>>=1, spre>>=1) + { + if (tid < s) { + const unsigned int xid1 = tid << 1; + const unsigned int xid2 = (tid + s) << 1; + cache_grad_attn_weight[tid] += cache_grad_attn_weight[tid + s]; + cache_grad_sampling_loc[xid1] += cache_grad_sampling_loc[xid2]; + cache_grad_sampling_loc[xid1 + 1] += cache_grad_sampling_loc[xid2 + 1]; + if (tid + (s << 1) < spre) + { + cache_grad_attn_weight[tid] += cache_grad_attn_weight[tid + (s << 1)]; + cache_grad_sampling_loc[xid1] += cache_grad_sampling_loc[xid2 + (s << 1)]; + cache_grad_sampling_loc[xid1 + 1] += cache_grad_sampling_loc[xid2 + 1 + (s << 1)]; + } + } + __syncthreads(); + } + + if (tid == 0) + { + *grad_sampling_loc = cache_grad_sampling_loc[0]; + *(grad_sampling_loc + 1) = cache_grad_sampling_loc[1]; + *grad_attn_weight = cache_grad_attn_weight[0]; + } + __syncthreads(); + + data_weight_ptr += 1; + data_loc_w_ptr += 2; + grad_attn_weight += grad_weight_stride; + grad_sampling_loc += grad_loc_stride; + } + } + } +} + +template +__global__ void ms_deformable_col2im_gpu_kernel_shm_reduce_v2_multi_blocks(const int n, + const scalar_t *grad_col, + const scalar_t *data_value, + const int64_t *data_spatial_shapes, + const int64_t *data_level_start_index, + const scalar_t *data_sampling_loc, + const scalar_t *data_attn_weight, + const int batch_size, + const int spatial_size, + const int num_heads, + const int channels, + const int num_levels, + const int num_query, + const int num_point, + scalar_t *grad_value, + scalar_t *grad_sampling_loc, + scalar_t *grad_attn_weight) +{ + CUDA_KERNEL_LOOP(index, n) + { + extern __shared__ int _s[]; + scalar_t* cache_grad_sampling_loc = (scalar_t*)_s; + scalar_t* cache_grad_attn_weight = cache_grad_sampling_loc + 2 * blockDim.x; + unsigned int tid = threadIdx.x; + int _temp = index; + const int c_col = _temp % channels; + _temp /= channels; + const int sampling_index = _temp; + const int m_col = _temp % num_heads; + _temp /= num_heads; + [[maybe_unused]] const int q_col = _temp % num_query; + _temp /= num_query; + const int b_col = _temp; + + const scalar_t top_grad = grad_col[index]; + + int data_weight_ptr = sampling_index * num_levels * num_point; + int data_loc_w_ptr = data_weight_ptr << 1; + const int grad_sampling_ptr = data_weight_ptr; + grad_sampling_loc += grad_sampling_ptr << 1; + grad_attn_weight += grad_sampling_ptr; + const int grad_weight_stride = 1; + const int grad_loc_stride = 2; + const int qid_stride = num_heads * channels; + const int data_value_ptr_init_offset = b_col * spatial_size * qid_stride; + + for (int l_col=0; l_col < num_levels; ++l_col) + { + const int level_start_id = data_level_start_index[l_col]; + const int spatial_h_ptr = l_col << 1; + const int spatial_h = data_spatial_shapes[spatial_h_ptr]; + const int spatial_w = data_spatial_shapes[spatial_h_ptr + 1]; + const int value_ptr_offset = data_value_ptr_init_offset + level_start_id * qid_stride; + const scalar_t *data_value_ptr = data_value + value_ptr_offset; + scalar_t *grad_value_ptr = grad_value + value_ptr_offset; + + for (int p_col=0; p_col < num_point; ++p_col) + { + const scalar_t loc_w = data_sampling_loc[data_loc_w_ptr]; + const scalar_t loc_h = data_sampling_loc[data_loc_w_ptr + 1]; + const scalar_t weight = data_attn_weight[data_weight_ptr]; + + const scalar_t h_im = loc_h * spatial_h - 0.5; + const scalar_t w_im = loc_w * spatial_w - 0.5; + *(cache_grad_sampling_loc+(threadIdx.x << 1)) = 0; + *(cache_grad_sampling_loc+((threadIdx.x << 1) + 1)) = 0; + *(cache_grad_attn_weight+threadIdx.x)=0; + if (h_im > -1 && w_im > -1 && h_im < spatial_h && w_im < spatial_w) + { + ms_deform_attn_col2im_bilinear( + data_value_ptr, spatial_h, spatial_w, num_heads, channels, h_im, w_im, m_col, c_col, + top_grad, weight, grad_value_ptr, + cache_grad_sampling_loc+(threadIdx.x << 1), cache_grad_attn_weight+threadIdx.x); + } + + __syncthreads(); + + for (unsigned int s=blockDim.x/2, spre=blockDim.x; s>0; s>>=1, spre>>=1) + { + if (tid < s) { + const unsigned int xid1 = tid << 1; + const unsigned int xid2 = (tid + s) << 1; + cache_grad_attn_weight[tid] += cache_grad_attn_weight[tid + s]; + cache_grad_sampling_loc[xid1] += cache_grad_sampling_loc[xid2]; + cache_grad_sampling_loc[xid1 + 1] += cache_grad_sampling_loc[xid2 + 1]; + if (tid + (s << 1) < spre) + { + cache_grad_attn_weight[tid] += cache_grad_attn_weight[tid + (s << 1)]; + cache_grad_sampling_loc[xid1] += cache_grad_sampling_loc[xid2 + (s << 1)]; + cache_grad_sampling_loc[xid1 + 1] += cache_grad_sampling_loc[xid2 + 1 + (s << 1)]; + } + } + __syncthreads(); + } + + if (tid == 0) + { + atomicAdd(grad_sampling_loc, cache_grad_sampling_loc[0]); + atomicAdd(grad_sampling_loc + 1, cache_grad_sampling_loc[1]); + atomicAdd(grad_attn_weight, cache_grad_attn_weight[0]); + } + __syncthreads(); + + data_weight_ptr += 1; + data_loc_w_ptr += 2; + grad_attn_weight += grad_weight_stride; + grad_sampling_loc += grad_loc_stride; + } + } + } +} + + +template +__global__ void ms_deformable_col2im_gpu_kernel_gm(const int n, + const scalar_t *grad_col, + const scalar_t *data_value, + const int64_t *data_spatial_shapes, + const int64_t *data_level_start_index, + const scalar_t *data_sampling_loc, + const scalar_t *data_attn_weight, + const int batch_size, + const int spatial_size, + const int num_heads, + const int channels, + const int num_levels, + const int num_query, + const int num_point, + scalar_t *grad_value, + scalar_t *grad_sampling_loc, + scalar_t *grad_attn_weight) +{ + CUDA_KERNEL_LOOP(index, n) + { + int _temp = index; + const int c_col = _temp % channels; + _temp /= channels; + const int sampling_index = _temp; + const int m_col = _temp % num_heads; + _temp /= num_heads; + [[maybe_unused]] const int q_col = _temp % num_query; + _temp /= num_query; + const int b_col = _temp; + + const scalar_t top_grad = grad_col[index]; + + int data_weight_ptr = sampling_index * num_levels * num_point; + int data_loc_w_ptr = data_weight_ptr << 1; + const int grad_sampling_ptr = data_weight_ptr; + grad_sampling_loc += grad_sampling_ptr << 1; + grad_attn_weight += grad_sampling_ptr; + const int grad_weight_stride = 1; + const int grad_loc_stride = 2; + const int qid_stride = num_heads * channels; + const int data_value_ptr_init_offset = b_col * spatial_size * qid_stride; + + for (int l_col=0; l_col < num_levels; ++l_col) + { + const int level_start_id = data_level_start_index[l_col]; + const int spatial_h_ptr = l_col << 1; + const int spatial_h = data_spatial_shapes[spatial_h_ptr]; + const int spatial_w = data_spatial_shapes[spatial_h_ptr + 1]; + const int value_ptr_offset = data_value_ptr_init_offset + level_start_id * qid_stride; + const scalar_t *data_value_ptr = data_value + value_ptr_offset; + scalar_t *grad_value_ptr = grad_value + value_ptr_offset; + + for (int p_col=0; p_col < num_point; ++p_col) + { + const scalar_t loc_w = data_sampling_loc[data_loc_w_ptr]; + const scalar_t loc_h = data_sampling_loc[data_loc_w_ptr + 1]; + const scalar_t weight = data_attn_weight[data_weight_ptr]; + + const scalar_t h_im = loc_h * spatial_h - 0.5; + const scalar_t w_im = loc_w * spatial_w - 0.5; + if (h_im > -1 && w_im > -1 && h_im < spatial_h && w_im < spatial_w) + { + ms_deform_attn_col2im_bilinear_gm( + data_value_ptr, spatial_h, spatial_w, num_heads, channels, h_im, w_im, m_col, c_col, + top_grad, weight, grad_value_ptr, + grad_sampling_loc, grad_attn_weight); + } + data_weight_ptr += 1; + data_loc_w_ptr += 2; + grad_attn_weight += grad_weight_stride; + grad_sampling_loc += grad_loc_stride; + } + } + } +} + + +template +void ms_deformable_im2col_cuda(cudaStream_t stream, + const scalar_t* data_value, + const int64_t* data_spatial_shapes, + const int64_t* data_level_start_index, + const scalar_t* data_sampling_loc, + const scalar_t* data_attn_weight, + const int batch_size, + const int spatial_size, + const int num_heads, + const int channels, + const int num_levels, + const int num_query, + const int num_point, + scalar_t* data_col) +{ + const int num_kernels = batch_size * num_query * num_heads * channels; + const int num_actual_kernels = batch_size * num_query * num_heads * channels; + const int num_threads = CUDA_NUM_THREADS; + ms_deformable_im2col_gpu_kernel + <<>>( + num_kernels, data_value, data_spatial_shapes, data_level_start_index, data_sampling_loc, data_attn_weight, + batch_size, spatial_size, num_heads, channels, num_levels, num_query, num_point, data_col); + + cudaError_t err = cudaGetLastError(); + if (err != cudaSuccess) + { + printf("error in ms_deformable_im2col_cuda: %s\n", cudaGetErrorString(err)); + } + +} + +template +void ms_deformable_col2im_cuda(cudaStream_t stream, + const scalar_t* grad_col, + const scalar_t* data_value, + const int64_t * data_spatial_shapes, + const int64_t * data_level_start_index, + const scalar_t * data_sampling_loc, + const scalar_t * data_attn_weight, + const int batch_size, + const int spatial_size, + const int num_heads, + const int channels, + const int num_levels, + const int num_query, + const int num_point, + scalar_t* grad_value, + scalar_t* grad_sampling_loc, + scalar_t* grad_attn_weight) +{ + const int num_threads = (channels > CUDA_NUM_THREADS)?CUDA_NUM_THREADS:channels; + const int num_kernels = batch_size * num_query * num_heads * channels; + const int num_actual_kernels = batch_size * num_query * num_heads * channels; + if (channels > 1024) + { + if ((channels & 1023) == 0) + { + ms_deformable_col2im_gpu_kernel_shm_reduce_v2_multi_blocks + <<>>( + num_kernels, + grad_col, + data_value, + data_spatial_shapes, + data_level_start_index, + data_sampling_loc, + data_attn_weight, + batch_size, + spatial_size, + num_heads, + channels, + num_levels, + num_query, + num_point, + grad_value, + grad_sampling_loc, + grad_attn_weight); + } + else + { + ms_deformable_col2im_gpu_kernel_gm + <<>>( + num_kernels, + grad_col, + data_value, + data_spatial_shapes, + data_level_start_index, + data_sampling_loc, + data_attn_weight, + batch_size, + spatial_size, + num_heads, + channels, + num_levels, + num_query, + num_point, + grad_value, + grad_sampling_loc, + grad_attn_weight); + } + } + else{ + switch(channels) + { + case 1: + ms_deformable_col2im_gpu_kernel_shm_blocksize_aware_reduce_v1 + <<>>( + num_kernels, + grad_col, + data_value, + data_spatial_shapes, + data_level_start_index, + data_sampling_loc, + data_attn_weight, + batch_size, + spatial_size, + num_heads, + channels, + num_levels, + num_query, + num_point, + grad_value, + grad_sampling_loc, + grad_attn_weight); + break; + case 2: + ms_deformable_col2im_gpu_kernel_shm_blocksize_aware_reduce_v1 + <<>>( + num_kernels, + grad_col, + data_value, + data_spatial_shapes, + data_level_start_index, + data_sampling_loc, + data_attn_weight, + batch_size, + spatial_size, + num_heads, + channels, + num_levels, + num_query, + num_point, + grad_value, + grad_sampling_loc, + grad_attn_weight); + break; + case 4: + ms_deformable_col2im_gpu_kernel_shm_blocksize_aware_reduce_v1 + <<>>( + num_kernels, + grad_col, + data_value, + data_spatial_shapes, + data_level_start_index, + data_sampling_loc, + data_attn_weight, + batch_size, + spatial_size, + num_heads, + channels, + num_levels, + num_query, + num_point, + grad_value, + grad_sampling_loc, + grad_attn_weight); + break; + case 8: + ms_deformable_col2im_gpu_kernel_shm_blocksize_aware_reduce_v1 + <<>>( + num_kernels, + grad_col, + data_value, + data_spatial_shapes, + data_level_start_index, + data_sampling_loc, + data_attn_weight, + batch_size, + spatial_size, + num_heads, + channels, + num_levels, + num_query, + num_point, + grad_value, + grad_sampling_loc, + grad_attn_weight); + break; + case 16: + ms_deformable_col2im_gpu_kernel_shm_blocksize_aware_reduce_v1 + <<>>( + num_kernels, + grad_col, + data_value, + data_spatial_shapes, + data_level_start_index, + data_sampling_loc, + data_attn_weight, + batch_size, + spatial_size, + num_heads, + channels, + num_levels, + num_query, + num_point, + grad_value, + grad_sampling_loc, + grad_attn_weight); + break; + case 32: + ms_deformable_col2im_gpu_kernel_shm_blocksize_aware_reduce_v1 + <<>>( + num_kernels, + grad_col, + data_value, + data_spatial_shapes, + data_level_start_index, + data_sampling_loc, + data_attn_weight, + batch_size, + spatial_size, + num_heads, + channels, + num_levels, + num_query, + num_point, + grad_value, + grad_sampling_loc, + grad_attn_weight); + break; + case 64: + ms_deformable_col2im_gpu_kernel_shm_blocksize_aware_reduce_v2 + <<>>( + num_kernels, + grad_col, + data_value, + data_spatial_shapes, + data_level_start_index, + data_sampling_loc, + data_attn_weight, + batch_size, + spatial_size, + num_heads, + channels, + num_levels, + num_query, + num_point, + grad_value, + grad_sampling_loc, + grad_attn_weight); + break; + case 128: + ms_deformable_col2im_gpu_kernel_shm_blocksize_aware_reduce_v2 + <<>>( + num_kernels, + grad_col, + data_value, + data_spatial_shapes, + data_level_start_index, + data_sampling_loc, + data_attn_weight, + batch_size, + spatial_size, + num_heads, + channels, + num_levels, + num_query, + num_point, + grad_value, + grad_sampling_loc, + grad_attn_weight); + break; + case 256: + ms_deformable_col2im_gpu_kernel_shm_blocksize_aware_reduce_v2 + <<>>( + num_kernels, + grad_col, + data_value, + data_spatial_shapes, + data_level_start_index, + data_sampling_loc, + data_attn_weight, + batch_size, + spatial_size, + num_heads, + channels, + num_levels, + num_query, + num_point, + grad_value, + grad_sampling_loc, + grad_attn_weight); + break; + case 512: + ms_deformable_col2im_gpu_kernel_shm_blocksize_aware_reduce_v2 + <<>>( + num_kernels, + grad_col, + data_value, + data_spatial_shapes, + data_level_start_index, + data_sampling_loc, + data_attn_weight, + batch_size, + spatial_size, + num_heads, + channels, + num_levels, + num_query, + num_point, + grad_value, + grad_sampling_loc, + grad_attn_weight); + break; + case 1024: + ms_deformable_col2im_gpu_kernel_shm_blocksize_aware_reduce_v2 + <<>>( + num_kernels, + grad_col, + data_value, + data_spatial_shapes, + data_level_start_index, + data_sampling_loc, + data_attn_weight, + batch_size, + spatial_size, + num_heads, + channels, + num_levels, + num_query, + num_point, + grad_value, + grad_sampling_loc, + grad_attn_weight); + break; + default: + if (channels < 64) + { + ms_deformable_col2im_gpu_kernel_shm_reduce_v1 + <<>>( + num_kernels, + grad_col, + data_value, + data_spatial_shapes, + data_level_start_index, + data_sampling_loc, + data_attn_weight, + batch_size, + spatial_size, + num_heads, + channels, + num_levels, + num_query, + num_point, + grad_value, + grad_sampling_loc, + grad_attn_weight); + } + else + { + ms_deformable_col2im_gpu_kernel_shm_reduce_v2 + <<>>( + num_kernels, + grad_col, + data_value, + data_spatial_shapes, + data_level_start_index, + data_sampling_loc, + data_attn_weight, + batch_size, + spatial_size, + num_heads, + channels, + num_levels, + num_query, + num_point, + grad_value, + grad_sampling_loc, + grad_attn_weight); + } + } + } + cudaError_t err = cudaGetLastError(); + if (err != cudaSuccess) + { + printf("error in ms_deformable_col2im_cuda: %s\n", cudaGetErrorString(err)); + } + +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000000000000000000000000000000000000..6fe55afb5a309a71720974748f2796b5c26a2f05 --- /dev/null +++ b/flake.nix @@ -0,0 +1,14 @@ +{ + description = "Flake for deformable_detr kernels"; + + inputs = { + kernel-builder.url = "git+ssh://git@github.com/huggingface/kernel-builder"; + }; + + outputs = + { + self, + kernel-builder, + }: + kernel-builder.lib.genFlakeOutputs ./.; +} diff --git a/media/benches_dark_animation.svg b/media/benches_dark_animation.svg deleted file mode 100644 index c0a1e976fa4e092b32e66f37cce4ce604b42f2ff..0000000000000000000000000000000000000000 --- a/media/benches_dark_animation.svg +++ /dev/null @@ -1,33 +0,0 @@ - -kernels-community/deformable-detr vs Torch - Relative Speed -PyTorch 2.11.0+cu130 · CPU - -MSDeformAttnBenchmark.forward -19.81x - - - - - - - -MSDeformAttnBenchmark.large -7.07x - - - - - - - -Kernel - -Torch (ref) - - - - - - - - \ No newline at end of file diff --git a/media/benches_dark_latency.svg b/media/benches_dark_latency.svg deleted file mode 100644 index 5f9dd4e282f2bec40ebad98733ee12832af0a82c..0000000000000000000000000000000000000000 --- a/media/benches_dark_latency.svg +++ /dev/null @@ -1,1936 +0,0 @@ - - - - - - - - 2026-04-17T20:56:04.447943 - image/svg+xml - - - Matplotlib v3.10.8, https://matplotlib.org/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/media/benches_dark_throughput.svg b/media/benches_dark_throughput.svg deleted file mode 100644 index 2dd1dedc0b853beebd01371c10fd662ddc4ceaa1..0000000000000000000000000000000000000000 --- a/media/benches_dark_throughput.svg +++ /dev/null @@ -1,2209 +0,0 @@ - - - - - - - - 2026-04-17T20:56:04.615321 - image/svg+xml - - - Matplotlib v3.10.8, https://matplotlib.org/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/media/benches_light_animation.svg b/media/benches_light_animation.svg deleted file mode 100644 index 1ea9b754f6bdf863e26860c649d39392a3bd373e..0000000000000000000000000000000000000000 --- a/media/benches_light_animation.svg +++ /dev/null @@ -1,33 +0,0 @@ - -kernels-community/deformable-detr vs Torch - Relative Speed -PyTorch 2.11.0+cu130 · CPU - -MSDeformAttnBenchmark.forward -19.81x - - - - - - - -MSDeformAttnBenchmark.large -7.07x - - - - - - - -Kernel - -Torch (ref) - - - - - - - - \ No newline at end of file diff --git a/media/benches_light_latency.svg b/media/benches_light_latency.svg deleted file mode 100644 index 64d0e4ccca5e9d66518a7203406039db7f91c9ee..0000000000000000000000000000000000000000 --- a/media/benches_light_latency.svg +++ /dev/null @@ -1,1936 +0,0 @@ - - - - - - - - 2026-04-17T20:56:03.846999 - image/svg+xml - - - Matplotlib v3.10.8, https://matplotlib.org/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/media/benches_light_throughput.svg b/media/benches_light_throughput.svg deleted file mode 100644 index 03a10a8b533cfebb3e4a6c342ac71d76bc815f4d..0000000000000000000000000000000000000000 --- a/media/benches_light_throughput.svg +++ /dev/null @@ -1,2209 +0,0 @@ - - - - - - - - 2026-04-17T20:56:04.167876 - image/svg+xml - - - Matplotlib v3.10.8, https://matplotlib.org/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/build/torch210-cxx11-cu126-aarch64-linux/__init__.py b/torch-ext/deformable_detr/__init__.py similarity index 100% rename from build/torch210-cxx11-cu126-aarch64-linux/__init__.py rename to torch-ext/deformable_detr/__init__.py diff --git a/build/torch210-cxx11-cu126-aarch64-linux/layers.py b/torch-ext/deformable_detr/layers.py similarity index 100% rename from build/torch210-cxx11-cu126-aarch64-linux/layers.py rename to torch-ext/deformable_detr/layers.py diff --git a/torch-ext/ms_deform_attn_cpu.cpp b/torch-ext/ms_deform_attn_cpu.cpp new file mode 100644 index 0000000000000000000000000000000000000000..388a73d22d4c9b561e2a887b50a1897b8cf2def9 --- /dev/null +++ b/torch-ext/ms_deform_attn_cpu.cpp @@ -0,0 +1,40 @@ +/*! +************************************************************************************************** +* Deformable DETR +* Copyright (c) 2020 SenseTime. All Rights Reserved. +* Licensed under the Apache License, Version 2.0 [see LICENSE for details] +************************************************************************************************** +* Modified from https://github.com/chengdazhi/Deformable-Convolution-V2-PyTorch/tree/pytorch_1.0.0 +************************************************************************************************** +*/ + +#include + +#include +#include + + +at::Tensor +ms_deform_attn_cpu_forward( + const at::Tensor &value, + const at::Tensor &spatial_shapes, + const at::Tensor &level_start_index, + const at::Tensor &sampling_loc, + const at::Tensor &attn_weight, + const int im2col_step) +{ + AT_ERROR("Not implement on cpu"); +} + +std::vector +ms_deform_attn_cpu_backward( + const at::Tensor &value, + const at::Tensor &spatial_shapes, + const at::Tensor &level_start_index, + const at::Tensor &sampling_loc, + const at::Tensor &attn_weight, + const at::Tensor &grad_output, + const int im2col_step) +{ + AT_ERROR("Not implement on cpu"); +} diff --git a/torch-ext/ms_deform_attn_cpu.h b/torch-ext/ms_deform_attn_cpu.h new file mode 100644 index 0000000000000000000000000000000000000000..7eac8c8bcd1bf529bb9c13d54d2d4215c9e4c89f --- /dev/null +++ b/torch-ext/ms_deform_attn_cpu.h @@ -0,0 +1,32 @@ +/*! +************************************************************************************************** +* Deformable DETR +* Copyright (c) 2020 SenseTime. All Rights Reserved. +* Licensed under the Apache License, Version 2.0 [see LICENSE for details] +************************************************************************************************** +* Modified from https://github.com/chengdazhi/Deformable-Convolution-V2-PyTorch/tree/pytorch_1.0.0 +************************************************************************************************** +*/ + +#pragma once +#include + +at::Tensor +ms_deform_attn_cpu_forward( + const at::Tensor &value, + const at::Tensor &spatial_shapes, + const at::Tensor &level_start_index, + const at::Tensor &sampling_loc, + const at::Tensor &attn_weight, + const int im2col_step); + +std::vector +ms_deform_attn_cpu_backward( + const at::Tensor &value, + const at::Tensor &spatial_shapes, + const at::Tensor &level_start_index, + const at::Tensor &sampling_loc, + const at::Tensor &attn_weight, + const at::Tensor &grad_output, + const int im2col_step); + diff --git a/torch-ext/torch_binding.cpp b/torch-ext/torch_binding.cpp new file mode 100644 index 0000000000000000000000000000000000000000..fb462761e30f07241c192fd610ac307ae3b76af2 --- /dev/null +++ b/torch-ext/torch_binding.cpp @@ -0,0 +1,19 @@ +#include + +#include "registration.h" +#include "torch_binding.h" + +TORCH_LIBRARY_EXPAND(TORCH_EXTENSION_NAME, ops) { + ops.def("ms_deform_attn_forward(Tensor value, Tensor spatial_shapes," + " Tensor level_start_index, Tensor sampling_loc," + " Tensor attn_weight, int im2col_step) -> Tensor"); + ops.impl("ms_deform_attn_forward", torch::kCUDA, &ms_deform_attn_cuda_forward); + + ops.def("ms_deform_attn_backward(Tensor value, Tensor spatial_shapes," + " Tensor level_start_index, Tensor sampling_loc," + " Tensor attn_weight, Tensor grad_output," + " int im2col_step) -> Tensor[]"); + ops.impl("ms_deform_attn_backward", torch::kCUDA, &ms_deform_attn_cuda_backward); +} + +REGISTER_EXTENSION(TORCH_EXTENSION_NAME) diff --git a/torch-ext/torch_binding.h b/torch-ext/torch_binding.h new file mode 100644 index 0000000000000000000000000000000000000000..e6e0d303971fc6641d03f610ea681369c82ff90f --- /dev/null +++ b/torch-ext/torch_binding.h @@ -0,0 +1,16 @@ +#pragma once + +#include + +at::Tensor ms_deform_attn_cuda_forward(const at::Tensor &value, + const at::Tensor &spatial_shapes, + const at::Tensor &level_start_index, + const at::Tensor &sampling_loc, + const at::Tensor &attn_weight, + const int64_t im2col_step); + +std::vector ms_deform_attn_cuda_backward( + const at::Tensor &value, const at::Tensor &spatial_shapes, + const at::Tensor &level_start_index, const at::Tensor &sampling_loc, + const at::Tensor &attn_weight, const at::Tensor &grad_output, + const int64_t im2col_step);