forked from tensorflow/tensorflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver_lib.i
More file actions
88 lines (69 loc) · 2.6 KB
/
Copy pathserver_lib.i
File metadata and controls
88 lines (69 loc) · 2.6 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/* Copyright 2016 Google Inc. All Rights Reserved.
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.
==============================================================================*/
%nothread tensorflow::ServerInterface::Join;
%include "tensorflow/python/platform/base.i"
//%newobject tensorflow::NewServer;
%typemap(in) const ServerDef& (tensorflow::ServerDef temp) {
char* c_string;
Py_ssize_t py_size;
if (PyBytes_AsStringAndSize($input, &c_string, &py_size) == -1) {
// Python has raised an error (likely TypeError or UnicodeEncodeError).
SWIG_fail;
}
if (!temp.ParseFromString(string(c_string, py_size))) {
PyErr_SetString(
PyExc_TypeError,
"The ServerDef could not be parsed as a valid protocol buffer");
SWIG_fail;
}
$1 = &temp;
}
%typemap(in, numinputs=0)
std::unique_ptr<tensorflow::ServerInterface>* out_server (
std::unique_ptr<tensorflow::ServerInterface> temp) {
$1 = &temp;
}
%typemap(out) tensorflow::Status tensorflow::NewServer {
if (!$1.ok()) {
RaiseStatusNotOK($1, $descriptor(tensorflow::Status*));
SWIG_fail;
}
}
%typemap(argout) std::unique_ptr<tensorflow::ServerInterface>* out_server {
// TODO(mrry): Convert this to SWIG_POINTER_OWN when the issues with freeing
// a server are fixed.
$result = SWIG_NewPointerObj($1->release(),
$descriptor(tensorflow::ServerInterface*),
0);
}
%feature("except") tensorflow::ServerInterface::Join {
// Let other threads run while we wait for the server to shut down.
Py_BEGIN_ALLOW_THREADS
$action
Py_END_ALLOW_THREADS
}
%{
#include "tensorflow/core/distributed_runtime/server_lib.h"
using tensorflow::ServerDef;
%}
%ignoreall
%unignore tensorflow;
%unignore tensorflow::ServerDef;
%unignore tensorflow::ServerInterface;
%unignore tensorflow::ServerInterface::~ServerInterface;
%unignore tensorflow::ServerInterface::Start;
%unignore tensorflow::ServerInterface::Stop;
%unignore tensorflow::ServerInterface::Join;
%unignore tensorflow::ServerInterface::target;
%unignore tensorflow::NewServer;
%include "tensorflow/core/distributed_runtime/server_lib.h"
%unignoreall