<commit_before>import unittest

import numpy

import chainer
from chainer.backends import cuda
import chainer.functions as F
from chainer import testing
from chainer.testing import array
from chainer.testing import attr
from chainer.testing import parameterize
from chainer.utils import conv


def _pair(x):
    if hasattr(x, '__getitem__'):
        return x
    return x, x


@parameterize(*(testing.product([
    testing.product({
        'c_contiguous': [True],
        'test_outsize': [True, False],
        'nobias': [True],
        'stride': [1, 2],
        'dilate': [1],
        'x_dtype': [numpy.float32],
        'W_dtype': [numpy.float32],
        'groups': [1, 2],
    })
    + testing.product({
        'c_contiguous': [False],
        'test_outsize': [True],
        'nobias': [False],
        'stride': [1, 2],
        'dilate': [1, 2],
        'x_dtype': [numpy.float16, numpy.float32, numpy.float64],
        'W_dtype': [numpy.float16, numpy.float32, numpy.float64],
        'groups': [1, 2],
    }),
])))
@testing.inject_backend_tests(
    ['test_forward', 'test_backward', 'test_double_backward'],
    # CPU tests
    [{}]
    # GPU tests
    + testing.product({
        'use_cuda': [True],
        'use_cudnn': ['never', 'always'],
    })
    # ChainerX tests
    + [
        {'use_chainerx': True, 'chainerx_device': 'native:0'},
        {'use_chainerx': True, 'chainerx_device': 'cuda:0'},
    ]
)
class TestDeconvolution2DFunction(testing.FunctionTestCase):

    def setUp(self):
        self.N = 2
        self.inh, self.inw = 4, 3
        self.in_channels_a_group = 3
        self.out_channels_a_group = 2
        self.in_channels = self.in_channels_a_group * self.groups
        self.out_channels = self.out_channels_a_group * self.groups
        self.ksize = 3
        self.pad = 1
        self.kh, self.kw = _pair(self.ksize)
        self.sh, self.sw = _pair(self.stride)
        self.ph, self.pw = _pair(self.pad)

        outh = conv.get_deconv_outsize(self.inh, self.kh, self.sh,
                                       self.ph, d=self.dilate)
        outw = conv.get_deconv_outsize(self.inw, self.kw, self.sw,
                                       self.pw, d=self.dilate)

        self.outsize = (outh, outw) if self.test_outsize else None

        if self.x_dtype == numpy.float16:<commit_msg>fixed missing backend configs<commit_after>import unittest

import numpy

import chainer
from chainer.backends import cuda
import chainer.functions as F
from chainer import testing
from chainer.testing import array
from chainer.testing import attr
from chainer.testing import parameterize
from chainer.utils import conv


def _pair(x):
    if hasattr(x, '__getitem__'):
        return x
    return x, x


@parameterize(*(testing.product([
    testing.product({
        'c_contiguous': [True],
        'test_outsize': [True, False],
        'nobias': [True],
        'stride': [1, 2],
        'dilate': [1],
        'x_dtype': [numpy.float32],
        'W_dtype': [numpy.float32],
        'groups': [1, 2],
    })
    + testing.product({
        'c_contiguous': [False],
        'test_outsize': [True],
        'nobias': [False],
        'stride': [1, 2],
        'dilate': [1, 2],
        'x_dtype': [numpy.float16, numpy.float32, numpy.float64],
        'W_dtype': [numpy.float16, numpy.float32, numpy.float64],
        'groups': [1, 2],
    }),
])))
@testing.inject_backend_tests(
    ['test_forward', 'test_backward', 'test_double_backward'],
    # CPU tests
    testing.product({
        'use_cuda': [False],
        'use_ideep': ['never', 'always'],
    })
    # GPU tests
    + testing.product([
        [{'use_cuda': True}],

        # Without cuDNN
        testing.product({
            'use_cudnn': ['never'],
        })
        # With cuDNN
        + testing.product({
            'use_cudnn': ['always'],
            'cudnn_deterministic': [True, False],
            'autotune': [True, False],
        })])
    # ChainerX tests
    + testing.product({
        'use_chainerx': [True],
        'chainerx_device': ['native:0', 'cuda:0'],
    }))
class TestDeconvolution2DFunction(testing.FunctionTestCase):

    def setUp(self):
        self.N = 2
        self.inh, self.inw = 4, 3
        self.in_channels_a_group = 3
        self.out_channels_a_group = 2
        self.in_channels = self.in_channels_a_group * self.groups
        self.out_channels = self.out_channels_a_group * self.groups
        self.ksize = 3
        self.pad = 1
        self.kh, self.kw = _pair(self.ksize)
        self.sh, self.sw = _pair(self.stride)
        self.ph, self.pw = _pair(self.pad)

        outh = conv.get_deconv_outsize(self.inh, self.kh, self.sh,
                                       self.ph, d=self.dilate)
        outw = conv.get_deconv_outsize(self.inw, self.kw, self.sw,
                                       self.pw, d=self.dilate)

        self.outsize = (outh, outw) if self.test_outsize else None

        if self.x_dtype == numpy.float16:
{'fraction_non_alphanumeric': 0.13915141765533884, 'fraction_numerical': 0.015684697365775185, 'mean_word_length': 2.263779527559055, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2146620', 'n_tokens_mistral': 1734, 'n_tokens_neox': 1673, 'n_words': 355}