register_cuda_op(name: str, aliases: Sequence[str]=()) -> NoneRegister a canonical CUDA operator name and optional aliases.
| 名称 | 类型 | 默认值 |
|---|---|---|
name | str | — |
aliases | Sequence[str] | () |
Custom CUDA operator wrappers for D-FINE / RT-DETRv4 with graceful PyTorch fallback, per-operator enable/disable switches (YAML + env), and build-cache staleness detection.
register_cuda_op(name: str, aliases: Sequence[str]=()) -> NoneRegister a canonical CUDA operator name and optional aliases.
| 名称 | 类型 | 默认值 |
|---|---|---|
name | str | — |
aliases | Sequence[str] | () |
list_cuda_ops() -> Tuple[str, ...]Return canonical names of all registered CUDA operators.
configure_cuda_ops(cfg: Any=None) -> NoneApply YAML or programmatic `cuda_ops` policy cleanly (resets prior YAML state).
| 名称 | 类型 | 默认值 |
|---|---|---|
cfg | Any | None |
reset_cuda_ops_config() -> NoneReset any programmatic/YAML CUDA operator configuration back to defaults.
get_global_cuda_ops_mode() -> strReturn effective global mode ('auto', 'off', or 'strict').
get_cuda_op_mode(op_name: str) -> strReturn effective policy ('auto', 'off', or 'strict') for a named CUDA operator.
| 名称 | 类型 | 默认值 |
|---|---|---|
op_name | str | — |
compute_cuda_ext_build_signature(repo_root: Path=_REPO_ROOT, setup_py: Optional[Path]=None) -> Dict[str, str]Compute a deterministic source + ABI build signature for `_detrium_cuda_ext`.
| 名称 | 类型 | 默认值 |
|---|---|---|
repo_root | Path | _REPO_ROOT |
setup_py | Optional[Path] | None |
is_cuda_ext_binary_up_to_date(repo_root: Path=_REPO_ROOT, setup_py: Optional[Path]=None) -> boolReturn True iff `_detrium_cuda_ext` binary exists in cache and matches current csrc/ABI.
| 名称 | 类型 | 默认值 |
|---|---|---|
repo_root | Path | _REPO_ROOT |
setup_py | Optional[Path] | None |
has_dfine_cuda_ext() -> boolReturn True when the compiled CUDA extension module is loaded.
use_dfine_cuda_ops() -> boolReturn True when the CUDA extension is loaded and at least one CUDA op is active.
is_cuda_op_enabled(op_name: str) -> boolReturn True when the CUDA extension is loaded and `op_name` is not set to `off`.
| 名称 | 类型 | 默认值 |
|---|---|---|
op_name | str | — |
should_use_cuda_op(op_name: str, precondition_ok: bool=True, reason: str='') -> boolCentral per-operator dispatch gate supporting `auto`, `off`, and `strict` modes.
| 名称 | 类型 | 默认值 |
|---|---|---|
op_name | str | — |
precondition_ok | bool | True |
reason | str | '' |
get_cuda_ops_status() -> Dict[str, Any]Return structured status of the CUDA extension and all registered operators.
ensure_dfine_cuda_ops(verbose: bool=True, setup_py: Optional[Path]=None) -> boolEnsure `_detrium_cuda_ext` is compiled into the out-of-tree cache, up-to-date, and loaded. Degrades cleanly to the pure-PyTorch fallback on CPU/MPS, missing nvcc, or opt-out.
| 名称 | 类型 | 默认值 |
|---|---|---|
verbose | bool | True |
setup_py | Optional[Path] | None |
can_use_cuda_ms_deform_attn_v2(value: torch.Tensor, spatial_shapes: Sequence[Sequence[int]], num_points_list: Sequence[int], method: str='default', sampling_locations: Optional[torch.Tensor]=None, attention_weights: Optional[torch.Tensor]=None, value_shape: str='default') -> bool| 名称 | 类型 | 默认值 |
|---|---|---|
value | torch.Tensor | — |
spatial_shapes | Sequence[Sequence[int]] | — |
num_points_list | Sequence[int] | — |
method | str | 'default' |
sampling_locations | Optional[torch.Tensor] | None |
attention_weights | Optional[torch.Tensor] | None |
value_shape | str | 'default' |
ms_deform_attn_v2_cuda(value: torch.Tensor, spatial_shapes: Sequence[Sequence[int]], sampling_locations: torch.Tensor, attention_weights: torch.Tensor, num_points_list: Sequence[int]) -> torch.Tensorvalue: [B, S, M, D] sampling_locations: [B, Lq, M, P_total, 2] in [0, 1] attention_weights: [B, Lq, M, P_total]
| 名称 | 类型 | 默认值 |
|---|---|---|
value | torch.Tensor | — |
spatial_shapes | Sequence[Sequence[int]] | — |
sampling_locations | torch.Tensor | — |
attention_weights | torch.Tensor | — |
num_points_list | Sequence[int] | — |
can_use_cuda_ms_deform_attn_v2_fused(value: torch.Tensor, spatial_shapes: Sequence[Sequence[int]], num_points_list: Sequence[int], sampling_offsets: torch.Tensor, attention_logits: torch.Tensor, reference_points: torch.Tensor, method: str='default', value_shape: str='default') -> bool| 名称 | 类型 | 默认值 |
|---|---|---|
value | torch.Tensor | — |
spatial_shapes | Sequence[Sequence[int]] | — |
num_points_list | Sequence[int] | — |
sampling_offsets | torch.Tensor | — |
attention_logits | torch.Tensor | — |
reference_points | torch.Tensor | — |
method | str | 'default' |
value_shape | str | 'default' |
ms_deform_attn_v2_fused_cuda(value: torch.Tensor, spatial_shapes: Sequence[Sequence[int]], sampling_offsets: torch.Tensor, attention_logits: torch.Tensor, reference_points: torch.Tensor, num_points_list: Sequence[int], offset_scale: float=0.5) -> torch.TensorFused MSDeformAttn v2 entrypoint combining 4D reference-point offset scaling, FP32 softmax over attention logits, and bilinear sampling. value: [B, S, M, D] sampling_offsets: [B, Lq, M, P_total, 2] attention_logits: [B, Lq, M, P_total] reference_points: [B, Lq, 1, 4]
| 名称 | 类型 | 默认值 |
|---|---|---|
value | torch.Tensor | — |
spatial_shapes | Sequence[Sequence[int]] | — |
sampling_offsets | torch.Tensor | — |
attention_logits | torch.Tensor | — |
reference_points | torch.Tensor | — |
num_points_list | Sequence[int] | — |
offset_scale | float | 0.5 |
can_use_cuda_batched_hungarian(cost: torch.Tensor, gt_mask: torch.Tensor) -> bool| 名称 | 类型 | 默认值 |
|---|---|---|
cost | torch.Tensor | — |
gt_mask | torch.Tensor | — |
batched_hungarian_cuda(cost: torch.Tensor, gt_mask: torch.Tensor) -> torch.TensorSolve P independent [N, M] exact min-cost injective assignments on GPU. Args: cost: [P, N, M] floating-point tensor on CUDA. gt_mask: [P, M] bool tensor on CUDA indicating active GTs per subproblem. Returns: gt_q: [P, M] int64 tensor on CUDA with matched query indices in [0, N-1] (0 for inactive/padded GTs).
| 名称 | 类型 | 默认值 |
|---|---|---|
cost | torch.Tensor | — |
gt_mask | torch.Tensor | — |
can_use_cuda_fused_focal_hungarian(boxes_all: torch.Tensor, tgt_boxes: torch.Tensor, tgt_labels: torch.Tensor, gt_mask: torch.Tensor, logits_cls: Optional[torch.Tensor]=None, logits_enc: Optional[torch.Tensor]=None) -> bool| 名称 | 类型 | 默认值 |
|---|---|---|
boxes_all | torch.Tensor | — |
tgt_boxes | torch.Tensor | — |
tgt_labels | torch.Tensor | — |
gt_mask | torch.Tensor | — |
logits_cls | Optional[torch.Tensor] | None |
logits_enc | Optional[torch.Tensor] | None |
fused_focal_hungarian_cuda(boxes_all: torch.Tensor, logits_cls: torch.Tensor, logits_enc: torch.Tensor, tgt_boxes: torch.Tensor, tgt_labels: torch.Tensor, gt_mask: torch.Tensor, alpha: float, gamma: float, w_bbox: float, w_cls: float, w_giou: float, enc_class_agnostic: bool) -> torch.TensorSingle-kernel fused Focal/L1/GIoU cost (ragged active GTs + unique-class dedup) and exact Super-Sink + Vickrey/GS-ARR GPU Hungarian solver.
| 名称 | 类型 | 默认值 |
|---|---|---|
boxes_all | torch.Tensor | — |
logits_cls | torch.Tensor | — |
logits_enc | torch.Tensor | — |
tgt_boxes | torch.Tensor | — |
tgt_labels | torch.Tensor | — |
gt_mask | torch.Tensor | — |
alpha | float | — |
gamma | float | — |
w_bbox | float | — |
w_cls | float | — |
w_giou | float | — |
enc_class_agnostic | bool | — |