Skip to content
This repository was archived by the owner on Jun 14, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
ae724eb
Adds builtins for BDF/NDF use in Leap
cmikida2 May 5, 2021
ce489e9
Silence pylint
cmikida2 May 11, 2021
562b2b5
Removes no longer needed (and problematic) reshape and cumulative
cmikida2 May 12, 2021
bdfb911
Merge branch 'main' into bdf-builtins
cmikida2 May 12, 2021
7319dea
Aggressively work-in-progress Fortran UserTypeArray support
cmikida2 May 26, 2021
7fef308
Fix bad quotes
cmikida2 May 26, 2021
fea9e9f
To get existing tests to pass
cmikida2 May 26, 2021
2d867cc
Merge branch 'main' into bdf-builtins
cmikida2 May 26, 2021
50d4350
Introduce better naming for UserTypeArrays, allowing for derived types
cmikida2 May 27, 2021
3788386
Continue fixing garbage naming conventions
cmikida2 May 27, 2021
ca8daee
Fix whoopsie identified by pylint
cmikida2 May 27, 2021
59758c3
Fix issue with UserTypeArray identifier inheritance
cmikida2 May 27, 2021
e4035e4
Merge branch 'main' into bdf-builtins
cmikida2 May 28, 2021
d7ffb53
Restructure builtin_array_utype to perform element allocation outside of
cmikida2 May 28, 2021
38abcaf
Fixes some bugs/patches some holes identified by a new dagrt-side test
cmikida2 May 28, 2021
a58c7c2
Scrubs PR of any builtins not directly pertaining to addition of
cmikida2 May 28, 2021
04ca336
Failure to remove leftover doc stuff
cmikida2 May 28, 2021
e31e67a
Merge branch 'main' into bdf-builtins
cmikida2 May 28, 2021
27d96ea
Handling UserTypeArray assignments more robustly, deferring deinit to
cmikida2 Jun 10, 2021
a5ef622
Actually use refcounts instead of casually ignoring them in
cmikida2 Jun 10, 2021
c70367f
Initial foray into cutting down on duplicate/messy code, in part by
cmikida2 Jun 10, 2021
2f926ae
Move UserTypeArray assignments to supporting function, a la UserType
cmikida2 Jun 10, 2021
2f013f1
Merge branch 'main' into bdf-builtins
cmikida2 Jun 10, 2021
5a666d0
Add support for .ne. comparisons in Fortran
cmikida2 Jun 11, 2021
cd79c87
Move end-of-loop deinits out of loops
cmikida2 Jun 16, 2021
4f0887d
Get rid of UserTypeArray hard dealloc
cmikida2 Jun 16, 2021
2e5f48d
Merge branch 'main' into bdf-builtins
cmikida2 Jun 23, 2021
3b7b736
Merge branch 'main' into bdf-builtins
cmikida2 Aug 31, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions dagrt/builtins_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@ def builtin_array(n):
return np.empty(n, dtype=np.float64)


def builtin_array_utype(n, x):
import numpy as np
if n != np.floor(n):
raise ValueError("array() argument n is not an integer")
n = int(n)

#return np.empty((n, x.size), dtype=x.dtype)
return np.zeros((n, x.size), dtype=x.dtype)


def builtin_matmul(a, b, a_cols, b_cols):
import numpy as np
if a_cols != np.floor(a_cols):
Expand Down Expand Up @@ -148,6 +158,7 @@ def builtin_print(arg):
"<builtin>dot_product": builtin_dot_product,
"<builtin>elementwise_abs": builtin_elementwise_abs,
"<builtin>array": builtin_array,
"<builtin>array_utype": builtin_array_utype,
"<builtin>matmul": builtin_matmul,
"<builtin>transpose": builtin_transpose,
"<builtin>linear_solve": builtin_linear_solve,
Expand Down
18 changes: 18 additions & 0 deletions dagrt/codegen/expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,24 @@ def map_logical_and(self, expr, enclosing_prec):
" .and. ", expr.children, PREC_LOGICAL_AND),
enclosing_prec, PREC_LOGICAL_AND)

_comparison_to_fortran = {
"==": ".eq.",
"!=": ".ne.",
"<": ".lt.",
">": ".gt.",
"<=": ".le.",
">=": ".ge.",
}

def map_comparison(self, expr, enclosing_prec, *args, **kwargs):
from pymbolic.mapper.stringifier import PREC_COMPARISON
return self.parenthesize_if_needed(
self.format("%s %s %s",
self.rec(expr.left, PREC_COMPARISON, *args, **kwargs),
self._comparison_to_fortran[expr.operator],
self.rec(expr.right, PREC_COMPARISON, *args, **kwargs)),
enclosing_prec, PREC_COMPARISON)

# }}}


Expand Down
Loading