make_node()
#
源码位置:src/node/reflection.cc
// API function to make node.
// args format:
// key1, value1, ..., key_n, value_n
void MakeNode(const TVMArgs& args, TVMRetValue* rv) {
std::string type_key = args[0];
std::string empty_str;
TVMArgs kwargs(args.values + 1, args.type_codes + 1, args.size() - 1);
*rv = ReflectionVTable::Global()->CreateObject(type_key, kwargs);
}
TVM_REGISTER_GLOBAL("node.MakeNode").set_body(MakeNode);
import set_env
from tvm.ir.attrs import make_node
make_node??
Signature: make_node(type_key, **kwargs)
Source:
def make_node(type_key, **kwargs):
"""Make a new IR node by its type key and fields
Parameters
----------
type_key : str
The type key of the node.
**kwargs : dict
The fields of the node.
Returns
-------
node : Node
The corresponding IR Node
Note
----
If the created node is instance of AttrsNode, then
the creator function will also run bound checks and
default value setup as supported by Attrs.
Example
-------
The following code constructs a IntImm object
.. code-block:: python
x = tvm.ir.make_node("IntImm", dtype="int32", value=10)
assert isinstance(x, tvm.tir.IntImm)
assert x.value == 10
"""
args = [type_key]
for k, v in kwargs.items():
args += [k, v]
return tvm.runtime._ffi_node_api.MakeNode(*args)
File: /media/pc/data/lxw/ai/tvm/python/tvm/ir/attrs.py
Type: function