put num_warps and num_stages in kwargs

Signed-off-by: jinjieliu <jinjie.liu@usc.edu>
This commit is contained in:
jinjieliu
2026-02-07 14:25:10 +08:00
parent 2298b6f8c8
commit 6a19a6b06d
5 changed files with 10 additions and 20 deletions

View File

@@ -4,7 +4,7 @@
#include <tvm/ffi/tvm_ffi.h>
#ifndef SOFTMAX_KERNEL_STUB
#define SOFTMAX_KERNEL_STUB(grid, stream, numWarps, numStages, args, kwargs)
#define SOFTMAX_KERNEL_STUB(grid, stream, args, kwargs)
#endif
#ifndef SOFTMAX_NAME
@@ -14,19 +14,17 @@
tvm::ffi::Tensor Softmax(tvm::ffi::Tensor x) {
at::Tensor xtorch = at::fromDLPack(x.ToDLPack());
at::Tensor ytorch = at::empty_like(xtorch);
uint32_t nRows = xtorch.size(0), nCols = xtorch.size(1), numWarps = 8,
numStages = 4, xStride = xtorch.stride(0),
yStride = ytorch.stride(0),
uint32_t nRows = xtorch.size(0), nCols = xtorch.size(1),
xStride = xtorch.stride(0), yStride = ytorch.stride(0),
BLOCK_SIZE = 1u << (32 - __builtin_clz(nCols - 1));
tvm::ffi::Tensor y = tvm::ffi::Tensor::FromDLPack(at::toDLPack(ytorch));
tvm::ffi::Tuple<int32_t, int32_t, int32_t> grid{nRows / 1024, 1, 1};
DLDevice device = x.device();
void* stream =
TVMFFIEnvGetStream(device.device_type, device.device_id);
void *stream = TVMFFIEnvGetStream(device.device_type, device.device_id);
tvm::ffi::Array<tvm::ffi::Any> args = {y, x, xStride, yStride,
nRows, nCols, BLOCK_SIZE};
tvm::ffi::Map<tvm::ffi::String, tvm::ffi::Any> kwargs = {};
SOFTMAX_KERNEL_STUB(grid, stream, numWarps, numStages, args, kwargs);
SOFTMAX_KERNEL_STUB(grid, stream, args, kwargs);
return y;
}