Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
N
ngraph
Project
Project
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ngraph
Commits
5136e1b5
Commit
5136e1b5
authored
May 24, 2019
by
Adam Rogowiec
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unit tests for GRUCell.
parent
da4e9a0e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
83 additions
and
0 deletions
+83
-0
backend_fused_op.in.cpp
test/backend_fused_op.in.cpp
+0
-0
type_prop.cpp
test/type_prop.cpp
+83
-0
No files found.
test/backend_fused_op.in.cpp
View file @
5136e1b5
This diff is collapsed.
Click to expand it.
test/type_prop.cpp
View file @
5136e1b5
...
...
@@ -14775,3 +14775,86 @@ TEST(type_prop, rnn_cell_invalid_input)
EXPECT_HAS_SUBSTRING
(
error
.
what
(),
std
::
string
(
"Input tensor B must have shape"
));
}
}
TEST
(
type_prop
,
gru_cell
)
{
const
size_t
batch_size
=
2
;
const
size_t
input_size
=
3
;
const
size_t
hidden_size
=
3
;
const
size_t
gates_count
=
3
;
const
auto
X
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
Shape
{
batch_size
,
input_size
});
const
auto
W
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
Shape
{
gates_count
*
hidden_size
,
input_size
});
const
auto
R
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
Shape
{
gates_count
*
hidden_size
,
hidden_size
});
const
auto
H_t
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
Shape
{
batch_size
,
hidden_size
});
const
auto
gru_cell
=
make_shared
<
op
::
GRUCell
>
(
X
,
W
,
R
,
H_t
,
hidden_size
);
EXPECT_EQ
(
gru_cell
->
output
(
0
).
get_element_type
(),
element
::
f32
);
EXPECT_EQ
(
gru_cell
->
output
(
0
).
get_shape
(),
(
Shape
{
batch_size
,
hidden_size
}));
}
TEST
(
type_prop
,
gru_cell_invalid_input
)
{
const
size_t
batch_size
=
2
;
const
size_t
input_size
=
3
;
const
size_t
hidden_size
=
3
;
const
size_t
gates_count
=
3
;
const
auto
X
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
Shape
{
batch_size
,
input_size
});
auto
R
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
Shape
{
gates_count
*
hidden_size
,
hidden_size
});
auto
H_t
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
Shape
{
batch_size
,
hidden_size
});
// Invalid W tensor shape.
auto
W
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
Shape
{
hidden_size
,
input_size
});
try
{
const
auto
gru_cell
=
make_shared
<
op
::
GRUCell
>
(
X
,
W
,
R
,
H_t
,
hidden_size
);
FAIL
()
<<
"GRUCell node was created with invalid data."
;
}
catch
(
const
NodeValidationFailure
&
error
)
{
EXPECT_HAS_SUBSTRING
(
error
.
what
(),
std
::
string
(
"Input tensor W must have shape"
));
}
// Invalid R tensor shape.
W
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
Shape
{
gates_count
*
hidden_size
,
input_size
});
R
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
Shape
{
hidden_size
,
1
});
try
{
const
auto
gru_cell
=
make_shared
<
op
::
GRUCell
>
(
X
,
W
,
R
,
H_t
,
hidden_size
);
FAIL
()
<<
"GRUCell node was created with invalid data."
;
}
catch
(
const
NodeValidationFailure
&
error
)
{
EXPECT_HAS_SUBSTRING
(
error
.
what
(),
std
::
string
(
"Input tensor R must have shape"
));
}
// Invalid H_t tensor shape.
R
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
Shape
{
gates_count
*
hidden_size
,
hidden_size
});
H_t
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
Shape
{
4
,
hidden_size
});
try
{
const
auto
gru_cell
=
make_shared
<
op
::
GRUCell
>
(
X
,
W
,
R
,
H_t
,
hidden_size
);
FAIL
()
<<
"GRUCell node was created with invalid data."
;
}
catch
(
const
NodeValidationFailure
&
error
)
{
EXPECT_HAS_SUBSTRING
(
error
.
what
(),
std
::
string
(
"Input tensor H_t must have shape"
));
}
// Invalid B tensor shape.
H_t
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
Shape
{
batch_size
,
hidden_size
});
auto
B
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
Shape
{
hidden_size
});
try
{
const
auto
gru_cell
=
make_shared
<
op
::
GRUCell
>
(
X
,
W
,
R
,
H_t
,
hidden_size
,
B
);
FAIL
()
<<
"GRUCell node was created with invalid data."
;
}
catch
(
const
NodeValidationFailure
&
error
)
{
EXPECT_HAS_SUBSTRING
(
error
.
what
(),
std
::
string
(
"Input tensor B must have shape"
));
}
}
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