lamp.Scope
See theScope companion object
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
}
Attributes
- Companion
- object
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
Members list
In this article