Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

werkwek

  • Loading branch information...
commit b56ec9853d7fb7b9af137ecc57576e914a26004d 1 parent 89419d5
@iskandr authored
View
5 parakeet/inline.py
@@ -128,7 +128,10 @@ def transform_Call(self, expr):
target = self.transform_expr(expr.fn)
closure_args = self.closure_elts(target)
target = self.get_fn(target)
- if target.__class__ is TypedFn and can_inline(target):
+ if target.__class__ is TypedFn:
+ if not can_inline(target):
+ print "[Warning] Can't inline %s" % target
+ return expr
self.count += 1
curr_block = self.blocks.current()
combined_args = tuple(closure_args) + tuple(expr.args)
View
5 parakeet/lib_patchmap.py
@@ -25,13 +25,14 @@ def local_apply((i,j)):
ux = min(i+hx+1, n_rows)
ly = max(j-hy, 0)
uy = min(j+hy+1, n_cols)
- return f(x[lx:ux, ly:uy])
+ result = f(x[lx:ux, ly:uy])
else:
lx = i-hx
ux = i+hx+1
ly = j-hy
uy = j+hy+1
- return f(x[lx:ux, ly:uy])
+ result = f(x[lx:ux, ly:uy])
+ return result
return imap(local_apply, x.shape)
View
24 parakeet/simplify.py
@@ -264,14 +264,7 @@ def transform_arg(self, x, name = None):
return self.temp(self.transform_expr(x), name = name)
def transform_args(self, args):
- new_args = []
- for arg in args:
- new_arg = self.transform_expr(arg)
- if self.is_simple(new_arg):
- new_args.append(new_arg)
- else:
- new_args.append(self.temp(new_arg))
- return new_args
+ return [self.transform_arg(x) for x in args]
def transform_Array(self, expr):
expr.elts = tuple(self.transform_args(expr.elts))
@@ -547,18 +540,17 @@ def transform_While(self, stmt):
return stmt
def transform_ForLoop(self, stmt):
- stmt.start = self.transform_arg(stmt.start)
- stmt.stop = self.transform_arg(stmt.stop)
- if self.is_none(stmt.step):
- stmt.step = syntax_helpers.one(stmt.start.type)
- else:
- stmt.step = self.transform_arg(stmt.step)
- return stmt
- stmt.step = self.transform_expr(stmt.step)
stmt.body = self.transform_block(stmt.body)
stmt.merge = self.transform_merge(stmt.merge,
left_block = self.blocks.current(),
right_block = stmt.body)
+ stmt.start = self.transform_arg(stmt.start, 'start')
+ stmt.stop = self.transform_arg(stmt.stop, 'stop')
+ if self.is_none(stmt.step):
+ stmt.step = syntax_helpers.one(stmt.start.type)
+ else:
+ stmt.step = self.transform_arg(stmt.step, 'step')
+
# if a loop is only going to run for one iteration, might as well get rid of
# it
View
2  parakeet/syntax.py
@@ -652,7 +652,7 @@ def __repr__(self):
block_to_str(self.body))
def __str__(self):
- return "Fn(%s : %s => %s)" % (self.name, self.input_types, self.return_type)
+ return "TypedFn(%s : %s => %s)" % (self.name, self.input_types, self.return_type)
def __hash__(self):
return hash(self.name)
View
2  parakeet/type_inference.py
@@ -627,8 +627,6 @@ def transform_phi_nodes(self, nodes):
for old_k, (old_left, old_right) in nodes.iteritems():
new_name, (left, right) = self.transform_phi_node(old_k, (old_left, old_right))
new_nodes[new_name] = (left, right)
- assert left.type == right.type
-
return new_nodes
def annotate_lhs(self, lhs, rhs_type):
View
2  tests/test_patchmap.py
@@ -13,7 +13,7 @@ def test_erode_identity_shape():
def test_erode():
shape = (3,3)
- expected = np.array([[1, 1, 1,], [1,1,2]])
+ expected = np.array([[1, 1, 2], [1,1,2]])
testing_helpers.expect(erode, [x, shape], expected)
Please sign in to comment.
Something went wrong with that request. Please try again.