Skip to content

Commit

Permalink
[Op] Fix RoI pooling (#2109)
Browse files Browse the repository at this point in the history
  • Loading branch information
antinucleon committed May 11, 2016
1 parent b9947a0 commit 2cff740
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ LDFLAGS = -pthread $(MSHADOW_LDFLAGS) $(DMLC_LDFLAGS)
ifeq ($(DEBUG), 1)
NVCCFLAGS = -D_FORCE_INLINES -g -G -O0 -ccbin $(CXX) $(MSHADOW_NVCCFLAGS)
else
NVCCFLAGS = -D_FORCE_INLINES --use_fast_math -g -O3 -ccbin $(CXX) $(MSHADOW_NVCCFLAGS)
NVCCFLAGS = -D_FORCE_INLINES -g -O3 -ccbin $(CXX) $(MSHADOW_NVCCFLAGS)
endif

ifndef LINT_LANG
Expand Down
12 changes: 10 additions & 2 deletions src/operator/roi_pooling-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@ class ROIPoolingOp : public Operator {
Tensor<xpu, 3> bbox = in_data[roipool::kBox].get<xpu, 3, real_t>(s);
Tensor<xpu, 4> out = out_data[roipool::kOut].get<xpu, 4, real_t>(s);
Tensor<xpu, 4> max_idx = out_data[roipool::kMaxIdx].get<xpu, 4, real_t>(s);

CHECK_EQ(data.CheckContiguous(), true);
CHECK_EQ(bbox.CheckContiguous(), true);
CHECK_EQ(out.CheckContiguous(), true);
CHECK_EQ(max_idx.CheckContiguous(), true);
out = -FLT_MAX;
max_idx = -1.0f;
ROIPoolForward(out, data, bbox, max_idx, param_.spatial_scale);
}

Expand All @@ -92,7 +97,10 @@ class ROIPoolingOp : public Operator {
Tensor<xpu, 3> bbox = in_data[roipool::kBox].get<xpu, 3, real_t>(s);
Tensor<xpu, 4> max_idx = out_data[roipool::kMaxIdx].get<xpu, 4, real_t>(s);
Tensor<xpu, 4> grad_in = in_grad[roipool::kData].get<xpu, 4, real_t>(s);

CHECK_EQ(grad_out.CheckContiguous(), true);
CHECK_EQ(bbox.CheckContiguous(), true);
CHECK_EQ(max_idx.CheckContiguous(), true);
CHECK_EQ(grad_in.CheckContiguous(), true);
ROIPoolBackward(grad_in, grad_out, bbox, max_idx, param_.spatial_scale);
}

Expand Down

0 comments on commit 2cff740

Please sign in to comment.