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
caf39d6b
Commit
caf39d6b
authored
3 years ago
by
Andreas Klöckner
Browse files
Options
Downloads
Patches
Plain Diff
Improve actx.compile docs
parent
e28ae5da
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
arraycontext/context.py
+15
-5
15 additions, 5 deletions
arraycontext/context.py
with
15 additions
and
5 deletions
arraycontext/context.py
+
15
−
5
View file @
caf39d6b
...
...
@@ -354,13 +354,23 @@ class ArrayContext(ABC):
def
compile
(
self
,
f
:
Callable
[[
Any
],
Any
],
inputs_like
:
Tuple
[
Union
[
Number
,
np
.
ndarray
],
...])
->
Callable
[
...,
Any
]:
"""
Compiles a function for use on this array context. Might perform some
optimizations (such as kernel fusion) during compilation.
"""
Compiles *f* for repeated use on this array context. *f* is expected
to be a `pure function <https://en.wikipedia.org/wiki/Pure_function>`__
performing an array computation.
:arg f: the function to compile.
:arg inputs_like: the input arguments to the function.
Control flow statements (``if``, ``while``) that might take different
paths depending on the data lead to undefined behavior and are illegal.
Any data-dependent control flow must be expressed via array functions,
such as ``actx.np.where``.
*f* may be called on placeholder data, to obtain a representation
of the computation performed, or it may be called as part of the actual
computation, on actual data. If *f* is called on placeholder data,
it may be called only once (or a few times).
:return: the compiled function.
:arg f: the function executing the computation.
:arg inputs_like: the input arguments to the function.
:return: a function with the same signature as *f*.
"""
return
f
...
...
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