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
a23b9241
Unverified
Commit
a23b9241
authored
Nov 21, 2017
by
Robert Kimball
Committed by
GitHub
Nov 21, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into bob/pch
parents
4be4a95b
293042a4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
216 additions
and
12 deletions
+216
-12
primary_tensor_view.cpp
src/ngraph/descriptor/primary_tensor_view.cpp
+3
-2
primary_tensor_view.hpp
src/ngraph/descriptor/primary_tensor_view.hpp
+2
-1
tensor.cpp
src/ngraph/descriptor/tensor.cpp
+3
-1
tensor.hpp
src/ngraph/descriptor/tensor.hpp
+4
-1
node.cpp
src/ngraph/node.cpp
+7
-1
node.hpp
src/ngraph/node.hpp
+1
-0
constant.hpp
src/ngraph/ops/constant.hpp
+2
-0
liveness.cpp
src/ngraph/pass/liveness.cpp
+1
-2
emitter.cpp
src/ngraph/runtime/cpu/emitter.cpp
+0
-0
tensor_view.cpp
src/ngraph/runtime/cpu/tensor_view.cpp
+5
-1
parameterized_tensor_view.hpp
src/ngraph/runtime/parameterized_tensor_view.hpp
+2
-1
backend_test.in.cpp
test/backend_test.in.cpp
+141
-1
pass_liveness.cpp
test/pass_liveness.cpp
+25
-1
pass_memory_layout.cpp
test/pass_memory_layout.cpp
+20
-0
No files found.
src/ngraph/descriptor/primary_tensor_view.cpp
View file @
a23b9241
...
...
@@ -20,9 +20,10 @@ using namespace descriptor;
PrimaryTensorView
::
PrimaryTensorView
(
const
std
::
shared_ptr
<
const
TensorViewType
>&
tensor_view_type
,
const
std
::
string
&
name
,
bool
is_output
,
bool
is_input
)
bool
is_input
,
bool
is_constant
)
:
TensorView
(
tensor_view_type
)
,
m_tensor
(
tensor_view_type
->
get_element_type
(),
this
,
name
,
is_output
,
is_input
)
,
m_tensor
(
tensor_view_type
->
get_element_type
(),
this
,
name
,
is_output
,
is_input
,
is_constant
)
{
// Set the name in the parent TensorView.
// This can't be done until after the m_tensor is constructed.
...
...
src/ngraph/descriptor/primary_tensor_view.hpp
View file @
a23b9241
...
...
@@ -43,7 +43,8 @@ namespace ngraph
PrimaryTensorView
(
const
std
::
shared_ptr
<
const
TensorViewType
>&
tensor_view_type
,
const
std
::
string
&
name
,
bool
is_output
,
bool
is_input
);
bool
is_input
,
bool
is_constant
);
virtual
const
Tensor
&
get_tensor
()
const
override
;
virtual
Tensor
&
get_tensor
()
override
;
...
...
src/ngraph/descriptor/tensor.cpp
View file @
a23b9241
...
...
@@ -23,12 +23,14 @@ Tensor::Tensor(const element::Type& element_type,
PrimaryTensorView
*
primary_tensor_view
,
const
std
::
string
&
name
,
bool
is_output
,
bool
is_input
)
bool
is_input
,
bool
is_constant
)
:
m_element_type
(
element_type
)
,
m_primary_tensor_view
(
primary_tensor_view
)
,
m_is_output
{
is_output
}
,
m_is_input
{
is_input
}
,
m_is_persistent
{
false
}
,
m_is_constant
{
is_constant
}
,
m_name
{
name
}
,
m_next_view_id
{
0
}
{
...
...
src/ngraph/descriptor/tensor.hpp
View file @
a23b9241
...
...
@@ -47,7 +47,8 @@ private:
PrimaryTensorView
*
tensor_view
,
const
std
::
string
&
name
,
bool
is_output
,
bool
is_input
);
bool
is_input
,
bool
is_constant
);
std
::
string
get_next_view_name
();
...
...
@@ -55,6 +56,7 @@ public:
bool
is_output
()
const
{
return
m_is_output
;
}
bool
is_input
()
const
{
return
m_is_input
;
}
bool
is_persistent
()
const
{
return
m_is_persistent
;
}
bool
is_constant
()
const
{
return
m_is_constant
;
}
const
std
::
string
&
get_name
()
const
{
return
m_name
;
}
size_t
size
()
const
;
void
set_pool_offset
(
size_t
);
...
...
@@ -68,6 +70,7 @@ protected:
bool
m_is_output
;
bool
m_is_input
;
bool
m_is_persistent
;
bool
m_is_constant
;
std
::
string
m_name
;
size_t
m_next_view_id
;
size_t
m_size
;
...
...
src/ngraph/node.cpp
View file @
a23b9241
...
...
@@ -70,7 +70,8 @@ void Node::set_value_type_checked(const shared_ptr<const ValueType>& value_type)
tvt
,
ngraph
::
descriptor
::
Tensor
::
make_tensor_name
(
this
,
i
),
is_output
(),
is_parameter
());
is_parameter
(),
is_constant
());
m_outputs
.
emplace_back
(
this
,
i
,
tensor_view_descriptor
);
i
++
;
}
...
...
@@ -124,6 +125,11 @@ void Node::set_is_output()
}
}
bool
Node
::
is_constant
()
const
{
return
false
;
}
std
::
string
Node
::
get_node_id
()
const
{
stringstream
ss
;
...
...
src/ngraph/node.hpp
View file @
a23b9241
...
...
@@ -89,6 +89,7 @@ namespace ngraph
bool
is_parameter
()
const
;
bool
is_output
()
const
;
void
set_is_output
();
virtual
bool
is_constant
()
const
;
size_t
get_instance_id
()
const
{
return
m_instance_id
;
}
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
,
const
Node
&
);
...
...
src/ngraph/ops/constant.hpp
View file @
a23b9241
...
...
@@ -40,6 +40,8 @@ namespace ngraph
{
set_value_type_checked
(
type
);
}
virtual
bool
is_constant
()
const
override
{
return
true
;
}
};
/// \brief Class for constants whose element types are known at C++ compile-time.
...
...
src/ngraph/pass/liveness.cpp
View file @
a23b9241
...
...
@@ -125,8 +125,7 @@ bool pass::Liveness::run_on_call_graph(list<shared_ptr<Node>>& ops)
bool
pass
::
Liveness
::
is_temporary
(
const
Tensor
&
tensor
)
{
return
tensor
.
is_persistent
()
==
false
&&
tensor
.
is_input
()
==
false
&&
tensor
.
is_output
()
==
false
;
// && tensor.is_constant() == false
tensor
.
is_output
()
==
false
&&
tensor
.
is_constant
()
==
false
;
// && tensor.is_compile_only() == false;
}
...
...
src/ngraph/runtime/cpu/emitter.cpp
View file @
a23b9241
This diff is collapsed.
Click to expand it.
src/ngraph/runtime/cpu/tensor_view.cpp
View file @
a23b9241
...
...
@@ -25,7 +25,11 @@ using namespace std;
runtime
::
cpu
::
CPUTensorView
::
CPUTensorView
(
const
ngraph
::
element
::
Type
&
element_type
,
const
Shape
&
shape
)
:
runtime
::
TensorView
(
std
::
make_shared
<
ngraph
::
descriptor
::
PrimaryTensorView
>
(
std
::
make_shared
<
ngraph
::
TensorViewType
>
(
element_type
,
shape
),
"external"
,
true
,
true
))
std
::
make_shared
<
ngraph
::
TensorViewType
>
(
element_type
,
shape
),
"external"
,
true
,
true
,
false
))
,
m_allocated_buffer_pool
(
nullptr
)
,
m_aligned_buffer_pool
(
nullptr
)
...
...
src/ngraph/runtime/parameterized_tensor_view.hpp
View file @
a23b9241
...
...
@@ -41,7 +41,8 @@ namespace ngraph
std
::
make_shared
<
ngraph
::
TensorViewType
>
(
ET
::
element_type
(),
shape
),
"external"
,
true
,
true
))
true
,
false
))
{
m_descriptor
->
set_tensor_view_layout
(
std
::
make_shared
<
ngraph
::
descriptor
::
layout
::
DenseTensorViewLayout
>
(
...
...
test/backend_test.in.cpp
View file @
a23b9241
...
...
@@ -1065,7 +1065,27 @@ TEST(${BACKEND_NAME}, subtract)
ASSERT_EQ
((
vector
<
float
>
{
1
,
2
,
4
,
8
}),
result
->
get_vector
<
float
>
());
}
TEST
(
$
{
BACKEND_NAME
},
scalar_constant
)
TEST
(
$
{
BACKEND_NAME
},
scalar_parameterized_constant_bool
)
{
auto
shape
=
Shape
{};
auto
t
=
runtime
::
make_tensor
<
element
::
Bool
>
(
shape
,
{
true
});
auto
A
=
make_shared
<
op
::
ParameterizedConstant
<
element
::
Bool
>>
(
shape
,
t
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Bool
::
element_type
(),
shape
);
auto
f
=
make_shared
<
Function
>
(
A
,
rt
,
op
::
Parameters
{});
auto
manager
=
runtime
::
Manager
::
get
(
"${BACKEND_NAME}"
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
// Create some tensors for input/output
auto
result
=
backend
->
make_primary_tensor_view
(
element
::
Bool
::
element_type
(),
shape
);
(
*
cf
)({},
{
result
});
ASSERT_EQ
((
vector
<
char
>
{
true
}),
result
->
get_vector
<
char
>
());
}
TEST
(
$
{
BACKEND_NAME
},
scalar_parameterized_constant_float
)
{
auto
shape
=
Shape
{};
auto
t
=
runtime
::
make_tensor
<
element
::
Float32
>
(
shape
,
{
-
3.0
f
});
...
...
@@ -1085,6 +1105,126 @@ TEST(${BACKEND_NAME}, scalar_constant)
ASSERT_EQ
((
vector
<
float
>
{
-
3.0
f
}),
result
->
get_vector
<
float
>
());
}
TEST
(
$
{
BACKEND_NAME
},
scalar_parameterized_constant_int8
)
{
auto
shape
=
Shape
{};
auto
t
=
runtime
::
make_tensor
<
element
::
Int8
>
(
shape
,
{
-
3
});
auto
A
=
make_shared
<
op
::
ParameterizedConstant
<
element
::
Int8
>>
(
shape
,
t
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Int8
::
element_type
(),
shape
);
auto
f
=
make_shared
<
Function
>
(
A
,
rt
,
op
::
Parameters
{});
auto
manager
=
runtime
::
Manager
::
get
(
"${BACKEND_NAME}"
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
// Create some tensors for input/output
auto
result
=
backend
->
make_primary_tensor_view
(
element
::
Int8
::
element_type
(),
shape
);
(
*
cf
)({},
{
result
});
ASSERT_EQ
((
vector
<
int8_t
>
{
-
3
}),
result
->
get_vector
<
int8_t
>
());
}
TEST
(
$
{
BACKEND_NAME
},
scalar_parameterized_constant_int32
)
{
auto
shape
=
Shape
{};
auto
t
=
runtime
::
make_tensor
<
element
::
Int32
>
(
shape
,
{
-
3
});
auto
A
=
make_shared
<
op
::
ParameterizedConstant
<
element
::
Int32
>>
(
shape
,
t
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Int32
::
element_type
(),
shape
);
auto
f
=
make_shared
<
Function
>
(
A
,
rt
,
op
::
Parameters
{});
auto
manager
=
runtime
::
Manager
::
get
(
"${BACKEND_NAME}"
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
// Create some tensors for input/output
auto
result
=
backend
->
make_primary_tensor_view
(
element
::
Int32
::
element_type
(),
shape
);
(
*
cf
)({},
{
result
});
ASSERT_EQ
((
vector
<
int32_t
>
{
-
3
}),
result
->
get_vector
<
int32_t
>
());
}
TEST
(
$
{
BACKEND_NAME
},
scalar_parameterized_constant_int64
)
{
auto
shape
=
Shape
{};
auto
t
=
runtime
::
make_tensor
<
element
::
Int64
>
(
shape
,
{
-
3
});
auto
A
=
make_shared
<
op
::
ParameterizedConstant
<
element
::
Int64
>>
(
shape
,
t
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Int64
::
element_type
(),
shape
);
auto
f
=
make_shared
<
Function
>
(
A
,
rt
,
op
::
Parameters
{});
auto
manager
=
runtime
::
Manager
::
get
(
"${BACKEND_NAME}"
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
// Create some tensors for input/output
auto
result
=
backend
->
make_primary_tensor_view
(
element
::
Int64
::
element_type
(),
shape
);
(
*
cf
)({},
{
result
});
ASSERT_EQ
((
vector
<
int64_t
>
{
-
3
}),
result
->
get_vector
<
int64_t
>
());
}
TEST
(
$
{
BACKEND_NAME
},
scalar_parameterized_constant_uint8
)
{
auto
shape
=
Shape
{};
auto
t
=
runtime
::
make_tensor
<
element
::
UInt8
>
(
shape
,
{
3
});
auto
A
=
make_shared
<
op
::
ParameterizedConstant
<
element
::
UInt8
>>
(
shape
,
t
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
UInt8
::
element_type
(),
shape
);
auto
f
=
make_shared
<
Function
>
(
A
,
rt
,
op
::
Parameters
{});
auto
manager
=
runtime
::
Manager
::
get
(
"${BACKEND_NAME}"
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
// Create some tensors for input/output
auto
result
=
backend
->
make_primary_tensor_view
(
element
::
UInt8
::
element_type
(),
shape
);
(
*
cf
)({},
{
result
});
ASSERT_EQ
((
vector
<
uint8_t
>
{
3
}),
result
->
get_vector
<
uint8_t
>
());
}
TEST
(
$
{
BACKEND_NAME
},
scalar_parameterized_constant_uint32
)
{
auto
shape
=
Shape
{};
auto
t
=
runtime
::
make_tensor
<
element
::
UInt32
>
(
shape
,
{
3
});
auto
A
=
make_shared
<
op
::
ParameterizedConstant
<
element
::
UInt32
>>
(
shape
,
t
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
UInt32
::
element_type
(),
shape
);
auto
f
=
make_shared
<
Function
>
(
A
,
rt
,
op
::
Parameters
{});
auto
manager
=
runtime
::
Manager
::
get
(
"${BACKEND_NAME}"
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
// Create some tensors for input/output
auto
result
=
backend
->
make_primary_tensor_view
(
element
::
UInt32
::
element_type
(),
shape
);
(
*
cf
)({},
{
result
});
ASSERT_EQ
((
vector
<
uint32_t
>
{
3
}),
result
->
get_vector
<
uint32_t
>
());
}
TEST
(
$
{
BACKEND_NAME
},
scalar_parameterized_constant_uint64
)
{
auto
shape
=
Shape
{};
auto
t
=
runtime
::
make_tensor
<
element
::
UInt64
>
(
shape
,
{
3
});
auto
A
=
make_shared
<
op
::
ParameterizedConstant
<
element
::
UInt64
>>
(
shape
,
t
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
UInt64
::
element_type
(),
shape
);
auto
f
=
make_shared
<
Function
>
(
A
,
rt
,
op
::
Parameters
{});
auto
manager
=
runtime
::
Manager
::
get
(
"${BACKEND_NAME}"
);
auto
external
=
manager
->
compile
(
f
);
auto
backend
=
manager
->
allocate_backend
();
auto
cf
=
backend
->
make_call_frame
(
external
);
// Create some tensors for input/output
auto
result
=
backend
->
make_primary_tensor_view
(
element
::
UInt64
::
element_type
(),
shape
);
(
*
cf
)({},
{
result
});
ASSERT_EQ
((
vector
<
uint64_t
>
{
3
}),
result
->
get_vector
<
uint64_t
>
());
}
TEST
(
$
{
BACKEND_NAME
},
tensor_constant
)
{
auto
shape
=
Shape
{
2
,
2
,
2
};
...
...
test/pass_liveness.cpp
View file @
a23b9241
...
...
@@ -34,7 +34,31 @@ using namespace std;
using
namespace
ngraph
;
namespace
ng
=
ngraph
;
TEST
(
pass
,
liveness
)
TEST
(
liveness
,
constant
)
{
auto
shape
=
Shape
{
1
};
auto
c
=
make_shared
<
op
::
Constant
>
(
element
::
i32
,
Shape
{},
"5"
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Negative
>
(
c
),
rt
,
op
::
Parameters
{});
pass
::
Manager
pass_manager
;
pass_manager
.
register_pass
<
pass
::
TopologicalSort
>
();
pass_manager
.
register_pass
<
pass
::
Liveness
>
();
pass_manager
.
run_passes
(
f
);
auto
tmp
=
f
->
get_ordered_ops
();
vector
<
shared_ptr
<
Node
>>
sorted
{
tmp
.
begin
(),
tmp
.
end
()};
ASSERT_EQ
(
2
,
sorted
.
size
());
EXPECT_EQ
(
0
,
sorted
[
0
]
->
liveness_live_list
.
size
());
EXPECT_EQ
(
0
,
sorted
[
0
]
->
liveness_new_list
.
size
());
EXPECT_EQ
(
0
,
sorted
[
0
]
->
liveness_free_list
.
size
());
EXPECT_EQ
(
0
,
sorted
[
1
]
->
liveness_live_list
.
size
());
EXPECT_EQ
(
0
,
sorted
[
1
]
->
liveness_new_list
.
size
());
EXPECT_EQ
(
0
,
sorted
[
1
]
->
liveness_free_list
.
size
());
}
TEST
(
liveness
,
liveness
)
{
string
image
=
"liveness.png"
;
string
dump_file
=
"liveness.txt"
;
...
...
test/pass_memory_layout.cpp
View file @
a23b9241
...
...
@@ -218,3 +218,23 @@ TEST(memory_layout, basic)
size_t
temporary_pool_size
=
pass_manager
.
get_state
().
get_temporary_pool_size
();
EXPECT_EQ
(
12
,
temporary_pool_size
);
}
TEST
(
memory_layout
,
constant
)
{
string
dump_file
=
"constant.txt"
;
pass
::
Manager
pass_manager
;
pass_manager
.
register_pass
<
pass
::
TopologicalSort
>
();
pass_manager
.
register_pass
<
pass
::
Liveness
>
();
pass_manager
.
register_pass
<
pass
::
MemoryLayout
>
();
pass_manager
.
register_pass
<
pass
::
DumpSorted
>
(
dump_file
);
auto
shape
=
Shape
{
1
};
auto
c
=
make_shared
<
op
::
Constant
>
(
element
::
i32
,
Shape
{},
"5"
);
auto
rt
=
make_shared
<
TensorViewType
>
(
element
::
Float32
::
element_type
(),
shape
);
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Negative
>
(
c
),
rt
,
op
::
Parameters
{});
pass_manager
.
run_passes
(
f
);
auto
sorted
=
f
->
get_ordered_ops
();
size_t
temporary_pool_size
=
pass_manager
.
get_state
().
get_temporary_pool_size
();
EXPECT_EQ
(
0
,
temporary_pool_size
);
}
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