-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Execute initializations on CPU much faster #1056
Changes from 14 commits
287671b
52c6b26
90e44e4
8cf1711
0d45382
8330a6c
6bc8034
239ed45
547f80c
8d5ea63
f0b6e68
150117f
454eb82
393d243
5bb27d2
9619b65
d5be1f9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
import numpy as np | ||
from termcolor import colored | ||
|
||
from desc.backend import jnp, tree_leaves, tree_map, tree_structure | ||
from desc.backend import jnp, set_default_cpu, tree_leaves, tree_map, tree_structure | ||
from desc.basis import zernike_radial, zernike_radial_coeffs | ||
from desc.utils import broadcast_tree, errorif, setdefault | ||
|
||
|
@@ -275,6 +275,7 @@ def __init__( | |
name=name, | ||
) | ||
|
||
@set_default_cpu | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want to apply this to all the build methods? It seems kind of inconsistent with where it is used now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've added it to the parent objective class before and for my test case it didn't give better results, so I picked suitable build methods intuitively. Also, maybe one important thing to keep in mind is when we build smt on cpu, probably the arrays are on cpu memory, we may need to copy them to gpu memory as we did during hackathon. |
||
def build(self, use_jit=False, verbose=1): | ||
"""Build constant arrays. | ||
|
||
|
@@ -373,6 +374,7 @@ def __init__( | |
name=name, | ||
) | ||
|
||
@set_default_cpu | ||
def build(self, use_jit=False, verbose=1): | ||
"""Build constant arrays. | ||
|
||
|
@@ -467,6 +469,7 @@ def __init__( | |
normalize_target=False, | ||
) | ||
|
||
@set_default_cpu | ||
def build(self, use_jit=False, verbose=1): | ||
"""Build constant arrays. | ||
|
||
|
@@ -553,6 +556,7 @@ def __init__( | |
normalize_target=False, | ||
) | ||
|
||
@set_default_cpu | ||
def build(self, use_jit=False, verbose=1): | ||
"""Build constant arrays. | ||
|
||
|
@@ -1548,6 +1552,7 @@ def __init__( | |
normalize_target=normalize_target, | ||
) | ||
|
||
@set_default_cpu | ||
def build(self, use_jit=False, verbose=1): | ||
"""Build constant arrays. | ||
|
||
|
@@ -1714,6 +1719,7 @@ def __init__( | |
name=name, | ||
) | ||
|
||
@set_default_cpu | ||
def build(self, use_jit=False, verbose=1): | ||
"""Build constant arrays. | ||
|
||
|
@@ -3029,6 +3035,7 @@ def __init__( | |
name=name, | ||
) | ||
|
||
@set_default_cpu | ||
def build(self, use_jit=True, verbose=1): | ||
"""Build constant arrays. | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like we could come up with a better/more descriptive name,
default_device_cpu
? or something? but not a dealbreaker