DiSMEC++
model-io.cpp File Reference
#include "io/model-io.h"
#include "io/common.h"
#include "io/weights.h"
#include "model/dense.h"
#include "model/sparse.h"
#include "model/submodel.h"
#include <fstream>
#include <array>
#include <iomanip>
#include <utility>
#include "spdlog/spdlog.h"
#include "spdlog/fmt/fmt.h"
#include "spdlog/fmt/chrono.h"
#include "nlohmann/json.hpp"
#include "parallel/numa.h"
#include "doctest.h"

Go to the source code of this file.

Namespaces

 anonymous_namespace{model-io.cpp}
 

Typedefs

using json = nlohmann::json
 

Functions

void anonymous_namespace{model-io.cpp}::save_weights_dispatch (std::ostream &target, const Model &model, SaveOption &options)
 This function calls on of the save functions, depending on the format specified on options More...
 
void anonymous_namespace{model-io.cpp}::read_weights_dispatch (std::istream &source, WeightFormat format, Model &model)
 This function calls the reads function that corresponds to the given weight format. More...
 
std::shared_ptr< Modelanonymous_namespace{model-io.cpp}::make_model (long num_features, ::model::PartialModelSpec spec, bool sparse)
 
bool anonymous_namespace{model-io.cpp}::use_sparse_weights (PartialModelLoader::ESparseMode mode, WeightFormat format)
 
 TEST_CASE ("partial model writer verifier")
 
 TEST_CASE ("label lower bound")
 
 TEST_CASE ("insert_sub_file")
 

Variables

const std::array< const char *, 4 > anonymous_namespace{model-io.cpp}::weight_format_names
 Translation from io::model::WeightFormat to std::string. More...
 
const std::array< bool, 4 > anonymous_namespace{model-io.cpp}::weight_format_sparsity
 Lookup which mode has sparse weights. More...
 

Typedef Documentation

◆ json

using json = nlohmann::json

Definition at line 22 of file model-io.cpp.

Function Documentation

◆ TEST_CASE() [1/3]

TEST_CASE ( "insert_sub_file"  )

Definition at line 529 of file model-io.cpp.

References dismec::io::model::NULL_FORMAT.

◆ TEST_CASE() [2/3]

◆ TEST_CASE() [3/3]

TEST_CASE ( "partial model writer verifier"  )
Test:
This test case checks that PartialModelSaver verifies that the partial models it receives are compatible. This includes checking that the number of total labels/features match. To check that the error condition we want to check for is really the problem, we first try the add_model call with an invalid partial model, and secondly call it with a corrected version. If the corrected version also fails, we know that our check did not work, or that the first call did throw but still added the partial model to its model list. We assume that label overlap tests are correctly performed; this is tested in the unit test for insert_sub_file.

Definition at line 478 of file model-io.cpp.

References dismec::io::model::PartialModelSaver::add_model(), dismec::io::model::PartialModelSaver::finalize(), dismec::io::model::SaveOption::Format, and dismec::io::model::NULL_FORMAT.