UniformQuantizedConvolutionHybrid

public final class UniformQuantizedConvolutionHybrid

Perform hybrid quantized convolution of float Tensor `lhs` and quantized Tensor `rhs`.

Given float `lhs` and quantized `rhs`, internally performs quantization on `lhs`, and then performs quantized convolution on quantized `lhs` and `rhs`.

The internal quantization on `lhs` is a quantization to `Trhs`, dynamic range, per-batch (per-axis along axis `dimension_numbers.input_batch_dimension`), asymmetric, and not narrow range (the range is [Trhs_MIN, Trhs_MAX]).

`lhs` and `rhs` must be Tensors of same rank, and meet following shape conditions. - lhs_feature % feature_group_count == 0 - lhs_feature % rhs_input_feature == 0 - lhs_feature / feature_group_count == rhs_input_feature - rhs_output_feature % feature_group_count == 0 - lhs_batch % batch_group_count == 0 - rhs_output_feature % batch_group_count == 0

`rhs` must be quantized Tensor, where its data value is quantized using the formula: quantized_data = clip(original_data / scale + zero_point, quantization_min_val, quantization_max_val).

Nested Classes

class UniformQuantizedConvolutionHybrid.Options Optional attributes for UniformQuantizedConvolutionHybrid  

Public Methods

Output<V>
asOutput()
Returns the symbolic handle of a tensor.
static UniformQuantizedConvolutionHybrid.Options
batchGroupCount(Long batchGroupCount)
static <V extends Number, T extends Number, U> UniformQuantizedConvolutionHybrid<V>
create(Scope scope, Operand<T> lhs, Operand<U> rhs, Operand<Float> rhsScales, Operand<Integer> rhsZeroPoints, Class<V> Tout, String padding, Long rhsQuantizationMinVal, Long rhsQuantizationMaxVal, Options... options)
Factory method to create a class wrapping a new UniformQuantizedConvolutionHybrid operation.
static UniformQuantizedConvolutionHybrid.Options
dimensionNumbers(String dimensionNumbers)
static UniformQuantizedConvolutionHybrid.Options
explicitPadding(List<Long> explicitPadding)
static UniformQuantizedConvolutionHybrid.Options
featureGroupCount(Long featureGroupCount)
static UniformQuantizedConvolutionHybrid.Options
lhsDilation(List<Long> lhsDilation)
Output<V>
output()
The output Tensor of `Tout`, same rank as `lhs` and `rhs`.
static UniformQuantizedConvolutionHybrid.Options
rhsDilation(List<Long> rhsDilation)
static UniformQuantizedConvolutionHybrid.Options
rhsQuantizationAxis(Long rhsQuantizationAxis)
static UniformQuantizedConvolutionHybrid.Options
windowStrides(List<Long> windowStrides)

Inherited Methods

Public Methods

public Output<V> asOutput ()

Returns the symbolic handle of a tensor.

Inputs to TensorFlow operations are outputs of another TensorFlow operation. This method is used to obtain a symbolic handle that represents the computation of the input.

public static UniformQuantizedConvolutionHybrid.Options batchGroupCount (Long batchGroupCount)

Parameters
batchGroupCount The number of batch groups. Used for grouped filters. Must be a divisor of output_feature.

public static UniformQuantizedConvolutionHybrid<V> create (Scope scope, Operand<T> lhs, Operand<U> rhs, Operand<Float> rhsScales, Operand<Integer> rhsZeroPoints, Class<V> Tout, String padding, Long rhsQuantizationMinVal, Long rhsQuantizationMaxVal, Options... options)

Factory method to create a class wrapping a new UniformQuantizedConvolutionHybrid operation.

Parameters
scope current scope
lhs Must be a non-quantized Tensor of `Tlhs`, rank >= 3.
rhs Must be a quantized Tensor of `Trhs`, same rank as `lhs`.
rhsScales The float value(s) used as scale factors when quantizing the original data that `rhs` represents. Must be a scalar Tensor for per-tensor quantization, or 1D Tensor of size `rhs.dim_size(kernel_output_feature_dimension)`, for per-channel quantization.
rhsZeroPoints The int32 value(s) used as zero_point when quantizing original data that `rhs` represents. Same shape condition as `rhs_scales`.
Tout The type of output Tensor.
padding string from: `"SAME"`, `"VALID"`, or `"EXPLICIT"`, indicating the type of padding algorithm to use.
rhsQuantizationMinVal The min value of the quantized data stored in `rhs`. For example, if `Trhs` is qint8, this must be set to -127 if narrow range quantized or -128 if not.
rhsQuantizationMaxVal The max value of the quantized data stored in `rhs`. For example, if `Trhs` is qint8, this must be set to 127.
options carries optional attributes values
Returns
  • a new instance of UniformQuantizedConvolutionHybrid

public static UniformQuantizedConvolutionHybrid.Options dimensionNumbers (String dimensionNumbers)

Parameters
dimensionNumbers Structure of dimension information for the convolution op. Must be an empty string (default) or a serialized string of tensorflow.UniformQuantizedConvolutionDimensionNumbersAttr proto. If empty string, the default is `("NCHW", "OIHW", "NCHW")` (for a 2D convolution).

public static UniformQuantizedConvolutionHybrid.Options explicitPadding (List<Long> explicitPadding)

Parameters
explicitPadding If `padding` Attr is `"EXPLICIT"`, must be set as a list indicating the explicit paddings at the start and end of each lhs spatial dimension. Otherwise, this Attr is must be empty.

(If used,) Must be a list of size 2 * (number of lhs spatial dimensions), where (explicit_padding[2 * i], explicit_padding[2 * i + 1]) indicates spatial_dimensions[i] (start_padding, end_padding).

public static UniformQuantizedConvolutionHybrid.Options featureGroupCount (Long featureGroupCount)

Parameters
featureGroupCount The number of feature groups. Used for grouped convolutions. Must be a divisor of both lhs_feature and output_feature.

public static UniformQuantizedConvolutionHybrid.Options lhsDilation (List<Long> lhsDilation)

Parameters
lhsDilation The dilation factor to apply in each spatial dimension of `lhs`. Must be an empty list (default) or a list of size (number of lhs spatial dimensions). If empty list, the dilation for each lhs spatial dimension is set to 1.

public Output<V> output ()

The output Tensor of `Tout`, same rank as `lhs` and `rhs`. The output data is the non-quantized output data.

public static UniformQuantizedConvolutionHybrid.Options rhsDilation (List<Long> rhsDilation)

Parameters
rhsDilation The dilation factor to apply in each spatial dimension of `rhs`. Must be an empty list (default) or a list of size (number of rhs spatial dimensions). If empty list, the dilation for each rhs spatial dimension is set to 1.

public static UniformQuantizedConvolutionHybrid.Options rhsQuantizationAxis (Long rhsQuantizationAxis)

Parameters
rhsQuantizationAxis Indicates the dimension index of the tensor where per-axis quantization is applied for the slices along that dimension. If set to -1 (default), this indicates per-tensor quantization. For the `rhs`, only per-tensor quantization or per-channel quantization along kernel_output_feature_dimension is supported. Thus, this attribute must be set to -1 or `dimension_numbers.kernel_output_feature_dimension`. Other values will raise error at OpKernel construction.

public static UniformQuantizedConvolutionHybrid.Options windowStrides (List<Long> windowStrides)

Parameters
windowStrides The stride of the sliding window for each spatial dimension of `lhs`. Must be an empty list (default) or a list of size (number of spatial dimensions). If an empty list is provided, the stride for each spatial dimension is set to 1.