Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
loopy
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ben Sepanski
loopy
Commits
de1a9c4d
Commit
de1a9c4d
authored
10 years ago
by
Andreas Klöckner
Browse files
Options
Downloads
Patches
Plain Diff
Allow split_arg_axis to work without splitting inames
parent
1cf7bf97
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
loopy/padding.py
+32
-18
32 additions, 18 deletions
loopy/padding.py
with
32 additions
and
18 deletions
loopy/padding.py
+
32
−
18
View file @
de1a9c4d
...
...
@@ -41,7 +41,7 @@ class ArgAxisSplitHelper(ExpandingIdentityMapper):
return
ExpandingIdentityMapper
.
map_subscript
(
self
,
expr
,
expn_state
)
def
split_arg_axis
(
kernel
,
args_and_axes
,
count
):
def
split_arg_axis
(
kernel
,
args_and_axes
,
count
,
auto_split_inames
=
True
):
"""
:arg args_and_axes: a list of tuples *(arg, axis_nr)* indicating
that the index in *axis_nr* should be split. The tuples may
...
...
@@ -51,6 +51,10 @@ def split_arg_axis(kernel, args_and_axes, count):
If *args_and_axes* is a :class:`tuple`, it is automatically
wrapped in a list, to make single splits easier.
:arg count: The group size to use in the split.
:arg auto_split_inames: Whether to automatically split inames
encountered in the specified indices.
Note that splits on the corresponding inames are carried out implicitly.
The inames may *not* be split beforehand. (There
'
s no *really* good reason
for this--this routine is just not smart enough to deal with this.)
...
...
@@ -163,29 +167,39 @@ def split_arg_axis(kernel, args_and_axes, count):
idx
=
list
(
idx
)
axis_idx
=
idx
[
axis_nr
]
from
pymbolic.primitives
import
Variable
if
not
isinstance
(
axis_idx
,
Variable
):
raise
RuntimeError
(
"
found access
'
%s
'
in which axis %d is not a
"
"
single variable--cannot split (Have you tried to do the split
"
"
yourself, manually, beforehand? If so, you shouldn
'
t.)
"
%
(
expr
,
axis_nr
))
split_iname
=
expr
.
index
[
axis_nr
].
name
assert
split_iname
in
kernel
.
all_inames
()
if
auto_split_inames
:
from
pymbolic.primitives
import
Variable
if
not
isinstance
(
axis_idx
,
Variable
):
raise
RuntimeError
(
"
found access
'
%s
'
in which axis %d is not a
"
"
single variable--cannot split
"
"
(Have you tried to do the split yourself, manually,
"
"
beforehand? If so, you shouldn
'
t.)
"
%
(
expr
,
axis_nr
))
split_iname
=
expr
.
index
[
axis_nr
].
name
assert
split_iname
in
kernel
.
all_inames
()
try
:
outer_iname
,
inner_iname
=
split_vars
[
split_iname
]
except
KeyError
:
outer_iname
=
var_name_gen
(
split_iname
+
"
_outer
"
)
inner_iname
=
var_name_gen
(
split_iname
+
"
_inner
"
)
split_vars
[
split_iname
]
=
outer_iname
,
inner_iname
try
:
outer_in
ame
,
inner_iname
=
split_vars
[
split
_iname
]
except
KeyError
:
outer_iname
=
var_name_gen
(
split_iname
+
"
_outer
"
)
inner_in
ame
=
var_name_gen
(
split_iname
+
"
_inner
"
)
split_vars
[
split_iname
]
=
outer_iname
,
inner_iname
inner_index
=
Variable
(
inner_iname
)
outer_in
dex
=
Variable
(
outer
_iname
)
else
:
inner_in
dex
=
axis_idx
%
count
outer_index
=
axis_idx
//
count
idx
[
axis_nr
]
=
Variable
(
inner_in
ame
)
idx
[
axis_nr
]
=
inner_in
dex
if
order
==
"
F
"
:
idx
.
insert
(
axis
+
1
,
Variable
(
outer_in
ame
)
)
idx
.
insert
(
axis
+
1
,
outer_in
dex
)
elif
order
==
"
C
"
:
idx
.
insert
(
axis
,
Variable
(
outer_in
ame
)
)
idx
.
insert
(
axis
,
outer_in
dex
)
else
:
raise
RuntimeError
(
"
order
'
%s
'
not understood
"
%
order
)
...
...
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