Skip to content

Commit

Permalink
Merge pull request #2 from virendrakabra14/list_reverse_tmp
Browse files Browse the repository at this point in the history
merge `main` into `list_reverse`
  • Loading branch information
kabra1110 authored May 14, 2023
2 parents 6a147a1 + 04e544b commit dbe9d91
Show file tree
Hide file tree
Showing 577 changed files with 12,204 additions and 2,949 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,9 @@ jobs:
- name: PIP install required packages
shell: bash -l {0}
run: |
python -m pip install lpynn numpy
# Package lpynn has lpython_emulation as dependency
# Hence, it should by default install lpython_emulation
python -m pip install lpython_emulation==0.0.1.8 lpynn==0.0.1.3 numpy==1.24.3
- name: PIP show installed packages
shell: bash -l {0}
Expand All @@ -235,7 +237,6 @@ jobs:
- name: Test PIP Packages with Python
shell: bash -l {0}
run: |
export PYTHONPATH=./src/runtime/lpython
python integration_tests/test_pip_import_01.py
- name: Test PIP Packages with LPython
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ inst/bin/*
*_ldd.txt
*_lines.dat.txt
*__tmp__generated__.c
visualize*.html
lpython_decorator*/
a.c
a.h
a.py

### https://raw.github.com/github/gitignore/218a941be92679ce67d0484547e3e142b2f5f6f0/Global/macOS.gitignore

Expand Down
20 changes: 19 additions & 1 deletion integration_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,8 @@ RUN(NAME variable_decl_02 LABELS cpython llvm c)
RUN(NAME variable_decl_03 LABELS cpython llvm c)
RUN(NAME array_expr_01 LABELS cpython llvm c)
RUN(NAME array_expr_02 LABELS cpython llvm c)
RUN(NAME array_size_01 LABELS cpython llvm c)
RUN(NAME array_size_02 LABELS cpython llvm c)
RUN(NAME array_01 LABELS cpython llvm wasm c)
RUN(NAME array_02 LABELS cpython wasm c)
RUN(NAME bindc_01 LABELS cpython llvm c)
Expand Down Expand Up @@ -326,15 +328,22 @@ RUN(NAME expr_13 LABELS llvm c
EXTRAFILES expr_13b.c)
RUN(NAME expr_14 LABELS cpython llvm c)
RUN(NAME expr_15 LABELS cpython llvm c)

RUN(NAME expr_01u LABELS cpython llvm c)
RUN(NAME expr_02u LABELS cpython llvm c)
RUN(NAME expr_03u LABELS cpython llvm c)

RUN(NAME loop_01 LABELS cpython llvm c)
RUN(NAME loop_02 LABELS cpython llvm c wasm wasm_x86 wasm_x64)
RUN(NAME loop_03 LABELS cpython llvm c wasm wasm_x64)
RUN(NAME loop_04 LABELS cpython llvm c)
RUN(NAME loop_05 LABELS cpython llvm c)
RUN(NAME if_01 LABELS cpython llvm c wasm wasm_x86 wasm_x64)
RUN(NAME if_02 LABELS cpython llvm c wasm wasm_x86 wasm_x64)
RUN(NAME if_03 FAIL LABELS cpython llvm c)
RUN(NAME print_02 LABELS cpython llvm c)
RUN(NAME test_types_01 LABELS cpython llvm c)
RUN(NAME test_types_02 LABELS cpython llvm c wasm)
RUN(NAME test_str_01 LABELS cpython llvm c)
RUN(NAME test_str_02 LABELS cpython llvm c)
RUN(NAME test_str_03 LABELS cpython llvm c)
Expand Down Expand Up @@ -366,6 +375,7 @@ RUN(NAME test_dict_08 LABELS cpython llvm c)
RUN(NAME test_dict_09 LABELS cpython llvm c)
RUN(NAME test_dict_10 LABELS cpython llvm) # TODO: Add support of dict with string in C backend
RUN(NAME test_dict_11 LABELS cpython llvm c)
RUN(NAME test_dict_bool LABELS cpython llvm)
RUN(NAME test_for_loop LABELS cpython llvm c)
RUN(NAME modules_01 LABELS cpython llvm c wasm wasm_x86 wasm_x64)
RUN(NAME modules_02 LABELS cpython llvm c wasm wasm_x86 wasm_x64)
Expand Down Expand Up @@ -477,6 +487,8 @@ RUN(NAME enum_04 LABELS cpython llvm c)
RUN(NAME enum_05 LABELS llvm c
EXTRAFILES enum_05b.c)
RUN(NAME enum_06 LABELS cpython llvm c)
RUN(NAME enum_07 IMPORT_PATH ..
LABELS cpython llvm c)
RUN(NAME union_01 LABELS cpython llvm c)
RUN(NAME union_02 LABELS llvm c)
RUN(NAME union_03 LABELS cpython llvm c)
Expand All @@ -489,10 +501,13 @@ RUN(NAME vec_01 LABELS cpython llvm c)
RUN(NAME test_str_comparison LABELS cpython llvm c)
RUN(NAME test_bit_length LABELS cpython llvm c)
RUN(NAME str_to_list_cast LABELS cpython llvm c)
RUN(NAME test_sys_01 LABELS cpython llvm c)


