Serialization Library

Copyright (c) Facebook, Inc.

and its affiliates. All rights reserved.

This source code is licensed under the BSD-style license found in the LICENSE file in the root directory of this source tree.

Serialization support using the Cereal library. Provides serialization functions for af::array and af::dim4 and convenience utilities.

Defines

FL_SAVE_LOAD(...)

Note the following guidelines for serialization:

  • By default you should use save/load pairs and explicit versioning. The provided macros encourage this usage.

  • Saving an object must not mutate it. save() being const helps, but be careful about Variable which is a shared_ptr to non-const.

  • Loading an object must provide the basic exception guarantee. After an exception, the object must be safe to destroy and no leaks can occur.

  • For simplicity, load() may assume that the initial state of the object is default-constructed. Conversely, one must only call load() on a default-constructed object.

  • Avoid serializing long, size_t, and ArrayFire’s dim_t since these types have platform-dependent sizes. Fixed-size types like int64_t are always fine. int, long long should be fine on virtually all platforms. Convenience macro for specifying a simple serialization method for Cereal. Serializes the specified arguments, usually class members. Should be placed in the private section of a class. For polymorphic classes, use FL_SAVE_LOAD_WITH_BASE instead.

Supports the common case when one adds fields to a class, which should be conditionally loaded for newer file versions. See fl::versioned().

FL_SAVE_LOAD_WITH_BASE(Base, ...)

Like FL_SAVE_LOAD, but also serializes the base class, which must be specified as the first argument.

NB: You do not need to use CEREAL_REGISTER_POLYMORPHIC_RELATION if you are using this macro. However you will still need CEREAL_REGISTER_TYPE.

FL_SAVE_LOAD_DECLARE()

Declaration-only.

Intended to reduce clutter in class definitions. This macro should be placed in the private section of a class. The method must be defined later (outside the class). Do not use this macro if you want your class to be unversioned.

namespace fl

Copyright (c) Facebook, Inc.

and its affiliates. All rights reserved.

This source code is licensed under the BSD-style license found in the LICENSE file in the root directory of this source tree.

and its affiliates. All rights reserved.

This source code is licensed under the BSD-style license found in the LICENSE file in the root directory of this source tree. Logging is a light, multi-level, compile time filterable, logging infrastructure that is similar to glog in output format. It defines two logging macros, one for any logging and the other for more verbose logging. Compile time filter is applied separately to each of the two.

Output format: LMMDD HH:MM:SS.uuuuuu tid filename:##] Log message … L: Log level (Fatal, Critical, Error, Warning, Info) MMDD: month, day HH:MM:SS.uuuuuu: time (24-hour format) with micro-seconds tid: thread ID filename:## the basename of the source file and line number of the LOG message

LOG use examples: LOG(INFO) << “foo bar n=” << 42; Output example: I0206 10:42:21.047293 87072 Logging.h:15 foo bar n=42 Note that LOG(level) only prints when level is <= from value set to Logging::setMaxLoggingLevel(level)

VLOG use example: VLOG(1) << “foo bar n=” << 42; Output example: vlog(1)0206 10:42:21.005439 87072 Logging.h:23 foo bar n=42 Note that VLOG(level) only prints when level is <= from value set to VerboseLogging::setMaxLoggingLevel(level)

and its affiliates. All rights reserved.

This source code is licensed under the BSD-style license found in the LICENSE file in the root directory of this source tree. The configurable memory allocator is obtained by calling: std::unique_ptr<MemoryAllocator> CreateMemoryAllocator(config) Config defines a a set of allocators assembled in a CompositeMemoryAllocator.

template<typename ...Args>
void save(const std::string &filepath, const Args&... args)
template<typename ...Args>
void save(std::ostream &ostr, const Args&... args)
template<typename ...Args>
void load(const std::string &filepath, Args&... args)
template<typename ...Args>
void load(std::istream &istr, Args&... args)
template <typename T> detail::Versioned<T> versioned(T&& t, uint32_t minVersion, uint32_t maxVersion = UINT32_MAX);