Skip to content
Snippets Groups Projects

Working example

Open Mattia Mancini requested to merge add_skeleton into main

Files

#version 450
layout(local_size_x = 1) in;
layout(local_size_x = 1024) in;
// The input-output tensors bind index is relative to index in parameter passed
layout(set = 0, binding = 0) buffer buffer_in_data {
float data[];
};
layout(set = 0, binding = 0) buffer buffer_in_data {float data[];};
void main() {
uint index = gl_GlobalInvocationID.x;
// Iterating to simulate longer process
for(int i = 0;
i < 2048;
i ++) {
fma(data[index], data[index], data[index]);
fma(data[index], - data[index], data[index]);
fma(data[index], data[index], - data[index]);
fma(data[index], data[index], data[index]);
vec2 fp32_8(vec2 a, vec2 b, vec2 c) {
vec2 result = {0.f, 0.f};
for(int i = 0; i < 2048; i ++) {
result.x = fma(a.x, b.x, c.x);
result.x = fma(-a.y, b.y, result.x);
result.y = fma(a.x, b.y, result.x);
result.y = fma(a.y, b.x, result.y);
}
return result;
}
void main() {
uint index = gl_GlobalInvocationID.x;
// Iterating to simulate longer process
vec2 a = { data[index], data[index + 1] };
vec2 b = { 1.f, 2.f };
vec2 c = { 3.f, 4.f };
vec2 d = {0.f, 0.f};
for(int i = 0; i < 2048; i ++) {
d = d+ fp32_8(a, b, c);
}
data[index] = d.x + d.y;
}
Loading