import numpy

from chainer import function
from chainer.utils import type_check


class Reshape(function.Function):

    """Reshapes an input array without copy."""

    def __init__(self, shape):
        self.shape = shape

    def check_type_forward(self, in_types):
        type_check.expect(
            in_types.size() == 1,
            type_check.prod(in_types[0].shape) ==
            type_check.prod(self.shape)
        )

    def check_type_backward(self, in_types, out_types):
        type_check.expect(
            out_types.size() == 1,
            type_check.prod(in_types[0].shape) ==
            type_check.prod(out_types[0].shape)
        )

    def forward(self, x):
        return x[0].reshape(self.shape),

    def backward(self, x, gy):
        return gy[0].reshape(x[0].shape),


def reshape(x, shape):
    """Reshapes an input variable without copy.

    Args:
        x (~chainer.Variable): Input variable.
        shape (tuple of ints): Target shape.

    Returns:
        ~chainer.Variable: Variable that holds a reshaped version of the input
            variable.

    """
    return Reshape(shape)(x)

@@ -108,16 +108,78 @@
 nction):
+%0A    type_check_prod = type_check.Variable(numpy.prod, 'prod')
 %0A%0A    %22%22
@@ -389,32 +389,37 @@
  1,%0A            
+self.
 type_check.prod(
@@ -404,33 +404,33 @@
  self.type_check
-.
+_
 prod(in_types%5B0%5D
@@ -444,32 +444,37 @@
  ==%0A            
+self.
 type_check.prod(
@@ -463,25 +463,25 @@
 f.type_check
-.
+_
 prod(self.sh
@@ -618,32 +618,37 @@
  1,%0A            
+self.
 type_check.prod(
@@ -637,25 +637,25 @@
 f.type_check
-.
+_
 prod(in_type
@@ -673,32 +673,37 @@
  ==%0A            
+self.
 type_check.prod(
@@ -696,17 +696,17 @@
 pe_check
-.
+_
 prod(out

Add type_check_prod to Reshape (see #203)