mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 12:21:27 +01:00
Part of implementing CacheEntry invalidation to fix https://github.com/pytorch/pytorch/issues/112090. Changes: - Move CacheEntry and ExtraState to C++ - Use pybind to control reference counting - Use std::list instead of manually implementing a linked list Pull Request resolved: https://github.com/pytorch/pytorch/pull/118438 Approved by: https://github.com/jansel
47 lines
1.4 KiB
C
47 lines
1.4 KiB
C
#pragma once
|
|
|
|
#include <stdio.h>
|
|
|
|
#ifdef _WIN32
|
|
#define unlikely(x) (x)
|
|
#else
|
|
#define unlikely(x) __builtin_expect((x), 0)
|
|
#endif
|
|
|
|
#define NULL_CHECK(val) \
|
|
if (unlikely((val) == NULL)) { \
|
|
fprintf(stderr, "NULL ERROR: %s:%d\n", __FILE__, __LINE__); \
|
|
PyErr_Print(); \
|
|
abort(); \
|
|
} else { \
|
|
}
|
|
|
|
// CHECK might be previously declared
|
|
#undef CHECK
|
|
#define CHECK(cond) \
|
|
if (unlikely(!(cond))) { \
|
|
fprintf(stderr, "DEBUG CHECK FAILED: %s:%d\n", __FILE__, __LINE__); \
|
|
abort(); \
|
|
} else { \
|
|
}
|
|
|
|
// Uncomment next line to print debug message
|
|
// #define TORCHDYNAMO_DEBUG 1
|
|
#ifdef TORCHDYNAMO_DEBUG
|
|
|
|
#define DEBUG_CHECK(cond) CHECK(cond)
|
|
#define DEBUG_NULL_CHECK(val) NULL_CHECK(val)
|
|
#define DEBUG_TRACE(msg, ...) \
|
|
fprintf(stderr, "TRACE[%s:%d] " msg "\n", __func__, __LINE__, __VA_ARGS__)
|
|
#define DEBUG_TRACE0(msg) \
|
|
fprintf(stderr, "TRACE[%s:%d] " msg "\n", __func__, __LINE__)
|
|
|
|
#else
|
|
|
|
#define DEBUG_CHECK(cond)
|
|
#define DEBUG_NULL_CHECK(val)
|
|
#define DEBUG_TRACE(msg, ...)
|
|
#define DEBUG_TRACE0(msg)
|
|
|
|
#endif
|