Home | History | Annotate | Download | only in platform
      1 /* Copyright 2015 The TensorFlow Authors. All Rights Reserved.
      2 
      3 Licensed under the Apache License, Version 2.0 (the "License");
      4 you may not use this file except in compliance with the License.
      5 You may obtain a copy of the License at
      6 
      7     http://www.apache.org/licenses/LICENSE-2.0
      8 
      9 Unless required by applicable law or agreed to in writing, software
     10 distributed under the License is distributed on an "AS IS" BASIS,
     11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     12 See the License for the specific language governing permissions and
     13 limitations under the License.
     14 ==============================================================================*/
     15 
     16 #ifndef TENSORFLOW_PLATFORM_SETROUND_H_
     17 #define TENSORFLOW_PLATFORM_SETROUND_H_
     18 
     19 #include <cfenv>
     20 
     21 #include "tensorflow/core/platform/macros.h"
     22 
     23 namespace tensorflow {
     24 namespace port {
     25 
     26 // While this class is active, floating point rounding mode is set to the given
     27 // mode. The mode can be one of the modes defined in <cfenv>, i.e. FE_DOWNWARD,
     28 // FE_TONEAREST, FE_TOWARDZERO, or FE_UPWARD. The destructor restores the
     29 // original rounding mode if it could be determined. If the original rounding
     30 // mode could not be determined, the destructor sets it to FE_TONEAREST.
     31 class ScopedSetRound {
     32  public:
     33   ScopedSetRound(int mode);
     34   ~ScopedSetRound();
     35 
     36  private:
     37   int original_mode_;
     38 
     39   TF_DISALLOW_COPY_AND_ASSIGN(ScopedSetRound);
     40 };
     41 
     42 }  // namespace port
     43 }  // namespace tensorflow
     44 
     45 #endif  // TENSORFLOW_PLATFORM_SETROUND_H_
     46