Extend tag conversion behavior to also convert :
(in addition to the
current `/`, `-`, and `.`) to `_`. PiperOrigin-RevId: 499243005
This commit is contained in:
parent
2f4bb5d545
commit
f53c0eacee
|
@ -55,7 +55,7 @@ absl::Status GetLatestDirectory(std::string* path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If options.convert_signature_to_tags() is set, will convert letters to
|
// If options.convert_signature_to_tags() is set, will convert letters to
|
||||||
// uppercase and replace /'s and -'s with _'s. This enables the standard
|
// uppercase and replace /, -, . and :'s with _'s. This enables the standard
|
||||||
// SavedModel classification, regression, and prediction signatures to be used
|
// SavedModel classification, regression, and prediction signatures to be used
|
||||||
// as uppercase INPUTS and OUTPUTS tags for streams and supports other common
|
// as uppercase INPUTS and OUTPUTS tags for streams and supports other common
|
||||||
// patterns.
|
// patterns.
|
||||||
|
@ -67,9 +67,8 @@ const std::string MaybeConvertSignatureToTag(
|
||||||
output.resize(name.length());
|
output.resize(name.length());
|
||||||
std::transform(name.begin(), name.end(), output.begin(),
|
std::transform(name.begin(), name.end(), output.begin(),
|
||||||
[](unsigned char c) { return std::toupper(c); });
|
[](unsigned char c) { return std::toupper(c); });
|
||||||
output = absl::StrReplaceAll(output, {{"/", "_"}});
|
output = absl::StrReplaceAll(
|
||||||
output = absl::StrReplaceAll(output, {{"-", "_"}});
|
output, {{"/", "_"}, {"-", "_"}, {".", "_"}, {":", "_"}});
|
||||||
output = absl::StrReplaceAll(output, {{".", "_"}});
|
|
||||||
LOG(INFO) << "Renamed TAG from: " << name << " to " << output;
|
LOG(INFO) << "Renamed TAG from: " << name << " to " << output;
|
||||||
return output;
|
return output;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -33,8 +33,8 @@ message TensorFlowSessionFromSavedModelCalculatorOptions {
|
||||||
// The name of the generic signature to load into the mapping from tags to
|
// The name of the generic signature to load into the mapping from tags to
|
||||||
// tensor names.
|
// tensor names.
|
||||||
optional string signature_name = 2 [default = "serving_default"];
|
optional string signature_name = 2 [default = "serving_default"];
|
||||||
// Whether to convert the signature keys to uppercase as well as switch /'s
|
// Whether to convert the signature keys to uppercase as well as switch
|
||||||
// and -'s to _'s, which enables common signatures to be used as Tags.
|
// /, -, .and :'s to _'s, which enables common signatures to be used as Tags.
|
||||||
optional bool convert_signature_to_tags = 3 [default = true];
|
optional bool convert_signature_to_tags = 3 [default = true];
|
||||||
// If true, saved_model_path can have multiple exported models in
|
// If true, saved_model_path can have multiple exported models in
|
||||||
// subdirectories saved_model_path/%08d and the alphabetically last (i.e.,
|
// subdirectories saved_model_path/%08d and the alphabetically last (i.e.,
|
||||||
|
|
|
@ -61,7 +61,7 @@ absl::Status GetLatestDirectory(std::string* path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If options.convert_signature_to_tags() is set, will convert letters to
|
// If options.convert_signature_to_tags() is set, will convert letters to
|
||||||
// uppercase and replace /'s and -'s with _'s. This enables the standard
|
// uppercase and replace /, -, and .'s with _'s. This enables the standard
|
||||||
// SavedModel classification, regression, and prediction signatures to be used
|
// SavedModel classification, regression, and prediction signatures to be used
|
||||||
// as uppercase INPUTS and OUTPUTS tags for streams and supports other common
|
// as uppercase INPUTS and OUTPUTS tags for streams and supports other common
|
||||||
// patterns.
|
// patterns.
|
||||||
|
@ -73,9 +73,8 @@ const std::string MaybeConvertSignatureToTag(
|
||||||
output.resize(name.length());
|
output.resize(name.length());
|
||||||
std::transform(name.begin(), name.end(), output.begin(),
|
std::transform(name.begin(), name.end(), output.begin(),
|
||||||
[](unsigned char c) { return std::toupper(c); });
|
[](unsigned char c) { return std::toupper(c); });
|
||||||
output = absl::StrReplaceAll(output, {{"/", "_"}});
|
output = absl::StrReplaceAll(
|
||||||
output = absl::StrReplaceAll(output, {{"-", "_"}});
|
output, {{"/", "_"}, {"-", "_"}, {".", "_"}, {":", "_"}});
|
||||||
output = absl::StrReplaceAll(output, {{".", "_"}});
|
|
||||||
LOG(INFO) << "Renamed TAG from: " << name << " to " << output;
|
LOG(INFO) << "Renamed TAG from: " << name << " to " << output;
|
||||||
return output;
|
return output;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -33,8 +33,8 @@ message TensorFlowSessionFromSavedModelGeneratorOptions {
|
||||||
// The name of the generic signature to load into the mapping from tags to
|
// The name of the generic signature to load into the mapping from tags to
|
||||||
// tensor names.
|
// tensor names.
|
||||||
optional string signature_name = 2 [default = "serving_default"];
|
optional string signature_name = 2 [default = "serving_default"];
|
||||||
// Whether to convert the signature keys to uppercase as well as switch /'s
|
// Whether to convert the signature keys to uppercase, as well as switch /'s
|
||||||
// and -'s to _'s, which enables common signatures to be used as Tags.
|
// -'s, .'s, and :'s to _'s, enabling common signatures to be used as Tags.
|
||||||
optional bool convert_signature_to_tags = 3 [default = true];
|
optional bool convert_signature_to_tags = 3 [default = true];
|
||||||
// If true, saved_model_path can have multiple exported models in
|
// If true, saved_model_path can have multiple exported models in
|
||||||
// subdirectories saved_model_path/%08d and the alphabetically last (i.e.,
|
// subdirectories saved_model_path/%08d and the alphabetically last (i.e.,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user