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
pycodegen
pystencils
Commits
39483609
Commit
39483609
authored
2 months ago
by
Richard Angersbach
Browse files
Options
Downloads
Plain Diff
Merge remote-tracking branch 'origin/rangersbach/reductions' into rangersbach/reductions
parents
1580a2b0
c0df001f
No related branches found
No related tags found
1 merge request
!438
Reduction Support
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/pystencils/backend/ast/vector.py
+3
-4
3 additions, 4 deletions
src/pystencils/backend/ast/vector.py
src/pystencils/backend/reduction_op_mapping.py
+17
-24
17 additions, 24 deletions
src/pystencils/backend/reduction_op_mapping.py
with
20 additions
and
28 deletions
src/pystencils/backend/ast/vector.py
+
3
−
4
View file @
39483609
...
...
@@ -41,10 +41,9 @@ class PsVecBroadcast(PsUnOp, PsVectorOp):
class
PsVecHorizontal
(
PsBinOp
,
PsVectorOp
):
"""
Represents a binary operation between a scalar and a vector operand.
With the binary operation not being vectorized, a horizontal reduction
along the lanes of the vector operand is required to extract a scalar value.
The result type will be equal to the scalar operand.
"""
Perform a horizontal reduction across a vector onto a scalar base value.
**Example:** vec_horizontal_add(s, v)` will compute `s + v[0] + v[1] + ... + v[n-1]`.
Args:
scalar_operand: Scalar operand
...
...
This diff is collapsed.
Click to expand it.
src/pystencils/backend/reduction_op_mapping.py
+
17
−
24
View file @
39483609
...
...
@@ -12,27 +12,20 @@ _available_operator_interface: set[ReductionOp] = {
def
reduction_op_to_expr
(
op
:
ReductionOp
,
op1
,
op2
)
->
PsExpression
:
if
op
in
_available_operator_interface
:
match
op
:
case
ReductionOp
.
Add
:
return
PsAdd
(
op1
,
op2
)
case
ReductionOp
.
Sub
:
return
PsSub
(
op1
,
op2
)
case
ReductionOp
.
Mul
:
return
PsMul
(
op1
,
op2
)
case
ReductionOp
.
Div
:
return
PsDiv
(
op1
,
op2
)
case
_
:
raise
FreezeError
(
f
"
Found unsupported operation type for reduction assignments:
{
op
}
.
"
)
else
:
match
op
:
case
ReductionOp
.
Min
:
return
PsCall
(
PsMathFunction
(
MathFunctions
.
Min
),
[
op1
,
op2
])
case
ReductionOp
.
Max
:
return
PsCall
(
PsMathFunction
(
MathFunctions
.
Max
),
[
op1
,
op2
])
case
_
:
raise
FreezeError
(
f
"
Found unsupported operation type for reduction assignments:
{
op
}
.
"
)
match
op
:
case
ReductionOp
.
Add
:
return
PsAdd
(
op1
,
op2
)
case
ReductionOp
.
Sub
:
return
PsSub
(
op1
,
op2
)
case
ReductionOp
.
Mul
:
return
PsMul
(
op1
,
op2
)
case
ReductionOp
.
Div
:
return
PsDiv
(
op1
,
op2
)
case
ReductionOp
.
Min
:
return
PsCall
(
PsMathFunction
(
MathFunctions
.
Min
),
[
op1
,
op2
])
case
ReductionOp
.
Max
:
return
PsCall
(
PsMathFunction
(
MathFunctions
.
Max
),
[
op1
,
op2
])
case
_
:
raise
FreezeError
(
f
"
Found unsupported operation type for reduction assignments:
{
op
}
.
"
)
This diff is collapsed.
Click to expand it.
Frederik Hennig
@da15siwa
mentioned in commit
4e688b86
·
2 months ago
mentioned in commit
4e688b86
mentioned in commit 4e688b867339c90a6fba3ad12c383d1e59211ed9
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