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/torch28-cxx11-cu126-x86_64-linux/deformable_detr/layers.py b/build/torch210-cxx11-cu126-x86_64-linux/layers.py similarity index 100% rename from build/torch28-cxx11-cu126-x86_64-linux/deformable_detr/layers.py rename to build/torch210-cxx11-cu126-x86_64-linux/layers.py 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/torch28-cxx11-cu128-x86_64-linux/deformable_detr/layers.py b/build/torch210-cxx11-cu128-x86_64-linux/layers.py similarity index 100% rename from build/torch28-cxx11-cu128-x86_64-linux/deformable_detr/layers.py rename to build/torch210-cxx11-cu128-x86_64-linux/layers.py 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/torch28-cxx11-cu129-x86_64-linux/deformable_detr/layers.py b/build/torch210-cxx11-cu130-x86_64-linux/layers.py similarity index 100% rename from build/torch28-cxx11-cu129-x86_64-linux/deformable_detr/layers.py rename to build/torch210-cxx11-cu130-x86_64-linux/layers.py 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 index 33db73ca6e361af4707ba5bb5f55bf0e7c3005a4..03dbc1afe1cf156661a2b1b22003cd5f599a0309 100644 --- a/build/torch28-cxx11-cu126-x86_64-linux/deformable_detr/__init__.py +++ b/build/torch28-cxx11-cu126-x86_64-linux/deformable_detr/__init__.py @@ -1,46 +1,26 @@ -from typing import List -import torch +import ctypes +import sys -from ._ops import ops -from . import layers +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 -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"] +globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py"))) diff --git a/build/torch28-cxx11-cu126-x86_64-linux/deformable_detr/__pycache__/__init__.cpython-313.pyc b/build/torch28-cxx11-cu126-x86_64-linux/deformable_detr/__pycache__/__init__.cpython-313.pyc deleted file mode 100644 index f32e9680149e4cd221db4979650b6a906f100d0c..0000000000000000000000000000000000000000 Binary files a/build/torch28-cxx11-cu126-x86_64-linux/deformable_detr/__pycache__/__init__.cpython-313.pyc and /dev/null differ diff --git a/build/torch28-cxx11-cu126-x86_64-linux/deformable_detr/__pycache__/_ops.cpython-313.pyc b/build/torch28-cxx11-cu126-x86_64-linux/deformable_detr/__pycache__/_ops.cpython-313.pyc deleted file mode 100644 index 9646bab073177cb7fbc71402b07217a9f10d272c..0000000000000000000000000000000000000000 Binary files a/build/torch28-cxx11-cu126-x86_64-linux/deformable_detr/__pycache__/_ops.cpython-313.pyc and /dev/null differ diff --git a/build/torch28-cxx11-cu126-x86_64-linux/deformable_detr/__pycache__/layers.cpython-313.pyc b/build/torch28-cxx11-cu126-x86_64-linux/deformable_detr/__pycache__/layers.cpython-313.pyc deleted file mode 100644 index d64f4e9e755556c506f2664826051738bb2865d1..0000000000000000000000000000000000000000 Binary files a/build/torch28-cxx11-cu126-x86_64-linux/deformable_detr/__pycache__/layers.cpython-313.pyc and /dev/null differ diff --git a/build/torch28-cxx11-cu126-x86_64-linux/deformable_detr/_deformable_detr_57c3d32.abi3.so b/build/torch28-cxx11-cu126-x86_64-linux/deformable_detr/_deformable_detr_57c3d32.abi3.so deleted file mode 100644 index bf945166a200b4f9e52aa2f36e040ca4908a70d9..0000000000000000000000000000000000000000 --- a/build/torch28-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:849b408dcea47846a61de3e2c5dc178297e38ac85542e99d737887da93b199e6 -size 6920920 diff --git a/build/torch28-cxx11-cu126-x86_64-linux/deformable_detr/_ops.py b/build/torch28-cxx11-cu126-x86_64-linux/deformable_detr/_ops.py deleted file mode 100644 index 39c2aa7875432779e86612a0e56271fe32133953..0000000000000000000000000000000000000000 --- a/build/torch28-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/torch29-cxx11-cu126-x86_64-linux/deformable_detr/layers.py b/build/torch28-cxx11-cu126-x86_64-linux/layers.py similarity index 100% rename from build/torch29-cxx11-cu126-x86_64-linux/deformable_detr/layers.py rename to build/torch28-cxx11-cu126-x86_64-linux/layers.py 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 index 33db73ca6e361af4707ba5bb5f55bf0e7c3005a4..03dbc1afe1cf156661a2b1b22003cd5f599a0309 100644 --- a/build/torch28-cxx11-cu128-x86_64-linux/deformable_detr/__init__.py +++ b/build/torch28-cxx11-cu128-x86_64-linux/deformable_detr/__init__.py @@ -1,46 +1,26 @@ -from typing import List -import torch +import ctypes +import sys -from ._ops import ops -from . import layers +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 -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"] +globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py"))) diff --git a/build/torch28-cxx11-cu128-x86_64-linux/deformable_detr/__pycache__/__init__.cpython-313.pyc b/build/torch28-cxx11-cu128-x86_64-linux/deformable_detr/__pycache__/__init__.cpython-313.pyc deleted file mode 100644 index 264f58df0be3c0f045f23cf24bd6c1def92e06c0..0000000000000000000000000000000000000000 Binary files a/build/torch28-cxx11-cu128-x86_64-linux/deformable_detr/__pycache__/__init__.cpython-313.pyc and /dev/null differ diff --git a/build/torch28-cxx11-cu128-x86_64-linux/deformable_detr/__pycache__/_ops.cpython-313.pyc b/build/torch28-cxx11-cu128-x86_64-linux/deformable_detr/__pycache__/_ops.cpython-313.pyc deleted file mode 100644 index cb732e520b638059885d997eabb67a9fc63ca8fe..0000000000000000000000000000000000000000 Binary files a/build/torch28-cxx11-cu128-x86_64-linux/deformable_detr/__pycache__/_ops.cpython-313.pyc and /dev/null differ diff --git a/build/torch28-cxx11-cu128-x86_64-linux/deformable_detr/__pycache__/layers.cpython-313.pyc b/build/torch28-cxx11-cu128-x86_64-linux/deformable_detr/__pycache__/layers.cpython-313.pyc deleted file mode 100644 index b5e17a04e38c21bdda0cee7084e1de99b4ce08f2..0000000000000000000000000000000000000000 Binary files a/build/torch28-cxx11-cu128-x86_64-linux/deformable_detr/__pycache__/layers.cpython-313.pyc and /dev/null differ diff --git a/build/torch28-cxx11-cu128-x86_64-linux/deformable_detr/_deformable_detr_57c3d32.abi3.so b/build/torch28-cxx11-cu128-x86_64-linux/deformable_detr/_deformable_detr_57c3d32.abi3.so deleted file mode 100644 index 9ef04523d02d5e1f4e045048c754d812c141414b..0000000000000000000000000000000000000000 --- a/build/torch28-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:488b575c5239b051da77051e49fe2b33d62574ed4cae68f71e0758527eee5536 -size 9908376 diff --git a/build/torch28-cxx11-cu128-x86_64-linux/deformable_detr/_ops.py b/build/torch28-cxx11-cu128-x86_64-linux/deformable_detr/_ops.py deleted file mode 100644 index 39c2aa7875432779e86612a0e56271fe32133953..0000000000000000000000000000000000000000 --- a/build/torch28-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/torch29-cxx11-cu128-x86_64-linux/deformable_detr/layers.py b/build/torch28-cxx11-cu128-x86_64-linux/layers.py similarity index 100% rename from build/torch29-cxx11-cu128-x86_64-linux/deformable_detr/layers.py rename to build/torch28-cxx11-cu128-x86_64-linux/layers.py 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 index 33db73ca6e361af4707ba5bb5f55bf0e7c3005a4..03dbc1afe1cf156661a2b1b22003cd5f599a0309 100644 --- a/build/torch28-cxx11-cu129-x86_64-linux/deformable_detr/__init__.py +++ b/build/torch28-cxx11-cu129-x86_64-linux/deformable_detr/__init__.py @@ -1,46 +1,26 @@ -from typing import List -import torch +import ctypes +import sys -from ._ops import ops -from . import layers +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 -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"] +globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py"))) diff --git a/build/torch28-cxx11-cu129-x86_64-linux/deformable_detr/__pycache__/__init__.cpython-313.pyc b/build/torch28-cxx11-cu129-x86_64-linux/deformable_detr/__pycache__/__init__.cpython-313.pyc deleted file mode 100644 index 5a86ac0bab49c777c7577e3f73598fdf618c0c0c..0000000000000000000000000000000000000000 Binary files a/build/torch28-cxx11-cu129-x86_64-linux/deformable_detr/__pycache__/__init__.cpython-313.pyc and /dev/null differ diff --git a/build/torch28-cxx11-cu129-x86_64-linux/deformable_detr/__pycache__/_ops.cpython-313.pyc b/build/torch28-cxx11-cu129-x86_64-linux/deformable_detr/__pycache__/_ops.cpython-313.pyc deleted file mode 100644 index e43032a1eaa83b3618f37e584765b8b3e0bddf21..0000000000000000000000000000000000000000 Binary files a/build/torch28-cxx11-cu129-x86_64-linux/deformable_detr/__pycache__/_ops.cpython-313.pyc and /dev/null differ diff --git a/build/torch28-cxx11-cu129-x86_64-linux/deformable_detr/__pycache__/layers.cpython-313.pyc b/build/torch28-cxx11-cu129-x86_64-linux/deformable_detr/__pycache__/layers.cpython-313.pyc deleted file mode 100644 index 497112af9fc891d11bc189fb4e15a0c52da14b97..0000000000000000000000000000000000000000 Binary files a/build/torch28-cxx11-cu129-x86_64-linux/deformable_detr/__pycache__/layers.cpython-313.pyc and /dev/null differ diff --git a/build/torch28-cxx11-cu129-x86_64-linux/deformable_detr/_deformable_detr_57c3d32.abi3.so b/build/torch28-cxx11-cu129-x86_64-linux/deformable_detr/_deformable_detr_57c3d32.abi3.so deleted file mode 100644 index 5e90422ff89601ef7fc17a67b10623286d08807e..0000000000000000000000000000000000000000 --- a/build/torch28-cxx11-cu129-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:e5cd16143ec4df47d54c69fef2541ae9a03ac5f8c2c018526822f7ae321510d7 -size 9962640 diff --git a/build/torch28-cxx11-cu129-x86_64-linux/deformable_detr/_ops.py b/build/torch28-cxx11-cu129-x86_64-linux/deformable_detr/_ops.py deleted file mode 100644 index 39c2aa7875432779e86612a0e56271fe32133953..0000000000000000000000000000000000000000 --- a/build/torch28-cxx11-cu129-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/torch29-cxx11-cu130-x86_64-linux/deformable_detr/layers.py b/build/torch28-cxx11-cu129-x86_64-linux/layers.py similarity index 100% rename from build/torch29-cxx11-cu130-x86_64-linux/deformable_detr/layers.py rename to build/torch28-cxx11-cu129-x86_64-linux/layers.py 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 index 33db73ca6e361af4707ba5bb5f55bf0e7c3005a4..03dbc1afe1cf156661a2b1b22003cd5f599a0309 100644 --- a/build/torch29-cxx11-cu126-x86_64-linux/deformable_detr/__init__.py +++ b/build/torch29-cxx11-cu126-x86_64-linux/deformable_detr/__init__.py @@ -1,46 +1,26 @@ -from typing import List -import torch +import ctypes +import sys -from ._ops import ops -from . import layers +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 -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"] +globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py"))) diff --git a/build/torch29-cxx11-cu126-x86_64-linux/deformable_detr/__pycache__/__init__.cpython-313.pyc b/build/torch29-cxx11-cu126-x86_64-linux/deformable_detr/__pycache__/__init__.cpython-313.pyc deleted file mode 100644 index a26657ec0d9332b7515de8efcde53094ad119bad..0000000000000000000000000000000000000000 Binary files a/build/torch29-cxx11-cu126-x86_64-linux/deformable_detr/__pycache__/__init__.cpython-313.pyc and /dev/null differ diff --git a/build/torch29-cxx11-cu126-x86_64-linux/deformable_detr/__pycache__/_ops.cpython-313.pyc b/build/torch29-cxx11-cu126-x86_64-linux/deformable_detr/__pycache__/_ops.cpython-313.pyc deleted file mode 100644 index f7def8aaa205795905bed3cbacd899fc37478dfa..0000000000000000000000000000000000000000 Binary files a/build/torch29-cxx11-cu126-x86_64-linux/deformable_detr/__pycache__/_ops.cpython-313.pyc and /dev/null differ diff --git a/build/torch29-cxx11-cu126-x86_64-linux/deformable_detr/__pycache__/layers.cpython-313.pyc b/build/torch29-cxx11-cu126-x86_64-linux/deformable_detr/__pycache__/layers.cpython-313.pyc deleted file mode 100644 index 67ffc374461840a598bab9d9f1a7e0ceea9bd10d..0000000000000000000000000000000000000000 Binary files a/build/torch29-cxx11-cu126-x86_64-linux/deformable_detr/__pycache__/layers.cpython-313.pyc and /dev/null differ diff --git a/build/torch29-cxx11-cu126-x86_64-linux/deformable_detr/_deformable_detr_57c3d32.abi3.so b/build/torch29-cxx11-cu126-x86_64-linux/deformable_detr/_deformable_detr_57c3d32.abi3.so deleted file mode 100644 index cbace88a56a9a0017db60de393e51d19475a5de5..0000000000000000000000000000000000000000 --- a/build/torch29-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:00131225eeba3d13bf037c67017b3e1ff8ce61ba77e874af2f2dd817aec5f7b5 -size 6921080 diff --git a/build/torch29-cxx11-cu126-x86_64-linux/deformable_detr/_ops.py b/build/torch29-cxx11-cu126-x86_64-linux/deformable_detr/_ops.py deleted file mode 100644 index 39c2aa7875432779e86612a0e56271fe32133953..0000000000000000000000000000000000000000 --- a/build/torch29-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/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 index 33db73ca6e361af4707ba5bb5f55bf0e7c3005a4..03dbc1afe1cf156661a2b1b22003cd5f599a0309 100644 --- a/build/torch29-cxx11-cu128-x86_64-linux/deformable_detr/__init__.py +++ b/build/torch29-cxx11-cu128-x86_64-linux/deformable_detr/__init__.py @@ -1,46 +1,26 @@ -from typing import List -import torch +import ctypes +import sys -from ._ops import ops -from . import layers +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 -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"] +globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py"))) diff --git a/build/torch29-cxx11-cu128-x86_64-linux/deformable_detr/__pycache__/__init__.cpython-313.pyc b/build/torch29-cxx11-cu128-x86_64-linux/deformable_detr/__pycache__/__init__.cpython-313.pyc deleted file mode 100644 index 363481f310583eed1593b42b506068180ca677f2..0000000000000000000000000000000000000000 Binary files a/build/torch29-cxx11-cu128-x86_64-linux/deformable_detr/__pycache__/__init__.cpython-313.pyc and /dev/null differ diff --git a/build/torch29-cxx11-cu128-x86_64-linux/deformable_detr/__pycache__/_ops.cpython-313.pyc b/build/torch29-cxx11-cu128-x86_64-linux/deformable_detr/__pycache__/_ops.cpython-313.pyc deleted file mode 100644 index 5ae8224c73e0082fa57c097cb36ac6e649dbdb82..0000000000000000000000000000000000000000 Binary files a/build/torch29-cxx11-cu128-x86_64-linux/deformable_detr/__pycache__/_ops.cpython-313.pyc and /dev/null differ diff --git a/build/torch29-cxx11-cu128-x86_64-linux/deformable_detr/__pycache__/layers.cpython-313.pyc b/build/torch29-cxx11-cu128-x86_64-linux/deformable_detr/__pycache__/layers.cpython-313.pyc deleted file mode 100644 index 47fd2b46de05040383c0c38c24c11da5072bc189..0000000000000000000000000000000000000000 Binary files a/build/torch29-cxx11-cu128-x86_64-linux/deformable_detr/__pycache__/layers.cpython-313.pyc and /dev/null differ diff --git a/build/torch29-cxx11-cu128-x86_64-linux/deformable_detr/_deformable_detr_57c3d32.abi3.so b/build/torch29-cxx11-cu128-x86_64-linux/deformable_detr/_deformable_detr_57c3d32.abi3.so deleted file mode 100644 index 1169678564d78e2dcc9b5eaec8563020d5377866..0000000000000000000000000000000000000000 --- a/build/torch29-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:25d345fba3f6c5317be583824806525f0a7d468e9b57c4535bb7cd87ca60955f -size 9908536 diff --git a/build/torch29-cxx11-cu128-x86_64-linux/deformable_detr/_ops.py b/build/torch29-cxx11-cu128-x86_64-linux/deformable_detr/_ops.py deleted file mode 100644 index 39c2aa7875432779e86612a0e56271fe32133953..0000000000000000000000000000000000000000 --- a/build/torch29-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/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 index 33db73ca6e361af4707ba5bb5f55bf0e7c3005a4..03dbc1afe1cf156661a2b1b22003cd5f599a0309 100644 --- a/build/torch29-cxx11-cu130-x86_64-linux/deformable_detr/__init__.py +++ b/build/torch29-cxx11-cu130-x86_64-linux/deformable_detr/__init__.py @@ -1,46 +1,26 @@ -from typing import List -import torch +import ctypes +import sys -from ._ops import ops -from . import layers +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 -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"] +globals().update(vars(_import_from_path(Path(__file__).parent.parent / "__init__.py"))) diff --git a/build/torch29-cxx11-cu130-x86_64-linux/deformable_detr/__pycache__/__init__.cpython-313.pyc b/build/torch29-cxx11-cu130-x86_64-linux/deformable_detr/__pycache__/__init__.cpython-313.pyc deleted file mode 100644 index f089440fcaeb0c9f45b1523dfd17bb9b74751988..0000000000000000000000000000000000000000 Binary files a/build/torch29-cxx11-cu130-x86_64-linux/deformable_detr/__pycache__/__init__.cpython-313.pyc and /dev/null differ diff --git a/build/torch29-cxx11-cu130-x86_64-linux/deformable_detr/__pycache__/_ops.cpython-313.pyc b/build/torch29-cxx11-cu130-x86_64-linux/deformable_detr/__pycache__/_ops.cpython-313.pyc deleted file mode 100644 index 33b66478d861bf8528fcf55e52cfff28bcd996e4..0000000000000000000000000000000000000000 Binary files a/build/torch29-cxx11-cu130-x86_64-linux/deformable_detr/__pycache__/_ops.cpython-313.pyc and /dev/null differ diff --git a/build/torch29-cxx11-cu130-x86_64-linux/deformable_detr/__pycache__/layers.cpython-313.pyc b/build/torch29-cxx11-cu130-x86_64-linux/deformable_detr/__pycache__/layers.cpython-313.pyc deleted file mode 100644 index 9d35ba5d686953a7864b95d358304edd7cf00270..0000000000000000000000000000000000000000 Binary files a/build/torch29-cxx11-cu130-x86_64-linux/deformable_detr/__pycache__/layers.cpython-313.pyc and /dev/null differ diff --git a/build/torch29-cxx11-cu130-x86_64-linux/deformable_detr/_deformable_detr_57c3d32.abi3.so b/build/torch29-cxx11-cu130-x86_64-linux/deformable_detr/_deformable_detr_57c3d32.abi3.so deleted file mode 100644 index 3c9b6193e669297f96b8455b3431402d00c158b3..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu130-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:d6332cd45ce67d0deb701b8e1bfd835bf70b7343e3c41e7e0664a8e4e72b5740 -size 9028440 diff --git a/build/torch29-cxx11-cu130-x86_64-linux/deformable_detr/_ops.py b/build/torch29-cxx11-cu130-x86_64-linux/deformable_detr/_ops.py deleted file mode 100644 index 39c2aa7875432779e86612a0e56271fe32133953..0000000000000000000000000000000000000000 --- a/build/torch29-cxx11-cu130-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/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