Commit 2cb9b90c by Eric Junyuan Xie Committed by Tianqi Chen

Add list attr recursive (#89)

* Add list attr recursive

* fix
parent 4363d0fb
......@@ -12,6 +12,7 @@
#include <string>
#include <vector>
#include <tuple>
#include <utility>
#include "./base.h"
......@@ -169,6 +170,15 @@ class Symbol {
*/
std::unordered_map<std::string, std::string> ListAttrs(ListAttrOption option) const;
/*!
* \brief Get attribute dictionary from the symbol and all children.
*
* For grouped symbol, an error will be raised.
*
* \return The created attribute in format <operator_name, key, value>.
*/
std::vector<std::tuple<std::string, std::string, std::string> >
ListAttrsRecursive() const;
/*!
* \brief Create symbolic functor(AtomicSymbol) by given operator and attributes.
* \param op The operator.
* \param attrs The additional attributes.
......
......@@ -472,6 +472,17 @@ std::unordered_map<std::string, std::string> Symbol::ListAttrs(ListAttrOption op
}
}
std::vector<std::tuple<std::string, std::string, std::string> >
Symbol::ListAttrsRecursive() const {
std::vector<std::tuple<std::string, std::string, std::string> > ret;
DFSVisit(this->outputs, [&ret](const NodePtr& n) {
for (const auto& it : n->attrs.dict) {
ret.emplace_back(std::make_tuple(n->attrs.name, it.first, it.second));
}
});
return ret;
}
Symbol Symbol::CreateFunctor(const Op* op,
std::unordered_map<std::string, std::string> attrs) {
static auto& fnum_vis_output = Op::GetAttr<FNumVisibleOutputs>("FNumVisibleOutputs");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment