Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pystencils-sfg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pycodegen
pystencils-sfg
Commits
3cb194c5
Commit
3cb194c5
authored
9 months ago
by
Frederik Hennig
Browse files
Options
Downloads
Patches
Plain Diff
Deprecate map_param. Fix test suite
parent
f0d11ee2
No related branches found
No related tags found
No related merge requests found
Pipeline
#69677
passed
9 months ago
Stage: Code Quality
Stage: Tests
Stage: Documentation
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/pystencilssfg/composer/basic_composer.py
+32
-26
32 additions, 26 deletions
src/pystencilssfg/composer/basic_composer.py
src/pystencilssfg/lang/expressions.py
+4
-3
4 additions, 3 deletions
src/pystencilssfg/lang/expressions.py
with
36 additions
and
29 deletions
src/pystencilssfg/composer/basic_composer.py
+
32
−
26
View file @
3cb194c5
...
@@ -468,8 +468,14 @@ class SfgBasicComposer(SfgIComposer):
...
@@ -468,8 +468,14 @@ class SfgBasicComposer(SfgIComposer):
depends
:
VarLike
|
Sequence
[
VarLike
],
depends
:
VarLike
|
Sequence
[
VarLike
],
mapping
:
str
,
mapping
:
str
,
):
):
"""
Arbitrary parameter mapping: Add a single line of code to define a left-hand
from
warnings
import
warn
side object from one or multiple right-hand side dependencies.
"""
warn
(
"
The `map_param` method of `SfgBasicComposer` is deprecated and will be removed
"
"
in a future version. Use `sfg.set_param` instead.
"
,
FutureWarning
,
)
if
isinstance
(
depends
,
_VarLike
):
if
isinstance
(
depends
,
_VarLike
):
depends
=
[
depends
]
depends
=
[
depends
]
lhs_var
:
SfgVar
|
sp
.
Symbol
=
(
lhs_var
:
SfgVar
|
sp
.
Symbol
=
(
...
@@ -508,37 +514,37 @@ def make_sequence(*args: SequencerArg) -> SfgSequence:
...
@@ -508,37 +514,37 @@ def make_sequence(*args: SequencerArg) -> SfgSequence:
- Sub-ASTs and AST builders, which are often produced by the syntactic sugar and
- Sub-ASTs and AST builders, which are often produced by the syntactic sugar and
factory methods of `SfgComposer`.
factory methods of `SfgComposer`.
Its usage is best shown by e
xample:
:E
xample:
.. code-block:: Python
.. code-block:: Python
tree = make_sequence(
tree = make_sequence(
"
int a = 0;
"
,
"
int a = 0;
"
,
"
int b = 1;
"
,
"
int b = 1;
"
,
(
(
"
int tmp = b;
"
,
"
int tmp = b;
"
,
"
b = a;
"
,
"
b = a;
"
,
"
a = tmp;
"
"
a = tmp;
"
),
),
SfgKernelCall(kernel_handle)
SfgKernelCall(kernel_handle)
)
)
sfg.context.add_function(
"
myFunction
"
, tree)
sfg.context.add_function(
"
myFunction
"
, tree)
will translate to
will translate to
.. code-block:: C++
.. code-block:: C++
void myFunction() {
void myFunction() {
int a = 0;
int a = 0;
int b = 0;
int b = 0;
{
{
int tmp = b;
int tmp = b;
b = a;
b = a;
a = tmp;
a = tmp;
}
kernels::kernel( ... );
}
}
kernels::kernel( ... );
}
"""
"""
children
=
[]
children
=
[]
for
i
,
arg
in
enumerate
(
args
):
for
i
,
arg
in
enumerate
(
args
):
...
...
This diff is collapsed.
Click to expand it.
src/pystencilssfg/lang/expressions.py
+
4
−
3
View file @
3cb194c5
...
@@ -288,8 +288,9 @@ def asvar(var: VarLike) -> SfgVar:
...
@@ -288,8 +288,9 @@ def asvar(var: VarLike) -> SfgVar:
SfgVar: Variable cast as `SfgVar`.
SfgVar: Variable cast as `SfgVar`.
Raises:
Raises:
SfgException: If given a non-variable `AugExpr`, or a `TypedSymbol` with a `DynamicType`
ValueError: If given a non-variable `AugExpr`,
ValueError: If given any non-variable-like object.
a `TypedSymbol` with a `DynamicType`,
or any non-variable-like object.
"""
"""
match
var
:
match
var
:
case
SfgVar
():
case
SfgVar
():
...
@@ -300,7 +301,7 @@ def asvar(var: VarLike) -> SfgVar:
...
@@ -300,7 +301,7 @@ def asvar(var: VarLike) -> SfgVar:
from
pystencils
import
DynamicType
from
pystencils
import
DynamicType
if
isinstance
(
var
.
dtype
,
DynamicType
):
if
isinstance
(
var
.
dtype
,
DynamicType
):
raise
SfgException
(
raise
ValueError
(
f
"
Unable to cast dynamically typed symbol
{
var
}
to a variable.
\n
"
f
"
Unable to cast dynamically typed symbol
{
var
}
to a variable.
\n
"
f
"
{
var
}
has dynamic type
{
var
.
dtype
}
, which cannot be resolved to a type outside of a kernel.
"
f
"
{
var
}
has dynamic type
{
var
.
dtype
}
, which cannot be resolved to a type outside of a kernel.
"
)
)
...
...
This diff is collapsed.
Click to expand it.
Frederik Hennig
@da15siwa
mentioned in commit
cf2d5d53
·
9 months ago
mentioned in commit
cf2d5d53
mentioned in commit cf2d5d53451b87f6f049417877440fa61bafa0aa
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment