Each graph uses a reentrant lock internally that protects its core state that can be returned via public accessors, as well as synchronizes session run calls with methods that create and mutate ops.
Each graph uses a reentrant lock internally that protects its core state that can be returned via public accessors,
as well as synchronizes session run calls with methods that create and mutate ops. This synchronization is necessary
because it is illegal to modify an operation after it has been run. Thread-safety is provided on a best-effort basis
to support buggy programs, and is not guaranteed by the public tf.Graph
API. Note that the lock must be reentrant
because methods that create and mutate ops may be called recursively due to control flow. Without a reentrant lock,
many methods would also need a synchronized version or a lock parameter.
Represents an indexer object.
Represents an indexer object. Indexers are used to index tensors.
An indexer can be one of:
Examples of constructing and using indexers are provided in the Ellipsis and the Slice class documentation. Here we provide examples of indexing over tensors using indexers:
// 't' is a tensor (i.e., Output) with shape [4, 2, 3, 8] t(::, ::, 1, ::) // Tensor with shape [4, 2, 1, 8] t(1 :: -2, ---, 2) // Tensor with shape [1, 2, 3, 1] t(---) // Tensor with shape [4, 2, 3, 8] t(1 :: -2, ---, NewAxis, 2) // Tensor with shape [1, 2, 3, 1, 1] t(1 ::, ---, NewAxis, 2) // Tensor with shape [3, 2, 3, 1, 1]
where ---
corresponds to an ellipsis.
Note that each indexing sequence is only allowed to contain at most one Ellipsis. Furthermore, if an ellipsis is
not provided, then one is implicitly appended at the end of indexing sequence. For example, foo(2 :: 4)
is
equivalent to foo(2 :: 4, ---)
.
TODO: Add more usage examples.
Helper trait for representing indexer construction phases.
Helper class for representing a indexer construction phase that has already been provided one numbers.
Helper class for representing a indexer construction phase that has already been provided three numbers.
Helper class for representing a indexer construction phase that has already been provided two numbers.
Represents the shape of a tensor computed by an op.
Represents the shape of a tensor computed by an op.
A Shape
represents a possibly-partial shape specification for an op output. It may be one of the following:
Unknown dimensions are represented as having a size of -1
and two shapes are considered equal only if they are
fully known and all their dimension sizes match.
If a tensor is produced by an op of type "Foo"
, its shape may be inferred if there is a registered shape function
for "Foo"
. See Shape Functions in C++ for
details on shape functions and how to register them.
Represents a slice object.
Represents a slice object. A slice is a sequence of indices for some underlying sequence or tensor.
The companion object provides some helpful implicit conversion functions that allow for easy creation of slices.
For example:
3 // Slice object representing the following indices: '[3]'. 2 :: 6 // Slice object representing the following indices: '[2, 3, 4, 5]'. 3 :: 4 :: 12 // Slice object representing the following indices: '[3, 7, 10]'. 0 :: 1 :: -2 // Slice object representing the following indices: '[0, 3, 6, ..., length - 3]'. 6 :: -2 :: 3 // Slice object representing the following indices: '[6, 4]'. -3 :: -2 :: -10 // Slice object representing the following indices: '[length - 3, length - 5, ..., length - 10]'. 2 :: - // Slice object representing the following indices: '[2, 3, ..., length - 1]'. 0 :: 1 :: - // Slice object representing the following indices: '[0, 3, 6, ..., length - 1]'.
Note how the end index is exclusive and the step size is optional.
Contains helper methods for dealing with devices.
Ellipsis indexer used to represent a full slice over multiple dimensions of a tensor.
Ellipsis indexer used to represent a full slice over multiple dimensions of a tensor. Ellipses are used to represent zero or more dimensions of a full-dimension indexer sequence. Usage examples are providedin the documentation of Indexer.
Contains helper functions for dealing with indexers.
New axis indexer used to represent the addition of a new axis in a sequence of indexers.
New axis indexer used to represent the addition of a new axis in a sequence of indexers. Usage examples are provided in the documentation of Indexer.
Contains helper functions for creating Shape objects.
Contains helper functions for creating Slice objects.