1+ /* Copyright 2025 The TensorFlow Authors. All Rights Reserved.
2+
3+ Licensed under the Apache License, Version 2.0 (the "License");
4+ you may not use this file except in compliance with the License.
5+ You may obtain a copy of the License at
6+
7+ http://www.apache.org/licenses/LICENSE-2.0
8+
9+ Unless required by applicable law or agreed to in writing, software
10+ distributed under the License is distributed on an "AS IS" BASIS,
11+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ See the License for the specific language governing permissions and
13+ limitations under the License.
14+ ==============================================================================*/
15+
16+ #ifdef _WIN32
17+
18+ #include " tensorflow/c/c_api.h"
19+ #include " tensorflow/c/c_api_experimental.h"
20+
21+ // On Windows, the TensorFlow C library currently does not export TFE_GetServerDef.
22+ // Provide a local stub so that the JNI native library can link successfully.
23+ // The stub simply sets the status to TF_UNIMPLEMENTED and returns an empty
24+ // TF_Buffer.
25+ extern " C" TF_Buffer* TFE_GetServerDef (const char * text_proto, TF_Status* status) {
26+ if (status != nullptr ) {
27+ TF_SetStatus (status, TF_UNIMPLEMENTED,
28+ " TFE_GetServerDef is not available in the Windows build of libtensorflow." );
29+ }
30+ // Allocate an empty TF_Buffer on the heap so that callers can still call
31+ // TF_DeleteBuffer() on the returned pointer safely.
32+ TF_Buffer* buf = static_cast <TF_Buffer*>(malloc (sizeof (TF_Buffer)));
33+ if (buf != nullptr ) {
34+ buf->data = nullptr ;
35+ buf->length = 0 ;
36+ buf->data_deallocator = nullptr ;
37+ }
38+ return buf;
39+ }
40+
41+ #endif // _WIN32
0 commit comments