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
63eaf425
Commit
63eaf425
authored
Aug 16, 2017
by
Avijit Chakraborty
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added the initial version of NGraph Plugin dynamic library.
parent
341a34b2
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
146 additions
and
0 deletions
+146
-0
CMakeLists.txt
src/CMakeLists.txt
+7
-0
ngraph.cpp
src/ngraph.cpp
+31
-0
ngraph.hpp
src/ngraph.hpp
+36
-0
CMakeLists.txt
test/CMakeLists.txt
+1
-0
main.cpp
test/main.cpp
+1
-0
ngraph.cpp
test/ngraph.cpp
+70
-0
No files found.
src/CMakeLists.txt
View file @
63eaf425
...
...
@@ -21,6 +21,7 @@ set (SRC
tree.cpp
util.cpp
log.cpp
ngraph.cpp
transformers/axes.cpp
transformers/exop.cpp
...
...
@@ -40,6 +41,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 @
63eaf425
// ----------------------------------------------------------------------------
// 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_plugin
()
{
return
new
NGraph
();
}
void
destroy_plugin
(
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
());
}
src/ngraph.hpp
0 → 100644
View file @
63eaf425
#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
{
return
m_params
;
}
std
::
string
get_name
()
const
{
return
"NGraph Plugin"
;
}
private
:
std
::
vector
<
std
::
string
>
m_params
;
};
// Factory methods
extern
"C"
NGraph
*
create_plugin
();
extern
"C"
void
destroy_plugin
(
NGraph
*
pObj
);
// FUnction pointers to the factory methods
typedef
NGraph
*
(
*
CreatePluginPfn
)();
typedef
void
(
*
DestroyPluginPfn
)(
NGraph
*
);
test/CMakeLists.txt
View file @
63eaf425
...
...
@@ -31,6 +31,7 @@ set (SRC
uuid.cpp
names.cpp
strides.cpp
ngraph.cpp
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-std=c++11"
)
...
...
test/main.cpp
View file @
63eaf425
...
...
@@ -16,6 +16,7 @@
#include <chrono>
#include "gtest/gtest.h"
#include "log.hpp"
using
namespace
std
;
...
...
test/ngraph.cpp
0 → 100644
View file @
63eaf425
// ----------------------------------------------------------------------------
// 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
*
pluginLib
=
dlopen
(
"../src/libngraph.so"
,
RTLD_LAZY
);
if
(
!
pluginLib
)
{
std
::
cerr
<<
"Cannot load library: "
<<
dlerror
()
<<
'\n'
;
ASSERT_FALSE
(
true
);
}
// reset errors
dlerror
();
// Get the symbols
auto
createPfn
=
reinterpret_cast
<
CreatePluginPfn
>
(
dlsym
(
pluginLib
,
"create_plugin"
));
ASSERT_FALSE
(
createPfn
==
nullptr
);
auto
destroyPfn
=
reinterpret_cast
<
DestroyPluginPfn
>
(
dlsym
(
pluginLib
,
"destroy_plugin"
));
ASSERT_FALSE
(
destroyPfn
==
nullptr
);
NGraph
*
pluginObj
=
createPfn
();
INFO
<<
"Call a method on the Object"
;
ASSERT_EQ
(
"NGraph Plugin"
,
pluginObj
->
get_name
());
INFO
<<
"Plugin Name: "
<<
pluginObj
->
get_name
();
// Add some parameters
const
vector
<
string
>
TEST_PARAMS
=
{
"param-1"
,
"param-2"
,
"param-3"
};
pluginObj
->
add_params
(
TEST_PARAMS
);
// Get the list of params
auto
&
storedParams
=
pluginObj
->
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 Plugin Object"
;
destroyPfn
(
pluginObj
);
dlclose
(
pluginLib
);
}
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