Modern Apps git
git clone https://git.maproj.org/Modern-Apps.git
translate ▾

Modern-Apps.git / library / ml / src / main / rust / shaders / add.comp

add.comp20 lines · 777 BRaw
1#version 450
2//! Elementwise sum of two equally-shaped tensors. 25 uses: U^2-Netp's 11 RSU residuals
3//! and the selfie net's 14.
4//!
5//! Not fused into the producing convolution the way activations are. It could be — the
6//! convolution's accumulator could start from the skip instead of from the bias — but
7//! every one of these adds a tensor that is *also* read elsewhere, so the fused form
8//! would need a second input binding and a flag on the conv shader for a saving of one
9//! pass over data that is already in cache.
10
11#include "common.glsl"
12
13void main() {
14 uint index = global_index();
15 if (index >= p.count) {
16 return;
17 }
18 float sum = float(arena[p.in0 + index]) + float(arena[p.in1 + index]);
19 arena[p.out_at + index] = float16_t(sum);
20}