Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ColossalAI
Commits
94bfd351
Commit
94bfd351
authored
Jul 12, 2022
by
xyupeng
Committed by
Frank Lee
Jul 13, 2022
Browse files
[NFC] polish colossalai/builder/builder.py code style (#1265)
parent
db13f963
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
9 deletions
+5
-9
colossalai/builder/builder.py
colossalai/builder/builder.py
+5
-9
No files found.
colossalai/builder/builder.py
View file @
94bfd351
...
...
@@ -6,7 +6,6 @@ import inspect
from
colossalai.registry
import
*
def
build_from_config
(
module
,
config
:
dict
):
"""Returns an object of :class:`module` constructed from `config`.
...
...
@@ -46,23 +45,20 @@ def build_from_registry(config, registry: Registry):
Raises:
Exception: Raises an Exception if an error occurred when building from registry.
"""
config_
=
config
.
copy
()
# keep the original config untouched
assert
isinstance
(
registry
,
Registry
),
f
'Expected type Registry but got
{
type
(
registry
)
}
'
config_
=
config
.
copy
()
# keep the original config untouched
assert
isinstance
(
registry
,
Registry
),
f
'Expected type Registry but got
{
type
(
registry
)
}
'
mod_type
=
config_
.
pop
(
'type'
)
assert
registry
.
has
(
mod_type
),
f
'
{
mod_type
}
is not found in registry
{
registry
.
name
}
'
assert
registry
.
has
(
mod_type
),
f
'
{
mod_type
}
is not found in registry
{
registry
.
name
}
'
try
:
obj
=
registry
.
get_module
(
mod_type
)(
**
config_
)
except
Exception
as
e
:
print
(
f
'An error occurred when building
{
mod_type
}
from registry
{
registry
.
name
}
'
,
flush
=
True
)
print
(
f
'An error occurred when building
{
mod_type
}
from registry
{
registry
.
name
}
'
,
flush
=
True
)
raise
e
return
obj
def
build_gradient_handler
(
config
,
model
,
optimizer
):
"""Returns a gradient handler object of :class:`BaseGradientHandler` constructed from `config`,
`model` and `optimizer`.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment