From 623e6671213cd5286f3f053c2dec355282a679fb Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" Date: Fri, 15 Mar 2019 15:48:17 -0700 Subject: [PATCH] Go: Update generated wrapper functions for TensorFlow ops. PiperOrigin-RevId: 238725068 --- tensorflow/go/op/wrappers.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tensorflow/go/op/wrappers.go b/tensorflow/go/op/wrappers.go index 7a3c03bd60e..51fa2039c81 100644 --- a/tensorflow/go/op/wrappers.go +++ b/tensorflow/go/op/wrappers.go @@ -126,6 +126,15 @@ func FakeQuantWithMinMaxVarsPerChannelNarrowRange(value bool) FakeQuantWithMinMa // then de-quantized and output as floats in `[min; max]` interval. // `num_bits` is the bitwidth of the quantization; between 2 and 16, inclusive. // +// Before quantization, `min` and `max` values are adjusted with the following +// logic. +// It is suggested to have `min <= 0 <= max`. If `0` is not in the range of values, +// the behavior can be unexpected: +// If `0 < min < max`: `min_adj = 0` and `max_adj = max - min`. +// If `min < max < 0`: `min_adj = min - max` and `max_adj = 0`. +// If `min <= 0 <= max`: `scale = (max - min) / (2^num_bits - 1) `, +// `min_adj = scale * round(min / scale)` and `max_adj = max + min_adj - min`. +// // This operation has a gradient and thus allows for training `min` and `max` // values. func FakeQuantWithMinMaxVarsPerChannel(scope *Scope, inputs tf.Output, min tf.Output, max tf.Output, optional ...FakeQuantWithMinMaxVarsPerChannelAttr) (outputs tf.Output) { @@ -307,6 +316,15 @@ func FakeQuantWithMinMaxArgsNarrowRange(value bool) FakeQuantWithMinMaxArgsAttr // then de-quantized and output as floats in `[min; max]` interval. // `num_bits` is the bitwidth of the quantization; between 2 and 16, inclusive. // +// Before quantization, `min` and `max` values are adjusted with the following +// logic. +// It is suggested to have `min <= 0 <= max`. If `0` is not in the range of values, +// the behavior can be unexpected: +// If `0 < min < max`: `min_adj = 0` and `max_adj = max - min`. +// If `min < max < 0`: `min_adj = min - max` and `max_adj = 0`. +// If `min <= 0 <= max`: `scale = (max - min) / (2^num_bits - 1) `, +// `min_adj = scale * round(min / scale)` and `max_adj = max + min_adj - min`. +// // Quantization is called fake since the output is still in floating point. func FakeQuantWithMinMaxArgs(scope *Scope, inputs tf.Output, optional ...FakeQuantWithMinMaxArgsAttr) (outputs tf.Output) { if scope.Err() != nil { @@ -20642,6 +20660,15 @@ func FakeQuantWithMinMaxVarsNarrowRange(value bool) FakeQuantWithMinMaxVarsAttr // then de-quantized and output as floats in `[min; max]` interval. // `num_bits` is the bitwidth of the quantization; between 2 and 16, inclusive. // +// Before quantization, `min` and `max` values are adjusted with the following +// logic. +// It is suggested to have `min <= 0 <= max`. If `0` is not in the range of values, +// the behavior can be unexpected: +// If `0 < min < max`: `min_adj = 0` and `max_adj = max - min`. +// If `min < max < 0`: `min_adj = min - max` and `max_adj = 0`. +// If `min <= 0 <= max`: `scale = (max - min) / (2^num_bits - 1) `, +// `min_adj = scale * round(min / scale)` and `max_adj = max + min_adj - min`. +// // This operation has a gradient and thus allows for training `min` and `max` // values. func FakeQuantWithMinMaxVars(scope *Scope, inputs tf.Output, min tf.Output, max tf.Output, optional ...FakeQuantWithMinMaxVarsAttr) (outputs tf.Output) {