-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrasterize_points.h
191 lines (152 loc) · 4.88 KB
/
rasterize_points.h
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
/*
* Copyright (C) 2023, Inria
* GRAPHDECO research group, https://team.inria.fr/graphdeco
* All rights reserved.
*
* This software is free for non-commercial, research and evaluation use
* under the terms of the LICENSE.md file.
*
* For inquiries contact [email protected]
*/
#pragma once
#include <torch/extension.h>
#include <cstdio>
#include <tuple>
#include <string>
torch::Tensor markVisible(
torch::Tensor& means3D,
torch::Tensor& viewmatrix,
torch::Tensor& projmatrix);
/////////////////////////////// Preprocess ///////////////////////////////
std::tuple<int, torch::Tensor, torch::Tensor, torch::Tensor, torch::Tensor, torch::Tensor, torch::Tensor, torch::Tensor>
PreprocessGaussiansCUDA(
const torch::Tensor& means3D,
const torch::Tensor& scales,
const torch::Tensor& rotations,
const torch::Tensor& sh,
const torch::Tensor& opacity,//3dgs' parametes.
const float scale_modifier,
const torch::Tensor& viewmatrix,
const torch::Tensor& projmatrix,
const float tan_fovx,
const float tan_fovy,
const int image_height,
const int image_width,
const int degree,
const torch::Tensor& campos,
const bool prefiltered,//raster_settings
const bool debug,
const pybind11::dict &args);
std::tuple<torch::Tensor, torch::Tensor, torch::Tensor, torch::Tensor, torch::Tensor>
PreprocessGaussiansBackwardCUDA(
const torch::Tensor& radii,
const torch::Tensor& cov3D,
const torch::Tensor& clamped,//the above are all per-Gaussian intemediate results.
const torch::Tensor& means3D,
const torch::Tensor& scales,
const torch::Tensor& rotations,
const torch::Tensor& sh,//input of this operator
const float scale_modifier,
const torch::Tensor& viewmatrix,
const torch::Tensor& projmatrix,
const float tan_fovx,
const float tan_fovy,
const int image_height,
const int image_width,
const int degree,
const torch::Tensor& campos,//rasterization setting.
const torch::Tensor& dL_dmeans2D,
const torch::Tensor& dL_dconic_opacity,
const torch::Tensor& dL_dcolors,//gradients of output of this operator
const int R,
const bool debug,
const pybind11::dict &args);
////////////////////// GetDistributionStrategy ////////////////////////
torch::Tensor GetDistributionStrategyCUDA(
const int image_height,
const int image_width,// image setting
torch::Tensor& means2D,// (P, 2)
torch::Tensor& radii,
const bool debug,
const pybind11::dict &args);
////////////////////// Image Distribution Utilities ////////////////////////
torch::Tensor GetTouchedLocally(
const torch::Tensor& compute_locally,
const int image_height,
const int image_width,
const int extension_distance
);
torch::Tensor LoadImageTilesByPos(
const torch::Tensor& local_image_rect,
const torch::Tensor& all_tiles_pos,
int image_height,
int image_width,
int min_pixel_y,
int min_pixel_x,
int local_image_rect_height,
int local_image_rect_width);
torch::Tensor SetImageTilesByPos(
const torch::Tensor& all_tiles_pos,
const torch::Tensor& image_tiles,
int image_height,
int image_width,
int min_pixel_y,
int min_pixel_x,
int local_image_rect_height,
int local_image_rect_width);
torch::Tensor GetPixelsComputeLocallyAndInRect(
const torch::Tensor& compute_locally,
int image_height,
int image_width,
int min_pixel_y,
int max_pixel_y,
int min_pixel_x,
int max_pixel_x);
/////////////////////////////// Render ///////////////////////////////
std::tuple<int, torch::Tensor, torch::Tensor, torch::Tensor, torch::Tensor, torch::Tensor, torch::Tensor, torch::Tensor>
RenderGaussiansCUDA(
const torch::Tensor& background,
const int image_height,
const int image_width,// image setting
torch::Tensor& means2D,
torch::Tensor& depths,
torch::Tensor& radii,
torch::Tensor& conic_opacity,
torch::Tensor& rgb,//3dgs intermediate results
const torch::Tensor& compute_locally,
const bool debug,
const pybind11::dict &args);
std::tuple<torch::Tensor, torch::Tensor, torch::Tensor>
RenderGaussiansBackwardCUDA(
const torch::Tensor& background,
const int R,
const torch::Tensor& geomBuffer,
const torch::Tensor& binningBuffer,
const torch::Tensor& imageBuffer,
const torch::Tensor& compute_locally,
const torch::Tensor& dL_dout_color,
const torch::Tensor& means2D,
const torch::Tensor& conic_opacity,
const torch::Tensor& rgb,
const bool debug,
const pybind11::dict &args);
/////////////////////////////// Utility tools ///////////////////////////////
torch::Tensor GetLocal2jIdsBoolCUDA(
int image_height,
int image_width,
int mp_rank,
int mp_world_size,
const torch::Tensor& means2D,
const torch::Tensor& radii,
const torch::Tensor& dist_global_strategy,
const pybind11::dict &args);
torch::Tensor GetLocal2jIdsBoolAdjustMode6CUDA(
int image_height,
int image_width,
int mp_rank,
int mp_world_size,
const torch::Tensor& means2D,
const torch::Tensor& radii,
const torch::Tensor& rectangles,
const pybind11::dict &args);
std::tuple<int, int, int> GetBlockXY();