utils.h 1.13 KB
Newer Older
rusty1s's avatar
rusty1s committed
1
2
3
4
5
6
#pragma once

#include <torch/extension.h>

#define CHECK_CPU(x) AT_ASSERTM(x.device().is_cpu(), #x " must be CPU tensor")
#define CHECK_INPUT(x) AT_ASSERTM(x, "Input mismatch")
rusty1s's avatar
matmul  
rusty1s committed
7
8
9
10
11
12
13
14
15
16
17
18
19
20

#define AT_DISPATCH_HAS_VALUE(optional_value, ...)                             \
  [&] {                                                                        \
    switch (optional_value.has_value()) {                                      \
    case true: {                                                               \
      const bool HAS_VALUE = true;                                             \
      return __VA_ARGS__();                                                    \
    }                                                                          \
    case false: {                                                              \
      const bool HAS_VALUE = false;                                            \
      return __VA_ARGS__();                                                    \
    }                                                                          \
    }                                                                          \
  }()