Shrink

Shrink - 9

Version

  • name: Shrink (GitHub)

  • domain: main

  • since_version: 9

  • function: True

  • support_level: SupportType.COMMON

  • shape inference: True

This version of the operator has been available since version 9.

Summary

Shrink takes one input data (Tensor) and produces one Tensor output, having same datatype and shape with input. It has two attributes, lambd and bias. The formula of this operator is: If x < -lambd, y = x + bias; If x > lambd, y = x - bias; Otherwise, y = 0.

Function Body

The function definition for this operator.

<
  domain: "",
  opset_import: ["" : 18]
>
Shrink <bias,lambd>(input) => (output)
{
   Lambd = Constant <value_float: float = @lambd> ()
   LambdCast = CastLike (Lambd, input)
   Bias = Constant <value_float: float = @bias> ()
   BiasCast = CastLike (Bias, input)
   Zero = Constant <value: tensor = float {0}> ()
   ZeroCast = CastLike (Zero, input)
   NegLmbda = Neg (LambdCast)
   InputLessThanNegLambda = Less (input, NegLmbda)
   InputAddBias = Add (input, BiasCast)
   InputSubBias = Sub (input, BiasCast)
   LambdaLessThanInput = Less (LambdCast, input)
   InputSubBiasOrZero = Where (LambdaLessThanInput, InputSubBias, ZeroCast)
   output = Where (InputLessThanNegLambda, InputAddBias, InputSubBiasOrZero)
}

Attributes

  • bias - FLOAT (default is '0.0'):

    The bias value added to output. Default is 0.

  • lambd - FLOAT (default is '0.5'):

    The lambd value for the Shrink formulation. Default is 0.5.

Inputs

  • input (heterogeneous) - T:

    The input data as Tensor.

Outputs

  • output (heterogeneous) - T:

    The output.

Type Constraints

  • T in ( tensor(double), tensor(float), tensor(float16), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8) ):

    Constrain input to only numeric types.