Skip to content

Commit

Permalink
Fix docstring in topi.nn.fifo_buffer (apache#4349)
Browse files Browse the repository at this point in the history
  • Loading branch information
hcho3 authored and Xingyu Zhou committed Nov 26, 2019
1 parent 5951794 commit 522c6f9
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 6 deletions.
14 changes: 9 additions & 5 deletions python/tvm/relay/op/nn/nn.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,15 +606,19 @@ def dense(data, weight, units=None, out_dtype=""):


def fifo_buffer(data, buffer, axis):
"""FIFO buffer
"""FIFO buffer to enable computation reuse in CNNs with sliding indow input
Compute equivalent of
```
concat(buffer, data, axis=axis) \
.slice_axis(axis=axis, begin=data.shape[axis], end=data.shape[axis]+buffer.shape[axis])
```
.. code-block:: python
concat(buffer, data, axis=axis)
.slice_axis(axis=axis,
begin=data.shape[axis],
end=data.shape[axis]+buffer.shape[axis])
Useful for
* Encoding explicit re-use of computation in convolution ops operated on a sliding window input
* Implementing a FIFO queue to cache intermediate results, e.g. as in Fast WaveNet.
Expand Down
30 changes: 29 additions & 1 deletion topi/python/topi/nn/fifo_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,35 @@
@tvm.tag_scope(tag=tag.INJECTIVE+",fifo_buffer")
def fifo_buffer(data, buffer, axis):
"""
Implements the FIFO buffer
FIFO buffer to enable computation reuse in CNNs with sliding indow input
Compute equivalent of
.. code-block:: python
concat(buffer, data, axis=axis)
.slice_axis(axis=axis,
begin=data.shape[axis],
end=data.shape[axis]+buffer.shape[axis])
Useful for
* Encoding explicit re-use of computation in convolution ops operated on a sliding window input
* Implementing a FIFO queue to cache intermediate results, e.g. as in Fast WaveNet.
Parameters
----------
data : tvm.Tensor
The input data
buffer : tvm.Tensor
Previous value of the FIFO buffer
axis : int
Specify which axis should be used for buffering
Returns
-------
result : tvm.Tensor
Updated value for the buffer
"""
assert len(data.shape) == len(buffer.shape), \
'buffer and data must have same number of dimensions, ' + \
Expand Down

0 comments on commit 522c6f9

Please sign in to comment.