code: def test_GpuCumOp3D(self, mode):
      np_func = dict(add=np.cumsum, mul=np.cumprod)[mode]
      op_class = partial(self.op_class, mode=mode)
      block_max_size = self.max_threads_dim0 * 2
  
      x = T.ftensor3("x")
      for shape_axis, axis in zip(
          [0, 1, 2, 0, 2, 1, 0], [0, 1, 2, None, -1, -2, -3]
      ):
          f = theano.function(
              [x], op_class(axis=axis)(x), mode=self.mode
          )
          assert [
              n
              for n in f.maker.fgraph.toposort()
              if isinstance(n.op, GpuCumOp)
          ]
  
          # Extensive testing for the first 1025 sizes
          a_shape = [5, 5, 5]
          a_shape[shape_axis] = 1025
          a = np.random.rand(*a_shape).astype("float32")
          slices = [slice(None), slice(None), slice(None)]
          for i in xrange(a.shape[shape_axis]):
              slices[shape_axis] = slice(i)
              fa = f(a[slices])
              npa = np_func(a[slices], axis=axis)
              utt.assert_allclose(npa, fa)
  
          # Use multiple GPU threadblocks (along accumulation axis)
          a_shape = [2, 2, 2]
          a_shape[shape_axis] = block_max_size + 2
          a = np.random.random(a_shape).astype("float32")
          utt.assert_allclose(np_func(a, axis=axis), f(a))
  
          # Use multiple GPU gridblocks (not along accumulation axis)
          a_shape = [5, 5, 5]
          a_shape[(shape_axis + 1) % 3] = self.max_grid_size1 + 1
          a = np.random.random(a_shape).astype("float32")
          if axis is None:
              # Avoid floating point error
              a = np.sign(a - 0.5).astype("float32")
          utt.assert_allclose(np_func(a, axis=axis), f(a))
  
          a_shape = [5, 5, 5]
          a_shape[(shape_axis + 2) % 3] = self.max_grid_size1 + 1
          a = np.random.random(a_shape).astype("float32")
          if axis is None:
              # Avoid floating point error
              a = np.sign(a - 0.5).astype("float32")
          utt.assert_allclose(np_func(a, axis=axis), f(a))
  
          # Use recursive cumop (along accumulation axis)
          a_shape = [3, 3, 3]
          a_shape[shape_axis] = (
              block_max_size * (block_max_size + 1) + 2
          )
          a = np.random.random(a_shape).astype("float32")
          a = np.sign(a - 0.5).astype(
              "float32"
          )  # Avoid floating point error
          utt.assert_allclose(np_func(a, axis=axis), f(a))
  
imports: from __future__ import absolute_import, print_function, division
  from functools import partial
  from itertools import product
  import numpy
  from six.moves import xrange
  from theano import tensor
  import theano
  import theano.tensor.tests.test_extra_ops
  from theano.tensor.extra_ops import CumOp
  from theano.tests.unittest_tools import SkipTest
  from theano.tests import unittest_tools
  from .config import mode_with_gpu, test_ctx_name
  from ..extra_ops import GpuCumOp
  from ..type import get_context
label_desc: Use image node_id 10 for calling the TestGpuCumOp obj's underlying member method code with example usage: obj.test_GpuCumOp3D(mode) without return types