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
bfd9655f
Commit
bfd9655f
authored
Sep 26, 2018
by
Adam Procter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove 'undetermined' class, encode unknown dimension as max size_t value
parent
3b4584f7
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
65 additions
and
173 deletions
+65
-173
CMakeLists.txt
src/ngraph/CMakeLists.txt
+1
-3
dimension.cpp
src/ngraph/dimension.cpp
+21
-8
dimension.hpp
src/ngraph/dimension.hpp
+16
-20
length.cpp
src/ngraph/length.cpp
+0
-35
partial_shape.cpp
src/ngraph/partial_shape.cpp
+11
-9
partial_shape.hpp
src/ngraph/partial_shape.hpp
+14
-12
rank.hpp
src/ngraph/rank.hpp
+2
-33
undetermined.cpp
src/ngraph/undetermined.cpp
+0
-21
undetermined.hpp
src/ngraph/undetermined.hpp
+0
-32
No files found.
src/ngraph/CMakeLists.txt
View file @
bfd9655f
...
...
@@ -29,9 +29,9 @@ set (SRC
descriptor/layout/tensor_layout.cpp
descriptor/output.cpp
descriptor/tensor.cpp
dimension.cpp
file_util.cpp
function.cpp
length.cpp
log.cpp
node.cpp
op/abs.cpp
...
...
@@ -137,7 +137,6 @@ set (SRC
pass/serialize.cpp
pass/zero_dim_tensor_elimination.cpp
pattern/matcher.cpp
rank.cpp
runtime/aligned_buffer.cpp
runtime/backend.cpp
runtime/backend_manager.cpp
...
...
@@ -147,7 +146,6 @@ set (SRC
shape.cpp
strides.cpp
type/element_type.cpp
undetermined.cpp
util.cpp
graph_util.cpp
placement.cpp
...
...
src/ngraph/
rank
.cpp
→
src/ngraph/
dimension
.cpp
View file @
bfd9655f
...
...
@@ -14,13 +14,18 @@
// limitations under the License.
//*****************************************************************************
#include "ngraph/rank.hpp"
#include <iostream>
#include <limits>
std
::
ostream
&
ngraph
::
operator
<<
(
std
::
ostream
&
str
,
const
Rank
&
rank
)
#include "ngraph/dimension.hpp"
using
namespace
ngraph
;
std
::
ostream
&
ngraph
::
operator
<<
(
std
::
ostream
&
str
,
const
Dimension
&
dimension
)
{
if
(
rank
.
is_determined
())
if
(
dimension
.
is_determined
())
{
return
(
str
<<
size_t
(
rank
));
return
(
str
<<
size_t
(
dimension
));
}
else
{
...
...
@@ -28,12 +33,20 @@ std::ostream& ngraph::operator<<(std::ostream& str, const Rank& rank)
}
}
bool
ngraph
::
operator
==
(
const
Rank
&
r1
,
const
Rank
&
r2
)
Dimension
ngraph
::
operator
+
(
const
Dimension
&
d1
,
const
Dimension
&
d2
)
{
return
(
d1
.
is_determined
()
&&
d2
.
is_determined
()
?
size_t
(
d1
)
+
size_t
(
d2
)
:
Dimension
::
undetermined
());
}
bool
ngraph
::
operator
==
(
const
Dimension
&
d1
,
const
Dimension
&
d2
)
{
return
(
r1
.
is_determined
()
&&
r2
.
is_determined
()
&&
size_t
(
r1
)
==
size_t
(
r
2
));
return
(
d1
.
is_determined
()
&&
d2
.
is_determined
()
&&
size_t
(
d1
)
==
size_t
(
d
2
));
}
bool
ngraph
::
operator
!=
(
const
Rank
&
r1
,
const
Rank
&
r
2
)
bool
ngraph
::
operator
!=
(
const
Dimension
&
d1
,
const
Dimension
&
d
2
)
{
return
(
r1
.
is_determined
()
&&
r2
.
is_determined
()
&&
size_t
(
r1
)
!=
size_t
(
r
2
));
return
(
d1
.
is_determined
()
&&
d2
.
is_determined
()
&&
size_t
(
d1
)
!=
size_t
(
d
2
));
}
const
Dimension
&
Dimension
::
s_undetermined
{};
src/ngraph/
length
.hpp
→
src/ngraph/
dimension
.hpp
View file @
bfd9655f
...
...
@@ -18,37 +18,33 @@
#pragma once
#include <limits>
#include <stddef.h>
#include "ngraph/undetermined.hpp"
namespace
ngraph
{
class
Length
class
Dimension
{
public
:
Length
(
size_t
length
)
:
m_length
(
length
)
,
m_is_determined
(
true
)
{
}
Length
(
const
Undetermined
&
)
:
m_length
(
0
)
,
m_is_determined
(
false
)
Dimension
(
size_t
dimension
)
:
m_dimension
(
dimension
)
{
}
Length
()
:
m_length
(
0
)
,
m_is_determined
(
false
)
Dimension
()
:
m_dimension
(
s_undetermined_val
)
{
}
bool
is_determined
()
const
{
return
m_is_determined
;
}
explicit
operator
size_t
()
const
{
return
m_length
;
}
bool
is_determined
()
const
{
return
m_dimension
!=
s_undetermined_val
;
}
explicit
operator
size_t
()
const
{
return
m_dimension
;
}
static
const
Dimension
&
undetermined
()
{
return
s_undetermined
;
}
private
:
size_t
m_length
;
bool
m_is_determined
;
size_t
m_dimension
;
static
const
Dimension
&
s_undetermined
;
static
const
size_t
s_undetermined_val
{
std
::
numeric_limits
<
size_t
>::
max
()};
};
std
::
ostream
&
operator
<<
(
std
::
ostream
&
str
,
const
Length
&
length
);
Length
operator
+
(
const
Length
&
l1
,
const
Length
&
l2
);
std
::
ostream
&
operator
<<
(
std
::
ostream
&
str
,
const
Dimension
&
dimension
);
Dimension
operator
+
(
const
Dimension
&
d1
,
const
Dimension
&
d2
);
bool
operator
==
(
const
Dimension
&
d1
,
const
Dimension
&
d2
);
bool
operator
!=
(
const
Dimension
&
d1
,
const
Dimension
&
d2
);
}
src/ngraph/length.cpp
deleted
100644 → 0
View file @
3b4584f7
//*****************************************************************************
// 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 "ngraph/length.hpp"
std
::
ostream
&
ngraph
::
operator
<<
(
std
::
ostream
&
str
,
const
Length
&
length
)
{
if
(
length
.
is_determined
())
{
return
(
str
<<
size_t
(
length
));
}
else
{
return
(
str
<<
"?"
);
}
}
ngraph
::
Length
ngraph
::
operator
+
(
const
Length
&
l1
,
const
Length
&
l2
)
{
return
(
l1
.
is_determined
()
&&
l2
.
is_determined
()
?
size_t
(
l1
)
+
size_t
(
l2
)
:
Length
(
undetermined
));
}
src/ngraph/partial_shape.cpp
View file @
bfd9655f
...
...
@@ -15,6 +15,7 @@
//*****************************************************************************
#include <algorithm>
#include <iostream>
#include <vector>
#include "ngraph/partial_shape.hpp"
...
...
@@ -23,16 +24,17 @@ using namespace ngraph;
bool
ngraph
::
PartialShape
::
is_complete
()
const
{
return
m_rank_is_determined
&&
std
::
all_of
(
m_lengths
.
begin
(),
m_lengths
.
end
(),
[](
const
Length
&
l
)
{
return
l
.
is_determined
();
});
return
m_rank_is_determined
&&
std
::
all_of
(
m_dimensions
.
begin
(),
m_dimensions
.
end
(),
[](
const
Dimension
&
d
)
{
return
d
.
is_determined
();
});
}
ngraph
::
PartialShape
ngraph
::
operator
+
(
const
PartialShape
&
s1
,
const
PartialShape
&
s2
)
PartialShape
ngraph
::
operator
+
(
const
PartialShape
&
s1
,
const
PartialShape
&
s2
)
{
if
(
!
s1
.
rank_is_determined
()
||
!
s2
.
rank_is_determined
())
{
return
undetermined
;
return
PartialShape
::
undetermined
()
;
}
if
(
s1
.
rank
()
!=
s2
.
rank
())
...
...
@@ -42,9 +44,9 @@ ngraph::PartialShape ngraph::operator+(const PartialShape& s1, const PartialShap
PartialShape
result
{};
result
.
m_rank_is_determined
=
true
;
for
(
size_t
i
=
0
;
i
<
s1
.
m_
length
s
.
size
();
i
++
)
for
(
size_t
i
=
0
;
i
<
s1
.
m_
dimension
s
.
size
();
i
++
)
{
result
.
m_
lengths
.
push_back
(
s1
.
m_lengths
[
i
]
+
s2
.
m_length
s
[
i
]);
result
.
m_
dimensions
.
push_back
(
s1
.
m_dimensions
[
i
]
+
s2
.
m_dimension
s
[
i
]);
}
return
result
;
}
...
...
@@ -55,13 +57,13 @@ std::ostream& ngraph::operator<<(std::ostream& str, const PartialShape& shape)
{
str
<<
"{"
;
bool
first
=
true
;
for
(
auto
&
l
:
shape
.
m_length
s
)
for
(
auto
&
d
:
shape
.
m_dimension
s
)
{
if
(
!
first
)
{
str
<<
","
;
}
str
<<
l
;
str
<<
d
;
first
=
false
;
}
return
(
str
<<
"}"
);
...
...
src/ngraph/partial_shape.hpp
View file @
bfd9655f
...
...
@@ -20,7 +20,7 @@
#include <stddef.h>
#include "ngraph/
length
.hpp"
#include "ngraph/
dimension
.hpp"
#include "ngraph/rank.hpp"
namespace
ngraph
...
...
@@ -28,26 +28,28 @@ namespace ngraph
class
PartialShape
{
public
:
PartialShape
(
std
::
initializer_list
<
Length
>
init
)
:
m_rank_is_determined
(
true
)
,
m_lengths
(
init
)
{
}
PartialShape
(
const
Undetermined
&
)
:
m_rank_is_determined
(
false
)
,
m_lengths
()
PartialShape
(
std
::
initializer_list
<
Dimension
>
init
)
:
PartialShape
(
true
,
init
)
{
}
bool
rank_is_determined
()
const
{
return
m_rank_is_determined
;
}
bool
is_complete
()
const
;
Rank
rank
()
const
{
return
m_rank_is_determined
?
Rank
(
m_lengths
.
size
())
:
undetermined
;
}
Rank
rank
()
const
{
return
m_rank_is_determined
?
Rank
(
m_dimensions
.
size
())
:
Rank
::
undetermined
();
}
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
str
,
const
PartialShape
&
shape
);
friend
PartialShape
operator
+
(
const
PartialShape
&
s1
,
const
PartialShape
&
s2
);
PartialShape
append
(
const
PartialShape
&
other
);
static
PartialShape
undetermined
()
{
return
PartialShape
(
false
,
{});
}
private
:
PartialShape
(
bool
rank_is_determined
,
std
::
initializer_list
<
Dimension
>
init
)
:
m_rank_is_determined
(
rank_is_determined
)
,
m_dimensions
(
init
)
{
}
bool
m_rank_is_determined
;
std
::
vector
<
Length
>
m_length
s
;
std
::
vector
<
Dimension
>
m_dimension
s
;
};
PartialShape
operator
+
(
const
PartialShape
&
s1
,
const
PartialShape
&
s2
);
...
...
src/ngraph/rank.hpp
View file @
bfd9655f
...
...
@@ -14,42 +14,11 @@
// limitations under the License.
//*****************************************************************************
// XXX: THIS CLASS IS NOT IN USE YET AND THE ENTIRE DESIGN IS SUBJECT TO CHANGE.
#pragma once
#include <stddef.h>
#include "ngraph/undetermined.hpp"
#include "ngraph/dimension.hpp"
namespace
ngraph
{
class
Rank
{
public
:
Rank
(
size_t
rank
)
:
m_rank
(
rank
)
,
m_is_determined
(
true
)
{
}
Rank
(
const
Undetermined
&
)
:
m_rank
(
0
)
,
m_is_determined
(
false
)
{
}
Rank
()
:
m_rank
(
0
)
,
m_is_determined
(
false
)
{
}
bool
is_determined
()
const
{
return
m_is_determined
;
}
explicit
operator
size_t
()
const
{
return
m_rank
;
}
private
:
size_t
m_rank
;
bool
m_is_determined
;
};
std
::
ostream
&
operator
<<
(
std
::
ostream
&
str
,
const
Rank
&
rank
);
bool
operator
==
(
const
Rank
&
r1
,
const
Rank
&
r2
);
bool
operator
!=
(
const
Rank
&
r1
,
const
Rank
&
r2
);
using
Rank
=
Dimension
;
}
src/ngraph/undetermined.cpp
deleted
100644 → 0
View file @
3b4584f7
//*****************************************************************************
// 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 "ngraph/undetermined.hpp"
using
namespace
ngraph
;
const
Undetermined
ngraph
::
undetermined
{};
src/ngraph/undetermined.hpp
deleted
100644 → 0
View file @
3b4584f7
//*****************************************************************************
// 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.
//*****************************************************************************
// XXX: THIS CLASS IS NOT IN USE YET AND THE ENTIRE DESIGN IS SUBJECT TO CHANGE.
#pragma once
#include <iostream>
namespace
ngraph
{
class
Undetermined
{
public
:
Undetermined
()
{}
};
extern
const
Undetermined
undetermined
;
}
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