mirror of
https://github.com/sgjzfzzf/triton-tvm-ffi.git
synced 2026-05-02 03:52:11 +08:00
put num_warps and num_stages in kwargs
Signed-off-by: jinjieliu <jinjie.liu@usc.edu>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user