1 /* Copyright 2015 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/compiler/xla/stream_executor/blas.h" 17 18 #include "absl/strings/str_cat.h" 19 20 namespace stream_executor { 21 namespace blas { 22 TransposeString(Transpose t)23std::string TransposeString(Transpose t) { 24 switch (t) { 25 case Transpose::kNoTranspose: 26 return "NoTranspose"; 27 case Transpose::kTranspose: 28 return "Transpose"; 29 case Transpose::kConjugateTranspose: 30 return "ConjugateTranspose"; 31 default: 32 LOG(FATAL) << "Unknown transpose " << static_cast<int32>(t); 33 } 34 } 35 UpperLowerString(UpperLower ul)36std::string UpperLowerString(UpperLower ul) { 37 switch (ul) { 38 case UpperLower::kUpper: 39 return "Upper"; 40 case UpperLower::kLower: 41 return "Lower"; 42 default: 43 LOG(FATAL) << "Unknown upperlower " << static_cast<int32>(ul); 44 } 45 } 46 DiagonalString(Diagonal d)47std::string DiagonalString(Diagonal d) { 48 switch (d) { 49 case Diagonal::kUnit: 50 return "Unit"; 51 case Diagonal::kNonUnit: 52 return "NonUnit"; 53 default: 54 LOG(FATAL) << "Unknown diagonal " << static_cast<int32>(d); 55 } 56 } 57 SideString(Side s)58std::string SideString(Side s) { 59 switch (s) { 60 case Side::kLeft: 61 return "Left"; 62 case Side::kRight: 63 return "Right"; 64 default: 65 LOG(FATAL) << "Unknown side " << static_cast<int32>(s); 66 } 67 } 68 69 // -- AlgorithmConfig 70 ToString() const71std::string AlgorithmConfig::ToString() const { 72 return absl::StrCat(algorithm_); 73 } 74 ComputationTypeString(ComputationType ty)75std::string ComputationTypeString(ComputationType ty) { 76 switch (ty) { 77 case ComputationType::kF16: 78 return "f16"; 79 case ComputationType::kF32: 80 return "f32"; 81 case ComputationType::kF64: 82 return "f64"; 83 case ComputationType::kI32: 84 return "i32"; 85 case ComputationType::kF16AsF32: 86 return "f16 (w/ f32 accumulation)"; 87 case ComputationType::kBF16AsF32: 88 return "bf16 (w/ f32 accumulation)"; 89 case ComputationType::kTF32AsF32: 90 return "tf32 (w/ f32 accumulation)"; 91 } 92 } 93 operator <<(std::ostream & os,ComputationType ty)94std::ostream& operator<<(std::ostream& os, ComputationType ty) { 95 return os << ComputationTypeString(ty); 96 } 97 DataTypeString(DataType ty)98std::string DataTypeString(DataType ty) { 99 switch (ty) { 100 case DataType::kBF16: 101 return "bf16"; 102 case DataType::kHalf: 103 return "f16"; 104 case DataType::kFloat: 105 return "f32"; 106 case DataType::kDouble: 107 return "f64"; 108 case DataType::kInt8: 109 return "i8"; 110 case DataType::kInt32: 111 return "i32"; 112 case DataType::kComplexFloat: 113 return "complex f32"; 114 case DataType::kComplexDouble: 115 return "complex f64"; 116 default: 117 LOG(FATAL) << "Unknown DataType " << static_cast<int32>(ty); 118 } 119 } 120 operator <<(std::ostream & os,DataType ty)121std::ostream& operator<<(std::ostream& os, DataType ty) { 122 return os << DataTypeString(ty); 123 } 124 125 } // namespace blas 126 } // namespace stream_executor 127