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_UTILS_EVAL_UTIL_H_ 17 #define TENSORFLOW_COMPILER_MLIR_TENSORFLOW_UTILS_EVAL_UTIL_H_ 18 19 #include "llvm/ADT/ArrayRef.h" 20 #include "llvm/ADT/SmallVector.h" 21 #include "llvm/ADT/StringRef.h" 22 #include "mlir/IR/Operation.h" // from @llvm-project 23 #include "tensorflow/c/eager/c_api.h" 24 25 namespace tensorflow { 26 27 // Attempts to evaluates an MLIR Operation in TensorFlow eager mode with the 28 // specified operands. The op is always executed on the local host CPU 29 // irrespective of the device attribute of the given op. If there is a CPU 30 // kernel registered for the op and is executed successfully, this fills in the 31 // results vector. If not, results vector is unspecified. 32 // 33 mlir::LogicalResult EvaluateOperation( 34 mlir::Operation* inst, llvm::ArrayRef<mlir::ElementsAttr> operands, 35 TFE_Context* context, llvm::SmallVectorImpl<mlir::Attribute>* results); 36 37 } // namespace tensorflow 38 39 #endif // TENSORFLOW_COMPILER_MLIR_TENSORFLOW_UTILS_EVAL_UTIL_H_ 40