Skip to content

Assertion macros compatible with pytorch master #540

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

Merged
merged 1 commit into from
Jul 3, 2018
Merged
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
4 changes: 2 additions & 2 deletions torchvision/csrc/cpu/ROIAlign_cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ at::Tensor ROIAlign_forward_cpu(const at::Tensor& input,
const int pooled_height,
const int pooled_width,
const int sampling_ratio) {
AT_ASSERT(!input.type().is_cuda(), "input must be a CPU tensor");
AT_ASSERT(!rois.type().is_cuda(), "rois must be a CPU tensor");
AT_ASSERTM(!input.type().is_cuda(), "input must be a CPU tensor");
AT_ASSERTM(!rois.type().is_cuda(), "rois must be a CPU tensor");

auto num_rois = rois.size(0);
auto channels = input.size(1);
Expand Down
6 changes: 3 additions & 3 deletions torchvision/csrc/cpu/nms_cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ template <typename scalar_t>
at::Tensor nms_cpu_kernel(const at::Tensor& dets,
const at::Tensor& scores,
const float threshold) {
AT_ASSERT(!dets.type().is_cuda(), "dets must be a CPU tensor");
AT_ASSERT(!scores.type().is_cuda(), "scores must be a CPU tensor");
AT_ASSERT(dets.type() == scores.type(), "dets should have the same type as scores");
AT_ASSERTM(!dets.type().is_cuda(), "dets must be a CPU tensor");
AT_ASSERTM(!scores.type().is_cuda(), "scores must be a CPU tensor");
AT_ASSERTM(dets.type() == scores.type(), "dets should have the same type as scores");

if (dets.numel() == 0)
return torch::CPU(at::kLong).tensor();
Expand Down
8 changes: 4 additions & 4 deletions torchvision/csrc/cuda/ROIAlign_cuda.cu
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ at::Tensor ROIAlign_forward_cuda(const at::Tensor& input,
const int pooled_height,
const int pooled_width,
const int sampling_ratio) {
AT_ASSERT(input.type().is_cuda(), "input must be a CUDA tensor");
AT_ASSERT(rois.type().is_cuda(), "rois must be a CUDA tensor");
AT_ASSERTM(input.type().is_cuda(), "input must be a CUDA tensor");
AT_ASSERTM(rois.type().is_cuda(), "rois must be a CUDA tensor");

auto num_rois = rois.size(0);
auto channels = input.size(1);
Expand Down Expand Up @@ -308,8 +308,8 @@ at::Tensor ROIAlign_backward_cuda(const at::Tensor& grad,
const int height,
const int width,
const int sampling_ratio) {
AT_ASSERT(grad.type().is_cuda(), "grad must be a CUDA tensor");
AT_ASSERT(rois.type().is_cuda(), "rois must be a CUDA tensor");
AT_ASSERTM(grad.type().is_cuda(), "grad must be a CUDA tensor");
AT_ASSERTM(rois.type().is_cuda(), "rois must be a CUDA tensor");

auto num_rois = rois.size(0);
at::Tensor grad_input = grad.type().tensor({batch_size, channels, height, width}).zero_();
Expand Down
8 changes: 4 additions & 4 deletions torchvision/csrc/cuda/ROIPool_cuda.cu
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ std::tuple<at::Tensor, at::Tensor> ROIPool_forward_cuda(const at::Tensor& input,
const float spatial_scale,
const int pooled_height,
const int pooled_width) {
AT_ASSERT(input.type().is_cuda(), "input must be a CUDA tensor");
AT_ASSERT(rois.type().is_cuda(), "rois must be a CUDA tensor");
AT_ASSERTM(input.type().is_cuda(), "input must be a CUDA tensor");
AT_ASSERTM(rois.type().is_cuda(), "rois must be a CUDA tensor");

auto num_rois = rois.size(0);
auto channels = input.size(1);
Expand Down Expand Up @@ -162,8 +162,8 @@ at::Tensor ROIPool_backward_cuda(const at::Tensor& grad,
const int channels,
const int height,
const int width) {
AT_ASSERT(grad.type().is_cuda(), "grad must be a CUDA tensor");
AT_ASSERT(rois.type().is_cuda(), "rois must be a CUDA tensor");
AT_ASSERTM(grad.type().is_cuda(), "grad must be a CUDA tensor");
AT_ASSERTM(rois.type().is_cuda(), "rois must be a CUDA tensor");
// TODO add more checks

auto num_rois = rois.size(0);
Expand Down