Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement on CPU #63

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# output dir
output
instant_test_output
inference_test_output


*.jpg
*.png
*.txt

# compilation and distribution
__pycache__
_ext
*.pyc
*.so
AdelaiDet.egg-info/
build/
dist/

# pytorch/python/numpy formats
*.pth
*.pkl
*.npy

# ipython/jupyter notebooks
*.ipynb
**/.ipynb_checkpoints/

# Editor temporaries
*.swn
*.swo
*.swp
*~

# Pycharm editor settings
.idea
.vscode
.python-version

# project dirs
/datasets/coco
/datasets/lvis
/datasets/pic
/datasets/ytvos
/models
/demo_outputs
/example_inputs
/debug
/weights
/export
eval.sh

demo/performance.py
demo/demo2.py
train.sh
benchmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <vector>

#include <ATen/ATen.h>
#include <ATen/cuda/CUDAContext.h>
// #include <ATen/cuda/CUDAContext.h>


at::Tensor
Expand Down
2 changes: 1 addition & 1 deletion adet/layers/csrc/DeformAttn/ms_deform_attn.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#pragma once

#include "ms_deform_attn_cpu.h"
#include "cpu/ms_deform_attn_cpu.h"

#ifdef WITH_CUDA
#include "ms_deform_attn_cuda.h"
Expand Down
14 changes: 12 additions & 2 deletions adet/layers/ms_deform_attn.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,18 @@ def forward(self, query, reference_points, input_flatten, input_spatial_shapes,
else:
raise ValueError(
'Last dim of reference_points must be 2 or 4, but get {} instead.'.format(reference_points.shape[-1]))
output = _MSDeformAttnFunction.apply(
value, input_spatial_shapes, input_level_start_index, sampling_locations, attention_weights, self.im2col_step)

try:
# CUDA implementation
output = _MSDeformAttnFunction.apply(
value, input_spatial_shapes, input_level_start_index, sampling_locations, attention_weights, self.im2col_step)
except Exception:
# PyTorch implementation
output = ms_deform_attn_core_pytorch(
value,
input_spatial_shapes,
sampling_locations,
attention_weights)
output = self.output_proj(output)
# if decoder:
# return output, sampling_locations, attention_weights
Expand Down