This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@parakeet.jit | |
def count_thresh(values, thresh): | |
n = 0 | |
for elt in values: | |
n += elt < thresh | |
return n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
count_thresh: | |
;; %entry | |
movq 8(%rdi), %rax | |
movq (%rax), %r8 | |
xorl %eax, %eax | |
testq %r8, %r8 | |
jle .LBB0_3 | |
;; %loop_body.preheader | |
movq 24(%rdi), %rax | |
movq (%rdi), %rdx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%ArrayT = type { double*, %PyCStructType*, %PyCStructType*, i64, i64 } | |
%PyCStructType = type { i64 } | |
define i64 @count_thresh(%ArrayT* nocapture %values.21, double %thresh.22) nounwind { | |
entry: | |
%shape_ptr = getelementptr %ArrayT* %values.21, i64 0, i32 1 | |
%shape_value = load %PyCStructType** %shape_ptr, align 8 | |
%data_ptr = getelementptr %ArrayT* %values.21, i64 0, i32 0 | |
%data_value = load double** %data_ptr, align 8 | |
%offset_ptr = getelementptr %ArrayT* %values.21, i64 0, i32 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def count_thresh(values :: array1(float64), thresh :: float64) => int64: | |
shape_tuple :: struct(int64) = values.shape | |
data :: ptr(float64) = values.data | |
base_offset :: int64 = values.offset | |
for i in range(0, shape_tuple.elt0, 1): | |
(header) | |
n_loop <- phi(0 :: int64, n2) | |
(body) | |
offset :: int64 = offset + i | |
elt :: float64 = data[offset] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def count_thresh(values :: array1(float64), thresh :: float64) => int64: | |
n :: int64 = 0 :: int64 | |
shape_tuple :: tuple(int64) = values.shape | |
for i in range(0, shape_tuple[0], 1): | |
(header) | |
n_loop <- phi(0 :: int64, n2) | |
(body) | |
elt :: float64 = values[i] | |
less_tmp :: bool = elt < thresh | |
n2 :: int64 = n_loop + cast<int64>(less_tmp) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def count_thresh(values, thresh): | |
n = 0 | |
for i in range(0, len(values), 1): | |
(header) | |
n_loop <- phi(n, n2) | |
(body) | |
elt = values[i] | |
n2 = n_loop + (elt < thresh) | |
return n_loop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0 LOAD_CONST 1 (0) | |
3 STORE_FAST 2 (n) | |
6 SETUP_LOOP 30 (to 39) | |
9 LOAD_FAST 0 (values) | |
12 GET_ITER | |
13 FOR_ITER 22 (to 38) | |
16 STORE_FAST 3 (elt) | |
19 LOAD_FAST 2 (n) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def count_thresh(values, thresh): | |
n = 0 | |
for elt in values: | |
n += elt < thresh | |
return n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FunctionDef( | |
name='count_thresh', | |
args=arguments(args=[Name(id='values'), Name(id='thresh')], | |
vararg=None, kwarg=None, defaults=[]), | |
body=[ | |
Assign(targets=[Name(id='n')], value=Num(n=0)), | |
For(target=Name(id='elt'), iter=Name(id='values'), body=[ | |
AugAssign(target=Name(id='n'), op=Add(), | |
value=Compare(left=Name(id='elt'), ops=[Lt()], | |
comparators=[Name(id='thresh')]))]), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Module(body=[ | |
FunctionDef(name='twice', | |
args=arguments(args=[Name(id='x', ctx=Param())], | |
vararg=None, kwarg=None, defaults=[]), | |
body=[ | |
Return(value= | |
BinOp( | |
left=Num(n=2), | |
op=Mult(), | |
right=Name(id='x', ctx=Load()))) |