Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pystencils
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
Model registry
Operate
Environments
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
Stephan Seitz
pystencils
Commits
69c29833
Commit
69c29833
authored
5 years ago
by
Stephan Seitz
Browse files
Options
Downloads
Patches
Plain Diff
Add option to use `auto` in `SympyAssignment`s
parent
0b8e7e88
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pystencils/astnodes.py
+2
-1
2 additions, 1 deletion
pystencils/astnodes.py
pystencils/backends/cbackend.py
+9
-4
9 additions, 4 deletions
pystencils/backends/cbackend.py
with
11 additions
and
5 deletions
pystencils/astnodes.py
+
2
−
1
View file @
69c29833
...
...
@@ -518,12 +518,13 @@ class LoopOverCoordinate(Node):
class
SympyAssignment
(
Node
):
def
__init__
(
self
,
lhs_symbol
,
rhs_expr
,
is_const
=
True
):
def
__init__
(
self
,
lhs_symbol
,
rhs_expr
,
is_const
=
True
,
use_auto
=
True
):
super
(
SympyAssignment
,
self
).
__init__
(
parent
=
None
)
self
.
_lhs_symbol
=
lhs_symbol
self
.
rhs
=
sp
.
sympify
(
rhs_expr
)
self
.
_is_const
=
is_const
self
.
_is_declaration
=
self
.
__is_declaration
()
self
.
use_auto
=
use_auto
def
__is_declaration
(
self
):
if
isinstance
(
self
.
_lhs_symbol
,
cast_func
):
...
...
This diff is collapsed.
Click to expand it.
pystencils/backends/cbackend.py
+
9
−
4
View file @
69c29833
...
...
@@ -5,6 +5,7 @@ import numpy as np
import
sympy
as
sp
from
sympy.core
import
S
from
sympy.printing.ccode
import
C89CodePrinter
from
pystencils.astnodes
import
KernelFunction
,
Node
from
pystencils.cpu.vectorization
import
vec_all
,
vec_any
from
pystencils.data_types
import
(
...
...
@@ -229,11 +230,15 @@ class CBackend:
def
_print_SympyAssignment
(
self
,
node
):
if
node
.
is_declaration
:
if
node
.
is_const
:
prefix
=
'
const
'
if
node
.
use_auto
:
data_type
=
'
auto
'
else
:
prefix
=
''
data_type
=
prefix
+
self
.
_print
(
node
.
lhs
.
dtype
).
replace
(
'
const
'
,
''
)
+
"
"
if
node
.
is_const
:
prefix
=
'
const
'
else
:
prefix
=
''
data_type
=
prefix
+
self
.
_print
(
node
.
lhs
.
dtype
).
replace
(
'
const
'
,
''
)
+
"
"
return
"
%s%s = %s;
"
%
(
data_type
,
self
.
sympy_printer
.
doprint
(
node
.
lhs
),
self
.
sympy_printer
.
doprint
(
node
.
rhs
))
...
...
This diff is collapsed.
Click to expand it.
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