What does the operator "tvm.relay.nn.dilate" do?

Hello. I’m trying to understand the operator “tvm.relay.nn.dilate” in the relay model. I can’t quite get it although there are some explainations in the “docs”. Can anyone explain more in detail that what nn.dilate is used for and in what case nn.dilate might be used? Thanks a lot.

In general, an easy way I use to understand things in TVM (or probably any framework is to look for unit tests), especially when documentation is not enough.

In this case, I looked at the test_topi_dilate.py function and based on its python implementation here (which is easier to understand) it seems like a traditional definition of dilation.

Given an input of some size and dilation would result in a potentially larger tensor that gets scaled by the dilation factor with the extra values being defaulted to zero or as mentioned in the dilation_value parameter.

Example I tried:

# coding: utf-8
from tvm.topi.testing.dilate_python import dilate_python
import numpy as np
inp = np.random.randint(low=0, high=255, size=(32,32)).astype('uint8')
out = dilate_python(inp, (2,2))
print(out)
dilate_python(inp, (2,2))
print(inp.shape)
print(out.shape)

Thank you so much for your help! I will check the links you’ve mentioned.