diff --git a/tensorflow-core/tensorflow-core-native/src/main/native/org/tensorflow/internal/c_api/tfj_gradients.h b/tensorflow-core/tensorflow-core-native/src/main/native/org/tensorflow/internal/c_api/tfj_gradients.h index 9743b9d4e15..1998b781c9e 100644 --- a/tensorflow-core/tensorflow-core-native/src/main/native/org/tensorflow/internal/c_api/tfj_gradients.h +++ b/tensorflow-core/tensorflow-core-native/src/main/native/org/tensorflow/internal/c_api/tfj_gradients.h @@ -19,9 +19,7 @@ limitations under the License. #include "tfj_scope.h" #include "tensorflow/c/c_api.h" -#ifdef __cplusplus extern "C" { -#endif /// Function to be implemented on the JVM side to be called back by the native library when it is time to attach gradient operations for the given op, graph and scope. /// @@ -40,9 +38,8 @@ TF_CAPI_EXPORT extern bool TFJ_HasGradient(const char* op_type); /// Returns true if the function has been registered successfully, false if operation failed or if gradient function is already registered to that `op_type`. TF_CAPI_EXPORT extern bool TFJ_RegisterCustomGradient(const char* op_type, TFJ_GradFuncAdapter custom_gradient_adapter); -#ifdef __cplusplus } /* end extern "C" */ + #include "tfj_gradients_impl.cc" // include CC file in its header to compile it with JavaCPP -#endif #endif // TENSORFLOW_JAVA_GRADIENTS_H_ diff --git a/tensorflow-core/tensorflow-core-native/src/main/native/org/tensorflow/internal/c_api/tfj_graph.h b/tensorflow-core/tensorflow-core-native/src/main/native/org/tensorflow/internal/c_api/tfj_graph.h index ebcae56118c..8ee17218d36 100644 --- a/tensorflow-core/tensorflow-core-native/src/main/native/org/tensorflow/internal/c_api/tfj_graph.h +++ b/tensorflow-core/tensorflow-core-native/src/main/native/org/tensorflow/internal/c_api/tfj_graph.h @@ -18,9 +18,7 @@ limitations under the License. #include "tensorflow/c/c_api.h" -#ifdef __cplusplus extern "C" { -#endif /// Unique identifier of a TensorFlow graph instance typedef void* TFJ_GraphId; @@ -32,9 +30,8 @@ TF_CAPI_EXPORT extern TFJ_GraphId TFJ_GetGraphId(const TF_Graph* g); /// This is particularly useful for preventing custom gradient operations to pollute the graph namespace. TF_CAPI_EXPORT extern void TFJ_UnmapOperationName(TF_Graph* g, TF_Operation* operation); -#ifdef __cplusplus } /* end extern "C" */ + #include "tfj_graph_impl.cc" // include CC file in its header to compile it with JavaCPP -#endif #endif // TENSORFLOW_JAVA_GRAPH_H_ diff --git a/tensorflow-core/tensorflow-core-native/src/main/native/org/tensorflow/internal/c_api/tfj_graph_impl.cc b/tensorflow-core/tensorflow-core-native/src/main/native/org/tensorflow/internal/c_api/tfj_graph_impl.cc index b13572b655c..d21bb0551c1 100644 --- a/tensorflow-core/tensorflow-core-native/src/main/native/org/tensorflow/internal/c_api/tfj_graph_impl.cc +++ b/tensorflow-core/tensorflow-core-native/src/main/native/org/tensorflow/internal/c_api/tfj_graph_impl.cc @@ -13,6 +13,8 @@ See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ +#ifndef _WIN32 + #include "tensorflow/c/c_api_internal.h" extern "C" { @@ -28,3 +30,18 @@ void TFJ_UnmapOperationName(TF_Graph* g, TF_Operation* operation) { } } /* end extern "C" */ + +#else // #indef _WIN32 + +/* This extension is not available on Windows */ +extern "C" { + +TFJ_GraphId TFJ_GetGraphId(const TF_Graph* g) { + return NULL; +} + +void TFJ_UnmapOperationName(TF_Graph* g, TF_Operation* operation) {} + +} /* end extern "C" */ + +#endif // #indef _WIN32 diff --git a/tensorflow-core/tensorflow-core-native/src/main/native/org/tensorflow/internal/c_api/tfj_scope.h b/tensorflow-core/tensorflow-core-native/src/main/native/org/tensorflow/internal/c_api/tfj_scope.h index d201450f32e..9bc6ace216e 100644 --- a/tensorflow-core/tensorflow-core-native/src/main/native/org/tensorflow/internal/c_api/tfj_scope.h +++ b/tensorflow-core/tensorflow-core-native/src/main/native/org/tensorflow/internal/c_api/tfj_scope.h @@ -18,9 +18,7 @@ limitations under the License. #include "tensorflow/c/c_api.h" -#ifdef __cplusplus extern "C" { -#endif typedef struct TFJ_Scope TFJ_Scope; @@ -51,9 +49,8 @@ TF_CAPI_EXPORT extern TFJ_Scope TFJ_NewScopeWithDevice(const TFJ_Scope* scope, c /// Note: returns C++ std string to prevent buffer to be freed up before consuming the characters TF_CAPI_EXPORT extern std::string TFJ_GetUniqueNameForOp(const TFJ_Scope* scope, const char* default_name); -#ifdef __cplusplus } /* end extern "C" */ + #include "tfj_scope_impl.cc" // include CC file in its header to compile it with JavaCPP -#endif #endif // TENSORFLOW_JAVA_SCOPE_H_