Skip to content
This repository was archived by the owner on Feb 2, 2024. It is now read-only.

Commit 7e8af7d

Browse files
authored
DataFrame Sort in new style. part 1 (#358)
1 parent 259d6ec commit 7e8af7d

2 files changed

Lines changed: 18 additions & 7 deletions

File tree

sdc/datatypes/hpat_pandas_dataframe_pass.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ def run_pass(self, state):
6565
out_nodes = [inst]
6666

6767
if isinstance(inst, ir.Assign):
68-
self.state.func_ir._definitions[inst.target.name].remove(inst.value)
68+
if inst.value in self.state.func_ir._definitions[inst.target.name]:
69+
self.state.func_ir._definitions[inst.target.name].remove(inst.value)
6970
out_nodes = self._run_assign(inst)
7071

7172
if isinstance(out_nodes, list):

sdc/hiframes/dataframe_pass.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,18 @@ def __init__(self, state):
7676
self.state = state
7777

7878
def run_pass(self):
79+
"""
80+
The function could return exxeption. It means that the IR transformation can not be completed.
81+
This is acceptable behaviour.
82+
"""
83+
84+
try:
85+
self.run_pass_throw()
86+
return True
87+
except ValueError:
88+
return False
89+
90+
def run_pass_throw(self):
7991
blocks = self.state.func_ir.blocks
8092
# topo_order necessary so DataFrame data replacement optimization can
8193
# be performed in one pass
@@ -109,8 +121,7 @@ def run_pass(self):
109121
# TODO: add this to dead_branch_prune pass
110122
for inst in self.state.func_ir.blocks[dead_label].body:
111123
if is_assign(inst):
112-
self.state.func_ir._definitions[inst.target.name].remove(
113-
inst.value)
124+
self.state.func_ir._definitions[inst.target.name].remove(inst.value)
114125

115126
del self.state.func_ir.blocks[dead_label]
116127
else:
@@ -124,9 +135,7 @@ def run_pass(self):
124135
used_vars = set()
125136
new_body = []
126137
for inst in reversed(block.body):
127-
if (is_assign(inst)
128-
and inst.target.name not in used_vars
129-
and inst.target.name in jmp_defs):
138+
if (is_assign(inst) and inst.target.name not in used_vars and inst.target.name in jmp_defs):
130139
self.state.func_ir._definitions[inst.target.name].remove(inst.value)
131140
continue
132141
used_vars.update(v.name for v in inst.list_vars())
@@ -140,7 +149,8 @@ def run_pass(self):
140149
out_nodes = [inst]
141150

142151
if isinstance(inst, ir.Assign):
143-
self.state.func_ir._definitions[inst.target.name].remove(inst.value)
152+
if inst.value in self.state.func_ir._definitions[inst.target.name]:
153+
self.state.func_ir._definitions[inst.target.name].remove(inst.value)
144154
out_nodes = self._run_assign(inst)
145155
elif isinstance(inst, (ir.SetItem, ir.StaticSetItem)):
146156
out_nodes = self._run_setitem(inst)

0 commit comments

Comments
 (0)