1 /* Copyright 2018 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_XLA_CLIENT_LIB_QR_H_ 17 #define TENSORFLOW_COMPILER_XLA_CLIENT_LIB_QR_H_ 18 19 #include "tensorflow/compiler/xla/client/xla_builder.h" 20 #include "tensorflow/compiler/xla/xla_data.pb.h" 21 22 namespace xla { 23 24 // Computes the QR decompositions of a batch of matrices. That is, 25 // given a (batched) matrix a, computes an orthonormal matrix Q and an 26 // upper-triangular matrix R such that a = QR. 27 // `a` must be a (batched) matrix of size [..., m, n]. 28 // The algorithm implements a blocked QR decomposition; `block_size` is 29 // the block size to use. 30 // TODO(phawkins): handle the complex case. 31 struct QRDecompositionResult { 32 XlaOp q; 33 XlaOp r; 34 }; 35 36 StatusOr<QRDecompositionResult> QRDecomposition( 37 XlaOp a, bool full_matrices, int64 block_size = 128, 38 PrecisionConfig::Precision precision = PrecisionConfig::HIGHEST); 39 40 } // namespace xla 41 42 #endif // TENSORFLOW_COMPILER_XLA_CLIENT_LIB_QR_H_ 43