Skip to content

Commit e0a3207

Browse files
authored
Fix PADDLE_ASSERT. (#10981)
* Enable assertions in CUDA. * Fix PADDLE_ASSERT.
1 parent 106ee9d commit e0a3207

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

paddle/fluid/platform/assert.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ limitations under the License. */
1717
#define STRINGIFY(x) #x
1818
#define TOSTRING(x) STRINGIFY(x)
1919

20-
#if defined(__APPLE__) && defined(__CUDA_ARCH__) && !defined(NDEBUG)
20+
#if defined(__CUDA_ARCH__)
2121
#include <stdio.h>
2222
#define PADDLE_ASSERT(e) \
2323
do { \
@@ -38,6 +38,9 @@ limitations under the License. */
3838
} while (0)
3939
#else
4040
#include <assert.h>
41-
#define PADDLE_ASSERT(e) assert(e)
41+
// For cuda, the assertions can affect performance and it is therefore
42+
// recommended to disable them in production code
43+
// https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#assertion
44+
#define PADDLE_ASSERT(e) assert((e))
4245
#define PADDLE_ASSERT_MSG(e, m) assert((e) && (m))
4346
#endif

0 commit comments

Comments
 (0)