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
295ed8eb
Unverified
Commit
295ed8eb
authored
Jul 14, 2018
by
Robert Kimball
Committed by
GitHub
Jul 14, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove regex from Backend.cpp (#1228)
parent
e6c3d5e3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
5 deletions
+24
-5
backend.cpp
src/ngraph/runtime/backend.cpp
+23
-5
backend.hpp
src/ngraph/runtime/backend.hpp
+1
-0
No files found.
src/ngraph/runtime/backend.cpp
View file @
295ed8eb
...
...
@@ -15,7 +15,6 @@
*******************************************************************************/
#include <dlfcn.h>
#include <regex>
#include <sstream>
#include "ngraph/file_util.hpp"
...
...
@@ -108,12 +107,11 @@ map<string, string> runtime::Backend::get_registered_device_map()
map
<
string
,
string
>
rc
;
string
my_directory
=
file_util
::
get_directory
(
find_my_file
());
vector
<
string
>
backend_list
;
regex
reg
(
"^lib(.+)_backend"
+
string
(
SHARED_LIB_EXT
));
smatch
result
;
auto
f
=
[
&
](
const
string
&
file
,
bool
is_dir
)
{
string
name
=
file_util
::
get_file_name
(
file
);
if
(
regex_match
(
name
,
result
,
reg
))
string
backend_name
;
if
(
is_backend_name
(
name
,
backend_name
))
{
auto
handle
=
dlopen
(
file
.
c_str
(),
RTLD_LAZY
|
RTLD_LOCAL
);
if
(
handle
)
...
...
@@ -126,7 +124,7 @@ map<string, string> runtime::Backend::get_registered_device_map()
if
(
get_ngraph_version_string
&&
get_ngraph_version_string
()
==
string
(
NGRAPH_VERSION
))
{
rc
.
insert
({
to_upper
(
result
[
1
]
),
file
});
rc
.
insert
({
to_upper
(
backend_name
),
file
});
}
}
...
...
@@ -219,3 +217,23 @@ void runtime::Backend::validate_call(shared_ptr<const Function> function,
}
}
}
bool
runtime
::
Backend
::
is_backend_name
(
const
string
&
file
,
string
&
backend_name
)
{
string
name
=
file_util
::
get_file_name
(
file
);
string
ext
=
SHARED_LIB_EXT
;
bool
rc
=
false
;
if
(
!
name
.
compare
(
0
,
3
,
"lib"
))
{
if
(
!
name
.
compare
(
name
.
size
()
-
ext
.
size
(),
ext
.
size
(),
ext
))
{
auto
pos
=
name
.
find
(
"_backend"
);
if
(
pos
!=
name
.
npos
)
{
backend_name
=
name
.
substr
(
3
,
pos
-
3
);
rc
=
true
;
}
}
}
return
rc
;
}
src/ngraph/runtime/backend.hpp
View file @
295ed8eb
...
...
@@ -85,6 +85,7 @@ namespace ngraph
private
:
static
void
*
open_shared_library
(
std
::
string
type
);
static
std
::
map
<
std
::
string
,
std
::
string
>
get_registered_device_map
();
static
bool
is_backend_name
(
const
std
::
string
&
file
,
std
::
string
&
backend_name
);
};
}
}
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