1 #ifndef CAFFE_OPERATORS_ENFORCE_FINITE_OP_H_ 2 #define CAFFE_OPERATORS_ENFORCE_FINITE_OP_H_ 4 #include "caffe2/core/context.h" 5 #include "caffe2/core/logging.h" 6 #include "caffe2/core/operator.h" 7 #include "caffe2/utils/math.h" 11 template <
class Context>
14 USE_OPERATOR_CONTEXT_FUNCTIONS;
15 template <
class... Args>
19 bool RunOnDevice()
override {
30 void EnforceOnCPU(
const Tensor& input) {
31 const T* input_data = input.template data<T>();
32 auto size = input.numel();
34 for (
auto i = 0; i < size; i++) {
36 std::isfinite(input_data[i]),
39 " is not finite (e.g., NaN, Inf): ",
47 #endif // CAFFE_OPERATORS_ENFORCE_FINITE_OP_H_
const Tensor & Input(int idx, DeviceType type=Context::GetDeviceType())
Retrieve a non-owning reference to the input at position 'idx' for this operator. ...
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...