9 #include <unordered_map> 11 #include "teq/ileaf.hpp" 12 #include "teq/functor.hpp" 20 using LabelsMapT = std::unordered_map<teq::iTensor*,std::string>;
26 [](
teq::iTensor*& root) -> std::vector<
teq::iTensor*>
30 auto& children = f->get_children();
31 std::vector<teq::iTensor*> tens(children.size());
32 std::transform(children.begin(), children.end(), tens.begin(),
35 return child.get_tensor().get();
45 auto it = this->
labels_.find(root);
48 out << it->second <<
"=";
50 if (
auto var = dynamic_cast<teq::iLeaf*>(root))
52 out << (var->is_const() ?
"constant:" :
"variable:");
54 out << root->to_string();
57 out << root->shape().to_string();
void print(std::ostream &out, const teq::TensptrT &ptr)
Stream equation of ptr to out.
Definition: teq.hpp:63
PrettyEquation(void)
Definition: teq.hpp:25
LabelsMapT labels_
For every label associated with a tensor, show LABEL=value in the tree.
Definition: teq.hpp:75
Interface of iOperation-defined operation node.
Definition: ifunctor.hpp:28
PrettyTree< teq::iTensor * > drawer_
Actual ascii renderer.
Definition: teq.hpp:82
Coordinate mapper and tensor pair.
Definition: funcarg.hpp:21
void print(std::ostream &out, T root)
Definition: tree.hpp:33
bool showshape_
Print every tensor's shape if true, otherwise don't.
Definition: teq.hpp:78
std::unordered_map< teq::iTensor *, std::string > LabelsMapT
Map tensor to label.
Definition: teq.hpp:20
std::shared_ptr< iTensor > TensptrT
Tensor smart pointer.
Definition: itensor.hpp:51
Use PrettyTree to render teq::TensptrT graph as an ascii art.
Definition: teq.hpp:23
Interface of traversible and differentiable nodes with shape information.
Definition: itensor.hpp:36
void print(std::ostream &out, teq::iTensor *ptr)
Stream equation of raw ptr to out.
Definition: teq.hpp:69