Hi, all.
I found that it’s not possible for me to change the value of a DistTensor object. See below:
logger.debug("Before: {}".format(
torch.sum(g.ndata['features'][local_nodes][0])))
g.ndata['features'][local_nodes][0] = torch.zeros(
g.ndata['features'][local_nodes][0].shape)
logger.debug("After: {}".format(
torch.sum(g.ndata['features'][local_nodes][0])))
After running this program, I found the value unchanged. But I thought the source code of DistTensor supports assigning tensor values via pushing the new value to kvstore:
def __setitem__(self, idx, val):
idx = utils.toindex(idx)
idx = idx.tousertensor()
# TODO(zhengda) how do we want to support broadcast (e.g., G.ndata['h'][idx] = 1).
self.kvstore.push(name=self._name, id_tensor=idx, data_tensor=val)
I wonder if it’s because DGL by default store caches after the first read, and afterwards only reads values from the local cache? Or is the DistTensor by default is read-only?
Besides, as I only need to change the feature values of local nodes, do I have any approach to achieve it?