main.es6 1.1 KB
Newer Older
Y
yangmingming 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
/* eslint-disable */
/**
 * @file 主函数
 * @author yangmingming
 */
export default `
    // start函数
    void main(void) {
        ivec4 oPos = getOutputTensorPosLIMIT_OUT();
        int x = oPos.a;
        int c = oPos.g;
        int y = oPos.b;
        int b = oPos.r; 
        float res = 0.0;

        int top = y * stride_v - padTop;
        int left = x * stride_h - padLeft;
        for (int fy = 0; fy < height_shape_filter; fy++) {
          int oy = top + fy * dilation_v;
          if (oy >= height_shape_origin) {
              break;
          }
          if (oy < 0) {
            continue;
          }
          for (int fx = 0; fx < width_shape_filter; fx++) {
            int ox = left + fx * dilation_h;
            if (ox >= width_shape_origin) {
                break;
            }
            if (ox < 0) {
                continue;
            }
            // b默认是0
            float f = getValueFromTensorPosLIMIT_FILTER_filter(c, 0, fy, fx);
            float o = getValueFromTensorPosLIMIT_ORIGIN_origin(b, c, oy, ox);
            res += f * o;
          }
        }
        setOutput(res);
    }
`;