mirror of
https://github.com/ggerganov/llama.cpp.git
synced 2024-11-15 15:29:53 +00:00
a3738b2fa7
* Fix Vulkan repeat op * Implement Vulkan concat op * Delete old Vulkan shader generator * Implement Vulkan im2col op * Implement Vulkan unary gelu_quick op * Implement Vulkan group_norm op * Implement Vulkan timestep_embedding op * Implement Vulkan upscale op * Fix Vulkan vk_context tensor extra index issue * Fix Vulkan matmul shader parameter bug * Properly fix Vulkan matmul shader parameter bug * Add Vulkan ADD f16 + f32 -> f16 operator support * Implement Vulkan tanh op * Fix Vulkan group count too large Validation error on non-Nvidia GPUs * Throw error when too much memory is requested * Fix another Vulkan group count too large Validation error on non-Nvidia GPUs * Fix matmul MMQ condition * Implement Vulkan pad op * Fix Vulkan crash when tensor is used multiple times in a compute graph * Add Vulkan CONCAT f16 + f16 -> f16 op * Add Vulkan LEAKY_RELU op
42 lines
1.0 KiB
Plaintext
42 lines
1.0 KiB
Plaintext
#version 450
|
|
|
|
#extension GL_EXT_shader_16bit_storage : require
|
|
|
|
layout (push_constant) uniform parameter
|
|
{
|
|
uint nb1;
|
|
uint dim;
|
|
uint max_period;
|
|
} p;
|
|
|
|
#include "types.comp"
|
|
|
|
#extension GL_EXT_control_flow_attributes : enable
|
|
#define BLOCK_SIZE 256
|
|
|
|
layout(local_size_x = BLOCK_SIZE, local_size_y = 1, local_size_z = 1) in;
|
|
|
|
layout (binding = 0) readonly buffer X {A_TYPE data_a[];};
|
|
layout (binding = 1) writeonly buffer D {D_TYPE data_d[];};
|
|
|
|
void main() {
|
|
const uint i = gl_WorkGroupID.y;
|
|
const uint j = gl_GlobalInvocationID.x;
|
|
const uint d_offset = i * p.nb1;
|
|
|
|
if (p.dim % 2 != 0 && j == ((p.dim + 1) / 2)) {
|
|
data_d[d_offset + p.dim] = 0.f;
|
|
}
|
|
|
|
const uint half_dim = p.dim / 2;
|
|
if (j >= half_dim) {
|
|
return;
|
|
}
|
|
|
|
const float timestep = float(data_a[i]);
|
|
const float freq = float(exp(-log(p.max_period) * j / half_dim));
|
|
const float arg = timestep * freq;
|
|
data_d[d_offset + j] = D_TYPE(cos(arg));
|
|
data_d[d_offset + j + half_dim] = D_TYPE(sin(arg));
|
|
}
|