BatchSize

class BatchSize

Symbolic size of the batch dimension of a Value.

A batch size is one of: the scalar size one (no batch dimension), a named symbol such as "batch_size", an anonymous symbol created for an intermediate result, or a sum of such terms with integer coefficients. Sizes are added and compared symbolically, so a graph can be type checked without knowing the actual number of events.

Public Types

using Named = std::string
using Unnamed = std::shared_ptr<UnnamedBody>
using One = std::monostate
using Compound = std::map<std::variant<Named, Unnamed, One>, int>

Public Functions

inline BatchSize(const std::string &name)

Named batch size such as "batch_size".

Parameters:

name – symbol name

inline BatchSize(One value)

Scalar batch size (no batch dimension).

inline BatchSize()

Fresh anonymous batch size, distinct from every other.

inline BatchSize operator+(const BatchSize &other) const

Symbolic sum of two batch sizes.

inline BatchSize operator-(const BatchSize &other) const

Symbolic difference of two batch sizes.

inline bool operator==(const BatchSize &other) const
inline bool operator!=(const BatchSize &other) const
std::string to_string() const

Human-readable representation such as "batch_size + 1".

Public Static Attributes

static const BatchSize zero

The empty batch size (a sum of no terms).

static const BatchSize one

The scalar batch size (no batch dimension).

Friends

friend std::ostream &operator<<(std::ostream &out, const BatchSize &batch_size)
friend void to_json(nlohmann::json &j, const BatchSize &batch_size)
friend void from_json(const nlohmann::json &j, BatchSize &batch_size)
class UnnamedBody

Public Functions

inline UnnamedBody()
inline bool operator==(const UnnamedBody &other) const
inline bool operator!=(const UnnamedBody &other) const

Friends

friend std::ostream &operator<<(std::ostream &out, const BatchSize &batch_size)
friend void to_json(nlohmann::json &j, const BatchSize &batch_size)