40 auto itr = _disposable_back_prop.find(index);
41 if (itr != _disposable_back_prop.end())
42 return itr->second.get();
48 std::unique_ptr<BackPropTensor> tensor)
50 assert(tensor !=
nullptr);
51 auto itr = _disposable_back_prop.find(index);
52 if (itr != _disposable_back_prop.end())
53 throw std::runtime_error{
54 "Tried to set a disposable tensor but another disposable tensor already exists."};
56 _disposable_back_prop[index] = std::move(tensor);
59 const std::unordered_map<DisposableTensorIndex, std::unique_ptr<BackPropTensor>> &
62 return _disposable_back_prop;
67 auto itr = _layer_scope.find(index);
68 if (itr != _layer_scope.end())
75 std::shared_ptr<LayerScopeTensor> &tensor)
77 assert(tensor !=
nullptr);
78 auto itr = _layer_scope.find(index);
79 if (itr != _layer_scope.end())
80 throw std::runtime_error{
81 "Tried to set a layer scope tensor but another layer scope tensor already exists."};
83 _layer_scope[index] = tensor;
86 const std::unordered_map<LayerScopeTensorIndex, std::shared_ptr<LayerScopeTensor>> &
94 std::unordered_map<DisposableTensorIndex, std::unique_ptr<BackPropTensor>> _disposable_back_prop;
95 std::unordered_map<LayerScopeTensorIndex, std::shared_ptr<LayerScopeTensor>> _layer_scope;