Skip to content

Commit 8a54281

Browse files
committed
Don't use the preprocessor to delimit namespace tcnn
1 parent fa82eca commit 8a54281

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+122
-157
lines changed

dependencies/pcg32/pcg32.h

+3-9
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,7 @@
3434
#define PCG32_DEFAULT_STREAM 0xda3e39cb94b95bdbULL
3535
#define PCG32_MULT 0x5851f42d4c957f2dULL
3636

37-
#include <cmath>
38-
#include <cassert>
39-
40-
41-
TCNN_NAMESPACE_BEGIN
37+
namespace tcnn {
4238

4339
/// PCG32 Pseudorandom number generator
4440
struct pcg32 {
@@ -171,8 +167,6 @@ struct pcg32 {
171167

172168
/// Compute the distance between two PCG32 pseudorandom number generators
173169
TCNN_HOST_DEVICE int64_t operator-(const pcg32 &other) const {
174-
assert(inc == other.inc);
175-
176170
uint64_t
177171
cur_mult = PCG32_MULT,
178172
cur_plus = inc,
@@ -185,7 +179,7 @@ struct pcg32 {
185179
cur_state = cur_state * cur_mult + cur_plus;
186180
distance |= the_bit;
187181
}
188-
assert((state & the_bit) == (cur_state & the_bit));
182+
189183
the_bit <<= 1;
190184
cur_plus = (cur_mult + 1ULL) * cur_plus;
191185
cur_mult *= cur_mult;
@@ -204,4 +198,4 @@ struct pcg32 {
204198
uint64_t inc; // Controls which RNG sequence (stream) is selected. Must *always* be odd.
205199
};
206200

207-
TCNN_NAMESPACE_END
201+
}

include/tiny-cuda-nn/common.h

+2-6
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@
2929

3030
#pragma once
3131

32-
// A macro is used such that external tools won't end up indenting entire files,
33-
// resulting in wasted horizontal space.
34-
#define TCNN_NAMESPACE_BEGIN namespace tcnn {
35-
#define TCNN_NAMESPACE_END }
3632

3733

3834
#include <tiny-cuda-nn/cpp_api.h>
@@ -47,7 +43,7 @@
4743

4844
#include <cuda_fp16.h>
4945

50-
TCNN_NAMESPACE_BEGIN
46+
namespace tcnn {
5147

5248
static constexpr uint32_t MIN_GPU_ARCH = TCNN_MIN_GPU_ARCH;
5349

@@ -615,4 +611,4 @@ struct PitchedPtr {
615611
uint32_t stride_in_bytes;
616612
};
617613

618-
TCNN_NAMESPACE_END
614+
}

include/tiny-cuda-nn/common_device.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
#include <tiny-cuda-nn/gpu_matrix.h>
4545

46-
TCNN_NAMESPACE_BEGIN
46+
namespace tcnn {
4747

4848
static constexpr float PI = 3.14159265358979323846f;
4949
static constexpr float SQRT2 = 1.41421356237309504880f;
@@ -683,4 +683,4 @@ __global__ void mult_kernel(const uint32_t num_elements, const T* factor1, const
683683
result[i] = factor1[i] * factor2[i];
684684
}
685685

686-
TCNN_NAMESPACE_END
686+
}

include/tiny-cuda-nn/config.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
#include <tiny-cuda-nn/optimizer.h>
4040
#include <tiny-cuda-nn/trainer.h>
4141

42-
TCNN_NAMESPACE_BEGIN
42+
namespace tcnn {
4343

4444
struct TrainableModel {
4545
std::shared_ptr<Loss<network_precision_t>> loss;
@@ -60,4 +60,4 @@ inline TrainableModel create_from_config(
6060
return {loss, optimizer, network, trainer};
6161
}
6262

63-
TCNN_NAMESPACE_END
63+
}

include/tiny-cuda-nn/cuda_graph.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#include <deque>
3737
#include <functional>
3838

39-
TCNN_NAMESPACE_BEGIN
39+
namespace tcnn {
4040

4141
class CudaGraph;
4242

@@ -177,4 +177,4 @@ class CudaGraph {
177177
bool m_synchronize_when_capture_done = false;
178178
};
179179

180-
TCNN_NAMESPACE_END
180+
}

include/tiny-cuda-nn/cutlass_matmul.h

+2-4
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,9 @@
4545
#include <cutlass/numeric_conversion.h>
4646
#include <cutlass/numeric_types.h>
4747

48-
#include <iostream>
49-
#include <map>
5048
#include <type_traits>
5149

52-
TCNN_NAMESPACE_BEGIN
50+
namespace tcnn {
5351

5452
#define CUTLASS_CHECK_THROW(x) \
5553
do { \
@@ -516,4 +514,4 @@ void fc_multiply_split_k(cudaStream_t stream, const GPUMatrixDynamic<TypeA>& A,
516514
fc_multiply_split_k<config>(stream, A, B, D, D, split_k_slices, beta);
517515
}
518516

519-
TCNN_NAMESPACE_END
517+
}

include/tiny-cuda-nn/encoding.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
#include <stdint.h>
3636

37-
TCNN_NAMESPACE_BEGIN
37+
namespace tcnn {
3838

3939
enum class InterpolationType {
4040
Nearest,
@@ -98,4 +98,4 @@ Encoding<T>* create_encoding(uint32_t n_dims_to_encode, const json& params, uint
9898
template <typename T>
9999
void register_encoding(const std::string& name, const std::function<Encoding<T>*(uint32_t, const json&)>& factory);
100100

101-
TCNN_NAMESPACE_END
101+
}

include/tiny-cuda-nn/encodings/composite.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
#include <string>
4343
#include <vector>
4444

45-
TCNN_NAMESPACE_BEGIN
45+
namespace tcnn {
4646

4747
template <typename T>
4848
__global__ void reduce_sum_forward(
@@ -459,4 +459,4 @@ class CompositeEncoding : public Encoding<T> {
459459
ReductionType m_reduction_type = ReductionType::Concatenation;
460460
};
461461

462-
TCNN_NAMESPACE_END
462+
}

include/tiny-cuda-nn/encodings/empty.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
#include <string>
4242
#include <vector>
4343

44-
TCNN_NAMESPACE_BEGIN
44+
namespace tcnn {
4545

4646
template <typename T>
4747
__global__ void empty_backward(
@@ -149,4 +149,4 @@ class EmptyEncoding : public Encoding<T> {
149149
uint32_t m_n_to_pad = 0;
150150
};
151151

152-
TCNN_NAMESPACE_END
152+
}

include/tiny-cuda-nn/encodings/frequency.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
#include <string>
4141
#include <vector>
4242

43-
TCNN_NAMESPACE_BEGIN
43+
namespace tcnn {
4444

4545
template <typename T>
4646
__global__ void frequency_encoding(
@@ -227,4 +227,4 @@ class FrequencyEncoding : public Encoding<T> {
227227
uint32_t m_n_to_pad = 0;
228228
};
229229

230-
TCNN_NAMESPACE_END
230+
}

include/tiny-cuda-nn/encodings/grid.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
#include <string>
4343
#include <vector>
4444

45-
TCNN_NAMESPACE_BEGIN
45+
namespace tcnn {
4646

4747
static constexpr uint32_t MAX_N_LEVELS = 128;
4848
struct GridOffsetTable {
@@ -1477,4 +1477,4 @@ GridEncoding<T>* create_grid_encoding(uint32_t n_dims_to_encode, const json& enc
14771477
}
14781478
}
14791479

1480-
TCNN_NAMESPACE_END
1480+
}

include/tiny-cuda-nn/encodings/identity.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
#include <string>
4141
#include <vector>
4242

43-
TCNN_NAMESPACE_BEGIN
43+
namespace tcnn {
4444

4545
template <typename T>
4646
__global__ void identity(
@@ -187,4 +187,4 @@ class IdentityEncoding : public Encoding<T> {
187187
uint32_t m_n_to_pad = 0;
188188
};
189189

190-
TCNN_NAMESPACE_END
190+
}

include/tiny-cuda-nn/encodings/oneblob.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
#include <string>
4242
#include <vector>
4343

44-
TCNN_NAMESPACE_BEGIN
44+
namespace tcnn {
4545

4646
template <typename F>
4747
__device__ inline float one_blob_subwarp_aligned(F kernel, MatrixView<const float> data_in, const uint32_t elem_index, const uint32_t encoded_index, const uint32_t num_bins_log2) {
@@ -306,4 +306,4 @@ class OneBlobEncoding : public Encoding<T> {
306306
uint32_t m_n_to_pad = 0;
307307
};
308308

309-
TCNN_NAMESPACE_END
309+
}

include/tiny-cuda-nn/encodings/spherical_harmonics.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
#include <string>
4141
#include <vector>
4242

43-
TCNN_NAMESPACE_BEGIN
43+
namespace tcnn {
4444

4545
template <typename T, typename ARRAY_T>
4646
__device__ void sh_enc(uint32_t degree, float x, float y, float z, ARRAY_T& data_out) {
@@ -503,4 +503,4 @@ class SphericalHarmonicsEncoding : public Encoding<T> {
503503
uint32_t m_n_to_pad = 0;
504504
};
505505

506-
TCNN_NAMESPACE_END
506+
}

include/tiny-cuda-nn/encodings/triangle_wave.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
#include <string>
4141
#include <vector>
4242

43-
TCNN_NAMESPACE_BEGIN
43+
namespace tcnn {
4444

4545
template <typename T>
4646
__global__ void triangle_wave_encoding(
@@ -220,4 +220,4 @@ class TriangleWaveEncoding : public Encoding<T> {
220220
uint32_t m_n_to_pad = 0;
221221
};
222222

223-
TCNN_NAMESPACE_END
223+
}

include/tiny-cuda-nn/gpu_matrix.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
#include <string>
4141
#include <vector>
4242

43-
TCNN_NAMESPACE_BEGIN
43+
namespace tcnn {
4444

4545
template<typename T>
4646
class GPUMatrixDynamic;
@@ -523,4 +523,4 @@ GPUMemoryArena::Allocation GPUMatrixBase::allocate_shared_memory(cudaStream_t st
523523
return allocate_shared_memory(stream, matrix_pointers);
524524
}
525525

526-
TCNN_NAMESPACE_END
526+
}

include/tiny-cuda-nn/gpu_memory.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
#include <unordered_map>
4747
#include <vector>
4848

49-
TCNN_NAMESPACE_BEGIN
49+
namespace tcnn {
5050

5151
#define DEBUG_GUARD_SIZE 0
5252

@@ -751,4 +751,4 @@ inline void free_all_gpu_memory_arenas() {
751751
global_gpu_memory_arenas().clear();
752752
}
753753

754-
TCNN_NAMESPACE_END
754+
}

include/tiny-cuda-nn/gpu_memory_json.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
#include <json/json.hpp>
3333

34-
TCNN_NAMESPACE_BEGIN
34+
namespace tcnn {
3535

3636
inline nlohmann::json::binary_t gpu_memory_to_json_binary(const void* gpu_data, size_t n_bytes) {
3737
nlohmann::json::binary_t data_cpu;
@@ -70,4 +70,4 @@ inline void from_json(const nlohmann::json& j, GPUMemory<T>& gpu_data) {
7070
}
7171
}
7272

73-
TCNN_NAMESPACE_END
73+
}

include/tiny-cuda-nn/loss.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include <tiny-cuda-nn/gpu_matrix.h>
3434
#include <tiny-cuda-nn/object.h>
3535

36-
TCNN_NAMESPACE_BEGIN
36+
namespace tcnn {
3737

3838
template <typename T>
3939
class Loss : public ObjectWithMutableHyperparams {
@@ -54,4 +54,4 @@ class Loss : public ObjectWithMutableHyperparams {
5454
template <typename T>
5555
Loss<T>* create_loss(const json& params);
5656

57-
TCNN_NAMESPACE_END
57+
}

include/tiny-cuda-nn/losses/cross_entropy.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#include <tiny-cuda-nn/common_device.h>
3535
#include <tiny-cuda-nn/loss.h>
3636

37-
TCNN_NAMESPACE_BEGIN
37+
namespace tcnn {
3838

3939
template <typename T>
4040
__global__ void cross_entropy_loss(
@@ -117,4 +117,4 @@ class CrossEntropyLoss : public Loss<T> {
117117
}
118118
};
119119

120-
TCNN_NAMESPACE_END
120+
}

include/tiny-cuda-nn/losses/l1.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#include <tiny-cuda-nn/common_device.h>
3535
#include <tiny-cuda-nn/loss.h>
3636

37-
TCNN_NAMESPACE_BEGIN
37+
namespace tcnn {
3838

3939
template <typename T>
4040
__global__ void l1_loss(
@@ -114,4 +114,4 @@ class L1Loss : public Loss<T> {
114114
}
115115
};
116116

117-
TCNN_NAMESPACE_END
117+
}

include/tiny-cuda-nn/losses/l2.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#include <tiny-cuda-nn/common_device.h>
3535
#include <tiny-cuda-nn/loss.h>
3636

37-
TCNN_NAMESPACE_BEGIN
37+
namespace tcnn {
3838

3939
template <typename T>
4040
__global__ void l2_loss(
@@ -114,4 +114,4 @@ class L2Loss : public Loss<T> {
114114
}
115115
};
116116

117-
TCNN_NAMESPACE_END
117+
}

include/tiny-cuda-nn/losses/mape.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#include <tiny-cuda-nn/common_device.h>
3535
#include <tiny-cuda-nn/loss.h>
3636

37-
TCNN_NAMESPACE_BEGIN
37+
namespace tcnn {
3838

3939
template <typename T>
4040
__global__ void mape_loss(
@@ -117,4 +117,4 @@ class MapeLoss : public Loss<T> {
117117
}
118118
};
119119

120-
TCNN_NAMESPACE_END
120+
}

include/tiny-cuda-nn/losses/relative_l1.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#include <tiny-cuda-nn/common_device.h>
3535
#include <tiny-cuda-nn/loss.h>
3636

37-
TCNN_NAMESPACE_BEGIN
37+
namespace tcnn {
3838

3939
template <typename T>
4040
__global__ void relative_l1_loss(
@@ -116,4 +116,4 @@ class RelativeL1Loss : public Loss<T> {
116116
}
117117
};
118118

119-
TCNN_NAMESPACE_END
119+
}

0 commit comments

Comments
 (0)