std::map<std::string, torch::Tensor*> tmpFloatActivations = model.getActivations();
std::map<std::string, torch::Tensor*> floatActivations;
floatActivations.insert(tmpFloatActivations.begin(), tmpFloatActivations.end());
for (auto& mapIter : tmpFloatActivations) {
cout << "[DEBUG-BEFORE] layerName: " << mapIter.first << " address: " << (void*)mapIter.second << endl;
torch::Tensor* clonedTensor = new torch::Tensor(mapIter.second->clone());
floatActivations.insert(std::make_pair(mapIter.first, clonedTensor));
cout << "[DEBUG-AFTER] layerName: " << mapIter.first << " address: " << (void*)floatActivations[mapIter.first] << endl;
}
The address of before and after are the same even if I create new tensor from clone tensor.
If I comment this line floatActivations.insert(tmpFloatActivations.begin(), tmpFloatActivations.end());, the address are different. Why does this happen?