Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
arraycontext
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alexandru Fikl
arraycontext
Commits
ae4bba35
Commit
ae4bba35
authored
3 years ago
by
Andreas Klöckner
Browse files
Options
Downloads
Patches
Plain Diff
Move actx.np.linalg.norm() implementation bits from pyopencl to generic
parent
ef9da97b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
arraycontext/fake_numpy.py
+20
-0
20 additions, 0 deletions
arraycontext/fake_numpy.py
arraycontext/impl/pyopencl.py
+1
-22
1 addition, 22 deletions
arraycontext/impl/pyopencl.py
with
21 additions
and
22 deletions
arraycontext/fake_numpy.py
+
20
−
0
View file @
ae4bba35
...
@@ -192,6 +192,26 @@ class BaseFakeNumpyLinalgNamespace:
...
@@ -192,6 +192,26 @@ class BaseFakeNumpyLinalgNamespace:
if
ary
.
size
==
0
:
if
ary
.
size
==
0
:
return
0
return
0
if
ord
is
None
:
ord
=
2
from
arraycontext.impl
import
_is_meshmode_dofarray
if
_is_meshmode_dofarray
(
ary
):
from
warnings
import
warn
warn
(
"
Taking an actx.np.linalg.norm of a DOFArray is deprecated.
"
"
(DOFArrays use 2D arrays internally, and
"
"
actx.np.linalg.norm should compute matrix norms of those.)
"
"
This will stop working in 2022.
"
"
Use meshmode.dof_array.flat_norm instead.
"
,
DeprecationWarning
,
stacklevel
=
2
)
import
numpy.linalg
as
la
return
la
.
norm
(
[
self
.
norm
(
_flatten_array
(
subary
),
ord
=
ord
)
for
_
,
subary
in
serialize_container
(
ary
)],
ord
=
ord
)
if
ord
==
np
.
inf
:
if
ord
==
np
.
inf
:
return
self
.
_array_context
.
np
.
max
(
abs
(
ary
))
return
self
.
_array_context
.
np
.
max
(
abs
(
ary
))
elif
isinstance
(
ord
,
Number
)
and
ord
>
0
:
elif
isinstance
(
ord
,
Number
)
and
ord
>
0
:
...
...
This diff is collapsed.
Click to expand it.
arraycontext/impl/pyopencl.py
+
1
−
22
View file @
ae4bba35
...
@@ -164,28 +164,7 @@ def _flatten_array(ary):
...
@@ -164,28 +164,7 @@ def _flatten_array(ary):
class
_PyOpenCLFakeNumpyLinalgNamespace
(
BaseFakeNumpyLinalgNamespace
):
class
_PyOpenCLFakeNumpyLinalgNamespace
(
BaseFakeNumpyLinalgNamespace
):
def
norm
(
self
,
ary
,
ord
=
None
):
pass
if
ord
is
None
:
ord
=
2
from
arraycontext.impl
import
_is_meshmode_dofarray
if
_is_meshmode_dofarray
(
ary
):
from
warnings
import
warn
warn
(
"
Taking an actx.np.linalg.norm of a DOFArray is deprecated.
"
"
(DOFArrays use 2D arrays internally, and
"
"
actx.np.linalg.norm should compute matrix norms of those.)
"
"
This will stop working in 2022.
"
"
Use meshmode.dof_array.flat_norm instead.
"
,
DeprecationWarning
,
stacklevel
=
2
)
import
numpy.linalg
as
la
return
la
.
norm
(
[
self
.
norm
(
_flatten_array
(
subary
),
ord
=
ord
)
for
_
,
subary
in
serialize_container
(
ary
)],
ord
=
ord
)
return
super
().
norm
(
ary
,
ord
)
# }}}
# }}}
...
...
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