Skip to content
Snippets Groups Projects

Working example

Open Mattia Mancini requested to merge add_skeleton into main
Files
5
+ 25
14
#version 450
#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
// The input-output tensors bind index is relative to index in parameter passed
layout(set = 0, binding = 0) buffer buffer_in_data {
layout(set = 0, binding = 0) buffer buffer_in_data {float data[];};
float data[];
};
void main() {
vec2 fp32_8(vec2 a, vec2 b, vec2 c) {
uint index = gl_GlobalInvocationID.x;
vec2 result = {0.f, 0.f};
// Iterating to simulate longer process
for(int i = 0; i < 2048; i ++) {
for(int i = 0;
result.x = fma(a.x, b.x, c.x);
i < 2048;
result.x = fma(-a.y, b.y, result.x);
i ++) {
result.y = fma(a.x, b.y, result.x);
fma(data[index], data[index], data[index]);
result.y = fma(a.y, b.x, result.y);
fma(data[index], - data[index], data[index]);
}
fma(data[index], data[index], - data[index]);
return result;
fma(data[index], data[index], data[index]);
}
}
 
 
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