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
b52a7798
Unverified
Commit
b52a7798
authored
Nov 09, 2018
by
Artur Wojcik
Committed by
GitHub
Nov 09, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
onnxifi: add exceptions for statuses (#1994)
Signed-off-by:
Artur Wojcik
<
artur.wojcik@intel.com
>
parent
65355a17
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
337 additions
and
10 deletions
+337
-10
CMakeLists.txt
src/ngraph/frontend/onnxifi/CMakeLists.txt
+8
-2
backend_manager.cpp
src/ngraph/frontend/onnxifi/backend_manager.cpp
+3
-2
exceptions.hpp
src/ngraph/frontend/onnxifi/exceptions.hpp
+323
-0
onnxifi.cpp
src/ngraph/frontend/onnxifi/onnxifi.cpp
+3
-6
No files found.
src/ngraph/frontend/onnxifi/CMakeLists.txt
View file @
b52a7798
...
...
@@ -14,11 +14,17 @@
# limitations under the License.
# ******************************************************************************
add_library
(
onnxifi-ngraph SHARED onnxifi.cpp backend.hpp backend_manager.hpp backend_manager.cpp
)
add_library
(
onnxifi-ngraph SHARED
onnxifi.cpp
backend.hpp
backend_manager.hpp
backend_manager.cpp
exceptions.hpp
)
target_link_libraries
(
onnxifi-ngraph PRIVATE ngraph
)
add_dependencies
(
onnxifi-ngraph onnx::libonnx
)
target_include_directories
(
onnxifi-ngraph SYSTEM PRIVATE
${
ONNX_INCLUDE_DIR
}
)
target_include_directories
(
onnxifi-ngraph SYSTEM PRIVATE
${
ONNX_INCLUDE_DIR
}
${
ONNX_IMPORT_INCLUDE_DIR
}
)
set
(
ONNXIFI_VERSION
${
NGRAPH_VERSION
}
)
set
(
ONNXIFI_ABI_VERSION 1
)
...
...
src/ngraph/frontend/onnxifi/backend_manager.cpp
View file @
b52a7798
...
...
@@ -23,6 +23,7 @@
#include "backend.hpp"
#include "backend_manager.hpp"
#include "exceptions.hpp"
namespace
ngraph
{
...
...
@@ -49,13 +50,13 @@ namespace ngraph
{
if
(
count
==
nullptr
)
{
throw
st
d
::
invalid_argument
{
"null pointer"
};
throw
st
atus
::
null_pointer
{
};
}
std
::
size_t
requested
{
*
count
};
*
count
=
m_registered_backends
.
size
();
if
((
requested
<
*
count
)
||
(
backend_ids
==
nullptr
))
{
throw
st
d
::
length_error
{
"not enough space"
};
throw
st
atus
::
fallback
{
};
}
{
std
::
lock_guard
<
decltype
(
m_mutex
)
>
lock
{
m_mutex
};
...
...
src/ngraph/frontend/onnxifi/exceptions.hpp
0 → 100644
View file @
b52a7798
//*****************************************************************************
// 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.
//*****************************************************************************
#pragma once
#include <onnxifi.h>
namespace
ngraph
{
namespace
onnxifi
{
namespace
status
{
struct
runtime
{
explicit
constexpr
runtime
(
::
onnxStatus
status
)
:
m_status
{
status
}
{
}
constexpr
::
onnxStatus
get_status
()
const
{
return
m_status
;
}
private
:
::
onnxStatus
m_status
;
};
struct
internal
:
runtime
{
constexpr
internal
()
:
runtime
{
ONNXIFI_STATUS_INTERNAL_ERROR
}
{
}
};
struct
fallback
:
runtime
{
constexpr
fallback
()
:
runtime
{
ONNXIFI_STATUS_FALLBACK
}
{
}
};
struct
invalid_id
:
runtime
{
constexpr
invalid_id
()
:
runtime
{
ONNXIFI_STATUS_INVALID_ID
}
{
}
};
struct
invalid_size
:
runtime
{
constexpr
invalid_size
()
:
runtime
{
ONNXIFI_STATUS_INVALID_SIZE
}
{
}
};
struct
null_pointer
:
runtime
{
constexpr
null_pointer
()
:
runtime
{
ONNXIFI_STATUS_INVALID_POINTER
}
{
}
};
struct
invalid_protobuf
:
runtime
{
constexpr
invalid_protobuf
()
:
runtime
{
ONNXIFI_STATUS_INVALID_PROTOBUF
}
{
}
};
struct
invalid_model
:
runtime
{
constexpr
invalid_model
()
:
runtime
{
ONNXIFI_STATUS_INVALID_MODEL
}
{
}
};
struct
invalid_backend
:
runtime
{
constexpr
invalid_backend
()
:
runtime
{
ONNXIFI_STATUS_INVALID_BACKEND
}
{
}
};
struct
invalid_graph
:
runtime
{
constexpr
invalid_graph
()
:
runtime
{
ONNXIFI_STATUS_INVALID_GRAPH
}
{
}
};
struct
invalid_event
:
runtime
{
constexpr
invalid_event
()
:
runtime
{
ONNXIFI_STATUS_INVALID_EVENT
}
{
}
};
struct
invalid_state
:
runtime
{
constexpr
invalid_state
()
:
runtime
{
ONNXIFI_STATUS_INVALID_STATE
}
{
}
};
struct
invalid_name
:
runtime
{
constexpr
invalid_name
()
:
runtime
{
ONNXIFI_STATUS_INVALID_NAME
}
{
}
};
struct
invalid_shape
:
runtime
{
constexpr
invalid_shape
()
:
runtime
{
ONNXIFI_STATUS_INVALID_SHAPE
}
{
}
};
struct
invalid_datatype
:
runtime
{
constexpr
invalid_datatype
()
:
runtime
{
ONNXIFI_STATUS_INVALID_DATATYPE
}
{
}
};
struct
invalid_memory_type
:
runtime
{
constexpr
invalid_memory_type
()
:
runtime
{
ONNXIFI_STATUS_INVALID_MEMORY_TYPE
}
{
}
};
struct
invalid_memory_location
:
runtime
{
constexpr
invalid_memory_location
()
:
runtime
{
ONNXIFI_STATUS_INVALID_MEMORY_LOCATION
}
{
}
};
struct
invalid_fence_type
:
runtime
{
constexpr
invalid_fence_type
()
:
runtime
{
ONNXIFI_STATUS_INVALID_FENCE_TYPE
}
{
}
};
struct
invalid_property
:
runtime
{
constexpr
invalid_property
()
:
runtime
{
ONNXIFI_STATUS_INVALID_PROPERTY
}
{
}
};
struct
unsupported_tag
:
runtime
{
constexpr
unsupported_tag
()
:
runtime
{
ONNXIFI_STATUS_UNSUPPORTED_TAG
}
{
}
};
struct
unsupported_version
:
runtime
{
constexpr
unsupported_version
()
:
runtime
{
ONNXIFI_STATUS_UNSUPPORTED_VERSION
}
{
}
};
struct
unsupported_operator
:
runtime
{
constexpr
unsupported_operator
()
:
runtime
{
ONNXIFI_STATUS_UNSUPPORTED_OPERATOR
}
{
}
};
struct
unsupported_attribute
:
runtime
{
constexpr
unsupported_attribute
()
:
runtime
{
ONNXIFI_STATUS_UNSUPPORTED_ATTRIBUTE
}
{
}
};
struct
unsupported_shape
:
runtime
{
constexpr
unsupported_shape
()
:
runtime
{
ONNXIFI_STATUS_UNSUPPORTED_SHAPE
}
{
}
};
struct
unsupported_datatype
:
runtime
{
constexpr
unsupported_datatype
()
:
runtime
{
ONNXIFI_STATUS_UNSUPPORTED_DATATYPE
}
{
}
};
struct
unsupported_memory_type
:
runtime
{
constexpr
unsupported_memory_type
()
:
runtime
{
ONNXIFI_STATUS_UNSUPPORTED_MEMORY_TYPE
}
{
}
};
struct
unsupported_fence_type
:
runtime
{
constexpr
unsupported_fence_type
()
:
runtime
{
ONNXIFI_STATUS_UNSUPPORTED_FENCE_TYPE
}
{
}
};
struct
unsupported_property
:
runtime
{
constexpr
unsupported_property
()
:
runtime
{
ONNXIFI_STATUS_UNSUPPORTED_PROPERTY
}
{
}
};
struct
unidentified_name
:
runtime
{
constexpr
unidentified_name
()
:
runtime
{
ONNXIFI_STATUS_UNIDENTIFIED_NAME
}
{
}
};
struct
mismatching_shape
:
runtime
{
constexpr
mismatching_shape
()
:
runtime
{
ONNXIFI_STATUS_MISMATCHING_SHAPE
}
{
}
};
struct
mismatching_datatype
:
runtime
{
constexpr
mismatching_datatype
()
:
runtime
{
ONNXIFI_STATUS_MISMATCHING_DATATYPE
}
{
}
};
struct
no_system_memory
:
runtime
{
constexpr
no_system_memory
()
:
runtime
{
ONNXIFI_STATUS_NO_SYSTEM_MEMORY
}
{
}
};
struct
no_device_memory
:
runtime
{
constexpr
no_device_memory
()
:
runtime
{
ONNXIFI_STATUS_NO_DEVICE_MEMORY
}
{
}
};
struct
no_system_resources
:
runtime
{
constexpr
no_system_resources
()
:
runtime
{
ONNXIFI_STATUS_NO_SYSTEM_RESOURCES
}
{
}
};
struct
no_device_resources
:
runtime
{
constexpr
no_device_resources
()
:
runtime
{
ONNXIFI_STATUS_NO_DEVICE_RESOURCES
}
{
}
};
struct
backend_unavailable
:
runtime
{
constexpr
backend_unavailable
()
:
runtime
{
ONNXIFI_STATUS_BACKEND_UNAVAILABLE
}
{
}
};
}
// namespace status
}
// namespace onnxifi
}
// namespace ngraph
src/ngraph/frontend/onnxifi/onnxifi.cpp
View file @
b52a7798
...
...
@@ -21,6 +21,7 @@
#include <onnxifi.h>
#include "backend_manager.hpp"
#include "exceptions.hpp"
using
namespace
ngraph
::
onnxifi
;
...
...
@@ -34,18 +35,14 @@ ONNXIFI_PUBLIC ONNXIFI_CHECK_RESULT onnxStatus ONNXIFI_ABI
BackendManager
::
get_backend_ids
(
backendIDs
,
numBackends
);
return
ONNXIFI_STATUS_SUCCESS
;
}
catch
(
const
st
d
::
invalid_argument
&
)
catch
(
const
st
atus
::
runtime
&
e
)
{
return
ONNXIFI_STATUS_INVALID_POINTER
;
return
e
.
get_status
()
;
}
catch
(
const
std
::
bad_alloc
&
)
{
return
ONNXIFI_STATUS_NO_SYSTEM_MEMORY
;
}
catch
(
const
std
::
length_error
&
)
{
return
ONNXIFI_STATUS_FALLBACK
;
}
catch
(...)
{
return
ONNXIFI_STATUS_INTERNAL_ERROR
;
...
...
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