forked from JeffreyXiang/FlexGEMM
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
25 lines (20 loc) · 722 Bytes
/
example.py
File metadata and controls
25 lines (20 loc) · 722 Bytes
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
import torch
import flex_gemm
from flex_gemm.ops.spconv import sparse_submanifold_conv3d
from tests.spconv_fwd import sphere_coords
# Sparse voxel shell
feats, coords, shape = sphere_coords(64, 256, dtype=torch.float16, device='cuda')
# Weight and bias
Ci, Co = 256, 256
Ks = 3
weight = torch.randn(Co, Ks, Ks, Ks, Ci, dtype=torch.float16, device='cuda', requires_grad=True)
bias = torch.randn(Co, dtype=torch.float16, device='cuda', requires_grad=True)
# Set algorithm: Masked + Split-K
flex_gemm.ops.spconv.set_algorithm(
flex_gemm.ops.spconv.Algorithm.MASKED_IMPLICIT_GEMM_SPLITK
)
out_feats, neignbor_cache = sparse_submanifold_conv3d(
feats, coords, shape,
weight, bias,
)
out_feats.sum().backward()