• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright 2022 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/core/transforms/utils/pdll/utils.h"
17 
18 #include "mlir/IR/PatternMatch.h"  // from @llvm-project
19 #include "mlir/Support/LogicalResult.h"  // from @llvm-project
20 #include "tensorflow/core/framework/types.h"
21 #include "tensorflow/core/ir/tf_op_wrapper.h"
22 #include "tensorflow/core/transforms/utils/utils.h"
23 
24 namespace mlir {
25 namespace tfg {
26 namespace {
27 #include "tensorflow/core/transforms/utils/pdll/PDLLUtils.h.inc"
28 }  // namespace
29 
OpHasCpuDeviceImpl(PatternRewriter & rewriter,Operation * op)30 static LogicalResult OpHasCpuDeviceImpl(PatternRewriter &rewriter,
31                                         Operation *op) {
32   return success(util::OpHasDevice(op, tensorflow::DEVICE_CPU));
33 }
34 
RegisterPDLLUtils(RewritePatternSet & patterns)35 void RegisterPDLLUtils(RewritePatternSet &patterns) {
36   patterns.getPDLPatterns().registerConstraintFunction("OpHasCpuDevice",
37                                                        OpHasCpuDeviceImpl);
38 }
39 
40 }  // namespace tfg
41 }  // namespace mlir
42