

def c_code(self, node, name, inputs, outputs, sub):
    '\n        .. todo::\n\n            WRITEME\n        '
    (images, seed) = inputs
    (targets,) = outputs
    fail = sub['fail']
    num_braces = 0
    if self.copy_non_contiguous:
        raise UnimplementedError()
    else:
        basic_setup = '#define STOCHASTICMAXPOOL_COPY_NON_CONTIGUOUS 0\n'
    setup_nv_images = (self._argument_contiguity_check('images') + '\n        if (%(images)s->nd != 4)\n        {\n            PyErr_Format(PyExc_ValueError,\n                "images must have nd=4, got nd=%%i", %(images)s->nd);\n            %(fail)s;\n        }\n\n        { //setup_nv_images brace 1\n\n        const int * images_dims = CudaNdarray_HOST_DIMS(%(images)s);\n        const int img_channels = images_dims[0];\n        const int imgSizeY = images_dims[1];\n        const int imgSizeX = images_dims[2];\n        const int batch_size = images_dims[3];\n\n        if(imgSizeY != imgSizeX){\n            PyErr_Format(PyExc_ValueError,\n                "images must be square(dims[1] == dims[2]). Shape (%%i,%%i,%%i,%%i)",\n                img_channels, imgSizeY, imgSizeX, batch_size);\n            %(fail)s;\n        }\n        if(%(ds)s > imgSizeY){\n            PyErr_Format(PyExc_ValueError,\n                "ds(%%d) must be <= imgSizeX(%%d) and imgSizeY(%%d).",\n                %(ds)s, imgSizeX, imgSizeY);\n            %(fail)s;\n        }\n        if(%(start)s >= imgSizeX){\n            PyErr_Format(PyExc_ValueError,\n                "start is %%d but must be smaller then the images size of %%d x %%d.",\n                %(start)s, imgSizeX, imgSizeY);\n            %(fail)s;\n        }\n\n        NVMatrix nv_images(%(images)s, img_channels * imgSizeY * imgSizeX, batch_size,\n        "MaxPool:nv_images");\n\n        //int * seed = CudaNdarray_HOST_DIMS%(seed)s;\n        float *  seed = CudaNdarray_DEV_DATA(%(seed)s);\n        //int * seed = %(seed)s;\n        ')
    num_braces += 1
    setup_nv_targets = '\n        //int _outputsX = int(ceil((dic[\'imgSize\'] - dic[\'start\'] - dic[\'sizeX\']) / float(dic[\'stride\']))) + 1;\n        int _outputsX = ((int)(ceil((imgSizeY - %(start)s - %(ds)s) / ((float)%(stride)s)))) + 1;\n\n        int target_dims [] = {\n            img_channels,\n            _outputsX,\n            _outputsX,\n            batch_size };\n\n        if (CudaNdarray_prep_output(& %(targets)s, 4, target_dims))\n        {\n            %(fail)s;\n        }\n\n        { // setup_nv_target brace # 1\n\n        NVMatrix nv_targets(%(targets)s, target_dims[0] * target_dims[1] * target_dims[2],\n                            target_dims[3], "MaxPool:nv_targets");\n\n        '
    num_braces += 1
    do_pool = '\n        convLocalStochasticMaxPool(nv_images, nv_targets, img_channels, %(ds)s,\n                      %(start)s, %(stride)s, _outputsX, MaxPooler(), seed);\n        '
    braces = ('}' * num_braces)
    rval = ((((basic_setup + setup_nv_images) + setup_nv_targets) + do_pool) + braces)
    start = self.start
    stride = self.stride
    ds = self.ds
    rval = (node % locals())
    return rval

dataset/ETHPy150Open lisa-lab/pylearn2/pylearn2/sandbox/cuda_convnet/stochastic_pool.py StochasticMaxPool.c_code/VarMisuse@148/1188 `rval`->`node`