MCPcopy Create free account
hub / github.com/pytorch/executorch / get_embedding_layer

Function get_embedding_layer

examples/mediatek/aot_utils/llm_utils/utils.py:437–444  ·  view source on GitHub ↗
(config, weight_dir, state_dict)

Source from the content-addressed store, hash-verified

435
436
437def get_embedding_layer(config, weight_dir, state_dict):
438 embedding_weight = _get_embedding_weight(weight_dir, state_dict)
439
440 model = torch.nn.Embedding(config.vocab_size, config.hidden_size, -1)
441 embed_state_dict = {}
442 embed_state_dict["weight"] = embedding_weight.to(torch.float32)
443 model.load_state_dict(embed_state_dict)
444 return model
445
446
447def get_export_shapes(shapes):

Callers 5

mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90

Calls 2

_get_embedding_weightFunction · 0.85
toMethod · 0.45

Tested by

no test coverage detected