Workspace

class Workspace

Sandbox to isolate the resources and computations.

Constructors

explicit dragon::Workspace::Workspace(const string &name)

Constructor with the name.

Public Properties

data

template<class Context>
inline void *dragon::Workspace::data(
  size_t size,
  const string &name = "BufferShared")

Return a shared raw data.

data

template<typename T, class Context>
inline T *dragon::Workspace::data(
  int64_t size,
  const string &name = "BufferShared")

Return a shared typed data.

graphs

vector<string> dragon::Workspace::graphs() const

Return the name of created graphs

name

inline const string &dragon::Workspace::name()

Return the workspace name.

tensors

vector<string> dragon::Workspace::tensors(bool external = true) const

Return the name of created tensors.

Public Functions

Clear

void dragon::Workspace::Clear()

Clear the cached resources.

CreateGraph

GraphBase *dragon::Workspace::CreateGraph(const GraphDef &def)

Create the graph.

CreateTensor

Tensor *dragon::Workspace::CreateTensor(const string &name)

Create the tensor.

GetTensor

Tensor *dragon::Workspace::GetTensor(
  const string &name,
  bool external = true) const

Return the tensor.

HasTensor

inline bool dragon::Workspace::HasTensor(
  const string &name,
  bool external = true) const

Return whether tensor is existing.

MergeFrom

void dragon::Workspace::MergeFrom(Workspace *other)

Merge resources from other.

RunGraph

void dragon::Workspace::RunGraph(
  const string &name,
  const string &include = "",
  const string &exclude = "",
  int stream = 0)

Run the graph.

RunOperator

void dragon::Workspace::RunOperator(const OperatorDef &def)

Run the operator.

SetAlias

inline void dragon::Workspace::SetAlias(
  const string &target,
  const string &alias)

TryGetTensor

Tensor *dragon::Workspace::TryGetTensor(
  const string &name,
  bool external = true) const

Try to return the tensor.

UniqueName

string dragon::Workspace::UniqueName(
  const string &name,
  const string &suffix,
  const string &scope = "",
  const bool zero_based = false)