1 /* Copyright 2021 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 #include "tensorflow/compiler/mlir/tensorflow/transforms/passes.h"
17 #include "tensorflow/compiler/mlir/tensorflow/transforms/passes_detail.h"
18 
19 namespace mlir {
20 namespace TF {
21 
22 namespace {
23 
24 // This tranformation pass strips any "_noinline" attributes from the module.
25 struct StripNoinlineAttributePass
26     : public StripNoinlineAttributePassBase<StripNoinlineAttributePass> {
27  public:
28   // void runOnOperation() override;
runOnOperationmlir::TF::__anon5c1881ac0111::StripNoinlineAttributePass29   void runOnOperation() override {
30     // Strip the "tf._noinline" attribute from top-level functions.
31     for (auto func_op : getOperation().getOps<func::FuncOp>())
32       func_op->removeAttr("tf._noinline");
33   }
34 };
35 
36 }  // namespace
37 
CreateStripNoinlineAttributePass()38 std::unique_ptr<OperationPass<ModuleOp>> CreateStripNoinlineAttributePass() {
39   return std::make_unique<StripNoinlineAttributePass>();
40 }
41 
42 }  // namespace TF
43 }  // namespace mlir
44