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
f03b2c20
Commit
f03b2c20
authored
Oct 01, 2018
by
Adam Procter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Review comment
parent
7da2eae4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
15 deletions
+21
-15
dimension.cpp
src/ngraph/dimension.cpp
+14
-0
dimension.hpp
src/ngraph/dimension.hpp
+6
-14
partial_shape.cpp
test/partial_shape.cpp
+1
-1
No files found.
src/ngraph/dimension.cpp
View file @
f03b2c20
...
...
@@ -16,11 +16,25 @@
#include <iostream>
#include <limits>
#include <sstream>
#include "ngraph/dimension.hpp"
using
namespace
ngraph
;
Dimension
::
Dimension
(
size_t
dimension
)
:
m_dimension
(
dimension
)
{
if
(
dimension
==
s_undetermined_val
)
{
std
::
stringstream
ss
;
ss
<<
"Cannot convert the value 0x"
<<
std
::
uppercase
<<
std
::
hex
<<
s_undetermined_val
<<
" to Dimension: this value is used internally to represent an undetermined "
"dimension."
;
throw
std
::
invalid_argument
(
ss
.
str
());
}
}
std
::
ostream
&
ngraph
::
operator
<<
(
std
::
ostream
&
str
,
const
Dimension
&
dimension
)
{
if
(
dimension
.
is_determined
())
...
...
src/ngraph/dimension.hpp
View file @
f03b2c20
...
...
@@ -32,17 +32,9 @@ namespace ngraph
public
:
/// \brief Constructs a known dimension.
///
/// Requires that size_t != std::numeric_limits<size_t>::max(). If that condition
/// does not hold, throws std::invalid_argument.
Dimension
(
size_t
dimension
)
:
m_dimension
(
dimension
)
{
if
(
dimension
==
s_undetermined_val
)
{
throw
std
::
invalid_argument
(
"Cannot convert std::numeric_limits<size_t>::max() to Dimension"
);
}
}
/// Requires that dimension != s_undetermined_val. If that condition does not hold,
/// throws std::invalid_argument.
Dimension
(
size_t
dimension
);
/// \brief Constructs an unknown dimension.
Dimension
()
{
m_dimension
=
s_undetermined_val
;
}
...
...
@@ -64,13 +56,13 @@ namespace ngraph
bool
compatible
(
const
Dimension
&
d
)
const
;
/// \brief Constructs an unknown dimension.
static
Dimension
undetermined
()
{
return
Dimension
();
}
/// \brief Constant for the value used internally to represent an unknown dimension.
static
const
size_t
s_undetermined_val
{
std
::
numeric_limits
<
size_t
>::
max
()};
private
:
// The actual numerical value of the dimension. s_undetermined_val is a special case,
// representing an unknown dimension.
size_t
m_dimension
;
// Constant for the size_t value used to represent an unknown dimension.
static
const
size_t
s_undetermined_val
{
std
::
numeric_limits
<
size_t
>::
max
()};
};
/// \brief Inserts a human-readable representation of "dimension" into "str".
...
...
test/partial_shape.cpp
View file @
f03b2c20
...
...
@@ -71,7 +71,7 @@ TEST(partial_shape, dim_construction_undetermined)
TEST
(
partial_shape
,
dim_construction_size_t_max
)
{
EXPECT_ANY_THROW
({
Dimension
d
{
std
::
numeric_limits
<
size_t
>::
max
()
};
});
EXPECT_ANY_THROW
({
Dimension
d
{
Dimension
::
s_undetermined_val
};
});
}
TEST
(
partial_shape
,
dim_conversion_determined
)
...
...
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