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
8c16125d
Commit
8c16125d
authored
Aug 17, 2017
by
Scott Cyphers
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into cyphers/view
parents
0064cfd0
8d57ce68
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
32 changed files
with
152 additions
and
146 deletions
+152
-146
.clang-format
.clang-format
+7
-0
element_type.cpp
src/element_type.cpp
+4
-1
element_type.hpp
src/element_type.hpp
+1
-1
log.cpp
src/log.cpp
+3
-3
log.hpp
src/log.hpp
+1
-1
names.cpp
src/names.cpp
+0
-0
names.hpp
src/names.hpp
+30
-32
strides.cpp
src/strides.cpp
+1
-1
strides.hpp
src/strides.hpp
+1
-3
axes.cpp
src/transformers/axes.cpp
+2
-2
axes.hpp
src/transformers/axes.hpp
+0
-0
exop.cpp
src/transformers/exop.cpp
+2
-2
exop.hpp
src/transformers/exop.hpp
+0
-0
mock.hpp
src/transformers/mock.hpp
+0
-0
mock_transformer.hpp
src/transformers/mock_transformer.hpp
+9
-12
ndarray.hpp
src/transformers/ndarray.hpp
+1
-1
op_graph.cpp
src/transformers/op_graph.cpp
+4
-2
op_graph.hpp
src/transformers/op_graph.hpp
+0
-0
tree.hpp
src/tree.hpp
+2
-3
util.cpp
src/util.cpp
+1
-1
util.hpp
src/util.hpp
+47
-48
uuid.hpp
src/uuid.hpp
+2
-3
axes.cpp
test/axes.cpp
+10
-10
element_type.cpp
test/element_type.cpp
+2
-2
exop.cpp
test/exop.cpp
+2
-2
main.cpp
test/main.cpp
+1
-1
names.cpp
test/names.cpp
+5
-3
op_graph.cpp
test/op_graph.cpp
+2
-2
strides.cpp
test/strides.cpp
+2
-2
tensor.cpp
test/tensor.cpp
+3
-3
util.cpp
test/util.cpp
+5
-3
uuid.cpp
test/uuid.cpp
+2
-2
No files found.
.clang-format
View file @
8c16125d
...
...
@@ -44,3 +44,10 @@ SpacesInSquareBrackets: false
SortIncludes: false
ReflowComments: true
IncludeCategories:
- Regex: '^".*'
Priority: 3
- Regex: '^<.*'
Priority: 2
SortIncludes: true
src/element_type.cpp
View file @
8c16125d
...
...
@@ -27,7 +27,10 @@ const ngraph::ElementType element_type_uint64_t = ngraph::ElementType(64, false,
std
::
map
<
std
::
string
,
ngraph
::
ElementType
>
ngraph
::
ElementType
::
m_element_list
;
ngraph
::
ElementType
::
ElementType
(
size_t
bitwidth
,
bool
is_float
,
bool
is_signed
,
const
std
::
string
&
cname
)
ngraph
::
ElementType
::
ElementType
(
size_t
bitwidth
,
bool
is_float
,
bool
is_signed
,
const
std
::
string
&
cname
)
:
m_bitwidth
{
bitwidth
}
,
m_is_float
{
is_float
}
,
m_is_signed
{
is_signed
}
...
...
src/element_type.hpp
View file @
8c16125d
...
...
@@ -18,8 +18,8 @@
#pragma once
#include <string>
#include <map>
#include <string>
namespace
ngraph
{
...
...
src/log.cpp
View file @
8c16125d
...
...
@@ -14,12 +14,12 @@
*/
#include <chrono>
#include <condition_variable>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <ctime>
#include <thread>
#include <mutex>
#include <
condition_variable
>
#include <
thread
>
#include "log.hpp"
...
...
src/log.hpp
View file @
8c16125d
...
...
@@ -15,9 +15,9 @@
#pragma once
#include <deque>
#include <sstream>
#include <stdexcept>
#include <deque>
namespace
nervana
{
...
...
src/names.cpp
View file @
8c16125d
src/names.hpp
View file @
8c16125d
...
...
@@ -14,40 +14,39 @@
#pragma once
#include <string>
#include <map>
#include <string>
namespace
ngraph
{
//================================================================================================
// NameableValue
// An Axis labels a dimension of a tensor. The op-graph uses
// the identity of Axis objects to pair and specify dimensions in
// symbolic expressions. This system has several advantages over
// using the length and position of the axis as in other frameworks:
//
// 1) Convenience. The dimensions of tensors, which may be nested
// deep in a computation graph, can be specified without having to
// calculate their lengths.
//
// 2) Safety. Axis labels are analogous to types in general-purpose
// programming languages, allowing objects to interact only when
// they are permitted to do so in advance. In symbolic computation,
// this prevents interference between axes that happen to have the
// same lengths but are logically distinct, e.g. if the number of
// training examples and the number of input features are both 50.
//
// TODO: Please add to the list...
//
// Arguments:
// length: The length of the axis.
// batch: Whether the axis is a batch axis.
// recurrent: Whether the axis is a recurrent axis.
//================================================================================================
class
NameableValue
{
public
:
//================================================================================================
// NameableValue
// An Axis labels a dimension of a tensor. The op-graph uses
// the identity of Axis objects to pair and specify dimensions in
// symbolic expressions. This system has several advantages over
// using the length and position of the axis as in other frameworks:
//
// 1) Convenience. The dimensions of tensors, which may be nested
// deep in a computation graph, can be specified without having to
// calculate their lengths.
//
// 2) Safety. Axis labels are analogous to types in general-purpose
// programming languages, allowing objects to interact only when
// they are permitted to do so in advance. In symbolic computation,
// this prevents interference between axes that happen to have the
// same lengths but are logically distinct, e.g. if the number of
// training examples and the number of input features are both 50.
//
// TODO: Please add to the list...
//
// Arguments:
// length: The length of the axis.
// batch: Whether the axis is a batch axis.
// recurrent: Whether the axis is a recurrent axis.
//================================================================================================
class
NameableValue
{
public
:
//!-----------------------------------------------------------------------------------
//! NameableValue
//! An object that can be named.
...
...
@@ -103,7 +102,6 @@ public:
std
::
string
m_graph_label
;
std
::
string
m_short_name
;
std
::
string
m_doc_string
;
};
};
}
// end namespace ngraph
src/strides.cpp
View file @
8c16125d
#include <iostream>
#include <algorithm>
#include <iostream>
#include "strides.hpp"
#include "util.hpp"
...
...
src/strides.hpp
View file @
8c16125d
#pragma once
#include <cstdio>
#include <vector>
#include <initializer_list>
#include <vector>
#include "element_type.hpp"
#include "tree.hpp"
...
...
@@ -27,7 +27,6 @@ public:
ElementType
et
=
element_type_float
);
const
ElementType
&
get_type
()
const
{
return
m_element_type
;
}
tensor_stride
full_strides
()
const
;
tensor_stride
strides
()
const
;
tensor_size
sizes
()
const
;
...
...
@@ -53,7 +52,6 @@ class ngraph::tensor_stride
public
:
tensor_stride
();
const
ElementType
&
get_type
()
const
{
return
m_element_type
;
}
tensor_stride
full_strides
()
const
;
tensor_stride
strides
()
const
;
...
...
src/transformers/axes.cpp
View file @
8c16125d
...
...
@@ -12,10 +12,10 @@
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#include <cassert>
#include <cmath>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cassert>
#include "axes.hpp"
#include "util.hpp"
...
...
src/transformers/axes.hpp
View file @
8c16125d
This diff is collapsed.
Click to expand it.
src/transformers/exop.cpp
View file @
8c16125d
...
...
@@ -12,10 +12,10 @@
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#include <cmath>
#include <exception>
#include <memory>
#include <sstream>
#include <exception>
#include <cmath>
#include "exop.hpp"
#include "op_graph.hpp"
...
...
src/transformers/exop.hpp
View file @
8c16125d
This diff is collapsed.
Click to expand it.
src/transformers/mock.hpp
View file @
8c16125d
This diff is collapsed.
Click to expand it.
src/transformers/mock_transformer.hpp
View file @
8c16125d
...
...
@@ -14,24 +14,21 @@
#pragma once
#include "mock.hpp"
#include "exop.hpp"
#include "mock.hpp"
namespace
ngraph
{
//================================================================================================
// CpuTransformer
//================================================================================================
class
CpuTransformer
:
public
Transformer
{
public
:
//================================================================================================
// CpuTransformer
//================================================================================================
class
CpuTransformer
:
public
Transformer
{
public
:
virtual
~
CpuTransformer
()
{}
ExecutionState
&
execution_state
()
override
{
return
m_execution_state
;
}
private
:
private
:
ExecutionState
m_execution_state
;
};
};
}
// end namespace ngraph
src/transformers/ndarray.hpp
View file @
8c16125d
...
...
@@ -14,8 +14,8 @@
#pragma once
#include <vector>
#include <memory>
#include <vector>
#include "element_type.hpp"
#include "strides.hpp"
...
...
src/transformers/op_graph.cpp
View file @
8c16125d
...
...
@@ -14,8 +14,8 @@
#include <sstream>
#include "op_graph.hpp"
#include "axes.hpp"
#include "op_graph.hpp"
#include "util.hpp"
using
namespace
ngraph
;
...
...
@@ -2794,7 +2794,9 @@ ElementWiseOp::ElementWiseOp()
{
}
void
ElementWiseOp
::
ElementWiseOp_init
(
std
::
vector
<
op_ptr
>
,
Axes
)
{}
void
ElementWiseOp
::
ElementWiseOp_init
(
std
::
vector
<
op_ptr
>
,
Axes
)
{
}
//================================================================================================
// UnaryElementWiseOp
...
...
src/transformers/op_graph.hpp
View file @
8c16125d
This diff is collapsed.
Click to expand it.
src/tree.hpp
View file @
8c16125d
#pragma once
#include <algorithm>
#include <functional>
#include <vector>
#include <initializer_list>
#include <iostream>
#include <
algorithm
>
#include <
vector
>
#include "util.hpp"
...
...
@@ -51,7 +51,6 @@ public:
bool
is_list
()
const
{
return
m_is_list
;
}
T
get_value
()
const
{
return
m_value
;
}
const
std
::
vector
<
tree
>&
get_list
()
const
{
return
m_list
;
}
static
void
traverse_tree
(
tree
&
s
,
std
::
function
<
void
(
T
*
)
>
func
)
{
if
(
s
.
is_list
())
...
...
src/util.cpp
View file @
8c16125d
...
...
@@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#include <map>
#include <iomanip>
#include <map>
#include "util.hpp"
...
...
src/util.hpp
View file @
8c16125d
...
...
@@ -14,23 +14,22 @@
#pragma once
#include <string>
#include <sstream>
#include <vector>
#include <chrono>
#include <algorithm>
#include <
map
>
#include <
chrono
>
#include <iostream>
#include <map>
#include <sstream>
#include <string>
#include <vector>
namespace
ngraph
{
class
stopwatch
;
extern
std
::
map
<
std
::
string
,
stopwatch
*>
stopwatch_statistics
;
class
stopwatch
;
extern
std
::
map
<
std
::
string
,
stopwatch
*>
stopwatch_statistics
;
template
<
typename
T
>
std
::
string
join
(
const
T
&
v
,
const
std
::
string
&
sep
)
{
template
<
typename
T
>
std
::
string
join
(
const
T
&
v
,
const
std
::
string
&
sep
)
{
std
::
ostringstream
ss
;
for
(
const
auto
&
x
:
v
)
{
...
...
@@ -41,11 +40,11 @@ std::string join(const T& v, const std::string& sep)
ss
<<
x
;
}
return
ss
.
str
();
}
}
template
<
typename
U
,
typename
T
>
bool
contains
(
const
U
&
container
,
const
T
&
obj
)
{
template
<
typename
U
,
typename
T
>
bool
contains
(
const
U
&
container
,
const
T
&
obj
)
{
bool
rc
=
false
;
for
(
auto
o
:
container
)
{
...
...
@@ -56,11 +55,11 @@ bool contains(const U& container, const T& obj)
}
}
return
rc
;
}
}
template
<
typename
U
,
typename
T
>
bool
contains_key
(
const
U
&
container
,
const
T
&
obj
)
{
template
<
typename
U
,
typename
T
>
bool
contains_key
(
const
U
&
container
,
const
T
&
obj
)
{
bool
rc
=
false
;
for
(
auto
o
:
container
)
{
...
...
@@ -71,28 +70,28 @@ bool contains_key(const U& container, const T& obj)
}
}
return
rc
;
}
}
template
<
typename
U
,
typename
T
>
void
remove_from
(
U
&
container
,
const
T
&
obj
)
{
template
<
typename
U
,
typename
T
>
void
remove_from
(
U
&
container
,
const
T
&
obj
)
{
auto
it
=
container
.
find
(
obj
);
if
(
it
!=
container
.
end
())
{
container
.
erase
(
it
);
}
}
}
size_t
hash_combine
(
const
std
::
vector
<
size_t
>&
list
);
void
dump
(
std
::
ostream
&
out
,
const
void
*
,
size_t
);
size_t
hash_combine
(
const
std
::
vector
<
size_t
>&
list
);
void
dump
(
std
::
ostream
&
out
,
const
void
*
,
size_t
);
std
::
string
to_lower
(
const
std
::
string
&
s
);
std
::
string
trim
(
const
std
::
string
&
s
);
std
::
vector
<
std
::
string
>
split
(
const
std
::
string
&
s
,
char
delimiter
,
bool
trim
=
false
);
std
::
string
to_lower
(
const
std
::
string
&
s
);
std
::
string
trim
(
const
std
::
string
&
s
);
std
::
vector
<
std
::
string
>
split
(
const
std
::
string
&
s
,
char
delimiter
,
bool
trim
=
false
);
class
stopwatch
{
public
:
class
stopwatch
{
public
:
stopwatch
()
{}
stopwatch
(
const
std
::
string
&
name
)
:
m_name
{
name
}
...
...
@@ -149,21 +148,21 @@ public:
size_t
get_total_milliseconds
()
const
{
return
get_total_nanoseconds
()
/
1e6
;
}
size_t
get_total_microseconds
()
const
{
return
get_total_nanoseconds
()
/
1e3
;
}
size_t
get_total_nanoseconds
()
const
{
return
m_total_time
.
count
();
}
private
:
private
:
std
::
chrono
::
high_resolution_clock
m_clock
;
std
::
chrono
::
time_point
<
std
::
chrono
::
high_resolution_clock
>
m_start_time
;
bool
m_active
=
false
;
std
::
chrono
::
nanoseconds
m_total_time
=
std
::
chrono
::
high_resolution_clock
::
duration
::
zero
();
std
::
chrono
::
nanoseconds
m_total_time
=
std
::
chrono
::
high_resolution_clock
::
duration
::
zero
();
std
::
chrono
::
nanoseconds
m_last_time
;
size_t
m_total_count
=
0
;
std
::
string
m_name
;
};
};
template
<
class
InputIt
,
class
BinaryOp
>
typename
std
::
iterator_traits
<
InputIt
>::
value_type
template
<
class
InputIt
,
class
BinaryOp
>
typename
std
::
iterator_traits
<
InputIt
>::
value_type
reduce
(
InputIt
first
,
InputIt
last
,
BinaryOp
op
)
{
{
typename
std
::
iterator_traits
<
InputIt
>::
value_type
result
;
if
(
first
==
last
)
...
...
@@ -180,18 +179,18 @@ typename std::iterator_traits<InputIt>::value_type
}
}
return
result
;
}
}
template
<
typename
T
>
T
plus
(
const
T
&
a
,
const
T
&
b
)
{
template
<
typename
T
>
T
plus
(
const
T
&
a
,
const
T
&
b
)
{
return
a
+
b
;
}
}
template
<
typename
T
>
T
mul
(
const
T
&
a
,
const
T
&
b
)
{
template
<
typename
T
>
T
mul
(
const
T
&
a
,
const
T
&
b
)
{
return
a
*
b
;
}
}
}
// end namespace ngraph
src/uuid.hpp
View file @
8c16125d
...
...
@@ -15,10 +15,10 @@
#pragma once
#include <array>
#include <
random
>
#include <
cstring
>
#include <iomanip>
#include <iostream>
#include <
cstring
>
#include <
random
>
static
std
::
mt19937_64
random_generator
;
...
...
@@ -74,7 +74,6 @@ public:
}
bool
operator
!=
(
const
uuid_type
&
other
)
const
{
return
!
(
*
this
==
other
);
}
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
uuid_type
&
id
)
{
out
<<
id
.
to_string
();
...
...
test/axes.cpp
View file @
8c16125d
...
...
@@ -12,10 +12,10 @@
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#include <vector>
#include <string>
#include <sstream>
#include <string>
#include <unordered_map>
#include <vector>
#include "gtest/gtest.h"
...
...
@@ -310,7 +310,7 @@ TEST(axes, index)
EXPECT_EQ
(
7
,
b
[
1
].
length
());
}
TEST
(
axes
,
as_nested_list
)
TEST
(
axes
,
DISABLED_
as_nested_list
)
{
Axis
C
=
make_axis
(
5
);
Axis
H
=
make_axis
(
3
);
...
...
@@ -325,7 +325,7 @@ TEST(axes, as_nested_list)
FAIL
();
}
TEST
(
axes
,
flatten
)
TEST
(
axes
,
DISABLED_
flatten
)
{
Axis
C
=
make_axis
(
5
);
Axis
H
=
make_axis
(
3
);
...
...
@@ -336,7 +336,7 @@ TEST(axes, flatten)
EXPECT_TRUE
(
c
.
is_flattened
());
}
TEST
(
axes
,
as_flattened_list
)
TEST
(
axes
,
DISABLED_
as_flattened_list
)
{
FAIL
();
}
...
...
@@ -364,7 +364,7 @@ TEST(axes, hash_axes)
m2
[
axes
]
=
1
;
}
TEST
(
axes
,
reaxe_0d_to_1d
)
TEST
(
axes
,
DISABLED_
reaxe_0d_to_1d
)
{
TensorDescription
td
{};
ngraph
::
ndarray
x
=
random
(
td
);
...
...
@@ -382,7 +382,7 @@ TEST(axes, reaxe_0d_to_1d)
FAIL
();
}
TEST
(
axes
,
reaxe_0d_to_2d
)
TEST
(
axes
,
DISABLED_
reaxe_0d_to_2d
)
{
// td = TensorDescription(axes=())
// x = random(td)
...
...
@@ -407,7 +407,7 @@ TEST(axes, reaxe_0d_to_2d)
// I started refactoring into smaller pieces as seen in tests above, but
// stopped ...
//-----------------------------------------------------------------------------------------------
TEST
(
axes
,
simple_tensors
)
TEST
(
axes
,
DISABLED_
simple_tensors
)
{
// # A simple vector
// td1 = TensorDescription(axes=[ax_A])
...
...
@@ -582,7 +582,7 @@ TEST(axes, axes_map)
// assert axes_after == axes_map.map_axes(axes_before)
}
TEST
(
axes
,
axes_map_immutable
)
TEST
(
axes
,
DISABLED_
axes_map_immutable
)
{
FAIL
();
// axes_map = AxesMap({})
...
...
@@ -591,7 +591,7 @@ TEST(axes, axes_map_immutable)
// axes_map["x"] = "y"
}
TEST
(
axes
,
axes_map_init_from_axes
)
TEST
(
axes
,
DISABLED_
axes_map_init_from_axes
)
{
FAIL
();
// axes_map = AxesMap({ng.make_axis(1, name="aaa"): ng.make_axis(1, name="zzz")})
...
...
test/element_type.cpp
View file @
8c16125d
...
...
@@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#include <vector>
#include <string>
#include <sstream>
#include <string>
#include <vector>
#include "gtest/gtest.h"
...
...
test/exop.cpp
View file @
8c16125d
...
...
@@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#include <vector>
#include <string>
#include <sstream>
#include <string>
#include <vector>
#include "gtest/gtest.h"
...
...
test/main.cpp
View file @
8c16125d
...
...
@@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#include <iostream>
#include <chrono>
#include <iostream>
#include "gtest/gtest.h"
...
...
test/names.cpp
View file @
8c16125d
...
...
@@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#include <vector>
#include <string>
#include <sstream>
#include <string>
#include <vector>
#include "gtest/gtest.h"
...
...
@@ -22,4 +22,6 @@
using
namespace
ngraph
;
TEST
(
names
,
name
)
{}
TEST
(
names
,
name
)
{
}
test/op_graph.cpp
View file @
8c16125d
...
...
@@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#include <vector>
#include <string>
#include <sstream>
#include <string>
#include <vector>
#include "gtest/gtest.h"
...
...
test/strides.cpp
View file @
8c16125d
...
...
@@ -12,10 +12,10 @@
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#include <vector>
#include <string>
#include <sstream>
#include <string>
#include <unordered_map>
#include <vector>
#include "gtest/gtest.h"
...
...
test/tensor.cpp
View file @
8c16125d
...
...
@@ -12,10 +12,10 @@
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#include <vector>
#include <string>
#include <sstream>
#include <memory>
#include <sstream>
#include <string>
#include <vector>
#include "gtest/gtest.h"
...
...
test/util.cpp
View file @
8c16125d
...
...
@@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#include <vector>
#include <string>
#include <sstream>
#include <string>
#include <vector>
#include "gtest/gtest.h"
...
...
@@ -134,7 +134,9 @@ TEST(util, contains)
EXPECT_FALSE
(
contains
(
v1
,
8
));
}
TEST
(
util
,
remove_from
)
{}
TEST
(
util
,
remove_from
)
{
}
TEST
(
util
,
reduce
)
{
...
...
test/uuid.cpp
View file @
8c16125d
...
...
@@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#include <vector>
#include <string>
#include <sstream>
#include <string>
#include <vector>
#include "gtest/gtest.h"
...
...
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