Skip to content

Commit 8653344

Browse files
Fix softmax kernel with padding for llm.c
1 parent 98644f7 commit 8653344

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

experimental/kernels/run.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,12 @@ void testSoftmax(Context &ctx) {
6565
struct SoftmaxParam {
6666
uint32_t N;
6767
uint32_t C;
68+
uint32_t Cp;
6869
};
6970
static constexpr size_t B = 6; // batch size
7071
static constexpr size_t T = 8; // token index
7172
static constexpr size_t C = 3072; // input channels
73+
static constexpr size_t Cp = 3072; // input channels with padding
7274
std::array<float, B * T * C> inputArr;
7375
std::array<float, B * T * C> outputArr;
7476
std::mt19937 gen(31415);
@@ -79,7 +81,7 @@ void testSoftmax(Context &ctx) {
7981
std::future<void> future = promise.get_future();
8082
Kernel op = createKernel(
8183
ctx, {kShaderSoftmax1, 256, kf32}, Bindings{input, output},
82-
Shape{cdiv(B * T, 256), 1, 1}, SoftmaxParam{B * T, C});
84+
Shape{cdiv(B * T, 256), 1, 1}, SoftmaxParam{B * T, C, Cp});
8385
dispatchKernel(ctx, op, promise);
8486
wait(ctx, future);
8587
toCPU(ctx, output, outputArr.data(), sizeof(outputArr));

0 commit comments

Comments
 (0)