RUN(NAME test_package_01 LABELS cpython llvm)
RUN(NAME test_pkg_lpdraw LABELS cpython llvm wasm)
RUN(NAME test_pkg_lnn LABELS cpython llvm)
RUN(NAME test_pkg_lnn_01 LABELS cpython llvm)
RUN(NAME test_pkg_lnn_02 LABELS cpython llvm)

RUN(NAME generics_01 LABELS cpython llvm c)
RUN(NAME generics_02 LABELS cpython llvm c)
Expand Down Expand Up @@ -532,4 +547,7 @@ RUN(NAME callback_01 LABELS cpython llvm)
# Intrinsic Functions
RUN(NAME intrinsics_01 LABELS cpython llvm) # any

# lpython decorator
RUN(NAME lpython_decorator_01 LABELS cpython)

COMPILE(NAME import_order_01 LABELS cpython llvm c) # any
23 changes: 23 additions & 0 deletions integration_tests/array_size_01.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from lpython import i32, f64, c32, c64
from numpy import empty

def main0():
x: i32[4, 5, 2] = empty([4, 5, 2])
y: f64[24, 100, 2, 5] = empty([24, 100, 2, 5])
print(x.size)
print(y.size)

assert x.size == 40
assert y.size == 24000

def main1():
a: c32[12] = empty([12])
b: c64[15, 15, 10] = empty([15, 15, 10])
print(a.size)
print(b.size)

assert a.size == 12
assert b.size == 2250

main0()
main1()
90 changes: 90 additions & 0 deletions integration_tests/array_size_02.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
from lpython import i32, f64, c32, c64, u32
from numpy import empty, size

def main0():
x: i32[4, 5, 2] = empty([4, 5, 2])
y: f64[24, 100, 2, 5] = empty([24, 100, 2, 5])
z: i32
w: i32
z = 2
w = 3
print(size(x))
print(size(x, 0))
print(size(x, 1))
print(size(x, 2))
print(size(y))
print(size(y, 0))
print(size(y, 1))
print(size(y, z))
print(size(y, w))

assert size(x) == 40
assert size(x, 0) == 4
assert size(x, 1) == 5
assert size(x, 2) == 2
assert size(y) == 24000
assert size(y, 0) == 24
assert size(y, 1) == 100
assert size(y, z) == 2
assert size(y, w) == 5

def main1():
a: c32[12] = empty([12])
b: c64[15, 15, 10] = empty([15, 15, 10])
c: i32
d: i32
c = 1
d = 2
print(size(a))
print(size(a, 0))
print(size(b))
print(size(b, 0))
print(size(b, c))
print(size(b, d))

assert size(a) == 12
assert size(a, 0) == 12
assert size(b) == 2250
assert size(b, 0) == 15
assert size(b, c) == 15
assert size(b, d) == 10

def main2():
a: i32[2, 3] = empty([2, 3])
print(size(a))
print(size(a, 0))
print(size(a, 1))

assert size(a) == 2*3
assert size(a, 0) == 2
assert size(a, 1) == 3

def main3():
a: u32[2, 3, 4] = empty([2, 3, 4])
b: u64[10, 5] = empty([10, 5])
c: i32
d: i32
c = 1
d = 2
print(size(a))
print(size(a, 0))
print(size(a, c))
print(size(a, d))

print(size(b))
print(size(b, 0))
print(size(b, c))

assert size(a) == 2*3*4
assert size(a, 0) == 2
assert size(a, c) == 3
assert size(a, d) == 4

assert size(b) == 50
assert size(b, 0) == 10
assert size(b, c) == 5

