One thing I would like to mention is that manual wrapping has its merit :)

Take the following wrapper code for scan as an example. By manually wrapping it 
in python, we can benefit from:
- A clear signature that users can look up
- Keyword argument and default value
- Python-specific documents, in particular, the type signature and most 
importantly code examples.

```python
def scan(init, update, state_placeholder, inputs=None, name="scan", tag="", 
attrs=None):
    """Construct new tensors by scanning over axis.

    Parameters
    ----------
    init: Tensor or list of Tensor
        The initial condition of first init.shape[0] timestamps
    update: Tensor or list of Tensor
        The update rule of the scan given by symbolic tensor.
    state_placeholder: Tensor or list of Tensor
        The placeholder variables used by update.
    inputs: Tensor or list of Tensor, optional
        The list of inputs to the scan. This is not required, but can
        be useful for the compiler to detect scan body faster.
    name: str, optional
        The name hint of the tensor
    tag: str, optional
        Additonal tag information about the compute.
    attrs: dict, optional
        The additional auxiliary attributes about the compute.
    Returns
    -------
    tensor: Tensor or list of Tensors
        The created tensor or tuple of tensors it it contains multiple outputs.
    Example
    -------
    .. code-block:: python
      # The following code is equivalent to numpy.cumsum
      m = tvm.var("m")
      n = tvm.var("n")
      X = tvm.placeholder((m, n), name="X")
      s_state = tvm.placeholder((m, n))
      s_init = tvm.compute((1, n), lambda _, i: X[0, i])
      s_update = tvm.compute((m, n), lambda t, i: s_state[t-1, i] + X[t, i])
      res = tvm.scan(s_init, s_update, s_state, X)
```

While it is possible to have a system that codegen these components, that might 
mean we have to write the python example documents directly in somewhere else, 
which is less natural.

Of course, one drawback of doing the manual wrapping is that such wrapper has 
to be created for each language.  This may not be a bad thing, especially we 
want to think clearly about the language specific features, and write good 
documents.

I do think there is some merit to do have good metadata for the node system and 
automatically generate some of the accessors.



-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/dmlc/tvm/issues/2983#issuecomment-480655160

Reply via email to