Skip to content

Commit

Permalink
Do not use deprecated at::Tensor::type()
Browse files Browse the repository at this point in the history
Summary:
X-link: facebookexternal/vizard#5

X-link: fairinternal/egohowto#72


Replace `tensor.type().scalarType()` with `tensor.scalar_type()` (this be able to get rid of the cast function in pytorch/pytorch#139358 )

Remove extraneous braces around lambdas

Reviewed By: huydhn, r-barnes

Differential Revision: D65308547
  • Loading branch information
malfet authored and facebook-github-bot committed Nov 1, 2024
1 parent 5b37512 commit f887c0d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions projects_oss/detr/detr/src/gpu/ms_deform_attn_cuda.cu
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ at::Tensor ms_deform_attn_cuda_forward(
for (int n = 0; n < batch/im2col_step_; ++n)
{
auto columns = output_n.select(0, n);
AT_DISPATCH_FLOATING_TYPES(value.type(), "ms_deform_attn_forward_cuda", ([&] {
AT_DISPATCH_FLOATING_TYPES(value.scalar_type(), "ms_deform_attn_forward_cuda", [&] {
ms_deformable_im2col_cuda(at::cuda::getCurrentCUDAStream(),
value.data<scalar_t>() + n * im2col_step_ * per_value_size,
spatial_shapes.data<int64_t>(),
Expand All @@ -71,7 +71,7 @@ at::Tensor ms_deform_attn_cuda_forward(
batch_n, spatial_size, num_heads, channels, num_levels, num_query, num_point,
columns.data<scalar_t>());

}));
});
}

output = output.view({batch, num_query, num_heads*channels});
Expand Down Expand Up @@ -131,7 +131,7 @@ std::vector<at::Tensor> ms_deform_attn_cuda_backward(
for (int n = 0; n < batch/im2col_step_; ++n)
{
auto grad_output_g = grad_output_n.select(0, n);
AT_DISPATCH_FLOATING_TYPES(value.type(), "ms_deform_attn_backward_cuda", ([&] {
AT_DISPATCH_FLOATING_TYPES(value.scalar_type(), "ms_deform_attn_backward_cuda", [&] {
ms_deformable_col2im_cuda(at::cuda::getCurrentCUDAStream(),
grad_output_g.data<scalar_t>(),
value.data<scalar_t>() + n * im2col_step_ * per_value_size,
Expand All @@ -144,7 +144,7 @@ std::vector<at::Tensor> ms_deform_attn_cuda_backward(
grad_sampling_loc.data<scalar_t>() + n * im2col_step_ * per_sample_loc_size,
grad_attn_weight.data<scalar_t>() + n * im2col_step_ * per_attn_weight_size);

}));
});
}

return {
Expand Down

0 comments on commit f887c0d

Please sign in to comment.