1 /* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
2 
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6 
7     http://www.apache.org/licenses/LICENSE-2.0
8 
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ==============================================================================*/
15 
16 #ifndef TENSORFLOW_COMPILER_MLIR_TENSORFLOW_TRANSFORMS_SHAPE_INFERENCE_H_
17 #define TENSORFLOW_COMPILER_MLIR_TENSORFLOW_TRANSFORMS_SHAPE_INFERENCE_H_
18 
19 #include <cstdint>
20 
21 #include "mlir/IR/BuiltinOps.h"  // from @llvm-project
22 #include "mlir/IR/Operation.h"  // from @llvm-project
23 #include "mlir/IR/Region.h"  // from @llvm-project
24 #include "mlir/Support/LogicalResult.h"  // from @llvm-project
25 
26 namespace mlir {
27 namespace TF {
28 
29 // Refines all the shapes in a module.
30 LogicalResult InferModuleShape(ModuleOp module, int64_t max_iterations = 10);
31 
32 // Given a list of refined shapes matching the function arguments of func, runs
33 // shape inference over the function to propagate this updated information.
34 // If arg_shapes are empty, then argument shapes will be left unchanged.
35 // Note: This affects the entire module, and changes are not just scoped to the
36 // function being inferred.
37 LogicalResult InferShapeForFunction(FuncOp func,
38                                     ArrayRef<ArrayRef<int64_t>> arg_shapes,
39                                     int64_t graph_version,
40                                     int64_t max_iterations = 10);
41 
42 }  // namespace TF
43 
44 }  // namespace mlir
45 
46 #endif  // TENSORFLOW_COMPILER_MLIR_TENSORFLOW_TRANSFORMS_SHAPE_INFERENCE_H_
47