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
5ed9d5b7
Commit
5ed9d5b7
authored
Oct 05, 2017
by
Adam Procter
Committed by
GitHub
Oct 05, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
A few unit tests involving dot products on zero-size tensors (#167)
parent
cf7a4384
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
143 additions
and
0 deletions
+143
-0
execute.cpp
test/execute.cpp
+143
-0
No files found.
test/execute.cpp
View file @
5ed9d5b7
...
...
@@ -279,6 +279,149 @@ TEST(execute, test_equal)
ASSERT_EQ
((
vector
<
char
>
{
1
,
1
,
0
,
0
,
0
,
1
,
1
,
0
}),
result
->
get_vector
());
}
TEST
(
execute
,
test_dot_0_0
)
{
auto
shape
=
Shape
{
0
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
B
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
shape_r
=
Shape
{};
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
Shape
{});
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Dot
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
external
=
make_shared
<
ngraph
::
runtime
::
ExternalFunction
>
(
f
);
auto
cf
=
external
->
make_call_frame
();
// Create some tensors for input/output
auto
a
=
ngraph
::
runtime
::
make_tensor
<
element
::
Float32
>
(
shape
);
*
a
=
vector
<
float
>
{};
auto
b
=
ngraph
::
runtime
::
make_tensor
<
element
::
Float32
>
(
shape
);
*
b
=
vector
<
float
>
{};
auto
result
=
ngraph
::
runtime
::
make_tensor
<
element
::
Float32
>
(
shape_r
);
(
*
cf
)({
a
,
b
},
{
result
});
ASSERT_EQ
((
vector
<
float
>
{
0
}),
result
->
get_vector
());
}
TEST
(
execute
,
test_dot_matrix_2x0_0x2
)
{
auto
shape_a
=
Shape
{
2
,
0
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape_a
);
auto
shape_b
=
Shape
{
0
,
2
};
auto
B
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape_b
);
auto
shape_r
=
Shape
{
2
,
2
};
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape_r
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Dot
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
external
=
make_shared
<
ngraph
::
runtime
::
ExternalFunction
>
(
f
);
auto
cf
=
external
->
make_call_frame
();
// Create some tensors for input/output
auto
a
=
ngraph
::
runtime
::
make_tensor
<
element
::
Float32
>
(
shape_a
);
*
a
=
vector
<
float
>
{};
auto
b
=
ngraph
::
runtime
::
make_tensor
<
element
::
Float32
>
(
shape_b
);
*
b
=
vector
<
float
>
{};
auto
result
=
ngraph
::
runtime
::
make_tensor
<
element
::
Float32
>
(
shape_r
);
(
*
cf
)({
a
,
b
},
{
result
});
ASSERT_EQ
((
vector
<
float
>
{
0
,
0
,
0
,
0
}),
result
->
get_vector
());
}
TEST
(
execute
,
test_dot_matrix_0x2_2x0
)
{
auto
shape_a
=
Shape
{
0
,
2
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape_a
);
auto
shape_b
=
Shape
{
2
,
0
};
auto
B
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape_b
);
auto
shape_r
=
Shape
{
0
,
0
};
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape_r
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Dot
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
external
=
make_shared
<
ngraph
::
runtime
::
ExternalFunction
>
(
f
);
auto
cf
=
external
->
make_call_frame
();
// Create some tensors for input/output
auto
a
=
ngraph
::
runtime
::
make_tensor
<
element
::
Float32
>
(
shape_a
);
*
a
=
vector
<
float
>
{};
auto
b
=
ngraph
::
runtime
::
make_tensor
<
element
::
Float32
>
(
shape_b
);
*
b
=
vector
<
float
>
{};
auto
result
=
ngraph
::
runtime
::
make_tensor
<
element
::
Float32
>
(
shape_r
);
(
*
cf
)({
a
,
b
},
{
result
});
ASSERT_EQ
((
vector
<
float
>
{}),
result
->
get_vector
());
}
TEST
(
execute
,
test_dot_matrix_3x2_2x0
)
{
auto
shape_a
=
Shape
{
3
,
2
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape_a
);
auto
shape_b
=
Shape
{
2
,
0
};
auto
B
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape_b
);
auto
shape_r
=
Shape
{
0
,
0
};
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape_r
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Dot
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
external
=
make_shared
<
ngraph
::
runtime
::
ExternalFunction
>
(
f
);
auto
cf
=
external
->
make_call_frame
();
// Create some tensors for input/output
auto
a
=
ngraph
::
runtime
::
make_tensor
<
element
::
Float32
>
(
shape_a
);
*
a
=
vector
<
float
>
{
1
,
2
,
3
,
4
,
5
,
6
};
auto
b
=
ngraph
::
runtime
::
make_tensor
<
element
::
Float32
>
(
shape_b
);
*
b
=
vector
<
float
>
{};
auto
result
=
ngraph
::
runtime
::
make_tensor
<
element
::
Float32
>
(
shape_r
);
(
*
cf
)({
a
,
b
},
{
result
});
ASSERT_EQ
((
vector
<
float
>
{}),
result
->
get_vector
());
}
TEST
(
execute
,
test_dot_scalar_0x2
)
{
auto
shape_a
=
Shape
{};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape_a
);
auto
shape_b
=
Shape
{
0
,
2
};
auto
B
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape_b
);
auto
shape_r
=
Shape
{
0
,
2
};
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape_r
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Dot
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
external
=
make_shared
<
ngraph
::
runtime
::
ExternalFunction
>
(
f
);
auto
cf
=
external
->
make_call_frame
();
// Create some tensors for input/output
auto
a
=
ngraph
::
runtime
::
make_tensor
<
element
::
Float32
>
(
shape_a
);
*
a
=
vector
<
float
>
{
1
};
auto
b
=
ngraph
::
runtime
::
make_tensor
<
element
::
Float32
>
(
shape_b
);
*
b
=
vector
<
float
>
{};
auto
result
=
ngraph
::
runtime
::
make_tensor
<
element
::
Float32
>
(
shape_r
);
(
*
cf
)({
a
,
b
},
{
result
});
ASSERT_EQ
((
vector
<
float
>
{}),
result
->
get_vector
());
}
TEST
(
execute
,
test_dot_2x0_0
)
{
auto
shape_a
=
Shape
{
2
,
0
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape_a
);
auto
shape_b
=
Shape
{
0
};
auto
B
=
make_shared
<
op
::
Parameter
>
(
element
::
Float32
::
element_type
(),
shape_b
);
auto
shape_r
=
Shape
{
2
};
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape_r
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Dot
>
(
A
,
B
),
rt
,
op
::
Parameters
{
A
,
B
});
auto
external
=
make_shared
<
ngraph
::
runtime
::
ExternalFunction
>
(
f
);
auto
cf
=
external
->
make_call_frame
();
// Create some tensors for input/output
auto
a
=
ngraph
::
runtime
::
make_tensor
<
element
::
Float32
>
(
shape_a
);
*
a
=
vector
<
float
>
{};
auto
b
=
ngraph
::
runtime
::
make_tensor
<
element
::
Float32
>
(
shape_b
);
*
b
=
vector
<
float
>
{};
auto
result
=
ngraph
::
runtime
::
make_tensor
<
element
::
Float32
>
(
shape_r
);
(
*
cf
)({
a
,
b
},
{
result
});
ASSERT_EQ
((
vector
<
float
>
{
0
,
0
}),
result
->
get_vector
());
}
TEST
(
execute
,
test_dot1d
)
{
auto
shape
=
Shape
{
4
};
...
...
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