Faciliates memory management of off-heap data structures.
Tracks allocations of aten.Tensor and aten.TensorOption instances.
aten.Tensor and aten.TensorOption instances are not freed up by the garbage collector. Lamp implements zoned memory management around these object. The managed counterpart of aten.Tensor is lamp.STen, while for aten.TensorOption it is lamp.STenOptions.
One can only create a lamp.STen instance with a lamp.Scope in implicit scope.
Create new scopes with lamp.Scope.root, lamp.Scope.apply or lamp.Scope.root.
=Examples=
// Scope.root returns Unit
Scope.root { implicit scope =>
val sum = Scope { implicit scope =>
// Intermediate values allocated in this block (`ident` and `ones`) are freed when
// this block returns
// The return value (`ident + ones`) of this block is moved to the outer scope
val ident = STen.eye(3, STenOptions.d)
val ones = STen.ones(List(3, 3), STenOptions.d)
ident + ones
}
assert(sum.toMat == mat.ones(3, 3) + mat.ident(3))
// `sum` is freed once this block exits
}
- Companion:
- object
Type members
Types
Value members
Concrete methods
Adds a resource to the managed resources, then returns it unchanged.
Adds a resource to the managed resources, then returns it unchanged.
The resources will be released when this Scope goes out of scope or otherwise releases.
Adds a resource to the managed resources, then returns it unchanged.
Adds a resource to the managed resources, then returns it unchanged.
The resources will be released when this Scope goes out of scope or otherwise releases.
Adds a resource to the managed resources.
Adds a resource to the managed resources.
The resources will be released when this Scope goes out of scope or otherwise releases.
Adds a resource to the managed resources.
Adds a resource to the managed resources.
The resources will be released when this Scope goes out of scope or otherwise releases.