From c8ccccf045596fd6735e6fd3e5a5c60813635cf1 Mon Sep 17 00:00:00 2001 From: nihuini Date: Fri, 5 Mar 2021 16:21:25 +0800 Subject: [PATCH] adapt mlir changes --- docs/how-to-build/build-mlir2ncnn.md | 12 +- tools/mlir/tf_attributes.cc | 2 +- tools/mlir/tf_dialect.cpp | 43 +- tools/mlir/tf_dialect.h | 4 +- tools/mlir/tf_generated_ops.td | 3976 +++++++++++++++++--------- tools/mlir/tf_op_base.td | 25 +- tools/mlir/tf_ops.td | 46 +- tools/mlir/tf_types.cc | 6 +- tools/mlir/tf_types.h | 22 +- 9 files changed, 2714 insertions(+), 1422 deletions(-) diff --git a/docs/how-to-build/build-mlir2ncnn.md b/docs/how-to-build/build-mlir2ncnn.md index 1cfdeea41..f975824c7 100644 --- a/docs/how-to-build/build-mlir2ncnn.md +++ b/docs/how-to-build/build-mlir2ncnn.md @@ -7,17 +7,15 @@ https://github.com/llvm/llvm-project.git git checkout -b mlir ``` -Current working commit id is 7c15e0f64ccc79a53ed2db258f1cb58ec452a957: +Current working commit id is 74e6030bcbcc8e628f9a99a424342a0c656456f9: ``` $ git log -commit 7c15e0f64ccc79a53ed2db258f1cb58ec452a957 (HEAD -> 01-26) -Author: MaheshRavishankar -Date: Tue Jan 26 23:21:33 2021 -0800 +commit 74e6030bcbcc8e628f9a99a424342a0c656456f9 (HEAD -> main, origin/main, origin/HEAD) +Author: Craig Topper +Date: Thu Mar 4 22:30:38 2021 -0800 - [mlir][Linalg] Add canonicalization for init_tensor -> subtensor op. - - Differential Revision: https://reviews.llvm.org/D95305 + [TargetLowering] Use HandleSDNodes to prevent nodes from being deleted by recursive calls in getNegatedExpression. ``` It is determined by query lastest git commit date of `tools/mlir` directory. diff --git a/tools/mlir/tf_attributes.cc b/tools/mlir/tf_attributes.cc index 3173cfabe..0397a62f4 100644 --- a/tools/mlir/tf_attributes.cc +++ b/tools/mlir/tf_attributes.cc @@ -139,7 +139,7 @@ bool ShapeAttr::hasStaticShape() const FuncAttr FuncAttr::get(mlir::MLIRContext* context, llvm::StringRef name, DictionaryAttr attr) { - auto symbol = SymbolRefAttr::get(name, context); + auto symbol = SymbolRefAttr::get(context, name); return Base::get(context, symbol, attr); } diff --git a/tools/mlir/tf_dialect.cpp b/tools/mlir/tf_dialect.cpp index 7ed7d8d0f..ce48fb2b9 100644 --- a/tools/mlir/tf_dialect.cpp +++ b/tools/mlir/tf_dialect.cpp @@ -178,8 +178,6 @@ Type TensorFlowDialect::parseType(DialectAsmParser& parser) const StringRef data; if (parser.parseKeyword(&data)) return Type(); - Location loc = parser.getEncodedSourceLoc(parser.getNameLoc()); - #define HANDLE_TF_TYPE(tftype, enumerant, name) \ if (data == name) return tftype##Type::get(getContext()); // Custom TensorFlow types are handled separately at the end as they do partial @@ -188,15 +186,25 @@ Type TensorFlowDialect::parseType(DialectAsmParser& parser) const // NOLINTNEXTLINE #include "tf_types.def" - if (data.startswith("resource")) return ParseResourceType(parser, loc); - if (data.startswith("variant")) return ParseVariantType(parser, loc); - return (emitError(loc, "unknown TensorFlow type: " + data), nullptr); + llvm::SMLoc loc = parser.getNameLoc(); + if (data.startswith("resource")) + { + Type ret = ParseResourceType(parser); + if (!ret) parser.emitError(loc, "invalid resource type"); + return ret; + } + if (data.startswith("variant")) + { + Type ret = ParseVariantType(parser); + if (!ret) parser.emitError(loc, "invalid variant type"); + return ret; + } + return (parser.emitError(loc, "unknown TensorFlow type: " + data), nullptr); } namespace { template -Type ParseTypeWithSubtype(MLIRContext* context, DialectAsmParser& parser, - Location loc) +Type ParseTypeWithSubtype(MLIRContext* context, DialectAsmParser& parser) { // Default type without inferred subtypes. if (failed(parser.parseOptionalLess())) return TypeWithSubtype::get(context); @@ -207,24 +215,31 @@ Type ParseTypeWithSubtype(MLIRContext* context, DialectAsmParser& parser, { TensorType tensor_ty; if (parser.parseType(tensor_ty)) return Type(); + + // Each of the subtypes should be a valid TensorFlow type. + // TODO(jpienaar): Remove duplication. + if (!IsValidTFTensorType(tensor_ty)) + { + parser.emitError(parser.getNameLoc()) << "invalid subtype: " << tensor_ty; + return Type(); + } subtypes.push_back(tensor_ty); } while (succeeded(parser.parseOptionalComma())); if (parser.parseGreater()) return Type(); - return TypeWithSubtype::getChecked(subtypes, context, loc); + + return TypeWithSubtype::get(subtypes, context); } } // anonymous namespace -Type TensorFlowDialect::ParseResourceType(DialectAsmParser& parser, - Location loc) const +Type TensorFlowDialect::ParseResourceType(DialectAsmParser& parser) const { - return ParseTypeWithSubtype(getContext(), parser, loc); + return ParseTypeWithSubtype(getContext(), parser); } -Type TensorFlowDialect::ParseVariantType(DialectAsmParser& parser, - Location loc) const +Type TensorFlowDialect::ParseVariantType(DialectAsmParser& parser) const { - return ParseTypeWithSubtype(getContext(), parser, loc); + return ParseTypeWithSubtype(getContext(), parser); } Operation* TensorFlowDialect::materializeConstant(OpBuilder& builder, diff --git a/tools/mlir/tf_dialect.h b/tools/mlir/tf_dialect.h index 9367b25f1..19a8c9360 100644 --- a/tools/mlir/tf_dialect.h +++ b/tools/mlir/tf_dialect.h @@ -47,11 +47,11 @@ public: Type parseType(DialectAsmParser& parser) const override; // Parses resource type with potential subtypes. - Type ParseResourceType(DialectAsmParser& parser, Location loc) const; + Type ParseResourceType(DialectAsmParser& parser) const; // Parse and print variant type. It may have subtypes inferred using shape // inference. - Type ParseVariantType(DialectAsmParser& parser, Location loc) const; + Type ParseVariantType(DialectAsmParser& parser) const; // Registered hook to materialize a constant operation from a given attribute // value with the desired resultant type. diff --git a/tools/mlir/tf_generated_ops.td b/tools/mlir/tf_generated_ops.td index d8d890cc2..b12b788c0 100644 --- a/tools/mlir/tf_generated_ops.td +++ b/tools/mlir/tf_generated_ops.td @@ -13,18 +13,20 @@ See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ -// This is the operation definition file for TensorFlow. +// This is the auto-generated operation definition file for TensorFlow. +// +// PLEASE DO NOT MANUALLY EDIT THIS FILE! +// +// If you absolutely need to modify the generated fields of an op, move the op +// definition to `tf_ops.td` and perform the modification there. // // This file contains TensorFlow ops whose definitions are programmatically // generated from the api-def-files in the following folder: // tensorflow/core/api_def/base_api // The generated fields for an op include name, summary, description, traits, // arguments, results, derived attributes. Therefore, modifications to these -// fields will **not** be respected upon subsequent refreshes. However, -// additional fields after those fields will be retained. -// -// If you absolutely need to modify the generated fields of an op, move the -// definition to `tf_ops.td` and perform the modification there. +// fields will NOT be respected upon subsequent refreshes. However, additional +// fields after those fields will be retained. // // Ops in this file are sorted alphabetically. @@ -50,7 +52,7 @@ an output element, this operation computes \\(y = |x|\\). TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; } -def TF_AcosOp : TF_Op<"Acos", [NoSideEffect, SameOperandsAndResultType]> { +def TF_AcosOp : TF_Op<"Acos", [NoSideEffect, TF_SameOperandsAndResultTypeResolveRef]> { let summary = "Computes acos of x element-wise."; let description = [{ @@ -70,7 +72,7 @@ Provided an input tensor, the `tf.math.acos` operation returns the inverse cosin TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; } -def TF_AcoshOp : TF_Op<"Acosh", [NoSideEffect, SameOperandsAndResultType]> { +def TF_AcoshOp : TF_Op<"Acosh", [NoSideEffect, TF_SameOperandsAndResultTypeResolveRef]> { let summary = "Computes inverse hyperbolic cosine of x element-wise."; let description = [{ @@ -116,7 +118,6 @@ Inputs must be of same size and shape. TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; TF_DerivedOperandSizeAttr N = TF_DerivedOperandSizeAttr<0>; - } def TF_AdjustContrastv2Op : TF_Op<"AdjustContrastv2", [NoSideEffect]> { @@ -135,12 +136,12 @@ channel and then adjusts each component of each pixel to }]; let arguments = (ins - TensorOf<[TF_Float16, TF_Float32]>:$images, - TF_Float32Tensor:$contrast_factor + Arg, [{Images to adjust. At least 3-D.}]>:$images, + Arg:$contrast_factor ); let results = (outs - TensorOf<[TF_Float16, TF_Float32]>:$output + Res, [{The contrast-adjusted image or images.}]>:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -159,12 +160,12 @@ and then remapped back to RGB colorspace. }]; let arguments = (ins - TensorOf<[TF_Float16, TF_Float32]>:$images, - TF_Float32Tensor:$delta + Arg, [{Images to adjust. At least 3-D.}]>:$images, + Arg:$delta ); let results = (outs - TensorOf<[TF_Float16, TF_Float32]>:$output + Res, [{The hue-adjusted image or images.}]>:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -183,12 +184,12 @@ values, and then remapped back to RGB colorspace. }]; let arguments = (ins - TensorOf<[TF_Float16, TF_Float32]>:$images, - TF_Float32Tensor:$scale + Arg, [{Images to adjust. At least 3-D.}]>:$images, + Arg:$scale ); let results = (outs - TensorOf<[TF_Float16, TF_Float32]>:$output + Res, [{The hue-adjusted image or images.}]>:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -207,14 +208,15 @@ retained with length 1. }]; let arguments = (ins - TF_BoolTensor:$input, - TF_I32OrI64Tensor:$reduction_indices, + Arg:$input, + Arg:$reduction_indices, DefaultValuedAttr:$keep_dims ); let results = (outs - TF_BoolTensor:$output + Res:$output ); TF_DerivedOperandTypeAttr Tidx = TF_DerivedOperandTypeAttr<1>; @@ -245,8 +247,10 @@ replica 1's output: `[[B], [D]]` }]; let arguments = (ins - TensorOf<[TF_Bfloat16, TF_Bool, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$input, - TF_Int32Tensor:$group_assignment, + Arg, [{The local input to the sum.}]>:$input, + Arg:$group_assignment, I64Attr:$concat_dimension, I64Attr:$split_dimension, @@ -254,7 +258,7 @@ replica 1's output: `[[B], [D]]` ); let results = (outs - TensorOf<[TF_Bfloat16, TF_Bool, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$output + Res, [{The exchanged result.}]>:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -304,7 +308,10 @@ def TF_AnonymousIteratorOp : TF_Op<"AnonymousIterator", []> { ); let results = (outs - Res:$handle + Res:$handle ); } @@ -317,8 +324,11 @@ def TF_AnonymousIteratorV2Op : TF_Op<"AnonymousIteratorV2", []> { ); let results = (outs - Res:$handle, - TF_VariantTensor:$deleter + Res:$handle, + Res:$deleter ); } @@ -343,8 +353,11 @@ def TF_AnonymousMultiDeviceIteratorOp : TF_Op<"AnonymousMultiDeviceIterator", [] ); let results = (outs - Res:$handle, - TF_VariantTensor:$deleter + Res:$handle, + Res:$deleter ); } @@ -390,14 +403,15 @@ retained with length 1. }]; let arguments = (ins - TF_BoolTensor:$input, - TF_I32OrI64Tensor:$reduction_indices, + Arg:$input, + Arg:$reduction_indices, DefaultValuedAttr:$keep_dims ); let results = (outs - TF_BoolTensor:$output + Res:$output ); TF_DerivedOperandTypeAttr Tidx = TF_DerivedOperandTypeAttr<1>; @@ -443,7 +457,9 @@ Usage: let arguments = (ins TensorOf<[TF_Bfloat16, TF_Bool, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$input, - TF_I32OrI64Tensor:$dimension + Arg:$dimension ); let results = (outs @@ -476,7 +492,9 @@ Usage: let arguments = (ins TensorOf<[TF_Bfloat16, TF_Bool, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$input, - TF_I32OrI64Tensor:$dimension + Arg:$dimension ); let results = (outs @@ -523,7 +541,7 @@ array([b'3.14', b'2.72'], dtype=object) TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; } -def TF_AsinOp : TF_Op<"Asin", [NoSideEffect, SameOperandsAndResultType]> { +def TF_AsinOp : TF_Op<"Asin", [NoSideEffect, TF_SameOperandsAndResultTypeResolveRef]> { let summary = "Computes the trignometric inverse sine of x element-wise."; let description = [{ @@ -555,7 +573,7 @@ tf.math.asin(y) # [1.047, 0.785] = x TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; } -def TF_AsinhOp : TF_Op<"Asinh", [NoSideEffect, SameOperandsAndResultType]> { +def TF_AsinhOp : TF_Op<"Asinh", [NoSideEffect, TF_SameOperandsAndResultTypeResolveRef]> { let summary = "Computes inverse hyperbolic sine of x element-wise."; let description = [{ @@ -589,8 +607,8 @@ If `condition` evaluates to false, print the list of tensors in `data`. }]; let arguments = (ins - TF_BoolTensor:$condition, - Variadic:$data, + Arg:$condition, + Arg, [{The tensors to print out when condition is false.}]>:$data, DefaultValuedAttr:$summarize ); @@ -598,7 +616,6 @@ If `condition` evaluates to false, print the list of tensors in `data`. let results = (outs); TF_DerivedOperandTypeListAttr T = TF_DerivedOperandTypeListAttr<1>; - } def TF_AssignAddVariableOp : TF_Op<"AssignAddVariableOp", []> { @@ -610,8 +627,8 @@ see the incremented value or a subsequent newer one. }]; let arguments = (ins - Arg:$resource, - TF_Tensor:$value + Arg:$resource, + Arg:$value ); let results = (outs); @@ -628,8 +645,8 @@ see the decremented value or a subsequent newer one. }]; let arguments = (ins - Arg:$resource, - TF_Tensor:$value + Arg:$resource, + Arg:$value ); let results = (outs); @@ -646,8 +663,8 @@ this value or a subsequent newer value of the variable. }]; let arguments = (ins - Arg:$resource, - TF_Tensor:$value + Arg:$resource, + Arg:$value ); let results = (outs); @@ -713,7 +730,7 @@ where \(r = \sqrt(x^2 + y^2) \). TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; } -def TF_AtanhOp : TF_Op<"Atanh", [NoSideEffect, SameOperandsAndResultType]> { +def TF_AtanhOp : TF_Op<"Atanh", [NoSideEffect, TF_SameOperandsAndResultTypeResolveRef]> { let summary = "Computes inverse hyperbolic tangent of x element-wise."; let description = [{ @@ -749,7 +766,7 @@ window in `value`. }]; let arguments = (ins - TF_FloatTensor:$value, + Arg:$value, Confined]>:$ksize, Confined]>:$strides, @@ -758,7 +775,7 @@ window in `value`. ); let results = (outs - TF_FloatTensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -773,7 +790,7 @@ Each entry in `output` is the mean of the corresponding size `ksize` window in }]; let arguments = (ins - TF_FloatTensor:$input, + Arg:$input, Confined]>:$ksize, Confined]>:$strides, @@ -782,7 +799,7 @@ Each entry in `output` is the mean of the corresponding size `ksize` window in ); let results = (outs - TF_FloatTensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -792,8 +809,8 @@ def TF_AvgPool3DGradOp : TF_Op<"AvgPool3DGrad", [NoSideEffect]> { let summary = "Computes gradients of average pooling function."; let arguments = (ins - TF_Int32Tensor:$orig_input_shape, - TF_FloatTensor:$grad, + Arg:$orig_input_shape, + Arg:$grad, Confined]>:$ksize, Confined]>:$strides, @@ -802,7 +819,7 @@ def TF_AvgPool3DGradOp : TF_Op<"AvgPool3DGrad", [NoSideEffect]> { ); let results = (outs - TF_FloatTensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<1>; @@ -812,8 +829,9 @@ def TF_AvgPoolGradOp : TF_Op<"AvgPoolGrad", [NoSideEffect]> { let summary = "Computes gradients of the average pooling function."; let arguments = (ins - TF_Int32Tensor:$orig_input_shape, - TF_FloatTensor:$grad, + Arg:$orig_input_shape, + Arg:$grad, Confined]>:$ksize, Confined]>:$strides, @@ -822,7 +840,7 @@ def TF_AvgPoolGradOp : TF_Op<"AvgPoolGrad", [NoSideEffect]> { ); let results = (outs - TF_FloatTensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<1>; @@ -853,20 +871,19 @@ It is computed as: }]; let arguments = (ins - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int32, TF_Int64]>:$x, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int32, TF_Int64]>:$y, + Arg, [{2-D or higher with shape `[..., r_x, c_x]`.}]>:$x, + Arg, [{2-D or higher with shape `[..., r_y, c_y]`.}]>:$y, DefaultValuedAttr:$adj_x, DefaultValuedAttr:$adj_y ); let results = (outs - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int32, TF_Int64]>:$output + Res, [{3-D or higher with shape `[..., r_o, c_o]`}]>:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; - let verifier = [{ return Verify(*this); }]; @@ -901,15 +918,15 @@ about broadcasting }]; let arguments = (ins - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64]>:$x, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64]>:$y, + Arg, [{2-D or higher with shape `[..., r_x, c_x]`.}]>:$x, + Arg, [{2-D or higher with shape `[..., r_y, c_y]`.}]>:$y, DefaultValuedAttr:$adj_x, DefaultValuedAttr:$adj_y ); let results = (outs - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64]>:$output + Res, [{3-D or higher with shape `[..., r_o, c_o]`}]>:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -917,7 +934,6 @@ about broadcasting let verifier = [{ return Verify(*this); }]; - } def TF_BatchNormWithGlobalNormalizationOp : TF_Op<"BatchNormWithGlobalNormalization", [NoSideEffect]> { @@ -928,11 +944,18 @@ This op is deprecated. Prefer `tf.nn.batch_normalization`. }]; let arguments = (ins - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$t, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$m, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$v, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$beta, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$gamma, + Arg, [{A 4D input Tensor.}]>:$t, + Arg, [{A 1D mean Tensor with size matching the last dimension of t. +This is the first output from tf.nn.moments, +or a saved moving average thereof.}]>:$m, + Arg, [{A 1D variance Tensor with size matching the last dimension of t. +This is the second output from tf.nn.moments, +or a saved moving average thereof.}]>:$v, + Arg, [{A 1D beta Tensor with size matching the last dimension of t. +An offset to be added to the normalized tensor.}]>:$beta, + Arg, [{A 1D gamma Tensor with size matching the last dimension of t. +If "scale_after_normalization" is true, this tensor will be multiplied +with the normalized tensor.}]>:$gamma, F32Attr:$variance_epsilon, BoolAttr:$scale_after_normalization @@ -959,14 +982,87 @@ followed by cropping along the `height` and `width` dimensions. }]; let arguments = (ins - TF_Tensor:$input, - TF_I32OrI64Tensor:$crops, + Arg:$input, + Arg:$crops, Confined]>:$block_size ); let results = (outs - TF_Tensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -975,7 +1071,6 @@ followed by cropping along the `height` and `width` dimensions. let verifier = [{ return Verify(*this); }]; - } def TF_BatchToSpaceNDOp : TF_Op<"BatchToSpaceND", [NoSideEffect]> { @@ -991,9 +1086,118 @@ reverse of SpaceToBatch. See below for a precise description. }]; let arguments = (ins - TF_Tensor:$input, - TF_I32OrI64Tensor:$block_shape, - TF_I32OrI64Tensor:$crops + Arg:$input, + Arg= 1.}]>:$block_shape, + Arg= 0. + `crops[i] = [crop_start, crop_end]` specifies the amount to crop from input + dimension `i + 1`, which corresponds to spatial dimension `i`. It is + required that + `crop_start[i] + crop_end[i] <= block_shape[i] * input_shape[i + 1]`. + +This operation is equivalent to the following steps: + +1. Reshape `input` to `reshaped` of shape: + [block_shape[0], ..., block_shape[M-1], + batch / prod(block_shape), + input_shape[1], ..., input_shape[N-1]] + +2. Permute dimensions of `reshaped` to produce `permuted` of shape + [batch / prod(block_shape), + + input_shape[1], block_shape[0], + ..., + input_shape[M], block_shape[M-1], + + input_shape[M+1], ..., input_shape[N-1]] + +3. Reshape `permuted` to produce `reshaped_permuted` of shape + [batch / prod(block_shape), + + input_shape[1] * block_shape[0], + ..., + input_shape[M] * block_shape[M-1], + + input_shape[M+1], + ..., + input_shape[N-1]] + +4. Crop the start and end of dimensions `[1, ..., M]` of + `reshaped_permuted` according to `crops` to produce the output of shape: + [batch / prod(block_shape), + + input_shape[1] * block_shape[0] - crops[0,0] - crops[0,1], + ..., + input_shape[M] * block_shape[M-1] - crops[M-1,0] - crops[M-1,1], + + input_shape[M+1], ..., input_shape[N-1]] + +Some examples: + +(1) For the following input of shape `[4, 1, 1, 1]`, `block_shape = [2, 2]`, and + `crops = [[0, 0], [0, 0]]`: + +``` +[[[[1]]], [[[2]]], [[[3]]], [[[4]]]] +``` + +The output tensor has shape `[1, 2, 2, 1]` and value: + +``` +x = [[[[1], [2]], [[3], [4]]]] +``` + +(2) For the following input of shape `[4, 1, 1, 3]`, `block_shape = [2, 2]`, and + `crops = [[0, 0], [0, 0]]`: + +``` +[[[[1, 2, 3]]], [[[4, 5, 6]]], [[[7, 8, 9]]], [[[10, 11, 12]]]] +``` + +The output tensor has shape `[1, 2, 2, 3]` and value: + +``` +x = [[[[1, 2, 3], [4, 5, 6]], + [[7, 8, 9], [10, 11, 12]]]] +``` + +(3) For the following input of shape `[4, 2, 2, 1]`, `block_shape = [2, 2]`, and + `crops = [[0, 0], [0, 0]]`: + +``` +x = [[[[1], [3]], [[9], [11]]], + [[[2], [4]], [[10], [12]]], + [[[5], [7]], [[13], [15]]], + [[[6], [8]], [[14], [16]]]] +``` + +The output tensor has shape `[1, 4, 4, 1]` and value: + +``` +x = [[[[1], [2], [3], [4]], + [[5], [6], [7], [8]], + [[9], [10], [11], [12]], + [[13], [14], [15], [16]]]] +``` + +(4) For the following input of shape `[8, 1, 3, 1]`, `block_shape = [2, 2]`, and + `crops = [[0, 0], [2, 0]]`: + +``` +x = [[[[0], [1], [3]]], [[[0], [9], [11]]], + [[[0], [2], [4]]], [[[0], [10], [12]]], + [[[0], [5], [7]]], [[[0], [13], [15]]], + [[[0], [6], [8]]], [[[0], [14], [16]]]] +``` + +The output tensor has shape `[2, 2, 4, 1]` and value: + +``` +x = [[[[1], [2], [3], [4]], + [[5], [6], [7], [8]]], + [[[9], [10], [11], [12]], + [[13], [14], [15], [16]]]] +```}]>:$crops ); let results = (outs @@ -1052,25 +1256,18 @@ Broadcasting is supported, so `value` may have any number of dimensions. }]; let arguments = (ins - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$value, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$bias, + Arg, [{Any number of dimensions.}]>:$value, + Arg, [{1-D with size the last dimension of `value`.}]>:$bias, DefaultValuedAttr:$data_format ); let results = (outs - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$output + Res, [{Broadcasted sum of `value` and `bias`.}]>:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; - let extraClassDeclaration = [{ - // TF_ContractionFusableInterface: - // TF_LayoutSensitiveInterface: - SmallVector GetLayoutDependentArgs() { return {0}; } - SmallVector GetLayoutDependentResults() { return {0}; } - }]; - let verifier = [{ return Verify(*this); }]; @@ -1088,13 +1285,13 @@ the feature dimension is the third-to-last. }]; let arguments = (ins - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$out_backprop, + Arg, [{Any number of dimensions.}]>:$out_backprop, DefaultValuedAttr:$data_format ); let results = (outs - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$output + Res, [{1-D with size the feature dimension of `out_backprop`.}]>:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -1115,16 +1312,46 @@ Broadcasting is supported, so `value` may have any number of dimensions. }]; let arguments = (ins - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$value, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$bias + Arg, [{Any number of dimensions.}]>:$value, + Arg, [{1-D with size the last dimension of `value`.}]>:$bias ); let results = (outs - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$output + Res, [{Broadcasted sum of `value` and `bias`.}]>:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; +} + +def TF_BincountOp : TF_Op<"Bincount", [NoSideEffect]> { + let summary = [{ +Counts the number of occurrences of each value in an integer array. + }]; + + let description = [{ +Outputs a vector with length `size` and the same dtype as `weights`. If +`weights` are empty, then index `i` stores the number of times the value `i` is +counted in `arr`. If `weights` are non-empty, then index `i` stores the sum of +the value in `weights` at each index where the corresponding value in `arr` is +`i`. + +Values in `arr` outside of the range [0, size) are ignored. + }]; + + let arguments = (ins + Arg:$arr, + Arg:$size, + Arg, [{is an int32, int64, float32, or float64 `Tensor` with the same +shape as `arr`, or a length-0 `Tensor`, in which case it acts as all weights +equal to 1.}]>:$weights + ); + let results = (outs + Res, [{1D `Tensor` with length equal to `size`. The counts or summed weights for +each value in the range [0, size).}]>:$bins + ); + + TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<2>; } def TF_BitcastOp : TF_Op<"Bitcast", [NoSideEffect]> { @@ -1195,7 +1422,6 @@ endian orderings will give different results. TF_DerivedResultTypeAttr type = TF_DerivedResultTypeAttr<0>; TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; - } def TF_BitwiseAndOp : TF_Op<"BitwiseAnd", [Commutative, NoSideEffect, ResultsBroadcastableShape]>, @@ -1321,12 +1547,13 @@ bucketized values for a single feature. }]; let arguments = (ins - Variadic:$float_values, - Variadic:$bucket_boundaries + Arg, [{float; List of Rank 1 Tensor each containing float values for a single feature.}]>:$float_values, + Arg, [{float; List of Rank 1 Tensors each containing the bucket boundaries for a single +feature.}]>:$bucket_boundaries ); let results = (outs - Variadic:$buckets + Res, [{int; List of Rank 1 Tensors each containing the bucketized values for a single feature.}]>:$buckets ); TF_DerivedOperandSizeAttr num_features = TF_DerivedOperandSizeAttr<0>; @@ -1376,7 +1603,6 @@ This is typically used by gradient computations for a broadcasting operation. let verifier = [{ return Verify(*this); }]; - } def TF_BroadcastToOp : TF_Op<"BroadcastTo", [NoSideEffect]> { @@ -1413,12 +1639,12 @@ subsequent operation and then be optimized away, however.) }]; let arguments = (ins - TF_Tensor:$input, - TF_I32OrI64Tensor:$shape + Arg:$input, + Arg:$shape ); let results = (outs - TF_Tensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -1446,13 +1672,17 @@ then the output will be }]; let arguments = (ins - TensorOf<[TF_Float32, TF_Float64, TF_Int32, TF_Int64]>:$input, + Arg, [{Any shape of Tensor contains with int or float type.}]>:$input, F32ArrayAttr:$boundaries ); let results = (outs - TF_Int32Tensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -1473,7 +1703,6 @@ def TF_CastOp : TF_Op<"Cast", [NoSideEffect, SameOperandsAndResultShape]> { TF_DerivedOperandTypeAttr SrcT = TF_DerivedOperandTypeAttr<0>; TF_DerivedResultTypeAttr DstT = TF_DerivedResultTypeAttr<0>; - } def TF_CeilOp : TF_Op<"Ceil", [Idempotent, NoSideEffect, SameOperandsAndResultType]> { @@ -1490,7 +1719,7 @@ def TF_CeilOp : TF_Op<"Ceil", [Idempotent, NoSideEffect, SameOperandsAndResultTy TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; } -def TF_CheckNumericsOp : TF_Op<"CheckNumerics", [SameOperandsAndResultType]> { +def TF_CheckNumericsOp : TF_Op<"CheckNumerics", [TF_SameOperandsAndResultTypeResolveRef]> { let summary = "Checks a tensor for NaN and Inf values."; let description = [{ @@ -1533,11 +1762,11 @@ case it might be faster to use the CPU. }]; let arguments = (ins - TensorOf<[TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64]>:$input + Arg, [{Shape is `[..., M, M]`.}]>:$input ); let results = (outs - TensorOf<[TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64]>:$output + Res, [{Shape is `[..., M, M]`.}]>:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -1554,13 +1783,15 @@ greater than `clip_value_max` are set to `clip_value_max`. }]; let arguments = (ins - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$t, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$clip_value_min, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$clip_value_max + Arg, [{A `Tensor`.}]>:$t, + Arg, [{A 0-D (scalar) `Tensor`, or a `Tensor` with the same shape +as `t`. The minimum value to clip by.}]>:$clip_value_min, + Arg, [{A 0-D (scalar) `Tensor`, or a `Tensor` with the same shape +as `t`. The maximum value to clip by.}]>:$clip_value_max ); let results = (outs - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$output + Res, [{A clipped `Tensor` with the same shape as input 't'.}]>:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -1629,7 +1860,7 @@ Mutually accumulates multiple tensors of identical type and shape. TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; } -def TF_CollectiveReduceOp : TF_Op<"CollectiveReduce", [SameOperandsAndResultType]> { +def TF_CollectiveReduceOp : TF_Op<"CollectiveReduce", [TF_SameOperandsAndResultTypeResolveRef]> { let summary = [{ Mutually reduces multiple tensors of identical type and shape. }]; @@ -1740,12 +1971,16 @@ def TF_ConcatOp : TF_Op<"Concat", [NoSideEffect]> { let summary = "Concatenates tensors along one dimension."; let arguments = (ins - TF_Int32Tensor:$concat_dim, - Variadic:$values + Arg:$concat_dim, + Arg, [{The `N` Tensors to concatenate. Their ranks and types must match, +and their sizes must match in all dimensions except `concat_dim`.}]>:$values ); let results = (outs - TF_Tensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<1>; @@ -1754,7 +1989,6 @@ def TF_ConcatOp : TF_Op<"Concat", [NoSideEffect]> { let verifier = [{ return Verify(*this); }]; - } def TF_ConcatOffsetOp : TF_Op<"ConcatOffset", [NoSideEffect]> { @@ -1774,12 +2008,13 @@ This is typically used by gradient computations for a concat operation. }]; let arguments = (ins - TF_Int32Tensor:$concat_dim, - Variadic:$shape + Arg:$concat_dim, + Arg, [{The `N` int32 vectors representing shape of tensors being concatenated.}]>:$shape ); let results = (outs - Variadic:$offset + Res, [{The `N` int32 vectors representing the starting offset +of input tensors within the concatenated output.}]>:$offset ); TF_DerivedOperandSizeAttr N = TF_DerivedOperandSizeAttr<1>; @@ -1787,19 +2022,22 @@ This is typically used by gradient computations for a concat operation. let verifier = [{ return Verify(*this); }]; - } def TF_ConcatV2Op : TF_Op<"ConcatV2", [NoSideEffect]> { let summary = "Concatenates tensors along one dimension."; let arguments = (ins - Variadic:$values, - TF_I32OrI64Tensor:$axis + Arg, [{List of `N` Tensors to concatenate. Their ranks and types must match, +and their sizes must match in all dimensions except `concat_dim`.}]>:$values, + Arg:$axis ); let results = (outs - TF_Tensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -1809,7 +2047,6 @@ def TF_ConcatV2Op : TF_Op<"ConcatV2", [NoSideEffect]> { let verifier = [{ return Verify(*this); }]; - } def TF_ConfigureDistributedTPUOp : TF_Op<"ConfigureDistributedTPU", []> { @@ -1826,7 +2063,8 @@ Sets up the centralized structures for a distributed TPU system. ); let results = (outs - TF_StrTensor:$topology + Res:$topology ); } @@ -1924,8 +2162,10 @@ horizontal and vertices strides, `strides = [1, stride, stride, 1]`. }]; let arguments = (ins - TensorOf<[TF_Bfloat16, TF_Float16, TF_Float32, TF_Float64, TF_Int32]>:$input, - TensorOf<[TF_Bfloat16, TF_Float16, TF_Float32, TF_Float64, TF_Int32]>:$filter, + Arg, [{A 4-D tensor. The dimension order is interpreted according to the value +of `data_format`, see below for details.}]>:$input, + Arg, [{A 4-D tensor of shape +`[filter_height, filter_width, in_channels, out_channels]`}]>:$filter, I64ArrayAttr:$strides, DefaultValuedAttr:$use_cudnn_on_gpu, @@ -1936,7 +2176,8 @@ horizontal and vertices strides, `strides = [1, stride, stride, 1]`. ); let results = (outs - TensorOf<[TF_Bfloat16, TF_Float16, TF_Float32, TF_Float64, TF_Int32]>:$output + Res, [{A 4-D tensor. The dimension order is determined by the value of +`data_format`, see below for details.}]>:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -1952,9 +2193,12 @@ Computes the gradients of convolution with respect to the filter. }]; let arguments = (ins - TF_FloatTensor:$input, - TF_Int32Tensor:$filter_sizes, - TF_FloatTensor:$out_backprop, + Arg:$input, + Arg:$filter_sizes, + Arg:$out_backprop, I64ArrayAttr:$strides, DefaultValuedAttr:$use_cudnn_on_gpu, @@ -1965,16 +2209,12 @@ Computes the gradients of convolution with respect to the filter. ); let results = (outs - TF_FloatTensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; - - let extraClassDeclaration = [{ - // TF_LayoutSensitiveInterface: - SmallVector GetLayoutDependentArgs() { return {0, 2}; } - SmallVector GetLayoutDependentResults() { return {}; } - }]; } def TF_Conv2DBackpropInputOp : TF_Op<"Conv2DBackpropInput", [NoSideEffect]> { @@ -1983,9 +2223,12 @@ Computes the gradients of convolution with respect to the input. }]; let arguments = (ins - TF_Int32Tensor:$input_sizes, - TensorOf<[TF_Bfloat16, TF_Float16, TF_Float32, TF_Float64, TF_Int32]>:$filter, - TensorOf<[TF_Bfloat16, TF_Float16, TF_Float32, TF_Float64, TF_Int32]>:$out_backprop, + Arg:$input_sizes, + Arg, [{4-D with shape +`[filter_height, filter_width, in_channels, out_channels]`.}]>:$filter, + Arg, [{4-D with shape `[batch, out_height, out_width, out_channels]`. +Gradients w.r.t. the output of the convolution.}]>:$out_backprop, I64ArrayAttr:$strides, DefaultValuedAttr:$use_cudnn_on_gpu, @@ -1996,7 +2239,8 @@ Computes the gradients of convolution with respect to the input. ); let results = (outs - TensorOf<[TF_Bfloat16, TF_Float16, TF_Float32, TF_Float64, TF_Int32]>:$output + Res, [{4-D with shape `[batch, in_height, in_width, in_channels]`. Gradient +w.r.t. the input of the convolution.}]>:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<1>; @@ -2004,12 +2248,6 @@ Computes the gradients of convolution with respect to the input. let verifier = [{ return Verify(*this); }]; - - let extraClassDeclaration = [{ - // TF_LayoutSensitiveInterface: - SmallVector GetLayoutDependentArgs() { return {2}; } - SmallVector GetLayoutDependentResults() { return {0}; } - }]; } def TF_Conv3DOp : TF_Op<"Conv3D", [NoSideEffect]> { @@ -2026,8 +2264,9 @@ Our Conv3D implements a form of cross-correlation. }]; let arguments = (ins - TF_FloatTensor:$input, - TF_FloatTensor:$filter, + Arg:$input, + Arg:$filter, Confined]>:$strides, TF_AnyStrAttrOf<["SAME", "VALID"]>:$padding, @@ -2052,9 +2291,13 @@ Computes the gradients of 3-D convolution with respect to the filter. }]; let arguments = (ins - TF_FloatTensor:$input, - TF_Int32Tensor:$filter_sizes, - TF_FloatTensor:$out_backprop, + Arg:$input, + Arg:$filter_sizes, + Arg:$out_backprop, Confined]>:$strides, TF_AnyStrAttrOf<["SAME", "VALID"]>:$padding, @@ -2075,9 +2318,13 @@ Computes the gradients of 3-D convolution with respect to the input. }]; let arguments = (ins - TF_I32OrI64Tensor:$input_sizes, - TF_FloatTensor:$filter, - TF_FloatTensor:$out_backprop, + Arg:$input_sizes, + Arg:$filter, + Arg:$out_backprop, Confined]>:$strides, TF_AnyStrAttrOf<["SAME", "VALID"]>:$padding, @@ -2093,7 +2340,7 @@ Computes the gradients of 3-D convolution with respect to the input. TF_DerivedOperandTypeAttr Tshape = TF_DerivedOperandTypeAttr<0>; } -def TF_CosOp : TF_Op<"Cos", [NoSideEffect, SameOperandsAndResultType]> { +def TF_CosOp : TF_Op<"Cos", [NoSideEffect, TF_SameOperandsAndResultTypeResolveRef]> { let summary = "Computes cos of x element-wise."; let description = [{ @@ -2119,7 +2366,7 @@ Given an input tensor, this function computes cosine of every TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; } -def TF_CoshOp : TF_Op<"Cosh", [NoSideEffect, SameOperandsAndResultType]> { +def TF_CoshOp : TF_Op<"Cosh", [NoSideEffect, TF_SameOperandsAndResultTypeResolveRef]> { let summary = "Computes hyperbolic cosine of x element-wise."; let description = [{ @@ -2154,12 +2401,12 @@ of corresponding 3-element vectors is cross-multiplied independently. }]; let arguments = (ins - TF_IntOrFpTensor:$a, - TF_IntOrFpTensor:$b + Arg:$a, + Arg:$b ); let results = (outs - TF_IntOrFpTensor:$product + Res:$product ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -2178,12 +2425,14 @@ and `B, D, F, H` as group 1. Thus we get the outputs: }]; let arguments = (ins - TensorOf<[TF_Bfloat16, TF_Float16, TF_Float32, TF_Int32, TF_Uint32]>:$input, - TF_Int32Tensor:$group_assignment + Arg, [{The local input to the sum.}]>:$input, + Arg:$group_assignment ); let results = (outs - TensorOf<[TF_Bfloat16, TF_Float16, TF_Float32, TF_Int32, TF_Uint32]>:$output + Res, [{The sum of all the distributed inputs.}]>:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -2226,8 +2475,11 @@ tf.cumprod([a, b, c], exclusive=True, reverse=True) # => [b * c, c, 1] }]; let arguments = (ins - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$x, - TF_I32OrI64Tensor:$axis, + Arg, [{A `Tensor`. Must be one of the following types: `float32`, `float64`, +`int64`, `int32`, `uint8`, `uint16`, `int16`, `int8`, `complex64`, +`complex128`, `qint8`, `quint8`, `qint32`, `half`.}]>:$x, + Arg:$axis, DefaultValuedAttr:$exclusive, DefaultValuedAttr:$reverse @@ -2280,8 +2532,11 @@ tf.cumsum([a, b, c], exclusive=True, reverse=True) # => [b + c, c, 0] }]; let arguments = (ins - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$x, - TF_I32OrI64Tensor:$axis, + Arg, [{A `Tensor`. Must be one of the following types: `float32`, `float64`, +`int64`, `int32`, `uint8`, `uint16`, `int16`, `int8`, `complex64`, +`complex128`, `qint8`, `quint8`, `qint32`, `half`.}]>:$x, + Arg:$axis, DefaultValuedAttr:$exclusive, DefaultValuedAttr:$reverse @@ -2299,7 +2554,7 @@ tf.cumsum([a, b, c], exclusive=True, reverse=True) # => [b + c, c, 0] }]; } -def TF_DataFormatDimMapOp : TF_Op<"DataFormatDimMap", [NoSideEffect, SameOperandsAndResultType]> { +def TF_DataFormatDimMapOp : TF_Op<"DataFormatDimMap", [NoSideEffect, TF_SameOperandsAndResultTypeResolveRef]> { let summary = [{ Returns the dimension index in the destination data format given the one in }]; @@ -2309,14 +2564,15 @@ the source data format. }]; let arguments = (ins - TF_I32OrI64Tensor:$x, + Arg:$x, DefaultValuedAttr:$src_format, DefaultValuedAttr:$dst_format ); let results = (outs - TF_I32OrI64Tensor:$y + Res:$y ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -2349,14 +2605,14 @@ and }]; let arguments = (ins - TF_I32OrI64Tensor:$x, + Arg:$x, DefaultValuedAttr:$src_format, DefaultValuedAttr:$dst_format ); let results = (outs - TF_I32OrI64Tensor:$y + Res:$y ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -2380,7 +2636,7 @@ computes summary information about one or more tensors. }]; let arguments = (ins - TF_Tensor:$input, + Arg:$input, StrAttr:$tfdbg_context_id, StrAttr:$op_name, @@ -2424,8 +2680,8 @@ decoding partial jpeg image. }]; let arguments = (ins - TF_StrTensor:$contents, - TF_Int32Tensor:$crop_window, + Arg:$contents, + Arg:$crop_window, DefaultValuedAttr:$channels, DefaultValuedAttr:$ratio, @@ -2436,7 +2692,7 @@ decoding partial jpeg image. ); let results = (outs - TF_Uint8Tensor:$image + Res:$image ); } @@ -2455,11 +2711,11 @@ This op also supports decoding JPEGs and PNGs, though it is cleaner to use }]; let arguments = (ins - TF_StrTensor:$contents + Arg:$contents ); let results = (outs - TF_Uint8Tensor:$image + Res:$image ); } @@ -2489,7 +2745,7 @@ the same, though it is cleaner to use `tf.io.decode_image`. }]; let arguments = (ins - TF_StrTensor:$contents, + Arg:$contents, DefaultValuedAttr:$channels, DefaultValuedAttr:$ratio, @@ -2500,7 +2756,7 @@ the same, though it is cleaner to use `tf.io.decode_image`. ); let results = (outs - TF_Uint8Tensor:$image + Res:$image ); } @@ -2526,13 +2782,13 @@ is the same, though it is cleaner to use `tf.io.decode_image`. }]; let arguments = (ins - TF_StrTensor:$contents, + Arg:$contents, DefaultValuedAttr:$channels ); let results = (outs - TensorOf<[TF_Uint16, TF_Uint8]>:$image + Res, [{3-D with shape `[height, width, channels]`.}]>:$image ); TF_DerivedResultTypeAttr dtype = TF_DerivedResultTypeAttr<0>; @@ -2542,8 +2798,8 @@ def TF_DeleteIteratorOp : TF_Op<"DeleteIterator", []> { let summary = "A container for an iterator resource."; let arguments = (ins - Arg:$handle, - TF_VariantTensor:$deleter + Arg:$handle, + Arg:$deleter ); let results = (outs); @@ -2564,9 +2820,9 @@ def TF_DeleteMultiDeviceIteratorOp : TF_Op<"DeleteMultiDeviceIterator", []> { let summary = "A container for an iterator resource."; let arguments = (ins - Arg:$multi_device_iterator, - Arg, "", [TF_DatasetIteratorRead]>:$iterators, - TF_VariantTensor:$deleter + Arg:$multi_device_iterator, + Arg, [{A list of iterator handles (unused). This is added so that automatic control dependencies get added during function tracing that ensure this op runs after all the dependent iterators are deleted.}], [TF_DatasetIteratorRead]>:$iterators, + Arg:$deleter ); let results = (outs); @@ -2755,9 +3011,16 @@ Computes the gradients of depthwise convolution with respect to the filter. }]; let arguments = (ins - TF_FloatTensor:$input, - TF_Int32Tensor:$filter_sizes, - TF_FloatTensor:$out_backprop, + Arg:$input, + Arg:$filter_sizes, + Arg:$out_backprop, I64ArrayAttr:$strides, TF_AnyStrAttrOf<["SAME", "VALID", "EXPLICIT"]>:$padding, @@ -2767,7 +3030,9 @@ Computes the gradients of depthwise convolution with respect to the filter. ); let results = (outs - TF_FloatTensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -2779,9 +3044,15 @@ Computes the gradients of depthwise convolution with respect to the input. }]; let arguments = (ins - TF_Int32Tensor:$input_sizes, - TF_FloatTensor:$filter, - TF_FloatTensor:$out_backprop, + Arg:$input_sizes, + Arg:$filter, + Arg:$out_backprop, I64ArrayAttr:$strides, TF_AnyStrAttrOf<["SAME", "VALID", "EXPLICIT"]>:$padding, @@ -2791,7 +3062,10 @@ Computes the gradients of depthwise convolution with respect to the input. ); let results = (outs - TF_FloatTensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<1>; @@ -2859,8 +3133,8 @@ and `QuantizeV2`, using the following algorithm: let arguments = (ins TensorOf<[TF_Qint16, TF_Qint32, TF_Qint8, TF_Quint16, TF_Quint8]>:$input, - TF_Float32Tensor:$min_range, - TF_Float32Tensor:$max_range, + Arg:$min_range, + Arg:$max_range, DefaultValuedAttr, "MIN_COMBINED">:$mode, DefaultValuedAttr:$narrow_range, @@ -2881,8 +3155,9 @@ Converts the given variant tensor to an iterator and stores it in the given reso }]; let arguments = (ins - Arg:$resource_handle, - TF_VariantTensor:$serialized + Arg:$resource_handle, + Arg:$serialized ); let results = (outs); @@ -2936,7 +3211,8 @@ then the final deserialized `SparseTensor` will be: }]; let arguments = (ins - TensorOf<[TF_Str, TF_Variant]>:$serialized_sparse + Arg, [{The serialized `SparseTensor` objects. The last dimension +must have 3 columns.}]>:$serialized_sparse ); let results = (outs @@ -2958,7 +3234,7 @@ error status. }]; let arguments = (ins - TF_ResourceTensor:$resource, + Arg:$resource, DefaultValuedAttr:$ignore_lookup_error ); @@ -2985,7 +3261,7 @@ this op runs. The length of the list is returned in two cases: ); } -def TF_DiagOp : TF_Op<"Diag", [NoSideEffect, SameOperandsAndResultElementType]> { +def TF_DiagOp : TF_Op<"Diag", [NoSideEffect, TF_SameOperandsAndResultElementTypeResolveRef]> { let summary = "Returns a diagonal tensor with a given diagonal values."; let description = [{ @@ -3009,7 +3285,7 @@ tf.diag(diagonal) ==> [[1, 0, 0, 0] }]; let arguments = (ins - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int32, TF_Int64]>:$diagonal + Arg, [{Rank k tensor where k is at most 1.}]>:$diagonal ); let results = (outs @@ -3044,17 +3320,17 @@ tf.diag_part(input) ==> [1, 2, 3, 4] }]; let arguments = (ins - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int32, TF_Int64]>:$input + Arg, [{Rank k tensor where k is even and not zero.}]>:$input ); let results = (outs - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int32, TF_Int64]>:$diagonal + Res, [{The extracted diagonal.}]>:$diagonal ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; } -def TF_DigammaOp : TF_Op<"Digamma", [NoSideEffect, SameOperandsAndResultType]> { +def TF_DigammaOp : TF_Op<"Digamma", [NoSideEffect, TF_SameOperandsAndResultTypeResolveRef]> { let summary = [{ Computes Psi, the derivative of Lgamma (the log of the absolute value of }]; @@ -3084,17 +3360,15 @@ def TF_DivOp : TF_Op<"Div", [NoSideEffect, ResultsBroadcastableShape, TF_SameOpe }]; let arguments = (ins - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Uint16, TF_Uint8]>:$x, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Uint16, TF_Uint8]>:$y + TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$x, + TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$y ); let results = (outs - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Uint16, TF_Uint8]>:$z + TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$z ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; - - } def TF_DummyMemoryCacheOp : TF_Op<"DummyMemoryCache", []> { @@ -3288,13 +3562,13 @@ Comparison with `numpy.einsum`: }]; let arguments = (ins - Variadic:$inputs, + Arg, [{List of 1 or 2 Tensors.}]>:$inputs, StrAttr:$equation ); let results = (outs - TF_Tensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -3305,7 +3579,7 @@ Comparison with `numpy.einsum`: }]; } -def TF_EluOp : TF_Op<"Elu", [NoSideEffect, SameOperandsAndResultType]> { +def TF_EluOp : TF_Op<"Elu", [NoSideEffect, TF_SameOperandsAndResultTypeResolveRef]> { let summary = [{ Computes exponential linear: `exp(features) - 1` if < 0, `features` otherwise. }]; @@ -3326,18 +3600,19 @@ See [Fast and Accurate Deep Network Learning by Exponential Linear Units (ELUs) TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; } -def TF_EluGradOp : TF_Op<"EluGrad", [NoSideEffect, SameOperandsAndResultType]> { +def TF_EluGradOp : TF_Op<"EluGrad", [NoSideEffect, TF_SameOperandsAndResultTypeResolveRef]> { let summary = [{ Computes gradients for the exponential linear (Elu) operation. }]; let arguments = (ins - TF_FloatTensor:$gradients, - TF_FloatTensor:$outputs + Arg:$gradients, + Arg:$outputs ); let results = (outs - TF_FloatTensor:$backprops + Res:$backprops ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -3351,17 +3626,16 @@ This operation creates a tensor of `shape` and `dtype`. }]; let arguments = (ins - TF_Int32Tensor:$shape, + Arg:$shape, DefaultValuedAttr:$init ); let results = (outs - TF_Tensor:$output + Res:$output ); TF_DerivedResultTypeAttr dtype = TF_DerivedResultTypeAttr<0>; - } def TF_EnqueueTPUEmbeddingIntegerBatchOp : TF_Op<"EnqueueTPUEmbeddingIntegerBatch", [TF_TPUEmbeddingSideEffect]> { @@ -3370,8 +3644,12 @@ An op that enqueues a list of input batch tensors to TPUEmbedding. }]; let arguments = (ins - Variadic:$batch, - TF_StrTensor:$mode_override, + Arg, [{A list of 1D tensors, one for each embedding table, containing the +indices into the tables.}]>:$batch, + Arg:$mode_override, DefaultValuedAttr:$device_ordinal ); @@ -3396,15 +3674,26 @@ the corresponding feature. }]; let arguments = (ins - Variadic:$sample_splits, - Variadic:$embedding_indices, - Variadic:$aggregation_weights, - TF_StrTensor:$mode_override, + Arg, [{A list of rank 1 Tensors specifying the break points for splitting +embedding_indices and aggregation_weights into rows. +It corresponds to ids.row_splits in embedding_lookup(), when ids is a +RaggedTensor.}]>:$sample_splits, + Arg, [{A list of rank 1 Tensors, indices into the embedding tables. +It corresponds to ids.values in embedding_lookup(), when ids is a RaggedTensor.}]>:$embedding_indices, + Arg, [{A list of rank 1 Tensors containing per training example +aggregation weights. It corresponds to the values field of a RaggedTensor +with the same row_splits as ids in embedding_lookup(), when ids is a +RaggedTensor.}]>:$aggregation_weights, + Arg:$mode_override, DefaultValuedAttr:$device_ordinal, DefaultValuedAttr:$combiners, I64ArrayAttr:$table_ids, - DefaultValuedAttr:$max_sequence_lengths + DefaultValuedAttr:$max_sequence_lengths, + DefaultValuedAttr:$num_features ); let results = (outs); @@ -3433,10 +3722,18 @@ number of lookups into the table described by the corresponding table_id. }]; let arguments = (ins - Variadic:$sample_indices, - Variadic:$embedding_indices, - Variadic:$aggregation_weights, - TF_StrTensor:$mode_override, + Arg, [{A list of rank 1 Tensors specifying the training example and +feature to which the corresponding embedding_indices and aggregation_weights +values belong. sample_indices[i] must equal b * nf + f, where nf is the +number of features from the corresponding table, f is in [0, nf), and +b is in [0, batch size).}]>:$sample_indices, + Arg, [{A list of rank 1 Tensors, indices into the embedding tables.}]>:$embedding_indices, + Arg, [{A list of rank 1 Tensors containing per sample -- i.e. per +(training example, feature) -- aggregation weights.}]>:$aggregation_weights, + Arg:$mode_override, DefaultValuedAttr:$device_ordinal, DefaultValuedAttr:$combiners @@ -3467,15 +3764,24 @@ the corresponding feature. }]; let arguments = (ins - Variadic:$sample_indices, - Variadic:$embedding_indices, - Variadic:$aggregation_weights, - TF_StrTensor:$mode_override, + Arg, [{A list of rank 1 Tensors specifying the training example to +which the corresponding embedding_indices and aggregation_weights values +belong. It corresponds to sp_ids.indices[:,0] in embedding_lookup_sparse().}]>:$sample_indices, + Arg, [{A list of rank 1 Tensors, indices into the embedding tables. +It corresponds to sp_ids.values in embedding_lookup_sparse().}]>:$embedding_indices, + Arg, [{A list of rank 1 Tensors containing per training example +aggregation weights. It corresponds to sp_weights.values in +embedding_lookup_sparse().}]>:$aggregation_weights, + Arg:$mode_override, DefaultValuedAttr:$device_ordinal, DefaultValuedAttr:$combiners, I64ArrayAttr:$table_ids, - DefaultValuedAttr:$max_sequence_lengths + DefaultValuedAttr:$max_sequence_lengths, + DefaultValuedAttr:$num_features ); let results = (outs); @@ -3495,13 +3801,13 @@ Returns the input tensor otherwise. }]; let arguments = (ins - TF_Tensor:$input, + Arg:$input, TF_ShapeAttr:$shape ); let results = (outs - TF_Tensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -3539,7 +3845,7 @@ tf.math.equal(x, y) ==> array([True, True]) TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; let builders = [ - OpBuilderDAG<(ins "Value":$x, "Value":$y, + OpBuilder<(ins "Value":$x, "Value":$y, "BoolAttr":$incompatible_shape_error)> ]; @@ -3548,7 +3854,7 @@ tf.math.equal(x, y) ==> array([True, True]) }]; } -def TF_ErfOp : TF_Op<"Erf", [NoSideEffect, SameOperandsAndResultType]> { +def TF_ErfOp : TF_Op<"Erf", [NoSideEffect, TF_SameOperandsAndResultTypeResolveRef]> { let summary = "Computes the Gauss error function of `x` element-wise."; let arguments = (ins @@ -3562,7 +3868,7 @@ def TF_ErfOp : TF_Op<"Erf", [NoSideEffect, SameOperandsAndResultType]> { TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; } -def TF_ErfcOp : TF_Op<"Erfc", [NoSideEffect, SameOperandsAndResultType]> { +def TF_ErfcOp : TF_Op<"Erfc", [NoSideEffect, TF_SameOperandsAndResultTypeResolveRef]> { let summary = [{ Computes the complementary error function of `x` element-wise. }]; @@ -3675,22 +3981,25 @@ size 1. let arguments = (ins TF_Tensor:$input, - TF_I32OrI64Tensor:$dim + Arg:$dim ); let results = (outs - TF_Tensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; TF_DerivedOperandTypeAttr Tdim = TF_DerivedOperandTypeAttr<1>; let builders = [ - OpBuilderDAG<(ins "Value":$condition, "Value":$dim)> + OpBuilder<(ins "Value":$condition, "Value":$dim)> ]; } -def TF_Expm1Op : TF_Op<"Expm1", [NoSideEffect, SameOperandsAndResultType]> { +def TF_Expm1Op : TF_Op<"Expm1", [NoSideEffect, TF_SameOperandsAndResultTypeResolveRef]> { let summary = "Computes `exp(x) - 1` element-wise."; let description = [{ @@ -3726,7 +4035,7 @@ Extract `patches` from `images` and put them in the "depth" output dimension. }]; let arguments = (ins - TensorOf<[TF_Bfloat16, TF_Bool, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$images, + Arg, [{4-D Tensor with shape `[batch, in_rows, in_cols, depth]`.}]>:$images, Confined]>:$ksizes, Confined]>:$strides, @@ -3735,7 +4044,10 @@ Extract `patches` from `images` and put them in the "depth" output dimension. ); let results = (outs - TensorOf<[TF_Bfloat16, TF_Bool, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$patches + Res, [{4-D Tensor with shape `[batch, out_rows, out_cols, ksize_rows * +ksize_cols * depth]` containing image patches with size +`ksize_rows x ksize_cols x depth` vectorized in the "depth" dimension. Note +`out_rows` and `out_cols` are the dimensions of the output patches.}]>:$patches ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -3750,11 +4062,16 @@ dimension of `input`. }]; let arguments = (ins - TensorOf<[TF_Complex128, TF_Complex64]>:$input + Arg, [{A complex tensor.}]>:$input ); let results = (outs - TensorOf<[TF_Complex128, TF_Complex64]>:$output + Res, [{A complex tensor of the same shape as `input`. The inner-most + dimension of `input` is replaced with its 1D Fourier transform. + +@compatibility(numpy) +Equivalent to np.fft.fft +@end_compatibility}]>:$output ); TF_DerivedOperandTypeAttr Tcomplex = TF_DerivedOperandTypeAttr<0>; @@ -3769,11 +4086,16 @@ Computes the 2-dimensional discrete Fourier transform over the inner-most }]; let arguments = (ins - TensorOf<[TF_Complex128, TF_Complex64]>:$input + Arg, [{A complex tensor.}]>:$input ); let results = (outs - TensorOf<[TF_Complex128, TF_Complex64]>:$output + Res, [{A complex tensor of the same shape as `input`. The inner-most 2 + dimensions of `input` are replaced with their 2D Fourier transform. + +@compatibility(numpy) +Equivalent to np.fft.fft2 +@end_compatibility}]>:$output ); TF_DerivedOperandTypeAttr Tcomplex = TF_DerivedOperandTypeAttr<0>; @@ -3788,19 +4110,22 @@ dimensions of `input`. }]; let arguments = (ins - TensorOf<[TF_Complex128, TF_Complex64]>:$input + Arg, [{A complex tensor.}]>:$input ); let results = (outs - TensorOf<[TF_Complex128, TF_Complex64]>:$output + Res, [{A complex tensor of the same shape as `input`. The inner-most 3 + dimensions of `input` are replaced with their 3D Fourier transform. + +@compatibility(numpy) +Equivalent to np.fft.fftn with 3 dimensions. +@end_compatibility}]>:$output ); TF_DerivedOperandTypeAttr Tcomplex = TF_DerivedOperandTypeAttr<0>; } def TF_FakeParamOp : TF_Op<"FakeParam", [NoSideEffect, TF_NoConstantFold]> { - // Disable constant folding of this op as the op doesn't provide any valid - // output. let summary = [{ This op is used as a placeholder in If branch functions. It doesn't provide a valid output when run, so must either be removed (e.g. replaced with a @@ -3813,13 +4138,13 @@ def TF_FakeParamOp : TF_Op<"FakeParam", [NoSideEffect, TF_NoConstantFold]> { ); let results = (outs - TF_Tensor:$output + Res:$output ); TF_DerivedResultTypeAttr dtype = TF_DerivedResultTypeAttr<0>; } -def TF_FakeQuantWithMinMaxArgsOp : TF_Op<"FakeQuantWithMinMaxArgs", [NoSideEffect, SameOperandsAndResultType]> { +def TF_FakeQuantWithMinMaxArgsOp : TF_Op<"FakeQuantWithMinMaxArgs", [NoSideEffect, TF_SameOperandsAndResultTypeResolveRef]> { let summary = [{ Fake-quantize the 'inputs' tensor, type float to 'outputs' tensor of same type. }]; @@ -3865,12 +4190,12 @@ Quantization is called fake since the output is still in floating point. }]; } -def TF_FakeQuantWithMinMaxArgsGradientOp : TF_Op<"FakeQuantWithMinMaxArgsGradient", [NoSideEffect, SameOperandsAndResultType]> { +def TF_FakeQuantWithMinMaxArgsGradientOp : TF_Op<"FakeQuantWithMinMaxArgsGradient", [NoSideEffect, TF_SameOperandsAndResultTypeResolveRef]> { let summary = "Compute gradients for a FakeQuantWithMinMaxArgs operation."; let arguments = (ins - TF_Float32Tensor:$gradients, - TF_Float32Tensor:$inputs, + Arg:$gradients, + Arg:$inputs, DefaultValuedAttr:$min, DefaultValuedAttr:$max, @@ -3879,7 +4204,8 @@ def TF_FakeQuantWithMinMaxArgsGradientOp : TF_Op<"FakeQuantWithMinMaxArgsGradien ); let results = (outs - TF_Float32Tensor:$backprops + Res= min && inputs <= max)`.}]>:$backprops ); } @@ -3937,8 +4263,9 @@ def TF_FakeQuantWithMinMaxVarsGradientOp : TF_Op<"FakeQuantWithMinMaxVarsGradien let summary = "Compute gradients for a FakeQuantWithMinMaxVars operation."; let arguments = (ins - TF_Float32Tensor:$gradients, - TF_Float32Tensor:$inputs, + Arg:$gradients, + Arg:$inputs, TF_Float32Tensor:$min, TF_Float32Tensor:$max, @@ -3947,9 +4274,12 @@ def TF_FakeQuantWithMinMaxVarsGradientOp : TF_Op<"FakeQuantWithMinMaxVarsGradien ); let results = (outs - TF_Float32Tensor:$backprops_wrt_input, - TF_Float32Tensor:$backprop_wrt_min, - TF_Float32Tensor:$backprop_wrt_max + Res= min && inputs <= max)`.}]>:$backprops_wrt_input, + Res:$backprop_wrt_min, + Res max))`.}]>:$backprop_wrt_max ); } @@ -4030,8 +4360,12 @@ fill([2, 3], 9) ==> [[9, 9, 9] }]; let arguments = (ins - TF_I32OrI64Tensor:$dims, - TF_Tensor:$value + Arg:$dims, + Arg:$value ); let results = (outs @@ -4045,9 +4379,8 @@ fill([2, 3], 9) ==> [[9, 9, 9] return Verify(*this); }]; - let builders = [ - OpBuilderDAG<(ins "Value":$dims, "Value":$value)> + OpBuilder<(ins "Value":$dims, "Value":$value)> ]; } @@ -4075,12 +4408,12 @@ def TF_FloorDivOp : TF_Op<"FloorDiv", [NoSideEffect, ResultsBroadcastableShape]> }]; let arguments = (ins - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Uint16, TF_Uint8]>:$x, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Uint16, TF_Uint8]>:$y + TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$x, + TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$y ); let results = (outs - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Uint16, TF_Uint8]>:$z + TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$z ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -4121,11 +4454,13 @@ The size of 1D Tensors matches the dimension C of the 4D Tensors. }]; let arguments = (ins - TF_Float32Tensor:$x, - TF_Float32Tensor:$scale, - TF_Float32Tensor:$offset, - TF_Float32Tensor:$mean, - TF_Float32Tensor:$variance, + Arg:$x, + Arg:$scale, + Arg:$offset, + Arg:$mean, + Arg:$variance, DefaultValuedAttr:$epsilon, DefaultValuedAttr:$exponential_avg_factor, @@ -4134,16 +4469,19 @@ The size of 1D Tensors matches the dimension C of the 4D Tensors. ); let results = (outs - TF_Float32Tensor:$y, - TF_Float32Tensor:$batch_mean, - TF_Float32Tensor:$batch_variance, - TF_Float32Tensor:$reserve_space_1, - TF_Float32Tensor:$reserve_space_2 + Res:$y, + Res:$batch_mean, + Res:$batch_variance, + Res:$reserve_space_1, + Res:$reserve_space_2 ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; - let verifier = [{ return Verify(*this); }]; @@ -4158,11 +4496,18 @@ The size of 1D Tensors matches the dimension C of the 4D Tensors. }]; let arguments = (ins - TF_Float32Tensor:$y_backprop, - TF_Float32Tensor:$x, - TF_Float32Tensor:$scale, - TF_Float32Tensor:$reserve_space_1, - TF_Float32Tensor:$reserve_space_2, + Arg:$y_backprop, + Arg:$x, + Arg:$scale, + Arg:$reserve_space_1, + Arg:$reserve_space_2, DefaultValuedAttr:$epsilon, DefaultValuedAttr:$data_format, @@ -4170,11 +4515,12 @@ The size of 1D Tensors matches the dimension C of the 4D Tensors. ); let results = (outs - TF_Float32Tensor:$x_backprop, - TF_Float32Tensor:$scale_backprop, - TF_Float32Tensor:$offset_backprop, - TF_Float32Tensor:$reserve_space_3, - TF_Float32Tensor:$reserve_space_4 + Res:$x_backprop, + Res:$scale_backprop, + Res:$offset_backprop, + Res:$reserve_space_3, + Res:$reserve_space_4 ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -4189,11 +4535,18 @@ The size of 1D Tensors matches the dimension C of the 4D Tensors. }]; let arguments = (ins - TensorOf<[TF_Bfloat16, TF_Float16, TF_Float32]>:$y_backprop, - TensorOf<[TF_Bfloat16, TF_Float16, TF_Float32]>:$x, - TF_Float32Tensor:$scale, - TF_Float32Tensor:$reserve_space_1, - TF_Float32Tensor:$reserve_space_2, + Arg, [{A 4D Tensor for the gradient with respect to y.}]>:$y_backprop, + Arg, [{A 4D Tensor for input data.}]>:$x, + Arg:$scale, + Arg:$reserve_space_1, + Arg:$reserve_space_2, DefaultValuedAttr:$epsilon, DefaultValuedAttr:$data_format, @@ -4201,11 +4554,12 @@ The size of 1D Tensors matches the dimension C of the 4D Tensors. ); let results = (outs - TensorOf<[TF_Bfloat16, TF_Float16, TF_Float32]>:$x_backprop, - TF_Float32Tensor:$scale_backprop, - TF_Float32Tensor:$offset_backprop, - TF_Float32Tensor:$reserve_space_3, - TF_Float32Tensor:$reserve_space_4 + Res, [{A 4D Tensor for the gradient with respect to x.}]>:$x_backprop, + Res:$scale_backprop, + Res:$offset_backprop, + Res:$reserve_space_3, + Res:$reserve_space_4 ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -4221,12 +4575,21 @@ The size of 1D Tensors matches the dimension C of the 4D Tensors. }]; let arguments = (ins - TensorOf<[TF_Bfloat16, TF_Float16, TF_Float32]>:$y_backprop, - TensorOf<[TF_Bfloat16, TF_Float16, TF_Float32]>:$x, - TF_Float32Tensor:$scale, - TF_Float32Tensor:$reserve_space_1, - TF_Float32Tensor:$reserve_space_2, - TF_Float32Tensor:$reserve_space_3, + Arg, [{A 4D Tensor for the gradient with respect to y.}]>:$y_backprop, + Arg, [{A 4D Tensor for input data.}]>:$x, + Arg:$scale, + Arg:$reserve_space_1, + Arg:$reserve_space_2, + Arg:$reserve_space_3, DefaultValuedAttr:$epsilon, DefaultValuedAttr, "NHWC">:$data_format, @@ -4234,21 +4597,16 @@ The size of 1D Tensors matches the dimension C of the 4D Tensors. ); let results = (outs - TensorOf<[TF_Bfloat16, TF_Float16, TF_Float32]>:$x_backprop, - TF_Float32Tensor:$scale_backprop, - TF_Float32Tensor:$offset_backprop, - TF_Float32Tensor:$reserve_space_4, - TF_Float32Tensor:$reserve_space_5 + Res, [{A 4D Tensor for the gradient with respect to x.}]>:$x_backprop, + Res:$scale_backprop, + Res:$offset_backprop, + Res:$reserve_space_4, + Res:$reserve_space_5 ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; TF_DerivedOperandTypeAttr U = TF_DerivedOperandTypeAttr<3>; - - let extraClassDeclaration = [{ - // TF_LayoutSensitiveInterface: - SmallVector GetLayoutDependentArgs() { return {0, 1}; } - SmallVector GetLayoutDependentResults() { return {0}; } - }]; } def TF_FusedBatchNormV2Op : TF_Op<"FusedBatchNormV2", [NoSideEffect]> { @@ -4260,11 +4618,13 @@ The size of 1D Tensors matches the dimension C of the 4D Tensors. }]; let arguments = (ins - TensorOf<[TF_Bfloat16, TF_Float16, TF_Float32]>:$x, - TF_Float32Tensor:$scale, - TF_Float32Tensor:$offset, - TF_Float32Tensor:$mean, - TF_Float32Tensor:$variance, + Arg, [{A 4D Tensor for input data.}]>:$x, + Arg:$scale, + Arg:$offset, + Arg:$mean, + Arg:$variance, DefaultValuedAttr:$epsilon, DefaultValuedAttr:$exponential_avg_factor, @@ -4273,23 +4633,19 @@ The size of 1D Tensors matches the dimension C of the 4D Tensors. ); let results = (outs - TensorOf<[TF_Bfloat16, TF_Float16, TF_Float32]>:$y, - TF_Float32Tensor:$batch_mean, - TF_Float32Tensor:$batch_variance, - TF_Float32Tensor:$reserve_space_1, - TF_Float32Tensor:$reserve_space_2 + Res, [{A 4D Tensor for output data.}]>:$y, + Res:$batch_mean, + Res:$batch_variance, + Res:$reserve_space_1, + Res:$reserve_space_2 ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; TF_DerivedOperandTypeAttr U = TF_DerivedOperandTypeAttr<1>; - - let extraClassDeclaration = [{ - // TF_FoldOperandsTransposeInterface: - SmallVector GetLayoutDependentArgs() { return {0}; } - SmallVector GetLayoutDependentResults() { return {0}; } - - // TF_LayoutSensitiveInterface: - }]; } def TF_FusedBatchNormV3Op : TF_Op<"FusedBatchNormV3", [NoSideEffect]> { @@ -4301,11 +4657,13 @@ The size of 1D Tensors matches the dimension C of the 4D Tensors. }]; let arguments = (ins - TensorOf<[TF_Bfloat16, TF_Float16, TF_Float32]>:$x, - TF_Float32Tensor:$scale, - TF_Float32Tensor:$offset, - TF_Float32Tensor:$mean, - TF_Float32Tensor:$variance, + Arg, [{A 4D Tensor for input data.}]>:$x, + Arg:$scale, + Arg:$offset, + Arg:$mean, + Arg:$variance, DefaultValuedAttr:$epsilon, DefaultValuedAttr:$exponential_avg_factor, @@ -4314,24 +4672,21 @@ The size of 1D Tensors matches the dimension C of the 4D Tensors. ); let results = (outs - TensorOf<[TF_Bfloat16, TF_Float16, TF_Float32]>:$y, - TF_Float32Tensor:$batch_mean, - TF_Float32Tensor:$batch_variance, - TF_Float32Tensor:$reserve_space_1, - TF_Float32Tensor:$reserve_space_2, - TF_Float32Tensor:$reserve_space_3 + Res, [{A 4D Tensor for output data.}]>:$y, + Res:$batch_mean, + Res:$batch_variance, + Res:$reserve_space_1, + Res:$reserve_space_2, + Res:$reserve_space_3 ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; TF_DerivedOperandTypeAttr U = TF_DerivedOperandTypeAttr<1>; - - let extraClassDeclaration = [{ - // TF_FoldOperandsTransposeInterface: - SmallVector GetLayoutDependentArgs() { return {0}; } - SmallVector GetLayoutDependentResults() { return {0}; } - - // TF_LayoutSensitiveInterface: - }]; } def TF_GatherOp : TF_Op<"Gather", [NoSideEffect]> { @@ -4493,12 +4848,13 @@ See also `tf.gather` and `tf.batch_gather`. }]; let arguments = (ins - TF_Tensor:$params, - TF_I32OrI64Tensor:$indices + Arg:$params, + Arg:$indices ); let results = (outs - TF_Tensor:$output + Res:$output ); TF_DerivedOperandTypeAttr Tindices = TF_DerivedOperandTypeAttr<1>; @@ -4541,15 +4897,18 @@ See also `tf.batch_gather` and `tf.gather_nd`. }]; let arguments = (ins - TF_Tensor:$params, - TF_I32OrI64Tensor:$indices, - TF_I32OrI64Tensor:$axis, + Arg:$params, + Arg:$indices, + Arg:$axis, DefaultValuedAttr:$batch_dims ); let results = (outs - TF_Tensor:$output + Res:$output ); TF_DerivedOperandTypeAttr Tindices = TF_DerivedOperandTypeAttr<1>; @@ -4639,11 +4998,11 @@ See `rgb_to_hsv` for a description of the HSV encoding. }]; let arguments = (ins - TF_FloatTensor:$images + Arg:$images ); let results = (outs - TF_FloatTensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -4667,7 +5026,7 @@ table will be immutable. ); let results = (outs - Res:$table_handle + Res:$table_handle ); } @@ -4680,11 +5039,16 @@ inner-most dimension of `input`. }]; let arguments = (ins - TensorOf<[TF_Complex128, TF_Complex64]>:$input + Arg, [{A complex tensor.}]>:$input ); let results = (outs - TensorOf<[TF_Complex128, TF_Complex64]>:$output + Res, [{A complex tensor of the same shape as `input`. The inner-most + dimension of `input` is replaced with its inverse 1D Fourier transform. + +@compatibility(numpy) +Equivalent to np.fft.ifft +@end_compatibility}]>:$output ); TF_DerivedOperandTypeAttr Tcomplex = TF_DerivedOperandTypeAttr<0>; @@ -4699,11 +5063,16 @@ inner-most 2 dimensions of `input`. }]; let arguments = (ins - TensorOf<[TF_Complex128, TF_Complex64]>:$input + Arg, [{A complex tensor.}]>:$input ); let results = (outs - TensorOf<[TF_Complex128, TF_Complex64]>:$output + Res, [{A complex tensor of the same shape as `input`. The inner-most 2 + dimensions of `input` are replaced with their inverse 2D Fourier transform. + +@compatibility(numpy) +Equivalent to np.fft.ifft2 +@end_compatibility}]>:$output ); TF_DerivedOperandTypeAttr Tcomplex = TF_DerivedOperandTypeAttr<0>; @@ -4718,11 +5087,16 @@ inner-most 3 dimensions of `input`. }]; let arguments = (ins - TensorOf<[TF_Complex128, TF_Complex64]>:$input + Arg, [{A complex tensor.}]>:$input ); let results = (outs - TensorOf<[TF_Complex128, TF_Complex64]>:$output + Res, [{A complex tensor of the same shape as `input`. The inner-most 3 + dimensions of `input` are replaced with their inverse 3D Fourier transform. + +@compatibility(numpy) +Equivalent to np.fft.ifftn with 3 dimensions. +@end_compatibility}]>:$output ); TF_DerivedOperandTypeAttr Tcomplex = TF_DerivedOperandTypeAttr<0>; @@ -4748,12 +5122,18 @@ larger, the dimension is padded with zeros. }]; let arguments = (ins - TensorOf<[TF_Complex128, TF_Complex64]>:$input, - TF_Int32Tensor:$fft_length + Arg, [{A complex tensor.}]>:$input, + Arg:$fft_length ); let results = (outs - TF_F32OrF64Tensor:$output + Res:$output ); TF_DerivedResultTypeAttr Treal = TF_DerivedResultTypeAttr<0>; @@ -4781,12 +5161,18 @@ the dimension is padded with zeros. }]; let arguments = (ins - TensorOf<[TF_Complex128, TF_Complex64]>:$input, - TF_Int32Tensor:$fft_length + Arg, [{A complex tensor.}]>:$input, + Arg:$fft_length ); let results = (outs - TF_F32OrF64Tensor:$output + Res:$output ); TF_DerivedResultTypeAttr Treal = TF_DerivedResultTypeAttr<0>; @@ -4814,12 +5200,18 @@ the dimension is padded with zeros. }]; let arguments = (ins - TensorOf<[TF_Complex128, TF_Complex64]>:$input, - TF_Int32Tensor:$fft_length + Arg, [{A complex tensor.}]>:$input, + Arg:$fft_length ); let results = (outs - TF_F32OrF64Tensor:$output + Res:$output ); TF_DerivedResultTypeAttr Treal = TF_DerivedResultTypeAttr<0>; @@ -4993,13 +5385,13 @@ $$out_i = predictions_{i, targets_i} \in TopKIncludingTies(predictions_i)$$ }]; let arguments = (ins - TF_Float32Tensor:$predictions, - TF_I32OrI64Tensor:$targets, - TF_I32OrI64Tensor:$k + Arg:$predictions, + Arg:$targets, + Arg:$k ); let results = (outs - TF_BoolTensor:$precision + Res:$precision ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<1>; @@ -5015,7 +5407,7 @@ A placeholder op for a value that will be fed into the computation. ); let results = (outs - TF_Tensor:$output + Res:$output ); TF_DerivedResultTypeAttr dtype = TF_DerivedResultTypeAttr<0>; @@ -5027,9 +5419,9 @@ Table initializer that takes two tensors for keys and values respectively. }]; let arguments = (ins - Arg:$table_handle, - TF_Tensor:$keys, - TF_Tensor:$values + Arg:$table_handle, + Arg:$keys, + Arg:$values ); let results = (outs); @@ -5038,7 +5430,7 @@ Table initializer that takes two tensors for keys and values respectively. TF_DerivedOperandTypeAttr Tkey = TF_DerivedOperandTypeAttr<1>; } -def TF_InplaceAddOp : TF_Op<"InplaceAdd", [AllTypesMatch<["x", "y"]>, NoSideEffect]> { +def TF_InplaceAddOp : TF_Op<"InplaceAdd", [NoSideEffect, TF_AllTypesMatch<["x", "y"]>]> { let summary = "Adds v into specified rows of x."; let description = [{ @@ -5046,13 +5438,13 @@ Computes y = x; y[i, :] += v; return y. }]; let arguments = (ins - TF_Tensor:$x, - TF_Int32Tensor:$i, - TF_Tensor:$v + Arg:$x, + Arg:$i, + Arg:$v ); let results = (outs - TF_Tensor:$y + Res:$y ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -5069,19 +5461,19 @@ operation create / operate on a copy of `x`. }]; let arguments = (ins - TF_Tensor:$x, - TF_Int32Tensor:$i, - TF_Tensor:$v + Arg:$x, + Arg:$i, + Arg:$v ); let results = (outs - TF_Tensor:$y + Res:$y ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; } -def TF_InvOp : TF_Op<"Inv", [NoSideEffect, SameOperandsAndResultType]> { +def TF_InvOp : TF_Op<"Inv", [NoSideEffect, TF_SameOperandsAndResultTypeResolveRef]> { let summary = "Computes the reciprocal of x element-wise."; let description = [{ @@ -5179,11 +5571,11 @@ invert_permutation(x) ==> [2, 4, 3, 0, 1] }]; let arguments = (ins - TF_I32OrI64Tensor:$x + Arg:$x ); let results = (outs - TF_I32OrI64Tensor:$y + Res:$y ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -5285,7 +5677,8 @@ def TF_IteratorOp : TF_Op<"Iterator", []> { ); let results = (outs - Res:$handle + Res:$handle ); } @@ -5295,14 +5688,14 @@ Converts the given string representing a handle to an iterator to a resource. }]; let arguments = (ins - TF_StrTensor:$string_handle, + Arg:$string_handle, DefaultValuedAttr:$output_types, DefaultValuedAttr:$output_shapes ); let results = (outs - Res:$resource_handle + Res:$resource_handle ); } @@ -5381,11 +5774,11 @@ Converts the given `resource_handle` representing an iterator to a string. }]; let arguments = (ins - Arg:$resource_handle + Arg:$resource_handle ); let results = (outs - TF_StrTensor:$string_handle + Res:$string_handle ); } @@ -5445,11 +5838,11 @@ Computes half the L2 norm of a tensor without the `sqrt`: }]; let arguments = (ins - TF_FloatTensor:$t + Arg:$t ); let results = (outs - TF_FloatTensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -5473,7 +5866,7 @@ convolutional neural networks (NIPS 2012)](http://papers.nips.cc/paper/4824-imag }]; let arguments = (ins - TensorOf<[TF_Bfloat16, TF_Float16, TF_Float32]>:$input, + Arg, [{4-D.}]>:$input, DefaultValuedAttr:$depth_radius, DefaultValuedAttr:$bias, @@ -5492,9 +5885,9 @@ def TF_LRNGradOp : TF_Op<"LRNGrad", [NoSideEffect]> { let summary = "Gradients for Local Response Normalization."; let arguments = (ins - TensorOf<[TF_Bfloat16, TF_Float16, TF_Float32]>:$input_grads, - TensorOf<[TF_Bfloat16, TF_Float16, TF_Float32]>:$input_image, - TensorOf<[TF_Bfloat16, TF_Float16, TF_Float32]>:$output_image, + Arg, [{4-D with shape `[batch, height, width, channels]`.}]>:$input_grads, + Arg, [{4-D with shape `[batch, height, width, channels]`.}]>:$input_image, + Arg, [{4-D with shape `[batch, height, width, channels]`.}]>:$output_image, DefaultValuedAttr:$depth_radius, DefaultValuedAttr:$bias, @@ -5503,13 +5896,13 @@ def TF_LRNGradOp : TF_Op<"LRNGrad", [NoSideEffect]> { ); let results = (outs - TensorOf<[TF_Bfloat16, TF_Float16, TF_Float32]>:$output + Res, [{The gradients for LRN.}]>:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; } -def TF_LeakyReluOp : TF_Op<"LeakyRelu", [NoSideEffect, SameOperandsAndResultType]> { +def TF_LeakyReluOp : TF_Op<"LeakyRelu", [NoSideEffect, TF_SameOperandsAndResultTypeResolveRef]> { let summary = "Computes rectified linear: `max(features, features * alpha)`."; let arguments = (ins @@ -5523,27 +5916,23 @@ def TF_LeakyReluOp : TF_Op<"LeakyRelu", [NoSideEffect, SameOperandsAndResultType ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; - - - let extraClassDeclaration = [{ - // TF_ContractionFusableInterface: - }]; } -def TF_LeakyReluGradOp : TF_Op<"LeakyReluGrad", [NoSideEffect, SameOperandsAndResultType]> { +def TF_LeakyReluGradOp : TF_Op<"LeakyReluGrad", [NoSideEffect, TF_SameOperandsAndResultTypeResolveRef]> { let summary = [{ Computes rectified linear gradients for a LeakyRelu operation. }]; let arguments = (ins - TF_FloatTensor:$gradients, - TF_FloatTensor:$features, + Arg:$gradients, + Arg:$features, DefaultValuedAttr:$alpha ); let results = (outs - TF_FloatTensor:$backprops + Res 0) + alpha * gradients * (features <= 0)`.}]>:$backprops ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -5664,7 +6053,7 @@ tf.math.less_equal(x, y) ==> [True, True, True] TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; } -def TF_LgammaOp : TF_Op<"Lgamma", [NoSideEffect, SameOperandsAndResultType]> { +def TF_LgammaOp : TF_Op<"Lgamma", [NoSideEffect, TF_SameOperandsAndResultTypeResolveRef]> { let summary = [{ Computes the log of the absolute value of `Gamma(x)` element-wise. }]; @@ -5708,13 +6097,13 @@ tf.linspace(10.0, 12.0, 3, name="linspace") => [ 10.0 11.0 12.0] }]; let arguments = (ins - TF_FloatTensor:$start, - TF_FloatTensor:$stop, - TF_I32OrI64Tensor:$num + Arg:$start, + Arg:$stop, + Arg:$num ); let results = (outs - TF_FloatTensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -5751,13 +6140,13 @@ idx ==> [1, 3, 5] }]; let arguments = (ins - TF_Tensor:$x, - TF_Tensor:$y + Arg:$x, + Arg:$y ); let results = (outs - TF_Tensor:$out, - TF_I32OrI64Tensor:$idx + Res:$out, + Res:$idx ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -5776,9 +6165,9 @@ executed. }]; let arguments = (ins - TF_Float32Tensor:$parameters, - TF_Float32Tensor:$momenta, - TF_Float32Tensor:$velocities, + Arg:$parameters, + Arg:$momenta, + Arg:$velocities, DefaultValuedAttr:$table_id, StrAttr:$table_name, @@ -5802,10 +6191,10 @@ executed. }]; let arguments = (ins - TF_Float32Tensor:$parameters, - TF_Float32Tensor:$momenta, - TF_Float32Tensor:$velocities, - TF_Float32Tensor:$gradient_accumulators, + Arg:$parameters, + Arg:$momenta, + Arg:$velocities, + Arg:$gradient_accumulators, DefaultValuedAttr:$table_id, StrAttr:$table_name, @@ -5829,9 +6218,9 @@ executed. }]; let arguments = (ins - TF_Float32Tensor:$parameters, - TF_Float32Tensor:$accumulators, - TF_Float32Tensor:$updates, + Arg:$parameters, + Arg:$accumulators, + Arg:$updates, DefaultValuedAttr:$table_id, StrAttr:$table_name, @@ -5855,10 +6244,10 @@ executed. }]; let arguments = (ins - TF_Float32Tensor:$parameters, - TF_Float32Tensor:$accumulators, - TF_Float32Tensor:$updates, - TF_Float32Tensor:$gradient_accumulators, + Arg:$parameters, + Arg:$accumulators, + Arg:$updates, + Arg:$gradient_accumulators, DefaultValuedAttr:$table_id, StrAttr:$table_name, @@ -5882,8 +6271,8 @@ executed. }]; let arguments = (ins - TF_Float32Tensor:$parameters, - TF_Float32Tensor:$accumulators, + Arg:$parameters, + Arg:$accumulators, DefaultValuedAttr:$table_id, StrAttr:$table_name, @@ -5907,9 +6296,9 @@ executed. }]; let arguments = (ins - TF_Float32Tensor:$parameters, - TF_Float32Tensor:$accumulators, - TF_Float32Tensor:$gradient_accumulators, + Arg:$parameters, + Arg:$accumulators, + Arg:$gradient_accumulators, DefaultValuedAttr:$table_id, StrAttr:$table_name, @@ -5933,10 +6322,10 @@ executed. }]; let arguments = (ins - TF_Float32Tensor:$parameters, - TF_Float32Tensor:$ms, - TF_Float32Tensor:$mom, - TF_Float32Tensor:$mg, + Arg:$parameters, + Arg:$ms, + Arg:$mom, + Arg:$mg, DefaultValuedAttr:$table_id, StrAttr:$table_name, @@ -5960,9 +6349,9 @@ executed. }]; let arguments = (ins - TF_Float32Tensor:$parameters, - TF_Float32Tensor:$accumulators, - TF_Float32Tensor:$linears, + Arg:$parameters, + Arg:$accumulators, + Arg:$linears, DefaultValuedAttr:$table_id, StrAttr:$table_name, @@ -5986,10 +6375,10 @@ executed. }]; let arguments = (ins - TF_Float32Tensor:$parameters, - TF_Float32Tensor:$accumulators, - TF_Float32Tensor:$linears, - TF_Float32Tensor:$gradient_accumulators, + Arg:$parameters, + Arg:$accumulators, + Arg:$linears, + Arg:$gradient_accumulators, DefaultValuedAttr:$table_id, StrAttr:$table_name, @@ -6013,10 +6402,10 @@ executed. }]; let arguments = (ins - TF_Float32Tensor:$parameters, - TF_Float32Tensor:$accumulators, - TF_Float32Tensor:$weights, - TF_Float32Tensor:$benefits, + Arg:$parameters, + Arg:$accumulators, + Arg:$weights, + Arg:$benefits, DefaultValuedAttr:$table_id, StrAttr:$table_name, @@ -6040,8 +6429,8 @@ executed. }]; let arguments = (ins - TF_Float32Tensor:$parameters, - TF_Float32Tensor:$momenta, + Arg:$parameters, + Arg:$momenta, DefaultValuedAttr:$table_id, StrAttr:$table_name, @@ -6065,9 +6454,9 @@ executed. }]; let arguments = (ins - TF_Float32Tensor:$parameters, - TF_Float32Tensor:$momenta, - TF_Float32Tensor:$gradient_accumulators, + Arg:$parameters, + Arg:$momenta, + Arg:$gradient_accumulators, DefaultValuedAttr:$table_id, StrAttr:$table_name, @@ -6091,8 +6480,8 @@ executed. }]; let arguments = (ins - TF_Float32Tensor:$parameters, - TF_Float32Tensor:$accumulators, + Arg:$parameters, + Arg:$accumulators, DefaultValuedAttr:$table_id, StrAttr:$table_name, @@ -6118,9 +6507,9 @@ executed. }]; let arguments = (ins - TF_Float32Tensor:$parameters, - TF_Float32Tensor:$accumulators, - TF_Float32Tensor:$gradient_accumulators, + Arg:$parameters, + Arg:$accumulators, + Arg:$gradient_accumulators, DefaultValuedAttr:$table_id, StrAttr:$table_name, @@ -6181,9 +6570,9 @@ executed. }]; let arguments = (ins - TF_Float32Tensor:$parameters, - TF_Float32Tensor:$ms, - TF_Float32Tensor:$mom, + Arg:$parameters, + Arg:$ms, + Arg:$mom, DefaultValuedAttr:$table_id, StrAttr:$table_name, @@ -6207,10 +6596,10 @@ executed. }]; let arguments = (ins - TF_Float32Tensor:$parameters, - TF_Float32Tensor:$ms, - TF_Float32Tensor:$mom, - TF_Float32Tensor:$gradient_accumulators, + Arg:$parameters, + Arg:$ms, + Arg:$mom, + Arg:$gradient_accumulators, DefaultValuedAttr:$table_id, StrAttr:$table_name, @@ -6234,7 +6623,7 @@ executed. }]; let arguments = (ins - TF_Float32Tensor:$parameters, + Arg:$parameters, DefaultValuedAttr:$table_id, StrAttr:$table_name, @@ -6258,8 +6647,8 @@ executed. }]; let arguments = (ins - TF_Float32Tensor:$parameters, - TF_Float32Tensor:$gradient_accumulators, + Arg:$parameters, + Arg:$gradient_accumulators, DefaultValuedAttr:$table_id, StrAttr:$table_name, @@ -6294,7 +6683,6 @@ tf.math.log(x) ==> [-inf, -0.6931472, 0. , 1.609438] ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; - } def TF_Log1pOp : TF_Op<"Log1p", [NoSideEffect, SameOperandsAndResultType, TF_CwiseUnary]> { @@ -6332,11 +6720,11 @@ For each batch `i` and class `j` we have }]; let arguments = (ins - TF_FloatTensor:$logits + Arg:$logits ); let results = (outs - TF_FloatTensor:$logsoftmax + Res:$logsoftmax ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -6365,13 +6753,12 @@ def TF_LogicalNotOp : TF_Op<"LogicalNot", [Involution, NoSideEffect, SameOperand let summary = "Returns the truth value of `NOT x` element-wise."; let arguments = (ins - TF_BoolTensor:$x + Arg:$x ); let results = (outs - TF_BoolTensor:$y + Res:$y ); - } def TF_LogicalOrOp : TF_Op<"LogicalOr", [Commutative, NoSideEffect, ResultsBroadcastableShape]>, @@ -6397,12 +6784,12 @@ def TF_LookupTableExportV2Op : TF_Op<"LookupTableExportV2", []> { let summary = "Outputs all keys and values in the table."; let arguments = (ins - Arg:$table_handle + Arg:$table_handle ); let results = (outs - TF_Tensor:$keys, - TF_Tensor:$values + Res:$keys, + Res:$values ); TF_DerivedResultTypeAttr Tkeys = TF_DerivedResultTypeAttr<0>; @@ -6421,13 +6808,14 @@ table. It must also be of the same type as the table values. }]; let arguments = (ins - Arg:$table_handle, - TF_Tensor:$keys, + Arg:$table_handle, + Arg:$keys, TF_Tensor:$default_value ); let results = (outs - TF_Tensor:$values + Res:$values ); TF_DerivedOperandTypeAttr Tin = TF_DerivedOperandTypeAttr<1>; @@ -6445,9 +6833,9 @@ The tensor `values` must be of the type of the table values. }]; let arguments = (ins - Arg:$table_handle, - TF_Tensor:$keys, - TF_Tensor:$values + Arg:$table_handle, + Arg:$keys, + Arg:$values ); let results = (outs); @@ -6465,9 +6853,9 @@ The tensor `values` must be of the type of the table values. }]; let arguments = (ins - Arg:$table_handle, - TF_Tensor:$keys, - TF_Tensor:$values + Arg:$table_handle, + Arg:$keys, + Arg:$values ); let results = (outs); @@ -6485,8 +6873,8 @@ already in the table are silently ignored. }]; let arguments = (ins - Arg:$table_handle, - TF_Tensor:$keys + Arg:$table_handle, + Arg:$keys ); let results = (outs); @@ -6498,11 +6886,11 @@ def TF_LookupTableSizeV2Op : TF_Op<"LookupTableSizeV2", []> { let summary = "Computes the number of elements in the given table."; let arguments = (ins - TF_ResourceTensor:$table_handle + Arg:$table_handle ); let results = (outs - TF_Int64Tensor:$size + Res:$size ); } @@ -6532,12 +6920,15 @@ A 2-D example: }]; let arguments = (ins - TF_Tensor:$sorted_inputs, - TF_Tensor:$values + Arg:$sorted_inputs, + Arg:$values ); let results = (outs - TF_I32OrI64Tensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -6634,9 +7025,9 @@ For example: ``` # if 'input' is [[ 0, 1, 2, 3] - [-1, 0, 1, 2] - [-2, -1, 0, 1] - [-3, -2, -1, 0]], +# [-1, 0, 1, 2] +# [-2, -1, 0, 1] +# [-3, -2, -1, 0]], tf.matrix_band_part(input, 1, -1) ==> [[ 0, 1, 2, 3] [-1, 0, 1, 2] @@ -6659,13 +7050,15 @@ Useful special cases: }]; let arguments = (ins - TF_Tensor:$input, - TF_I32OrI64Tensor:$num_lower, - TF_I32OrI64Tensor:$num_upper + Arg:$input, + Arg:$num_lower, + Arg:$num_upper ); let results = (outs - TF_Tensor:$band + Res:$band ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -6711,11 +7104,11 @@ which has shape (2, 4, 4) }]; let arguments = (ins - TF_Tensor:$diagonal + Arg= 1`.}]>:$diagonal ); let results = (outs - TF_Tensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -6827,15 +7220,19 @@ tf.matrix_diag_part(input, k = (1, 3), padding_value = 9) }]; let arguments = (ins - TF_Tensor:$input, - TF_Int32Tensor:$k, - TF_Tensor:$padding_value, + Arg= 2`.}]>:$input, + Arg:$k, + Arg:$padding_value, DefaultValuedAttr, "RIGHT_LEFT">:$align ); let results = (outs - TF_Tensor:$diagonal + Res:$diagonal ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -6937,15 +7334,23 @@ tf.matrix_diag(diagonal, k = -1, num_rows = 3, padding_value = 9) }]; let arguments = (ins - TF_Tensor:$diagonal, - TF_Int32Tensor:$k, - TF_Int32Tensor:$num_rows, - TF_Int32Tensor:$num_cols, - TF_Tensor:$padding_value + Arg= 1`}]>:$diagonal, + Arg:$k, + Arg:$num_rows, + Arg:$num_cols, + Arg:$padding_value ); let results = (outs - TF_Tensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -7076,17 +7481,25 @@ tf.matrix_diag(diagonal, k = -1, num_rows = 3, padding_value = 9) }]; let arguments = (ins - TF_Tensor:$diagonal, - TF_Int32Tensor:$k, - TF_Int32Tensor:$num_rows, - TF_Int32Tensor:$num_cols, - TF_Tensor:$padding_value, + Arg= 1`}]>:$diagonal, + Arg:$k, + Arg:$num_rows, + Arg:$num_cols, + Arg:$padding_value, DefaultValuedAttr, "RIGHT_LEFT">:$align ); let results = (outs - TF_Tensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -7110,13 +7523,17 @@ garbage result. }]; let arguments = (ins - TensorOf<[TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64]>:$input, + Arg, [{Shape is `[..., M, M]`.}]>:$input, DefaultValuedAttr:$adjoint ); let results = (outs - TensorOf<[TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64]>:$output + Res, [{Shape is `[..., M, M]`. + +@compatibility(numpy) +Equivalent to np.linalg.inv +@end_compatibility}]>:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -7143,16 +7560,15 @@ tensor of rank `k+1` with dimensions `[I, J, K, ..., M, N]` where: }]; let arguments = (ins - TF_Tensor:$input, - TF_Tensor:$diagonal + Arg= 1`.}]>:$input, + Arg= 1`.}]>:$diagonal ); let results = (outs - TF_Tensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; - } def TF_MatrixSetDiagV2Op : TF_Op<"MatrixSetDiagV2", [NoSideEffect]> { @@ -7235,17 +7651,20 @@ tf.matrix_set_diag(diagonals, k = (-1, 0)) }]; let arguments = (ins - TF_Tensor:$input, - TF_Tensor:$diagonal, - TF_Int32Tensor:$k + Arg= 1`.}]>:$input, + Arg= 1`.}]>:$diagonal, + Arg:$k ); let results = (outs - TF_Tensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; - } def TF_MatrixSetDiagV3Op : TF_Op<"MatrixSetDiagV3", [NoSideEffect]> { @@ -7361,15 +7780,19 @@ tf.matrix_set_diag(input, diagonals, k = (-1, 2), align="LEFT_RIGHT") }]; let arguments = (ins - TF_Tensor:$input, - TF_Tensor:$diagonal, - TF_Int32Tensor:$k, + Arg= 1`.}]>:$input, + Arg= 1`.}]>:$diagonal, + Arg:$k, DefaultValuedAttr, "RIGHT_LEFT">:$align ); let results = (outs - TF_Tensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -7388,14 +7811,14 @@ If `adjoint` is `True` then each output matrix satisfies }]; let arguments = (ins - TensorOf<[TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64]>:$matrix, - TensorOf<[TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64]>:$rhs, + Arg, [{Shape is `[..., M, M]`.}]>:$matrix, + Arg, [{Shape is `[..., M, K]`.}]>:$rhs, DefaultValuedAttr:$adjoint ); let results = (outs - TensorOf<[TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64]>:$output + Res, [{Shape is `[..., M, K]`.}]>:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -7455,15 +7878,15 @@ tf.matmul(a, x) }]; let arguments = (ins - TensorOf<[TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64]>:$matrix, - TensorOf<[TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64]>:$rhs, + Arg, [{Shape is `[..., M, M]`.}]>:$matrix, + Arg, [{Shape is `[..., M, K]`.}]>:$rhs, DefaultValuedAttr:$lower, DefaultValuedAttr:$adjoint ); let results = (outs - TensorOf<[TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64]>:$output + Res, [{Shape is `[..., M, K]`.}]>:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -7482,21 +7905,22 @@ retained with length 1. }]; let arguments = (ins - TensorOf<[TF_Bfloat16, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint16, TF_Qint32, TF_Qint8, TF_Quint16, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$input, - TF_I32OrI64Tensor:$reduction_indices, + Arg, [{The tensor to reduce.}]>:$input, + Arg:$reduction_indices, DefaultValuedAttr:$keep_dims ); let results = (outs - TensorOf<[TF_Bfloat16, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint16, TF_Qint32, TF_Qint8, TF_Quint16, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$output + Res, [{The reduced tensor.}]>:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; TF_DerivedOperandTypeAttr Tidx = TF_DerivedOperandTypeAttr<1>; let builders = [ - OpBuilderDAG<(ins "Value":$input, "Value":$reduction_indices, + OpBuilder<(ins "Value":$input, "Value":$reduction_indices, "BoolAttr":$keep_dims)> ]; } @@ -7505,7 +7929,7 @@ def TF_MaxPoolOp : TF_Op<"MaxPool", [NoSideEffect]> { let summary = "Performs max pooling on the input."; let arguments = (ins - TensorOf<[TF_Bfloat16, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint8, TF_Uint16, TF_Uint8]>:$input, + Arg, [{4-D input to pool over.}]>:$input, Confined]>:$ksize, Confined]>:$strides, @@ -7515,24 +7939,17 @@ def TF_MaxPoolOp : TF_Op<"MaxPool", [NoSideEffect]> { ); let results = (outs - TensorOf<[TF_Bfloat16, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint8, TF_Uint16, TF_Uint8]>:$output + Res, [{The max pooled output tensor.}]>:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; - - let extraClassDeclaration = [{ - // TF_FoldOperandsTransposeInterface: - SmallVector GetLayoutDependentArgs() { return {0}; } - SmallVector GetLayoutDependentResults() { return {0}; } - // TF_LayoutSensitiveInterface: - }]; } def TF_MaxPool3DOp : TF_Op<"MaxPool3D", [NoSideEffect]> { let summary = "Performs 3D max pooling on the input."; let arguments = (ins - TensorOf<[TF_Bfloat16, TF_Float16, TF_Float32]>:$input, + Arg, [{Shape `[batch, depth, rows, cols, channels]` tensor to pool over.}]>:$input, Confined]>:$ksize, Confined]>:$strides, @@ -7541,7 +7958,7 @@ def TF_MaxPool3DOp : TF_Op<"MaxPool3D", [NoSideEffect]> { ); let results = (outs - TensorOf<[TF_Bfloat16, TF_Float16, TF_Float32]>:$output + Res, [{The max pooled output tensor.}]>:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -7551,9 +7968,9 @@ def TF_MaxPool3DGradOp : TF_Op<"MaxPool3DGrad", [NoSideEffect]> { let summary = "Computes gradients of 3D max pooling function."; let arguments = (ins - TensorOf<[TF_Bfloat16, TF_Float16, TF_Float32]>:$orig_input, - TensorOf<[TF_Bfloat16, TF_Float16, TF_Float32]>:$orig_output, - TensorOf<[TF_Bfloat16, TF_Float16, TF_Float32]>:$grad, + Arg, [{The original input tensor.}]>:$orig_input, + Arg, [{The original output tensor.}]>:$orig_output, + Arg, [{Output backprop of shape `[batch, depth, rows, cols, channels]`.}]>:$grad, Confined]>:$ksize, Confined]>:$strides, @@ -7573,9 +7990,9 @@ def TF_MaxPool3DGradGradOp : TF_Op<"MaxPool3DGradGrad", [NoSideEffect]> { let summary = "Computes second-order gradients of the maxpooling function."; let arguments = (ins - TF_IntOrFpTensor:$orig_input, - TF_IntOrFpTensor:$orig_output, - TF_IntOrFpTensor:$grad, + Arg:$orig_input, + Arg:$orig_output, + Arg:$grad, Confined]>:$ksize, Confined]>:$strides, @@ -7584,7 +8001,7 @@ def TF_MaxPool3DGradGradOp : TF_Op<"MaxPool3DGradGrad", [NoSideEffect]> { ); let results = (outs - TF_IntOrFpTensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -7594,9 +8011,9 @@ def TF_MaxPoolGradOp : TF_Op<"MaxPoolGrad", [NoSideEffect]> { let summary = "Computes gradients of the maxpooling function."; let arguments = (ins - TF_IntOrFpTensor:$orig_input, - TF_IntOrFpTensor:$orig_output, - TF_IntOrFpTensor:$grad, + Arg:$orig_input, + Arg:$orig_output, + Arg:$grad, Confined]>:$ksize, Confined]>:$strides, @@ -7606,7 +8023,7 @@ def TF_MaxPoolGradOp : TF_Op<"MaxPoolGrad", [NoSideEffect]> { ); let results = (outs - TF_IntOrFpTensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -7620,9 +8037,9 @@ def TF_MaxPoolGradGradOp : TF_Op<"MaxPoolGradGrad", [NoSideEffect]> { let summary = "Computes second-order gradients of the maxpooling function."; let arguments = (ins - TF_IntOrFpTensor:$orig_input, - TF_IntOrFpTensor:$orig_output, - TF_IntOrFpTensor:$grad, + Arg:$orig_input, + Arg:$orig_output, + Arg:$grad, Confined]>:$ksize, Confined]>:$strides, @@ -7631,7 +8048,7 @@ def TF_MaxPoolGradGradOp : TF_Op<"MaxPoolGradGrad", [NoSideEffect]> { ); let results = (outs - TF_IntOrFpTensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -7641,18 +8058,19 @@ def TF_MaxPoolGradGradV2Op : TF_Op<"MaxPoolGradGradV2", [NoSideEffect]> { let summary = "Computes second-order gradients of the maxpooling function."; let arguments = (ins - TF_IntOrFpTensor:$orig_input, - TF_IntOrFpTensor:$orig_output, - TF_IntOrFpTensor:$grad, - TF_Int32Tensor:$ksize, - TF_Int32Tensor:$strides, + Arg:$orig_input, + Arg:$orig_output, + Arg:$grad, + Arg:$ksize, + Arg:$strides, TF_AnyStrAttrOf<["SAME", "VALID"]>:$padding, DefaultValuedAttr:$data_format ); let results = (outs - TF_IntOrFpTensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -7662,18 +8080,19 @@ def TF_MaxPoolGradV2Op : TF_Op<"MaxPoolGradV2", [NoSideEffect]> { let summary = "Computes gradients of the maxpooling function."; let arguments = (ins - TF_IntOrFpTensor:$orig_input, - TF_IntOrFpTensor:$orig_output, - TF_IntOrFpTensor:$grad, - TF_Int32Tensor:$ksize, - TF_Int32Tensor:$strides, + Arg:$orig_input, + Arg:$orig_output, + Arg:$grad, + Arg:$ksize, + Arg:$strides, TF_AnyStrAttrOf<["SAME", "VALID"]>:$padding, DefaultValuedAttr:$data_format ); let results = (outs - TF_IntOrFpTensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -7683,16 +8102,17 @@ def TF_MaxPoolV2Op : TF_Op<"MaxPoolV2", [NoSideEffect]> { let summary = "Performs max pooling on the input."; let arguments = (ins - TensorOf<[TF_Bfloat16, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint8, TF_Uint16, TF_Uint8]>:$input, - TF_Int32Tensor:$ksize, - TF_Int32Tensor:$strides, + Arg, [{4-D input to pool over.}]>:$input, + Arg:$ksize, + Arg:$strides, TF_AnyStrAttrOf<["SAME", "VALID"]>:$padding, DefaultValuedAttr, "NHWC">:$data_format ); let results = (outs - TensorOf<[TF_Bfloat16, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint8, TF_Uint16, TF_Uint8]>:$output + Res, [{The max pooled output tensor.}]>:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -7709,24 +8129,19 @@ retained with length 1. }]; let arguments = (ins - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$input, - TF_I32OrI64Tensor:$reduction_indices, + Arg, [{The tensor to reduce.}]>:$input, + Arg:$reduction_indices, DefaultValuedAttr:$keep_dims ); let results = (outs - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$output + Res, [{The reduced tensor.}]>:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; TF_DerivedOperandTypeAttr Tidx = TF_DerivedOperandTypeAttr<1>; - - let extraClassDeclaration = [{ - // TF_FoldOperandsTransposeInterface: - SmallVector GetLayoutDependentArgs() { return {0}; } - SmallVector GetLayoutDependentResults() { return {}; } - }]; } def TF_MergeSummaryOp : TF_Op<"MergeSummary", [NoSideEffect, SameOperandsAndResultType]> { @@ -7743,11 +8158,12 @@ in the summaries to merge use the same tag. }]; let arguments = (ins - Variadic:$inputs + Arg, [{Can be of any shape. Each must contain serialized `Summary` protocol +buffers.}]>:$inputs ); let results = (outs - TF_StrTensor:$summary + Res:$summary ); TF_DerivedOperandSizeAttr N = TF_DerivedOperandSizeAttr<0>; @@ -7770,8 +8186,9 @@ user-facing temporary locations. }]; let arguments = (ins - TF_StrTensor:$checkpoint_prefixes, - TF_StrTensor:$destination_prefix, + Arg:$checkpoint_prefixes, + Arg:$destination_prefix, DefaultValuedAttr:$delete_old_dirs ); @@ -7792,14 +8209,15 @@ retained with length 1. }]; let arguments = (ins - TensorOf<[TF_Bfloat16, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint16, TF_Qint32, TF_Qint8, TF_Quint16, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$input, - TF_I32OrI64Tensor:$reduction_indices, + Arg, [{The tensor to reduce.}]>:$input, + Arg:$reduction_indices, DefaultValuedAttr:$keep_dims ); let results = (outs - TensorOf<[TF_Bfloat16, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint16, TF_Qint32, TF_Qint8, TF_Quint16, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$output + Res, [{The reduced tensor.}]>:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -7827,7 +8245,7 @@ def TF_MinimumOp : TF_Op<"Minimum", [NoSideEffect, ResultsBroadcastableShape, TF TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; } -def TF_MirrorPadOp : TF_Op<"MirrorPad", [NoSideEffect]> { +def TF_MirrorPadOp : TF_Op<"MirrorPad", [NoSideEffect, TF_OperandHasRank<1, 2>]> { let summary = "Pads a tensor with mirrored values."; let description = [{ @@ -7859,21 +8277,22 @@ pad(t, paddings) ==> [[2, 1, 1, 2, 3, 3, 2] }]; let arguments = (ins - TF_Tensor:$input, - TF_I32OrI64Tensor:$paddings, + Arg:$input, + Arg:$paddings, TF_AnyStrAttrOf<["REFLECT", "SYMMETRIC"]>:$mode ); let results = (outs - TF_Tensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; TF_DerivedOperandTypeAttr Tpaddings = TF_DerivedOperandTypeAttr<1>; } -def TF_MirrorPadGradOp : TF_Op<"MirrorPadGrad", [NoSideEffect]> { +def TF_MirrorPadGradOp : TF_Op<"MirrorPadGrad", [NoSideEffect, TF_OperandHasRank<1, 2>]> { let summary = [{ Gradient op for `MirrorPad` op. This op folds a mirror-padded tensor. }]; @@ -7900,14 +8319,15 @@ pad(t, paddings) ==> [[ 1, 5] }]; let arguments = (ins - TF_Tensor:$input, - TF_I32OrI64Tensor:$paddings, + Arg:$input, + Arg:$paddings, TF_AnyStrAttrOf<["REFLECT", "SYMMETRIC"]>:$mode ); let results = (outs - TF_Tensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -8006,6 +8426,28 @@ the result here is consistent with a truncating divide. E.g. TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; } +def TF_ModelDatasetOp : TF_Op<"ModelDataset", [NoSideEffect]> { + let summary = "Identity transformation that models performance."; + + let description = [{ +Identity transformation that models performance. + }]; + + let arguments = (ins + Arg:$input_dataset, + + DefaultValuedAttr:$algorithm, + DefaultValuedAttr:$cpu_budget, + DefaultValuedAttr:$ram_budget, + Confined]>:$output_types, + Confined]>:$output_shapes + ); + + let results = (outs + TF_VariantTensor:$handle + ); +} + def TF_MulOp : TF_Op<"Mul", [Commutative, NoSideEffect, ResultsBroadcastableShape, TF_CwiseBinary, TF_SameOperandsAndResultElementTypeResolveRef]>, WithBroadcastableBinOpBuilder { let summary = "Returns x * y element-wise."; @@ -8016,16 +8458,15 @@ def TF_MulOp : TF_Op<"Mul", [Commutative, NoSideEffect, ResultsBroadcastableShap }]; let arguments = (ins - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Uint16, TF_Uint8]>:$x, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Uint16, TF_Uint8]>:$y + TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$x, + TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$y ); let results = (outs - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Uint16, TF_Uint8]>:$z + TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$z ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; - } def TF_MulNoNanOp : TF_Op<"MulNoNan", [NoSideEffect, ResultsBroadcastableShape]>, @@ -8063,7 +8504,7 @@ def TF_MultiDeviceIteratorOp : TF_Op<"MultiDeviceIterator", []> { ); let results = (outs - Res:$handle + Res:$handle ); } @@ -8073,14 +8514,14 @@ Generates a MultiDeviceIterator resource from its provided string handle. }]; let arguments = (ins - TF_StrTensor:$string_handle, + Arg:$string_handle, DefaultValuedAttr:$output_types, DefaultValuedAttr:$output_shapes ); let results = (outs - Res:$multi_device_iterator + Res:$multi_device_iterator ); } @@ -8088,13 +8529,13 @@ def TF_MultiDeviceIteratorGetNextFromShardOp : TF_Op<"MultiDeviceIteratorGetNext let summary = "Gets next element for the provided shard number."; let arguments = (ins - Arg:$multi_device_iterator, - TF_Int32Tensor:$shard_num, - TF_Int64Tensor:$incarnation_id + Arg:$multi_device_iterator, + Arg:$shard_num, + Arg:$incarnation_id ); let results = (outs - Variadic:$components + Res, [{Result of the get_next on the dataset.}]>:$components ); TF_DerivedResultShapeListAttr output_shapes = TF_DerivedResultShapeListAttr<0>; @@ -8105,13 +8546,14 @@ def TF_MultiDeviceIteratorInitOp : TF_Op<"MultiDeviceIteratorInit", []> { let summary = "Initializes the multi device iterator with the given dataset."; let arguments = (ins - TF_VariantTensor:$dataset, - Arg:$multi_device_iterator, - TF_Int64Tensor:$max_buffer_size + Arg:$dataset, + Arg:$multi_device_iterator, + Arg:$max_buffer_size ); let results = (outs - TF_Int64Tensor:$incarnation_id + Res:$incarnation_id ); } @@ -8119,11 +8561,11 @@ def TF_MultiDeviceIteratorToStringHandleOp : TF_Op<"MultiDeviceIteratorToStringH let summary = "Produces a string handle for the given MultiDeviceIterator."; let arguments = (ins - Arg:$multi_device_iterator + Arg:$multi_device_iterator ); let results = (outs - TF_StrTensor:$string_handle + Res:$string_handle ); } @@ -8131,15 +8573,17 @@ def TF_MultinomialOp : TF_Op<"Multinomial", [TF_CannotDuplicate]> { let summary = "Draws samples from a multinomial distribution."; let arguments = (ins - TF_IntOrFpTensor:$logits, - TF_Int32Tensor:$num_samples, + Arg:$logits, + Arg:$num_samples, DefaultValuedAttr:$seed, DefaultValuedAttr:$seed2 ); let results = (outs - TF_I32OrI64Tensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -8161,7 +8605,8 @@ the insert operations. It does not support the initialization operation. }]; let arguments = (ins - TF_Tensor:$empty_key, + Arg:$empty_key, TF_Tensor:$deleted_key, StrAttr:$container, @@ -8174,7 +8619,7 @@ the insert operations. It does not support the initialization operation. ); let results = (outs - Res:$table_handle + Res:$table_handle ); TF_DerivedOperandTypeAttr key_dtype = TF_DerivedOperandTypeAttr<0>; @@ -8199,7 +8644,7 @@ the insert operations. It does not support the initialization operation. ); let results = (outs - Res:$table_handle + Res:$table_handle ); } @@ -8221,7 +8666,7 @@ the insert operations. It does not support the initialization operation. ); let results = (outs - Res:$table_handle + Res:$table_handle ); } @@ -8319,20 +8764,24 @@ using the `tf.gather operation`. For example: }]; let arguments = (ins - TensorOf<[TF_Float16, TF_Float32]>:$boxes, - TensorOf<[TF_Float16, TF_Float32]>:$scores, - TF_Int32Tensor:$max_output_size, - TensorOf<[TF_Float16, TF_Float32]>:$iou_threshold, - TensorOf<[TF_Float16, TF_Float32]>:$score_threshold + Arg, [{A 2-D float tensor of shape `[num_boxes, 4]`.}]>:$boxes, + Arg, [{A 1-D float tensor of shape `[num_boxes]` representing a single +score corresponding to each box (each row of boxes).}]>:$scores, + Arg:$max_output_size, + Arg, [{A 0-D float tensor representing the threshold for deciding whether +boxes overlap too much with respect to IOU.}]>:$iou_threshold, + Arg, [{A 0-D float tensor representing the threshold for deciding when to remove +boxes based on score.}]>:$score_threshold ); let results = (outs - TF_Int32Tensor:$selected_indices + Res:$selected_indices ); TF_DerivedOperandTypeAttr T_threshold = TF_DerivedOperandTypeAttr<3>; TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; - } def TF_NonMaxSuppressionV4Op : TF_Op<"NonMaxSuppressionV4", [NoSideEffect]> { @@ -8361,18 +8810,24 @@ using the `tf.gather operation`. For example: }]; let arguments = (ins - TensorOf<[TF_Float16, TF_Float32]>:$boxes, - TensorOf<[TF_Float16, TF_Float32]>:$scores, - TF_Int32Tensor:$max_output_size, - TensorOf<[TF_Float16, TF_Float32]>:$iou_threshold, - TensorOf<[TF_Float16, TF_Float32]>:$score_threshold, + Arg, [{A 2-D float tensor of shape `[num_boxes, 4]`.}]>:$boxes, + Arg, [{A 1-D float tensor of shape `[num_boxes]` representing a single +score corresponding to each box (each row of boxes).}]>:$scores, + Arg:$max_output_size, + Arg, [{A 0-D float tensor representing the threshold for deciding whether +boxes overlap too much with respect to IOU.}]>:$iou_threshold, + Arg, [{A 0-D float tensor representing the threshold for deciding when to remove +boxes based on score.}]>:$score_threshold, DefaultValuedAttr:$pad_to_max_output_size ); let results = (outs - TF_Int32Tensor:$selected_indices, - TF_Int32Tensor:$valid_outputs + Res:$selected_indices, + Res:$valid_outputs ); TF_DerivedOperandTypeAttr T_threshold = TF_DerivedOperandTypeAttr<3>; @@ -8410,20 +8865,31 @@ larger than 0. }]; let arguments = (ins - TensorOf<[TF_Float16, TF_Float32]>:$boxes, - TensorOf<[TF_Float16, TF_Float32]>:$scores, - TF_Int32Tensor:$max_output_size, - TensorOf<[TF_Float16, TF_Float32]>:$iou_threshold, - TensorOf<[TF_Float16, TF_Float32]>:$score_threshold, - TensorOf<[TF_Float16, TF_Float32]>:$soft_nms_sigma, + Arg, [{A 2-D float tensor of shape `[num_boxes, 4]`.}]>:$boxes, + Arg, [{A 1-D float tensor of shape `[num_boxes]` representing a single +score corresponding to each box (each row of boxes).}]>:$scores, + Arg:$max_output_size, + Arg, [{A 0-D float tensor representing the threshold for deciding whether +boxes overlap too much with respect to IOU.}]>:$iou_threshold, + Arg, [{A 0-D float tensor representing the threshold for deciding when to remove +boxes based on score.}]>:$score_threshold, + Arg, [{A 0-D float tensor representing the sigma parameter for Soft NMS; see Bodla et +al (c.f. https://arxiv.org/abs/1704.04503). When `soft_nms_sigma=0.0` (which +is default), we fall back to standard (hard) NMS.}]>:$soft_nms_sigma, DefaultValuedAttr:$pad_to_max_output_size ); let results = (outs - TF_Int32Tensor:$selected_indices, - TensorOf<[TF_Float16, TF_Float32]>:$selected_scores, - TF_Int32Tensor:$valid_outputs + Res:$selected_indices, + Res, [{A 1-D float tensor of shape `[M]` representing the corresponding +scores for each selected box, where `M <= max_output_size`. Scores only differ +from corresponding input scores when using Soft NMS (i.e. when +`soft_nms_sigma>0`)}]>:$selected_scores, + Res:$valid_outputs ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -8451,7 +8917,7 @@ def TF_NotEqualOp : TF_Op<"NotEqual", [Commutative, NoSideEffect]> { TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; let builders = [ - OpBuilderDAG<(ins "Value":$x, "Value":$y, + OpBuilder<(ins "Value":$x, "Value":$y, "BoolAttr":$incompatible_shape_error)> ]; @@ -8554,23 +9020,23 @@ output = }]; let arguments = (ins - TensorOf<[TF_Int32, TF_Int64, TF_Uint8]>:$indices, - TF_Int32Tensor:$depth, - TF_Tensor:$on_value, - TF_Tensor:$off_value, + Arg, [{A tensor of indices.}]>:$indices, + Arg:$depth, + Arg:$on_value, + Arg:$off_value, DefaultValuedAttr:$axis ); let results = (outs - TF_Tensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<2>; TF_DerivedOperandTypeAttr TI = TF_DerivedOperandTypeAttr<0>; let builders = [ - OpBuilderDAG<(ins "Value":$indices, "Value":$depth, "Value":$on_value, + OpBuilder<(ins "Value":$indices, "Value":$depth, "Value":$on_value, "Value":$off_value, "IntegerAttr":$axis)> ]; @@ -8613,7 +9079,8 @@ times by rerunning "MakeIterator". ); let results = (outs - Res:$handle + Res:$handle ); } @@ -8621,16 +9088,58 @@ def TF_OnesLikeOp : TF_Op<"OnesLike", [Idempotent, NoSideEffect, SameOperandsAnd let summary = "Returns a tensor of ones with the same shape and type as x."; let arguments = (ins - TensorOf<[TF_Bfloat16, TF_Bool, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Uint16, TF_Uint8]>:$x + Arg, [{a tensor of type T.}]>:$x ); let results = (outs - TensorOf<[TF_Bfloat16, TF_Bool, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Uint16, TF_Uint8]>:$y + Res, [{a tensor of the same shape and type as x but filled with ones.}]>:$y ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; } +def TF_OptimizeDatasetV2Op : TF_Op<"OptimizeDatasetV2", [NoSideEffect]> { + let summary = [{ +Creates a dataset by applying related optimizations to `input_dataset`. + }]; + + let description = [{ +Creates a dataset by applying related optimizations to `input_dataset`. + }]; + + let arguments = (ins + Arg:$input_dataset, + Arg:$optimizations_enabled, + Arg:$optimizations_disabled, + Arg:$optimizations_default, + + Confined]>:$output_types, + Confined]>:$output_shapes, + DefaultValuedAttr:$optimization_configs + ); + + let results = (outs + TF_VariantTensor:$handle + ); +} + +def TF_OptionalGetValueOp : TF_Op<"OptionalGetValue", [NoSideEffect]> { + let summary = [{ +Returns the value stored in an Optional variant or raises an error if none exists. + }]; + + let arguments = (ins + TF_VariantTensor:$optional + ); + + let results = (outs + Variadic:$components + ); + + TF_DerivedResultShapeListAttr output_shapes = TF_DerivedResultShapeListAttr<0>; + TF_DerivedResultTypeListAttr output_types = TF_DerivedResultTypeListAttr<0>; +} + def TF_OptionalHasValueOp : TF_Op<"OptionalHasValue", [NoSideEffect]> { let summary = [{ Returns true if and only if the given Optional variant has a value. @@ -8649,7 +9158,8 @@ def TF_OutfeedEnqueueTupleOp : TF_Op<"OutfeedEnqueueTuple", []> { let summary = "Enqueue multiple Tensor values on the computation outfeed."; let arguments = (ins - Variadic:$inputs + Arg, [{A list of tensors that will be inserted into the outfeed queue as an +XLA tuple.}]>:$inputs ); let results = (outs); @@ -8685,13 +9195,13 @@ This is the opposite of `unpack`. }]; let arguments = (ins - Variadic:$values, + Arg, [{Must be of same shape and type.}]>:$values, DefaultValuedAttr:$axis ); let results = (outs - TF_Tensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -8700,10 +9210,9 @@ This is the opposite of `unpack`. let verifier = [{ return Verify(*this); }]; - } -def TF_PadOp : TF_Op<"Pad", [NoSideEffect]> { +def TF_PadOp : TF_Op<"Pad", [NoSideEffect, TF_OperandHasRank<1, 2>]> { let summary = "Pads a tensor with zeros."; let description = [{ @@ -8742,15 +9251,9 @@ pad(t, paddings) ==> [[0, 0, 0, 0, 0, 0] TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; TF_DerivedOperandTypeAttr Tpaddings = TF_DerivedOperandTypeAttr<1>; - - let extraClassDeclaration = [{ - // TF_FoldOperandsTransposeInterface: - SmallVector GetLayoutDependentArgs() { return {0}; } - SmallVector GetLayoutDependentResults() { return {0}; } - }]; } -def TF_PadV2Op : TF_Op<"PadV2", [NoSideEffect]> { +def TF_PadV2Op : TF_Op<"PadV2", [NoSideEffect, TF_OperandHasRank<1, 2>]> { let summary = "Pads a tensor."; let description = [{ @@ -8887,18 +9390,20 @@ stores the parameters for each batch. }]; let arguments = (ins - TF_I32OrI64Tensor:$shape, - TF_FloatTensor:$means, - TF_FloatTensor:$stdevs, - TF_FloatTensor:$minvals, - TF_FloatTensor:$maxvals, + Arg:$shape, + Arg:$means, + Arg:$stdevs, + Arg:$minvals, + Arg:$maxvals, DefaultValuedAttr:$seed, DefaultValuedAttr:$seed2 ); let results = (outs - TF_FloatTensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -8974,19 +9479,18 @@ tf.pow(x, y) ==> [[256, 65536], [9, 27]] }]; let arguments = (ins - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int32, TF_Int64]>:$x, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int32, TF_Int64]>:$y + TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8]>:$x, + TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8]>:$y ); let results = (outs - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int32, TF_Int64]>:$z + TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8]>:$z ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; - } -def TF_PreventGradientOp : TF_Op<"PreventGradient", [NoSideEffect, SameOperandsAndResultType]> { +def TF_PreventGradientOp : TF_Op<"PreventGradient", [NoSideEffect, TF_SameOperandsAndResultTypeResolveRef]> { let summary = [{ An identity op that triggers an error if a gradient is requested. }]; @@ -9002,13 +9506,13 @@ gradients in some corner cases. }]; let arguments = (ins - TF_Tensor:$input, + Arg:$input, StrAttr:$message ); let results = (outs - TF_Tensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -9022,7 +9526,7 @@ Prints a string scalar to the desired output_stream. }]; let arguments = (ins - TF_StrTensor:$input, + Arg:$input, DefaultValuedAttr:$output_stream, DefaultValuedAttr:$end @@ -9044,14 +9548,15 @@ retained with length 1. }]; let arguments = (ins - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$input, - TF_I32OrI64Tensor:$reduction_indices, + Arg, [{The tensor to reduce.}]>:$input, + Arg:$reduction_indices, DefaultValuedAttr:$keep_dims ); let results = (outs - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$output + Res, [{The reduced tensor.}]>:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -9079,14 +9584,18 @@ q_full, r_full = qr(a, full_matrices=True) }]; let arguments = (ins - TensorOf<[TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64]>:$input, + Arg, [{A tensor of shape `[..., M, N]` whose inner-most 2 dimensions +form matrices of size `[M, N]`. Let `P` be the minimum of `M` and `N`.}]>:$input, DefaultValuedAttr:$full_matrices ); let results = (outs - TensorOf<[TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64]>:$q, - TensorOf<[TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64]>:$r + Res, [{Orthonormal basis for range of `a`. If `full_matrices` is `False` then +shape is `[..., M, P]`; if `full_matrices` is `True` then shape is +`[..., M, M]`.}]>:$q, + Res, [{Triangular factor. If `full_matrices` is `False` then shape is +`[..., P, N]`. If `full_matrices` is `True` then shape is `[..., M, N]`.}]>:$r ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -9096,7 +9605,7 @@ q_full, r_full = qr(a, full_matrices=True) }]; } -def TF_QuantizeAndDequantizeOp : TF_Op<"QuantizeAndDequantize", [NoSideEffect, SameOperandsAndResultType]> { +def TF_QuantizeAndDequantizeOp : TF_Op<"QuantizeAndDequantize", [NoSideEffect, TF_SameOperandsAndResultTypeResolveRef]> { let summary = "Use QuantizeAndDequantizeV2 instead."; let arguments = (ins @@ -9174,9 +9683,13 @@ The above round function rounds the value based on the given round_mode. }]; let arguments = (ins - TF_FloatTensor:$input, - TF_FloatTensor:$input_min, - TF_FloatTensor:$input_max, + Arg:$input, + Arg:$input_min, + Arg:$input_max, DefaultValuedAttr:$signed_input, DefaultValuedAttr:$num_bits, @@ -9233,13 +9746,13 @@ has been dequeued (or 'timeout_ms' elapses, if specified). }]; let arguments = (ins - TF_ResourceTensor:$handle, + Arg:$handle, DefaultValuedAttr:$timeout_ms ); let results = (outs - Variadic:$components + Res, [{One or more tensors that were dequeued as a tuple.}]>:$components ); TF_DerivedResultTypeListAttr component_types = TF_DerivedResultTypeListAttr<0>; @@ -9262,12 +9775,18 @@ the dimension is padded with zeros. }]; let arguments = (ins - TF_F32OrF64Tensor:$input, - TF_Int32Tensor:$fft_length + Arg:$input, + Arg:$fft_length ); let results = (outs - TensorOf<[TF_Complex128, TF_Complex64]>:$output + Res, [{A complex64 tensor of the same rank as `input`. The inner-most + dimension of `input` is replaced with the `fft_length / 2 + 1` unique + frequency components of its 1D Fourier transform. + +@compatibility(numpy) +Equivalent to np.fft.rfft +@end_compatibility}]>:$output ); TF_DerivedOperandTypeAttr Treal = TF_DerivedOperandTypeAttr<0>; @@ -9292,12 +9811,19 @@ the dimension is padded with zeros. }]; let arguments = (ins - TF_F32OrF64Tensor:$input, - TF_Int32Tensor:$fft_length + Arg:$input, + Arg:$fft_length ); let results = (outs - TensorOf<[TF_Complex128, TF_Complex64]>:$output + Res, [{A complex64 tensor of the same rank as `input`. The inner-most 2 + dimensions of `input` are replaced with their 2D Fourier transform. The + inner-most dimension contains `fft_length / 2 + 1` unique frequency + components. + +@compatibility(numpy) +Equivalent to np.fft.rfft2 +@end_compatibility}]>:$output ); TF_DerivedOperandTypeAttr Treal = TF_DerivedOperandTypeAttr<0>; @@ -9322,12 +9848,19 @@ the dimension is padded with zeros. }]; let arguments = (ins - TF_F32OrF64Tensor:$input, - TF_Int32Tensor:$fft_length + Arg:$input, + Arg:$fft_length ); let results = (outs - TensorOf<[TF_Complex128, TF_Complex64]>:$output + Res, [{A complex64 tensor of the same rank as `input`. The inner-most 3 + dimensions of `input` are replaced with the their 3D Fourier transform. The + inner-most dimension contains `fft_length / 2 + 1` unique frequency + components. + +@compatibility(numpy) +Equivalent to np.fft.rfftn with 3 dimensions. +@end_compatibility}]>:$output ); TF_DerivedOperandTypeAttr Treal = TF_DerivedOperandTypeAttr<0>; @@ -9359,13 +9892,104 @@ array([0.6666667, 1. , 1. ], dtype=float32) }]; let arguments = (ins - TF_FloatTensor:$images + Arg:$images ); let results = (outs - TF_FloatTensor:$output + Res:$output + ); + + TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; +} + +def TF_RaggedGatherOp : TF_Op<"RaggedGather", [NoSideEffect]> { + let summary = [{ +Gather ragged slices from `params` axis `0` according to `indices`. + }]; + + let description = [{ +Outputs a `RaggedTensor` output composed from `output_dense_values` and +`output_nested_splits`, such that: + +```python +output.shape = indices.shape + params.shape[1:] +output.ragged_rank = indices.shape.ndims + params.ragged_rank +output[i...j, d0...dn] = params[indices[i...j], d0...dn] +``` + +where + +* `params = + ragged.from_nested_row_splits(params_dense_values, params_nested_splits)` + provides the values that should be gathered. +* `indices` ia a dense tensor with dtype `int32` or `int64`, indicating which + values should be gathered. +* `output = + ragged.from_nested_row_splits(output_dense_values, output_nested_splits)` + is the output tensor. + +(Note: This c++ op is used to implement the higher-level python +`tf.ragged.gather` op, which also supports ragged indices.) + }]; + + let arguments = (ins + Arg, [{The `nested_row_splits` tensors that define the row-partitioning for the +`params` RaggedTensor input.}]>:$params_nested_splits, + Arg:$params_dense_values, + Arg:$indices + ); + + let results = (outs + Res, [{The `nested_row_splits` tensors that define the row-partitioning for the +returned RaggedTensor.}]>:$output_nested_splits, + Res:$output_dense_values + ); + + TF_DerivedOperandTypeAttr Tsplits = TF_DerivedOperandTypeAttr<0>; + TF_DerivedOperandTypeAttr Tvalues = TF_DerivedOperandTypeAttr<1>; + TF_DerivedResultSizeAttr OUTPUT_RAGGED_RANK = TF_DerivedResultSizeAttr<0>; + TF_DerivedOperandTypeAttr Tindices = TF_DerivedOperandTypeAttr<2>; + TF_DerivedOperandSizeAttr PARAMS_RAGGED_RANK = TF_DerivedOperandSizeAttr<0>; +} + +def TF_RaggedRangeOp : TF_Op<"RaggedRange", [NoSideEffect]> { + let summary = [{ +Returns a `RaggedTensor` containing the specified sequences of numbers. + }]; + + let description = [{ +Returns a `RaggedTensor` `result` composed from `rt_dense_values` and +`rt_nested_splits`, such that +`result[i] = range(starts[i], limits[i], deltas[i])`. + +```python +(rt_nested_splits, rt_dense_values) = ragged_range( + starts=[2, 5, 8], limits=[3, 5, 12], deltas=1) +result = tf.ragged.from_row_splits(rt_dense_values, rt_nested_splits) +print(result) + +``` + +The input tensors `starts`, `limits`, and `deltas` may be scalars or vectors. +The vector inputs must all have the same size. Scalar inputs are broadcast +to match the size of the vector inputs. + }]; + + let arguments = (ins + Arg, [{The starts of each range.}]>:$starts, + Arg, [{The limits of each range.}]>:$limits, + Arg, [{The deltas of each range.}]>:$deltas + ); + + let results = (outs + Res:$rt_nested_splits, + Res, [{The `flat_values` for the returned `RaggedTensor`.}]>:$rt_dense_values ); + TF_DerivedResultTypeAttr Tsplits = TF_DerivedResultTypeAttr<0>; TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; } @@ -9381,15 +10005,19 @@ See http://dl.acm.org/citation.cfm?id=358414 }]; let arguments = (ins - TF_I32OrI64Tensor:$shape, - TensorOf<[TF_Float16, TF_Float32, TF_Float64]>:$alpha, + Arg:$shape, + Arg, [{A tensor in which each scalar is a "shape" parameter describing the +associated gamma distribution.}]>:$alpha, DefaultValuedAttr:$seed, DefaultValuedAttr:$seed2 ); let results = (outs - TensorOf<[TF_Float16, TF_Float32, TF_Float64]>:$output + Res, [{A tensor with shape `shape + shape(alpha)`. Each slice +`[:, ..., :, i0, i1, ...iN]` contains the samples drawn for +`alpha[i0, i1, ...iN]`. The dtype of the output matches the dtype of alpha.}]>:$output ); TF_DerivedOperandTypeAttr S = TF_DerivedOperandTypeAttr<0>; @@ -9451,15 +10079,19 @@ Programming, Volume 2. Addison Wesley }]; let arguments = (ins - TF_I32OrI64Tensor:$shape, - TensorOf<[TF_Float16, TF_Float32, TF_Float64, TF_Int32, TF_Int64]>:$rate, + Arg:$shape, + Arg, [{A tensor in which each scalar is a "rate" parameter describing the +associated poisson distribution.}]>:$rate, DefaultValuedAttr:$seed, DefaultValuedAttr:$seed2 ); let results = (outs - TensorOf<[TF_Float16, TF_Float32, TF_Float64, TF_Int32, TF_Int64]>:$output + Res, [{A tensor with shape `shape + shape(rate)`. Each slice +`[:, ..., :, i0, i1, ...iN]` contains the samples drawn for +`rate[i0, i1, ...iN]`.}]>:$output ); TF_DerivedOperandTypeAttr R = TF_DerivedOperandTypeAttr<1>; @@ -9467,7 +10099,7 @@ Programming, Volume 2. Addison Wesley TF_DerivedResultTypeAttr dtype = TF_DerivedResultTypeAttr<0>; } -def TF_RandomShuffleOp : TF_Op<"RandomShuffle", [SameOperandsAndResultType, TF_CannotDuplicate]> { +def TF_RandomShuffleOp : TF_Op<"RandomShuffle", [TF_CannotDuplicate, TF_SameOperandsAndResultTypeResolveRef]> { let summary = "Randomly shuffles a tensor along its first dimension."; let description = [{ @@ -9483,14 +10115,15 @@ The tensor is shuffled along dimension 0, such that each `value[j]` is mapped }]; let arguments = (ins - TF_Tensor:$value, + Arg:$value, DefaultValuedAttr:$seed, DefaultValuedAttr:$seed2 ); let results = (outs - TF_Tensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -9504,14 +10137,14 @@ The generated values will have mean 0 and standard deviation 1. }]; let arguments = (ins - TF_I32OrI64Tensor:$shape, + Arg:$shape, DefaultValuedAttr:$seed, DefaultValuedAttr:$seed2 ); let results = (outs - TF_FloatTensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -9527,14 +10160,14 @@ lower bound 0 is included in the range, while the upper bound 1 is excluded. }]; let arguments = (ins - TF_I32OrI64Tensor:$shape, + Arg:$shape, DefaultValuedAttr:$seed, DefaultValuedAttr:$seed2 ); let results = (outs - TF_FloatTensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -9559,16 +10192,16 @@ smaller than the range of the output (either `2^32` or `2^64`). }]; let arguments = (ins - TF_I32OrI64Tensor:$shape, - TF_I32OrI64Tensor:$minval, - TF_I32OrI64Tensor:$maxval, + Arg:$shape, + Arg:$minval, + Arg:$maxval, DefaultValuedAttr:$seed, DefaultValuedAttr:$seed2 ); let results = (outs - TF_I32OrI64Tensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -9593,19 +10226,19 @@ tf.range(start, limit, delta) ==> [3, 6, 9, 12, 15] }]; let arguments = (ins - TF_FpOrI32OrI64Tensor:$start, - TF_FpOrI32OrI64Tensor:$limit, - TF_FpOrI32OrI64Tensor:$delta + Arg, [{0-D (scalar). First entry in the sequence.}]>:$start, + Arg, [{0-D (scalar). Upper limit of sequence, exclusive.}]>:$limit, + Arg, [{0-D (scalar). Optional. Default is 1. Number that increments `start`.}]>:$delta ); let results = (outs - TF_FpOrI32OrI64Tensor:$output + Res, [{1-D.}]>:$output ); TF_DerivedOperandTypeAttr Tidx = TF_DerivedOperandTypeAttr<0>; let builders = [ - OpBuilderDAG<(ins "Value":$start, "Value":$limit, "Value":$delta)> + OpBuilder<(ins "Value":$start, "Value":$limit, "Value":$delta)> ]; } @@ -9615,9 +10248,9 @@ Creates a dataset with a range of values. Corresponds to python's xrange. }]; let arguments = (ins - TF_Int64Tensor:$start, - TF_Int64Tensor:$stop, - TF_Int64Tensor:$step, + Arg:$start, + Arg:$stop, + Arg:$step, Confined]>:$output_types, Confined]>:$output_shapes @@ -9658,9 +10291,8 @@ of the tensor. Rank is also known as "order", "degree", or "ndims." TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; let builders = [ - OpBuilderDAG<(ins "Value":$input)> + OpBuilder<(ins "Value":$input)> ]; - } def TF_ReadVariableOp : TF_Op<"ReadVariableOp", []> { @@ -9676,7 +10308,7 @@ operation. }]; let arguments = (ins - Arg:$resource + Arg:$resource ); let results = (outs @@ -9684,7 +10316,6 @@ operation. ); TF_DerivedResultTypeAttr dtype = TF_DerivedResultTypeAttr<0>; - } def TF_RealOp : TF_Op<"Real", [NoSideEffect, SameOperandsAndResultShape]> { @@ -9734,7 +10365,7 @@ I.e., \\(y = 1 / x\\). TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; } -def TF_ReciprocalGradOp : TF_Op<"ReciprocalGrad", [NoSideEffect, SameOperandsAndResultType]> { +def TF_ReciprocalGradOp : TF_Op<"ReciprocalGrad", [NoSideEffect, TF_SameOperandsAndResultTypeResolveRef]> { let summary = "Computes the gradient for the inverse of `x` wrt its input."; let description = [{ @@ -9754,6 +10385,24 @@ is the corresponding input gradient. TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; } +def TF_RecvOp : TF_Op<"Recv", []> { + let summary = "Receives the named tensor from send_device on recv_device."; + + let arguments = (ins + StrAttr:$tensor_name, + StrAttr:$send_device, + I64Attr:$send_device_incarnation, + StrAttr:$recv_device, + DefaultValuedAttr:$client_terminated + ); + + let results = (outs + Res:$tensor + ); + + TF_DerivedResultTypeAttr tensor_type = TF_DerivedResultTypeAttr<0>; +} + def TF_RecvTPUEmbeddingActivationsOp : TF_Op<"RecvTPUEmbeddingActivations", [TF_TPUEmbeddingSideEffect]> { let summary = "An op that receives embedding activations on the TPU."; @@ -9771,7 +10420,8 @@ most one RecvTPUEmbeddingActivations op in the TPU graph. ); let results = (outs - Variadic:$outputs + Res, [{A TensorList of embedding activations containing one Tensor per +embedding table in the model.}]>:$outputs ); TF_DerivedResultSizeAttr num_outputs = TF_DerivedResultSizeAttr<0>; @@ -9807,15 +10457,18 @@ tf.reduce_join(a) = tf.reduce_join(a, [1, 0]) ==> "abcd" }]; let arguments = (ins - TF_StrTensor:$inputs, - TF_Int32Tensor:$reduction_indices, + Arg:$inputs, + Arg:$reduction_indices, DefaultValuedAttr:$keep_dims, StrAttr:$separator ); let results = (outs - TF_StrTensor:$output + Res:$output ); } @@ -9838,10 +10491,6 @@ array([ 0., 0., -0., 3.], dtype=float32) ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; - - let extraClassDeclaration = [{ - // TF_ContractionFusableInterface: - }]; } def TF_Relu6Op : TF_Op<"Relu6", [Idempotent, NoSideEffect, SameOperandsAndResultType]> { @@ -9858,31 +10507,34 @@ def TF_Relu6Op : TF_Op<"Relu6", [Idempotent, NoSideEffect, SameOperandsAndResult TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; } -def TF_Relu6GradOp : TF_Op<"Relu6Grad", [NoSideEffect, SameOperandsAndResultType]> { +def TF_Relu6GradOp : TF_Op<"Relu6Grad", [NoSideEffect, TF_SameOperandsAndResultTypeResolveRef]> { let summary = "Computes rectified linear 6 gradients for a Relu6 operation."; let arguments = (ins - TF_IntOrFpTensor:$gradients, - TF_IntOrFpTensor:$features + Arg:$gradients, + Arg:$features ); let results = (outs - TF_IntOrFpTensor:$backprops + Res 0) * (features < 6)`.}]>:$backprops ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; } -def TF_ReluGradOp : TF_Op<"ReluGrad", [NoSideEffect, SameOperandsAndResultType]> { +def TF_ReluGradOp : TF_Op<"ReluGrad", [NoSideEffect, TF_SameOperandsAndResultTypeResolveRef]> { let summary = "Computes rectified linear gradients for a Relu operation."; let arguments = (ins - TF_IntOrFpTensor:$gradients, - TF_IntOrFpTensor:$features + Arg:$gradients, + Arg:$features ); let results = (outs - TF_IntOrFpTensor:$backprops + Res 0)`.}]>:$backprops ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -9892,14 +10544,14 @@ def TF_RemoteCallOp : TF_Op<"RemoteCall", []> { let summary = "Runs function `f` on a remote device indicated by `target`."; let arguments = (ins - TF_StrTensor:$target, - Variadic:$args, + Arg:$target, + Arg, [{A list of arguments for the function.}]>:$args, SymbolRefAttr:$f ); let results = (outs - Variadic:$output + Res, [{A list of return values.}]>:$output ); TF_DerivedOperandTypeListAttr Tin = TF_DerivedOperandTypeListAttr<1>; @@ -9973,7 +10625,7 @@ reshape(t, []) ==> 7 let arguments = (ins TF_Tensor:$tensor, - TF_I32OrI64Tensor:$shape + Arg:$shape ); let results = (outs @@ -9984,13 +10636,12 @@ reshape(t, []) ==> 7 TF_DerivedOperandTypeAttr Tshape = TF_DerivedOperandTypeAttr<1>; let builders = [ - OpBuilderDAG<(ins "Value":$tensor, "Value":$shape)> + OpBuilder<(ins "Value":$tensor, "Value":$shape)> ]; let verifier = [{ return Verify(*this); }]; - } def TF_ResizeBilinearOp : TF_Op<"ResizeBilinear", [NoSideEffect]> { @@ -10001,15 +10652,17 @@ Input images can be of different types but output images are always float. }]; let arguments = (ins - TensorOf<[TF_Bfloat16, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Uint16, TF_Uint8]>:$images, - TF_Int32Tensor:$size, + Arg, [{4-D with shape `[batch, height, width, channels]`.}]>:$images, + Arg:$size, DefaultValuedAttr:$align_corners, DefaultValuedAttr:$half_pixel_centers ); let results = (outs - TF_Float32Tensor:$resized_images + Res:$resized_images ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -10019,15 +10672,18 @@ def TF_ResizeBilinearGradOp : TF_Op<"ResizeBilinearGrad", [NoSideEffect]> { let summary = "Computes the gradient of bilinear interpolation."; let arguments = (ins - TF_Float32Tensor:$grads, - TF_FloatTensor:$original_image, + Arg:$grads, + Arg:$original_image, DefaultValuedAttr:$align_corners, DefaultValuedAttr:$half_pixel_centers ); let results = (outs - TF_FloatTensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<1>; @@ -10039,15 +10695,17 @@ Resize `images` to `size` using nearest neighbor interpolation. }]; let arguments = (ins - TensorOf<[TF_Bfloat16, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Uint16, TF_Uint8]>:$images, - TF_Int32Tensor:$size, + Arg, [{4-D with shape `[batch, height, width, channels]`.}]>:$images, + Arg:$size, DefaultValuedAttr:$align_corners, DefaultValuedAttr:$half_pixel_centers ); let results = (outs - TensorOf<[TF_Bfloat16, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Uint16, TF_Uint8]>:$resized_images + Res, [{4-D with shape +`[batch, new_height, new_width, channels]`.}]>:$resized_images ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -10057,15 +10715,17 @@ def TF_ResizeNearestNeighborGradOp : TF_Op<"ResizeNearestNeighborGrad", [NoSideE let summary = "Computes the gradient of nearest neighbor interpolation."; let arguments = (ins - TensorOf<[TF_Bfloat16, TF_Float16, TF_Float32, TF_Float64, TF_Int32, TF_Int8, TF_Uint8]>:$grads, - TF_Int32Tensor:$size, + Arg, [{4-D with shape `[batch, height, width, channels]`.}]>:$grads, + Arg:$size, DefaultValuedAttr:$align_corners, DefaultValuedAttr:$half_pixel_centers ); let results = (outs - TensorOf<[TF_Bfloat16, TF_Float16, TF_Float32, TF_Float64, TF_Int32, TF_Int8, TF_Uint8]>:$output + Res, [{4-D with shape `[batch, orig_height, orig_width, channels]`. Gradients +with respect to the input image.}]>:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -10081,15 +10741,15 @@ variable <- variable - learning_rate / (1 - beta1^t) * m_t / (v_t + epsilon) }]; let arguments = (ins - Arg:$var, - Arg:$m, - Arg:$v, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$beta1_power, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$lr, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$beta1, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$beta2, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$epsilon, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$grad, + Arg:$var, + Arg:$m, + Arg:$v, + Arg, [{Must be a scalar.}]>:$beta1_power, + Arg, [{Scaling factor. Must be a scalar.}]>:$lr, + Arg, [{Momentum factor. Must be a scalar.}]>:$beta1, + Arg, [{Momentum factor. Must be a scalar.}]>:$beta2, + Arg, [{Ridge term. Must be a scalar.}]>:$epsilon, + Arg, [{The gradient.}]>:$grad, DefaultValuedAttr:$use_locking ); @@ -10110,13 +10770,13 @@ var -= update; }]; let arguments = (ins - Arg:$var, - Arg:$accum, - Arg:$accum_update, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$lr, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$rho, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$epsilon, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$grad, + Arg:$var, + Arg:$accum, + Arg:$accum_update, + Arg, [{Scaling factor. Must be a scalar.}]>:$lr, + Arg, [{Decay factor. Must be a scalar.}]>:$rho, + Arg, [{Constant factor. Must be a scalar.}]>:$epsilon, + Arg, [{The gradient.}]>:$grad, DefaultValuedAttr:$use_locking ); @@ -10135,10 +10795,10 @@ var -= lr * grad * (1 / sqrt(accum)) }]; let arguments = (ins - Arg:$var, - Arg:$accum, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$lr, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$grad, + Arg:$var, + Arg:$accum, + Arg, [{Scaling factor. Must be a scalar.}]>:$lr, + Arg, [{The gradient.}]>:$grad, DefaultValuedAttr:$use_locking, DefaultValuedAttr:$update_slots @@ -10153,14 +10813,14 @@ def TF_ResourceApplyAdagradDAOp : TF_Op<"ResourceApplyAdagradDA", []> { let summary = "Update '*var' according to the proximal adagrad scheme."; let arguments = (ins - Arg:$var, - Arg:$gradient_accumulator, - Arg:$gradient_squared_accumulator, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$grad, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$lr, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$l1, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$l2, - TF_Int64Tensor:$global_step, + Arg:$var, + Arg:$gradient_accumulator, + Arg:$gradient_squared_accumulator, + Arg, [{The gradient.}]>:$grad, + Arg, [{Scaling factor. Must be a scalar.}]>:$lr, + Arg, [{L1 regularization. Must be a scalar.}]>:$l1, + Arg, [{L2 regularization. Must be a scalar.}]>:$l2, + Arg:$global_step, DefaultValuedAttr:$use_locking ); @@ -10179,11 +10839,11 @@ var -= lr * grad * (1 / (sqrt(accum) + epsilon)) }]; let arguments = (ins - Arg:$var, - Arg:$accum, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$lr, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$epsilon, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$grad, + Arg:$var, + Arg:$accum, + Arg, [{Scaling factor. Must be a scalar.}]>:$lr, + Arg, [{Constant factor. Must be a scalar.}]>:$epsilon, + Arg, [{The gradient.}]>:$grad, DefaultValuedAttr:$use_locking, DefaultValuedAttr:$update_slots @@ -10205,16 +10865,16 @@ $$\text{variable} := \text{variable} - \text{lr}_t * m_t / (\sqrt{v_t} + \epsilo }]; let arguments = (ins - Arg:$var, - Arg:$m, - Arg:$v, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$beta1_power, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$beta2_power, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$lr, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$beta1, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$beta2, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$epsilon, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$grad, + Arg:$var, + Arg:$m, + Arg:$v, + Arg, [{Must be a scalar.}]>:$beta1_power, + Arg, [{Must be a scalar.}]>:$beta2_power, + Arg, [{Scaling factor. Must be a scalar.}]>:$lr, + Arg, [{Momentum factor. Must be a scalar.}]>:$beta1, + Arg, [{Momentum factor. Must be a scalar.}]>:$beta2, + Arg, [{Ridge term. Must be a scalar.}]>:$epsilon, + Arg, [{The gradient.}]>:$grad, DefaultValuedAttr:$use_locking, DefaultValuedAttr:$use_nesterov @@ -10235,13 +10895,13 @@ variable <- variable - lr_t * update }]; let arguments = (ins - Arg:$var, - Arg:$m, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$lr, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$alpha, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$sign_decay, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$beta, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$grad, + Arg:$var, + Arg:$m, + Arg, [{Scaling factor. Must be a scalar.}]>:$lr, + Arg, [{Must be a scalar.}]>:$alpha, + Arg, [{Must be a scalar.}]>:$sign_decay, + Arg, [{Must be a scalar.}]>:$beta, + Arg, [{The gradient.}]>:$grad, DefaultValuedAttr:$use_locking ); @@ -10276,15 +10936,15 @@ var <- var - mom }]; let arguments = (ins - Arg:$var, - Arg:$mg, - Arg:$ms, - Arg:$mom, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$lr, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$rho, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$momentum, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$epsilon, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$grad, + Arg:$var, + Arg:$mg, + Arg:$ms, + Arg:$mom, + Arg, [{Scaling factor. Must be a scalar.}]>:$lr, + Arg, [{Decay rate. Must be a scalar.}]>:$rho, + Arg, [{Momentum Scale. Must be a scalar.}]>:$momentum, + Arg, [{Ridge term. Must be a scalar.}]>:$epsilon, + Arg, [{The gradient.}]>:$grad, DefaultValuedAttr:$use_locking ); @@ -10306,14 +10966,14 @@ accum = accum_new }]; let arguments = (ins - Arg:$var, - Arg:$accum, - Arg:$linear, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$grad, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$lr, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$l1, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$l2, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$lr_power, + Arg:$var, + Arg:$accum, + Arg:$linear, + Arg, [{The gradient.}]>:$grad, + Arg, [{Scaling factor. Must be a scalar.}]>:$lr, + Arg, [{L1 regularization. Must be a scalar.}]>:$l1, + Arg, [{L2 regularization. Must be a scalar.}]>:$l2, + Arg, [{Scaling factor. Must be a scalar.}]>:$lr_power, DefaultValuedAttr:$use_locking, DefaultValuedAttr:$multiply_linear_by_lr @@ -10338,15 +10998,15 @@ accum = accum_new }]; let arguments = (ins - Arg:$var, - Arg:$accum, - Arg:$linear, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$grad, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$lr, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$l1, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$l2, + Arg:$var, + Arg:$accum, + Arg:$linear, + Arg, [{The gradient.}]>:$grad, + Arg, [{Scaling factor. Must be a scalar.}]>:$lr, + Arg, [{L1 regularization. Must be a scalar.}]>:$l1, + Arg, [{L2 shrinkage regularization. Must be a scalar.}]>:$l2, TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$l2_shrinkage, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$lr_power, + Arg, [{Scaling factor. Must be a scalar.}]>:$lr_power, DefaultValuedAttr:$use_locking, DefaultValuedAttr:$multiply_linear_by_lr @@ -10361,9 +11021,9 @@ def TF_ResourceApplyGradientDescentOp : TF_Op<"ResourceApplyGradientDescent", [] let summary = "Update '*var' by subtracting 'alpha' * 'delta' from it."; let arguments = (ins - Arg:$var, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$alpha, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$delta, + Arg:$var, + Arg, [{Scaling factor. Must be a scalar.}]>:$alpha, + Arg, [{The change.}]>:$delta, DefaultValuedAttr:$use_locking ); @@ -10384,11 +11044,11 @@ var += accum }]; let arguments = (ins - Arg:$var, - Arg:$accum, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$lr, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$grad, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$momentum, + Arg:$var, + Arg:$accum, + Arg, [{Scaling factor. Must be a scalar.}]>:$lr, + Arg, [{The gradient.}]>:$grad, + Arg, [{Momentum. Must be a scalar.}]>:$momentum, DefaultValuedAttr:$use_locking, DefaultValuedAttr:$use_nesterov @@ -10410,11 +11070,11 @@ var -= lr * accum }]; let arguments = (ins - Arg:$var, - Arg:$accum, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$lr, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$grad, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$momentum, + Arg:$var, + Arg:$accum, + Arg, [{Scaling factor. Must be a scalar.}]>:$lr, + Arg, [{The gradient.}]>:$grad, + Arg, [{Momentum. Must be a scalar.}]>:$momentum, DefaultValuedAttr:$use_locking, DefaultValuedAttr:$use_nesterov @@ -10435,13 +11095,13 @@ variable <- variable - lr_t * update }]; let arguments = (ins - Arg:$var, - Arg:$m, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$lr, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$logbase, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$sign_decay, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$beta, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$grad, + Arg:$var, + Arg:$m, + Arg, [{Scaling factor. Must be a scalar.}]>:$lr, + Arg, [{Must be a scalar.}]>:$logbase, + Arg, [{Must be a scalar.}]>:$sign_decay, + Arg, [{Must be a scalar.}]>:$beta, + Arg, [{The gradient.}]>:$grad, DefaultValuedAttr:$use_locking ); @@ -10463,12 +11123,12 @@ var = sign(prox_v)/(1+lr*l2) * max{|prox_v|-lr*l1,0} }]; let arguments = (ins - Arg:$var, - Arg:$accum, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$lr, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$l1, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$l2, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$grad, + Arg:$var, + Arg:$accum, + Arg, [{Scaling factor. Must be a scalar.}]>:$lr, + Arg, [{L1 regularization. Must be a scalar.}]>:$l1, + Arg, [{L2 regularization. Must be a scalar.}]>:$l2, + Arg, [{The gradient.}]>:$grad, DefaultValuedAttr:$use_locking ); @@ -10487,11 +11147,11 @@ var = sign(prox_v)/(1+alpha*l2) * max{|prox_v|-alpha*l1,0} }]; let arguments = (ins - Arg:$var, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$alpha, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$l1, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$l2, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$delta, + Arg:$var, + Arg, [{Scaling factor. Must be a scalar.}]>:$alpha, + Arg, [{L1 regularization. Must be a scalar.}]>:$l1, + Arg, [{L2 regularization. Must be a scalar.}]>:$l2, + Arg, [{The change.}]>:$delta, DefaultValuedAttr:$use_locking ); @@ -10518,14 +11178,14 @@ var <- var - mom }]; let arguments = (ins - Arg:$var, - Arg:$ms, - Arg:$mom, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$lr, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$rho, + Arg:$var, + Arg:$ms, + Arg:$mom, + Arg, [{Scaling factor. Must be a scalar.}]>:$lr, + Arg, [{Decay rate. Must be a scalar.}]>:$rho, TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$momentum, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$epsilon, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$grad, + Arg, [{Ridge term. Must be a scalar.}]>:$epsilon, + Arg, [{The gradient.}]>:$grad, DefaultValuedAttr:$use_locking ); @@ -10598,9 +11258,9 @@ Requires `updates.shape = indices.shape + ref.shape[1:]` or `updates.shape = []` }]; let arguments = (ins - Arg:$resource, - TF_I32OrI64Tensor:$indices, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$updates + Arg:$resource, + Arg:$indices, + Arg, [{A tensor of updated values to add to `ref`.}]>:$updates ); let results = (outs); @@ -10637,9 +11297,9 @@ Requires `updates.shape = indices.shape + ref.shape[1:]` or `updates.shape = []` }]; let arguments = (ins - Arg:$resource, - TF_I32OrI64Tensor:$indices, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$updates + Arg:$resource, + Arg:$indices, + Arg, [{A tensor of updated values to add to `ref`.}]>:$updates ); let results = (outs); @@ -10676,9 +11336,9 @@ Requires `updates.shape = indices.shape + ref.shape[1:]` or `updates.shape = []` }]; let arguments = (ins - Arg:$resource, - TF_I32OrI64Tensor:$indices, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$updates + Arg:$resource, + Arg:$indices, + Arg, [{A tensor of updated values to add to `ref`.}]>:$updates ); let results = (outs); @@ -10715,9 +11375,9 @@ Requires `updates.shape = indices.shape + ref.shape[1:]` or `updates.shape = []` }]; let arguments = (ins - Arg:$resource, - TF_I32OrI64Tensor:$indices, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$updates + Arg:$resource, + Arg:$indices, + Arg, [{A tensor of updated values to add to `ref`.}]>:$updates ); let results = (outs); @@ -10754,9 +11414,9 @@ Requires `updates.shape = indices.shape + ref.shape[1:]` or `updates.shape = []` }]; let arguments = (ins - Arg:$resource, - TF_I32OrI64Tensor:$indices, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$updates + Arg:$resource, + Arg:$indices, + Arg, [{A tensor of updated values to add to `ref`.}]>:$updates ); let results = (outs); @@ -10807,9 +11467,11 @@ slices. }]; let arguments = (ins - Arg:$ref, - TF_I32OrI64Tensor:$indices, - TF_Tensor:$updates, + Arg:$ref, + Arg:$indices, + Arg:$updates, DefaultValuedAttr:$use_locking ); @@ -10862,9 +11524,11 @@ slices. }]; let arguments = (ins - Arg:$ref, - TF_I32OrI64Tensor:$indices, - TF_Tensor:$updates, + Arg:$ref, + Arg:$indices, + Arg:$updates, DefaultValuedAttr:$use_locking ); @@ -10919,9 +11583,11 @@ slices. }]; let arguments = (ins - Arg:$ref, - TF_I32OrI64Tensor:$indices, - TF_Tensor:$updates, + Arg:$ref, + Arg:$indices, + Arg:$updates, DefaultValuedAttr:$use_locking ); @@ -10960,9 +11626,9 @@ Requires `updates.shape = indices.shape + ref.shape[1:]` or `updates.shape = []` }]; let arguments = (ins - Arg:$resource, - TF_I32OrI64Tensor:$indices, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$updates + Arg:$resource, + Arg:$indices, + Arg, [{A tensor of updated values to add to `ref`.}]>:$updates ); let results = (outs); @@ -10990,9 +11656,9 @@ This operation computes }]; let arguments = (ins - Arg:$resource, - TF_I32OrI64Tensor:$indices, - TF_Tensor:$updates + Arg:$resource, + Arg:$indices, + Arg:$updates ); let results = (outs); @@ -11033,6 +11699,44 @@ shape must be exactly the shape produced by the slice of `ref`. TF_DerivedOperandTypeAttr Index = TF_DerivedOperandTypeAttr<1>; } +def TF_RestoreOp : TF_Op<"Restore", []> { + let summary = "Restores a tensor from checkpoint files."; + + let description = [{ +Reads a tensor stored in one or several files. If there are several files (for +instance because a tensor was saved as slices), `file_pattern` may contain +wildcard symbols (`*` and `?`) in the filename portion only, not in the +directory portion. + +If a `file_pattern` matches several files, `preferred_shard` can be used to hint +in which file the requested tensor is likely to be found. This op will first +open the file at index `preferred_shard` in the list of matching files and try +to restore tensors from that file. Only if some tensors or tensor slices are +not found in that first file, then the Op opens all the files. Setting +`preferred_shard` to match the value passed as the `shard` input +of a matching `Save` Op may speed up Restore. This attribute only affects +performance, not correctness. The default value -1 means files are processed in +order. + +See also `RestoreSlice`. + }]; + + let arguments = (ins + Arg:$file_pattern, + Arg:$tensor_name, + + DefaultValuedAttr:$preferred_shard + ); + + let results = (outs + Res:$tensor + ); + + TF_DerivedResultTypeAttr dt = TF_DerivedResultTypeAttr<0>; +} + def TF_RestoreV2Op : TF_Op<"RestoreV2", []> { let summary = "Restores tensors from a V2 checkpoint."; @@ -11053,13 +11757,15 @@ Callers must ensure all the named tensors are indeed stored in the checkpoint. }]; let arguments = (ins - TF_StrTensor:$prefix, - TF_StrTensor:$tensor_names, - TF_StrTensor:$shape_and_slices + Arg:$prefix, + Arg:$tensor_names, + Arg:$shape_and_slices ); let results = (outs - Variadic:$tensors + Res, [{shape {N}. The restored tensors, whose shapes are read from the +checkpoint directly.}]>:$tensors ); TF_DerivedResultTypeListAttr dtypes = TF_DerivedResultTypeListAttr<0>; @@ -11084,9 +11790,9 @@ used to retrieve updated parameters before saving a checkpoint. ); let results = (outs - TF_Float32Tensor:$parameters, - TF_Float32Tensor:$momenta, - TF_Float32Tensor:$velocities + Res:$parameters, + Res:$momenta, + Res:$velocities ); } @@ -11109,10 +11815,10 @@ used to retrieve updated parameters before saving a checkpoint. ); let results = (outs - TF_Float32Tensor:$parameters, - TF_Float32Tensor:$momenta, - TF_Float32Tensor:$velocities, - TF_Float32Tensor:$gradient_accumulators + Res:$parameters, + Res:$momenta, + Res:$velocities, + Res:$gradient_accumulators ); } @@ -11135,9 +11841,9 @@ used to retrieve updated parameters before saving a checkpoint. ); let results = (outs - TF_Float32Tensor:$parameters, - TF_Float32Tensor:$accumulators, - TF_Float32Tensor:$updates + Res:$parameters, + Res:$accumulators, + Res:$updates ); } @@ -11160,10 +11866,10 @@ used to retrieve updated parameters before saving a checkpoint. ); let results = (outs - TF_Float32Tensor:$parameters, - TF_Float32Tensor:$accumulators, - TF_Float32Tensor:$updates, - TF_Float32Tensor:$gradient_accumulators + Res:$parameters, + Res:$accumulators, + Res:$updates, + Res:$gradient_accumulators ); } @@ -11186,8 +11892,8 @@ used to retrieve updated parameters before saving a checkpoint. ); let results = (outs - TF_Float32Tensor:$parameters, - TF_Float32Tensor:$accumulators + Res:$parameters, + Res:$accumulators ); } @@ -11210,9 +11916,9 @@ used to retrieve updated parameters before saving a checkpoint. ); let results = (outs - TF_Float32Tensor:$parameters, - TF_Float32Tensor:$accumulators, - TF_Float32Tensor:$gradient_accumulators + Res:$parameters, + Res:$accumulators, + Res:$gradient_accumulators ); } @@ -11235,10 +11941,10 @@ used to retrieve updated parameters before saving a checkpoint. ); let results = (outs - TF_Float32Tensor:$parameters, - TF_Float32Tensor:$ms, - TF_Float32Tensor:$mom, - TF_Float32Tensor:$mg + Res:$parameters, + Res:$ms, + Res:$mom, + Res:$mg ); } @@ -11261,9 +11967,9 @@ used to retrieve updated parameters before saving a checkpoint. ); let results = (outs - TF_Float32Tensor:$parameters, - TF_Float32Tensor:$accumulators, - TF_Float32Tensor:$linears + Res:$parameters, + Res:$accumulators, + Res:$linears ); } @@ -11286,10 +11992,10 @@ used to retrieve updated parameters before saving a checkpoint. ); let results = (outs - TF_Float32Tensor:$parameters, - TF_Float32Tensor:$accumulators, - TF_Float32Tensor:$linears, - TF_Float32Tensor:$gradient_accumulators + Res:$parameters, + Res:$accumulators, + Res:$linears, + Res:$gradient_accumulators ); } @@ -11312,10 +12018,10 @@ used to retrieve updated parameters before saving a checkpoint. ); let results = (outs - TF_Float32Tensor:$parameters, - TF_Float32Tensor:$accumulators, - TF_Float32Tensor:$weights, - TF_Float32Tensor:$benefits + Res:$parameters, + Res:$accumulators, + Res:$weights, + Res:$benefits ); } @@ -11338,8 +12044,8 @@ used to retrieve updated parameters before saving a checkpoint. ); let results = (outs - TF_Float32Tensor:$parameters, - TF_Float32Tensor:$momenta + Res:$parameters, + Res:$momenta ); } @@ -11362,9 +12068,9 @@ used to retrieve updated parameters before saving a checkpoint. ); let results = (outs - TF_Float32Tensor:$parameters, - TF_Float32Tensor:$momenta, - TF_Float32Tensor:$gradient_accumulators + Res:$parameters, + Res:$momenta, + Res:$gradient_accumulators ); } @@ -11387,8 +12093,8 @@ used to retrieve updated parameters before saving a checkpoint. ); let results = (outs - TF_Float32Tensor:$parameters, - TF_Float32Tensor:$accumulators + Res:$parameters, + Res:$accumulators ); } @@ -11413,9 +12119,9 @@ used to retrieve updated parameters before saving a checkpoint. ); let results = (outs - TF_Float32Tensor:$parameters, - TF_Float32Tensor:$accumulators, - TF_Float32Tensor:$gradient_accumulators + Res:$parameters, + Res:$accumulators, + Res:$gradient_accumulators ); } @@ -11475,9 +12181,9 @@ used to retrieve updated parameters before saving a checkpoint. ); let results = (outs - TF_Float32Tensor:$parameters, - TF_Float32Tensor:$ms, - TF_Float32Tensor:$mom + Res:$parameters, + Res:$ms, + Res:$mom ); } @@ -11500,10 +12206,10 @@ used to retrieve updated parameters before saving a checkpoint. ); let results = (outs - TF_Float32Tensor:$parameters, - TF_Float32Tensor:$ms, - TF_Float32Tensor:$mom, - TF_Float32Tensor:$gradient_accumulators + Res:$parameters, + Res:$ms, + Res:$mom, + Res:$gradient_accumulators ); } @@ -11526,7 +12232,7 @@ used to retrieve updated parameters before saving a checkpoint. ); let results = (outs - TF_Float32Tensor:$parameters + Res:$parameters ); } @@ -11549,8 +12255,8 @@ used to retrieve updated parameters before saving a checkpoint. ); let results = (outs - TF_Float32Tensor:$parameters, - TF_Float32Tensor:$gradient_accumulators + Res:$parameters, + Res:$gradient_accumulators ); } @@ -11615,15 +12321,16 @@ output[2:, :, 3, :, ...] = input[2:, :, 3, :, ...] }]; let arguments = (ins - TF_Tensor:$input, - TF_I32OrI64Tensor:$seq_lengths, + Arg:$input, + Arg:$seq_lengths, I64Attr:$seq_dim, DefaultValuedAttr:$batch_dim ); let results = (outs - TF_Tensor:$output + Res:$output ); TF_DerivedOperandTypeAttr Tlen = TF_DerivedOperandTypeAttr<1>; @@ -11683,12 +12390,13 @@ reverse(t, dims) ==> [[[[8, 9, 10, 11], }]; let arguments = (ins - TensorOf<[TF_Bfloat16, TF_Bool, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Str, TF_Uint16, TF_Uint8]>:$tensor, - TF_I32OrI64Tensor:$axis + Arg, [{Up to 8-D.}]>:$tensor, + Arg:$axis ); let results = (outs - TensorOf<[TF_Bfloat16, TF_Bool, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Str, TF_Uint16, TF_Uint8]>:$output + Res, [{The same shape as `tensor`.}]>:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -11814,6 +12522,27 @@ def TF_RiscDotOp : TF_Op<"RiscDot", [NoSideEffect]> { TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; } +def TF_RngReadAndSkipOp : TF_Op<"RngReadAndSkip", []> { + let summary = "Advance the counter of a counter-based RNG."; + + let description = [{ +The state of the RNG after +`rng_read_and_skip(n)` will be the same as that after `uniform([n])` +(or any other distribution). The actual increment added to the +counter is an unspecified implementation choice. + }]; + + let arguments = (ins + TF_ResourceTensor:$resource, + TF_Int32Tensor:$alg, + TF_Uint64Tensor:$delta + ); + + let results = (outs + TF_Int64Tensor:$value + ); +} + def TF_RollOp : TF_Op<"Roll", [NoSideEffect]> { let summary = "Rolls the elements of a tensor along an axis."; @@ -11842,12 +12571,20 @@ roll(t, shift=[2, -3], axis=[1, 1]) ==> [[1, 2, 3, 4, 0], [6, 7, 8, 9, 5]] let arguments = (ins TF_Tensor:$input, - TF_I32OrI64Tensor:$shift, - TF_I32OrI64Tensor:$axis + Arg:$shift, + Arg:$axis ); let results = (outs - TF_Tensor:$output + Res:$output ); TF_DerivedOperandTypeAttr Tshift = TF_DerivedOperandTypeAttr<1>; @@ -11894,7 +12631,7 @@ I.e., \\(y = 1 / \sqrt{x}\\). TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; } -def TF_RsqrtGradOp : TF_Op<"RsqrtGrad", [NoSideEffect, SameOperandsAndResultType]> { +def TF_RsqrtGradOp : TF_Op<"RsqrtGrad", [NoSideEffect, TF_SameOperandsAndResultTypeResolveRef]> { let summary = "Computes the gradient for the rsqrt of `x` wrt its input."; let description = [{ @@ -11914,6 +12651,69 @@ is the corresponding input gradient. TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; } +def TF_SaveOp : TF_Op<"Save", []> { + let summary = "Saves the input tensors to disk."; + + let description = [{ +The size of `tensor_names` must match the number of tensors in `data`. `data[i]` +is written to `filename` with name `tensor_names[i]`. + +See also `SaveSlices`. + }]; + + let arguments = (ins + Arg:$filename, + Arg:$tensor_names, + Arg, [{`N` tensors to save.}]>:$data + ); + + let results = (outs); + + TF_DerivedOperandTypeListAttr T = TF_DerivedOperandTypeListAttr<2>; +} + +def TF_SaveSlicesOp : TF_Op<"SaveSlices", []> { + let summary = "Saves input tensors slices to disk."; + + let description = [{ +This is like `Save` except that tensors can be listed in the saved file as being +a slice of a larger tensor. `shapes_and_slices` specifies the shape of the +larger tensor and the slice that this tensor covers. `shapes_and_slices` must +have as many elements as `tensor_names`. + +Elements of the `shapes_and_slices` input must either be: + +* The empty string, in which case the corresponding tensor is + saved normally. +* A string of the form `dim0 dim1 ... dimN-1 slice-spec` where the + `dimI` are the dimensions of the larger tensor and `slice-spec` + specifies what part is covered by the tensor to save. + +`slice-spec` itself is a `:`-separated list: `slice0:slice1:...:sliceN-1` +where each `sliceI` is either: + +* The string `-` meaning that the slice covers all indices of this dimension +* `start,length` where `start` and `length` are integers. In that + case the slice covers `length` indices starting at `start`. + +See also `Save`. + }]; + + let arguments = (ins + Arg:$filename, + Arg:$tensor_names, + Arg:$shapes_and_slices, + Arg, [{`N` tensors to save.}]>:$data + ); + + let results = (outs); + + TF_DerivedOperandTypeListAttr T = TF_DerivedOperandTypeListAttr<3>; +} + def TF_SaveV2Op : TF_Op<"SaveV2", []> { let summary = "Saves tensors in V2 checkpoint format."; @@ -11924,10 +12724,12 @@ and correspondingly well-formed. }]; let arguments = (ins - TF_StrTensor:$prefix, - TF_StrTensor:$tensor_names, - TF_StrTensor:$shape_and_slices, - Variadic:$tensors + Arg:$prefix, + Arg:$tensor_names, + Arg:$shape_and_slices, + Arg, [{`N` tensors to save.}]>:$tensors ); let results = (outs); @@ -12022,13 +12824,14 @@ On GPU, if an out of bound index is found, the index is ignored. }]; let arguments = (ins - TF_I32OrI64Tensor:$indices, - TF_Tensor:$updates, - TF_I32OrI64Tensor:$shape + Arg:$indices, + Arg:$updates, + Arg:$shape ); let results = (outs - TF_Tensor:$output + Res:$output ); TF_DerivedOperandTypeAttr Tindices = TF_DerivedOperandTypeAttr<0>; @@ -12065,11 +12868,13 @@ tf.segment_max(c, tf.constant([0, 0, 1])) let arguments = (ins TF_IntOrFpTensor:$data, - TF_I32OrI64Tensor:$segment_ids + Arg:$segment_ids ); let results = (outs - TF_IntOrFpTensor:$output + Res:$output ); TF_DerivedOperandTypeAttr Tindices = TF_DerivedOperandTypeAttr<1>; @@ -12107,11 +12912,13 @@ tf.segment_mean(c, tf.constant([0, 0, 1])) let arguments = (ins TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$data, - TF_I32OrI64Tensor:$segment_ids + Arg:$segment_ids ); let results = (outs - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$output + Res, [{Has same shape as data, except for dimension 0 which +has size `k`, the number of segments.}]>:$output ); TF_DerivedOperandTypeAttr Tindices = TF_DerivedOperandTypeAttr<1>; @@ -12148,11 +12955,13 @@ tf.segment_min(c, tf.constant([0, 0, 1])) let arguments = (ins TF_IntOrFpTensor:$data, - TF_I32OrI64Tensor:$segment_ids + Arg:$segment_ids ); let results = (outs - TF_IntOrFpTensor:$output + Res:$output ); TF_DerivedOperandTypeAttr Tindices = TF_DerivedOperandTypeAttr<1>; @@ -12189,11 +12998,13 @@ tf.segment_prod(c, tf.constant([0, 0, 1])) let arguments = (ins TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$data, - TF_I32OrI64Tensor:$segment_ids + Arg:$segment_ids ); let results = (outs - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$output + Res, [{Has same shape as data, except for dimension 0 which +has size `k`, the number of segments.}]>:$output ); TF_DerivedOperandTypeAttr Tindices = TF_DerivedOperandTypeAttr<1>; @@ -12230,11 +13041,13 @@ tf.segment_sum(c, tf.constant([0, 0, 1])) let arguments = (ins TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$data, - TF_I32OrI64Tensor:$segment_ids + Arg:$segment_ids ); let results = (outs - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$output + Res, [{Has same shape as data, except for dimension 0 which +has size `k`, the number of segments.}]>:$output ); TF_DerivedOperandTypeAttr Tindices = TF_DerivedOperandTypeAttr<1>; @@ -12287,17 +13100,18 @@ select(condition, t, e) ==> [[1, 2], let arguments = (ins TF_BoolTensor:$condition, - TF_Tensor:$t, - TF_Tensor:$e + Arg:$t, + Arg:$e ); let results = (outs - TF_Tensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<1>; - let verifier = [{ return Verify(*this); }]; @@ -12319,7 +13133,7 @@ def TF_SelectV2Op : TF_Op<"SelectV2", [NoSideEffect, ResultsBroadcastableShape]> TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<1>; let builders = [ - OpBuilderDAG<(ins "Value":$condition, "Value":$e, "Value":$t)> + OpBuilder<(ins "Value":$condition, "Value":$e, "Value":$t)> ]; } @@ -12343,20 +13157,20 @@ e = self_adjoint_eig(a, compute_v=False) }]; let arguments = (ins - TensorOf<[TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64]>:$input, + Arg, [{`Tensor` input of shape `[N, N]`.}]>:$input, DefaultValuedAttr:$compute_v ); let results = (outs - TensorOf<[TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64]>:$e, - TensorOf<[TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64]>:$v + Res, [{Eigenvalues. Shape is `[N]`.}]>:$e, + Res, [{Eigenvectors. Shape is `[N, N]`.}]>:$v ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; } -def TF_SeluOp : TF_Op<"Selu", [NoSideEffect, SameOperandsAndResultType]> { +def TF_SeluOp : TF_Op<"Selu", [NoSideEffect, TF_SameOperandsAndResultTypeResolveRef]> { let summary = [{ Computes scaled exponential linear: `scale * alpha * (exp(features) - 1)` }]; @@ -12382,37 +13196,74 @@ See [Self-Normalizing Neural Networks](https://arxiv.org/abs/1706.02515) TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; } -def TF_SeluGradOp : TF_Op<"SeluGrad", [NoSideEffect, SameOperandsAndResultType]> { +def TF_SeluGradOp : TF_Op<"SeluGrad", [NoSideEffect, TF_SameOperandsAndResultTypeResolveRef]> { let summary = [{ Computes gradients for the scaled exponential linear (Selu) operation. }]; let arguments = (ins - TF_FloatTensor:$gradients, - TF_FloatTensor:$outputs + Arg:$gradients, + Arg:$outputs ); let results = (outs - TF_FloatTensor:$backprops + Res:$backprops ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; } +def TF_SendOp : TF_Op<"Send", []> { + let summary = "Sends the named tensor from send_device to recv_device."; + + let arguments = (ins + Arg:$tensor, + + StrAttr:$tensor_name, + StrAttr:$send_device, + I64Attr:$send_device_incarnation, + StrAttr:$recv_device, + DefaultValuedAttr:$client_terminated + ); + + let results = (outs); + + TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; +} + def TF_SerializeIteratorOp : TF_Op<"SerializeIterator", []> { let summary = [{ Converts the given `resource_handle` representing an iterator to a variant tensor. }]; let arguments = (ins - Arg:$resource_handle, + Arg:$resource_handle, DefaultValuedAttr:$external_state_policy ); let results = (outs - TF_VariantTensor:$serialized + Res:$serialized + ); +} + +def TF_SerializeSparseOp : TF_Op<"SerializeSparse", [NoSideEffect]> { + let summary = "Serialize a `SparseTensor` into a `[3]` `Tensor` object."; + + let arguments = (ins + Arg:$sparse_indices, + Arg:$sparse_values, + Arg:$sparse_shape ); + + let results = (outs + TensorOf<[TF_Str, TF_Variant]>:$serialized_sparse + ); + + TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<1>; + TF_DerivedResultTypeAttr out_type = TF_DerivedResultTypeAttr<0>; } def TF_ShapeOp : TF_Op<"Shape", [NoSideEffect]> { @@ -12445,9 +13296,8 @@ shape(t) ==> [2, 2, 3] }]; let builders = [ - OpBuilderDAG<(ins "Value":$input, "BoolAttr":$use32Bit)> + OpBuilder<(ins "Value":$input, "BoolAttr":$use32Bit)> ]; - } def TF_ShapeNOp : TF_Op<"ShapeN", [NoSideEffect]> { @@ -12472,7 +13322,6 @@ This operation returns N 1-D integer tensors representing shape of `input[i]s`. let verifier = [{ return Verify(*this); }]; - } def TF_ShardedFilenameOp : TF_Op<"ShardedFilename", [NoSideEffect]> { @@ -12565,7 +13414,7 @@ The op returns an error if no system is running. let results = (outs); } -def TF_SigmoidOp : TF_Op<"Sigmoid", [NoSideEffect, SameOperandsAndResultType]> { +def TF_SigmoidOp : TF_Op<"Sigmoid", [NoSideEffect, TF_SameOperandsAndResultTypeResolveRef]> { let summary = "Computes sigmoid of `x` element-wise."; let description = [{ @@ -12583,7 +13432,7 @@ Specifically, `y = 1 / (1 + exp(-x))`. TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; } -def TF_SigmoidGradOp : TF_Op<"SigmoidGrad", [NoSideEffect, SameOperandsAndResultType]> { +def TF_SigmoidGradOp : TF_Op<"SigmoidGrad", [NoSideEffect, TF_SameOperandsAndResultTypeResolveRef]> { let summary = "Computes the gradient of the sigmoid of `x` wrt its input."; let description = [{ @@ -12652,7 +13501,7 @@ Given an input tensor, this function computes sine of every TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; } -def TF_SinhOp : TF_Op<"Sinh", [NoSideEffect, SameOperandsAndResultType]> { +def TF_SinhOp : TF_Op<"Sinh", [NoSideEffect, TF_SameOperandsAndResultTypeResolveRef]> { let summary = "Computes hyperbolic sine of x element-wise."; let description = [{ @@ -12706,7 +13555,6 @@ size(t) ==> 12 let verifier = [{ return Verify(*this); }]; - } def TF_SliceOp : TF_Op<"Slice", [NoSideEffect]> { @@ -12723,8 +13571,12 @@ whose values are extracted from 'input' starting at the offsets in let arguments = (ins TF_Tensor:$input, - TF_I32OrI64Tensor:$begin, - TF_I32OrI64Tensor:$size + Arg:$begin, + Arg:$size ); let results = (outs @@ -12739,7 +13591,7 @@ whose values are extracted from 'input' starting at the offsets in }]; } -def TF_SnapshotOp : TF_Op<"Snapshot", [NoSideEffect, SameOperandsAndResultType]> { +def TF_SnapshotOp : TF_Op<"Snapshot", [NoSideEffect, TF_SameOperandsAndResultTypeResolveRef]> { let summary = "Returns a copy of the input tensor."; let arguments = (ins @@ -12763,11 +13615,11 @@ For each batch `i` and class `j` we have }]; let arguments = (ins - TF_FloatTensor:$logits + Arg:$logits ); let results = (outs - TF_FloatTensor:$softmax + Res:$softmax ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -12787,13 +13639,15 @@ Inputs are the logits, not probabilities. }]; let arguments = (ins - TF_FloatTensor:$features, - TF_FloatTensor:$labels + Arg:$features, + Arg:$labels ); let results = (outs - TF_FloatTensor:$loss, - TF_FloatTensor:$backprop + Res:$loss, + Res:$backprop ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -12803,7 +13657,7 @@ Inputs are the logits, not probabilities. }]; } -def TF_SoftplusOp : TF_Op<"Softplus", [NoSideEffect, SameOperandsAndResultType]> { +def TF_SoftplusOp : TF_Op<"Softplus", [NoSideEffect, TF_SameOperandsAndResultTypeResolveRef]> { let summary = "Computes softplus: `log(exp(features) + 1)`."; let arguments = (ins @@ -12817,22 +13671,22 @@ def TF_SoftplusOp : TF_Op<"Softplus", [NoSideEffect, SameOperandsAndResultType]> TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; } -def TF_SoftplusGradOp : TF_Op<"SoftplusGrad", [NoSideEffect, SameOperandsAndResultType]> { +def TF_SoftplusGradOp : TF_Op<"SoftplusGrad", [NoSideEffect, TF_SameOperandsAndResultTypeResolveRef]> { let summary = "Computes softplus gradients for a softplus operation."; let arguments = (ins - TF_FloatTensor:$gradients, - TF_FloatTensor:$features + Arg:$gradients, + Arg:$features ); let results = (outs - TF_FloatTensor:$backprops + Res:$backprops ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; } -def TF_SoftsignOp : TF_Op<"Softsign", [NoSideEffect, SameOperandsAndResultType]> { +def TF_SoftsignOp : TF_Op<"Softsign", [NoSideEffect, TF_SameOperandsAndResultTypeResolveRef]> { let summary = "Computes softsign: `features / (abs(features) + 1)`."; let arguments = (ins @@ -12846,16 +13700,16 @@ def TF_SoftsignOp : TF_Op<"Softsign", [NoSideEffect, SameOperandsAndResultType]> TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; } -def TF_SoftsignGradOp : TF_Op<"SoftsignGrad", [NoSideEffect, SameOperandsAndResultType]> { +def TF_SoftsignGradOp : TF_Op<"SoftsignGrad", [NoSideEffect, TF_SameOperandsAndResultTypeResolveRef]> { let summary = "Computes softsign gradients for a softsign operation."; let arguments = (ins - TF_FloatTensor:$gradients, - TF_FloatTensor:$features + Arg:$gradients, + Arg:$features ); let results = (outs - TF_FloatTensor:$backprops + Res:$backprops ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -12875,8 +13729,92 @@ block size. }]; let arguments = (ins - TF_Tensor:$input, - TF_I32OrI64Tensor:$paddings, + Arg:$input, + Arg:$paddings, Confined]>:$block_size ); @@ -12904,9 +13842,117 @@ precise description. }]; let arguments = (ins - TF_Tensor:$input, - TF_I32OrI64Tensor:$block_shape, - TF_I32OrI64Tensor:$paddings + Arg:$input, + Arg= 1.}]>:$block_shape, + Arg= 0. + `paddings[i] = [pad_start, pad_end]` specifies the padding for input dimension + `i + 1`, which corresponds to spatial dimension `i`. It is required that + `block_shape[i]` divides `input_shape[i + 1] + pad_start + pad_end`. + +This operation is equivalent to the following steps: + +1. Zero-pad the start and end of dimensions `[1, ..., M]` of the + input according to `paddings` to produce `padded` of shape `padded_shape`. + +2. Reshape `padded` to `reshaped_padded` of shape: + + [batch] + + [padded_shape[1] / block_shape[0], + block_shape[0], + ..., + padded_shape[M] / block_shape[M-1], + block_shape[M-1]] + + remaining_shape + +3. Permute dimensions of `reshaped_padded` to produce + `permuted_reshaped_padded` of shape: + + block_shape + + [batch] + + [padded_shape[1] / block_shape[0], + ..., + padded_shape[M] / block_shape[M-1]] + + remaining_shape + +4. Reshape `permuted_reshaped_padded` to flatten `block_shape` into the batch + dimension, producing an output tensor of shape: + + [batch * prod(block_shape)] + + [padded_shape[1] / block_shape[0], + ..., + padded_shape[M] / block_shape[M-1]] + + remaining_shape + +Some examples: + +(1) For the following input of shape `[1, 2, 2, 1]`, `block_shape = [2, 2]`, and + `paddings = [[0, 0], [0, 0]]`: + +``` +x = [[[[1], [2]], [[3], [4]]]] +``` + +The output tensor has shape `[4, 1, 1, 1]` and value: + +``` +[[[[1]]], [[[2]]], [[[3]]], [[[4]]]] +``` + +(2) For the following input of shape `[1, 2, 2, 3]`, `block_shape = [2, 2]`, and + `paddings = [[0, 0], [0, 0]]`: + +``` +x = [[[[1, 2, 3], [4, 5, 6]], + [[7, 8, 9], [10, 11, 12]]]] +``` + +The output tensor has shape `[4, 1, 1, 3]` and value: + +``` +[[[[1, 2, 3]]], [[[4, 5, 6]]], [[[7, 8, 9]]], [[[10, 11, 12]]]] +``` + +(3) For the following input of shape `[1, 4, 4, 1]`, `block_shape = [2, 2]`, and + `paddings = [[0, 0], [0, 0]]`: + +``` +x = [[[[1], [2], [3], [4]], + [[5], [6], [7], [8]], + [[9], [10], [11], [12]], + [[13], [14], [15], [16]]]] +``` + +The output tensor has shape `[4, 2, 2, 1]` and value: + +``` +x = [[[[1], [3]], [[9], [11]]], + [[[2], [4]], [[10], [12]]], + [[[5], [7]], [[13], [15]]], + [[[6], [8]], [[14], [16]]]] +``` + +(4) For the following input of shape `[2, 2, 4, 1]`, block_shape = `[2, 2]`, and + paddings = `[[0, 0], [2, 0]]`: + +``` +x = [[[[1], [2], [3], [4]], + [[5], [6], [7], [8]]], + [[[9], [10], [11], [12]], + [[13], [14], [15], [16]]]] +``` + +The output tensor has shape `[8, 1, 3, 1]` and value: + +``` +x = [[[[0], [1], [3]]], [[[0], [9], [11]]], + [[[0], [2], [4]]], [[[0], [10], [12]]], + [[[0], [5], [7]]], [[[0], [13], [15]]], + [[[0], [6], [8]]], [[[0], [14], [16]]]] +``` + +Among others, this operation is useful for reducing atrous convolution into +regular convolution.}]>:$paddings ); let results = (outs @@ -12918,12 +13964,6 @@ precise description. TF_DerivedOperandTypeAttr Tblock_shape = TF_DerivedOperandTypeAttr<1>; let verifier = [{ return Verify(*this); }]; - - let extraClassDeclaration = [{ - static bool isCompatibleReturnTypes(ArrayRef l, ArrayRef r) { - return ArraysAreCastCompatible(l, r); - } - }]; } def TF_SpaceToDepthOp : TF_Op<"SpaceToDepth", [NoSideEffect]> { @@ -13074,17 +14114,20 @@ backpropagation, }]; let arguments = (ins - TF_Int64Tensor:$indices, - TF_Tensor:$values, - TF_Int64Tensor:$dense_shape, - TF_Tensor:$default_value + Arg:$indices, + Arg:$values, + Arg:$dense_shape, + Arg:$default_value ); let results = (outs TF_Int64Tensor:$output_indices, - TF_Tensor:$output_values, - TF_BoolTensor:$empty_row_indicator, - TF_Int64Tensor:$reverse_index_map + Res:$output_values, + Res:$empty_row_indicator, + Res:$reverse_index_map ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<1>; @@ -13149,14 +14192,18 @@ has length `R_out`, then `input_indices` has shape `[N, R_in]`, }]; let arguments = (ins - TF_Int64Tensor:$input_indices, - TF_Int64Tensor:$input_shape, - TF_Int64Tensor:$new_shape + Arg:$input_indices, + Arg:$input_shape, + Arg:$new_shape ); let results = (outs - TF_Int64Tensor:$output_indices, - TF_Int64Tensor:$output_shape + Res:$output_indices, + Res:$output_shape ); } @@ -13172,12 +14219,13 @@ dimension, selecting a subset of dimension 0, specified by `indices`. let arguments = (ins TensorOf<[TF_Bfloat16, TF_Float32, TF_Float64]>:$data, - TF_I32OrI64Tensor:$indices, - TF_I32OrI64Tensor:$segment_ids + Arg:$indices, + Arg:$segment_ids ); let results = (outs - TensorOf<[TF_Bfloat16, TF_Float32, TF_Float64]>:$output + Res, [{Has same shape as data, except for dimension 0 which +has size `k`, the number of segments.}]>:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -13198,12 +14246,13 @@ See `tf.sparse.segment_sum` for usage examples. let arguments = (ins TensorOf<[TF_Bfloat16, TF_Float32, TF_Float64]>:$data, - TF_I32OrI64Tensor:$indices, - TF_I32OrI64Tensor:$segment_ids + Arg:$indices, + Arg:$segment_ids ); let results = (outs - TensorOf<[TF_Bfloat16, TF_Float32, TF_Float64]>:$output + Res, [{Has same shape as data, except for dimension 0 which +has size `k`, the number of segments.}]>:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -13248,12 +14297,13 @@ tf.segment_sum(c, tf.constant([0, 0, 1])) let arguments = (ins TF_IntOrFpTensor:$data, - TF_I32OrI64Tensor:$indices, - TF_I32OrI64Tensor:$segment_ids + Arg:$indices, + Arg:$segment_ids ); let results = (outs - TF_IntOrFpTensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -13276,13 +14326,14 @@ Inputs are the logits, not probabilities. }]; let arguments = (ins - TF_FloatTensor:$features, - TF_I32OrI64Tensor:$labels + Arg:$features, + Arg:$labels ); let results = (outs - TF_FloatTensor:$loss, - TF_FloatTensor:$backprop + Res:$loss, + Res:$backprop ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -13317,16 +14368,19 @@ are checked during execution. }]; let arguments = (ins - TF_I32OrI64Tensor:$sparse_indices, - TF_I32OrI64Tensor:$output_shape, - TF_Tensor:$sparse_values, - TF_Tensor:$default_value, + Arg:$sparse_indices, + Arg:$output_shape, + Arg:$sparse_values, + Arg:$default_value, DefaultValuedAttr:$validate_indices ); let results = (outs - TF_Tensor:$dense + Res:$dense ); TF_DerivedOperandTypeAttr Tindices = TF_DerivedOperandTypeAttr<0>; @@ -13337,12 +14391,15 @@ def TF_SplitOp : TF_Op<"Split", [NoSideEffect]> { let summary = "Splits a tensor into `num_split` tensors along one dimension."; let arguments = (ins - TF_Int32Tensor:$split_dim, - TF_Tensor:$value + Arg:$split_dim, + Arg:$value ); let results = (outs - Variadic:$output + Res, [{They are identically shaped tensors, whose shape matches that of `value` +except along `axis`, where their sizes are +`values.shape[split_dim] / num_split`.}]>:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<1>; @@ -13355,13 +14412,18 @@ def TF_SplitVOp : TF_Op<"SplitV", [NoSideEffect]> { let summary = "Splits a tensor into `num_split` tensors along one dimension."; let arguments = (ins - TF_Tensor:$value, - TF_I32OrI64Tensor:$size_splits, - TF_Int32Tensor:$split_dim + Arg:$value, + Arg:$size_splits, + Arg:$split_dim ); let results = (outs - Variadic:$output + Res, [{Tensors whose shape matches that of `value` +except along `axis`, where their sizes are +`size_splits[i]`.}]>:$output ); TF_DerivedOperandTypeAttr Tlen = TF_DerivedOperandTypeAttr<1>; @@ -13389,7 +14451,7 @@ I.e., \\(y = \sqrt{x} = x^{1/2}\\). TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; } -def TF_SqrtGradOp : TF_Op<"SqrtGrad", [NoSideEffect, SameOperandsAndResultType]> { +def TF_SqrtGradOp : TF_Op<"SqrtGrad", [NoSideEffect, TF_SameOperandsAndResultTypeResolveRef]> { let summary = "Computes the gradient for the sqrt of `x` wrt its input."; let description = [{ @@ -13425,7 +14487,6 @@ I.e., \\(y = x * x = x^2\\). ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; - } def TF_SquaredDifferenceOp : TF_Op<"SquaredDifference", [Commutative, NoSideEffect, ResultsBroadcastableShape]>, @@ -13474,13 +14535,14 @@ shape(squeeze(t, [2, 4])) ==> [1, 2, 3, 1] }]; let arguments = (ins - TF_Tensor:$input, + Arg:$input, DefaultValuedAttr:$squeeze_dims ); let results = (outs - TF_Tensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -13490,7 +14552,7 @@ def TF_StackCloseV2Op : TF_Op<"StackCloseV2", []> { let summary = "Delete the stack from its resource container."; let arguments = (ins - Arg:$handle + Arg:$handle ); let results = (outs); @@ -13500,11 +14562,11 @@ def TF_StackPopV2Op : TF_Op<"StackPopV2", []> { let summary = "Pop the element at the top of the stack."; let arguments = (ins - Arg:$handle + Arg:$handle ); let results = (outs - TF_Tensor:$elem + Res:$elem ); TF_DerivedResultTypeAttr elem_type = TF_DerivedResultTypeAttr<0>; @@ -13514,14 +14576,14 @@ def TF_StackPushV2Op : TF_Op<"StackPushV2", []> { let summary = "Push an element onto the stack."; let arguments = (ins - Arg:$handle, - TF_Tensor:$elem, + Arg:$handle, + Arg:$elem, DefaultValuedAttr:$swap_memory ); let results = (outs - TF_Tensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<1>; @@ -13531,14 +14593,15 @@ def TF_StackV2Op : TF_Op<"StackV2", []> { let summary = "A stack that produces elements in first-in last-out order."; let arguments = (ins - TF_Int32Tensor:$max_size, + Arg:$max_size, TypeAttr:$elem_type, StrAttr:$stack_name ); let results = (outs - Res:$handle + Res:$handle ); } @@ -13546,13 +14609,15 @@ def TF_StatelessMultinomialOp : TF_Op<"StatelessMultinomial", [NoSideEffect, TF_ let summary = "Draws samples from a multinomial distribution."; let arguments = (ins - TF_IntOrFpTensor:$logits, - TF_Int32Tensor:$num_samples, - TF_I32OrI64Tensor:$seed + Arg:$logits, + Arg:$num_samples, + Arg:$seed ); let results = (outs - TF_I32OrI64Tensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -13564,16 +14629,18 @@ def TF_StatelessParameterizedTruncatedNormalOp : TF_Op<"StatelessParameterizedTr let summary = ""; let arguments = (ins - TF_I32OrI64Tensor:$shape, - TF_I32OrI64Tensor:$seed, - TensorOf<[TF_Float16, TF_Float32, TF_Float64]>:$means, - TensorOf<[TF_Float16, TF_Float32, TF_Float64]>:$stddevs, - TensorOf<[TF_Float16, TF_Float32, TF_Float64]>:$minvals, - TensorOf<[TF_Float16, TF_Float32, TF_Float64]>:$maxvals + Arg:$shape, + Arg:$seed, + Arg, [{The mean parameter of each batch.}]>:$means, + Arg, [{The standard deviation parameter of each batch. Must be greater than 0.}]>:$stddevs, + Arg, [{The minimum cutoff. May be -infinity.}]>:$minvals, + Arg, [{The maximum cutoff. May be +infinity, and must be more than the minval +for each batch.}]>:$maxvals ); let results = (outs - TensorOf<[TF_Float16, TF_Float32, TF_Float64]>:$output + Res, [{The outputs are truncated normal samples and are a deterministic function of +`shape`, `seed`, `minvals`, `maxvals`, `means` and `stddevs`.}]>:$output ); TF_DerivedOperandTypeAttr S = TF_DerivedOperandTypeAttr<0>; @@ -13593,14 +14660,16 @@ The outputs are a deterministic function of `shape`, `seed`, `counts`, and `prob }]; let arguments = (ins - TF_I32OrI64Tensor:$shape, - TF_I32OrI64Tensor:$seed, - TensorOf<[TF_Float16, TF_Float32, TF_Float64, TF_Int32, TF_Int64]>:$counts, - TensorOf<[TF_Float16, TF_Float32, TF_Float64, TF_Int32, TF_Int64]>:$probs + Arg:$shape, + Arg:$seed, + Arg, [{The counts of the binomial distribution. Must be broadcastable with `probs`, +and broadcastable with the rightmost dimensions of `shape`.}]>:$counts, + Arg, [{The probability of success for the binomial distribution. Must be broadcastable +with `counts` and broadcastable with the rightmost dimensions of `shape`.}]>:$probs ); let results = (outs - TensorOf<[TF_Float16, TF_Float32, TF_Float64, TF_Int32, TF_Int64]>:$output + Res, [{Random values with specified shape.}]>:$output ); TF_DerivedOperandTypeAttr S = TF_DerivedOperandTypeAttr<0>; @@ -13621,13 +14690,14 @@ The outputs are a deterministic function of `shape`, `seed`, and `alpha`. }]; let arguments = (ins - TF_I32OrI64Tensor:$shape, - TF_I32OrI64Tensor:$seed, - TensorOf<[TF_Float16, TF_Float32, TF_Float64]>:$alpha + Arg:$shape, + Arg:$seed, + Arg, [{The concentration of the gamma distribution. Shape must match the rightmost +dimensions of `shape`.}]>:$alpha ); let results = (outs - TensorOf<[TF_Float16, TF_Float32, TF_Float64]>:$output + Res, [{Random values with specified shape.}]>:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -13645,7 +14715,7 @@ This op picks the best counter-based RNG algorithm based on device. let arguments = (ins); let results = (outs - TF_Int32Tensor:$alg + Res:$alg ); } @@ -13659,18 +14729,18 @@ This op scrambles a shape-[2] seed into a key and a counter, both needed by coun }]; let arguments = (ins - TF_I32OrI64Tensor:$seed + Arg:$seed ); let results = (outs - TF_Uint64Tensor:$key, - TF_Uint64Tensor:$counter + Res:$key, + Res:$counter ); TF_DerivedOperandTypeAttr Tseed = TF_DerivedOperandTypeAttr<0>; } -def TF_StatelessRandomGetKeyCounterAlgOp : TF_Op<"StatelessRandomGetKeyCounterAlg", []> { +def TF_StatelessRandomGetKeyCounterAlgOp : TF_Op<"StatelessRandomGetKeyCounterAlg", [NoSideEffect, TF_NoConstantFold]> { let summary = [{ Picks the best algorithm based on device, and scrambles seed into key and counter. }]; @@ -13680,13 +14750,13 @@ This op picks the best counter-based RNG algorithm based on device, and scramble }]; let arguments = (ins - TF_I32OrI64Tensor:$seed + Arg:$seed ); let results = (outs - TF_Uint64Tensor:$key, - TF_Uint64Tensor:$counter, - TF_Int32Tensor:$alg + Res:$key, + Res:$counter, + Res:$alg ); TF_DerivedOperandTypeAttr Tseed = TF_DerivedOperandTypeAttr<0>; @@ -13704,12 +14774,12 @@ The outputs are a deterministic function of `shape` and `seed`. }]; let arguments = (ins - TF_I32OrI64Tensor:$shape, - TF_I32OrI64Tensor:$seed + Arg:$shape, + Arg:$seed ); let results = (outs - TF_FloatTensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -13729,14 +14799,14 @@ The outputs are a deterministic function of `shape`, `key`, `counter` and `alg`. }]; let arguments = (ins - TF_I32OrI64Tensor:$shape, - TF_Uint64Tensor:$key, - TF_Uint64Tensor:$counter, - TF_Int32Tensor:$alg + Arg:$shape, + Arg:$key, + Arg:$counter, + Arg:$alg ); let results = (outs - TF_FloatTensor:$output + Res:$output ); TF_DerivedOperandTypeAttr Tshape = TF_DerivedOperandTypeAttr<0>; @@ -13755,13 +14825,14 @@ The outputs are a deterministic function of `shape`, `seed`, and `lam`. }]; let arguments = (ins - TF_I32OrI64Tensor:$shape, - TF_I32OrI64Tensor:$seed, - TensorOf<[TF_Float16, TF_Float32, TF_Float64, TF_Int32, TF_Int64]>:$lam + Arg:$shape, + Arg:$seed, + Arg, [{The rate of the Poisson distribution. Shape must match the rightmost dimensions +of `shape`.}]>:$lam ); let results = (outs - TensorOf<[TF_Float16, TF_Float32, TF_Float64, TF_Int32, TF_Int64]>:$output + Res, [{Random values with specified shape.}]>:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -13783,12 +14854,12 @@ The outputs are a deterministic function of `shape` and `seed`. }]; let arguments = (ins - TF_I32OrI64Tensor:$shape, - TF_I32OrI64Tensor:$seed + Arg:$shape, + Arg:$seed ); let results = (outs - TF_FloatTensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -13808,12 +14879,12 @@ The outputs are a deterministic function of `shape` and `seed`. }]; let arguments = (ins - TF_I32OrI64Tensor:$shape, - TensorOf<[TF_Int32, TF_Int64, TF_Uint32, TF_Uint64]>:$seed + Arg:$shape, + Arg, [{2 seeds (shape [2]).}]>:$seed ); let results = (outs - TensorOf<[TF_Int32, TF_Int64, TF_Uint32, TF_Uint64]>:$output + Res, [{Random values with specified shape.}]>:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -13821,6 +14892,32 @@ The outputs are a deterministic function of `shape` and `seed`. TF_DerivedResultTypeAttr dtype = TF_DerivedResultTypeAttr<0>; } +def TF_StatelessRandomUniformFullIntV2Op : TF_Op<"StatelessRandomUniformFullIntV2", [NoSideEffect]> { + let summary = [{ +Outputs deterministic pseudorandom random integers from a uniform distribution. + }]; + + let description = [{ +The generated values are uniform integers covering the whole range of `dtype`. + +The outputs are a deterministic function of `shape`, `key`, `counter` and `alg`. + }]; + + let arguments = (ins + Arg:$shape, + Arg:$key, + Arg:$counter, + Arg:$alg + ); + + let results = (outs + Res, [{Random values with specified shape.}]>:$output + ); + + TF_DerivedOperandTypeAttr Tshape = TF_DerivedOperandTypeAttr<0>; + TF_DerivedResultTypeAttr dtype = TF_DerivedResultTypeAttr<0>; +} + def TF_StatelessRandomUniformIntOp : TF_Op<"StatelessRandomUniformInt", [NoSideEffect, TF_NoConstantFold]> { let summary = [{ Outputs deterministic pseudorandom random integers from a uniform distribution. @@ -13833,14 +14930,14 @@ The outputs are a deterministic function of `shape`, `seed`, `minval`, and `maxv }]; let arguments = (ins - TF_I32OrI64Tensor:$shape, - TF_I32OrI64Tensor:$seed, - TF_I32OrI64Tensor:$minval, - TF_I32OrI64Tensor:$maxval + Arg:$shape, + Arg:$seed, + Arg:$minval, + Arg:$maxval ); let results = (outs - TF_I32OrI64Tensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -13860,16 +14957,16 @@ The outputs are a deterministic function of `shape`, `key`, `counter`, `alg`, `m }]; let arguments = (ins - TF_I32OrI64Tensor:$shape, - TF_Uint64Tensor:$key, - TF_Uint64Tensor:$counter, - TF_Int32Tensor:$alg, - TensorOf<[TF_Int32, TF_Int64, TF_Uint32, TF_Uint64]>:$minval, - TensorOf<[TF_Int32, TF_Int64, TF_Uint32, TF_Uint64]>:$maxval + Arg:$shape, + Arg:$key, + Arg:$counter, + Arg:$alg, + Arg, [{Minimum value (inclusive, scalar).}]>:$minval, + Arg, [{Maximum value (exclusive, scalar).}]>:$maxval ); let results = (outs - TensorOf<[TF_Int32, TF_Int64, TF_Uint32, TF_Uint64]>:$output + Res, [{Random values with specified shape.}]>:$output ); TF_DerivedOperandTypeAttr Tshape = TF_DerivedOperandTypeAttr<0>; @@ -13889,14 +14986,14 @@ The outputs are a deterministic function of `shape`, `key`, `counter` and `alg`. }]; let arguments = (ins - TF_I32OrI64Tensor:$shape, - TF_Uint64Tensor:$key, - TF_Uint64Tensor:$counter, - TF_Int32Tensor:$alg + Arg:$shape, + Arg:$key, + Arg:$counter, + Arg:$alg ); let results = (outs - TF_FloatTensor:$output + Res:$output ); TF_DerivedOperandTypeAttr Tshape = TF_DerivedOperandTypeAttr<0>; @@ -13917,12 +15014,12 @@ The outputs are a deterministic function of `shape` and `seed`. }]; let arguments = (ins - TF_I32OrI64Tensor:$shape, - TF_I32OrI64Tensor:$seed + Arg:$shape, + Arg:$seed ); let results = (outs - TF_FloatTensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -13944,14 +15041,14 @@ The outputs are a deterministic function of `shape`, `key`, `counter` and `alg`. }]; let arguments = (ins - TF_I32OrI64Tensor:$shape, - TF_Uint64Tensor:$key, - TF_Uint64Tensor:$counter, - TF_Int32Tensor:$alg + Arg:$shape, + Arg:$key, + Arg:$counter, + Arg:$alg ); let results = (outs - TF_FloatTensor:$output + Res:$output ); TF_DerivedOperandTypeAttr Tshape = TF_DerivedOperandTypeAttr<0>; @@ -13972,7 +15069,45 @@ in the graph it inputs are masked from the gradient generator. They are not taken into account for computing gradients. This is useful any time you want to compute a value with TensorFlow but need -to pretend that the value was a constant. Some examples include: +to pretend that the value was a constant. For example, the softmax function +for a vector x can be written as + +```python + + def softmax(x): + numerator = tf.exp(x) + denominator = tf.reduce_sum(numerator) + return numerator / denominator +``` + +This however is susceptible to overflow if the values in x are large. An +alternative more stable way is to subtract the maximum of x from each of the +values. + +```python + + def stable_softmax(x): + z = x - tf.reduce_max(x) + numerator = tf.exp(z) + denominator = tf.reduce_sum(numerator) + return numerator / denominator +``` + +However, when we backprop through the softmax to x, we dont want to backprop +through the `tf.reduce_max(x)` (if the max values are not unique then the +gradient could flow to the wrong input) calculation and treat that as a +constant. Therefore, we should write this out as + +```python + + def stable_softmax(x): + z = x - tf.stop_gradient(tf.reduce_max(x)) + numerator = tf.exp(z) + denominator = tf.reduce_sum(numerator) + return numerator / denominator +``` + +Some other examples include: * The *EM* algorithm where the *M-step* should not involve backpropagation through the output of the *E-step*. @@ -14091,9 +15226,18 @@ receive 0, 0, and 1, respectively. The appropriate bits in `begin_mask` and let arguments = (ins TF_Tensor:$input, - TF_I32OrI64Tensor:$begin, - TF_I32OrI64Tensor:$end, - TF_I32OrI64Tensor:$strides, + Arg:$begin, + Arg:$end, + Arg0` or `[-1,dim[i]-1] if slice[i] < 0`}]>:$strides, DefaultValuedAttr:$begin_mask, DefaultValuedAttr:$end_mask, @@ -14188,7 +15332,9 @@ Examples: }]; let arguments = (ins - Variadic:$inputs, + Arg, [{A list of string tensors. The tensors must all have the same shape, +or be scalars. Scalars may be mixed in; these will be broadcast to the shape +of non-scalar inputs.}]>:$inputs, StrAttr:$separator ); @@ -14220,13 +15366,13 @@ array([0, 2, 2]) }]; let arguments = (ins - TF_StrTensor:$input, + Arg:$input, Confined]>:$num_buckets ); let results = (outs - TF_Int64Tensor:$output + Res:$output ); } @@ -14240,17 +15386,15 @@ def TF_SubOp : TF_Op<"Sub", [NoSideEffect, ResultsBroadcastableShape, TF_CwiseBi }]; let arguments = (ins - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Uint16, TF_Uint32, TF_Uint8]>:$x, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Uint16, TF_Uint32, TF_Uint8]>:$y + TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$x, + TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$y ); let results = (outs - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Uint16, TF_Uint32, TF_Uint8]>:$z + TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$z ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; - - } def TF_SumOp : TF_Op<"Sum", [NoSideEffect]> { @@ -14264,24 +15408,24 @@ retained with length 1. }]; let arguments = (ins - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$input, - TF_I32OrI64Tensor:$reduction_indices, + Arg, [{The tensor to reduce.}]>:$input, + Arg:$reduction_indices, DefaultValuedAttr:$keep_dims ); let results = (outs - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$output + Res, [{The reduced tensor.}]>:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; TF_DerivedOperandTypeAttr Tidx = TF_DerivedOperandTypeAttr<1>; let builders = [ - OpBuilderDAG<(ins "Value":$input, "Value":$reduction_indices, + OpBuilder<(ins "Value":$input, "Value":$reduction_indices, "BoolAttr":$keep_dims)> ]; - } def TF_SvdOp : TF_Op<"Svd", [NoSideEffect]> { @@ -14304,16 +15448,21 @@ s, _, _ = svd(a, compute_uv=False) }]; let arguments = (ins - TensorOf<[TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64]>:$input, + Arg, [{A tensor of shape `[..., M, N]` whose inner-most 2 dimensions +form matrices of size `[M, N]`. Let `P` be the minimum of `M` and `N`.}]>:$input, DefaultValuedAttr:$compute_uv, DefaultValuedAttr:$full_matrices ); let results = (outs - TensorOf<[TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64]>:$s, - TensorOf<[TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64]>:$u, - TensorOf<[TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64]>:$v + Res, [{Singular values. Shape is `[..., P]`.}]>:$s, + Res, [{Left singular vectors. If `full_matrices` is `False` then shape is +`[..., M, P]`; if `full_matrices` is `True` then shape is +`[..., M, M]`. Undefined if `compute_uv` is `False`.}]>:$u, + Res, [{Left singular vectors. If `full_matrices` is `False` then shape is +`[..., N, P]`. If `full_matrices` is `True` then shape is `[..., N, N]`. +Undefined if `compute_uv` is false.}]>:$v ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -14325,20 +15474,20 @@ Computes the gradient function for function f via backpropagation. }]; let arguments = (ins - Variadic:$input, + Arg, [{a list of input tensors of size N + M;}]>:$input, SymbolRefAttr:$f ); let results = (outs - Variadic:$output + Res, [{a list of output tensors of size N;}]>:$output ); TF_DerivedOperandTypeListAttr Tin = TF_DerivedOperandTypeListAttr<0>; TF_DerivedResultTypeListAttr Tout = TF_DerivedResultTypeListAttr<0>; } -def TF_TPUCompilationResultOp : TF_Op<"TPUCompilationResult", [NoSideEffect]> { +def TF_TPUCompilationResultOp : TF_Op<"TPUCompilationResult", []> { let summary = "Returns the result of a TPU compilation."; let description = [{ @@ -14403,8 +15552,8 @@ libraries. }]; let arguments = (ins - TF_Float32Tensor:$embedding_variable, - TF_Float32Tensor:$sliced_activations, + Arg:$embedding_variable, + Arg:$sliced_activations, Confined]>:$table_id, Confined]>:$lookup_id @@ -14415,7 +15564,7 @@ libraries. ); } -def TF_TPUExecuteOp : TF_Op<"TPUExecute"> { +def TF_TPUExecuteOp : TF_Op<"TPUExecute", []> { let summary = "Op that loads and executes a TPU program on a TPU device."; let description = [{ @@ -14435,7 +15584,7 @@ For the internal use of the distributed TPU compiler. TF_DerivedResultTypeListAttr Tresults = TF_DerivedResultTypeListAttr<0>; } -def TF_TPUExecuteAndUpdateVariablesOp : TF_Op<"TPUExecuteAndUpdateVariables"> { +def TF_TPUExecuteAndUpdateVariablesOp : TF_Op<"TPUExecuteAndUpdateVariables", []> { let summary = [{ Op that executes a program with optional in-place variable updates. }]; @@ -14501,7 +15650,7 @@ consumed by TPUPartitionedCall. let arguments = (ins); let results = (outs - TF_Int32Tensor:$device_ordinals + Res:$device_ordinals ); } @@ -14588,7 +15737,7 @@ variables. TF_DerivedOperandSizeAttr N = TF_DerivedOperandSizeAttr<0>; } -def TF_TanOp : TF_Op<"Tan", [NoSideEffect, SameOperandsAndResultType]> { +def TF_TanOp : TF_Op<"Tan", [NoSideEffect, TF_SameOperandsAndResultTypeResolveRef]> { let summary = "Computes tan of x element-wise."; let description = [{ @@ -14614,7 +15763,7 @@ Given an input tensor, this function computes tangent of every TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; } -def TF_TanhOp : TF_Op<"Tanh", [NoSideEffect, SameOperandsAndResultType, TF_LayoutAgnostic]> { +def TF_TanhOp : TF_Op<"Tanh", [NoSideEffect, TF_LayoutAgnostic, TF_SameOperandsAndResultTypeResolveRef]> { let summary = "Computes hyperbolic tangent of `x` element-wise."; let description = [{ @@ -14640,7 +15789,7 @@ Given an input tensor, this function computes hyperbolic tangent of every TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; } -def TF_TanhGradOp : TF_Op<"TanhGrad", [NoSideEffect, SameOperandsAndResultType]> { +def TF_TanhGradOp : TF_Op<"TanhGrad", [NoSideEffect, TF_SameOperandsAndResultTypeResolveRef]> { let summary = "Computes the gradient for the tanh of `x` wrt its input."; let description = [{ @@ -14669,7 +15818,7 @@ of a step/run. }]; let arguments = (ins - Arg:$handle + Arg:$handle ); let results = (outs); @@ -14693,15 +15842,18 @@ All elements must have the same shape (excepting the first dimension). }]; let arguments = (ins - Arg:$handle, - TF_Float32Tensor:$flow_in, + Arg:$handle, + Arg:$flow_in, DefaultValuedAttr:$element_shape_except0 ); let results = (outs - TF_Tensor:$value, - TF_Int64Tensor:$lengths + Res:$value, + Res:$lengths ); TF_DerivedResultTypeAttr dtype = TF_DerivedResultTypeAttr<0>; @@ -14717,15 +15869,16 @@ All elements selected by `indices` must have the same shape. }]; let arguments = (ins - Arg:$handle, - TF_Int32Tensor:$indices, - TF_Float32Tensor:$flow_in, + Arg:$handle, + Arg:$indices, + Arg:$flow_in, DefaultValuedAttr:$element_shape ); let results = (outs - TF_Tensor:$value + Res:$value ); TF_DerivedResultTypeAttr dtype = TF_DerivedResultTypeAttr<0>; @@ -14776,8 +15929,8 @@ calculation gets its own TensorArray accumulator. }]; let arguments = (ins - Arg:$handle, - TF_Float32Tensor:$flow_in, + Arg:$handle, + Arg:$flow_in, StrAttr:$source ); @@ -14792,13 +15945,13 @@ def TF_TensorArrayReadV3Op : TF_Op<"TensorArrayReadV3", []> { let summary = "Read an element from the TensorArray into output `value`."; let arguments = (ins - Arg:$handle, + Arg:$handle, TF_Int32Tensor:$index, - TF_Float32Tensor:$flow_in + Arg:$flow_in ); let results = (outs - TF_Tensor:$value + Res:$value ); TF_DerivedResultTypeAttr dtype = TF_DerivedResultTypeAttr<0>; @@ -14814,14 +15967,14 @@ Scatter the data from the input value into specific TensorArray elements. }]; let arguments = (ins - Arg:$handle, - TF_Int32Tensor:$indices, - TF_Tensor:$value, - TF_Float32Tensor:$flow_in + Arg:$handle, + Arg:$indices, + Arg:$value, + Arg:$flow_in ); let results = (outs - TF_Float32Tensor:$flow_out + Res:$flow_out ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<2>; @@ -14831,12 +15984,12 @@ def TF_TensorArraySizeV3Op : TF_Op<"TensorArraySizeV3", []> { let summary = "Get the current size of the TensorArray."; let arguments = (ins - Arg:$handle, - TF_Float32Tensor:$flow_in + Arg:$handle, + Arg:$flow_in ); let results = (outs - TF_Int32Tensor:$size + Res:$size ); } @@ -14866,14 +16019,15 @@ and having size }]; let arguments = (ins - Arg:$handle, - TF_Tensor:$value, - TF_Int64Tensor:$lengths, - TF_Float32Tensor:$flow_in + Arg:$handle, + Arg:$value, + Arg:$lengths, + Arg:$flow_in ); let results = (outs - TF_Float32Tensor:$flow_out + Res:$flow_out ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<1>; @@ -14887,7 +16041,7 @@ Write data via Write and read via Read or Pack. }]; let arguments = (ins - TF_Int32Tensor:$size, + Arg:$size, TypeAttr:$dtype, DefaultValuedAttr:$element_shape, @@ -14898,8 +16052,8 @@ Write data via Write and read via Read or Pack. ); let results = (outs - Res:$handle, - TF_Float32Tensor:$flow + Res:$handle, + Res:$flow ); } @@ -14907,14 +16061,14 @@ def TF_TensorArrayWriteV3Op : TF_Op<"TensorArrayWriteV3", []> { let summary = "Push an element onto the tensor_array."; let arguments = (ins - Arg:$handle, - TF_Int32Tensor:$index, - TF_Tensor:$value, - TF_Float32Tensor:$flow_in + Arg:$handle, + Arg:$index, + Arg:$value, + Arg:$flow_in ); let results = (outs - TF_Float32Tensor:$flow_out + Res:$flow_out ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<2>; @@ -14969,7 +16123,6 @@ input_handle: the list ); TF_DerivedResultTypeAttr shape_type = TF_DerivedResultTypeAttr<0>; - } def TF_TensorListFromTensorOp : TF_Op<"TensorListFromTensor", [NoSideEffect]> { @@ -15268,13 +16421,13 @@ On GPU, if an out of bound index is found, the index is ignored. }]; let arguments = (ins - TF_Tensor:$tensor, - TF_I32OrI64Tensor:$indices, - TF_Tensor:$updates + Arg:$tensor, + Arg:$indices, + Arg:$updates ); let results = (outs - TF_Tensor:$output + Res:$output ); TF_DerivedOperandTypeAttr Tindices = TF_DerivedOperandTypeAttr<1>; @@ -15285,13 +16438,13 @@ def TF_TensorScatterMaxOp : TF_Op<"TensorScatterMax", [NoSideEffect]> { let summary = ""; let arguments = (ins - TF_Tensor:$tensor, - TF_I32OrI64Tensor:$indices, - TF_Tensor:$updates + Arg:$tensor, + Arg:$indices, + Arg:$updates ); let results = (outs - TF_Tensor:$output + Res:$output ); TF_DerivedOperandTypeAttr Tindices = TF_DerivedOperandTypeAttr<1>; @@ -15302,13 +16455,13 @@ def TF_TensorScatterMinOp : TF_Op<"TensorScatterMin", [NoSideEffect]> { let summary = ""; let arguments = (ins - TF_Tensor:$tensor, - TF_I32OrI64Tensor:$indices, - TF_Tensor:$updates + Arg:$tensor, + Arg:$indices, + Arg:$updates ); let results = (outs - TF_Tensor:$output + Res:$output ); TF_DerivedOperandTypeAttr Tindices = TF_DerivedOperandTypeAttr<1>; @@ -15386,13 +16539,13 @@ On GPU, if an out of bound index is found, the index is ignored. }]; let arguments = (ins - TF_Tensor:$tensor, - TF_I32OrI64Tensor:$indices, - TF_Tensor:$updates + Arg:$tensor, + Arg:$indices, + Arg:$updates ); let results = (outs - TF_Tensor:$output + Res:$output ); TF_DerivedOperandTypeAttr Tindices = TF_DerivedOperandTypeAttr<1>; @@ -15443,13 +16596,14 @@ https://www.tensorflow.org/api_docs/python/tf/tensor_scatter_nd_update) function }]; let arguments = (ins - TF_Tensor:$tensor, - TF_I32OrI64Tensor:$indices, - TF_Tensor:$updates + Arg:$tensor, + Arg:$indices, + Arg:$updates ); let results = (outs - TF_Tensor:$output + Res:$output ); TF_DerivedOperandTypeAttr Tindices = TF_DerivedOperandTypeAttr<1>; @@ -15458,7 +16612,7 @@ https://www.tensorflow.org/api_docs/python/tf/tensor_scatter_nd_update) function let verifier = [{ return Verify(*this); }]; let builders = [ - OpBuilderDAG<(ins "Value":$tensor, "Value":$indices, "Value":$updates), + OpBuilder<(ins "Value":$tensor, "Value":$indices, "Value":$updates), [{build($_builder, $_state, tensor.getType(), tensor, indices, updates);}]> ]; } @@ -15530,8 +16684,8 @@ array([[1, 2, 3, 1, 2, 3], }]; let arguments = (ins - TF_Tensor:$input, - TF_I32OrI64Tensor:$multiples + Arg:$input, + Arg:$multiples ); let results = (outs @@ -15542,7 +16696,6 @@ array([[1, 2, 3, 1, 2, 3], TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; let verifier = [{ return Verify(*this); }]; - } def TF_TopKUniqueOp : TF_Op<"TopKUnique", [NoSideEffect]> { @@ -15594,15 +16747,16 @@ If two elements are equal, the lower-index element appears first. }]; let arguments = (ins - TF_IntOrFpTensor:$input, - TF_Int32Tensor:$k, + Arg:$input, + Arg:$k, DefaultValuedAttr:$sorted ); let results = (outs - TF_IntOrFpTensor:$values, - TF_Int32Tensor:$indices + Res:$values, + Res:$indices ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -15654,13 +16808,12 @@ The output `y` has the same rank as `x`. The shapes of `x` and `y` satisfy: TF_DerivedOperandTypeAttr Tperm = TF_DerivedOperandTypeAttr<1>; let builders = [ - OpBuilderDAG<(ins "Value":$x, "Value":$perm)> + OpBuilder<(ins "Value":$x, "Value":$perm)> ]; let verifier = [{ return Verify(*this); }]; - } def TF_TridiagonalSolveOp : TF_Op<"TridiagonalSolve", [NoSideEffect]> { @@ -15677,14 +16830,18 @@ Solves tridiagonal systems of equations. }]; let arguments = (ins - TensorOf<[TF_Complex128, TF_Complex64, TF_Float32, TF_Float64]>:$diagonals, - TensorOf<[TF_Complex128, TF_Complex64, TF_Float32, TF_Float64]>:$rhs, + Arg, [{Tensor of shape `[..., 3, M]` whose innermost 2 dimensions represent the +tridiagonal matrices with three rows being the superdiagonal, diagonals, and +subdiagonals, in order. The last element of the superdiagonal and the first +element of the subdiagonal is ignored.}]>:$diagonals, + Arg, [{Tensor of shape `[..., M, K]`, representing K right-hand sides per each +left-hand side.}]>:$rhs, DefaultValuedAttr:$partial_pivoting ); let results = (outs - TensorOf<[TF_Complex128, TF_Complex64, TF_Float32, TF_Float64]>:$output + Res, [{Tensor of shape `[..., M, K]` containing the solutions}]>:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -15705,16 +16862,15 @@ Python Semantics. }]; let arguments = (ins - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Uint16, TF_Uint8]>:$x, - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Uint16, TF_Uint8]>:$y + TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$x, + TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$y ); let results = (outs - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Uint16, TF_Uint8]>:$z + TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$z ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; - } def TF_TruncateModOp : TF_Op<"TruncateMod", [NoSideEffect, ResultsBroadcastableShape, TF_SameOperandsAndResultElementTypeResolveRef]>, @@ -15753,20 +16909,36 @@ deviations from the mean are dropped and re-picked. }]; let arguments = (ins - TF_I32OrI64Tensor:$shape, + Arg:$shape, DefaultValuedAttr:$seed, DefaultValuedAttr:$seed2 ); let results = (outs - TF_FloatTensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; TF_DerivedResultTypeAttr dtype = TF_DerivedResultTypeAttr<0>; } +def TF_UncompressElementOp : TF_Op<"UncompressElement", [NoSideEffect]> { + let summary = "Uncompresses a compressed dataset element."; + + let arguments = (ins + TF_VariantTensor:$compressed + ); + + let results = (outs + Variadic:$components + ); + + TF_DerivedResultShapeListAttr output_shapes = TF_DerivedResultShapeListAttr<0>; + TF_DerivedResultTypeListAttr output_types = TF_DerivedResultTypeListAttr<0>; +} + def TF_UniqueOp : TF_Op<"Unique", [NoSideEffect]> { let summary = "Finds unique elements in a 1-D tensor."; @@ -15796,12 +16968,12 @@ idx ==> [0, 1, 2, 3, 4, 4, 0, 1] }]; let arguments = (ins - TF_Tensor:$x + Arg:$x ); let results = (outs - TF_Tensor:$y, - TF_I32OrI64Tensor:$idx + Res:$y, + Res:$idx ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -15829,20 +17001,19 @@ This is the opposite of `pack`. }]; let arguments = (ins - TF_Tensor:$value, + Arg:$value, DefaultValuedAttr:$axis ); let results = (outs - Variadic:$output + Res, [{The list of tensors unpacked from `value`.}]>:$output ); TF_DerivedResultSizeAttr num = TF_DerivedResultSizeAttr<0>; TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; let verifier = [{ return Verify(*this); }]; - } def TF_UnsortedSegmentMaxOp : TF_Op<"UnsortedSegmentMax", [NoSideEffect]> { @@ -15883,12 +17054,14 @@ tf.unsorted_segment_max(c, tf.constant([0, 1, 0]), num_segments=2) let arguments = (ins TF_IntOrFpTensor:$data, - TF_I32OrI64Tensor:$segment_ids, + Arg:$segment_ids, TF_I32OrI64Tensor:$num_segments ); let results = (outs - TF_IntOrFpTensor:$output + Res:$output ); TF_DerivedOperandTypeAttr Tindices = TF_DerivedOperandTypeAttr<1>; @@ -15932,12 +17105,14 @@ dropped, and will not be included in the result. let arguments = (ins TF_IntOrFpTensor:$data, - TF_I32OrI64Tensor:$segment_ids, + Arg:$segment_ids, TF_I32OrI64Tensor:$num_segments ); let results = (outs - TF_IntOrFpTensor:$output + Res:$output ); TF_DerivedOperandTypeAttr Tindices = TF_DerivedOperandTypeAttr<1>; @@ -15980,12 +17155,14 @@ dropped, and will not be included in the result. let arguments = (ins TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$data, - TF_I32OrI64Tensor:$segment_ids, + Arg:$segment_ids, TF_I32OrI64Tensor:$num_segments ); let results = (outs - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$output + Res, [{Has same shape as data, except for the first `segment_ids.rank` +dimensions, which are replaced with a single dimension which has size +`num_segments`.}]>:$output ); TF_DerivedOperandTypeAttr Tindices = TF_DerivedOperandTypeAttr<1>; @@ -16029,12 +17206,14 @@ tf.unsorted_segment_sum(c, tf.constant([0, 1, 0]), num_segments=2) let arguments = (ins TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$data, - TF_I32OrI64Tensor:$segment_ids, + Arg:$segment_ids, TF_I32OrI64Tensor:$num_segments ); let results = (outs - TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$output + Res, [{Has same shape as data, except for the first `segment_ids.rank` +dimensions, which are replaced with a single dimension which has size +`num_segments`.}]>:$output ); TF_DerivedOperandTypeAttr Tindices = TF_DerivedOperandTypeAttr<1>; @@ -16070,12 +17249,15 @@ A 2-D example: }]; let arguments = (ins - TF_Tensor:$sorted_inputs, - TF_Tensor:$values + Arg:$sorted_inputs, + Arg:$values ); let results = (outs - TF_I32OrI64Tensor:$output + Res:$output ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -16088,13 +17270,13 @@ Checks whether a resource handle-based variable has been initialized. }]; let arguments = (ins - Arg:$resource + Arg:$resource ); let results = (outs - TF_BoolTensor:$is_initialized + Res:$is_initialized ); - } def TF_VariableOp : TF_Op<"Variable", []> { @@ -16111,7 +17293,6 @@ def TF_VariableOp : TF_Op<"Variable", []> { ); TF_DerivedResultTypeAttr dtype = TF_DerivedResultTypeAttr<0>; - } def TF_VariableShapeOp : TF_Op<"VariableShape", []> { @@ -16141,7 +17322,6 @@ shape(t) ==> [2, 2, 3] let verifier = [{ return Verify(*this); }]; - } def TF_VariableV2Op : TF_Op<"VariableV2", []> { @@ -16162,7 +17342,7 @@ about sharing states in tensorflow. ); let results = (outs - TF_Tensor:$ref + Res:$ref ); TF_DerivedResultTypeAttr dtype = TF_DerivedResultTypeAttr<0>; @@ -16258,7 +17438,6 @@ def TF_XdivyOp : TF_Op<"Xdivy", [NoSideEffect, ResultsBroadcastableShape, TF_Sam ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; - } def TF_XlaBroadcastHelperOp : TF_Op<"XlaBroadcastHelper", [NoSideEffect]> { @@ -16330,6 +17509,37 @@ https://www.tensorflow.org/performance/xla/operation_semantics#conv_convolution TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; } +def TF_XlaConvV2Op : TF_Op<"XlaConvV2", [NoSideEffect]> { + let summary = "Wraps the XLA ConvGeneralDilated operator, documented at"; + + let description = [{ +https://www.tensorflow.org/performance/xla/operation_semantics#conv_convolution +. + }]; + + let arguments = (ins + Arg, [{the input tensor}]>:$lhs, + Arg, [{the kernel tensor}]>:$rhs, + Arg:$window_strides, + Arg:$padding, + Arg:$lhs_dilation, + Arg:$rhs_dilation, + Arg:$feature_group_count, + + StrAttr:$dimension_numbers, + StrAttr:$precision_config + ); + + let results = (outs + TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$output + ); + + TF_DerivedOperandTypeAttr Tindices = TF_DerivedOperandTypeAttr<2>; + TF_DerivedOperandTypeAttr LhsT = TF_DerivedOperandTypeAttr<0>; + TF_DerivedOperandTypeAttr RhsT = TF_DerivedOperandTypeAttr<1>; + TF_DerivedResultTypeAttr preferred_element_type = TF_DerivedResultTypeAttr<0>; +} + def TF_XlaDotOp : TF_Op<"XlaDot", [NoSideEffect]> { let summary = "Wraps the XLA DotGeneral operator, documented at"; @@ -16353,6 +17563,31 @@ https://www.tensorflow.org/performance/xla/operation_semantics#dotgeneral TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; } +def TF_XlaDotV2Op : TF_Op<"XlaDotV2", [NoSideEffect]> { + let summary = "Wraps the XLA DotGeneral operator, documented at"; + + let description = [{ +https://www.tensorflow.org/performance/xla/operation_semantics#dotgeneral +. + }]; + + let arguments = (ins + Arg, [{the LHS tensor}]>:$lhs, + Arg, [{the RHS tensor}]>:$rhs, + + StrAttr:$dimension_numbers, + StrAttr:$precision_config + ); + + let results = (outs + TensorOf<[TF_Bfloat16, TF_Complex128, TF_Complex64, TF_Float16, TF_Float32, TF_Float64, TF_Int16, TF_Int32, TF_Int64, TF_Int8, TF_Qint32, TF_Qint8, TF_Quint8, TF_Uint16, TF_Uint32, TF_Uint64, TF_Uint8]>:$output + ); + + TF_DerivedOperandTypeAttr LhsT = TF_DerivedOperandTypeAttr<0>; + TF_DerivedOperandTypeAttr RhsT = TF_DerivedOperandTypeAttr<1>; + TF_DerivedResultTypeAttr preferred_element_type = TF_DerivedResultTypeAttr<0>; +} + def TF_XlaDynamicSliceOp : TF_Op<"XlaDynamicSlice", [NoSideEffect]> { let summary = "Wraps the XLA DynamicSlice operator, documented at"; @@ -16468,7 +17703,7 @@ A pseudo-op to represent host-side computation in an XLA program. }]; let arguments = (ins - Variadic:$inputs, + Arg, [{A list of tensors that will be sent to the host.}]>:$inputs, StrArrayAttr:$ancestors, TF_ShapeAttrArray:$shapes, @@ -16479,7 +17714,7 @@ A pseudo-op to represent host-side computation in an XLA program. ); let results = (outs - Variadic:$outputs + Res, [{A list of tensors that will be returned to the device.}]>:$outputs ); TF_DerivedOperandTypeListAttr Tinputs = TF_DerivedOperandTypeListAttr<0>; @@ -16521,9 +17756,13 @@ https://www.tensorflow.org/performance/xla/operation_semantics#pad let arguments = (ins Arg:$input, Arg:$padding_value, - Arg:$padding_low, - Arg:$padding_high, - Arg:$padding_interior + Arg:$padding_low, + Arg:$padding_high, + Arg:$padding_interior ); let results = (outs @@ -16880,11 +18119,11 @@ def TF_ZerosLikeOp : TF_Op<"ZerosLike", [Idempotent, NoSideEffect, SameOperandsA let summary = "Returns a tensor of zeros with the same shape and type as x."; let arguments = (ins - TF_Tensor:$x + Arg:$x ); let results = (outs - TF_Tensor:$y + Res:$y ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; @@ -16940,12 +18179,12 @@ expected to create these operators. }]; let arguments = (ins - TensorOf<[TF_Float16, TF_Float32]>:$x, + TensorOf<[TF_Bfloat16, TF_Float16, TF_Float32]>:$x, TF_Float32Tensor:$scale, TF_Float32Tensor:$offset, TF_Float32Tensor:$mean, TF_Float32Tensor:$variance, - Variadic>:$side_input, + Variadic>:$side_input, DefaultValuedAttr:$epsilon, DefaultValuedAttr:$exponential_avg_factor, @@ -16955,7 +18194,7 @@ expected to create these operators. ); let results = (outs - TensorOf<[TF_Float16, TF_Float32]>:$y, + TensorOf<[TF_Bfloat16, TF_Float16, TF_Float32]>:$y, TF_Float32Tensor:$batch_mean, TF_Float32Tensor:$batch_variance, TF_Float32Tensor:$reserve_space_1, @@ -17017,7 +18256,7 @@ create these operators. TF_DerivedOperandSizeAttr num_args = TF_DerivedOperandSizeAttr<2>; } -def TF__FusedMatMulOp : TF_Op<"_FusedMatMul", [NoSideEffect, SameOperandsAndResultElementType]> { +def TF__FusedMatMulOp : TF_Op<"_FusedMatMul", [NoSideEffect, TF_SameOperandsAndResultElementTypeResolveRef]> { let summary = [{ Performs a MatMul followed by a specified series of operations. }]; @@ -17050,7 +18289,8 @@ expected to create these operators. DefaultValuedAttr:$transpose_a, DefaultValuedAttr:$transpose_b, DefaultValuedAttr:$fused_ops, - DefaultValuedAttr:$epsilon + DefaultValuedAttr:$epsilon, + DefaultValuedAttr:$leakyrelu_alpha ); let results = (outs @@ -17061,6 +18301,52 @@ expected to create these operators. TF_DerivedOperandSizeAttr num_args = TF_DerivedOperandSizeAttr<2>; } +def TF__HostRecvOp : TF_Op<"_HostRecv", []> { + let summary = "Receives the named tensor from send_device on recv_device."; + + let description = [{ +_HostRecv produces its output on host memory whereas _Recv produces its +output on device memory. + }]; + + let arguments = (ins + StrAttr:$tensor_name, + StrAttr:$send_device, + I64Attr:$send_device_incarnation, + StrAttr:$recv_device, + DefaultValuedAttr:$client_terminated + ); + + let results = (outs + Res:$tensor + ); + + TF_DerivedResultTypeAttr tensor_type = TF_DerivedResultTypeAttr<0>; +} + +def TF__HostSendOp : TF_Op<"_HostSend", []> { + let summary = "Sends the named tensor from send_device to recv_device."; + + let description = [{ +_HostSend requires its input on host memory whereas _Send requires its +input on device memory. + }]; + + let arguments = (ins + Arg:$tensor, + + StrAttr:$tensor_name, + StrAttr:$send_device, + I64Attr:$send_device_incarnation, + StrAttr:$recv_device, + DefaultValuedAttr:$client_terminated + ); + + let results = (outs); + + TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; +} + def TF__ListToArrayOp : TF_Op<"_ListToArray", [NoSideEffect]> { let summary = "Converts a list of tensors to an array of tensors."; @@ -17159,7 +18445,7 @@ rewrite passes must replace this op with a _TPUCompileMlir op `program` output. ); } -def TF__UnaryOpsCompositionOp : TF_Op<"_UnaryOpsComposition", [NoSideEffect, SameOperandsAndResultType]> { +def TF__UnaryOpsCompositionOp : TF_Op<"_UnaryOpsComposition", [NoSideEffect, TF_SameOperandsAndResultTypeResolveRef]> { let summary = [{ *NOTE*: Do not invoke this operator directly in Python. Graph rewrite pass is }]; diff --git a/tools/mlir/tf_op_base.td b/tools/mlir/tf_op_base.td index f2881c521..341f49cb7 100644 --- a/tools/mlir/tf_op_base.td +++ b/tools/mlir/tf_op_base.td @@ -24,7 +24,6 @@ limitations under the License. include "mlir/IR/OpBase.td" include "mlir/Interfaces/SideEffectInterfaces.td" -//include "tf_op_interfaces.td" //===----------------------------------------------------------------------===// // TensorFlow dialect definitions @@ -477,13 +476,13 @@ class TF_DerivedOperandTypeListAttr : DerivedAttr< "return {mlir::OperandElementTypeIterator(values.begin()), " "mlir::OperandElementTypeIterator(values.end())};", [{ - ArrayAttr::get( + ArrayAttr::get($_ctx, [&]() { llvm::SmallVector ret; for (auto t : $_self) ret.push_back(TypeAttr::get(t)); return ret; - }(), $_ctx) + }()) }] >; @@ -497,13 +496,13 @@ class TF_DerivedOperandShapeListAttr : DerivedAttr< "return {mlir::TF::OperandShapeIterator(values.begin()), " "mlir::TF::OperandShapeIterator(values.end())};", [{ - ArrayAttr::get( + ArrayAttr::get($_ctx, [&](){ llvm::SmallVector ret; for (auto shape : $_self) ret.push_back(mlir::TF::ShapeAttr::get($_ctx, shape)); return ret; - }(), $_ctx) + }()) }] >; @@ -533,13 +532,13 @@ class TF_DerivedResultTypeListAttr : DerivedAttr< "return {mlir::ResultElementTypeIterator(values.begin()), " "mlir::ResultElementTypeIterator(values.end())};", [{ - ArrayAttr::get( + ArrayAttr::get($_ctx, [&]() { llvm::SmallVector ret; for (auto t : $_self) ret.push_back(TypeAttr::get(t)); return ret; - }(), $_ctx) + }()) }] >; @@ -553,13 +552,13 @@ class TF_DerivedResultShapeListAttr : DerivedAttr< "return {mlir::TF::ResultShapeIterator(values.begin()), " "mlir::TF::ResultShapeIterator(values.end())};", [{ - ArrayAttr::get( + ArrayAttr::get($_ctx, [&](){ llvm::SmallVector ret; for (auto shape : $_self) ret.push_back(mlir::TF::ShapeAttr::get($_ctx, shape)); return ret; - }(), $_ctx) + }()) }] >; @@ -579,8 +578,8 @@ def TF_IntTypeAttr : TypeAttrBase<"IntegerType", "integer type"> { // Mixin class defining a builder for binary ops supporting broadcast // behavior. The result type has the same element type as both operands. class WithBroadcastableBinOpBuilder { - list builders = [ - OpBuilderDAG<(ins "Value":$x, "Value":$y), + list builders = [ + OpBuilder<(ins "Value":$x, "Value":$y), [{ auto resultType = OpTrait::util::getBroadcastedType(x.getType(), y.getType()); @@ -593,8 +592,8 @@ class WithBroadcastableBinOpBuilder { // Mixin class defining a builder for comparison ops supporting broadcast // behavior. The result type has bool element type. class WithBroadcastableCmpOpBuilder { - list builders = [ - OpBuilderDAG<(ins "Value":$x, "Value":$y), + list builders = [ + OpBuilder<(ins "Value":$x, "Value":$y), [{ Type resultType; if (x.getType().isa() || diff --git a/tools/mlir/tf_ops.td b/tools/mlir/tf_ops.td index e00c118e1..4a4ba519a 100644 --- a/tools/mlir/tf_ops.td +++ b/tools/mlir/tf_ops.td @@ -34,6 +34,7 @@ include "mlir/Interfaces/ControlFlowInterfaces.td" include "mlir/Interfaces/LoopLikeInterface.td" include "mlir/Interfaces/SideEffectInterfaces.td" include "mlir/IR/OpBase.td" +include "mlir/IR/SymbolInterfaces.td" class TF_TensorListInitOp : TF_Op { let results = (outs @@ -112,7 +113,6 @@ An n-way switch statement, implementing the following: TF_DerivedResultTypeListAttr Tout = TF_DerivedResultTypeListAttr<0>; TF_DerivedResultShapeListAttr output_shapes = TF_DerivedResultShapeListAttr<0>; - let verifier = [{ return Verify(*this); }]; @@ -179,7 +179,6 @@ An n-way switch statement, implementing the following: return Verify(*this); }]; - } // In MLIR, the TensorFlow tensor value is represented as an ElementsAttr, with @@ -198,8 +197,8 @@ def TF_ConstOp : TF_Op<"Const", [ConstantLike, NoSideEffect]> { TF_DerivedResultTypeAttr dtype = TF_DerivedResultTypeAttr<0>; let builders = [ - OpBuilderDAG<(ins "Attribute":$value)>, - OpBuilderDAG<(ins "Type":$type, "Attribute":$value)>, + OpBuilder<(ins "Attribute":$value)>, + OpBuilder<(ins "Type":$type, "Attribute":$value)>, ]; } @@ -322,11 +321,6 @@ else_branch: A function that takes 'inputs' and returns a list of TF_DerivedResultTypeListAttr Tout = TF_DerivedResultTypeListAttr<0>; TF_DerivedResultShapeListAttr output_shapes = TF_DerivedResultShapeListAttr<0>; - let verifier = [{ - return Verify(*this); - }]; - - let extraClassDeclaration = [{ // Get the then branch function. FuncOp then_function() { @@ -381,7 +375,12 @@ else_branch: A region that computes the outputs of the op if cond = false. 0DTensorOf<[I1]>:$cond, // Used to map StatelessIf and If op defined in TensorFlow to a common op. - BoolAttr:$is_stateless + BoolAttr:$is_stateless, + // Used to maintain function name when round-tripping + // between functional and regional control flow. This can be removed if + // the runtime does not require globally unique then/else branch function names. + OptionalAttr:$_then_func_name, + OptionalAttr:$_else_func_name ); let results = (outs @@ -395,14 +394,13 @@ else_branch: A region that computes the outputs of the op if cond = false. }]; let builders = [ - OpBuilderDAG<(ins "TypeRange":$resultTypes, "ValueRange":$operands, + OpBuilder<(ins "TypeRange":$resultTypes, "ValueRange":$operands, "llvm::ArrayRef<::mlir::NamedAttribute>":$attributes, "unsigned":$numRegions), [{ assert(numRegions == 2u && "mismatched number of regions"); build($_builder, $_state, resultTypes, operands, attributes); }]>]; - } def TF_LegacyCallOp : TF_Op<"LegacyCall", @@ -699,10 +697,6 @@ body: A function that takes a list of tensors and returns another TF_DerivedOperandTypeListAttr T = TF_DerivedOperandTypeListAttr<0>; TF_DerivedResultShapeListAttr output_shapes = TF_DerivedResultShapeListAttr<0>; - let verifier = [{ - return Verify(*this); - }]; - let extraClassDeclaration = [{ // Get the condition function. FuncOp cond_function() { @@ -776,7 +770,6 @@ def TF_WhileRegionOp : TF_Op<"WhileRegion", let regions = (region SizedRegion<1>:$cond, SizedRegion<1>:$body); let verifier = [{ return Verify(*this); }]; - } def TF_TensorListReserveOp : TF_TensorListInitOp<"TensorListReserve"> { @@ -825,7 +818,7 @@ This operation holds the metadata common to operations of a `tpu.replicate()` co let results = (outs); } -def TF_VarHandleOp : TF_Op<"VarHandleOp"> { +def TF_VarHandleOp : TF_Op<"VarHandleOp", []> { let summary = "Creates a handle to a Variable resource from its name."; let description = [{ @@ -967,6 +960,7 @@ An op which shards the input based on the given sharding attribute. let arguments = (ins TF_Tensor:$input, + DefaultValuedAttr:$sharding, OptionalAttr:$_XlaSharding ); @@ -1168,12 +1162,11 @@ as true/false for a branch condition. TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; let builders = [ - OpBuilderDAG<(ins "Value":$value), + OpBuilder<(ins "Value":$value), [{ build($_builder, $_state, RankedTensorType::get({}, $_builder.getI1Type()), value); }]>]; - } def TF_BesselI0eOp : TF_Op<"BesselI0e", [NoSideEffect, SameOperandsAndResultType]> { @@ -1333,17 +1326,15 @@ def TF_AddV2Op : TF_Op<"AddV2", [Commutative, NoSideEffect, ResultsBroadcastable }]; let arguments = (ins - TensorOf<[TF_Float, TF_SInt, TF_Complex, TF_Uint8, TF_Uint32]>:$x, - TensorOf<[TF_Float, TF_SInt, TF_Complex, TF_Uint8, TF_Uint32]>:$y + TensorOf<[TF_Float, TF_SInt, TF_Complex, TF_Uint8, TF_Uint16, TF_Uint32, TF_Uint64]>:$x, + TensorOf<[TF_Float, TF_SInt, TF_Complex, TF_Uint8, TF_Uint16, TF_Uint32, TF_Uint64]>:$y ); let results = (outs - TensorOf<[TF_Float, TF_SInt, TF_Complex, TF_Uint8, TF_Uint32]>:$z + TensorOf<[TF_Float, TF_SInt, TF_Complex, TF_Uint8, TF_Uint16, TF_Uint32, TF_Uint64]>:$z ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; - - } def TF_DivNoNanOp : TF_Op<"DivNoNan", [NoSideEffect, ResultsBroadcastableShape, TF_SameOperandsAndResultElementTypeResolveRef]>, @@ -1409,8 +1400,6 @@ If `x` and `y` are reals, this will return the floating-point division. ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; - - } def TF_AddOp : TF_Op<"Add", [NoSideEffect, ResultsBroadcastableShape, TF_LayoutAgnostic, TF_SameOperandsAndResultElementTypeResolveRef]>, @@ -1436,7 +1425,6 @@ Both input and output have a range `(-inf, inf)`. ); TF_DerivedOperandTypeAttr T = TF_DerivedOperandTypeAttr<0>; - } def TF_StatefulStandardNormalV2Op : TF_Op<"StatefulStandardNormalV2", []> { @@ -1665,7 +1653,7 @@ event: A string containing a binary-encoded tf.Event proto. let results = (outs); } -def TF_SummaryWriterOp : TF_Op<"SummaryWriter"> { +def TF_SummaryWriterOp : TF_Op<"SummaryWriter", []> { let summary = "Returns a handle to be used to access a summary writer."; let description = [{ diff --git a/tools/mlir/tf_types.cc b/tools/mlir/tf_types.cc index a23ac4ebc..381ca869e 100644 --- a/tools/mlir/tf_types.cc +++ b/tools/mlir/tf_types.cc @@ -230,7 +230,7 @@ ArrayRef TensorFlowTypeWithSubtype::GetSubtypes() // TODO(jpienaar): BroadcastCompatible and HasCompatibleElementTypes have // similar structure that could be extracted into helper method. -bool BroadcastCompatible(ArrayRef lhs, ArrayRef rhs) +bool BroadcastCompatible(TypeRange lhs, TypeRange rhs) { if (lhs.size() != rhs.size()) return false; for (auto types : llvm::zip(lhs, rhs)) @@ -395,7 +395,7 @@ bool HasCompatibleElementTypes(Type lhs, Type rhs, return GetCastCompatibleType(lhs, rhs, may_ignore_ref_type_lhs) != nullptr; } -bool AreCastCompatible(ArrayRef types) +bool AreCastCompatible(TypeRange types) { Type common = types.front(); for (auto type : types.drop_front()) @@ -407,7 +407,7 @@ bool AreCastCompatible(ArrayRef types) return true; } -bool ArraysAreCastCompatible(ArrayRef lhs, ArrayRef rhs) +bool ArraysAreCastCompatible(TypeRange lhs, TypeRange rhs) { if (lhs.size() != rhs.size()) return false; for (auto pair : llvm::zip(lhs, rhs)) diff --git a/tools/mlir/tf_types.h b/tools/mlir/tf_types.h index 496aa0229..4bf74cafb 100644 --- a/tools/mlir/tf_types.h +++ b/tools/mlir/tf_types.h @@ -123,14 +123,14 @@ public: static TensorFlowType getChecked(Type type, MLIRContext* context, Location loc) { - if (failed(verifyConstructionInvariants(loc, type))) + if (failed(verify(loc, type))) { return TensorFlowRefType(); } return get(type); } - static LogicalResult verifyConstructionInvariants(Location loc, Type type) + static LogicalResult verify(Location loc, Type type) { // type should be a valid TensorFlow type. if (!IsValidTFTensorType(type)) @@ -237,21 +237,27 @@ public: { return Base::getChecked(loc, subtypes); } + static Derived getChecked(function_ref emitError, + MLIRContext* context, + ArrayRef subtypes) + { + return Base::getChecked(emitError, context, subtypes); + } static Derived get(MLIRContext* context) { return get({}, context); } - static LogicalResult verifyConstructionInvariants( - Location loc, ArrayRef subtypes) + static LogicalResult verify(function_ref emitError, + ArrayRef subtypes) { // Each of the subtypes should be a valid TensorFlow type. for (TensorType subtype : subtypes) { if (!IsValidTFTensorType(subtype)) { - return emitError(loc) << "invalid " << Derived::getTypeName() + return emitError() << "invalid " << Derived::getTypeName() << " subtype: " << subtype; } } @@ -328,7 +334,7 @@ mlir::Type GetCastCompatibleType(mlir::Type a, mlir::Type b, bool may_ignore_ref_type_a); // Returns whether two arrays of Type are broadcast compatible. -bool BroadcastCompatible(ArrayRef lhs, ArrayRef rhs); +bool BroadcastCompatible(TypeRange lhs, TypeRange rhs); // Returns whether the two elemental types are compatible. Shapes are compatible // if: @@ -346,11 +352,11 @@ bool HasCompatibleElementTypes(Type lhs, Type rhs, // another. In other words, a single run-time value is legal for both the types. // For example, tensor<*xf32>, tensor and tensor<3xf32> are cast // compatible. -bool AreCastCompatible(ArrayRef types); +bool AreCastCompatible(TypeRange types); // Returns true if corresponding elements of lhs and rhs AreCastCompatible and // lhs and rhs are the same length. -bool ArraysAreCastCompatible(ArrayRef lhs, ArrayRef rhs); +bool ArraysAreCastCompatible(TypeRange lhs, TypeRange rhs); // If `ty` is a tensor type and its element type has subtypes, then returns a // new type of same shape but dropped subtypes for the element type.