Uh oh!
There was an error while loading. Please reload this page.
[TOPI][IMAGE][RESIZE] Bilinear interpolation for resize and upsampling. - #1181
Conversation
aecac12 to
8543d28CompareFrozenGene
commented
May 29, 2018
I just go through in mobile. Maybe omit something. |
align_corners doesn't affect the final shape, it just few pixels retained from input source to output with out re computation.. I will add that soon while review in progress. |
srkreddy1238
commented
May 29, 2018
How about merging upsampling and bilinear into scale from frontend ? |
FrozenGene
commented
May 30, 2018
align_corners, you can refer the TF's implementation: For nearest neighbours: const int64 in_y = std::min(
(align_corners) ? static_cast<int64>(roundf(y * height_scale))
: static_cast<int64>(floorf(y * height_scale)),
in_height - 1);
for (int x = 0; x < out_width; ++x) {
const int64 in_x = std::min(
(align_corners) ? static_cast<int64>(roundf(x * width_scale))
: static_cast<int64>(floorf(x * width_scale)),
in_width - 1);For ResizeBilinear: // CalculateResizeScale determines the float scaling factor.inlinefloatCalculateResizeScale(int64 in_size, int64 out_size,
bool align_corners) {
return (align_corners && out_size > 1)
? (in_size - 1) / static_cast<float>(out_size - 1)
: in_size / static_cast<float>(out_size);
}
height_scale = CalculateResizeScale(in_height, out_height, align_corners_);
width_scale = CalculateResizeScale(in_width, out_width, align_corners_);I personally prefer keep separate interface. Which will make the customer know what op do. How to implement these op is the low-level framework's work. You can unify into scale you can also choose not to do. |
srkreddy1238
commented
May 30, 2018
Thanks, I will check the above logic for align_coeners. Separation at customer end happens by "mode" attribute. The template and purpose is same hence I feel good to unify upto frontend. @tqchen what do you think ? |
ed38ba4 to
4a32049Comparesrkreddy1238
commented
May 30, 2018
I got through align_corners for bilinear, the same for nn is a challenge due to round, floor compatible IR instructions. Any ideas ? Or will hold align_corners for nn until there is a demand for it ! |
srkreddy1238
commented
May 31, 2018
|
FrozenGene
commented
May 31, 2018
You can implement floor like this: https://discuss.tvm.ai/t/floordiv-operation-in-tensors-how-to-achieve/146/5 Then we should not have not-compatibility instruction |
srkreddy1238
commented
May 31, 2018
Ok, let me try the floor operator addition first. I hope mod division work fine with all platforms by default. |
masahi
commented
May 31, 2018
thanks, having bilinear upsampling is nice. But what is the use case of asymmetric upsampling (different scales for width and height) ? |
srkreddy1238
commented
May 31, 2018
Yes, different scale for width and height. I don't have information on real time models for asymmetric scale. I felt its easy to maintain with new algorithms in future if required. Thanks for the review :) |
FrozenGene
commented
May 31, 2018
Please do the test on the OpenCL platform carefully. Someone told me that mod opeartor on floating point type has some issue. |
srkreddy1238
commented
May 31, 2018
Sure, I will check that too. |
tqchen
commented
Jun 5, 2018
any updates on this PR? @masahi@FrozenGene do you have followup comments? |
masahi
commented
Jun 6, 2018
Shouldn't |
srkreddy1238
commented
Jun 6, 2018
Can I merge them both as "scale" and made it generic at all levels? |
srkreddy1238
commented
Jun 6, 2018
@masahi |
masahi
commented
Jun 6, 2018
I think "upsampling" is a better name than "scale". I don't know why you want down sampling, when we already have pooling. |
* Doc changes from review (3D tensor and others) * set_num_inputs, input_names : Dynamic assignment for resize and upsampling. * align_corners removed across for upsampling. * in_shape->size checks updated. * Bilinear test case added at compiler level.
* UseBilinear as common function. * Doc correction.
* mode -> method * Documentation changes.
f78a5c4 to
d24c986Compare* weights arg removed across nnvm/tvm.
srkreddy1238
commented
Jun 14, 2018
tqchen
commented
Jun 14, 2018
CI is upgraded to use python3 in most cases but there is still python2 checks, so the code is better to be compatible until 2019 |
| )" NNVM_ADD_FILELINE) | ||
| .add_argument("data", "4D Tensor", "Input data.") | ||
| .add_argument("weight", "3D Tensor", "Weight matrix.") |
There was a problem hiding this comment.
Thanks. removed now.
masahi
commented
Jun 14, 2018
LGTM. |
Thanks to the reviewers and the contributor, this is merged. |
ppwwyyxx
commented
Jul 26, 2019
From the discussion it seems like this implementation follows resize in tensorflow. However, |
Discuss:
Above implementation merges both nn (upsampling) and bilinear at topi.cpp level as scale.
How about merging upsampling & bilinear as scale at python tvm.topi and nnvm front end too ?
We can have just "scale" at all places in this case.