dmccloskey / TensorBase

A GPU accelerated, in memory, and multi-dimensional database
MIT License
1 stars 1 forks source link

TensorCollection metadata serialization using Cereal #35

Closed dmccloskey closed 5 years ago

dmccloskey commented 5 years ago

Description

As a user, I would like to store the TensorCollection metadata in a binary form that has minimal disk space and is fast to read and write to.

Objectives

Validation

Code Snippets

storeTensorCollectionBinary with e.g. (const std::string & filename, const InterpreterT& model_interpreter) arguments (To be updated)

        std::ofstream ofs(filename, std::ios::binary);  
        //if (ofs.is_open() == false) {// Lines check to make sure the file is not already created
        cereal::BinaryOutputArchive oarchive(ofs); 
        oarchive(model_interpreter); 
        ofs.close();
        //}// Lines check to make sure the file is not already created
        return true;

loadTensorCollectionBinary with e.g. (const std::string & filename, InterpreterT& model_interpreter) arguments (To be updated)

        std::ifstream ifs(filename, std::ios::binary); 
        if (ifs.is_open()) {
            cereal::BinaryInputArchive iarchive(ifs);
            iarchive(model_interpreter);
            ifs.close();
        }
        return true;

e.g. class headers


#include <cereal/access.hpp>  // serialiation of private members
#include <cereal/types/memory.hpp>
#include <cereal/types/map.hpp>
#include <cereal/types/utility.hpp> // std::pair
#include <cereal/types/vector.hpp>

e.g. class decorators

private:
        friend class cereal::access;
        template<class Archive>
        void serialize(Archive& archive)
        {
            archive(id_, name_, module_id_, module_name_, layer_name_, output_max_, output_min_,
                tensor_index_, type_, status_, 
                activation_, activation_grad_, 
                integration_, integration_error_, integration_weight_grad_
            );
        }