Skip to content
This repository has been archived by the owner on Jul 2, 2021. It is now read-only.

Commit

Permalink
Merge pull request #907 from Hakuyume/use-dummy-roi-align-in-unittest
Browse files Browse the repository at this point in the history
Use dummy roi_average_align_2d in cpu tests
  • Loading branch information
yuyu2172 authored Jun 28, 2019
2 parents 8c9ddcc + 79fa9d2 commit 7afb31f
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions tests/links_tests/model_tests/fpn_tests/test_faster_rcnn.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from __future__ import division

import mock
import numpy as np
import unittest

import chainer
from chainer import backends
from chainer import testing
from chainer.testing import attr

Expand Down Expand Up @@ -46,6 +48,16 @@ def __init__(self, n_fg_class, return_values, min_size, max_size):
)


def dummy_roi_average_align_2d(
x, rois, roi_indices, outsize, spatial_scale, sampling_ratio=None):
if not isinstance(outsize, chainer.utils.collections_abc.Iterable):
outsize = outsize, outsize

xp = backends.cuda.get_array_module(x.array)
y = _random_array(xp, (len(rois), x.shape[1], outsize[0], outsize[1]))
return chainer.Variable(y)


@testing.parameterize(*testing.product_dict(
[
{'return_values': 'detection'},
Expand Down Expand Up @@ -122,7 +134,9 @@ def _check_call(self):

@attr.slow
def test_call_cpu(self):
self._check_call()
with mock.patch('chainer.functions.roi_average_align_2d',
dummy_roi_average_align_2d):
self._check_call()

@attr.gpu
def test_call_gpu(self):
Expand Down Expand Up @@ -155,7 +169,9 @@ def _check_predict(self):

@attr.slow
def test_predict_cpu(self):
self._check_predict()
with mock.patch('chainer.functions.roi_average_align_2d',
dummy_roi_average_align_2d):
self._check_predict()

@attr.gpu
def test_predict_gpu(self):
Expand Down

0 comments on commit 7afb31f

Please sign in to comment.