-
Notifications
You must be signed in to change notification settings - Fork 0
/
mimo.cpp
38 lines (30 loc) · 910 Bytes
/
mimo.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <torch/extension.h>
#include <vector>
// CUDA forward declarations
torch::Tensor mimo_cuda_forward(
torch::Tensor u,
torch::Tensor a,
torch::Tensor b,
torch::Tensor c,
torch::Tensor d,
unsigned int sequence_length);
#define CHECK_CUDA(x) TORCH_CHECK(x.device().is_cuda(), #x " must be a CUDA tensor")
#define CHECK_CONTIGUOUS(x) TORCH_CHECK(x.is_contiguous(), #x " must be contiguous")
#define CHECK_INPUT(x) CHECK_CUDA(x); CHECK_CONTIGUOUS(x)
torch::Tensor mimo_forward(
torch::Tensor u,
torch::Tensor a,
torch::Tensor b,
torch::Tensor c,
torch::Tensor d,
unsigned int sequence_length) {
CHECK_INPUT(u);
CHECK_INPUT(a);
CHECK_INPUT(b);
CHECK_INPUT(c);
CHECK_INPUT(d);
return {mimo_cuda_forward(u, a, b, c, d, sequence_length)};
}
PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {
m.def("forward", &mimo_forward, "Mimo forward (CUDA)");
}