This is an automated email from the ASF dual-hosted git repository.

skm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git


The following commit(s) were added to refs/heads/master by this push:
     new 874fb89  Add API documentation for upsampling operator with examples 
(#14919)
874fb89 is described below

commit 874fb89cd33b0e4affd7f3fb1b4ae4e09f25ef84
Author: Sandeep Krishnamurthy <sandeep.krishn...@gmail.com>
AuthorDate: Thu May 9 16:12:18 2019 -0700

    Add API documentation for upsampling operator with examples (#14919)
    
    * Add API documentation for upsampling operator with examples
    
    * Update src/operator/nn/upsampling.cc
    
    Co-Authored-By: Aaron Markham <markh...@amazon.com>
    
    * Update src/operator/nn/upsampling.cc
    
    Co-Authored-By: Aaron Markham <markh...@amazon.com>
    
    * Update src/operator/nn/upsampling.cc
    
    Co-Authored-By: Aaron Markham <markh...@amazon.com>
    
    * Make API doc example as pseudocode than code
---
 src/operator/nn/upsampling.cc | 53 ++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 50 insertions(+), 3 deletions(-)

diff --git a/src/operator/nn/upsampling.cc b/src/operator/nn/upsampling.cc
index cb57b1b..971ff6a 100644
--- a/src/operator/nn/upsampling.cc
+++ b/src/operator/nn/upsampling.cc
@@ -121,9 +121,56 @@ struct UpSamplingGrad {
 DMLC_REGISTER_PARAMETER(UpSamplingParam);
 
 NNVM_REGISTER_OP(UpSampling)
-.describe("Performs nearest neighbor/bilinear up sampling to inputs. "
-          "Bilinear upsampling makes use of deconvolution. Therefore, "
-          "provide 2 inputs - data and weight. ")
+.describe(R"code(Upsamples the given input data.
+
+Two algorithms (``sample_type``) are available for upsampling:
+
+- Nearest Neighbor
+- Bilinear
+
+**Nearest Neighbor Upsampling**
+
+Input data is expected to be NCHW.
+
+Example::
+
+  x = [[[[1. 1. 1.]
+         [1. 1. 1.]
+         [1. 1. 1.]]]]
+
+  UpSampling(x, scale=2, sample_type='nearest') = [[[[1. 1. 1. 1. 1. 1.]
+                                                     [1. 1. 1. 1. 1. 1.]
+                                                     [1. 1. 1. 1. 1. 1.]
+                                                     [1. 1. 1. 1. 1. 1.]
+                                                     [1. 1. 1. 1. 1. 1.]
+                                                     [1. 1. 1. 1. 1. 1.]]]]
+
+**Bilinear Upsampling**
+
+Uses `deconvolution` algorithm under the hood. You need provide both input 
data and the kernel.
+
+Input data is expected to be NCHW.
+
+`num_filter` is expected to be same as the number of channels.
+
+Example::
+
+  x = [[[[1. 1. 1.]
+         [1. 1. 1.]
+         [1. 1. 1.]]]]
+
+  w = [[[[1. 1. 1. 1.]
+         [1. 1. 1. 1.]
+         [1. 1. 1. 1.]
+         [1. 1. 1. 1.]]]]
+  
+  UpSampling(x, w, scale=2, sample_type='bilinear', num_filter=1) = [[[[1. 2. 
2. 2. 2. 1.]
+                                                                       [2. 4. 
4. 4. 4. 2.]
+                                                                       [2. 4. 
4. 4. 4. 2.]
+                                                                       [2. 4. 
4. 4. 4. 2.]
+                                                                       [2. 4. 
4. 4. 4. 2.]
+                                                                       [1. 2. 
2. 2. 2. 1.]]]]
+)code" ADD_FILELINE)
 .set_num_inputs([](const NodeAttrs& attrs) {
   const UpSamplingParam& params = nnvm::get<UpSamplingParam>(attrs.parsed);
   return params.sample_type == up_enum::kNearest ? params.num_args : 2;

Reply via email to