Skip to content

Commit 069c9fd

Browse files
bottlerfacebook-github-bot
authored andcommitted
pytorch TORCH_CHECK_ARG version compatibility
Summary: Restore compatibility with old C++ after recent torch change. #995 Reviewed By: patricklabatut Differential Revision: D33093174 fbshipit-source-id: 841202fb875d601db265e93dcf9cfa4249d02b25
1 parent 9eec430 commit 069c9fd

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

pytorch3d/csrc/pulsar/cuda/commands.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,9 @@ __device__ static float atomicMin(float* address, float val) {
208208
#define IABS(a) abs(a)
209209

210210
// Checks.
211-
#define ARGCHECK TORCH_CHECK_ARG
211+
// like TORCH_CHECK_ARG in PyTorch > 1.10
212+
#define ARGCHECK(cond, argN, ...) \
213+
TORCH_CHECK(cond, "invalid argument ", argN, ": ", __VA_ARGS__)
212214

213215
// Math.
214216
#define NORM3DF(x, y, z) norm3df(x, y, z)

pytorch3d/csrc/pulsar/host/commands.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,9 @@ INLINE void ATOMICADD_F3(T* address, T val) {
155155
#define IABS(a) abs(a)
156156

157157
// Checks.
158-
#define ARGCHECK TORCH_CHECK_ARG
158+
// like TORCH_CHECK_ARG in PyTorch > 1.10
159+
#define ARGCHECK(cond, argN, ...) \
160+
TORCH_CHECK(cond, "invalid argument ", argN, ": ", __VA_ARGS__)
159161

160162
// Math.
161163
#define NORM3DF(x, y, z) sqrtf(x* x + y * y + z * z)

pytorch3d/csrc/pulsar/pytorch/renderer.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@
1717
#include <c10/cuda/CUDAGuard.h>
1818
#endif
1919

20+
#ifndef TORCH_CHECK_ARG
21+
// torch <= 1.10
22+
#define TORCH_CHECK_ARG(cond, argN, ...) \
23+
TORCH_CHECK(cond, "invalid argument ", argN, ": ", __VA_ARGS__)
24+
#endif
25+
2026
namespace PRE = ::pulsar::Renderer;
2127

2228
namespace pulsar {

0 commit comments

Comments
 (0)