9 #include <unordered_map> 10 #include <unordered_set> 13 #include "teq/ileaf.hpp" 16 #include "estd/estd.hpp" 20 #ifndef DBG_TEQ_CSV_HPP 21 #define DBG_TEQ_CSV_HPP 30 while ((i = multiline.find(nline, i)) != std::string::npos)
32 multiline.replace(i, 1,
"\\");
45 using GetTypeF = std::function<NODE_TYPE(teq::iFunctor*)>;
57 if (estd::has(
nodes_, leaf))
65 label = it->second +
"=";
82 if (estd::has(
nodes_, func))
90 funcstr = it->second +
"=";
103 for (
size_t i = 0, n = children.size(); i < n; ++i)
114 std::string coordstr = coorder->to_string();
131 size_t nnodes =
nodes_.size();
132 for (
size_t i = 0, nedges =
edges_.size(); i < nedges; ++i)
137 std::string color = child_node.ntype_ ==
CACHED_FUNC ?
142 << parent_node.label_ <<
',' 144 << child_node.label_ <<
',' 151 << parent_node.label_ <<
',' 160 << child_node.label_ <<
',' 196 std::unordered_map<teq::iTensor*,Node>
nodes_;
198 std::unordered_map<teq::iCoordMap*,std::string>
coorders_;
203 #endif // DBG_TEQ_CSV_HPP std::vector< Edge > edges_
Definition: teq_csv.hpp:194
const char label_delim
CSV delimiter.
Definition: teq_csv.hpp:24
size_t id_
Definition: teq_csv.hpp:191
std::string to_string(void) const
Return string representation of shape.
Definition: shape.hpp:148
virtual const ArgsT & get_children(void) const =0
Return children nodes as a vector of raw pointers.
std::unordered_map< teq::iCoordMap *, std::string > coorders_
Definition: teq_csv.hpp:198
Interface of iOperation-defined operation node.
Definition: ifunctor.hpp:28
bool showshape_
Print every tensor's shape if true, otherwise don't.
Definition: teq_csv.hpp:168
LabelsMapT labels_
For every label associated with a tensor, show LABEL=value in the tree.
Definition: teq_csv.hpp:171
NODE_TYPE ntype_
Definition: teq_csv.hpp:189
Definition: teq_csv.hpp:41
TensptrT get_tensor(void) const
Return tensor being mapped.
Definition: funcarg.hpp:61
NODE_TYPE
Type of the tensors.
Definition: teq_csv.hpp:37
Interface for transforming coordinates and reversing the coordinate.
Definition: coord.hpp:20
CoordptrT get_coorder(void) const
Return coord map for coordinates.
Definition: funcarg.hpp:80
Coordinate mapper and tensor pair.
Definition: funcarg.hpp:21
void visit(teq::iFunctor *func) override
Implementation of iTraveler.
Definition: teq_csv.hpp:80
teq::iFunctor * func_
Definition: teq_csv.hpp:176
Definition: teq_csv.hpp:39
Interface to travel through graph, treating iLeaf and iFunctor differently.
Definition: itensor.hpp:24
GetTypeF get_ftype_
Definition: teq_csv.hpp:200
teq::iCoordMap * coorder_
Definition: teq_csv.hpp:180
void to_stream(std::ostream &out)
Stream visited graphs to out.
Definition: teq_csv.hpp:129
std::unordered_map< teq::iTensor *, Node > nodes_
Definition: teq_csv.hpp:196
std::unordered_map< teq::iTensor *, std::string > LabelsMapT
Map tensor to label.
Definition: teq.hpp:20
void visit(teq::iLeaf *leaf) override
Implementation of iTraveler.
Definition: teq_csv.hpp:55
std::string to_string(teq::CoordptrT c)
Return brief hashable string representation of coordinate mapper.
teq::iTensor * child_
Definition: teq_csv.hpp:178
Definition: teq_csv.hpp:40
std::string edge_label_
Definition: teq_csv.hpp:182
std::function< NODE_TYPE(teq::iFunctor *)> GetTypeF
Function that identify functors by NODE_TYPE.
Definition: teq_csv.hpp:45
virtual std::string to_string(void) const =0
Return the string representation of the tensor.
Use CSVEquation to render teq::TensptrT graph to output csv edges.
Definition: teq_csv.hpp:48
CSVEquation(GetTypeF get_ftype=[](teq::iFunctor *func) { return FUNCTOR;})
Definition: teq_csv.hpp:50
Interface of traversible and differentiable nodes with shape information.
Definition: itensor.hpp:36
std::string label_
Definition: teq_csv.hpp:187
Definition: teq_csv.hpp:185
static void multiline_replace(std::string &multiline)
Definition: teq_csv.hpp:26
Definition: teq_csv.hpp:174
Leaf of the graph commonly representing the variable in an equation.
Definition: ileaf.hpp:19
bool is_identity(iCoordMap *coorder)
Checks if the coord mapper is an identity mapper.
virtual const Shape & shape(void) const =0
Return the shape held by this tensor.