Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lang] Expose SNode ID to python #2162

Merged
merged 1 commit into from
Jan 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions python/taichi/lang/snode.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ def data_type(self):
def dim(self):
return len(self.shape)

@property
def id(self):
return self.ptr.id

@property
def shape(self):
impl.get_runtime().materialize()
Expand Down
3 changes: 3 additions & 0 deletions python/taichi/misc/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,9 @@ def print_async_stats(include_kernel_profiler=False):
print(f'Tasks launched: {int(counters["launched_tasks"])}')
print(f'Instructions emitted: {int(counters["codegen_statements"])}')
print(f'Tasks compiled: {int(counters["codegen_offloaded_tasks"])}')
NUM_FUSED_TASKS_KEY = 'num_fused_tasks'
if NUM_FUSED_TASKS_KEY in counters:
print(f'Tasks fused: {int(counters["num_fused_tasks"])}')
print('=======================')


Expand Down
1 change: 1 addition & 0 deletions taichi/program/state_flow_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,7 @@ std::unordered_set<int> StateFlowGraph::fuse_range(int begin, int end) {
auto *node_b = nodes[b];
TI_TRACE("Fuse: nodes[{}]({}) <- nodes[{}]({})", a, node_a->string(), b,
node_b->string());
stat.add("num_fused_tasks");
auto &rec_a = node_a->rec;
auto &rec_b = node_b->rec;
rec_a.ir_handle =
Expand Down
1 change: 1 addition & 0 deletions taichi/python/export_lang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ void export_lang(py::module &m) {
.def(py::init<>())
.def_readwrite("parent", &SNode::parent)
.def_readonly("type", &SNode::type)
.def_readonly("id", &SNode::id)
.def("dense",
(SNode & (SNode::*)(const std::vector<Index> &,
const std::vector<int> &))(&SNode::dense),
Expand Down