Class SymbolVar

Class Documentation

class mgb::cg::SymbolVar

Wrap a VarNode* for operator overloading.

Public Functions

SymbolVar() = default
SymbolVar(cg::VarNode *node)
cg::VarNode *node() const
DType dtype() const
Maybe<DTypeScalar> as_immutable_scalar() const

if the value is immutable and equals to some value at every position, return it

Note: the shape may be larger than (1, )

Maybe<DTypeScalar> as_immutable_scalar_require_shape() const

similar to as_immutable_scalar(), but also require shape to be (1, )

template<typename Node, typename ...Args>
SymbolVar insert_single_output_opr(Args&&... args) const

insert an operation with signle output into underlying graph Implemented in graph/cg.h

helper function for creating an operator with unique output and inserting it into graph

SymbolVar rename(const std::string &name) const

set a new name; note that the underlying VarNode would be modified, not this SymbolVar itself

SymbolVar reshape(const TensorShape &tshape) const
SymbolVar reshape(SymbolVar tshape) const
SymbolVar broadcast(const TensorShape &tshape) const
SymbolVar broadcast(SymbolVar tshape) const
SymbolVar symshape() const
SymbolVar flatten() const
SymbolVar add_axis(size_t idx) const
const TensorShape &shape() const
TensorFormat format() const
SymbolVar operator+(const SymbolVar &rhs) const
SymbolVar operator-(const SymbolVar &rhs) const
SymbolVar operator*(const SymbolVar &rhs) const
SymbolVar operator/(const SymbolVar &rhs) const
SymbolVar operator<(const SymbolVar &rhs) const
SymbolVar operator<=(const SymbolVar &rhs) const
SymbolVar operator>(const SymbolVar &rhs) const
SymbolVar operator-() const
template<typename ctype>
ctype_enable_if<ctype, SymbolVar>::type operator+(ctype v) const
template<typename ctype>
ctype_enable_if<ctype, SymbolVar>::type operator-(ctype v) const
template<typename ctype>
ctype_enable_if<ctype, SymbolVar>::type operator*(ctype v) const
template<typename ctype>
ctype_enable_if<ctype, SymbolVar>::type operator/(ctype v) const
template<typename ctype>
ctype_enable_if<ctype, SymbolVar>::type operator>(ctype v) const
template<typename ctype>
ctype_enable_if<ctype, SymbolVar>::type operator<(ctype v) const
template<typename ctype>
ctype_enable_if<ctype, SymbolVar>::type operator<=(ctype v) const
template<typename ctype>
ctype_enable_if<ctype, SymbolVar>::type fill_retain_dtype(ctype val) const

fill the tensor with a constant value, but retaining the dtype

SymbolVar make_scalar(DTypeScalar value) const

make a const scalar value using computing graph and comp node provided by this var

template<typename ctype>
ctype_enable_if<ctype, SymbolVar>::type make_scalar_dt(ctype val) const

make a scalar with given value and dtype of this symvar

const DeviceTensorND &eager_eval_get_value() const

get value in eager evaluation mode

This essentially synchronizes the dispatch queue and then call dev_tensor()

bool allow_shape_change() const

Public Static Functions

SymbolVar make_scalar(DTypeScalar value, ComputingGraph &cg, CompNode cn)

make a const scalar value on given computing graph and computing node