From 6f36ade67665e89143a981506cfb8070879ed185 Mon Sep 17 00:00:00 2001 From: Haoliang Zhang Date: Fri, 12 Feb 2021 17:27:44 -0800 Subject: [PATCH] Add ODS for `SaveOp` and `RestoreOp`. PiperOrigin-RevId: 357297873 Change-Id: Ifdc604b482c6d495f9eaabe5811b9ea70ba8776c --- .../mlir/tensorflow/ir/tf_generated_ops.td | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/tensorflow/compiler/mlir/tensorflow/ir/tf_generated_ops.td b/tensorflow/compiler/mlir/tensorflow/ir/tf_generated_ops.td index d3ab0b1d5a6..43f02b9b182 100644 --- a/tensorflow/compiler/mlir/tensorflow/ir/tf_generated_ops.td +++ b/tensorflow/compiler/mlir/tensorflow/ir/tf_generated_ops.td @@ -11823,6 +11823,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."; @@ -12716,6 +12754,28 @@ 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.";