diff --git a/examples/pytorch/appnp/train.py b/examples/pytorch/appnp/train.py index f08cdc29cb94..59d9c5899b4e 100644 --- a/examples/pytorch/appnp/train.py +++ b/examples/pytorch/appnp/train.py @@ -25,9 +25,14 @@ def main(args): data = load_data(args) features = torch.FloatTensor(data.features) labels = torch.LongTensor(data.labels) - train_mask = torch.ByteTensor(data.train_mask) - val_mask = torch.ByteTensor(data.val_mask) - test_mask = torch.ByteTensor(data.test_mask) + if hasattr(torch, 'BoolTensor'): + train_mask = torch.BoolTensor(data.train_mask) + val_mask = torch.BoolTensor(data.val_mask) + test_mask = torch.BoolTensor(data.test_mask) + else: + train_mask = torch.ByteTensor(data.train_mask) + val_mask = torch.ByteTensor(data.val_mask) + test_mask = torch.ByteTensor(data.test_mask) in_feats = features.shape[1] n_classes = data.num_labels n_edges = data.graph.number_of_edges() diff --git a/examples/pytorch/cluster_gcn/cluster_gcn.py b/examples/pytorch/cluster_gcn/cluster_gcn.py index 079f2306866c..6fa96b412bb9 100644 --- a/examples/pytorch/cluster_gcn/cluster_gcn.py +++ b/examples/pytorch/cluster_gcn/cluster_gcn.py @@ -46,9 +46,14 @@ def main(args): labels = torch.LongTensor(data.labels) else: labels = torch.FloatTensor(data.labels) - train_mask = torch.ByteTensor(data.train_mask).type(torch.bool) - val_mask = torch.ByteTensor(data.val_mask).type(torch.bool) - test_mask = torch.ByteTensor(data.test_mask).type(torch.bool) + if hasattr(torch, 'BoolTensor'): + train_mask = torch.BoolTensor(data.train_mask) + val_mask = torch.BoolTensor(data.val_mask) + test_mask = torch.BoolTensor(data.test_mask) + else: + train_mask = torch.ByteTensor(data.train_mask) + val_mask = torch.ByteTensor(data.val_mask) + test_mask = torch.ByteTensor(data.test_mask) in_feats = features.shape[1] n_classes = data.num_labels n_edges = data.graph.number_of_edges() diff --git a/examples/pytorch/dgi/train.py b/examples/pytorch/dgi/train.py index 129a181706b8..9fd0efd3c26d 100644 --- a/examples/pytorch/dgi/train.py +++ b/examples/pytorch/dgi/train.py @@ -22,9 +22,14 @@ def main(args): data = load_data(args) features = torch.FloatTensor(data.features) labels = torch.LongTensor(data.labels) - train_mask = torch.ByteTensor(data.train_mask) - val_mask = torch.ByteTensor(data.val_mask) - test_mask = torch.ByteTensor(data.test_mask) + if hasattr(torch, 'BoolTensor'): + train_mask = torch.BoolTensor(data.train_mask) + val_mask = torch.BoolTensor(data.val_mask) + test_mask = torch.BoolTensor(data.test_mask) + else: + train_mask = torch.ByteTensor(data.train_mask) + val_mask = torch.ByteTensor(data.val_mask) + test_mask = torch.ByteTensor(data.test_mask) in_feats = features.shape[1] n_classes = data.num_labels n_edges = data.graph.number_of_edges() diff --git a/examples/pytorch/gat/train.py b/examples/pytorch/gat/train.py index e77d8fc3bfcc..d79be0d105ea 100644 --- a/examples/pytorch/gat/train.py +++ b/examples/pytorch/gat/train.py @@ -41,9 +41,14 @@ def main(args): data = load_data(args) features = torch.FloatTensor(data.features) labels = torch.LongTensor(data.labels) - train_mask = torch.ByteTensor(data.train_mask) - val_mask = torch.ByteTensor(data.val_mask) - test_mask = torch.ByteTensor(data.test_mask) + if hasattr(torch, 'BoolTensor'): + train_mask = torch.BoolTensor(data.train_mask) + val_mask = torch.BoolTensor(data.val_mask) + test_mask = torch.BoolTensor(data.test_mask) + else: + train_mask = torch.ByteTensor(data.train_mask) + val_mask = torch.ByteTensor(data.val_mask) + test_mask = torch.ByteTensor(data.test_mask) num_feats = features.shape[1] n_classes = data.num_labels n_edges = data.graph.number_of_edges() diff --git a/examples/pytorch/gcn/gcn_mp.py b/examples/pytorch/gcn/gcn_mp.py index 24affad94840..550aef276fb1 100644 --- a/examples/pytorch/gcn/gcn_mp.py +++ b/examples/pytorch/gcn/gcn_mp.py @@ -118,9 +118,14 @@ def main(args): data = load_data(args) features = torch.FloatTensor(data.features) labels = torch.LongTensor(data.labels) - train_mask = torch.ByteTensor(data.train_mask) - val_mask = torch.ByteTensor(data.val_mask) - test_mask = torch.ByteTensor(data.test_mask) + if hasattr(torch, 'BoolTensor'): + train_mask = torch.BoolTensor(data.train_mask) + val_mask = torch.BoolTensor(data.val_mask) + test_mask = torch.BoolTensor(data.test_mask) + else: + train_mask = torch.ByteTensor(data.train_mask) + val_mask = torch.ByteTensor(data.val_mask) + test_mask = torch.ByteTensor(data.test_mask) in_feats = features.shape[1] n_classes = data.num_labels n_edges = data.graph.number_of_edges() diff --git a/examples/pytorch/gcn/train.py b/examples/pytorch/gcn/train.py index be90b20c5ef4..8a82c34a3430 100644 --- a/examples/pytorch/gcn/train.py +++ b/examples/pytorch/gcn/train.py @@ -25,9 +25,14 @@ def main(args): data = load_data(args) features = torch.FloatTensor(data.features) labels = torch.LongTensor(data.labels) - train_mask = torch.ByteTensor(data.train_mask) - val_mask = torch.ByteTensor(data.val_mask) - test_mask = torch.ByteTensor(data.test_mask) + if hasattr(torch, 'BoolTensor'): + train_mask = torch.BoolTensor(data.train_mask) + val_mask = torch.BoolTensor(data.val_mask) + test_mask = torch.BoolTensor(data.test_mask) + else: + train_mask = torch.ByteTensor(data.train_mask) + val_mask = torch.ByteTensor(data.val_mask) + test_mask = torch.ByteTensor(data.test_mask) in_feats = features.shape[1] n_classes = data.num_labels n_edges = data.graph.number_of_edges() diff --git a/examples/pytorch/graphsage/graphsage.py b/examples/pytorch/graphsage/graphsage.py index 1a4a22eea78b..b5fd307d56c4 100644 --- a/examples/pytorch/graphsage/graphsage.py +++ b/examples/pytorch/graphsage/graphsage.py @@ -60,9 +60,14 @@ def main(args): data = load_data(args) features = torch.FloatTensor(data.features) labels = torch.LongTensor(data.labels) - train_mask = torch.ByteTensor(data.train_mask) - val_mask = torch.ByteTensor(data.val_mask) - test_mask = torch.ByteTensor(data.test_mask) + if hasattr(torch, 'BoolTensor'): + train_mask = torch.BoolTensor(data.train_mask) + val_mask = torch.BoolTensor(data.val_mask) + test_mask = torch.BoolTensor(data.test_mask) + else: + train_mask = torch.ByteTensor(data.train_mask) + val_mask = torch.ByteTensor(data.val_mask) + test_mask = torch.ByteTensor(data.test_mask) in_feats = features.shape[1] n_classes = data.num_labels n_edges = data.graph.number_of_edges() diff --git a/examples/pytorch/model_zoo/citation_network/run.py b/examples/pytorch/model_zoo/citation_network/run.py index cc2648204c2d..fb55e5961b06 100644 --- a/examples/pytorch/model_zoo/citation_network/run.py +++ b/examples/pytorch/model_zoo/citation_network/run.py @@ -45,9 +45,14 @@ def main(args): data = load_data(args) features = torch.FloatTensor(data.features) labels = torch.LongTensor(data.labels) - train_mask = torch.ByteTensor(data.train_mask) - val_mask = torch.ByteTensor(data.val_mask) - test_mask = torch.ByteTensor(data.test_mask) + if hasattr(torch, 'BoolTensor'): + train_mask = torch.BoolTensor(data.train_mask) + val_mask = torch.BoolTensor(data.val_mask) + test_mask = torch.BoolTensor(data.test_mask) + else: + train_mask = torch.ByteTensor(data.train_mask) + val_mask = torch.ByteTensor(data.val_mask) + test_mask = torch.ByteTensor(data.test_mask) in_feats = features.shape[1] n_classes = data.num_labels n_edges = data.graph.number_of_edges() @@ -147,4 +152,4 @@ def main(args): help="graph self-loop (default=False)") args = parser.parse_args() print(args) - main(args) \ No newline at end of file + main(args) diff --git a/examples/pytorch/sampling/dis_sampling/gcn_cv_sc_train.py b/examples/pytorch/sampling/dis_sampling/gcn_cv_sc_train.py index 221e336fba9f..be3cae40612e 100644 --- a/examples/pytorch/sampling/dis_sampling/gcn_cv_sc_train.py +++ b/examples/pytorch/sampling/dis_sampling/gcn_cv_sc_train.py @@ -24,9 +24,14 @@ def main(args): features = torch.FloatTensor(data.features) labels = torch.LongTensor(data.labels) - train_mask = torch.ByteTensor(data.train_mask) - val_mask = torch.ByteTensor(data.val_mask) - test_mask = torch.ByteTensor(data.test_mask) + if hasattr(torch, 'BoolTensor'): + train_mask = torch.BoolTensor(data.train_mask) + val_mask = torch.BoolTensor(data.val_mask) + test_mask = torch.BoolTensor(data.test_mask) + else: + train_mask = torch.ByteTensor(data.train_mask) + val_mask = torch.ByteTensor(data.val_mask) + test_mask = torch.ByteTensor(data.test_mask) in_feats = features.shape[1] n_classes = data.num_labels n_edges = data.graph.number_of_edges() diff --git a/examples/pytorch/sampling/dis_sampling/gcn_ns_sc_train.py b/examples/pytorch/sampling/dis_sampling/gcn_ns_sc_train.py index 7134cf56e6b5..d2665ff066a3 100644 --- a/examples/pytorch/sampling/dis_sampling/gcn_ns_sc_train.py +++ b/examples/pytorch/sampling/dis_sampling/gcn_ns_sc_train.py @@ -25,9 +25,14 @@ def main(args): features = torch.FloatTensor(data.features) labels = torch.LongTensor(data.labels) - train_mask = torch.ByteTensor(data.train_mask) - val_mask = torch.ByteTensor(data.val_mask) - test_mask = torch.ByteTensor(data.test_mask) + if hasattr(torch, 'BoolTensor'): + train_mask = torch.BoolTensor(data.train_mask) + val_mask = torch.BoolTensor(data.val_mask) + test_mask = torch.BoolTensor(data.test_mask) + else: + train_mask = torch.ByteTensor(data.train_mask) + val_mask = torch.ByteTensor(data.val_mask) + test_mask = torch.ByteTensor(data.test_mask) in_feats = features.shape[1] n_classes = data.num_labels n_edges = data.graph.number_of_edges() diff --git a/examples/pytorch/sampling/gcn_cv_sc.py b/examples/pytorch/sampling/gcn_cv_sc.py index 0c854d878f48..fabe0431f81c 100644 --- a/examples/pytorch/sampling/gcn_cv_sc.py +++ b/examples/pytorch/sampling/gcn_cv_sc.py @@ -149,9 +149,14 @@ def main(args): features = torch.FloatTensor(data.features) labels = torch.LongTensor(data.labels) - train_mask = torch.ByteTensor(data.train_mask) - val_mask = torch.ByteTensor(data.val_mask) - test_mask = torch.ByteTensor(data.test_mask) + if hasattr(torch, 'BoolTensor'): + train_mask = torch.BoolTensor(data.train_mask) + val_mask = torch.BoolTensor(data.val_mask) + test_mask = torch.BoolTensor(data.test_mask) + else: + train_mask = torch.ByteTensor(data.train_mask) + val_mask = torch.ByteTensor(data.val_mask) + test_mask = torch.ByteTensor(data.test_mask) in_feats = features.shape[1] n_classes = data.num_labels n_edges = data.graph.number_of_edges() diff --git a/examples/pytorch/sampling/gcn_ns_sc.py b/examples/pytorch/sampling/gcn_ns_sc.py index da945a4c1ee7..e5fd6cc39ba9 100644 --- a/examples/pytorch/sampling/gcn_ns_sc.py +++ b/examples/pytorch/sampling/gcn_ns_sc.py @@ -120,9 +120,14 @@ def main(args): features = torch.FloatTensor(data.features) labels = torch.LongTensor(data.labels) - train_mask = torch.ByteTensor(data.train_mask) - val_mask = torch.ByteTensor(data.val_mask) - test_mask = torch.ByteTensor(data.test_mask) + if hasattr(torch, 'BoolTensor'): + train_mask = torch.BoolTensor(data.train_mask) + val_mask = torch.BoolTensor(data.val_mask) + test_mask = torch.BoolTensor(data.test_mask) + else: + train_mask = torch.ByteTensor(data.train_mask) + val_mask = torch.ByteTensor(data.val_mask) + test_mask = torch.ByteTensor(data.test_mask) in_feats = features.shape[1] n_classes = data.num_labels n_edges = data.graph.number_of_edges() diff --git a/examples/pytorch/sgc/sgc.py b/examples/pytorch/sgc/sgc.py index f799269fe588..db092f24d142 100644 --- a/examples/pytorch/sgc/sgc.py +++ b/examples/pytorch/sgc/sgc.py @@ -30,9 +30,14 @@ def main(args): data = load_data(args) features = torch.FloatTensor(data.features) labels = torch.LongTensor(data.labels) - train_mask = torch.ByteTensor(data.train_mask) - val_mask = torch.ByteTensor(data.val_mask) - test_mask = torch.ByteTensor(data.test_mask) + if hasattr(torch, 'BoolTensor'): + train_mask = torch.BoolTensor(data.train_mask) + val_mask = torch.BoolTensor(data.val_mask) + test_mask = torch.BoolTensor(data.test_mask) + else: + train_mask = torch.ByteTensor(data.train_mask) + val_mask = torch.ByteTensor(data.val_mask) + test_mask = torch.ByteTensor(data.test_mask) in_feats = features.shape[1] n_classes = data.num_labels n_edges = data.graph.number_of_edges() diff --git a/examples/pytorch/sgc/sgc_reddit.py b/examples/pytorch/sgc/sgc_reddit.py index f1a25e438d48..de5e9af8d1c9 100644 --- a/examples/pytorch/sgc/sgc_reddit.py +++ b/examples/pytorch/sgc/sgc_reddit.py @@ -33,9 +33,14 @@ def main(args): data = load_data(args) features = torch.FloatTensor(data.features) labels = torch.LongTensor(data.labels) - train_mask = torch.ByteTensor(data.train_mask) - val_mask = torch.ByteTensor(data.val_mask) - test_mask = torch.ByteTensor(data.test_mask) + if hasattr(torch, 'BoolTensor'): + train_mask = torch.BoolTensor(data.train_mask) + val_mask = torch.BoolTensor(data.val_mask) + test_mask = torch.BoolTensor(data.test_mask) + else: + train_mask = torch.ByteTensor(data.train_mask) + val_mask = torch.ByteTensor(data.val_mask) + test_mask = torch.ByteTensor(data.test_mask) in_feats = features.shape[1] n_classes = data.num_labels n_edges = data.graph.number_of_edges() diff --git a/examples/pytorch/tagcn/train.py b/examples/pytorch/tagcn/train.py index 4628d72aec83..3bacc7e8efec 100644 --- a/examples/pytorch/tagcn/train.py +++ b/examples/pytorch/tagcn/train.py @@ -23,9 +23,14 @@ def main(args): data = load_data(args) features = torch.FloatTensor(data.features) labels = torch.LongTensor(data.labels) - train_mask = torch.ByteTensor(data.train_mask) - val_mask = torch.ByteTensor(data.val_mask) - test_mask = torch.ByteTensor(data.test_mask) + if hasattr(torch, 'BoolTensor'): + train_mask = torch.BoolTensor(data.train_mask) + val_mask = torch.BoolTensor(data.val_mask) + test_mask = torch.BoolTensor(data.test_mask) + else: + train_mask = torch.ByteTensor(data.train_mask) + val_mask = torch.ByteTensor(data.val_mask) + test_mask = torch.ByteTensor(data.test_mask) in_feats = features.shape[1] n_classes = data.num_labels n_edges = data.graph.number_of_edges()