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

Method get_partner_model

src/execution_algorithms/ltfb/checkpoint_binary.cpp:48–76  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46{}
47
48std::unique_ptr<model>
49CheckpointBinary::get_partner_model(model const& m,
50 El::Int partner_trainer,
51 size_t /*step*/)
52{
53 auto const& comm = *m.get_comm();
54
55 // Start by copying this model, then do the exchange.
56 auto partner_model_ptr = std::make_unique<model>(m);
57 model& partner_model = *partner_model_ptr;
58
59 // Keep track of weights that shouldn't be exchanged
60 std::unordered_map<std::string, std::unique_ptr<weights>> restore_weights;
61 auto const& weights_names = this->weights_names();
62 if (!weights_names.empty()) {
63 for (auto w : partner_model.get_weights()) {
64 if (weights_names.find(w->get_name()) == weights_names.cend()) {
65 using TensorDataType = DataType;
66 using WeightsType = data_type_weights<TensorDataType>;
67 restore_weights[w->get_name()] =
68 std::make_unique<WeightsType>(dynamic_cast<WeightsType&>(*w));
69 }
70 }
71 }
72 exchange(comm, partner_model, partner_trainer);
73 restore_model_weights(partner_model, restore_weights);
74
75 return partner_model_ptr;
76}
77
78} // namespace ltfb
79} // namespace lbann

Callers

nothing calls this directly

Calls 7

weights_namesMethod · 0.80
exchangeFunction · 0.70
restore_model_weightsFunction · 0.70
get_commMethod · 0.45
emptyMethod · 0.45
get_weightsMethod · 0.45
get_nameMethod · 0.45

Tested by

no test coverage detected