Caffe2 - C++ API
A deep learning, cross platform ML framework
is_empty_op.h
1 #ifndef IS_EMPTY_OP_H_
2 #define IS_EMPTY_OP_H_
3 
4 #include "caffe2/core/context.h"
5 #include "caffe2/core/operator.h"
6 
7 namespace caffe2 {
8 
9 template <class Context>
10 class IsEmptyOp : public Operator<Context> {
11  public:
12  USE_OPERATOR_CONTEXT_FUNCTIONS;
13  USE_SIMPLE_CTOR_DTOR(IsEmptyOp);
14 
15  bool RunOnDevice() override {
16  auto& input = Input(0);
17 
18  auto* output = Output(0, std::vector<int64_t>{}, at::dtype<bool>());
19  *output->template mutable_data<bool>() = (input.numel() == 0);
20  return true;
21  }
22 };
23 
24 } // namespace caffe2
25 
26 #endif // IS_EMPTY_OP_H_
const Tensor & Input(int idx, DeviceType type=Context::GetDeviceType())
Retrieve a non-owning reference to the input at position &#39;idx&#39; for this operator. ...
Definition: operator.h:702
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...
Definition: blob.h:13