Workspace

class dragon.Workspace[source]

Standalone environment for resources and computations.

__init__

Workspace.__init__()[source]

Create a Workspace.

Methods

as_default

Workspace.as_default()[source]

Set as the default workspace.

Call this method with the with keyword.

Once with is exited, the previous default will be set.

Returns:
dragon.Workspace – This workspace.

clear

Workspace.clear()[source]

Release the created tensors, operators and graphs.

memory_allocated

Workspace.memory_allocated(
  device_type='cpu',
  device_index=0
)[source]

Return the size of memory used by tensors on given device.

Parameters:
  • device_type (str, optional) – The device type.
  • device_index (int, optional) – The device index.
Returns:

int – The total number of allocated bytes.

merge_from

Workspace.merge_from(other)[source]

Merge resources from the other.

The other will not be reset until self is reset.

Parameters:
Returns:

dragon.Workspace – This workspace.