diff --git a/build/torch210-cxx11-cu126-x86_64-linux/__init__.py b/build/torch210-cxx11-cu126-x86_64-linux/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..33db73ca6e361af4707ba5bb5f55bf0e7c3005a4 --- /dev/null +++ b/build/torch210-cxx11-cu126-x86_64-linux/__init__.py @@ -0,0 +1,46 @@ +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_7ba5e9c.abi3.so b/build/torch210-cxx11-cu126-x86_64-linux/_deformable_detr_7ba5e9c.abi3.so new file mode 100644 index 0000000000000000000000000000000000000000..2343a37f1fe861f198f5d5451bf4a0a568a67d90 --- /dev/null +++ b/build/torch210-cxx11-cu126-x86_64-linux/_deformable_detr_7ba5e9c.abi3.so @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:983865cafc6b57fb51e47143078b330f21ceb02c4f0a0a4408cdca2c96d6bb72 +size 8541064 diff --git a/build/torch210-cxx11-cu126-x86_64-linux/_ops.py b/build/torch210-cxx11-cu126-x86_64-linux/_ops.py new file mode 100644 index 0000000000000000000000000000000000000000..a4397f8617212897a5959166d63eaa3a01e1074a --- /dev/null +++ b/build/torch210-cxx11-cu126-x86_64-linux/_ops.py @@ -0,0 +1,9 @@ +import torch +from . import _deformable_detr_7ba5e9c +ops = torch.ops._deformable_detr_7ba5e9c + +def add_op_namespace_prefix(op_name: str): + """ + Prefix op by namespace. + """ + return f"_deformable_detr_7ba5e9c::{op_name}" \ No newline at end of file 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 new file mode 100644 index 0000000000000000000000000000000000000000..03dbc1afe1cf156661a2b1b22003cd5f599a0309 --- /dev/null +++ b/build/torch210-cxx11-cu126-x86_64-linux/deformable_detr/__init__.py @@ -0,0 +1,26 @@ +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-cxx11-cu126-x86_64-linux/layers.py b/build/torch210-cxx11-cu126-x86_64-linux/layers.py new file mode 100644 index 0000000000000000000000000000000000000000..db94032dea3d445f27017f923ae80468e18d2d77 --- /dev/null +++ b/build/torch210-cxx11-cu126-x86_64-linux/layers.py @@ -0,0 +1,84 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..76bafa5f33b6818aa6bb4cab04be811b87519b44 --- /dev/null +++ b/build/torch210-cxx11-cu126-x86_64-linux/metadata.json @@ -0,0 +1 @@ +{"python-depends":[]} \ No newline at end of file diff --git a/build/torch210-cxx11-cu128-x86_64-linux/__init__.py b/build/torch210-cxx11-cu128-x86_64-linux/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..33db73ca6e361af4707ba5bb5f55bf0e7c3005a4 --- /dev/null +++ b/build/torch210-cxx11-cu128-x86_64-linux/__init__.py @@ -0,0 +1,46 @@ +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_7ba5e9c.abi3.so b/build/torch210-cxx11-cu128-x86_64-linux/_deformable_detr_7ba5e9c.abi3.so new file mode 100644 index 0000000000000000000000000000000000000000..16620e4afe046f25f38c86d0305b28b43ea6e6c3 --- /dev/null +++ b/build/torch210-cxx11-cu128-x86_64-linux/_deformable_detr_7ba5e9c.abi3.so @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5622c742bb45a864c22f78340b820f45651868ea8e34e6e4fa5f11ae99421901 +size 11524544 diff --git a/build/torch210-cxx11-cu128-x86_64-linux/_ops.py b/build/torch210-cxx11-cu128-x86_64-linux/_ops.py new file mode 100644 index 0000000000000000000000000000000000000000..a4397f8617212897a5959166d63eaa3a01e1074a --- /dev/null +++ b/build/torch210-cxx11-cu128-x86_64-linux/_ops.py @@ -0,0 +1,9 @@ +import torch +from . import _deformable_detr_7ba5e9c +ops = torch.ops._deformable_detr_7ba5e9c + +def add_op_namespace_prefix(op_name: str): + """ + Prefix op by namespace. + """ + return f"_deformable_detr_7ba5e9c::{op_name}" \ No newline at end of file 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 new file mode 100644 index 0000000000000000000000000000000000000000..03dbc1afe1cf156661a2b1b22003cd5f599a0309 --- /dev/null +++ b/build/torch210-cxx11-cu128-x86_64-linux/deformable_detr/__init__.py @@ -0,0 +1,26 @@ +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-cxx11-cu128-x86_64-linux/layers.py b/build/torch210-cxx11-cu128-x86_64-linux/layers.py new file mode 100644 index 0000000000000000000000000000000000000000..db94032dea3d445f27017f923ae80468e18d2d77 --- /dev/null +++ b/build/torch210-cxx11-cu128-x86_64-linux/layers.py @@ -0,0 +1,84 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..76bafa5f33b6818aa6bb4cab04be811b87519b44 --- /dev/null +++ b/build/torch210-cxx11-cu128-x86_64-linux/metadata.json @@ -0,0 +1 @@ +{"python-depends":[]} \ No newline at end of file diff --git a/build/torch210-cxx11-cu130-x86_64-linux/__init__.py b/build/torch210-cxx11-cu130-x86_64-linux/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..33db73ca6e361af4707ba5bb5f55bf0e7c3005a4 --- /dev/null +++ b/build/torch210-cxx11-cu130-x86_64-linux/__init__.py @@ -0,0 +1,46 @@ +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_7ba5e9c.abi3.so b/build/torch210-cxx11-cu130-x86_64-linux/_deformable_detr_7ba5e9c.abi3.so new file mode 100644 index 0000000000000000000000000000000000000000..af817c65848084576b573c51eb7ea7e74d728fd9 --- /dev/null +++ b/build/torch210-cxx11-cu130-x86_64-linux/_deformable_detr_7ba5e9c.abi3.so @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cc258c88b7ebdaa8ab9027b34b111677b6d19fef02d4db23cf7d9f05139ecdd6 +size 9808352 diff --git a/build/torch210-cxx11-cu130-x86_64-linux/_ops.py b/build/torch210-cxx11-cu130-x86_64-linux/_ops.py new file mode 100644 index 0000000000000000000000000000000000000000..a4397f8617212897a5959166d63eaa3a01e1074a --- /dev/null +++ b/build/torch210-cxx11-cu130-x86_64-linux/_ops.py @@ -0,0 +1,9 @@ +import torch +from . import _deformable_detr_7ba5e9c +ops = torch.ops._deformable_detr_7ba5e9c + +def add_op_namespace_prefix(op_name: str): + """ + Prefix op by namespace. + """ + return f"_deformable_detr_7ba5e9c::{op_name}" \ No newline at end of file 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 new file mode 100644 index 0000000000000000000000000000000000000000..03dbc1afe1cf156661a2b1b22003cd5f599a0309 --- /dev/null +++ b/build/torch210-cxx11-cu130-x86_64-linux/deformable_detr/__init__.py @@ -0,0 +1,26 @@ +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-cxx11-cu130-x86_64-linux/layers.py b/build/torch210-cxx11-cu130-x86_64-linux/layers.py new file mode 100644 index 0000000000000000000000000000000000000000..db94032dea3d445f27017f923ae80468e18d2d77 --- /dev/null +++ b/build/torch210-cxx11-cu130-x86_64-linux/layers.py @@ -0,0 +1,84 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..76bafa5f33b6818aa6bb4cab04be811b87519b44 --- /dev/null +++ b/build/torch210-cxx11-cu130-x86_64-linux/metadata.json @@ -0,0 +1 @@ +{"python-depends":[]} \ No newline at end of file diff --git a/build/torch28-cxx11-cu126-x86_64-linux/__init__.py b/build/torch28-cxx11-cu126-x86_64-linux/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..33db73ca6e361af4707ba5bb5f55bf0e7c3005a4 --- /dev/null +++ b/build/torch28-cxx11-cu126-x86_64-linux/__init__.py @@ -0,0 +1,46 @@ +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_7ba5e9c.abi3.so b/build/torch28-cxx11-cu126-x86_64-linux/_deformable_detr_7ba5e9c.abi3.so new file mode 100644 index 0000000000000000000000000000000000000000..f8d27ef90d14d4fb191fa694ae465ccbc8b956ca --- /dev/null +++ b/build/torch28-cxx11-cu126-x86_64-linux/_deformable_detr_7ba5e9c.abi3.so @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9e7f8052b26751544b2a4c8aab8af4ab90628823b85a64dcd79f6405de428361 +size 8535712 diff --git a/build/torch28-cxx11-cu126-x86_64-linux/_ops.py b/build/torch28-cxx11-cu126-x86_64-linux/_ops.py new file mode 100644 index 0000000000000000000000000000000000000000..a4397f8617212897a5959166d63eaa3a01e1074a --- /dev/null +++ b/build/torch28-cxx11-cu126-x86_64-linux/_ops.py @@ -0,0 +1,9 @@ +import torch +from . import _deformable_detr_7ba5e9c +ops = torch.ops._deformable_detr_7ba5e9c + +def add_op_namespace_prefix(op_name: str): + """ + Prefix op by namespace. + """ + return f"_deformable_detr_7ba5e9c::{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 new file mode 100644 index 0000000000000000000000000000000000000000..03dbc1afe1cf156661a2b1b22003cd5f599a0309 --- /dev/null +++ b/build/torch28-cxx11-cu126-x86_64-linux/deformable_detr/__init__.py @@ -0,0 +1,26 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..db94032dea3d445f27017f923ae80468e18d2d77 --- /dev/null +++ b/build/torch28-cxx11-cu126-x86_64-linux/layers.py @@ -0,0 +1,84 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..76bafa5f33b6818aa6bb4cab04be811b87519b44 --- /dev/null +++ b/build/torch28-cxx11-cu126-x86_64-linux/metadata.json @@ -0,0 +1 @@ +{"python-depends":[]} \ No newline at end of file diff --git a/build/torch28-cxx11-cu128-x86_64-linux/__init__.py b/build/torch28-cxx11-cu128-x86_64-linux/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..33db73ca6e361af4707ba5bb5f55bf0e7c3005a4 --- /dev/null +++ b/build/torch28-cxx11-cu128-x86_64-linux/__init__.py @@ -0,0 +1,46 @@ +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_7ba5e9c.abi3.so b/build/torch28-cxx11-cu128-x86_64-linux/_deformable_detr_7ba5e9c.abi3.so new file mode 100644 index 0000000000000000000000000000000000000000..c1f8f06915afb89ed66bcafb029cb10fa4eceeb6 --- /dev/null +++ b/build/torch28-cxx11-cu128-x86_64-linux/_deformable_detr_7ba5e9c.abi3.so @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e81e1303c5583c4bf177b118ae1f32dc8e5c7c21edb5314147ea8f969ea001a0 +size 11523184 diff --git a/build/torch28-cxx11-cu128-x86_64-linux/_ops.py b/build/torch28-cxx11-cu128-x86_64-linux/_ops.py new file mode 100644 index 0000000000000000000000000000000000000000..a4397f8617212897a5959166d63eaa3a01e1074a --- /dev/null +++ b/build/torch28-cxx11-cu128-x86_64-linux/_ops.py @@ -0,0 +1,9 @@ +import torch +from . import _deformable_detr_7ba5e9c +ops = torch.ops._deformable_detr_7ba5e9c + +def add_op_namespace_prefix(op_name: str): + """ + Prefix op by namespace. + """ + return f"_deformable_detr_7ba5e9c::{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 new file mode 100644 index 0000000000000000000000000000000000000000..03dbc1afe1cf156661a2b1b22003cd5f599a0309 --- /dev/null +++ b/build/torch28-cxx11-cu128-x86_64-linux/deformable_detr/__init__.py @@ -0,0 +1,26 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..db94032dea3d445f27017f923ae80468e18d2d77 --- /dev/null +++ b/build/torch28-cxx11-cu128-x86_64-linux/layers.py @@ -0,0 +1,84 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..76bafa5f33b6818aa6bb4cab04be811b87519b44 --- /dev/null +++ b/build/torch28-cxx11-cu128-x86_64-linux/metadata.json @@ -0,0 +1 @@ +{"python-depends":[]} \ No newline at end of file diff --git a/build/torch28-cxx11-cu129-x86_64-linux/__init__.py b/build/torch28-cxx11-cu129-x86_64-linux/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..33db73ca6e361af4707ba5bb5f55bf0e7c3005a4 --- /dev/null +++ b/build/torch28-cxx11-cu129-x86_64-linux/__init__.py @@ -0,0 +1,46 @@ +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_7ba5e9c.abi3.so b/build/torch28-cxx11-cu129-x86_64-linux/_deformable_detr_7ba5e9c.abi3.so new file mode 100644 index 0000000000000000000000000000000000000000..b52496e5572cf13f42afd04ec73fc3994243dc66 --- /dev/null +++ b/build/torch28-cxx11-cu129-x86_64-linux/_deformable_detr_7ba5e9c.abi3.so @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:86846cc3da17baceee74f2a1420fb466e4a2120447760b3898e99ac6aaf34683 +size 11581544 diff --git a/build/torch28-cxx11-cu129-x86_64-linux/_ops.py b/build/torch28-cxx11-cu129-x86_64-linux/_ops.py new file mode 100644 index 0000000000000000000000000000000000000000..a4397f8617212897a5959166d63eaa3a01e1074a --- /dev/null +++ b/build/torch28-cxx11-cu129-x86_64-linux/_ops.py @@ -0,0 +1,9 @@ +import torch +from . import _deformable_detr_7ba5e9c +ops = torch.ops._deformable_detr_7ba5e9c + +def add_op_namespace_prefix(op_name: str): + """ + Prefix op by namespace. + """ + return f"_deformable_detr_7ba5e9c::{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 new file mode 100644 index 0000000000000000000000000000000000000000..03dbc1afe1cf156661a2b1b22003cd5f599a0309 --- /dev/null +++ b/build/torch28-cxx11-cu129-x86_64-linux/deformable_detr/__init__.py @@ -0,0 +1,26 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..db94032dea3d445f27017f923ae80468e18d2d77 --- /dev/null +++ b/build/torch28-cxx11-cu129-x86_64-linux/layers.py @@ -0,0 +1,84 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..76bafa5f33b6818aa6bb4cab04be811b87519b44 --- /dev/null +++ b/build/torch28-cxx11-cu129-x86_64-linux/metadata.json @@ -0,0 +1 @@ +{"python-depends":[]} \ No newline at end of file diff --git a/build/torch29-cxx11-cu126-x86_64-linux/__init__.py b/build/torch29-cxx11-cu126-x86_64-linux/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..33db73ca6e361af4707ba5bb5f55bf0e7c3005a4 --- /dev/null +++ b/build/torch29-cxx11-cu126-x86_64-linux/__init__.py @@ -0,0 +1,46 @@ +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_7ba5e9c.abi3.so b/build/torch29-cxx11-cu126-x86_64-linux/_deformable_detr_7ba5e9c.abi3.so new file mode 100644 index 0000000000000000000000000000000000000000..bd1a80fc42c4876731fffd2323b658c814f02c36 --- /dev/null +++ b/build/torch29-cxx11-cu126-x86_64-linux/_deformable_detr_7ba5e9c.abi3.so @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ef56a6b25a1798b09cb41bf7f0e5afd3ac1681edff68e0a576f83b6cef9dea1d +size 8535872 diff --git a/build/torch29-cxx11-cu126-x86_64-linux/_ops.py b/build/torch29-cxx11-cu126-x86_64-linux/_ops.py new file mode 100644 index 0000000000000000000000000000000000000000..a4397f8617212897a5959166d63eaa3a01e1074a --- /dev/null +++ b/build/torch29-cxx11-cu126-x86_64-linux/_ops.py @@ -0,0 +1,9 @@ +import torch +from . import _deformable_detr_7ba5e9c +ops = torch.ops._deformable_detr_7ba5e9c + +def add_op_namespace_prefix(op_name: str): + """ + Prefix op by namespace. + """ + return f"_deformable_detr_7ba5e9c::{op_name}" \ No newline at end of file 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 new file mode 100644 index 0000000000000000000000000000000000000000..03dbc1afe1cf156661a2b1b22003cd5f599a0309 --- /dev/null +++ b/build/torch29-cxx11-cu126-x86_64-linux/deformable_detr/__init__.py @@ -0,0 +1,26 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..db94032dea3d445f27017f923ae80468e18d2d77 --- /dev/null +++ b/build/torch29-cxx11-cu126-x86_64-linux/layers.py @@ -0,0 +1,84 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..76bafa5f33b6818aa6bb4cab04be811b87519b44 --- /dev/null +++ b/build/torch29-cxx11-cu126-x86_64-linux/metadata.json @@ -0,0 +1 @@ +{"python-depends":[]} \ No newline at end of file diff --git a/build/torch29-cxx11-cu128-x86_64-linux/__init__.py b/build/torch29-cxx11-cu128-x86_64-linux/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..33db73ca6e361af4707ba5bb5f55bf0e7c3005a4 --- /dev/null +++ b/build/torch29-cxx11-cu128-x86_64-linux/__init__.py @@ -0,0 +1,46 @@ +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_7ba5e9c.abi3.so b/build/torch29-cxx11-cu128-x86_64-linux/_deformable_detr_7ba5e9c.abi3.so new file mode 100644 index 0000000000000000000000000000000000000000..7bb276ac18be8a1c728a20d25af5bbb34ab9d206 --- /dev/null +++ b/build/torch29-cxx11-cu128-x86_64-linux/_deformable_detr_7ba5e9c.abi3.so @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c93a6b99ce46547f1ef6eb1e049eac25600e87fa27e7cf4ff72bcfded6d4e961 +size 11519248 diff --git a/build/torch29-cxx11-cu128-x86_64-linux/_ops.py b/build/torch29-cxx11-cu128-x86_64-linux/_ops.py new file mode 100644 index 0000000000000000000000000000000000000000..a4397f8617212897a5959166d63eaa3a01e1074a --- /dev/null +++ b/build/torch29-cxx11-cu128-x86_64-linux/_ops.py @@ -0,0 +1,9 @@ +import torch +from . import _deformable_detr_7ba5e9c +ops = torch.ops._deformable_detr_7ba5e9c + +def add_op_namespace_prefix(op_name: str): + """ + Prefix op by namespace. + """ + return f"_deformable_detr_7ba5e9c::{op_name}" \ No newline at end of file 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 new file mode 100644 index 0000000000000000000000000000000000000000..03dbc1afe1cf156661a2b1b22003cd5f599a0309 --- /dev/null +++ b/build/torch29-cxx11-cu128-x86_64-linux/deformable_detr/__init__.py @@ -0,0 +1,26 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..db94032dea3d445f27017f923ae80468e18d2d77 --- /dev/null +++ b/build/torch29-cxx11-cu128-x86_64-linux/layers.py @@ -0,0 +1,84 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..76bafa5f33b6818aa6bb4cab04be811b87519b44 --- /dev/null +++ b/build/torch29-cxx11-cu128-x86_64-linux/metadata.json @@ -0,0 +1 @@ +{"python-depends":[]} \ No newline at end of file diff --git a/build/torch29-cxx11-cu130-x86_64-linux/__init__.py b/build/torch29-cxx11-cu130-x86_64-linux/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..33db73ca6e361af4707ba5bb5f55bf0e7c3005a4 --- /dev/null +++ b/build/torch29-cxx11-cu130-x86_64-linux/__init__.py @@ -0,0 +1,46 @@ +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_7ba5e9c.abi3.so b/build/torch29-cxx11-cu130-x86_64-linux/_deformable_detr_7ba5e9c.abi3.so new file mode 100644 index 0000000000000000000000000000000000000000..6a9cc49f7b73af7e7acc5efe5965245e4b795179 --- /dev/null +++ b/build/torch29-cxx11-cu130-x86_64-linux/_deformable_detr_7ba5e9c.abi3.so @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9dc30eee0301361f310aa369b4768d714a023bd825d202fe133d9bb17150ac70 +size 9803056 diff --git a/build/torch29-cxx11-cu130-x86_64-linux/_ops.py b/build/torch29-cxx11-cu130-x86_64-linux/_ops.py new file mode 100644 index 0000000000000000000000000000000000000000..a4397f8617212897a5959166d63eaa3a01e1074a --- /dev/null +++ b/build/torch29-cxx11-cu130-x86_64-linux/_ops.py @@ -0,0 +1,9 @@ +import torch +from . import _deformable_detr_7ba5e9c +ops = torch.ops._deformable_detr_7ba5e9c + +def add_op_namespace_prefix(op_name: str): + """ + Prefix op by namespace. + """ + return f"_deformable_detr_7ba5e9c::{op_name}" \ No newline at end of file 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 new file mode 100644 index 0000000000000000000000000000000000000000..03dbc1afe1cf156661a2b1b22003cd5f599a0309 --- /dev/null +++ b/build/torch29-cxx11-cu130-x86_64-linux/deformable_detr/__init__.py @@ -0,0 +1,26 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..db94032dea3d445f27017f923ae80468e18d2d77 --- /dev/null +++ b/build/torch29-cxx11-cu130-x86_64-linux/layers.py @@ -0,0 +1,84 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..76bafa5f33b6818aa6bb4cab04be811b87519b44 --- /dev/null +++ b/build/torch29-cxx11-cu130-x86_64-linux/metadata.json @@ -0,0 +1 @@ +{"python-depends":[]} \ No newline at end of file