From c567bfb280a9265010df94c20658e53181e9b34f Mon Sep 17 00:00:00 2001 From: whning Date: Fri, 19 Jun 2026 14:38:39 +0800 Subject: [PATCH] =?UTF-8?q?Fix=20#5749:=20GINDataset=20=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- b/python/dgl/data/gindt.py | 18 ++++++++++++++++++ python/dgl/data/gindt.py | 7 ++++--- 2 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 b/python/dgl/data/gindt.py diff --git a/b/python/dgl/data/gindt.py b/b/python/dgl/data/gindt.py new file mode 100644 index 000000000000..9f22c889fc20 --- /dev/null +++ b/b/python/dgl/data/gindt.py @@ -0,0 +1,18 @@ + self.graphs.append(g) + self.labels = F.tensor(self.labels, F.int64) + # if no attr + if not self.nattrs_flag: + if self.verbose: + g.ndata["attr"] = F.tensor(nattrs, F.float32) + self.nattrs_flag = True + g.ndata["label"] = F.tensor(nlabels, F.int64) + if len(self.nlabel_dict) > 1: + self.nlabels_flag = True + if tmp == len(nrow): + # no node attributes + nrow = [int(w) for w in nrow] + elif tmp < len(nrow): + # has node attributes + nrow = [int(w) for w in nrow[:tmp]] + nattr = [float(w) for w in nrow[tmp:]] + nattrs.append(nattr) diff --git a/python/dgl/data/gindt.py b/python/dgl/data/gindt.py index cae9a461a102..8b47bbf9fd6c 100644 --- a/python/dgl/data/gindt.py +++ b/python/dgl/data/gindt.py @@ -221,7 +221,8 @@ def process(self): if tmp == len(nrow): # no node attributes nrow = [int(w) for w in nrow] - elif tmp > len(nrow): + elif tmp < len(nrow): + # has node attributes nrow = [int(w) for w in nrow[:tmp]] nattr = [float(w) for w in nrow[tmp:]] nattrs.append(nattr) @@ -257,7 +258,7 @@ def process(self): g.ndata["attr"] = F.tensor(nattrs, F.float32) self.nattrs_flag = True - g.ndata["label"] = F.tensor(nlabels) + g.ndata["label"] = F.tensor(nlabels, F.int64) if len(self.nlabel_dict) > 1: self.nlabels_flag = True @@ -269,7 +270,7 @@ def process(self): self.graphs.append(g) - self.labels = F.tensor(self.labels) + self.labels = F.tensor(self.labels, F.int64) # if no attr if not self.nattrs_flag: if self.verbose: