1 /* Copyright 2020 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_XLA_ATTRIBUTE_EXPORTER_H_ 17 #define TENSORFLOW_COMPILER_MLIR_XLA_ATTRIBUTE_EXPORTER_H_ 18 19 #include "mlir/IR/Attributes.h" // from @llvm-project 20 #include "tensorflow/compiler/mlir/hlo/include/mlir-hlo/Dialect/mhlo/IR/hlo_ops.h" 21 #include "tensorflow/compiler/xla/statusor.h" 22 #include "tensorflow/compiler/xla/types.h" 23 #include "tensorflow/compiler/xla/xla_data.pb.h" 24 #include "tensorflow/stream_executor/dnn.h" 25 26 namespace xla { 27 28 // Converts the conv dimensions attribute to XLA HLO. 29 ConvolutionDimensionNumbers ConvertConvDimensionNumbers( 30 mlir::mhlo::ConvDimensionNumbers input); 31 32 StatusOr<stream_executor::dnn::ActivationMode> ConvertConvActivationMode( 33 llvm::StringRef input); 34 35 StatusOr<std::vector<ReplicaGroup>> ConvertReplicaGroups( 36 mlir::DenseIntElementsAttr input); 37 38 // Convert a (N, 2) dense attribute to a list of tuples. This is the way padding 39 // and source-target pairs are defined in HLO. 40 StatusOr<std::vector<std::pair<int64, int64>>> ConvertNx2Attribute( 41 llvm::Optional<mlir::DenseIntElementsAttr> optional_attr); 42 43 StatusOr<FftType> ConvertFftType(llvm::StringRef type_string); 44 StatusOr<TriangularSolveOptions::Transpose> ConvertTranspose( 45 llvm::StringRef transpose_string); 46 47 } // namespace xla 48 #endif // TENSORFLOW_COMPILER_MLIR_XLA_ATTRIBUTE_EXPORTER_H_ 49