MCPcopy Create free account
hub / github.com/LBANN/lbann / add_weights

Method add_weights

src/models/model.cpp:496–527  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

494}
495
496void model::add_weights(OwningWeightsPtr&& ptr)
497{
498
499 // Check for null pointer
500 if (ptr == nullptr) {
501 LBANN_ERROR("attempted to add a null pointer as weights to ",
502 "model \"",
503 get_name(),
504 "\"");
505 }
506
507 // Check that the new weights name is unique
508 // Note: Adding weights is O(n^2), but this is unlikely to be a
509 // bottleneck. If it is, consider maintaining a hash table
510 // containing all weights names (and properly updating it during
511 // copies and pointer remaps).
512 const auto& name = ptr->get_name();
513 for (const auto& w : m_weights) {
514 if (w->get_name() == name) {
515 LBANN_ERROR("attempted to add weights \"",
516 name,
517 "\" to ",
518 "model \"",
519 get_name(),
520 "\", ",
521 "but the model already contains weights with that name");
522 }
523 }
524
525 // Add weights to model
526 m_weights.emplace_back(std::move(ptr));
527}
528
529void model::remove_weights(std::string const& removable_weight_name)
530{

Callers 9

construct_modelFunction · 0.45
write_protoMethod · 0.45
setup_dataMethod · 0.45
setup_dataMethod · 0.45
setup_dataMethod · 0.45
setup_dataMethod · 0.45
setup_dataMethod · 0.45
write_specific_protoMethod · 0.45
write_protoMethod · 0.45

Calls 1

get_nameMethod · 0.45

Tested by

no test coverage detected