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
apex
Commits
4cc1c1b4
Commit
4cc1c1b4
authored
Feb 18, 2019
by
Michael Carilli
Browse files
Adding small python wrapper for multi_tensor_apply
parent
6763a8be
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
0 deletions
+34
-0
apex/multi_tensor_apply/__init__.py
apex/multi_tensor_apply/__init__.py
+4
-0
apex/multi_tensor_apply/multi_tensor_apply.py
apex/multi_tensor_apply/multi_tensor_apply.py
+30
-0
No files found.
apex/multi_tensor_apply/__init__.py
0 → 100644
View file @
4cc1c1b4
from
.multi_tensor_apply
import
MultiTensorApply
multi_tensor_applier
=
MultiTensorApply
(
2048
*
32
)
apex/multi_tensor_apply/multi_tensor_apply.py
0 → 100644
View file @
4cc1c1b4
import
torch
class
MultiTensorApply
(
object
):
available
=
False
warned
=
False
def
__init__
(
self
,
chunk_size
):
try
:
import
amp_C
MultiTensorApply
.
available
=
True
self
.
chunk_size
=
chunk_size
except
ImportError
as
err
:
MultiTensorApply
.
availble
=
False
MultiTensorApply
.
import_err
=
err
def
check_avail
(
self
):
if
MultiTensorApply
.
available
==
False
:
raise
RuntimeError
(
"Attempted to call MultiTensorApply method, but MultiTensorApply "
"is not available, possibly because Apex was installed without "
"--cpp_ext --cuda_ext. Original import error message:"
,
MultiTensorApply
.
import_err
)
def
__call__
(
self
,
op
,
noop_flag_buffer
,
tensor_lists
,
*
args
):
self
.
check_avail
()
return
op
(
self
.
chunk_size
,
noop_flag_buffer
,
tensor_lists
,
*
args
)
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