File tree Expand file tree Collapse file tree 5 files changed +60
-1
lines changed Expand file tree Collapse file tree 5 files changed +60
-1
lines changed Original file line number Diff line number Diff line change 1
-
2
1
#windows treat symbolic file as a real file, which is different with unix
3
2
#We create a hidden file and compile it instead of origin source file.
4
3
function (windows_symbolic TARGET )
@@ -207,3 +206,24 @@ endif (NOT WIN32)
207
206
208
207
cc_library (dlpack_tensor SRCS dlpack_tensor.cc DEPS tensor dlpack )
209
208
cc_test (dlpack_tensor_test SRCS dlpack_tensor_test.cc DEPS dlpack_tensor glog )
209
+
210
+ # Get the current working branch
211
+ execute_process (
212
+ COMMAND git rev-parse --abbrev-ref HEAD
213
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
214
+ OUTPUT_VARIABLE PADDLE_BRANCH
215
+ OUTPUT_STRIP_TRAILING_WHITESPACE
216
+ )
217
+
218
+ # Get the latest abbreviated commit hash of the working branch
219
+ execute_process (
220
+ COMMAND git log -1 --format=%h
221
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
222
+ OUTPUT_VARIABLE PADDLE_COMMIT
223
+ OUTPUT_STRIP_TRAILING_WHITESPACE
224
+ )
225
+
226
+ message (STATUS "commit: ${PADDLE_COMMIT} " )
227
+ message (STATUS "branch: ${PADDLE_BRANCH} " )
228
+
229
+ configure_file (commit.h.in commit.h )
Original file line number Diff line number Diff line change
1
+ #pragma once
2
+
3
+ #include <string>
4
+
5
+ namespace paddle {
6
+ namespace framework {
7
+
8
+ static std ::string paddle_commit () {
9
+ return "@PADDLE_COMMIT@" ;
10
+ }
11
+
12
+ static std ::string paddle_compile_branch () {
13
+ return "@PADDLE_BRANCH@" ;
14
+ }
15
+
16
+ static std ::string paddle_version () {
17
+ return "@PADDLE_VERSION@" ;
18
+ }
19
+
20
+ } // namespace framework
21
+ } // namespace paddle
Original file line number Diff line number Diff line change 12
12
// See the License for the specific language governing permissions and
13
13
// limitations under the License.
14
14
15
+ #include < sstream>
16
+ #include " paddle/fluid/framework/commit.h"
15
17
#include " paddle/fluid/framework/lod_tensor.h"
16
18
#include " paddle/fluid/framework/scope.h"
17
19
#include " paddle/fluid/inference/api/paddle_inference_api.h"
@@ -97,4 +99,12 @@ void PaddleBuf::Free() {
97
99
}
98
100
}
99
101
102
+ std::string get_version () {
103
+ std::stringstream ss;
104
+ ss << " version: " << framework::paddle_version () << " \n " ;
105
+ ss << " commit: " << framework::paddle_commit () << " \n " ;
106
+ ss << " branch: " << framework::paddle_compile_branch () << " \n " ;
107
+ return ss.str ();
108
+ }
109
+
100
110
} // namespace paddle
Original file line number Diff line number Diff line change @@ -61,4 +61,10 @@ TEST(paddle_inference_api, demo) {
61
61
predictor->Run ({}, &outputs);
62
62
}
63
63
64
+ TEST (paddle_inference_api, get_version) {
65
+ LOG (INFO) << " paddle version:\n " << get_version ();
66
+ auto version = get_version ();
67
+ ASSERT_FALSE (version.empty ());
68
+ }
69
+
64
70
} // namespace paddle
Original file line number Diff line number Diff line change @@ -296,4 +296,6 @@ std::unique_ptr<PaddlePredictor> CreatePaddlePredictor(const ConfigT& config);
296
296
297
297
int PaddleDtypeSize (PaddleDType dtype);
298
298
299
+ std::string get_version ();
300
+
299
301
} // namespace paddle
You can’t perform that action at this time.
0 commit comments