Module ImportFrom alias Import alias Import alias Import alias If UnaryOpNot AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr body ImportFrom alias Raise Call NameLoad Str Import alias identifier If UnaryOpNot AttributeLoad NameLoad attr body ImportFrom alias Raise Call NameLoad Str Import alias identifier ImportFrom alias alias If CompareEq AttributeLoad AttributeLoad NameLoad attr attr Str body Assign NameStore Call AttributeLoad Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr Str attr Str Assign NameStore Call AttributeLoad Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr Str attr Str orelse Assign NameStore Call AttributeLoad Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr attr Str Assign NameStore Call AttributeLoad Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr attr Str FunctionDef arguments args defaults body For NameStore ListLoad TupleLoad Num Num TupleLoad Num Num TupleLoad Num Num TupleLoad Num Num body For NameStore ListLoad AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr body Assign NameStore Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Assign NameStore Call NameLoad NameLoad Assign NameStore Call NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr ListLoad NameLoad NameLoad Call NameLoad NameLoad NameLoad keyword NameLoad Assign NameStore Call AttributeLoad NameLoad attr ListLoad NameLoad NameLoad Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr Call NameLoad NameLoad NameLoad keyword NameLoad Assign NameStore Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr ListLoad NameLoad NameLoad Call NameLoad NameLoad NameLoad keyword NameLoad Assign NameStore Call AttributeLoad NameLoad attr ListLoad NameLoad NameLoad Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr Call NameLoad NameLoad NameLoad keyword NameLoad Assert Call NameLoad ListComp Call NameLoad AttributeLoad NameLoad attr AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr comprehension NameStore Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr Assert Call NameLoad ListComp Call NameLoad AttributeLoad NameLoad attr NameLoad comprehension NameStore Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr Assert Call NameLoad ListComp Call NameLoad AttributeLoad NameLoad attr NameLoad comprehension NameStore Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr Assert Call NameLoad ListComp Call NameLoad AttributeLoad NameLoad attr NameLoad comprehension NameStore Call AttributeLoad AttributeLoad AttributeLoad NameLoad attr attr attr Assign NameStore Call AttributeLoad NameLoad attr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad keyword Str Assign NameStore Call AttributeLoad NameLoad attr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad keyword Str Assert Call AttributeLoad NameLoad attr Call NameLoad NameLoad NameLoad Call NameLoad NameLoad NameLoad Assert Call AttributeLoad NameLoad attr Call NameLoad NameLoad NameLoad Call NameLoad NameLoad NameLoad Assert Call AttributeLoad NameLoad attr Call NameLoad NameLoad NameLoad Call NameLoad NameLoad NameLoad decorator_list Expr Str
N/A __future__ print_function N/A numpy N/A theano N/A theano.misc.pycuda_init N/A N/A N/A N/A N/A theano misc pycuda_init pycuda_available N/A nose.plugins.skip SkipTest N/A N/A SkipTest Pycuda not installed. Skip test of theano op with pycuda code. N/A theano.sandbox.cuda cuda_ndarray N/A N/A N/A cuda_ndarray cuda_available N/A nose.plugins.skip SkipTest N/A N/A SkipTest Optional package cuda disabled N/A theano.tensor T theano.misc.pycuda_example PycudaElemwiseSourceModuleOp PycudaElemwiseSourceModuleMakeThunkOp N/A N/A N/A N/A theano config mode FAST_COMPILE N/A N/A mode_with_gpu N/A N/A N/A N/A N/A N/A theano compile mode get_mode FAST_RUN including gpu N/A mode_without_gpu N/A N/A N/A N/A N/A N/A theano compile mode get_mode FAST_RUN excluding gpu N/A N/A mode_with_gpu N/A N/A N/A N/A N/A N/A theano compile mode get_default_mode including gpu N/A mode_without_gpu N/A N/A N/A N/A N/A N/A theano compile mode get_default_mode excluding gpu test_pycuda_elemwise_source_module N/A N/A N/A N/A N/A shape N/A N/A 5 5 N/A 10 49 N/A 50 49 N/A 500 501 N/A N/A op N/A N/A N/A N/A theano scalar basic mul N/A N/A N/A theano scalar basic add N/A N/A x N/A N/A T fmatrix x N/A y N/A N/A T fmatrix y N/A elemwise_op N/A N/A N/A theano tensor Elemwise op N/A pycuda_op N/A PycudaElemwiseSourceModuleOp op N/A pycuda_op_thunk N/A PycudaElemwiseSourceModuleMakeThunkOp op N/A f N/A N/A theano function N/A x y N/A elemwise_op x y mode mode_with_gpu N/A f2 N/A N/A theano function N/A x y N/A N/A N/A N/A theano sandbox cuda host_from_gpu N/A pycuda_op x y mode mode_with_gpu N/A mode_pycuda N/A N/A mode_with_gpu including local_pycuda_gpu_elemwise N/A f3 N/A N/A theano function N/A x y N/A elemwise_op x y mode mode_pycuda N/A f4 N/A N/A theano function N/A x y N/A N/A N/A N/A theano sandbox cuda host_from_gpu N/A pycuda_op_thunk x y mode mode_with_gpu N/A N/A any N/A N/A isinstance N/A node op N/A N/A N/A theano sandbox cuda GpuElemwise N/A node N/A N/A N/A N/A f maker fgraph toposort N/A N/A any N/A N/A isinstance N/A node op PycudaElemwiseSourceModuleOp N/A node N/A N/A N/A N/A f2 maker fgraph toposort N/A N/A any N/A N/A isinstance N/A node op PycudaElemwiseSourceModuleOp N/A node N/A N/A N/A N/A f3 maker fgraph toposort N/A N/A any N/A N/A isinstance N/A node op PycudaElemwiseSourceModuleMakeThunkOp N/A node N/A N/A N/A N/A f4 maker fgraph toposort N/A val1 N/A N/A numpy asarray N/A N/A N/A numpy random rand shape dtype float32 N/A val2 N/A N/A numpy asarray N/A N/A N/A numpy random rand shape dtype float32 N/A N/A N/A numpy allclose N/A f val1 val2 N/A f2 val1 val2 N/A N/A N/A numpy allclose N/A f val1 val2 N/A f3 val1 val2 N/A N/A N/A numpy allclose N/A f val1 val2 N/A f4 val1 val2 N/A N/A 
#commented as it work only with old pycuda version.
def test_pycuda_elemwise_kernel():
    x = T.fmatrix('x')
    y = T.fmatrix('y')
    f = theano.function([x, y], x + y, mode=mode_with_gpu)
    print(f.maker.fgraph.toposort())
    mode_pycuda = mode_with_gpu.including("local_pycuda_gpu_elemwise_kernel")
    f2 = theano.function([x, y], x + y, mode=mode_pycuda)
    print(f2.maker.fgraph.toposort())

    assert any([isinstance(node.op, theano.sandbox.cuda.GpuElemwise)
                for node in f.maker.fgraph.toposort()])
    assert any([isinstance(node.op, PycudaElemwiseKernelOp)
                for node in f2.maker.fgraph.toposort()])

    val1 = numpy.asarray(numpy.random.rand(5, 5), dtype='float32')
    val2 = numpy.asarray(numpy.random.rand(5, 5), dtype='float32')
    #val1 = numpy.ones((5,5))
    #val2 = numpy.arange(25).reshape(5,5)
    assert (f(val1, val2) == f2(val1, val2)).all()
    print(f(val1, val2))
    print(f2(val1, val2))

    x3 = T.ftensor3('x')
    y3 = T.ftensor3('y')
    z3 = T.ftensor3('y')

    f4 = theano.function([x3, y3, z3], x3 * y3 + z3, mode=mode_pycuda)
    print(f4.maker.fgraph.toposort())
    assert any([isinstance(node.op, PycudaElemwiseKernelOp)
                for node in f4.maker.fgraph.toposort()])

    val1 = numpy.random.rand(2, 2, 2)
    print(val1)
    print(f4(val1, val1, val1))
    assert numpy.allclose(f4(val1, val1, val1), val1 * val1 + val1)