main0()
main1()
main2()
main3()
2 changes: 1 addition & 1 deletion integration_tests/bindc_03.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def h(q_void: CPtr) -> None:
def run():
a: CPtr
array_wrapped: ArrayWrapped = ArrayWrapped(a)
array_wrapped1: ArrayWrapped
array_wrapped1: ArrayWrapped = ArrayWrapped()
size: i32
size = 10
a = get_array(size)
Expand Down
4 changes: 2 additions & 2 deletions integration_tests/elemental_03.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def elemental_sqrt64():
shape[0] = 4096
observed = reshape(sqrt(array), shape)
for l in range(4096):
i = i32(int(l/256))
i = i32(l/256)
j = (l - i*256)//16
k = (l - i*256 - j*16)
assert abs(observed[l]**2.0 - f64(i + j + k)) <= eps
Expand All @@ -42,7 +42,7 @@ def elemental_sqrt32():
shape[0] = 256
observed = reshape(sqrt(array), shape)
for l in range(256):
i = i32(int(l/16))
i = i32(l/16)
j = (l - i*16)
assert abs(observed[l]**f32(2.0) - f32(i + j)) <= eps

Expand Down
2 changes: 1 addition & 1 deletion integration_tests/elemental_04.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def verify(observed: f32[:], base: i32, eps: f32):
j: i32

for k in range(100):
i = i32(int(k/10))
i = i32(k/10)
j = (k - i*10)
assert abs(f32(base)**(observed[k]) - f32(i + j + 1)) <= eps

Expand Down
7 changes: 7 additions & 0 deletions integration_tests/enum_07.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from enum_07_module import Constants

def check():
assert Constants.NUM_ELEMS.value == 4
assert Constants.NUM_CHECK.value == 51

check()
6 changes: 6 additions & 0 deletions integration_tests/enum_07_module.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from enum import Enum
from lpython import i32

class Constants(Enum):
NUM_ELEMS: i32 = 4
NUM_CHECK: i32 = 51
28 changes: 28 additions & 0 deletions integration_tests/expr_01u.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from lpython import inline, u32

@inline
def uadd(x: u32, y: u32) -> u32:
return x + y

@inline
def uand_op(x: u32, y: u32) -> u32:
return x & y

def main1():
x: u32
y: u32
z: u32
x = (u32(2)+u32(3))*u32(5)
y = uadd(x, u32(2))*u32(2)
assert x == u32(25)
assert y == u32(54)

z = uand_op(x, y)
assert z == u32(16)


main1()

# Not implemented yet in LPython:
#if __name__ == "__main__":
# main()
78 changes: 78 additions & 0 deletions integration_tests/expr_02u.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
from lpython import u8, u16, u32, u64

def add_u8(x: u8, y: u8) -> u8:
return x + y

def add_u16(x: u16, y: u16) -> u16:
return x + y

def add_u32(x: u32, y: u32) -> u32:
return x + y

def add_u64(x: u64, y: u64) -> u64:
return x + y

def and_u8(x: u8, y: u8) -> u8:
return x & y

def and_u16(x: u16, y: u16) -> u16:
return x & y

def and_u32(x: u32, y: u32) -> u32:
return x & y

def and_u64(x: u64, y: u64) -> u64:
return x & y

def main_u8():
x: u8
y: u8
z: u8
x = (u8(2)+u8(3))*u8(5)
y = add_u8(x, u8(2))*u8(2)
z = and_u8(x, y)
assert x == u8(25)
assert y == u8(54)
assert z == u8(16)

def main_u16():
x: u16
y: u16
z: u16
x = (u16(2)+u16(3))*u16(5)
y = add_u16(x, u16(2))*u16(2)
z = and_u16(x, y)
assert x == u16(25)
assert y == u16(54)
assert z == u16(16)

def main_u32():
x: u32
y: u32
z: u32
x = (u32(2)+u32(3))*u32(5)
y = add_u32(x, u32(2))*u32(2)
z = and_u32(x, y)
assert x == u32(25)
assert y == u32(54)
assert z == u32(16)

def main_u64():
x: u64
y: u64
z: u64
x = (u64(2)+u64(3))*u64(5)
y = add_u64(x, u64(2))*u64(2)
z = and_u64(x, y)
assert x == u64(25)
assert y == u64(54)
assert z == u64(16)

main_u8()
main_u16()
main_u32()
main_u64()

# Not implemented yet in LPython:
#if __name__ == "__main__":
# main()
Loading

0 comments on commit dbe9d91

Please sign in to comment.