Skip to content

Commit

Permalink
[lang] Expose SNode ID to python (#2162)
Browse files Browse the repository at this point in the history
  • Loading branch information
k-ye committed Jan 17, 2021
1 parent 4e363f0 commit c728d38
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
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

0 comments on commit c728d38

Please sign in to comment.