• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2018 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_COMPILER_XLA_ERROR_SPEC_H_
17 #define TENSORFLOW_COMPILER_XLA_ERROR_SPEC_H_
18 
19 namespace xla {
20 
21 // Structure describing permissible absolute and relative error bounds.
22 struct ErrorSpec {
23   explicit ErrorSpec(float aabs, float arel = 0, bool relaxed_nans = false)
absErrorSpec24       : abs(aabs), rel(arel), relaxed_nans(relaxed_nans) {}
25 
26   float abs;  // Absolute error bound.
27   float rel;  // Relative error bound.
28 
29   // If relaxed_nans is true then any result is valid if we are expecting NaNs.
30   // In effect, this allows the tested operation to produce incorrect results
31   // for inputs outside its mathematical domain.
32   bool relaxed_nans;
33 
34   // If this is true, then we treat each +/-inf in the actual result as
35   // equivalent to our choice of either +/-inf or the min/max floating-point
36   // value.
37   //
38   // If the expected result is +/-inf, the actual result must still be +/-inf.
39   //
40   // In effect, this allows the tested operation to overflow, so long as it's
41   // overflowing on "large" values.
42   //
43   // (We could have a symmetric more_infs_ok flag if necessary; right now it
44   // appears not to be.)
45   bool fewer_infs_ok = false;
46 };
47 
48 }  // namespace xla
49 
50 #endif  // TENSORFLOW_COMPILER_XLA_ERROR_SPEC_H_
51