Example #1
0
def test_comptime_run():
    x = theano.tensor.matrix('x')
    y = theano.tensor.matrix('y')
    z = theano.tensor.dot(x, y)
    inputs, outputs = (x, y), (z,)
    variables = theano.gof.graph.variables(inputs, outputs)

    nodes = theano.gof.graph.list_of_nodes(inputs, outputs)

    theano.gof.utils.give_variables_names(variables)
    map(clean_variable, variables)

    input_shapes = {x: (10, 10), y: (10, 10)}
    known_shapes = shape_of_variables(inputs, outputs, input_shapes)
    known_shapes = {str(k): v for k,v in known_shapes.items()}

    time_comp_fn = lambda ins, outs, num_ins, niter: 1

    fgraphs = list(graph_iter(nodes))
    niter = 3

    results = comptime_run(known_shapes, niter, fgraphs, time_comp_fn)
    assert results == [1]*len(fgraphs)
Example #2
0
from sys import argv, stdout, stdin, stderr
import theano
import time
from ape.timings.computation.run import debugprint, collect_inputs, comptime_run

mode = theano.compile.mode.get_default_mode()
mode = mode.excluding('gpu')


def time_computation(inputs, outputs, numeric_inputs, niter):

    f = theano.function(inputs, outputs, mode=mode)

    starttime = time.time()
    debugprint("Computing")
    for n in xrange(niter):
        outputs = f(*numeric_inputs)
    endtime = time.time()
    duration = endtime - starttime

    return duration / niter


if __name__ == '__main__':

    known_shapes, niter, fgraphs = collect_inputs(argv, stdin)
    results = comptime_run(known_shapes, niter, fgraphs, time_computation)

    stdout.write(str(results))
    stdout.close()
Example #3
0
from sys import argv, stdout, stdin, stderr
import theano
import time
from ape.timings.computation.run import debugprint, collect_inputs, comptime_run

mode = theano.compile.mode.get_default_mode()
mode = mode.excluding('gpu')

def time_computation(inputs, outputs, numeric_inputs, niter):

    f = theano.function(inputs, outputs, mode=mode)

    starttime = time.time()
    debugprint("Computing")
    for n in xrange(niter):
        outputs = f(*numeric_inputs)
    endtime = time.time()
    duration = endtime - starttime

    return duration/niter

if __name__ == '__main__':

    known_shapes, niter, fgraphs = collect_inputs(argv, stdin)
    results = comptime_run(known_shapes, niter, fgraphs, time_computation)

    stdout.write(str(results))
    stdout.close()