MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / Canonicalize

Function Canonicalize

tensorflow/core/framework/function.cc:908–962  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

906}
907
908string Canonicalize(const string& funcname, AttrSlice attrs,
909 const FunctionLibraryRuntime::InstantiateOptions& options) {
910 std::vector<string> entries;
911 entries.reserve(attrs.size() + static_cast<int>(options.target.empty()) +
912 options.input_devices.size());
913 for (auto p : attrs) {
914 if (p.first != kExecutorAttr) {
915 entries.push_back(strings::StrCat(p.first, "=", Print(p.second)));
916 }
917 }
918 if (!options.target.empty()) {
919 entries.push_back(
920 strings::StrCat("_target", "=", absl::CEscape(options.target)));
921 }
922 for (int i = 0; i < options.input_devices.size(); ++i) {
923 entries.push_back(strings::StrCat("_input_dev", i, "=",
924 absl::CEscape(options.input_devices[i])));
925 }
926 for (int i = 0; i < options.output_devices.size(); ++i) {
927 entries.push_back(strings::StrCat(
928 "_output_dev", i, "=", absl::CEscape(options.output_devices[i])));
929 }
930 for (const auto& iter : options.input_tensor_shapes) {
931 entries.push_back(
932 strings::StrCat("_input_tensor_shape", iter.first, "=",
933 absl::CEscape(iter.second.DebugString())));
934 }
935 for (const auto& iter : options.input_resource_dtypes_and_shapes) {
936 entries.push_back(strings::StrCat("_input_resource_dtype", iter.first, "=",
937 DataTypeString(iter.second.dtype)));
938 entries.push_back(
939 strings::StrCat("_input_resource_shape", iter.first, "=",
940 absl::CEscape(iter.second.shape.DebugString())));
941 }
942 if (options.lib_def) {
943 entries.push_back(strings::StrCat(
944 "_lib_def", "=", reinterpret_cast<uintptr_t>(options.lib_def)));
945 }
946 if (!options.state_handle.empty()) {
947 entries.push_back(
948 strings::StrCat("_state_handle", "=", options.state_handle));
949 }
950 string executor_type = FunctionLibraryRuntime::ExecutorType(options, attrs);
951 if (!executor_type.empty()) {
952 entries.push_back(strings::StrCat(kExecutorAttr, "=", executor_type));
953 }
954 string config_proto_serialized;
955 options.config_proto.SerializeToString(&config_proto_serialized);
956 if (!config_proto_serialized.empty()) {
957 entries.push_back(strings::StrCat("_config_proto", "=",
958 absl::CEscape(config_proto_serialized)));
959 }
960 std::sort(entries.begin(), entries.end());
961 return strings::StrCat(funcname, "[", absl::StrJoin(entries, ","), "]");
962}
963
964FunctionCallFrame::FunctionCallFrame(DataTypeSlice arg_types,
965 DataTypeSlice ret_types)

Callers

nothing calls this directly

Calls 13

CEscapeFunction · 0.85
sortFunction · 0.85
PrintFunction · 0.70
DataTypeStringFunction · 0.70
StrCatFunction · 0.50
reserveMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45
push_backMethod · 0.45
DebugStringMethod · 0.45
SerializeToStringMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected