aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/platform/setround.h
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2017-02-14 10:16:35 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-02-14 10:31:11 -0800
commit37fea69023ab11dcc41790878deb4e526bac081e (patch)
treebe4421984887216f1659cd2c196847041232b460 /tensorflow/core/platform/setround.h
parent628b7bfbc017b5486810ca7960cc02608d8df502 (diff)
Make port::ScopedSetRound() work as advertised in the header and add unit tests.
Use the C++11 version of std::fe{set,get}round defined in <cfenv>. Change: 147487955
Diffstat (limited to 'tensorflow/core/platform/setround.h')
-rw-r--r--tensorflow/core/platform/setround.h15
1 files changed, 11 insertions, 4 deletions
diff --git a/tensorflow/core/platform/setround.h b/tensorflow/core/platform/setround.h
index 4b1b3fd497..d076e7acc6 100644
--- a/tensorflow/core/platform/setround.h
+++ b/tensorflow/core/platform/setround.h
@@ -16,23 +16,30 @@ limitations under the License.
#ifndef TENSORFLOW_PLATFORM_SETROUND_H_
#define TENSORFLOW_PLATFORM_SETROUND_H_
+#include <cfenv>
+
#include "tensorflow/core/platform/macros.h"
namespace tensorflow {
namespace port {
-// While this class is active, floating point numbers are rounded to NEAREST
-// to zero. The destructor restores the original flags.
+// While this class is active, floating point rounding mode is set to the given
+// mode. The mode can be one of the modes defined in <cfenv>, i.e. FE_DOWNWARD,
+// FE_TONEAREST, FE_TOWARDZERO, or FE_UPWARD. The destructor restores the
+// original rounding mode if it could be determined. If the original rounding
+// mode could not be determined, the destructor sets it to FE_TONEAREST.
class ScopedSetRound {
public:
- ScopedSetRound();
+ ScopedSetRound(int mode);
~ScopedSetRound();
private:
+ int original_mode_;
+
TF_DISALLOW_COPY_AND_ASSIGN(ScopedSetRound);
};
} // namespace port
} // namespace tensorflow
-#endif // TENSORFLOW_PLATFORM_SETROUN_H_
+#endif // TENSORFLOW_PLATFORM_SETROUND_H_