Add tf.DecodeAndCropJpeg, tf.DecodeGif, tf.DecodeJpeg and tf.DecodePng to TensorFlow MLIR ODS.

These ops are autogenerated from TensorFlow op registry.

PiperOrigin-RevId: 309778952
Change-Id: I89298c5cd21e1811d9b437a81483eb805ff95c6f
This commit is contained in:
Andy Ly 2020-05-04 11:02:19 -07:00 committed by TensorFlower Gardener
parent 3036a47f17
commit 4158c029ef
2 changed files with 147 additions and 0 deletions

View File

@ -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<I64Attr, "0">:$channels,
DefaultValuedAttr<I64Attr, "1">:$ratio,
DefaultValuedAttr<BoolAttr, "true">:$fancy_upscaling,
DefaultValuedAttr<BoolAttr, "false">:$try_recover_truncated,
DefaultValuedAttr<F32Attr, "1.0f">:$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<I64Attr, "0">:$channels,
DefaultValuedAttr<I64Attr, "1">:$ratio,
DefaultValuedAttr<BoolAttr, "true">:$fancy_upscaling,
DefaultValuedAttr<BoolAttr, "false">:$try_recover_truncated,
DefaultValuedAttr<F32Attr, "1.0f">:$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<I64Attr, "0">:$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.";

View File

@ -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]>;