forked from onnx/onnx-tensorrt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nv_onnx_parser_bindings.i
46 lines (38 loc) · 1.07 KB
/
nv_onnx_parser_bindings.i
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* NvOnnxParser.i
* Interface file for generating Python wrapper for
* the onnx parser class
*/
%module nv_onnx_parser_bindings
%{
#define SWIG_FILE_WITH_INIT
#include "NvOnnxParser.h"
%}
%feature("director") nvonnxparser::IParser;
%feature("director") nvonnxparser::IParserError;
%rename("%(utitle)s", %$isfunction) "";
%rename("%(regex:/^(I)(.*)/\\2/)s", %$isclass) "";
// CamelCase to snake_case
%rename("%(utitle)s", %$isfunction) "";
// remove I from interface class
%rename("%(regex:/^(I)(.*)/\\2/)s", %$isclass) "";
// support int64_t
%include "stdint.i"
%typemap(in) (void const* serialized_onnx_model,
size_t serialized_onnx_model_size) {
if (!PyString_Check($input)) {
PyErr_SetString(PyExc_ValueError, "Expecting a string");
return NULL;
}
$1 = (void *) PyString_AsString($input);
$2 = PyString_Size($input);
}
%unrefobject nvonnxparser::IParser {
$this->destroy();
}
%newobject nvonnxparser::createParser;
%delobject nvonnxparser::IParser::destroy;
%include "NvOnnxParser.h"