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

Method ConvertToHashLookupOp

serving/processor/framework/graph_optimizer.cc:1819–1848  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1817}
1818
1819Status SavedModelOptimizer::ConvertToHashLookupOp(
1820 Node* node, std::vector<SrcInfo>& input_info) {
1821 std::unordered_map<std::string, std::string> attr_info_map;
1822
1823 // KvResourceGather -> LookupTableFindV2
1824 attr_info_map["dtype"] = "Tout";
1825 attr_info_map["Tkeys"] = "Tin";
1826
1827 AttrValue* dtype_attr = nullptr;
1828 Status s_attr = GetNodeAttr(node, "dtype", &dtype_attr);
1829 TF_RETURN_IF_ERROR(s_attr);
1830
1831 // create a defaualt value node
1832 Node* default_value_node = nullptr;
1833 int dim = 0;
1834 Status s_shape_value = GetShapeValue(input_info[0].src_node, &dim);
1835 TF_RETURN_IF_ERROR(s_shape_value);
1836 // shape = [dim]
1837 Status s_default_value = CreateDefaultValueNode(
1838 &graph_, dim, &default_value_node, dtype_attr->type(),
1839 input_info[2].src_node->name() + "/new_default_value");
1840 TF_RETURN_IF_ERROR(s_default_value);
1841
1842 // use newly created default value node(filled by zeros)
1843 input_info[2].src_node = default_value_node;
1844 input_info[2].src_slot = 0;
1845 return ReplaceNode(
1846 "LookupTableFindV2", node, &graph_, input_info,
1847 attr_info_map);
1848}
1849
1850Status SavedModelOptimizer::ConvertToHashImportOp(
1851 Node* node, std::vector<SrcInfo>& input_info) {

Callers

nothing calls this directly

Calls 6

GetShapeValueFunction · 0.85
CreateDefaultValueNodeFunction · 0.85
GetNodeAttrFunction · 0.70
ReplaceNodeFunction · 0.70
typeMethod · 0.65
nameMethod · 0.65

Tested by

no test coverage detected