Skip to content

Commit eae32ae

Browse files
committed
fix pybind int64 problem
1 parent eaa58a3 commit eae32ae

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

paddle/fluid/distributed/ps/table/graph/graph_node.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
#include <vector>
2121
#include "glog/logging.h"
2222
#include "paddle/fluid/distributed/ps/table/graph/graph_weighted_sampler.h"
23-
#include "paddle/phi/core/enforce.h"
2423
#include "paddle/fluid/string/string_helper.h"
24+
#include "paddle/phi/core/enforce.h"
2525

2626
namespace paddle {
2727
namespace distributed {
@@ -33,6 +33,7 @@ class Node {
3333
virtual ~Node() {}
3434
static int id_size, int_size, weight_size;
3535
uint64_t get_id() { return id; }
36+
int64_t get_py_id() { return (int64_t)id; }
3637
void set_id(uint64_t id) { this->id = id; }
3738

3839
virtual void build_edges(bool is_weighted) {}
@@ -49,7 +50,9 @@ class Node {
4950
virtual void to_buffer(char *buffer, bool need_feature);
5051
virtual void recover_from_buffer(char *buffer);
5152
virtual std::string get_feature(int idx) { return std::string(""); }
52-
virtual int get_feature_ids(int slot_idx, std::vector<uint64_t>* res) const { return 0; }
53+
virtual int get_feature_ids(int slot_idx, std::vector<uint64_t> *res) const {
54+
return 0;
55+
}
5356
virtual void set_feature(int idx, std::string str) {}
5457
virtual void set_feature_size(int size) {}
5558
virtual int get_feature_size() { return 0; }
@@ -99,15 +102,15 @@ class FeatureNode : public Node {
99102
}
100103
}
101104

102-
virtual int get_feature_ids(int slot_idx, std::vector<uint64_t>* res) const {
105+
virtual int get_feature_ids(int slot_idx, std::vector<uint64_t> *res) const {
103106
PADDLE_ENFORCE_NOT_NULL(res);
104107
res->clear();
105108
errno = 0;
106109
if (slot_idx < (int)this->feature.size()) {
107-
const char* feat_str = this->feature[slot_idx].c_str();
110+
const char *feat_str = this->feature[slot_idx].c_str();
108111
auto fields = paddle::string::split_string<std::string>(feat_str, " ");
109-
char* head_ptr = NULL;
110-
for (auto &field: fields) {
112+
char *head_ptr = NULL;
113+
for (auto &field : fields) {
111114
PADDLE_ENFORCE_EQ(field.empty(), false);
112115
uint64_t feasign = strtoull(field.c_str(), &head_ptr, 10);
113116
PADDLE_ENFORCE_EQ(field.c_str() + field.length(), head_ptr);

paddle/fluid/pybind/fleet_py.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,13 @@ void BindHeterClient(py::module* m) {
178178
void BindGraphNode(py::module* m) {
179179
py::class_<GraphNode>(*m, "GraphNode")
180180
.def(py::init<>())
181-
.def("get_id", &GraphNode::get_id)
181+
.def("get_id", &GraphNode::get_py_id)
182182
.def("get_feature", &GraphNode::get_feature);
183183
}
184184
void BindGraphPyFeatureNode(py::module* m) {
185185
py::class_<FeatureNode>(*m, "FeatureNode")
186186
.def(py::init<>())
187-
.def("get_id", &GraphNode::get_id)
187+
.def("get_id", &GraphNode::get_py_id)
188188
.def("get_feature", &GraphNode::get_feature);
189189
}
190190

0 commit comments

Comments
 (0)