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
ff467c65
Unverified
Commit
ff467c65
authored
Feb 28, 2018
by
Scott Cyphers
Committed by
GitHub
Feb 28, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into cyphers/dochow
parents
91a835eb
803c3b36
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
156 additions
and
128 deletions
+156
-128
CMakeLists.txt
CMakeLists.txt
+8
-5
var_functions.cmake
cmake/Modules/var_functions.cmake
+37
-0
external_json.cmake
cmake/external_json.cmake
+56
-0
CMakeLists.txt
src/ngraph/CMakeLists.txt
+2
-1
json.hpp
src/ngraph/json.hpp
+0
-0
cpu_tracing.hpp
src/ngraph/runtime/cpu/cpu_tracing.hpp
+1
-1
serializer.cpp
src/ngraph/serializer.cpp
+9
-79
serializer.hpp
src/ngraph/serializer.hpp
+1
-1
CMakeLists.txt
src/resource/CMakeLists.txt
+0
-2
CMakeLists.txt
src/tools/CMakeLists.txt
+4
-3
CMakeLists.txt
test/CMakeLists.txt
+2
-1
argon_fusion.cpp
test/argon_fusion.cpp
+1
-1
backend_test.in.cpp
test/backend_test.in.cpp
+9
-9
core_fusion.cpp
test/core_fusion.cpp
+1
-1
cpu_fusion.cpp
test/cpu_fusion.cpp
+18
-18
reshape_elimination.cpp
test/reshape_elimination.cpp
+1
-1
serialize.cpp
test/serialize.cpp
+3
-3
all_close.hpp
test/util/all_close.hpp
+2
-2
CMakeLists.txt
third-party/CMakeLists.txt
+1
-0
No files found.
CMakeLists.txt
View file @
ff467c65
...
...
@@ -60,6 +60,8 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# set directory where the custom finders live
set
(
CMAKE_MODULE_PATH
${
CMAKE_MODULE_PATH
}
"
${
CMAKE_SOURCE_DIR
}
/cmake/Modules/"
)
include
(
var_functions
)
#-----------------------------------------------------------------------------------------------
# Installation logic...
#-----------------------------------------------------------------------------------------------
...
...
@@ -97,14 +99,15 @@ endif()
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-std=c++11"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-O3"
)
SET
(
CMAKE_CXX_FLAGS_RELWITHDEBINFO
"-O3 -g"
)
SET
(
CMAKE_CXX_FLAGS_RELEASE
"-O3"
)
SET
(
CMAKE_CXX_FLAGS_DEBUG
"-O0 -g"
)
if
(
"
${
NGRAPH_WARNINGS_AS_ERRORS
}
"
MATCHES
"^ON$
"
)
message
(
STATUS
"Enabling warnings as errors
"
)
ngraph_var
(
NGRAPH_WARNINGS_AS_ERRORS DEFAULT
"OFF
"
)
if
(
"
${
NGRAPH_WARNINGS_AS_ERRORS
}
"
MATCHES
"^(ON|TRUE)$
"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Werror"
)
message
(
STATUS
"Warnings as errors"
)
endif
()
SET
(
CMAKE_CXX_FLAGS_RELWITHDEBINFO
"-O3 -g"
)
SET
(
CMAKE_CXX_FLAGS_RELEASE
"-O3"
)
SET
(
CMAKE_CXX_FLAGS_DEBUG
"-O0 -g"
)
# Set true if CPU backend is built by default
if
(
NOT DEFINED NGRAPH_CPU_ENABLE
)
...
...
cmake/Modules/var_functions.cmake
0 → 100644
View file @
ff467c65
# ******************************************************************************
# 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.
# ******************************************************************************
# function check existence of cmake and environment variable and read their value
# If the variable is not defined then the supplied default value used
# example:
# ngraph_var(NGRAPH_VARIABLE_NAME DEFAULT "OFF")
# checks if variable NGRAPH_VARIABLE_NAME was passed in via the cmake command line
# if found then passed in value is used
# else checks for the existence of the environment variable NGRAPH_VARIABLE_NAME
# if found it's value is used
# if none of the above then the default value is used
function
(
NGRAPH_VAR
)
set
(
options
)
set
(
oneValueArgs DEFAULT
)
set
(
multiValueArgs
)
cmake_parse_arguments
(
NGRAPH_VAR
"
${
options
}
"
"
${
oneValueArgs
}
"
"
${
multiValueArgs
}
"
${
ARGN
}
)
if
(
NOT DEFINED
${
NGRAPH_VAR_UNPARSED_ARGUMENTS
}
)
set
(
${
NGRAPH_VAR_UNPARSED_ARGUMENTS
}
${
NGRAPH_VAR_DEFAULT
}
PARENT_SCOPE
)
if
(
DEFINED ENV{
${
NGRAPH_VAR_UNPARSED_ARGUMENTS
}
}
)
set
(
${
NGRAPH_VAR_UNPARSED_ARGUMENTS
}
$ENV{
${
NGRAPH_VAR_UNPARSED_ARGUMENTS
}
} PARENT_SCOPE
)
endif
()
endif
()
endfunction
()
cmake/external_json.cmake
0 → 100644
View file @
ff467c65
# ******************************************************************************
# 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.
# ******************************************************************************
# Enable ExternalProject CMake module
include
(
ExternalProject
)
#------------------------------------------------------------------------------
# Download json
#------------------------------------------------------------------------------
SET
(
JSON_GIT_REPO_URL https://github.com/nlohmann/json
)
SET
(
JSON_GIT_LABEL v3.1.1
)
# The 'BUILD_BYPRODUCTS' argument was introduced in CMake 3.2.
if
(
${
CMAKE_VERSION
}
VERSION_LESS 3.2
)
ExternalProject_Add
(
ext_json
GIT_REPOSITORY
${
JSON_GIT_REPO_URL
}
GIT_TAG
${
JSON_GIT_LABEL
}
# Disable install step
BUILD_COMMAND
""
INSTALL_COMMAND
""
UPDATE_COMMAND
""
)
else
()
ExternalProject_Add
(
ext_json
GIT_REPOSITORY
${
JSON_GIT_REPO_URL
}
GIT_TAG
${
JSON_GIT_LABEL
}
# Disable install step
BUILD_COMMAND
""
INSTALL_COMMAND
""
UPDATE_COMMAND
""
)
endif
()
#------------------------------------------------------------------------------
get_filename_component
(
JSON_INCLUDE_DIR
"
${
EXTERNAL_PROJECTS_ROOT
}
/ext_json-prefix/src/ext_json/include"
ABSOLUTE
)
set
(
JSON_INCLUDE_DIR
"
${
JSON_INCLUDE_DIR
}
"
PARENT_SCOPE
)
src/ngraph/CMakeLists.txt
View file @
ff467c65
...
...
@@ -266,8 +266,9 @@ if (NGRAPH_CPU_ENABLE AND LLVM_INCLUDE_DIR AND MKLDNN_INCLUDE_DIR)
DEPENDS resource_generator ext_eigen ext_llvm ext_mkldnn
BYPRODUCTS
)
add_dependencies
(
ngraph header_resource
)
add_dependencies
(
ngraph header_resource
ext_json
)
include_directories
(
${
CMAKE_BINARY_DIR
}
)
include_directories
(
SYSTEM
${
JSON_INCLUDE_DIR
}
)
endif
()
if
(
NOT APPLE
)
...
...
src/ngraph/json.hpp
deleted
100644 → 0
View file @
91a835eb
This diff is collapsed.
Click to expand it.
src/ngraph/runtime/cpu/cpu_tracing.hpp
View file @
ff467c65
...
...
@@ -21,8 +21,8 @@
#include <string>
#include <vector>
#include "ngraph/json.hpp"
#include "ngraph/runtime/cpu/cpu_external_function.hpp"
#include "nlohmann/json.hpp"
namespace
ngraph
{
...
...
src/ngraph/serializer.cpp
View file @
ff467c65
...
...
@@ -90,57 +90,6 @@ static std::shared_ptr<ngraph::Function>
static
json
write
(
const
ngraph
::
Function
&
);
static
json
write
(
const
ngraph
::
Node
&
);
// There should be a map from element type names to element types so deserialization can
// find the singletons and serialization can serialize by name.
static
const
element
::
Type
&
to_ref
(
const
element
::
Type
&
t
)
{
if
(
t
==
element
::
boolean
)
{
return
element
::
boolean
;
}
if
(
t
==
element
::
f32
)
{
return
element
::
f32
;
}
if
(
t
==
element
::
f64
)
{
return
element
::
f64
;
}
if
(
t
==
element
::
i8
)
{
return
element
::
i8
;
}
if
(
t
==
element
::
i16
)
{
return
element
::
i16
;
}
if
(
t
==
element
::
i32
)
{
return
element
::
i32
;
}
if
(
t
==
element
::
i64
)
{
return
element
::
i64
;
}
if
(
t
==
element
::
u8
)
{
return
element
::
u8
;
}
if
(
t
==
element
::
u16
)
{
return
element
::
u16
;
}
if
(
t
==
element
::
u32
)
{
return
element
::
u32
;
}
if
(
t
==
element
::
u64
)
{
return
element
::
u64
;
}
throw
runtime_error
(
"type not valid"
);
}
static
json
write_element_type
(
const
ngraph
::
element
::
Type
&
n
)
{
json
j
;
...
...
@@ -148,12 +97,12 @@ static json write_element_type(const ngraph::element::Type& n)
return
j
;
}
static
const
element
::
Type
&
read_element_type
(
const
json
&
j
)
static
element
::
Type
read_element_type
(
const
json
&
j
)
{
size_t
bitwidth
=
0
;
bool
is_real
;
bool
is_signed
;
string
c_type_string
;
bool
is_real
=
false
;
bool
is_signed
=
false
;
string
c_type_string
=
""
;
if
(
j
.
is_object
())
{
bitwidth
=
j
.
at
(
"bitwidth"
).
get
<
size_t
>
();
...
...
@@ -176,26 +125,7 @@ static const element::Type& read_element_type(const json& j)
}
}
}
return
to_ref
(
element
::
Type
(
bitwidth
,
is_real
,
is_signed
,
c_type_string
));
}
static
json
write_tensor_type
(
const
element
::
Type
&
element_type
,
const
Shape
&
shape
)
{
json
j
;
j
[
"element_type"
]
=
write_element_type
(
element_type
);
j
[
"shape"
]
=
shape
;
return
j
;
}
static
std
::
shared_ptr
<
const
TensorViewType
>
read_tensor_type
(
const
json
&
j
,
const
string
&
type
,
const
string
&
sshape
)
{
const
element
::
Type
&
et
=
read_element_type
(
j
.
at
(
type
));
Shape
shape
=
j
.
count
(
sshape
)
>
0
?
Shape
(
j
.
at
(
sshape
).
get
<
vector
<
size_t
>>
())
:
Shape
{}
/*HACK, so we could call read_tensor_type uniformly @ each callsite*/
;
return
make_shared
<
TensorViewType
>
(
et
,
shape
);
return
element
::
Type
(
bitwidth
,
is_real
,
is_signed
,
c_type_string
);
}
string
ngraph
::
serialize
(
shared_ptr
<
ngraph
::
Function
>
func
,
size_t
indent
)
...
...
@@ -216,7 +146,7 @@ string ngraph::serialize(shared_ptr<ngraph::Function> func, size_t indent)
}
else
{
rc
=
j
.
dump
(
indent
);
rc
=
j
.
dump
(
static_cast
<
int
>
(
indent
)
);
}
return
rc
;
}
...
...
@@ -405,14 +335,14 @@ static shared_ptr<ngraph::Function>
{
auto
type_node_js
=
node_js
.
count
(
"element_type"
)
==
0
?
node_js
.
at
(
"value_type"
)
:
node_js
;
auto
&
element_type
=
read_element_type
(
type_node_js
.
at
(
"element_type"
));
auto
element_type
=
read_element_type
(
type_node_js
.
at
(
"element_type"
));
auto
shape
=
type_node_js
.
at
(
"shape"
);
auto
value
=
node_js
.
at
(
"value"
).
get
<
vector
<
string
>>
();
node
=
make_shared
<
op
::
Constant
>
(
element_type
,
shape
,
value
);
}
else
if
(
node_op
==
"Convert"
)
{
auto
&
target_type
=
read_element_type
(
node_js
.
at
(
"target_type"
));
auto
target_type
=
read_element_type
(
node_js
.
at
(
"target_type"
));
node
=
make_shared
<
op
::
Convert
>
(
args
[
0
],
target_type
);
}
else
if
(
node_op
==
"Convolution"
)
...
...
@@ -662,7 +592,7 @@ static shared_ptr<ngraph::Function>
{
auto
type_node_js
=
node_js
.
count
(
"element_type"
)
==
0
?
node_js
.
at
(
"value_type"
)
:
node_js
;
auto
&
element_type
=
read_element_type
(
type_node_js
.
at
(
"element_type"
));
auto
element_type
=
read_element_type
(
type_node_js
.
at
(
"element_type"
));
auto
shape
=
type_node_js
.
at
(
"shape"
);
node
=
make_shared
<
op
::
Parameter
>
(
element_type
,
shape
);
}
...
...
src/ngraph/serializer.hpp
View file @
ff467c65
...
...
@@ -20,8 +20,8 @@
#include <unordered_map>
#include "ngraph/function.hpp"
#include "ngraph/json.hpp"
#include "ngraph/node.hpp"
#include "nlohmann/json.hpp"
namespace
ngraph
{
...
...
src/resource/CMakeLists.txt
View file @
ff467c65
...
...
@@ -37,7 +37,5 @@ if (NGRAPH_CPU_ENABLE)
set
(
HEADER_SEARCH_DEFINES
${
HEADER_SEARCH_DEFINES
}
"NGRAPH_TBB_ENABLE"
)
endif
()
message
(
"HEADER_SEARCH_DEFINES
${
HEADER_SEARCH_DEFINES
}
"
)
set_source_files_properties
(
main.cpp PROPERTIES COMPILE_DEFINITIONS
"
${
HEADER_SEARCH_DEFINES
}
"
)
endif
()
src/tools/CMakeLists.txt
View file @
ff467c65
...
...
@@ -26,13 +26,14 @@ if (NGRAPH_CPU_ENABLE)
add_executable
(
nbench
${
SRC
}
)
add_dependencies
(
nbench ngraph
)
set
(
HEADER_SEARCH_DEFINES
"NGRAPH_HEADERS_PATH=
\"
${
NGRAPH_INCLUDE_PATH
}
\"
"
)
target_link_libraries
(
nbench ngraph
)
include_directories
(
SYSTEM
${
JSON_INCLUDE_DIR
}
)
set_source_files_properties
(
nbench.cpp PROPERTIES COMPILE_DEFINITIONS
"
${
HEADER_SEARCH_DEFINES
}
"
)
endif
()
test/CMakeLists.txt
View file @
ff467c65
...
...
@@ -178,7 +178,8 @@ endif()
target_link_libraries
(
unit-test ngraph libgtest pthread
)
target_link_libraries
(
unit-test
${
CMAKE_DL_LIBS
}
)
add_dependencies
(
unit-test ngraph libgtest ext_eigen
)
add_dependencies
(
unit-test ngraph libgtest ext_eigen ext_json
)
include_directories
(
SYSTEM
${
JSON_INCLUDE_DIR
}
)
add_custom_target
(
style-check
COMMAND
${
PROJECT_SOURCE_DIR
}
/maint/check-code-format.sh
...
...
test/argon_fusion.cpp
View file @
ff467c65
...
...
@@ -24,7 +24,6 @@
#include "ngraph/file_util.hpp"
#include "ngraph/graph_util.hpp"
#include "ngraph/json.hpp"
#include "ngraph/log.hpp"
#include "ngraph/ngraph.hpp"
#include "ngraph/ops/relu.hpp"
...
...
@@ -37,6 +36,7 @@
#include "ngraph/runtime/argon/pass/argon_fusion.hpp"
#include "ngraph/serializer.hpp"
#include "ngraph/util.hpp"
#include "nlohmann/json.hpp"
#include "util/matcher.hpp"
#include "util/test_tools.hpp"
...
...
test/backend_test.in.cpp
View file @
ff467c65
...
...
@@ -3055,7 +3055,7 @@ TEST(${BACKEND_NAME}, scalar_constant_float32)
auto
result
=
backend
->
make_primary_tensor_view
(
element
::
f32
,
Shape
{});
cf
->
call
({},
{
result
});
EXPECT_EQ
(
vector
<
float
>
{
4.8
},
read_vector
<
float
>
(
result
));
EXPECT_EQ
(
vector
<
float
>
{
4.8
f
},
read_vector
<
float
>
(
result
));
}
TEST
(
$
{
BACKEND_NAME
},
scalar_constant_int64
)
...
...
@@ -3073,7 +3073,7 @@ TEST(${BACKEND_NAME}, scalar_constant_int64)
auto
result
=
backend
->
make_primary_tensor_view
(
element
::
i64
,
Shape
{});
cf
->
call
({},
{
result
});
EXPECT_EQ
(
vector
<
int64_t
>
{
{
2112
}
},
read_vector
<
int64_t
>
(
result
));
EXPECT_EQ
(
vector
<
int64_t
>
{
2112
},
read_vector
<
int64_t
>
(
result
));
}
TEST
(
$
{
BACKEND_NAME
},
tensor_constant_float32
)
...
...
@@ -3092,7 +3092,7 @@ TEST(${BACKEND_NAME}, tensor_constant_float32)
auto
result
=
backend
->
make_primary_tensor_view
(
element
::
f32
,
shape
);
cf
->
call
({},
{
result
});
EXPECT_EQ
((
vector
<
float
>
{
4.8
,
4.7
,
-
5.3
,
0
}),
read_vector
<
float
>
(
result
));
EXPECT_EQ
((
vector
<
float
>
{
4.8
f
,
4.7
f
,
-
5.3
f
,
0.0
f
}),
read_vector
<
float
>
(
result
));
}
TEST
(
$
{
BACKEND_NAME
},
tensor_constant_int64
)
...
...
@@ -3514,11 +3514,11 @@ TEST(${BACKEND_NAME}, sum_to_scalar_stable)
// Create some tensors for input/output
auto
a
=
backend
->
make_primary_tensor_view
(
element
::
f32
,
shape
);
copy_data
(
a
,
vector
<
float
>
{
1e-6
,
-
1
,
0
,
1
});
copy_data
(
a
,
vector
<
float
>
{
1e-6
f
,
-
1
,
0
,
1
});
auto
result
=
backend
->
make_primary_tensor_view
(
element
::
f32
,
Shape
{});
cf
->
call
({
a
},
{
result
});
EXPECT_TRUE
(
test
::
all_close
(
read_vector
<
float
>
(
result
),
vector
<
float
>
{
1e-6
},
5e-2
f
));
EXPECT_TRUE
(
test
::
all_close
(
read_vector
<
float
>
(
result
),
vector
<
float
>
{
1e-6
f
},
5e-2
f
));
// EXPECT_EQ(vector<float>{1e-6}, read_vector<float>(result));
}
...
...
@@ -3539,13 +3539,13 @@ TEST(${BACKEND_NAME}, sum_3d_to_vector_stable)
// Create some tensors for input/output
auto
a
=
backend
->
make_primary_tensor_view
(
element
::
f32
,
shape_a
);
copy_data
(
a
,
vector
<
float
>
{
1
,
1
,
1
,
1
,
1
,
1
,
1e-4
,
1e-5
,
1e-6
,
1
,
1
,
1
,
1
,
1
,
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
});
copy_data
(
a
,
vector
<
float
>
{
1
,
1
,
1
,
1
,
1
,
1
,
1e-4
f
,
1e-5
f
,
1e-6
f
,
1
,
1
,
1
,
1
,
1
,
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
});
auto
result
=
backend
->
make_primary_tensor_view
(
element
::
f32
,
shape_rt
);
cf
->
call
({
a
},
{
result
});
EXPECT_TRUE
(
test
::
all_close
(
read_vector
<
float
>
(
result
),
vector
<
float
>
{
1e-4
,
1e-5
,
1e-6
},
5e-2
f
));
test
::
all_close
(
read_vector
<
float
>
(
result
),
vector
<
float
>
{
1e-4
f
,
1e-5
f
,
1e-6
f
},
5e-2
f
));
}
TEST
(
$
{
BACKEND_NAME
},
sign
)
...
...
@@ -3562,7 +3562,7 @@ TEST(${BACKEND_NAME}, sign)
// Create some tensors for input/output
auto
a
=
backend
->
make_primary_tensor_view
(
element
::
f32
,
shape
);
copy_data
(
a
,
vector
<
float
>
{
1
,
-
2
,
0
,
-
4.8
f
,
4.8
f
,
-
0.0
});
copy_data
(
a
,
vector
<
float
>
{
1
,
-
2
,
0
,
-
4.8
f
,
4.8
f
,
-
0.0
f
});
auto
result
=
backend
->
make_primary_tensor_view
(
element
::
f32
,
shape
);
cf
->
call
({
a
},
{
result
});
...
...
test/core_fusion.cpp
View file @
ff467c65
...
...
@@ -24,7 +24,6 @@
#include "ngraph/file_util.hpp"
#include "ngraph/graph_util.hpp"
#include "ngraph/json.hpp"
#include "ngraph/log.hpp"
#include "ngraph/ngraph.hpp"
#include "ngraph/ops/relu.hpp"
...
...
@@ -36,6 +35,7 @@
#include "ngraph/pattern/op/label.hpp"
#include "ngraph/serializer.hpp"
#include "ngraph/util.hpp"
#include "nlohmann/json.hpp"
#include "util/matcher.hpp"
#include "util/test_tools.hpp"
...
...
test/cpu_fusion.cpp
View file @
ff467c65
...
...
@@ -33,13 +33,13 @@
#include "ngraph/pattern/op/label.hpp"
//
#include "ngraph/file_util.hpp"
#include "ngraph/json.hpp"
#include "ngraph/pass/reshape_elimination.hpp"
#include "ngraph/pass/visualize_tree.hpp"
#include "ngraph/runtime/cpu/ops/matmul_bias.hpp"
#include "ngraph/runtime/cpu/pass/cpu_fusion.hpp"
#include "ngraph/serializer.hpp"
#include "ngraph/util.hpp"
#include "nlohmann/json.hpp"
#include "util/all_close.hpp"
#include "util/matcher.hpp"
#include "util/test_tools.hpp"
...
...
@@ -201,26 +201,26 @@ TEST(cpu_fusion, batchnorm_fprop_b1c2h2w2)
0.54488319
f
,
0.42365479
f
,
0.64589411
f
,
0.4375872
,
0.89177299
});
0.4375872
f
,
0.89177299
f
});
auto
_mean
=
backend
->
make_primary_tensor_view
(
element
::
f32
,
mean_shape
);
copy_data
(
_mean
,
vector
<
float
>
{
0.60291237
,
0.59972727
});
copy_data
(
_mean
,
vector
<
float
>
{
0.60291237
f
,
0.59972727
f
});
auto
_var
=
backend
->
make_primary_tensor_view
(
element
::
f32
,
var_shape
);
copy_data
(
_var
,
vector
<
float
>
{
0.00472505
,
0.03617825
});
copy_data
(
_var
,
vector
<
float
>
{
0.00472505
f
,
0.03617825
f
});
auto
_gamma
=
backend
->
make_primary_tensor_view
(
element
::
f32
,
gamma_shape
);
copy_data
(
_gamma
,
vector
<
float
>
{
1.0
f
,
1.0
f
});
auto
_beta
=
backend
->
make_primary_tensor_view
(
element
::
f32
,
beta_shape
);
copy_data
(
_beta
,
vector
<
float
>
{
0.0
f
,
0.0
f
});
auto
result
=
backend
->
make_primary_tensor_view
(
element
::
f32
,
shape_r
);
vector
<
float
>
expected_result
{
-
0.71498716
,
1.48388731
,
-
0.00196938
,
-
0.76693159
,
-
0.91316032
,
0.23943391
,
-
0.84090298
,
1.51462936
};
vector
<
float
>
expected_result
{
-
0.71498716
f
,
1.48388731
f
,
-
0.00196938
f
,
-
0.76693159
f
,
-
0.91316032
f
,
0.23943391
f
,
-
0.84090298
f
,
1.51462936
f
};
cf
->
call
({
_mean
,
_var
,
_input
,
_gamma
,
_beta
},
{
result
});
EXPECT_TRUE
(
test
::
all_close
(
expected_result
,
read_vector
<
float
>
(
result
)));
}
...
...
@@ -255,12 +255,12 @@ TEST(cpu_fusion, batchnorm_fprop_b2c2h2w1)
0.54488319
f
,
0.42365479
f
,
0.64589411
f
,
0.4375872
,
0.89177299
});
0.4375872
f
,
0.89177299
f
});
auto
_mean
=
backend
->
make_primary_tensor_view
(
element
::
f32
,
mean_shape
);
copy_data
(
_mean
,
vector
<
float
>
{
0.60291237
,
0.59972727
});
copy_data
(
_mean
,
vector
<
float
>
{
0.60291237
f
,
0.59972727
f
});
auto
_var
=
backend
->
make_primary_tensor_view
(
element
::
f32
,
var_shape
);
copy_data
(
_var
,
vector
<
float
>
{
0.00472505
,
0.03617825
});
copy_data
(
_var
,
vector
<
float
>
{
0.00472505
f
,
0.03617825
f
});
auto
_gamma
=
backend
->
make_primary_tensor_view
(
element
::
f32
,
gamma_shape
);
copy_data
(
_gamma
,
vector
<
float
>
{
1.0
f
,
1.0
f
});
auto
_beta
=
backend
->
make_primary_tensor_view
(
element
::
f32
,
beta_shape
);
...
...
@@ -268,7 +268,7 @@ TEST(cpu_fusion, batchnorm_fprop_b2c2h2w1)
auto
result
=
backend
->
make_primary_tensor_view
(
element
::
f32
,
shape_r
);
vector
<
float
>
expected_result
{
-
0.714987
,
1.48389
,
0.015746
,
-
0.284436
,
-
2.36912
,
0.56806
,
-
0.840903
,
1.51463
};
-
0.714987
f
,
1.48389
f
,
0.015746
f
,
-
0.284436
f
,
-
2.36912
f
,
0.56806
f
,
-
0.840903
f
,
1.51463
f
};
cf
->
call
({
_mean
,
_var
,
_input
,
_gamma
,
_beta
},
{
result
});
EXPECT_TRUE
(
test
::
all_close
(
expected_result
,
read_vector
<
float
>
(
result
)));
}
...
...
test/reshape_elimination.cpp
View file @
ff467c65
...
...
@@ -23,7 +23,6 @@
#include "gtest/gtest.h"
#include "ngraph/file_util.hpp"
#include "ngraph/graph_util.hpp"
#include "ngraph/json.hpp"
#include "ngraph/log.hpp"
#include "ngraph/ngraph.hpp"
#include "ngraph/ops/sum.hpp"
...
...
@@ -35,6 +34,7 @@
#include "ngraph/pattern/op/label.hpp"
#include "ngraph/serializer.hpp"
#include "ngraph/util.hpp"
#include "nlohmann/json.hpp"
#include "util/matcher.hpp"
#include "util/test_tools.hpp"
...
...
test/serialize.cpp
View file @
ff467c65
...
...
@@ -20,10 +20,10 @@
#include "gtest/gtest.h"
#include "ngraph/file_util.hpp"
#include "ngraph/json.hpp"
#include "ngraph/ngraph.hpp"
#include "ngraph/serializer.hpp"
#include "ngraph/util.hpp"
#include "nlohmann/json.hpp"
#include "util/test_tools.hpp"
using
namespace
std
;
...
...
@@ -60,8 +60,8 @@ TEST(serialize, main)
string
js
=
serialize
(
h
,
4
);
{
ofstream
f
(
"serialize_function.js"
);
f
<<
js
;
ofstream
out
(
"serialize_function.js"
);
out
<<
js
;
}
istringstream
in
(
js
);
...
...
test/util/all_close.hpp
View file @
ff467c65
...
...
@@ -36,8 +36,8 @@ namespace ngraph
template
<
typename
T
>
bool
all_close
(
const
std
::
vector
<
T
>&
a
,
const
std
::
vector
<
T
>&
b
,
T
rtol
=
1e-5
f
,
T
atol
=
1e-8
f
)
T
rtol
=
static_cast
<
T
>
(
1e-5
)
,
T
atol
=
static_cast
<
T
>
(
1e-8
)
)
{
assert
(
a
.
size
()
==
b
.
size
());
for
(
size_t
i
=
0
;
i
<
a
.
size
();
++
i
)
...
...
third-party/CMakeLists.txt
View file @
ff467c65
...
...
@@ -19,6 +19,7 @@ if(NOT DEFINED EXTERNAL_PROJECTS_ROOT)
endif
()
include
(
../cmake/external_gtest.cmake
)
include
(
../cmake/external_json.cmake
)
include
(
../cmake/external_eigen.cmake
)
include
(
../cmake/external_mkldnn.cmake
)
if
(
NGRAPH_USE_PREBUILT_LLVM OR DEFINED LLVM_TARBALL_URL
)
...
...
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