Commits


Seungwon Jeong authored and GitHub committed 307ad1413a0
[js/web] support 'pytorch_half_pixel' mode for WebGL kernel 'Resize' (#11208) **Description**: 1. add pytorch_half_pixel interpolation mode in resize-packed.ts Changes: add the following case in createPackedResizeProgramInfo function: ``` case 'pytorch_half_pixel': getSourceFracIndex = ` vec4 getSourceFracIndex(ivec4 coords) { vec4 fcoords = vec4(coords); return vec4( ${outputWidth}.0 > 1.0 ? (fcoords.x + 0.5) / scaleWHWH.x - 0.5 : 0.0, ${outputHeight}.0 > 1.0 ? (fcoords.y + 0.5) / scaleWHWH.y - 0.5 : 0.0, ${outputWidth}.0 > 1.0 ? (fcoords.z + 0.5) / scaleWHWH.z - 0.5 : 0.0, ${outputHeight}.0 > 1.0 ? (fcoords.w + 0.5) / scaleWHWH.w - 0.5 : 0.0 ); } `; break; ``` 2. fix "unrecognized input '' for node: Resize_$num" error when inputs like [input_tensor, None, scale_factor] (roiInput not given) are fed into the resize layer. Changes: change in input handling logic in upsample.ts & node scanning logic in graph.ts **Motivation and Context** Before this fix, we aren't able to use webGL backend when the neural network contains pytorch resize layers. This fix adds 'pytorch_half_pixel' interpolation mode support and makes it possible to use webGL backend for more kind of computer vision networks. This commit solves: #10430 Co-authored-by: neo <neo@icode-lab.com> Co-authored-by: Yulong Wang <7679871+fs-eire@users.noreply.github.com>