Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
distiller
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
llvm
distiller
Commits
748cb056
Commit
748cb056
authored
4 years ago
by
Neta Zmora
Browse files
Options
Downloads
Patches
Plain Diff
Add EltwiseSub
As requested in issue #496
parent
410a059b
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
distiller/modules/__init__.py
+1
-1
1 addition, 1 deletion
distiller/modules/__init__.py
distiller/modules/eltwise.py
+23
-4
23 additions, 4 deletions
distiller/modules/eltwise.py
with
24 additions
and
5 deletions
distiller/modules/__init__.py
+
1
−
1
View file @
748cb056
...
...
@@ -21,7 +21,7 @@ from .rnn import *
from
.aggregate
import
*
from
.topology
import
*
__all__
=
[
'
EltwiseAdd
'
,
'
EltwiseMult
'
,
'
EltwiseDiv
'
,
'
Matmul
'
,
'
BatchMatmul
'
,
__all__
=
[
'
EltwiseAdd
'
,
'
EltwiseSub
'
,
'
EltwiseMult
'
,
'
EltwiseDiv
'
,
'
Matmul
'
,
'
BatchMatmul
'
,
'
Concat
'
,
'
Chunk
'
,
'
Split
'
,
'
Stack
'
,
'
DistillerLSTMCell
'
,
'
DistillerLSTM
'
,
'
convert_model_to_distiller_lstm
'
,
'
Norm
'
,
'
Mean
'
,
'
BranchPoint
'
,
'
Print
'
]
...
...
This diff is collapsed.
Click to expand it.
distiller/modules/eltwise.py
+
23
−
4
View file @
748cb056
...
...
@@ -19,8 +19,8 @@ import torch.nn as nn
class
EltwiseAdd
(
nn
.
Module
):
def
__init__
(
self
,
inplace
=
False
):
super
(
EltwiseAdd
,
self
).
__init__
()
"""
Element-wise addition
"""
super
().
__init__
()
self
.
inplace
=
inplace
def
forward
(
self
,
*
input
):
...
...
@@ -34,9 +34,27 @@ class EltwiseAdd(nn.Module):
return
res
class
EltwiseSub
(
nn
.
Module
):
def
__init__
(
self
,
inplace
=
False
):
"""
Element-wise subtraction
"""
super
().
__init__
()
self
.
inplace
=
inplace
def
forward
(
self
,
*
input
):
res
=
input
[
0
]
if
self
.
inplace
:
for
t
in
input
[
1
:]:
res
-=
t
else
:
for
t
in
input
[
1
:]:
res
=
res
-
t
return
res
class
EltwiseMult
(
nn
.
Module
):
def
__init__
(
self
,
inplace
=
False
):
super
(
EltwiseMult
,
self
).
__init__
()
"""
Element-wise multiplication
"""
super
().
__init__
()
self
.
inplace
=
inplace
def
forward
(
self
,
*
input
):
...
...
@@ -52,7 +70,8 @@ class EltwiseMult(nn.Module):
class
EltwiseDiv
(
nn
.
Module
):
def
__init__
(
self
,
inplace
=
False
):
super
(
EltwiseDiv
,
self
).
__init__
()
"""
Element-wise division
"""
super
().
__init__
()
self
.
inplace
=
inplace
def
forward
(
self
,
x
:
torch
.
Tensor
,
y
):
...
...
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