1616#include " tnn/layer/base_layer.h"
1717#include " tnn/utils/dims_vector_utils.h"
1818#include " tnn/utils/naive_compute.h"
19+ #include " tnn/utils/string_utils_inner.h"
1920
2021namespace TNN_NS {
2122
@@ -110,12 +111,12 @@ Status EinsumLayer::InferOutputShape(bool ignore_error) {
110111
111112 case ' .' :
112113 if (found_ell) {
113- const std::string message = " Error: einsum() found \' .\' for operand " + std::to_string (curr_op) +
114+ const std::string message = " Error: einsum() found \' .\' for operand " + ToString (curr_op) +
114115 " for which an ellipsis was already found" ;
115116 return Status (TNNERR_MODEL_ERR, message);
116117 }
117118 if (!(i + 2 < lhs.length () && lhs[++i] == ' .' && lhs[++i] == ' .' )) {
118- const std::string message = " einsum() found \' .\' for operand " + std::to_string (curr_op) +
119+ const std::string message = " einsum() found \' .\' for operand " + ToString (curr_op) +
119120 " that is not part of any ellipsis" ;
120121 return Status (TNNERR_MODEL_ERR, message);
121122 }
@@ -137,7 +138,7 @@ Status EinsumLayer::InferOutputShape(bool ignore_error) {
137138 // Parse label
138139 if (lhs[i] < ' a' && lhs[i] > ' z' ) {
139140 const std::string message = " einsum() operand subscript must be in range [a, z] but found " +
140- std::to_string (lhs[i]) + " for operand " + std::to_string (curr_op);
141+ ToString (lhs[i]) + " for operand " + ToString (curr_op);
141142 return Status (TNNERR_MODEL_ERR, message);
142143 }
143144 // Convert label to index in [0, 25] and store
@@ -179,10 +180,10 @@ Status EinsumLayer::InferOutputShape(bool ignore_error) {
179180
180181 if (!(has_ellipsis ? nlabels <= ndims : nlabels == ndims)) {
181182 const std::string message = " einsum() the number of subscripts in the equation (" +
182- std::to_string (nlabels) +
183+ ToString (nlabels) +
183184 (has_ellipsis ? " ) is more than the number of dimensions ("
184185 : " ) does not match the number of dimensions (" ) +
185- std::to_string (ndims) + " ) for operand " + std::to_string (i) +
186+ ToString (ndims) + " ) for operand " + ToString (i) +
186187 (has_ellipsis ? " " : " and no ellipsis was given" );
187188
188189 return Status (TNNERR_MODEL_ERR, message);
@@ -236,13 +237,13 @@ Status EinsumLayer::InferOutputShape(bool ignore_error) {
236237 default :
237238 if (rhs[i] < ' a' && rhs[i] > ' z' ) {
238239 const std::string message = " einsum() subscripts must be in range [a, z] but found " +
239- std::to_string (rhs[i]) + " for the output" ;
240+ ToString (rhs[i]) + " for the output" ;
240241 return Status (TNNERR_MODEL_ERR, message);
241242 }
242243 const auto label = rhs[i] - ' a' ;
243244 if (!(label_count[label] > 0 && label_perm_index[label] == -1 )) {
244245 const std::string message =
245- " einsum() output subscript " + std::to_string (rhs[i]) +
246+ " einsum() output subscript " + ToString (rhs[i]) +
246247 (label_perm_index[label] > -1 ? " appears more than once in the output"
247248 : " does not appear in the equation for any input operand" );
248249 return Status (TNNERR_MODEL_ERR, message);
@@ -297,10 +298,10 @@ Status EinsumLayer::InferOutputShape(bool ignore_error) {
297298 // Repeated label, take diagonal
298299 const auto dim = label_dim[label];
299300 if (operand_dims[j] != operand_dims[dim]) {
300- const std::string message = " einsum() subscript " + std::to_string (char (label + ' a' )) +
301- " is repeated for operand " + std::to_string (i) +
302- " but the sizes don't match, " + std::to_string (operand_dims[j]) +
303- " != " + std::to_string (operand_dims[dim]);
301+ const std::string message = " einsum() subscript " + ToString (char (label + ' a' )) +
302+ " is repeated for operand " + ToString (i) +
303+ " but the sizes don't match, " + ToString (operand_dims[j]) +
304+ " != " + ToString (operand_dims[dim]);
304305 return Status (TNNERR_MODEL_ERR, message);
305306 }
306307 // diagonal is not supported
0 commit comments