Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

Commit

Permalink
parameterize functions tests by batch size
Browse files Browse the repository at this point in the history
  • Loading branch information
asi1024 committed Apr 20, 2018
1 parent 80b6834 commit 5667e3f
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 32 deletions.
9 changes: 5 additions & 4 deletions benchmarks/functions/pooling/average_pooling_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

from benchmarks.functions import FunctionBenchmark
from benchmarks.utils import backends
from benchmarks.utils import parameterize


@backends('gpu', 'gpu-cudnn', 'cpu', 'cpu-ideep')
@parameterize([('batches', [1, 16])])
class AveragePooling2D(FunctionBenchmark):
def setup(self):
def setup(self, batches):
xp = self.xp

# Prepare test data.
batches = 16
channels = 4
x_size = (128, 128)
ksize = 4
Expand All @@ -25,8 +26,8 @@ def setup(self):
# Setup benchmark.
self.setup_benchmark(F.average_pooling_2d, (x, ksize), gy)

def time_forward(self):
def time_forward(self, batches):
self.forward()

def time_backward(self):
def time_backward(self, batches):
self.backward()
9 changes: 5 additions & 4 deletions benchmarks/functions/pooling/average_pooling_nd.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

from benchmarks.functions import FunctionBenchmark
from benchmarks.utils import backends
from benchmarks.utils import parameterize


@backends('gpu', 'gpu-cudnn', 'cpu')
@parameterize([('batches', [1, 16])])
class AveragePoolingND(FunctionBenchmark):
def setup(self):
def setup(self, batches):
xp = self.xp

# Prepare test data.
batches = 16
channels = 4
x_size = (32, 32, 16, 16)
ksize = 4
Expand All @@ -25,8 +26,8 @@ def setup(self):
# Setup benchmark.
self.setup_benchmark(F.average_pooling_nd, (x, ksize), gy)

def time_forward(self):
def time_forward(self, batches):
self.forward()

def time_backward(self):
def time_backward(self, batches):
self.backward()
9 changes: 5 additions & 4 deletions benchmarks/functions/pooling/max_pooling_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

from benchmarks.functions import FunctionBenchmark
from benchmarks.utils import backends
from benchmarks.utils import parameterize


@backends('gpu', 'gpu-cudnn', 'cpu', 'cpu-ideep')
@parameterize([('batches', [1, 16])])
class MaxPooling2D(FunctionBenchmark):
def setup(self):
def setup(self, batches):
xp = self.xp

# Prepare test data.
batches = 16
channels = 4
x_size = (128, 128)
ksize = 4
Expand All @@ -25,8 +26,8 @@ def setup(self):
# Setup benchmark.
self.setup_benchmark(F.max_pooling_2d, (x, ksize), gy)

def time_forward(self):
def time_forward(self, batches):
self.forward()

def time_backward(self):
def time_backward(self, batches):
self.backward()
9 changes: 5 additions & 4 deletions benchmarks/functions/pooling/max_pooling_nd.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

from benchmarks.functions import FunctionBenchmark
from benchmarks.utils import backends
from benchmarks.utils import parameterize


@backends('gpu', 'gpu-cudnn', 'cpu')
@parameterize([('batches', [1, 16])])
class MaxPoolingND(FunctionBenchmark):
def setup(self):
def setup(self, batches):
xp = self.xp

# Prepare test data.
batches = 16
channels = 4
x_size = (32, 32, 16, 16)
ksize = 4
Expand All @@ -25,8 +26,8 @@ def setup(self):
# Setup benchmark.
self.setup_benchmark(F.max_pooling_nd, (x, ksize), gy)

def time_forward(self):
def time_forward(self, batches):
self.forward()

def time_backward(self):
def time_backward(self, batches):
self.backward()
9 changes: 5 additions & 4 deletions benchmarks/functions/pooling/roi_pooling_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@

from benchmarks.functions import FunctionBenchmark
from benchmarks.utils import backends
from benchmarks.utils import parameterize


@backends('gpu', 'cpu')
@parameterize([('batches', [1, 16])])
class ROIPooling2D(FunctionBenchmark):
def setup(self):
def setup(self, batches):
xp = self.xp

# Prepare test data.
batches = 16
channels = 4
x_size = (128, 128)
out_size = (32, 32)
Expand All @@ -36,8 +37,8 @@ def setup(self):
self.setup_benchmark(F.roi_pooling_2d,
(x, rois) + out_size + (spatial_scale,), gy)

def time_forward(self):
def time_forward(self, batches):
self.forward()

def time_backward(self):
def time_backward(self, batches):
self.backward()
9 changes: 5 additions & 4 deletions benchmarks/functions/pooling/spatial_pyramid_pooling_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@

from benchmarks.functions import FunctionBenchmark
from benchmarks.utils import backends
from benchmarks.utils import parameterize


@backends('gpu', 'gpu-cudnn', 'cpu')
@parameterize([('batches', [1, 16])])
class SpatialPyramidPooling2D(FunctionBenchmark):
def setup(self):
def setup(self, batches):
xp = self.xp

# Prepare test data.
batches = 16
channels = 4
x_size = (128, 128)
pyramid_height = 4
Expand All @@ -31,8 +32,8 @@ def setup(self):
self.setup_benchmark(F.spatial_pyramid_pooling_2d,
(x, pyramid_height, None, 'max'), gy)

def time_forward(self):
def time_forward(self, batches):
self.forward()

def time_backward(self):
def time_backward(self, batches):
self.backward()
9 changes: 5 additions & 4 deletions benchmarks/functions/pooling/unpooling_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@

from benchmarks.functions import FunctionBenchmark
from benchmarks.utils import backends
from benchmarks.utils import parameterize


@backends('gpu', 'gpu-cudnn', 'cpu')
@parameterize([('batches', [1, 16])])
class Unpooling2D(FunctionBenchmark):
def setup(self):
def setup(self, batches):
xp = self.xp

# Prepare test data.
batches = 16
channels = 4
ih, iw = (128, 128)
ksize = 4
Expand All @@ -32,8 +33,8 @@ def setup(self):
# Setup benchmark.
self.setup_benchmark(F.unpooling_2d, (x, ksize), gy)

def time_forward(self):
def time_forward(self, batches):
self.forward()

def time_backward(self):
def time_backward(self, batches):
self.backward()
9 changes: 5 additions & 4 deletions benchmarks/functions/pooling/unpooling_nd.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@

from benchmarks.functions import FunctionBenchmark
from benchmarks.utils import backends
from benchmarks.utils import parameterize


@backends('gpu', 'gpu-cudnn', 'cpu')
@parameterize([('batches', [1, 16])])
class UnpoolingND(FunctionBenchmark):
def setup(self):
def setup(self, batches):
xp = self.xp

# Prepare test data.
batches = 16
channels = 4
in_size = (32, 32, 32)
ksize = 4
Expand All @@ -32,8 +33,8 @@ def setup(self):
# Setup benchmark.
self.setup_benchmark(F.unpooling_nd, (x, ksize), gy)

def time_forward(self):
def time_forward(self, batches):
self.forward()

def time_backward(self):
def time_backward(self, batches):
self.backward()

0 comments on commit 5667e3f

Please sign in to comment.