Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tic
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wenyuanbo
tic
Commits
02396a7f
Commit
02396a7f
authored
Jan 07, 2017
by
Eric Junyuan Xie
Committed by
Tianqi Chen
May 29, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add FSetInputVariableAttrs (#92)
* add FSetInputVariableAttrs * rename
parent
84b29b7b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
0 deletions
+22
-0
nnvm/include/nnvm/op_attr_types.h
+12
-0
nnvm/src/core/symbolic.cc
+10
-0
No files found.
nnvm/include/nnvm/op_attr_types.h
View file @
02396a7f
...
...
@@ -142,6 +142,18 @@ using FGradient = std::function<std::vector<NodeEntry>(
const
NodePtr
&
nodeptr
,
const
std
::
vector
<
NodeEntry
>&
out_grads
)
>
;
/*!
* \brief Set the attributes of input variable.
* Usually used for setting initialization or weight decay.
* \param attrs The attributes of this node.
* \param var the input variable
* \param index index of var in all inputs
*/
using
FSetInputVarAttrOnCompose
=
std
::
function
<
void
(
const
NodeAttrs
&
attrs
,
NodePtr
var
,
const
int
index
)
>
;
}
// namespace nnvm
#endif // NNVM_OP_ATTR_TYPES_H_
nnvm/src/core/symbolic.cc
View file @
02396a7f
...
...
@@ -259,6 +259,7 @@ void Symbol::Compose(const array_view<const Symbol*>& args,
const
std
::
unordered_map
<
std
::
string
,
const
Symbol
*>&
kwargs
,
const
std
::
string
&
name
)
{
static
auto
&
flist_inputs
=
Op
::
GetAttr
<
FListInputNames
>
(
"FListInputNames"
);
static
auto
&
fset_attrs
=
Op
::
GetAttr
<
FSetInputVarAttrOnCompose
>
(
"FSetInputVarAttrOnCompose"
);
CHECK
(
!
outputs
[
0
].
node
->
is_variable
())
<<
"Variable cannot be composed"
;
// parameter check.
...
...
@@ -323,6 +324,15 @@ void Symbol::Compose(const array_view<const Symbol*>& args,
}
}
UpdateNodeVersion
(
n
);
FSetInputVarAttrOnCompose
fn
=
fset_attrs
.
get
(
n
->
op
(),
nullptr
);
if
(
fn
!=
nullptr
)
{
for
(
size_t
i
=
0
;
i
<
n
->
inputs
.
size
();
++
i
)
{
if
(
n
->
inputs
[
i
].
node
->
is_variable
())
{
fn
(
n
->
attrs
,
n
->
inputs
[
i
].
node
,
i
);
}
}
}
}
else
{
// general composition
CHECK_EQ
(
args
.
size
(),
0U
)
...
...
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