detrium.nn.decoders.utils

DEIM: DETR with Improved Matching for Fast Convergence Copyright (c) 2024 The DEIM Authors. All Rights Reserved. --------------------------------------------------------------------------------- Modified from D-FINE (https://github.com/Peterande/D-FINE) Copyright (c) 2023 . All Rights Reserved.

deformable_attention_core_func(value, value_spatial_shapes, sampling_locations, attention_weights)

Args: value (Tensor): [bs, value_length, n_head, c] value_spatial_shapes (Tensor|List): [n_levels, 2] value_level_start_index (Tensor|List): [n_levels] sampling_locations (Tensor): [bs, query_length, n_head, n_levels, n_points, 2] attention_weights (Tensor): [bs, query_length, n_head, n_levels, n_points] Returns: output (Tensor): [bs, Length_{query}, C]

名称类型默认值
value——
value_spatial_shapes——
sampling_locations——
attention_weights——
deformable_attention_core_func_v2(value: torch.Tensor, value_spatial_shapes, sampling_locations: torch.Tensor, attention_weights: torch.Tensor, num_points_list: List[int], method='default', value_shape='default')

Args: value (Tensor): [bs, value_length, n_head, c] value_spatial_shapes (Tensor|List): [n_levels, 2] value_level_start_index (Tensor|List): [n_levels] sampling_locations (Tensor): [bs, query_length, n_head, n_levels * n_points, 2] attention_weights (Tensor): [bs, query_length, n_head, n_levels * n_points] Returns: output (Tensor): [bs, Length_{query}, C]

名称类型默认值
valuetorch.Tensor—
value_spatial_shapes——
sampling_locationstorch.Tensor—
attention_weightstorch.Tensor—
num_points_listList[int]—
method—'default'
value_shape—'default'
self_attn_needs_weights(tensor: torch.Tensor) -> bool

Return True for ONNX export or FP32 execution (exact parity), False under FP16/BF16 AMP.

名称类型默认值
tensortorch.Tensor—