Warning
You are reading a version of the website built against the unstable main branch. This content is liable to change without notice and may be inappropriate for your use case.
You can find the documentation for the current stable release here.
pyop3.expr.tensor package¶
Submodules¶
pyop3.expr.tensor.base module¶
- class pyop3.expr.tensor.base.CallableTensorTransform[source]¶
Bases:
TensorTransform
- class pyop3.expr.tensor.base.IdentityTensorTransform[source]¶
Bases:
TensorTransform
- class pyop3.expr.tensor.base.OutOfPlaceCallableTensorTransform(transform_in, transform_out, prev=None)[source]¶
Bases:
CallableTensorTransformOutOfPlaceCallableTensorTransform(transform_in: ‘Callable[[Tensor, Tensor], None]’, transform_out: ‘Callable[[Tensor, Tensor], None]’, prev: ‘TensorTransform | None’ = None)
- prev = None¶
- record_new(**attrs)¶
Create and initialise a new record from an existing one.
- transform_in¶
- transform_out¶
- class pyop3.expr.tensor.base.ReshapeTensorTransform(axis_trees, prev=None)[source]¶
Bases:
IdentityTensorTransformReshapeTensorTransform(axis_trees: ‘tuple[pyop3.axis_tree.AxisTree, …]’, prev: ‘TensorTransform | None’ = None)
- axis_trees¶
- prev = None¶
- record_new(**attrs)¶
Create and initialise a new record from an existing one.
- class pyop3.expr.tensor.base.Tensor[source]¶
Bases:
TerminalExpression,ABC- DEFAULT_PREFIX = 'array'¶
- assign(other, /, mode='write', *, eager=False, eager_strategy=None, compiler_parameters=None, **kwargs)[source]¶
- abstract property axis_trees¶
- property comm¶
- copy(*, constant=None)[source]¶
Return a copy of the tensor.
- Parameters:
constant – Is the copy mutable or not? If \(None\) then default to the const-ness of the original object.
- property data¶
- property data_ro¶
Return a read-only view of the data stored by the dat.
- property data_rw¶
Return a modifiable view of the data stored by the dat.
- property data_wo¶
Return a write-only view of the data stored by the dat.
- abstract property dim¶
- property dtype¶
- duplicate(*, copy=False, constant=None)[source]¶
Return a duplicate of the tensor.
- Parameters:
copy – Whether to copy values to the new object.
constant – Is the duplicate mutable or not? If \(None\) then default to the const-ness of the original object.
- abstract property size¶
- abstract property transform¶
pyop3.expr.tensor.dat module¶
- class pyop3.expr.tensor.dat.AggregateDat(subdats, axis, *, name=None, prefix=None)[source]¶
Bases:
ObjectA dat formed of multiple subdats concatenated together.
- DEFAULT_PREFIX = 'aggdat'¶
- axis¶
- property comm¶
- property dtype¶
- name¶
- record_new(**attrs)¶
Create and initialise a new record from an existing one.
- property size¶
- subdats¶
- property subtensors¶
- exception pyop3.expr.tensor.dat.AxisMismatchException[source]¶
Bases:
Pyop3Exception
- class pyop3.expr.tensor.dat.CompositeDat(axis_tree, exprs)[source]¶
Bases:
Terminalexprs: expression per leaf path TODO check only leaf paths allowed, I think so?
- axis_tree¶
- dtype = dtype('int32')¶
- exprs¶
- property local_max¶
- property local_min¶
- record_new(**attrs)¶
Create and initialise a new record from an existing one.
- class pyop3.expr.tensor.dat.Dat(axes, buffer=None, *, data=None, name=None, prefix=None, buffer_kwargs=None, constant=False, transform=None)[source]¶
Bases:
TensorMulti-dimensional, hierarchical array.
- DEFAULT_PREFIX = 'dat'¶
- axes¶
- property axis_trees¶
- axpy(alpha, other)[source]¶
Compute the operation \(y = \alpha x + y\).
In this case,
selfisyandotherisx.
- buffer¶
- property comm¶
- property context_free¶
- property dat_version¶
- property data_ro_with_halos¶
Return a read-only view of the data stored by the dat.
This view includes ghost entries.
- property data_rw_with_halos¶
Return a modifiable view of the data stored by the dat.
This view includes ghost entries.
- property data_with_halos¶
- property data_wo_with_halos¶
Return a write-only view of the data stored by the dat.
This view includes ghost entries.
- dim = 1¶
- property dtype¶
- classmethod empty(axes, dtype=dtype('float64'), *, buffer_kwargs=immutabledict({}), **kwargs)[source]¶
- classmethod from_array(array, *, sf=None, comm=<mpi4py.MPI.Intracomm object>, buffer_kwargs=None, constant=False, rank_equal=False, **kwargs)[source]¶
- classmethod full(axes, fill_value, dtype=dtype('float64'), *, buffer_kwargs=immutabledict({}), **kwargs)[source]¶
- property global_data¶
Return all the data for the Dat gathered onto individual ranks.
This function is logically collective over MPI ranks, it is an error to call it on fewer than all the ranks in MPI communicator. PYOP3_SPMD_STRICT=1 is in your environment and function calls will be guarded by a barrier where possible.
- inner(other, /)[source]¶
Compute the l2 inner product against another dat.
- Parameters:
other – The other \(Dat\) to compute the inner product against. Its complex conjugate is taken.
- Returns:
The l2 inner product.
- Return type:
- property local_max¶
- property local_min¶
- property max¶
Return the global maximum value held by the dat.
- maxpy(alphas, dats)[source]¶
Compute a sequence of axpy operations.
This is equivalent to calling
axpyfor each pair of scalars and \(Dat\) in the input sequences.- Parameters:
alphas – A sequence of scalars.
dats – A sequence of \(Dat\).
- property min¶
Return the global minimum value held by the dat.
- name¶
- property nbytes¶
Return an estimate of the size of the data associated with this
Datin bytes. This will be the correct size of the data payload, but does not take into account the (presumably small) overhead of the object and its metadata.Note that this is the process local memory usage, not the sum over all MPI processes.
- property norm¶
Compute the l2 norm of this \(Dat\).
Note
This acts on the flattened data (see also
inner()).
- classmethod null(axes, dtype=dtype('float64'), *, buffer_kwargs=immutabledict({}), **kwargs)[source]¶
- record_new(**attrs)¶
Create and initialise a new record from an existing one.
- property sf¶
- property size¶
- property transform¶
- property vec¶
- property vec_ro¶
- property vec_rw¶
- property vec_wo¶
pyop3.expr.tensor.mat module¶
- class pyop3.expr.tensor.mat.AggregateMat(submats, row_axis, column_axis, *, name=None, prefix=None)[source]¶
Bases:
ObjectA matrix formed of multiple submatrices concatenated together.
- DEFAULT_PREFIX = 'aggmat'¶
- column_axis¶
- property comm¶
- property dtype¶
- name¶
- record_new(**attrs)¶
Create and initialise a new record from an existing one.
- row_axis¶
- submats¶
- property subtensors¶
- class pyop3.expr.tensor.mat.Mat(row_axes, column_axes, buffer, *, name=None, prefix=None, transform=None)[source]¶
Bases:
TensorA matrix.
- DEFAULT_MAT_INIT_BUFFER_SPEC = MonolithicPetscMatInitBufferSpec(mat_type='aij', block_shape=((), ()))¶
- DEFAULT_PREFIX = 'mat'¶
- buffer¶
- column_axes¶
- property comm¶
- property dim¶
- property dtype¶
- classmethod empty(row_axes, column_axes, *, buffer_spec=None, preallocator=False, buffer_kwargs=immutabledict({}), **kwargs)[source]¶
- property handle¶
- property local_max¶
- property local_min¶
- name¶
- classmethod null(row_axes, column_axes, dtype=dtype('float64'), *, buffer_kwargs=immutabledict({}), **kwargs)[source]¶
- record_new(**attrs)¶
Create and initialise a new record from an existing one.
- row_axes¶
- property transform¶
- property values¶
pyop3.expr.tensor.scalar module¶
- class pyop3.expr.tensor.scalar.Scalar(value=None, comm=None, *, buffer=None, constant=None, name=None, prefix=None)[source]¶
Bases:
TensorA scalar value.
- DEFAULT_DTYPE = dtype('float64')¶
- DEFAULT_PREFIX = 'scalar'¶
- as_array(mode)[source]¶
Return a view of the scalar’s buffer.
- Parameters:
mode – The access mode: read-only, write-only, or read-write.
- Returns:
A view of the buffer with the requested access mode.
- Return type:
- axis_trees = ()¶
- buffer¶
- property comm¶
- property constant¶
- dim = 0¶
- property local_max¶
- property local_min¶
- loop_axes = immutabledict({})¶
- name¶
- record_new(**attrs)¶
Create and initialise a new record from an existing one.
- shape = (_UnitAxisTree(),)¶
- size = 1¶
- transform = None¶
- property value¶
