OptionFlags
#include <poplar/OptionFlags.hpp>
-
namespace poplar
Poplar classes and functions.
A VectorList is a list of vectors with a specific layout and with the usage semantics of a 2D vector.
A 1D vector must be laid out in a contiguous memory region. A 2D vector is a vector of 1D vectors. Each of these 1D vectors that make up a 2D vector is called a “sub-vector” for the remainder of this document. The elements of a 2D vector can be accessed by indexing the 2D vector along the
outer
andinner
dimensions asA[outer][inner]
.The following two categories of layouts are supported:
VectorListLayout::DELTANELEMENTS
is a memory efficient 2D vector layout. For legacy systemsVectorListLayout::DELTAN
served a similar purpose. Each sub-vector must be laid out as a contiguous memory region but the sub-vectors may may not be laid out contiguous with respect to each other in memory. Each sub-vector may have a different length.VectorListLayout::ONE_PTR
and otherVectorListLayout
layouts that are prefixed by SCALED_PTR are for Poplar runtime use only.
Functions
-
ProfileValue getAsProfileValue(const OptionFlags &flags)
-
void readJSON(StringRef string, OptionFlags &flags)
Read options from a string in JSON format.
- Parameters
string – The string to parse.
flags – The OptionFlags to update.
- Throws
parse_error – if the input cannot be parsed.
-
void readJSON(std::istream &stream, OptionFlags &flags)
Read options from a stream in JSON format.
- Parameters
stream – The input stream to read from.
flags – The OptionFlags to update.
- Throws
parse_error – if the input cannot be parsed.
-
void readJSONFromEnv(StringRef envVarName, OptionFlags &flags)
Read options from a environment variable in JSON format.
- Parameters
envVarName – The environment variable to retrieve and parse.
flags – The OptionFlags to update.
- Throws
parse_error – if the input cannot be parsed.
-
std::ostream &operator<<(std::ostream &ostream, const OptionFlags &flags)
Write the contents of the given flags to an ostream in JSON format.
- Parameters
ostream – The stream to write to.
flags – The OptionFlags to write.
-
class OptionFlags
- #include <OptionFlags.hpp>
A set of option/value string flags to be used in various APIs.
Public Types
-
using initializer_list = std::initializer_list<OptionFlag>
Public Functions
-
OptionFlags()
Construct a set of option flags.
The default constructor creates an empty set of flags.
-
~OptionFlags()
-
OptionFlags(const OptionFlags &other)
-
OptionFlags(OptionFlags &&other) noexcept
-
OptionFlags &operator=(const OptionFlags &other)
-
OptionFlags &operator=(OptionFlags &&other) noexcept
-
bool operator==(const OptionFlags &other) const
Option flags are an exact match.
Each collection contains the same keys, and both collections have the same values for each key
-
inline OptionFlags(initializer_list &&list)
Construct a set of option flags from an initializer list of string pairs.
Flags are set in the order they appear in the constructor.
Setting a flag more than once will result in the previous value for that option being overwritten.
- Parameters
initializer – A list of option/value string pairs to set in the flags.
-
void set(initializer_list &&list)
Set option flags from an initializer list of string pairs.
Flags are set in the order they appear in the list.
Setting a flag more than once will result in the previous value for that option being overwritten. If the option was already set in these flags then the previous value will be overwritten.
- Parameters
initializer – A list of option/value string pairs to set in the flags.
-
void set(StringRef option, StringRef value)
Set a single option to a value.
If the option was already set in these flags then the previous value will be over- written.
- Parameters
option – The option to set in the flags.
value – The value to set the option to in the flags.
-
StringRef at(StringRef option) const
Retrieves the value of the given option.
If the option does not exist, then an exception is thrown.
- Parameters
option – The option to retrieve in the flags.
-
OptionFlags::iterator find(const StringRef option) const
Retrieves an iterator to an element with key equivalent to option.
If no such element is found, past-the-end (see end()) iterator is returned.
- Parameters
option – The option to retrieve in the flags.
-
size_t size() const
Returns the number of option/value string flags that have been set.
-
void clear()
Remove all set flags.
-
iterator begin() const
Get iterators for the currently set option flags.
All iterators are invalidated when a new flag is set or the option flags are re-assigned.
-
inline const gccs::OptionFlags &getImpl() const
-
class iterator : public std::iterator<std::forward_iterator_tag, OptionFlag>
Public Functions
-
~iterator()
-
const OptionFlag &operator*() const
-
const OptionFlag *operator->() const
Friends
- friend class OptionFlags
-
~iterator()
-
using initializer_list = std::initializer_list<OptionFlag>