17 #include "caffe2/operators/utility_ops.h" 21 template <
class Context>
24 USE_OPERATOR_CONTEXT_FUNCTIONS;
28 template <
typename T,
typename M>
29 bool DoRunWithType() {
34 auto* output = Output(0);
35 T* output_data = output->template mutable_data<T>();
36 for (
int i = 0; i < output->size(); ++i) {
37 output_data[i] = std::max(static_cast<T>(0), output_data[i]);
42 bool RunOnDevice()
override {
43 if (
Input(0).
template IsType<float>()) {
44 return DoRunWithType<float, float>();
45 }
else if (
Input(0).template IsType<int>()) {
46 return DoRunWithType<int, int>();
49 "Sum operator only supports 32-bit float and ints, but",
50 " input was of type ",
51 Input(0).dtype().name());
Workspace is a class that holds all the related objects created during runtime: (1) all blobs...
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 ...