1 #include "caffe2/operators/minmax_ops.h" 5 REGISTER_CPU_OPERATOR(Max, MaxOp<float, CPUContext>);
6 REGISTER_CPU_OPERATOR(Min, MinOp<float, CPUContext>);
11 .IdenticalTypeAndShapeOfInput(0)
12 .AllowInplace({{0, 0}})
14 Element-wise max of each of the input tensors. The first input tensor can be 15 used in-place as the output tensor, in which case the max will be done in 16 place and results will be accumulated in input0. All inputs and outputs must 17 have the same shape and data type. 19 .Input(0, "data_0",
"First of the input tensors. Can be inplace.")
20 .Output(0,
"max",
"Output tensor. Same dimension as inputs.")
21 .InheritOnnxSchema(
"Max");
24 .NumInputs(1, INT_MAX)
26 .IdenticalTypeAndShapeOfInput(0)
27 .AllowInplace({{0, 0}})
29 Element-wise min of each of the input tensors. The first input tensor can be 30 used in-place as the output tensor, in which case the min will be done in 31 place and results will be accumulated in input0. All inputs and outputs must 32 have the same shape and data type. 34 .Input(0, "data_0",
"First of the input tensors. Can be inplace.")
35 .Output(0,
"min",
"Output tensor. Same dimension as inputs.")
36 .InheritOnnxSchema(
"Min");
38 template <
typename T,
class Context>
39 bool MaxOp<T, Context>::Compute() {
40 auto& input0 = Input(0);
41 const int N = input0.size();
42 T* output_data = Output(0)->template mutable_data<T>();
44 for (
int i = 1; i < InputSize(); i++) {
45 auto input_data = Input(i).template data<T>();
46 EigenVectorMap<T> output_vec(output_data, N);
47 output_vec = output_vec.cwiseMax(ConstEigenVectorMap<T>(input_data, N));
53 template <
typename T,
class Context>
54 bool MinOp<T, Context>::Compute() {
55 auto& input0 = Input(0);
56 const int N = input0.size();
57 T* output_data = Output(0)->template mutable_data<T>();
59 for (
int i = 1; i < InputSize(); i++) {
60 auto input_data = Input(i).template data<T>();
61 EigenVectorMap<T> output_vec(output_data, N);
62 output_vec = output_vec.cwiseMin(ConstEigenVectorMap<T>(input_data, N));
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...