aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow
diff options
context:
space:
mode:
authorGravatar Asim Shankar <ashankar@google.com>2016-11-14 15:54:33 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2016-11-14 16:08:54 -0800
commita374ea13c0c7b9598b5ada851b43655f895a578e (patch)
tree0eff063ac40e04115ce5c630ddf02ddbf69abe94 /tensorflow
parent33c61f3e5a92c371785864b14ce97386d65ade3b (diff)
C API: Add TF_Version(), akin to __version__ in python.
Since we envision a binary release of the C-library and other language bindings linking against it, will be useful to have version information when any debugging needs to be done. There is a slight problem in that TF_VERSION_STRING will point to the latest release when compiled from source at HEAD - which might be confusing as the version string will not represent true state of the libraries. But that seems like something to be dealt with in version.h independently of exporting this TF_Version() function. While at it, make the version string accessible in the Go API. TensorFlow follows semantic versioning, but parsing the version string into MAJOR, MINOR and PATCH is left as an excercise to the user (who can use any number of semantic version parsing libraries out there). Change: 139132778
Diffstat (limited to 'tensorflow')
-rw-r--r--tensorflow/c/c_api.cc4
-rw-r--r--tensorflow/c/c_api.h5
-rw-r--r--tensorflow/c/c_api_test.cc2
-rw-r--r--tensorflow/go/version.go23
4 files changed, 34 insertions, 0 deletions
diff --git a/tensorflow/c/c_api.cc b/tensorflow/c/c_api.cc
index 600e0738d6..2a9bec4281 100644
--- a/tensorflow/c/c_api.cc
+++ b/tensorflow/c/c_api.cc
@@ -41,6 +41,7 @@ limitations under the License.
#include "tensorflow/core/platform/thread_annotations.h"
#include "tensorflow/core/platform/types.h"
#include "tensorflow/core/public/session.h"
+#include "tensorflow/core/public/version.h"
// The implementation below is at the top level instead of the
// brain namespace because we are defining 'extern "C"' functions.
@@ -77,6 +78,9 @@ using tensorflow::TensorShapeProto;
extern "C" {
// --------------------------------------------------------------------------
+const char* TF_Version() { return TF_VERSION_STRING; }
+
+// --------------------------------------------------------------------------
struct TF_Status {
Status status;
};
diff --git a/tensorflow/c/c_api.h b/tensorflow/c/c_api.h
index 1b4d3990f9..aa30928ca0 100644
--- a/tensorflow/c/c_api.h
+++ b/tensorflow/c/c_api.h
@@ -69,6 +69,11 @@ extern "C" {
#endif
// --------------------------------------------------------------------------
+// TF_Version returns a string describing version information of the
+// TensorFlow library. TensorFlow using semantic versioning.
+const char* TF_Version();
+
+// --------------------------------------------------------------------------
// TF_DataType holds the type for a scalar value. E.g., one slot in a tensor.
// The enum values here are identical to corresponding values in types.proto.
typedef enum {
diff --git a/tensorflow/c/c_api_test.cc b/tensorflow/c/c_api_test.cc
index 2b46c6f1e6..ca1324033d 100644
--- a/tensorflow/c/c_api_test.cc
+++ b/tensorflow/c/c_api_test.cc
@@ -45,6 +45,8 @@ TF_Tensor* TF_Tensor_EncodeStrings(const Tensor& src);
namespace {
+TEST(CAPI, Version) { EXPECT_NE("", string(TF_Version())); }
+
TEST(CAPI, Status) {
TF_Status* s = TF_NewStatus();
EXPECT_EQ(TF_OK, TF_GetCode(s));
diff --git a/tensorflow/go/version.go b/tensorflow/go/version.go
new file mode 100644
index 0000000000..c777c44bea
--- /dev/null
+++ b/tensorflow/go/version.go
@@ -0,0 +1,23 @@
+// Copyright 2016 The TensorFlow Authors. 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.
+
+package tensorflow
+
+// #include <string.h>
+// #include "tensorflow/c/c_api.h"
+import "C"
+
+// Version returns a string describing the version of the underlying TensorFlow
+// runtime.
+func Version() string { return C.GoString(C.TF_Version()) }