コード例 #1
0
    def check_type_forward(self, in_types):
        type_check.expect(in_types.size() == 1)
        a_type = self.value
        b_type = in_types[0]

        type_check.expect(
            a_type.dtype.kind == 'f',
            b_type.dtype.kind == 'f',
            a_type.ndim >= 1,
            a_type.ndim == b_type.ndim,
        )

        ndim = type_check.eval(a_type.ndim)
        if ndim == 1:
            type_check.expect(a_type.shape == b_type.shape)
        else:
            a_idx = _matmul._get_check_index(False,
                                             False,
                                             row_idx=-2,
                                             col_idx=-1)
            b_idx = _matmul._get_check_index(False,
                                             True,
                                             row_idx=-2,
                                             col_idx=-1)
            type_check.expect(
                a_type.shape[:-2] == b_type.shape[:-2],
                a_type.shape[a_idx] == b_type.shape[b_idx],
            )
コード例 #2
0
ファイル: basic_math.py プロジェクト: zachmayer/chainer
    def check_type_forward(self, in_types):
        type_check.expect(in_types.size() == 1)
        a_type = self.value
        b_type = in_types[0]

        type_check.expect(b_type.dtype.kind == 'f')

        _matmul._check_ndim(b_type)

        a_idx = _matmul._get_check_index(False, False)
        b_idx = _matmul._get_check_index(False, True)
        type_check.expect(a_type.shape[a_idx] == b_type.shape[b_idx])
コード例 #3
0
ファイル: basic_math.py プロジェクト: tohmae/chainer
    def check_type_forward(self, in_types):
        type_check.expect(in_types.size() == 1)
        a_type = self.value
        b_type = in_types[0]

        type_check.expect(b_type.dtype.kind == "f")

        _matmul._check_ndim(b_type)

        b_type = _matmul._convert_type(b_type)
        a_idx = _matmul._get_check_index(False, False)
        b_idx = _matmul._get_check_index(False, True)
        type_check.expect(a_type.shape[a_idx] == b_type.shape[b_idx])
コード例 #4
0
    def check_type_forward(self, in_types):
        type_check.expect(in_types.size() == 1)
        a_type, = in_types

        type_check.expect(a_type.dtype == numpy.float32, )

        _check_ndim(a_type, lower=2, upper=3)

        a_idx = _get_check_index(self.transa, False, row_idx=1, col_idx=2)
コード例 #5
0
    def check_type_forward(self, in_types):
        type_check.expect(in_types.size() == 1)
        a_type, = in_types

        type_check.expect(a_type.dtype.kind == 'f', )

        _check_ndim(a_type)

        a_idx = _get_check_index(self.transa, False)
        a_size = _get_size(a_type, a_idx, 1)
コード例 #6
0
ファイル: basic_math.py プロジェクト: MakotoSeto/chainer
    def check_type_forward(self, in_types):
        type_check.expect(in_types.size() == 1)
        a_type = self.value
        b_type = in_types[0]

        type_check.expect(
            a_type.dtype.kind == 'f',
            b_type.dtype.kind == 'f',
            a_type.ndim >= 1,
            a_type.ndim == b_type.ndim,
        )

        ndim = type_check.eval(a_type.ndim)
        if ndim == 1:
            type_check.expect(a_type.shape == b_type.shape)
        else:
            a_idx = _matmul._get_check_index(False, False,
                                             row_idx=-2, col_idx=-1)
            b_idx = _matmul._get_check_index(False, True,
                                             row_idx=-2, col_idx=-1)
            type_check.expect(
                a_type.shape[:-2] == b_type.shape[:-2],
                a_type.shape[a_idx] == b_type.shape[b_idx],
            )
コード例 #7
0
    def check_type_forward(self, in_types):
        type_check.expect(in_types.size() == 1)
        a_type, = in_types

        type_check.expect(
            a_type.dtype == numpy.float32
#             ,
#             self.b.dtype == numpy.float32
        )

        _check_ndim(a_type, lower=2, upper=3)
#         _check_ndim(b_type, lower=2, upper=3)

        a_type = _convert_type(a_type, vector_ndim=2)
#         b_type = _convert_type(b_type, vector_ndim=2)
        a_idx = _get_check_index(self.transa, False, row_idx=1, col_idx=2)