diff options
author | 2018-07-02 06:44:41 -0700 | |
---|---|---|
committer | 2018-07-02 06:47:18 -0700 | |
commit | e0ebc3dc4f64d84c6acd5f2ff3574e7f2b3a8fbf (patch) | |
tree | e156cbf4e0f5f57f94ef37cd1c333c41546a41b5 /tensorflow/compiler/tf2xla/kernels/quantize_and_dequantize_op.cc | |
parent | b641e4ef932bd46035565556f94eba74115f33e1 (diff) |
[XLA] Add a new client helper library for building constants.
New functions include xla::ScalarLike, xla::Zero, xla::Zeros, xla::ZerosLike, xla::One, xla::Epsilon, xla::{Min,Max,MinFinite,MaxFinite}Value.
Update Erf, Erfc, ErfInv to use new operator overloads and xla::ScalarLike. Remove the explicit type arguments.
[TF:XLA] Refactor various parts of the bridge to use new constant functions. Make more types implicit. Clean up ArgMin/ArgMax as part of adapting it to use the new APIs.
No functional changes intended.
PiperOrigin-RevId: 202943293
Diffstat (limited to 'tensorflow/compiler/tf2xla/kernels/quantize_and_dequantize_op.cc')
-rw-r--r-- | tensorflow/compiler/tf2xla/kernels/quantize_and_dequantize_op.cc | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/tensorflow/compiler/tf2xla/kernels/quantize_and_dequantize_op.cc b/tensorflow/compiler/tf2xla/kernels/quantize_and_dequantize_op.cc index 02293796e4..e88221e4f4 100644 --- a/tensorflow/compiler/tf2xla/kernels/quantize_and_dequantize_op.cc +++ b/tensorflow/compiler/tf2xla/kernels/quantize_and_dequantize_op.cc @@ -18,6 +18,7 @@ limitations under the License. #include "tensorflow/compiler/tf2xla/xla_op_kernel.h" #include "tensorflow/compiler/tf2xla/xla_op_registry.h" #include "tensorflow/compiler/xla/client/lib/arithmetic.h" +#include "tensorflow/compiler/xla/client/lib/constants.h" #include "tensorflow/compiler/xla/client/xla_client/xla_builder.h" #include "tensorflow/core/platform/macros.h" @@ -50,8 +51,8 @@ class QuantizeAndDequantizeOp : public XlaOpKernel { } else { const xla::XlaComputation* fmax = ctx->GetOrCreateMax(data_type); const xla::XlaComputation* fmin = ctx->GetOrCreateMin(data_type); - min_range = ReduceAll(input, XlaHelpers::MaxValue(b, data_type), *fmin); - max_range = ReduceAll(input, XlaHelpers::MinValue(b, data_type), *fmax); + min_range = ReduceAll(input, xla::MaxValue(b, xla_type), *fmin); + max_range = ReduceAll(input, xla::MinValue(b, xla_type), *fmax); } xla::XlaOp num_bits; @@ -93,10 +94,10 @@ class QuantizeAndDequantizeOp : public XlaOpKernel { // while keeping 0 unchanged. xla::XlaOp scale_from_min_side = Select(Gt(min_quantized * min_range, zero), min_quantized / min_range, - XlaHelpers::MaxFiniteValue(b, data_type)); + xla::MaxFiniteValue(b, xla_type)); xla::XlaOp scale_from_max_side = Select(Gt(max_quantized * max_range, zero), max_quantized / max_range, - XlaHelpers::MaxFiniteValue(b, data_type)); + xla::MaxFiniteValue(b, xla_type)); // Note: Avoids changing the side of the range that determines scale. xla::XlaOp cond = Lt(scale_from_min_side, scale_from_max_side); |