Where is the compute programs of pooling

Hi, thanks for answer this question.

I check the code of topi/python/topi/cuda/pooling.py and find that this file is changed, there is no compute code now. what I can see is that :

return cpp.nn.pool(data, kernel, stride, padding,POOL_TYPE_CODE[pool_type], ceil_mode, layout)

there is no details of compute as before like this.

  • assert len(data.shape) == 4, “only support 4-dim pooling”
  • assert len(stride) == 2, “only support 2-dim stride”
  • kernel_height, kernel_width = kernel
  • stride_height, stride_width = stride
  • batch, channel, height, width = data.shape
  • pad_top, pad_left, pad_down, pad_right = get_pad_tuple(
  •    padding, (kernel_height, kernel_width))
    
  • if ceil_mode:
  •    # Additional padding to ensure we do ceil instead of floor when divide stride.
    
  •    pad_down += stride_height -1
    
  •    pad_right += stride_width - 1
    
  • pad_before = [0, 0, pad_top, pad_left]
  • pad_after = [0, 0, pad_down, pad_right]
  • out_height = util.simplify((height - kernel_height + pad_top + pad_down) // stride_height + 1)
  • out_width = util.simplify((width - kernel_width + pad_left + pad_right) // stride_width + 1)
  • dheight = tvm.reduce_axis((0, kernel_height))
  • dwidth = tvm.reduce_axis((0, kernel_width))
  • if pool_type == ‘max’:
  •    temp = pad(data, pad_before, pad_after, name="pad_temp", \
    
  •        pad_value=tvm.min_value(data.dtype))
    
  •    return tvm.compute((batch, channel, out_height, out_width), \
    
  •                        lambda n, c, h, w: \
    
  •                        tvm.max(temp[n, c, h*stride_height+dheight, w*stride_width+dwidth], \
    
  •                            axis=[dheight, dwidth]), \
    
  •                        tag="pool_max")
    

so does the details is changed to another files ?

The code you see in
topi/python/topi/nn/pooling.py

return cpp.nn.pool(data, kernel, stride, padding,
                       POOL_TYPE_CODE[pool_type], ceil_mode, layout, count_include_pad)

diverts the call to cpp implementation of pooling operator. You can find CPP definition of pooling compute here

In pooling.h you can find your required compute definition.

Hope this solves your query.

thanks for your help