TVM  0.9.4
memoryChecks.h
Go to the documentation of this file.
1 
3 #pragma once
4 
5 #include <tvm/api.h>
6 
7 #include <Eigen/Core>
8 
9 namespace tvm::utils
10 {
11 
12 #ifdef NDEBUG
13 inline bool is_malloc_allowed() { return true; }
14 inline bool set_is_malloc_allowed(bool b) { return b; }
15 inline void override_is_malloc_allowed(bool) {}
16 inline void restore_is_malloc_allowed() {}
17 #else
18 namespace internal
19 {
24 
26 {
27 # ifdef EIGEN_RUNTIME_NO_MALLOC
29  && "Eigen::internal::is_malloc_allowed() at the caller site and tvm::utils::is_malloc_allowed are differing. "
30  "This might be due to the fact that Eigen::internal::set_is_alloc_allowed was called independently/instead "
31  "of tvm::utils::set_is_malloc_allowed in the current program/library.");
32 # endif
33 }
34 
40 {
41 # ifdef EIGEN_RUNTIME_NO_MALLOC
43 # endif
44 }
45 } // namespace internal
46 
48 inline bool is_malloc_allowed()
49 {
52 }
53 
55 inline bool set_is_malloc_allowed(bool allow)
56 {
60  return allow;
61 }
62 
69 inline void override_is_malloc_allowed(bool allow)
70 {
74 }
75 
78 {
82 }
83 #endif
84 
85 #define TVM_TEMPORARY_ALLOW_EIGEN_MALLOC(x) \
86  tvm::utils::override_is_malloc_allowed(true); \
87  x; \
88  tvm::utils::restore_is_malloc_allowed();
89 
90 } // namespace tvm::utils
#define TVM_DLLAPI
Definition: api.h:35
TVM_DLLAPI void override_is_malloc_allowed_(bool v)
TVM_DLLAPI void restore_is_malloc_allowed_()
void check_malloc_coherency()
Definition: memoryChecks.h:25
TVM_DLLAPI bool is_malloc_allowed_()
void enforce_malloc_coherency()
Definition: memoryChecks.h:39
TVM_DLLAPI bool set_is_malloc_allowed_(bool allow)
Definition: enums.h:13
void restore_is_malloc_allowed()
Definition: memoryChecks.h:77
bool set_is_malloc_allowed(bool allow)
Definition: memoryChecks.h:55
void override_is_malloc_allowed(bool allow)
Definition: memoryChecks.h:69
bool is_malloc_allowed()
Definition: memoryChecks.h:48