suffix.es6 1.4 KB
Newer Older
W
wangqun 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/* eslint-disable */
/**
 * @file 公共方法-尾部, 方法1: 获取输出坐标
 * @author yangmingming
 */
export default `
vec2 _2d_shape_texture_out = vec2(float(width_texture_out), float(height_texture_out));
ivec4 getOutputTensorPos() {
    // 获取原始长度
    vec2 outCoord = vCoord.xy * _2d_shape_texture_out;
    int x = int(outCoord.x / float(channel_out));
    int c = int(mod(outCoord.x, float(channel_out)));
    int y = int(mod(outCoord.y, float(height_shape_out)));
    int b = int(outCoord.y / float(height_shape_out));
    return ivec4(b, c, y, x);
}

18

W
wangqun 已提交
19 20 21 22 23
ivec4 getOutputTensorPosLimit() {
    // 获取原始长度
    vec2 outCoord = vCoord.xy * _2d_shape_texture_out;
    float offsetY = floor(outCoord.y / float(height_shape_out));
    int x = int(outCoord.x / float(channel_out));
24 25
    if (mod(offsetY, 4.0) > 0.0) {
        x += int(mod(offsetY, 4.0)) * int(ceil(float(width_shape_out) / 4.0));
W
wangqun 已提交
26 27 28
    }
    int y = int(mod(outCoord.y, float(height_shape_out)));
    int c = int(mod(outCoord.x, float(channel_out)));
29
    int b = int(outCoord.y / float(4 * height_shape_out));
W
wangqun 已提交
30 31 32 33 34 35 36 37 38 39 40 41 42 43
    return ivec4(b, c, y, x);
}

ivec4 getOutputPackedTensorPos() {
    // 获取原始长度
    vec2 outCoord = vCoord.xy * _2d_shape_texture_out;
    int height = height_shape_out + offset_y_out;
    int x = int(outCoord.x);
    int c = int(outCoord.y / float(height / 2));
    int y = int(mod(outCoord.y, float(height / 2)));
    int b = 0;
    return ivec4(b, c, y, x);
}
`;