def benchmark_relu():
    """
    Benchmark the speed of different relu implementations.
    Both fprop and grad are tested.
    """
    x = T.ftensor4('inputs')
    ops = [
        relu_(x).sum(), # old
        relu(x).sum(), # alter, short for alternative
        relu__(x).sum(), # alter 2
        T.grad(relu_(x).sum(),x), # grad_old
        T.grad(relu(x).sum(),x), # grad_alter
        T.grad(relu__(x).sum(),x), # grad_alter2
    ]

    names = ['fprop_old', 'fprop_alter', 'fprop_alter2',
             'grad_old', 'grad_alter', 'grad_alter2']


    value = numpy.random.uniform(size=(512,32,32,100)).astype(floatX)
    times = []
    for op, name in zip(ops, names):
        f = theano.function(inputs=[x], outputs=op, name=name)
        n_loops = 10

        t0 = time.time()
        for i in range(n_loops):
            f(value)
        t1 = time.time()
        benchmark = t1-t0
        times.append(benchmark)
        print(name)
        theano.printing.debugprint(f, print_type=True)
    print(names)
    print(times)
dataset/ETHPy150Open lisa-lab/pylearn2/pylearn2/scripts/benchmark/time_relu.py/benchmark_relu/original