File size: 707 Bytes
4c65bff
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
39
40
#include <torch/extension.h>
#include <ATen/ATen.h>
#include <vector>

#define min(a, b) ((a)<(b)?(a):(b))
#define max(a, b) ((a)>(b)?(a):(b))

std::vector<at::Tensor> index_max_kernel(
  at::Tensor index_vals,
  at::Tensor indices,
  int A_num_block,
  int B_num_block
);

at::Tensor mm_to_sparse_kernel(
  at::Tensor dense_A,
  at::Tensor dense_B,
  at::Tensor indices
);

at::Tensor sparse_dense_mm_kernel(
  at::Tensor sparse_A,
  at::Tensor indices,
  at::Tensor dense_B,
  int A_num_block
);

at::Tensor reduce_sum_kernel(
  at::Tensor sparse_A,
  at::Tensor indices,
  int A_num_block,
  int B_num_block
);

at::Tensor scatter_kernel(
  at::Tensor dense_A,
  at::Tensor indices,
  int B_num_block
);