code: def test_local_gpu_elemwise():
      # Test local_gpu_elemwise when there is a dtype upcastable to float32
  
      a = tensor.bmatrix()
      b = tensor.fmatrix()
      c = tensor.fmatrix()
  
      a_v = (np.random.rand(4, 5) * 10).astype("int8")
      b_v = (np.random.rand(4, 5) * 10).astype("float32")
      c_v = (np.random.rand(4, 5) * 10).astype("float32")
  
      # Due to optimization order, this composite is created when all
      # the op are on the gpu.
      f = theano.function([a, b, c], a + b + c, mode=mode_with_gpu)
      topo = f.maker.fgraph.toposort()
      assert sum(isinstance(node.op, GpuElemwise) for node in topo) == 1
      assert sum(type(node.op) == tensor.Elemwise for node in topo) == 0
      utt.assert_allclose(f(a_v, b_v, c_v), a_v + b_v + c_v)
      assert _check_stack_trace(f)
  
      # Now test with the composite already on the cpu before we move it
      # to the gpu
      a_s = theano.scalar.int8()
      b_s = theano.scalar.float32()
      c_s = theano.scalar.float32()
      out_s = theano.scalar.Composite(
          [a_s, b_s, c_s], [a_s + b_s + c_s]
      )
      out_op = tensor.Elemwise(out_s)
      f = theano.function(
          [a, b, c], out_op(a, b, c), mode=mode_with_gpu
      )
      topo = f.maker.fgraph.toposort()
      assert sum(isinstance(node.op, GpuElemwise) for node in topo) == 1
      assert sum(type(node.op) == tensor.Elemwise for node in topo) == 0
      utt.assert_allclose(f(a_v, b_v, c_v), a_v + b_v + c_v)
      assert _check_stack_trace(f)
  
      return  # Not yet implemeted
      # Test multiple output
      a_s = theano.scalar.float32()
      a = tensor.fmatrix()
      from theano.scalar.basic import identity
  
      out_s = theano.scalar.Composite(
          [a_s, b_s, c_s], [identity(a_s), identity(c_s), identity(b_s)]
      )
      outs_op = tensor.Elemwise(out_s)
      f = theano.function(
          [a, b, c], outs_op(a, b, c), mode=mode_with_gpu
      )
      topo = f.maker.fgraph.toposort()
      assert sum(isinstance(node.op, GpuElemwise) for node in topo) == 1
      assert sum(type(node.op) == tensor.Elemwise for node in topo) == 0
      out = f(a_v, b_v, c_v)
      utt.assert_allclose(out[0], a_v)
      utt.assert_allclose(out[1], c_v)
      utt.assert_allclose(out[2], b_v)
      assert _check_stack_trace(f)
  
      # Test multiple output
      out_s = theano.scalar.Composite(
          [a_s, b_s, c_s], [a_s + b_s, a_s * b_s]
      )
      outs_op = tensor.Elemwise(out_s)
      f = theano.function(
          [a, b, c], outs_op(a, b, c), mode=mode_with_gpu
      )
      topo = f.maker.fgraph.toposort()
      assert sum(isinstance(node.op, GpuElemwise) for node in topo) == 1
      assert sum(type(node.op) == tensor.Elemwise for node in topo) == 0
      out = f(a_v, b_v, c_v)
      utt.assert_allclose(out[0], a_v + b_v)
      utt.assert_allclose(out[1], a_v * c_v)
      assert _check_stack_trace(f)
  
      # Test non-contiguous input
      c = gpuarray_shared_constructor(np.asarray(c_v, dtype="float32"))
      f = theano.function(
          [a, b], outs_op(a[::2], b[::2], c[::2]), mode=mode_with_gpu
      )
      out = f(a_v, b_v)
      utt.assert_allclose(out[0], a_v[::2] + b_v[::2])
      utt.assert_allclose(out[1], a_v[::2] * c_v[::2])
      assert _check_stack_trace(f)
  
imports: from __future__ import absolute_import, print_function, division
  from nose.tools import assert_raises
  import numpy
  import theano
  from theano import tensor
  import theano.tensor.slinalg
  from theano.tests.breakpoint import PdbBreakpoint
  from theano.tests import unittest_tools, test_ifelse
  from theano.tensor.tests import test_basic
  from theano.gof.opt import check_stack_trace
  import theano.gpuarray
  from ..None import basic_ops
  from ..type import GpuArrayType, gpuarray_shared_constructor, get_context
  from ..basic_ops import GpuAlloc, GpuAllocEmpty, GpuReshape, GpuFromHost, HostFromGpu, host_from_gpu
  from ..blas import GpuGemm
  from ..elemwise import GpuCAReduceCuda, GpuCAReduceCPY, GpuElemwise, Elemwise, max_inputs_to_GpuElemwise
  from ..dnn import GpuDnnReduction
  from ..subtensor import GpuSubtensor
  from ..linalg import GpuCusolverSolve, cusolver_available, GpuCholesky
  from .config import mode_with_gpu, mode_without_gpu, test_ctx_name, SkipTest
  import unittest
  from theano.tensor.nnet import abstract_conv
  from theano.gpuarray import dnn, blas, opt
label_desc: Use image node_id 16 for calling a global function with example usage: test_local_gpu_elemwise() without return types