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
43eb19bd
Commit
43eb19bd
authored
Aug 23, 2017
by
Scott Cyphers
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into cyphers/view
parents
271fb025
fdf535a2
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
189 additions
and
40 deletions
+189
-40
CMakeLists.txt
CMakeLists.txt
+3
-7
clang_4_0_flags.cmake
cmake/clang_4_0_flags.cmake
+33
-33
CMakeLists.txt
src/CMakeLists.txt
+6
-0
ngraph.cpp
src/ngraph.cpp
+36
-0
ngraph.hpp
src/ngraph.hpp
+35
-0
CMakeLists.txt
test/CMakeLists.txt
+3
-0
main.cpp
test/main.cpp
+1
-0
ngraph.cpp
test/ngraph.cpp
+72
-0
No files found.
CMakeLists.txt
View file @
43eb19bd
...
...
@@ -2,9 +2,9 @@
# 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.
...
...
@@ -62,7 +62,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
set
(
NGRAPH_CXX_WARNING_FLAGS
""
)
# Compiler-specific logic...
if
(
"
${
CMAKE_CXX_COMPILER_ID
}
"
STREQUAL
"Clang
"
)
if
(
"
${
CMAKE_CXX_COMPILER_ID
}
"
MATCHES
"^(Apple)?Clang$
"
)
include
(
cmake/clang_4_0_flags.cmake
)
else
()
message
(
WARNING
"CMAKE_CXX_COMPILER_ID='
${
CMAKE_CXX_COMPILER_ID
}
'. CMAKE_CXX_COMPILER='
${
CMAKE_CXX_COMPILER
}
'. The only supported compiler is 'clang', but the selected compiler is '
${
CMAKE_CXX_COMPILER
}
'."
)
...
...
@@ -71,10 +71,6 @@ endif()
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-std=c++11"
)
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
FOREACH
(
F IN LISTS NGRAPH_CXX_WARNING_FLAGS
)
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
${
F
}
"
)
ENDFOREACH
()
#-----------------------------------------------------------------------------------------------
# The following 'add_subdirectory' call:
...
...
cmake/clang_4_0_flags.cmake
View file @
43eb19bd
...
...
@@ -2,44 +2,44 @@
# 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.
SET
(
NGRAPH_CXX_WARNING_FLAGS
"-Werror=return-type"
"-Werror=inconsistent-missing-override"
"-Weverything"
"-Wno-c++98-compat"
"-Wno-c++98-compat-pedantic"
"-Wno-padded"
"-Wno-weak-vtables"
"-Wno-global-constructors"
"-Wno-switch-enum"
"-Wno-gnu-zero-variadic-macro-arguments"
"-Wno-undef"
"-Wno-exit-time-destructors"
"-Wno-missing-prototypes"
"-Wno-disabled-macro-expansion"
"-Wno-pedantic"
"-Wno-documentation"
"-Wno-covered-switch-default"
"-Wno-old-style-cast"
"-Wno-unknown-warning-option"
"-Wno-sign-conversion"
"-Wno-sign-compare"
"-Wno-unused-parameter"
"-Wno-conversion"
"-Wno-float-equal"
"-Wno-duplicate-enum"
"-Wno-used-but-marked-unused"
"-Wno-c++11-compat-deprecated-writable-strings"
"-Wno-deprecated"
"-Wno-double-promotion"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Werror=return-type"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Werror=inconsistent-missing-override"
)
# whitelist errors here
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Weverything"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wno-c++98-compat"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wno-c++98-compat-pedantic"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wno-padded"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wno-weak-vtables"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wno-global-constructors"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wno-switch-enum"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wno-gnu-zero-variadic-macro-arguments"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wno-undef"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wno-exit-time-destructors"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wno-missing-prototypes"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wno-disabled-macro-expansion"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wno-pedantic"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wno-documentation"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wno-covered-switch-default"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wno-old-style-cast"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wno-unknown-warning-option"
)
# should remove these
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wno-sign-compare"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wno-unused-parameter"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wno-conversion"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wno-float-equal"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wno-duplicate-enum"
)
# from numpy
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wno-used-but-marked-unused"
)
# from sox
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wno-c++11-compat-deprecated-writable-strings"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wno-deprecated"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-Wno-double-promotion"
)
src/CMakeLists.txt
View file @
43eb19bd
...
...
@@ -34,6 +34,12 @@ include_directories(
add_library
(
ngraph SHARED
${
SRC
}
)
if
(
APPLE
)
set_property
(
TARGET ngraph PROPERTY PREFIX
"lib"
)
set_property
(
TARGET ngraph PROPERTY OUTPUT_NAME
"ngraph.so"
)
set_property
(
TARGET ngraph PROPERTY SUFFIX
""
)
endif
()
#-----------------------------------------------------------------------------------------------
# Installation logic...
#-----------------------------------------------------------------------------------------------
...
...
src/ngraph.cpp
0 → 100644
View file @
43eb19bd
// ----------------------------------------------------------------------------
// Copyright 2017 Nervana Systems Inc.
// 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
// ----------------------------------------------------------------------------
#include "ngraph.hpp"
#include "log.hpp"
NGraph
*
create_ngraph_object
()
{
return
new
NGraph
();
}
void
destroy_ngraph_object
(
NGraph
*
pObj
)
{
delete
pObj
;
}
void
NGraph
::
add_params
(
const
std
::
vector
<
std
::
string
>&
paramList
)
{
INFO
<<
"Adding parameters"
;
m_params
.
insert
(
m_params
.
end
(),
paramList
.
begin
(),
paramList
.
end
());
}
const
std
::
vector
<
std
::
string
>&
NGraph
::
get_params
()
const
{
return
m_params
;
}
src/ngraph.hpp
0 → 100644
View file @
43eb19bd
#pragma once
// ----------------------------------------------------------------------------
// Copyright 2017 Nervana Systems Inc.
// 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
// ----------------------------------------------------------------------------
#include <string>
#include <vector>
class
NGraph
{
public
:
void
add_params
(
const
std
::
vector
<
std
::
string
>&
paramList
);
const
std
::
vector
<
std
::
string
>&
get_params
()
const
;
std
::
string
get_name
()
const
{
return
"NGraph Implementation Object"
;
}
private
:
std
::
vector
<
std
::
string
>
m_params
;
};
// Factory methods
extern
"C"
NGraph
*
create_ngraph_object
();
extern
"C"
void
destroy_ngraph_object
(
NGraph
*
pObj
);
// FUnction pointers to the factory methods
typedef
NGraph
*
(
*
CreateNGraphObjPfn
)();
typedef
void
(
*
DestroyNGraphObjPfn
)(
NGraph
*
);
test/CMakeLists.txt
View file @
43eb19bd
...
...
@@ -33,7 +33,10 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-DCURDIR=
\\\"
${
CMAKE_CURRENT_SOURCE_DIR
}
\\\"
"
)
add_executable
(
unit-test
${
SRC
}
)
target_link_libraries
(
unit-test ngraph pthread libgtest
)
target_link_libraries
(
unit-test
${
CMAKE_DL_LIBS
}
)
add_dependencies
(
unit-test ngraph libgtest
)
add_custom_target
(
check
...
...
test/main.cpp
View file @
43eb19bd
...
...
@@ -16,6 +16,7 @@
#include <iostream>
#include "gtest/gtest.h"
#include "log.hpp"
using
namespace
std
;
...
...
test/ngraph.cpp
0 → 100644
View file @
43eb19bd
// ----------------------------------------------------------------------------
// Copyright 2017 Nervana Systems Inc.
// 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
// ----------------------------------------------------------------------------
#include <vector>
#include <string>
#include <sstream>
#include <memory>
#include <dlfcn.h>
#include "gtest/gtest.h"
#include "ngraph.hpp"
#include "log.hpp"
using
namespace
std
;
TEST
(
NGraph
,
loadTest
)
{
// load the triangle library
void
*
ngraphImplLib
=
dlopen
(
"../src/libngraph.so"
,
RTLD_LAZY
);
if
(
!
ngraphImplLib
)
{
std
::
cerr
<<
"Cannot load library: "
<<
dlerror
()
<<
'\n'
;
ASSERT_FALSE
(
true
);
}
// reset errors
dlerror
();
// Get the symbols
auto
createPfn
=
reinterpret_cast
<
CreateNGraphObjPfn
>
(
dlsym
(
ngraphImplLib
,
"create_ngraph_object"
));
ASSERT_FALSE
(
createPfn
==
nullptr
);
auto
destroyPfn
=
reinterpret_cast
<
DestroyNGraphObjPfn
>
(
dlsym
(
ngraphImplLib
,
"destroy_ngraph_object"
));
ASSERT_FALSE
(
destroyPfn
==
nullptr
);
NGraph
*
nGraphObj
=
createPfn
();
INFO
<<
"Call a method on the Object"
;
ASSERT_EQ
(
"NGraph Implementation Object"
,
nGraphObj
->
get_name
());
INFO
<<
"Object Name: "
<<
nGraphObj
->
get_name
();
// Add some parameters
const
vector
<
string
>
TEST_PARAMS
=
{
"param-1"
,
"param-2"
,
"param-3"
};
nGraphObj
->
add_params
(
TEST_PARAMS
);
// Get the list of params
auto
&
storedParams
=
nGraphObj
->
get_params
();
EXPECT_EQ
(
TEST_PARAMS
.
size
(),
storedParams
.
size
());
for
(
int
i
=
0
;
i
<
TEST_PARAMS
.
size
();
i
++
)
{
EXPECT_EQ
(
TEST_PARAMS
[
i
],
storedParams
[
i
]);
}
INFO
<<
"Destroy the NGraph Object"
;
destroyPfn
(
nGraphObj
);
dlclose
(
ngraphImplLib
);
}
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