Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a padding operator #94

Open
xyzsam opened this issue Jun 27, 2021 · 0 comments
Open

Add a padding operator #94

xyzsam opened this issue Jun 27, 2021 · 0 comments

Comments

@xyzsam
Copy link
Member

xyzsam commented Jun 27, 2021

Sometimes tensors need to be manually padded in some dimensions. Add an operator like numpy.pad.

xyzsam pushed a commit that referenced this issue Jul 17, 2021
The implemented operator supports padding in all dimensions and asymmetric padding. And it is implemented in software only, no accelerated version is available. The code is tested in both CPP and python API. In the CPP test, I test it with different input sizes (2D, 4D) and different padding patterns (asymmetric, symmetric). The python API testing is mainly focused on it can work in a graph.

Example Python code.
```python
      # consider input_tensor is a 4D tensor, we pad the last 2 dimension with 1
      out = array_ops.padding(input_tensor, [0, 0, 0, 0, 1, 1, 1, 1], "padding")
      # consider input_tensor is a 4D tensor, we pad the 2nd dimension with symmetric 
      # padding with size 1 and the 3rd dimension with asymmetric padiing of size 1 and 2.
      out = array_ops.padding(input_tensor, [0, 0, 0, 0, 1, 1, 1, 2], "padding")
```

Fixes issue #94.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant