1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
|
#include "caffe2/operators/stats_put_ops.h"
#include "caffe2/core/operator.h"
#include "caffe2/core/stats.h"
#include "caffe2/core/tensor.h"
namespace caffe2 {
#define REGISTER_TEMPLATED_STAT_PUT_OP(OP_NAME, STAT_NAME, STAT_MACRO) \
struct STAT_NAME { \
CAFFE_STAT_CTOR(STAT_NAME); \
STAT_MACRO(stat_value); \
}; \
REGISTER_CPU_OPERATOR(OP_NAME, TemplatePutOp<STAT_NAME>);
// NOLINTNEXTLINE(modernize-pass-by-value,cppcoreguidelines-avoid-non-const-global-variables)
REGISTER_TEMPLATED_STAT_PUT_OP(
AveragePut,
AveragePutStat,
CAFFE_AVG_EXPORTED_STAT)
OPERATOR_SCHEMA(AveragePut)
.NumInputs(1)
.NumOutputs(0)
.Arg(
"name",
"(*str*): name of the stat. If not present, then uses name of input blob")
.Arg(
"magnitude_expand",
"(*int64_t*): number to multiply input values by (used when inputting floats, as stats can only receive integers")
.Arg(
"bound",
"(*boolean*): whether or not to clamp inputs to the max inputs allowed")
.Arg(
"default_value",
"(*float*): Optionally provide a default value for receiving empty tensors")
.SetDoc(R"DOC(
Consume a value and pushes it to the global stat registry as an average.
Github Links:
- https://github.com/pytorch/pytorch/blob/master/caffe2/operators/stats_put_ops.cc
)DOC")
.Input(
0,
"value",
"(*Tensor`<number>`*): A scalar tensor, representing any numeric value");
// NOLINTNEXTLINE(modernize-pass-by-value,cppcoreguidelines-avoid-non-const-global-variables)
REGISTER_TEMPLATED_STAT_PUT_OP(
IncrementPut,
IncrementPutStat,
CAFFE_EXPORTED_STAT)
OPERATOR_SCHEMA(IncrementPut)
.NumInputs(1)
.NumOutputs(0)
.Arg(
"name",
"(*str*): name of the stat. If not present, then uses name of input blob")
.Arg(
"magnitude_expand",
"(*int64_t*): number to multiply input values by (used when inputting floats, as stats can only receive integers")
.Arg(
"bound",
"(*boolean*): whether or not to clamp inputs to the max inputs allowed")
.Arg(
"default_value",
"(*float*): Optionally provide a default value for receiving empty tensors")
.SetDoc(R"DOC(
Consume a value and pushes it to the global stat registry as an sum.
Github Links:
- https://github.com/pytorch/pytorch/blob/master/caffe2/operators/stats_put_ops.cc
)DOC")
.Input(
0,
"value",
"(*Tensor`<number>`*): A scalar tensor, representing any numeric value");
// NOLINTNEXTLINE(modernize-pass-by-value,cppcoreguidelines-avoid-non-const-global-variables)
REGISTER_TEMPLATED_STAT_PUT_OP(
StdDevPut,
StdDevPutStat,
CAFFE_STDDEV_EXPORTED_STAT)
OPERATOR_SCHEMA(StdDevPut)
.NumInputs(1)
.NumOutputs(0)
.Arg(
"name",
"(*str*): name of the stat. If not present, then uses name of input blob")
.Arg(
"magnitude_expand",
"(*int64_t*): number to multiply input values by (used when inputting floats, as stats can only receive integers")
.Arg(
"bound",
"(*boolean*): whether or not to clamp inputs to the max inputs allowed")
.Arg(
"default_value",
"(*float*): Optionally provide a default value for receiving empty tensors")
.SetDoc(R"DOC(
Consume a value and pushes it to the global stat registry as an standard deviation.
Github Links:
- https://github.com/pytorch/pytorch/blob/master/caffe2/operators/stats_put_ops.cc
)DOC")
.Input(
0,
"value",
"(*Tensor`<number>`*): A scalar tensor, representing any numeric value");
} // namespace caffe2
|