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/stream_executor/blas.h"
17 
18 #include "absl/strings/str_cat.h"
19 
20 namespace stream_executor {
21 namespace blas {
22 
TransposeString(Transpose t)23 std::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)36 std::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)47 std::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)58 std::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() const71 std::string AlgorithmConfig::ToString() const {
72   return absl::StrCat(algorithm_);
73 }
74 
ComputationTypeString(ComputationType ty)75 std::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::kComplexF32:
86       return "complex f32";
87     case ComputationType::kComplexF64:
88       return "complex f64";
89     default:
90       LOG(FATAL) << "Unknown ComputationType " << static_cast<int32>(ty);
91   }
92 }
93 
operator <<(std::ostream & os,ComputationType ty)94 std::ostream& operator<<(std::ostream& os, ComputationType ty) {
95   return os << ComputationTypeString(ty);
96 }
97 
DataTypeString(DataType ty)98 std::string DataTypeString(DataType ty) {
99   switch (ty) {
100     case DataType::kHalf:
101       return "f16";
102     case DataType::kFloat:
103       return "f32";
104     case DataType::kDouble:
105       return "f64";
106     case DataType::kInt8:
107       return "i8";
108     case DataType::kInt32:
109       return "i32";
110     case DataType::kComplexFloat:
111       return "complex f32";
112     case DataType::kComplexDouble:
113       return "complex f64";
114     default:
115       LOG(FATAL) << "Unknown DataType " << static_cast<int32>(ty);
116   }
117 }
118 
operator <<(std::ostream & os,DataType ty)119 std::ostream& operator<<(std::ostream& os, DataType ty) {
120   return os << DataTypeString(ty);
121 }
122 
123 }  // namespace blas
124 }  // namespace stream_executor
125