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
53257254
Commit
53257254
authored
Sep 26, 2018
by
Adam Procter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Forgot to add the test file
parent
e1b5cfbc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
299 additions
and
0 deletions
+299
-0
partial_shape.cpp
test/partial_shape.cpp
+299
-0
No files found.
test/partial_shape.cpp
0 → 100644
View file @
53257254
//*****************************************************************************
// Copyright 2017-2018 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#include "gtest/gtest.h"
#include "ngraph/ngraph.hpp"
#include "util/test_tools.hpp"
using
namespace
ngraph
;
TEST
(
partial_shape
,
ps_construction_empty
)
{
auto
ps
=
PartialShape
{};
ASSERT_TRUE
(
ps
.
rank_is_determined
());
ASSERT_TRUE
(
ps
.
rank
().
is_determined
());
ASSERT_TRUE
(
ps
.
is_complete
());
ASSERT_EQ
(
ps
.
rank
(),
0
);
}
TEST
(
partial_shape
,
ps_construction_undetermined
)
{
auto
ps
=
PartialShape
::
undetermined
();
ASSERT_FALSE
(
ps
.
rank_is_determined
());
ASSERT_FALSE
(
ps
.
rank
().
is_determined
());
ASSERT_FALSE
(
ps
.
is_complete
());
}
TEST
(
partial_shape
,
ps_construction_incomplete
)
{
auto
ps
=
PartialShape
{
2
,
Dimension
::
undetermined
(),
3
};
ASSERT_TRUE
(
ps
.
rank_is_determined
());
ASSERT_TRUE
(
ps
.
rank
().
is_determined
());
ASSERT_FALSE
(
ps
.
is_complete
());
ASSERT_EQ
(
ps
.
rank
(),
3
);
}
TEST
(
partial_shape
,
ps_construction_complete
)
{
auto
ps
=
PartialShape
{
2
,
5
,
3
,
6
};
ASSERT_TRUE
(
ps
.
rank_is_determined
());
ASSERT_TRUE
(
ps
.
rank
().
is_determined
());
ASSERT_TRUE
(
ps
.
is_complete
());
ASSERT_EQ
(
ps
.
rank
(),
4
);
}
TEST
(
partial_shape
,
dim_construction_determined
)
{
Dimension
dim
{
3
};
ASSERT_EQ
(
size_t
(
dim
),
3
);
ASSERT_TRUE
(
dim
.
is_determined
());
}
TEST
(
partial_shape
,
dim_construction_undetermined
)
{
Dimension
dim
=
Dimension
::
undetermined
();
ASSERT_FALSE
(
dim
.
is_determined
());
}
TEST
(
partial_shape
,
rank_construction_determined
)
{
Rank
r
{
4
};
ASSERT_EQ
(
size_t
(
r
),
4
);
ASSERT_TRUE
(
r
.
is_determined
());
}
TEST
(
partial_shape
,
rank_construction_undetermined
)
{
Rank
r
=
Rank
::
undetermined
();
ASSERT_FALSE
(
r
.
is_determined
());
}
TEST
(
partial_shape
,
dim_equal_left_undetermined
)
{
Dimension
d1
{
Dimension
::
undetermined
()};
Dimension
d2
{
3
};
// Note: Can't use ASSERT_NE because the undetermined dimension has "NaN-like" behavior.
ASSERT_FALSE
(
d1
==
d2
);
}
TEST
(
partial_shape
,
dim_not_equal_left_undetermined
)
{
Dimension
d1
{
Dimension
::
undetermined
()};
Dimension
d2
{
3
};
// Note: Can't use ASSERT_EQ because the undetermined dimension has "NaN-like" behavior.
ASSERT_FALSE
(
d1
!=
d2
);
}
TEST
(
partial_shape
,
dim_equal_right_undetermined
)
{
Dimension
d1
{
3
};
Dimension
d2
{
Dimension
::
undetermined
()};
// Note: Can't use ASSERT_NE because the undetermined dimension has "NaN-like" behavior.
ASSERT_FALSE
(
d1
==
d2
);
}
TEST
(
partial_shape
,
dim_not_equal_right_undetermined
)
{
Dimension
d1
{
3
};
Dimension
d2
{
Dimension
::
undetermined
()};
// Note: Can't use ASSERT_EQ because the undetermined dimension has "NaN-like" behavior.
ASSERT_FALSE
(
d1
!=
d2
);
}
TEST
(
partial_shape
,
dim_equal_both_undetermined
)
{
Dimension
d1
{
Dimension
::
undetermined
()};
Dimension
d2
{
Dimension
::
undetermined
()};
ASSERT_FALSE
(
d1
==
d2
);
}
TEST
(
partial_shape
,
dim_not_equal_both_undetermined
)
{
Dimension
d1
{
Dimension
::
undetermined
()};
Dimension
d2
{
Dimension
::
undetermined
()};
ASSERT_FALSE
(
d1
!=
d2
);
}
TEST
(
partial_shape
,
dim_equal_both_determined
)
{
Dimension
d1
{
3
};
Dimension
d2
{
8
};
Dimension
d3
{
3
};
ASSERT_FALSE
(
d1
==
d2
);
ASSERT_TRUE
(
d1
==
d3
);
}
TEST
(
partial_shape
,
dim_not_equal_both_determined
)
{
Dimension
d1
{
3
};
Dimension
d2
{
8
};
Dimension
d3
{
3
};
ASSERT_TRUE
(
d1
!=
d2
);
ASSERT_FALSE
(
d1
!=
d3
);
}
TEST
(
partial_shape
,
shapes_equal_both_rank_undetermined
)
{
PartialShape
ps1
{
PartialShape
::
undetermined
()};
PartialShape
ps2
{
PartialShape
::
undetermined
()};
ASSERT_FALSE
(
ps1
==
ps2
);
ASSERT_TRUE
(
ps1
.
possibly_eq
(
ps2
));
}
TEST
(
partial_shape
,
shapes_equal_left_rank_undetermined
)
{
PartialShape
ps1
{
3
};
PartialShape
ps2
{
PartialShape
::
undetermined
()};
ASSERT_FALSE
(
ps1
==
ps2
);
ASSERT_TRUE
(
ps1
.
possibly_eq
(
ps2
));
}
TEST
(
partial_shape
,
shapes_equal_right_rank_undetermined
)
{
PartialShape
ps1
{
PartialShape
::
undetermined
()};
PartialShape
ps2
{
4
};
ASSERT_FALSE
(
ps1
==
ps2
);
ASSERT_TRUE
(
ps1
.
possibly_eq
(
ps2
));
}
TEST
(
partial_shape
,
shapes_equal_both_partial_all_known_equal
)
{
PartialShape
ps1
{
2
,
Dimension
::
undetermined
(),
3
,
Dimension
::
undetermined
(),
5
};
PartialShape
ps2
{
2
,
Dimension
::
undetermined
(),
Dimension
::
undetermined
(),
4
,
5
};
ASSERT_FALSE
(
ps1
==
ps2
);
ASSERT_TRUE
(
ps1
.
possibly_eq
(
ps2
));
}
TEST
(
partial_shape
,
shapes_equal_both_partial_some_known_unequal
)
{
PartialShape
ps1
{
2
,
Dimension
::
undetermined
(),
3
,
Dimension
::
undetermined
(),
5
};
PartialShape
ps2
{
1
,
Dimension
::
undetermined
(),
Dimension
::
undetermined
(),
4
,
5
};
ASSERT_FALSE
(
ps1
==
ps2
);
ASSERT_FALSE
(
ps1
.
possibly_eq
(
ps2
));
}
TEST
(
partial_shape
,
shapes_equal_both_complete_different_rank
)
{
PartialShape
ps1
{
2
,
4
,
6
,
8
};
PartialShape
ps2
{
2
,
4
,
6
,
8
,
10
};
ASSERT_FALSE
(
ps1
==
ps2
);
ASSERT_FALSE
(
ps1
.
possibly_eq
(
ps2
));
}
TEST
(
partial_shape
,
shapes_equal_both_complete_same_rank_same_dims
)
{
PartialShape
ps1
{
2
,
4
,
6
,
8
};
PartialShape
ps2
{
2
,
4
,
6
,
8
};
ASSERT_TRUE
(
ps1
==
ps2
);
ASSERT_TRUE
(
ps1
.
possibly_eq
(
ps2
));
}
TEST
(
partial_shape
,
shapes_equal_both_complete_same_rank_different_dims
)
{
PartialShape
ps1
{
2
,
4
,
6
,
8
};
PartialShape
ps2
{
2
,
4
,
3
,
8
};
ASSERT_FALSE
(
ps1
==
ps2
);
ASSERT_FALSE
(
ps1
.
possibly_eq
(
ps2
));
}
TEST
(
partial_shape
,
shapes_not_equal_both_rank_undetermined
)
{
PartialShape
ps1
{
PartialShape
::
undetermined
()};
PartialShape
ps2
{
PartialShape
::
undetermined
()};
ASSERT_FALSE
(
ps1
!=
ps2
);
ASSERT_TRUE
(
ps1
.
possibly_neq
(
ps2
));
}
TEST
(
partial_shape
,
shapes_not_equal_left_rank_undetermined
)
{
PartialShape
ps1
{
3
};
PartialShape
ps2
{
PartialShape
::
undetermined
()};
ASSERT_FALSE
(
ps1
!=
ps2
);
ASSERT_TRUE
(
ps1
.
possibly_neq
(
ps2
));
}
TEST
(
partial_shape
,
shapes_not_equal_right_rank_undetermined
)
{
PartialShape
ps1
{
PartialShape
::
undetermined
()};
PartialShape
ps2
{
4
};
ASSERT_FALSE
(
ps1
!=
ps2
);
ASSERT_TRUE
(
ps1
.
possibly_neq
(
ps2
));
}
TEST
(
partial_shape
,
shapes_not_equal_both_partial_all_known_equal
)
{
PartialShape
ps1
{
2
,
Dimension
::
undetermined
(),
3
,
Dimension
::
undetermined
(),
5
};
PartialShape
ps2
{
2
,
Dimension
::
undetermined
(),
Dimension
::
undetermined
(),
4
,
5
};
ASSERT_FALSE
(
ps1
!=
ps2
);
ASSERT_TRUE
(
ps1
.
possibly_neq
(
ps2
));
}
TEST
(
partial_shape
,
shapes_not_equal_both_partial_some_known_unequal
)
{
PartialShape
ps1
{
2
,
Dimension
::
undetermined
(),
3
,
Dimension
::
undetermined
(),
5
};
PartialShape
ps2
{
1
,
Dimension
::
undetermined
(),
Dimension
::
undetermined
(),
4
,
5
};
ASSERT_TRUE
(
ps1
!=
ps2
);
ASSERT_TRUE
(
ps1
.
possibly_neq
(
ps2
));
}
TEST
(
partial_shape
,
shapes_not_equal_both_complete_different_rank
)
{
PartialShape
ps1
{
2
,
4
,
6
,
8
};
PartialShape
ps2
{
2
,
4
,
6
,
8
,
10
};
ASSERT_TRUE
(
ps1
!=
ps2
);
ASSERT_TRUE
(
ps1
.
possibly_neq
(
ps2
));
}
TEST
(
partial_shape
,
shapes_not_equal_both_complete_same_rank_same_dims
)
{
PartialShape
ps1
{
2
,
4
,
6
,
8
};
PartialShape
ps2
{
2
,
4
,
6
,
8
};
ASSERT_FALSE
(
ps1
!=
ps2
);
ASSERT_FALSE
(
ps1
.
possibly_neq
(
ps2
));
}
TEST
(
partial_shape
,
shapes_not_equal_both_complete_same_rank_different_dims
)
{
PartialShape
ps1
{
2
,
4
,
6
,
8
};
PartialShape
ps2
{
2
,
4
,
3
,
8
};
ASSERT_TRUE
(
ps1
!=
ps2
);
ASSERT_TRUE
(
ps1
.
possibly_neq
(
ps2
));
}
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