Commit 1feabb0d by Eric Junyuan Xie Committed by Tianqi Chen

create symbol from nodeattr (#116)

parent 61df4ec5
...@@ -193,6 +193,12 @@ class Symbol { ...@@ -193,6 +193,12 @@ class Symbol {
static Symbol CreateFunctor(const Op* op, static Symbol CreateFunctor(const Op* op,
std::unordered_map<std::string, std::string> attrs); std::unordered_map<std::string, std::string> attrs);
/*! /*!
* \brief Create symbolic functor(AtomicSymbol) by given node attributes.
* \param attrs pre-initialized Node attributes.
* \return Symbol that can be used to call compose further.
*/
static Symbol CreateFunctor(const NodeAttrs& attrs);
/*!
* \brief Create symbol node representing variable. * \brief Create symbol node representing variable.
* \param name Name of the variable. * \param name Name of the variable.
* \return The symbol. * \return The symbol.
......
...@@ -527,6 +527,22 @@ Symbol Symbol::CreateFunctor(const Op* op, ...@@ -527,6 +527,22 @@ Symbol Symbol::CreateFunctor(const Op* op,
return s; return s;
} }
Symbol Symbol::CreateFunctor(const NodeAttrs& attrs) {
static auto& fnum_vis_output = Op::GetAttr<FNumVisibleOutputs>("FNumVisibleOutputs");
Symbol s;
NodePtr n = Node::Create();
n->attrs = attrs;
uint32_t nout = n->num_outputs();
if (fnum_vis_output.count(n->op())) {
nout = fnum_vis_output[n->op()](n->attrs);
}
for (uint32_t i = 0; i < nout; ++i) {
s.outputs.emplace_back(NodeEntry{n, i, 0});
}
return s;
}
Symbol Symbol::CreateGroup(const std::vector<Symbol> &symbols) { Symbol Symbol::CreateGroup(const std::vector<Symbol> &symbols) {
Symbol ret; Symbol ret;
for (const auto &s : symbols) { for (const auto &s : symbols) {
......
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