1 /* Copyright 2017 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_ARITHMETIC_H_ 17 #define TENSORFLOW_COMPILER_XLA_CLIENT_LIB_ARITHMETIC_H_ 18 19 #include <memory> 20 21 #include "tensorflow/compiler/xla/client/xla_builder.h" 22 #include "tensorflow/compiler/xla/client/xla_computation.h" 23 #include "tensorflow/compiler/xla/xla_data.pb.h" 24 25 namespace xla { 26 27 // Creates a scalar add computation and returns it. 28 XlaComputation CreateScalarAddComputation(PrimitiveType type, 29 XlaBuilder* builder); 30 31 // Creates a scalar multiply computation and returns it. 32 XlaComputation CreateScalarMultiplyComputation(PrimitiveType type, 33 XlaBuilder* builder); 34 35 // Creates a scalar ge computation and returns it. 36 XlaComputation CreateScalarGeComputation(PrimitiveType type, 37 XlaBuilder* builder); 38 39 // Creates a scalar max computation and returns it. 40 XlaComputation CreateScalarMaxComputation(PrimitiveType type, 41 XlaBuilder* builder); 42 43 // Creates a scalar min computation and returns it. 44 XlaComputation CreateScalarMinComputation(PrimitiveType type, 45 XlaBuilder* builder); 46 47 // Creates a scalar logical AND computation and returns it. 48 XlaComputation CreateScalarAndComputation(PrimitiveType type, 49 XlaBuilder* builder); 50 51 // Creates a scalar logical OR computation and returns it. 52 XlaComputation CreateScalarOrComputation(PrimitiveType type, 53 XlaBuilder* builder); 54 55 // Returns whether any predicate in "predicates" is set. 56 // 57 // Note: if predicates is zero-sized, Any() vacuously returns false. 58 XlaOp Any(XlaOp predicates); 59 60 // Returns the argmax of `input` along `axis`. `output_type` is the type to 61 // use for the output. 62 XlaOp ArgMax(XlaOp input, PrimitiveType output_type, int axis); 63 64 // Returns the argmin of `input` along `axis`. `output_type` is the type to 65 // use for the output. 66 XlaOp ArgMin(XlaOp input, PrimitiveType output_type, int axis); 67 68 } // namespace xla 69 70 #endif // TENSORFLOW_COMPILER_XLA_CLIENT_LIB_ARITHMETIC_H_ 71