fix clip_op bug
Summary: ajtulloch caught me. This fixes the min() bug - should be lowest().
Reviewed By: xianjiec, dzhulgakov
Differential Revision: D5316406
fbshipit-source-id: 76c13e8eddc4233b40f99a801910fbf7a1ef6b28
diff --git a/caffe2/operators/clip_op.cc b/caffe2/operators/clip_op.cc
index 97d1c12..1077d37 100644
--- a/caffe2/operators/clip_op.cc
+++ b/caffe2/operators/clip_op.cc
@@ -38,22 +38,29 @@
REGISTER_CPU_OPERATOR(ClipGradient, ClipGradientOp<float, CPUContext>);
OPERATOR_SCHEMA(Clip)
- .NumInputs(1)
- .NumOutputs(1)
- .AllowInplace({{0, 0}})
- .IdenticalTypeAndShape()
- .SetDoc(R"DOC(
+ .NumInputs(1)
+ .NumOutputs(1)
+ .AllowInplace({{0, 0}})
+ .IdenticalTypeAndShape()
+ .SetDoc(R"DOC(
Clip operator limits the given input within an interval. The interval is
-specified with arguments 'min' and 'max'. They default to numeric_limits::min()
-and numeric_limits::max() respectively. The clipping operation can be done in
-in-place fashion too, where the input and output blobs are the same.
+specified with arguments 'min' and 'max'. They default to
+numeric_limits::lowest() and numeric_limits::max() respectively. The clipping
+operation can be done in in-place fashion too, where the input and output blobs
+are the same.
)DOC")
- .Arg("min", "Minimum value, under which element is replaced by min")
- .Arg("max", "Maximum value, above which element is replaced by max")
- .Input(0, "input", "Input tensor (Tensor<float>) containing elements to be"
- "clipped")
- .Input(1, "output", "Output tensor (Tensor<float>) containing clipped"
- "input elements");
+ .Arg("min", "Minimum value, under which element is replaced by min")
+ .Arg("max", "Maximum value, above which element is replaced by max")
+ .Input(
+ 0,
+ "input",
+ "Input tensor (Tensor<float>) containing elements to be"
+ "clipped")
+ .Input(
+ 1,
+ "output",
+ "Output tensor (Tensor<float>) containing clipped"
+ "input elements");
OPERATOR_SCHEMA(ClipGradient).NumInputs(2).NumOutputs(1).AllowInplace({{1, 0}});
diff --git a/caffe2/operators/clip_op.h b/caffe2/operators/clip_op.h
index 8ee36aa..d2d899e 100644
--- a/caffe2/operators/clip_op.h
+++ b/caffe2/operators/clip_op.h
@@ -16,7 +16,7 @@
USE_OPERATOR_CONTEXT_FUNCTIONS;
ClipOp(const OperatorDef& operator_def, Workspace* ws)
: Operator<Context>(operator_def, ws),
- min_(std::numeric_limits<T>::min()),
+ min_(std::numeric_limits<T>::lowest()),
max_(std::numeric_limits<T>::max()) {
if (HasArgument("min")) {
min_ = static_cast<T>(OperatorBase::GetSingleArgument<float>("min", 0));
@@ -39,7 +39,7 @@
USE_OPERATOR_CONTEXT_FUNCTIONS;
ClipGradientOp(const OperatorDef& operator_def, Workspace* ws)
: Operator<Context>(operator_def, ws),
- min_(std::numeric_limits<T>::min()),
+ min_(std::numeric_limits<T>::lowest()),
max_(std::numeric_limits<T>::max()) {
if (HasArgument("min")) {
min_ = static_cast<T>(OperatorBase::GetSingleArgument<float>("min", 0));