Skip to content

Commit

Permalink
gridsample op support (#4288)
Browse files Browse the repository at this point in the history

Co-authored-by: LRY89757 <LRY89757@users.noreply.github.com>
Co-authored-by: nihuini <nihuini@tencent.com>
Co-authored-by: nihui <shuizhuyuanluo@126.com>
  • Loading branch information
4 people authored Nov 11, 2022
1 parent 6019f47 commit 6a47f8d
Show file tree
Hide file tree
Showing 13 changed files with 836 additions and 1 deletion.
29 changes: 29 additions & 0 deletions docs/developer-guide/operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
* [GELU](#gelu)
* [GLU](#glu)
* [Gemm](#gemm)
* [GridSample](#gridsample)
* [GroupNorm](#groupnorm)
* [GRU](#gru)
* [HardSigmoid](#hardsigmoid)
Expand Down Expand Up @@ -816,6 +817,34 @@ y = gemm(a, b) * alpha + c * beta
| 2 | transA | int | 0 | |
| 3 | transb | int | 0 | |

# GridSample
```
Given an input and a flow-field grid, computes the output using input values and pixel locations from grid.
For each output location output[:, h2, w2], the size-2 vector grid[h2, w2, 2] specifies input pixel[:, h1, w1] locations x and y,
which are used to interpolate the output value output[:, h2, w2]
This function is often used in conjunction with affine_grid() to build Spatial Transformer Networks .
```

| param id | name | type | default | description |
| --------- | ------------- | ----- | --------- | ----------------- |
| 0 | sample_type | int | 1 | |
| 1 | padding_mode | int | 1 | |
| 2 | align_corner | int | 0 | |


Sample type:
- 1 = Nearest
- 2 = Bilinear
- 3 = Bicubic

Padding mode:
- 1 = zeros
- 2 = border
- 3 = reflection


# GroupNorm
```
split x along channel axis into group x0, x1 ...
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ ncnn_add_layer(DeformableConv2D)
ncnn_add_layer(GLU)
ncnn_add_layer(Fold)
ncnn_add_layer(Unfold)
ncnn_add_layer(GridSample)

if(NCNN_VULKAN)
ncnn_add_shader(${CMAKE_CURRENT_SOURCE_DIR}/convert_ycbcr.comp)
Expand Down
Loading

0 comments on commit 6a47f8d

Please sign in to comment.