Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
seminar-breakout
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shashank Suhas
seminar-breakout
Commits
2c5b1bec
Commit
2c5b1bec
authored
Oct 18, 2017
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow double-wrapping TowerFuncWrapper
parent
d9817a56
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
3 deletions
+12
-3
tensorpack/tfutils/tower.py
tensorpack/tfutils/tower.py
+12
-3
No files found.
tensorpack/tfutils/tower.py
View file @
2c5b1bec
...
...
@@ -161,10 +161,19 @@ class TowerFuncWrapper(object):
It takes several input tensors and could return anything.
inputs_desc ([InputDesc]): use this to figure out the right name for the input tensors.
"""
self
.
_tower_fn
=
tower_fn
self
.
_inputs_desc
=
inputs_desc
assert
callable
(
tower_fn
),
tower_fn
if
not
isinstance
(
tower_fn
,
TowerFuncWrapper
):
self
.
_tower_fn
=
tower_fn
self
.
_inputs_desc
=
inputs_desc
self
.
_towers
=
[]
self
.
_towers
=
[]
def
__new__
(
cls
,
tower_fn
,
inputs_desc
=
None
):
# to avoid double-wrapping a function
if
isinstance
(
tower_fn
,
TowerFuncWrapper
):
return
tower_fn
else
:
return
super
(
TowerFuncWrapper
,
cls
)
.
__new__
(
cls
)
def
__call__
(
self
,
*
args
):
ctx
=
get_current_tower_context
()
...
...
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