diff --git a/tensorflow/compiler/mlir/tensorflow/ir/tf_generated_ops.td b/tensorflow/compiler/mlir/tensorflow/ir/tf_generated_ops.td index bd9f968f433..5b6e9562e48 100644 --- a/tensorflow/compiler/mlir/tensorflow/ir/tf_generated_ops.td +++ b/tensorflow/compiler/mlir/tensorflow/ir/tf_generated_ops.td @@ -1736,6 +1736,146 @@ tf.cumsum([a, b, c], exclusive=True, reverse=True) # => [b + c, c, 0] TF_DerivedOperandTypeAttr Tidx = TF_DerivedOperandTypeAttr<1>; } +def TF_DecodeAndCropJpegOp : TF_Op<"DecodeAndCropJpeg", [NoSideEffect]> { + let summary = "Decode and Crop a JPEG-encoded image to a uint8 tensor."; + + let description = [{ +The attr `channels` indicates the desired number of color channels for the +decoded image. + +Accepted values are: + +* 0: Use the number of channels in the JPEG-encoded image. +* 1: output a grayscale image. +* 3: output an RGB image. + +If needed, the JPEG-encoded image is transformed to match the requested number +of color channels. + +The attr `ratio` allows downscaling the image by an integer factor during +decoding. Allowed values are: 1, 2, 4, and 8. This is much faster than +downscaling the image later. + + +It is equivalent to a combination of decode and crop, but much faster by only +decoding partial jpeg image. + }]; + + let arguments = (ins + TF_StrTensor:$contents, + I32Tensor:$crop_window, + + DefaultValuedAttr:$channels, + DefaultValuedAttr:$ratio, + DefaultValuedAttr:$fancy_upscaling, + DefaultValuedAttr:$try_recover_truncated, + DefaultValuedAttr:$acceptable_fraction, + StrAttr:$dct_method + ); + + let results = (outs + TF_Uint8Tensor:$image + ); +} + +def TF_DecodeGifOp : TF_Op<"DecodeGif", [NoSideEffect]> { + let summary = "Decode the frame(s) of a GIF-encoded image to a uint8 tensor."; + + let description = [{ +GIF images with frame or transparency compression are not supported. +On Linux and MacOS systems, convert animated GIFs from compressed to +uncompressed by running: + + convert $src.gif -coalesce $dst.gif + +This op also supports decoding JPEGs and PNGs, though it is cleaner to use +`tf.io.decode_image`. + }]; + + let arguments = (ins + TF_StrTensor:$contents + ); + + let results = (outs + TF_Uint8Tensor:$image + ); +} + +def TF_DecodeJpegOp : TF_Op<"DecodeJpeg", [NoSideEffect]> { + let summary = "Decode a JPEG-encoded image to a uint8 tensor."; + + let description = [{ +The attr `channels` indicates the desired number of color channels for the +decoded image. + +Accepted values are: + +* 0: Use the number of channels in the JPEG-encoded image. +* 1: output a grayscale image. +* 3: output an RGB image. + +If needed, the JPEG-encoded image is transformed to match the requested number +of color channels. + +The attr `ratio` allows downscaling the image by an integer factor during +decoding. Allowed values are: 1, 2, 4, and 8. This is much faster than +downscaling the image later. + + +This op also supports decoding PNGs and non-animated GIFs since the interface is +the same, though it is cleaner to use `tf.io.decode_image`. + }]; + + let arguments = (ins + TF_StrTensor:$contents, + + DefaultValuedAttr:$channels, + DefaultValuedAttr:$ratio, + DefaultValuedAttr:$fancy_upscaling, + DefaultValuedAttr:$try_recover_truncated, + DefaultValuedAttr:$acceptable_fraction, + StrAttr:$dct_method + ); + + let results = (outs + TF_Uint8Tensor:$image + ); +} + +def TF_DecodePngOp : TF_Op<"DecodePng", [NoSideEffect]> { + let summary = "Decode a PNG-encoded image to a uint8 or uint16 tensor."; + + let description = [{ +The attr `channels` indicates the desired number of color channels for the +decoded image. + +Accepted values are: + +* 0: Use the number of channels in the PNG-encoded image. +* 1: output a grayscale image. +* 3: output an RGB image. +* 4: output an RGBA image. + +If needed, the PNG-encoded image is transformed to match the requested number +of color channels. + +This op also supports decoding JPEGs and non-animated GIFs since the interface +is the same, though it is cleaner to use `tf.io.decode_image`. + }]; + + let arguments = (ins + TF_StrTensor:$contents, + + DefaultValuedAttr:$channels + ); + + let results = (outs + TensorOf<[TF_Uint16, TF_Uint8]>:$image + ); + + TF_DerivedResultTypeAttr dtype = TF_DerivedResultTypeAttr<0>; +} + def TF_DepthToSpaceOp : TF_Op<"DepthToSpace", [NoSideEffect]> { let summary = "DepthToSpace for tensors of type T."; diff --git a/tensorflow/compiler/mlir/tensorflow/ir/tf_op_base.td b/tensorflow/compiler/mlir/tensorflow/ir/tf_op_base.td index 80a2b1925e6..cb17341cefd 100644 --- a/tensorflow/compiler/mlir/tensorflow/ir/tf_op_base.td +++ b/tensorflow/compiler/mlir/tensorflow/ir/tf_op_base.td @@ -129,9 +129,16 @@ def TF_I32Or64 : SignlessIntOfWidths<[32, 64]>; def TF_I32OrI64Tensor : TensorOf<[TF_I32Or64]>; def TF_Uint8 : UI<8>; +def TF_Uint8Tensor : TensorOf<[TF_Uint8]>; + def TF_Uint16 : UI<16>; +def TF_Uint16Tensor : TensorOf<[TF_Uint16]>; + def TF_Uint32 : UI<32>; +def TF_Uint32Tensor : TensorOf<[TF_Uint32]>; + def TF_Uint64 : UI<64>; +def TF_Uint64Tensor : TensorOf<[TF_Uint64]>; // Any unsigned integer type def TF_UInt : UnsignedIntOfWidths<[8, 16, 32, 64]>;