CTileTensor#
- class CTileTensor#
An encrypted tile tensor. A tile tensor is an data structure for storing tensors (multiply dimensional arrays, e.g., vectors, matrices, or higher dimensional arrays) in a set of fixed size tiles, in this case ciphertexts.
- add(self: pyhelayers.CTileTensor, other: pyhelayers.CTileTensor) None #
Elementwise add with other CTileTensor. Relies on CTile::add.
- Parameters:
other (CTileTensor) – other CTileTensor to add.
- add_dim(self: pyhelayers.CTileTensor, place: int = -1) None #
Adds a dim with original size and tile size 1 to this tensor at given place. :param place: Place of the new dimension, default is last. :type place: int
- add_plain(self: pyhelayers.CTileTensor, other: pyhelayers.PTileTensor) None #
Elementwise add with other (plaintext) PTileTensor. Relies on CTile::add_plain.
- Parameters:
other (PTileTensor) – other PTileTensor to add.
- add_plain_raw(self: pyhelayers.CTileTensor, other: pyhelayers.PTileTensor) None #
Elementwise add with other (plaintext) PTileTensor. Relies on CTile::add_plain_raw.
- Parameters:
other (PTileTensor) – other PTileTensor to add.
- add_raw(self: pyhelayers.CTileTensor, other: pyhelayers.CTileTensor) None #
Elementwise add with other CTileTensor. Relies on CTile::add_raw.
- Parameters:
other (CTileTensor) – other CTileTensor to add.
- add_scalar(self: pyhelayers.CTileTensor, scalar: float, keep_unknowns_clear: bool = False) None #
adds a double scalar value to all elements of this tensor.
- Parameters:
scalar (double) – double value to add.
keep_unknowns_clear (boolean) – the default is ‘false’.
- adjust_chain_index(self: pyhelayers.CTileTensor, chain_index: int) None #
Calls corresponding function for every CTile.
- Parameters:
chain_index (int) – The required chain index.
- clear_unknowns(self: pyhelayers.CTileTensor) None #
Clears all unknowns from this tile tensor.
- duplicate_over_dim(self: pyhelayers.CTileTensor, dim: int) None #
Cause a dimension to become duplicated
- Parameters:
dim (int) – The dimension to duplicate.
- flatten(*args, **kwargs)#
Overloaded function.
flatten(self: pyhelayers.CTileTensor, start_dim: int, end_dim: int) -> None
Flattens consecutive fully-duplicated dimensions into a single fully-duplicated dimension. The Flattened dimension will have tile size equals to the product of tile sizes of all the flattened dimensions, and will be considered interleaved if and only if all the flattened dimensions are.
- param start_dim:
The first dimension to be flattened.
- type start_dim:
int
- param end_dim:
The dimension in which to end the flattening (exclusive). Flatten(a, b) will flatten dimensions [a,b).
- type end_dim:
int
- raises RuntimeError:
If the specified dimensions do not exist, or are not fully duplicated, or if startDim >= endDim.
flatten(self: pyhelayers.CTileTensor, start_dim: int, end_dim: int) -> pyhelayers.CTileTensor
Returns the result of Flattening consecutive fully-duplicated dimensions into a single fully-duplicated dimension. See also CTileTensor::flatten.
- param start_dim:
The first dimension to be flattened.
- type start_dim:
int
- param end_dim:
The dimension in which to end the flattening (exclusive). Flatten(a, b) will flatten dimensions [a,b).
- type end_dim:
int
- raises RuntimeError:
If the specified dimensions do not exist, or are not fully duplicated, or if startDim >= endDim.
- get_add_plain(self: pyhelayers.CTileTensor, plain: pyhelayers.PTileTensor) pyhelayers.CTileTensor #
Returns the result of elementwise add of this and other PTileTensor. Relies on CTile::addPlain.
- Parameters:
plain (PTileTensor) – Other PTileTensor to add.
- get_add_plain_raw(self: pyhelayers.CTileTensor, plain: pyhelayers.PTileTensor) pyhelayers.CTileTensor #
Returns the result of elementwise add of this and other PTileTensor. Relies on CTile::addPlainRaw.
- Parameters:
plain (PTileTensor) – Other PTileTensor to add.
- get_add_scalar(self: pyhelayers.CTileTensor, val: float) pyhelayers.CTileTensor #
Returns the result of elementwise add of this and the given scalar.
- Parameters:
val (double) – Scalar to add.
- get_chain_index(self: pyhelayers.CTileTensor) int #
Returns chain index of tiles. They are maintained to have equal chain index.
- get_clear_unknowns(self: pyhelayers.CTileTensor) pyhelayers.CTileTensor #
Returns the result of clearing all unknowns.
- get_convolution(self: pyhelayers.CTileTensor, filters: pyhelayers.CTileTensor, biases: pyhelayers.CTileTensor, stride_rows: int, stride_cols: int) pyhelayers.CTileTensor #
Returns the result of applying convolution with the given parameters.
- Parameters:
filters (CTileTensor) – The filters to convolute with.
biases (CTileTensor) – The biases to add.
stride_rows (int) – Stride rows parameter to use during the convolution.
stride_cols (int) – Stride cols parameter to use during the convolution.
- get_duplicate_over_dim(self: pyhelayers.CTileTensor, dim: int) pyhelayers.CTileTensor #
Returns the result of duplicating the specified dimension.
- Parameters:
dim (int) – The dimension to duplicate.
- get_matrix_multiplication(self: pyhelayers.CTileTensor, other: pyhelayers.TileTensor, sum_dim: int) pyhelayers.CTileTensor #
Computes matrix-vector multiplication with other. For non-diagonalized computation, it calls get_multiply_and_sum() (See documentation in get_multiply_and_sum())
For diagonalization, other shape should be diagonalized. For example: Other is a matrix [(d)16/t1,6/t2,1/t3] This is a vector [16/t1*t2,1/t3] Result is [*/t1,6/t2,1/t3]
Constraints: - other should be diagonalized - this should not be diagonalized - this tile size 0 should equal other tileSize0*tileSize1 - this original size 0 should equal other original size 0 - this dims 1..end should be identical to other dims 2..end. (will be extended to support comptability) - sumDim must be 0
- Parameters:
other – Other tile tensor to multiply with
sumDim – Dimension to sum over.
- get_multiply_and_sum(self: pyhelayers.CTileTensor, other: pyhelayers.CTileTensor, sum_dim: int) pyhelayers.CTileTensor #
Returns the result of elementwise multiplication and summation between this and other. See CTileTensor::multiplyAndSum for usage examples.
- Parameters:
other (CTileTensor) – Other encoded tile tensor.
sumDim – Dimension to sum over.
- get_multiply_plain(self: pyhelayers.CTileTensor, plain: pyhelayers.PTileTensor) pyhelayers.CTileTensor #
Returns the result of elementwise multiplication of this and other PTileTensor. Relies on CTile::multiplyPlain.
- Parameters:
plain (PTileTensor) – Other PTileTensor to multiply by.
- get_multiply_plain_and_sum(self: pyhelayers.CTileTensor, other: pyhelayers.PTileTensor, sum_dim: int) pyhelayers.CTileTensor #
Returns the result of elementwise multiplication and summation between this and other. See CTileTensor::multiplyAndSum for usage examples.
- Parameters:
other (PTileTensor) – Other encoded tile tensor.
sumDim – Dimension to sum over.
- get_multiply_plain_raw(self: pyhelayers.CTileTensor, plain: pyhelayers.PTileTensor) pyhelayers.CTileTensor #
Returns the result of elementwise multiplication of this and other PTileTensor. Relies on CTile::multiplyPlainRaw.
- Parameters:
plain (PTileTensor) – Other PTileTensor to multiply by.
- get_multiply_scalar(self: pyhelayers.CTileTensor, val: float) pyhelayers.CTileTensor #
Returns the result of elementwise multiplication of this and the given scalar.
- Parameters:
val (double) – Scalar to multiply by.
- get_pseudo_rotate_along_dim(self: pyhelayers.CTileTensor, dim: int, offset: int, real_rotate: bool = False) pyhelayers.CTileTensor #
Returns the result of calling psuedoRotateAlongDim. See also pseudo_roate_along_dim().
- get_reduce_chain_index(self: pyhelayers.CTileTensor) pyhelayers.CTileTensor #
Returns the result of reducing chain indexes of every CTile.
- get_relinearize(self: pyhelayers.CTileTensor) pyhelayers.CTileTensor #
Returns the result of calling relinearize on every CTile.
- get_rescale(self: pyhelayers.CTileTensor) pyhelayers.CTileTensor #
Returns the result of calling rescale on every CTile.
- get_set_chain_index(*args, **kwargs)#
Overloaded function.
get_set_chain_index(self: pyhelayers.CTileTensor, other: pyhelayers.CTileTensor) -> pyhelayers.CTileTensor
Returns the result of Calling corresponding function for every CTile.
- param other:
CTileTensor to get chain index from.
- type other:
CTileTensor
get_set_chain_index(self: pyhelayers.CTileTensor, chain_index: int) -> pyhelayers.CTileTensor
Returns the result of Calling corresponding function for every CTile.
- param chain_index:
The required chain index.
- type chain_index:
int
- get_slice(self: pyhelayers.CTileTensor, dim: int, start_index: int, slice_depth: int) pyhelayers.CTileTensor #
Returns a slice of the tensor in specific dimension. Result has the same number of dimensions as the original tensor. For dim with tile size of 1, getSlice is supported for every valid startIndex and sliceDepth. For a non-interleaved dim with tile size > 1, getSlice is supported only for startIndex which is a multiple of the tile size. For interleaved dim with tile size > 1, getSlice is supported only for startIndex 0.
- Parameters:
dim – The dimension to slice along. Specifying negative value will count from the last dim backwards (-1 for the last dim, -2 for the previous one etc.).
start_index – The index to start slicing at along the dimension
slice_depth – The depth/size of the slice along the dimension
- get_square(self: pyhelayers.CTileTensor) pyhelayers.CTileTensor #
Returns the result of elementwise squaring of this CTileTensor. Relies on CTile::square.
- get_square_raw(self: pyhelayers.CTileTensor) pyhelayers.CTileTensor #
Returns the result of elementwise squaring of this CTileTensor. Relies on CTile::squareRaw.
- get_sub(self: pyhelayers.CTileTensor, other: pyhelayers.CTileTensor) pyhelayers.CTileTensor #
Returns the result of elementwise sub of this and other CTileTensor. Relies on CTile::sub.
- Parameters:
other (CTileTensor) – Other CTileTensor to sub.
- get_sub_plain(self: pyhelayers.CTileTensor, plain: pyhelayers.PTileTensor) pyhelayers.CTileTensor #
Returns the result of elementwise sub of this and other PTileTensor. Relies on CTile::subPlain.
- Parameters:
plain (PTileTensor) – Other PTileTensor to sub.
- get_sub_plain_raw(self: pyhelayers.CTileTensor, plain: pyhelayers.PTileTensor) pyhelayers.CTileTensor #
Returns the result of elementwise sub of this and other PTileTensor. Relies on CTile::subPlainRaw.
- Parameters:
plain (PTileTensor) – Other PTileTensor to sub.
- get_sub_raw(self: pyhelayers.CTileTensor, other: pyhelayers.CTileTensor) pyhelayers.CTileTensor #
Returns the result of elementwise sub of this and other CTileTensor. Relies on CTile::subRaw.
- Parameters:
other (CTileTensor) – Other CTileTensor to sub.
- get_sum_in_tiles_over_dim(self: pyhelayers.CTileTensor, dim: int) pyhelayers.CTileTensor #
Returns the result of summing inside the tiles over the specified dimension.
- Parameters:
dim (int) – The dimension to sum over.
- get_sum_over_dim(self: pyhelayers.CTileTensor, dim: int) pyhelayers.CTileTensor #
Returns the result of summing over the specified dimension.
- Parameters:
dim (int) – The dimension to sum over.
- get_sum_tiles_over_dim(self: pyhelayers.CTileTensor, dim: int) pyhelayers.CTileTensor #
Returns the result of summing tiles over the specified dimension.
- Parameters:
dim (int) – The dimension to sum over.
- multiply(self: pyhelayers.CTileTensor, other: pyhelayers.CTileTensor) None #
Elementwise multiplication with other CTileTensor. Relies on CTile::multiply.
- Parameters:
other (CTileTensor) – other CTileTensor to multiply by.
- multiply_and_sum(self: pyhelayers.CTileTensor, other: pyhelayers.CTileTensor, sum_dim: int) None #
Performs elementwise multiplication between this and other, then sums over the specified dim. If both are vectors of same length, sum over dim 0 to get inner product.
If this is a matrix [a/t1,b/t2] and other is a vector [a/t1,*/t2], sum over dim 0 will produce the matrix-vector multiplication. Similarly for matrix [a/t1,b/t2] and vector [*/t1,b/t2], sum over dim 1.
For matrix-matrix multiplication use for example:
Matrix1 [ a/t1,b/t2,* /t3] and Matrix2 [a/t1,* / t2, c/t3], sum over dim 0.
or:
Matrix1 [ a/t1,b/t2,* /t3] and Matrix2 [* / t1,b / t2, c/t3], sum over dim 1.
- Parameters:
other (CTileTensor) – Other encrypted tile tensor.
sumDim (int) – Dimension to sum over.
- multiply_over_dim(*args, **kwargs)#
Overloaded function.
multiply_over_dim(self: pyhelayers.CTileTensor, dim: int) -> None
Multiplies over a dimension.
- param dim:
The dimension to multiply over.
- type dim:
int
multiply_over_dim(self: pyhelayers.CTileTensor, dim: int) -> None
Multiplies over a dimension.
- param dim:
The dimension to multiply over.
- type dim:
int
- multiply_plain(self: pyhelayers.CTileTensor, other: pyhelayers.PTileTensor) None #
Elementwise multiply by other (plaintext) PTileTensor. Relies on CTile::multiply_plain.
- Parameters:
other (PTileTensor) – other PTileTensor to multiply by.
- multiply_plain_and_sum(self: pyhelayers.CTileTensor, other: pyhelayers.PTileTensor, sum_dim: int) None #
Performs elementwise multiplication between this and other, then sums over the specified dim. See CTileTensor::multiplyAndSum for usage examples.
- Parameters:
other (PTileTensor) – Other encoded tile tensor.
sumDim – Dimension to sum over.
- multiply_plain_raw(self: pyhelayers.CTileTensor, other: pyhelayers.PTileTensor) None #
Elementwise multiply by other (plaintext) PTileTensor. Relies on CTile::multiply_plain_raw.
- Parameters:
other (PTileTensor) – other PTileTensor to multiply by.
- multiply_raw(self: pyhelayers.CTileTensor, other: pyhelayers.CTileTensor) None #
Elementwise multiplication with other CTileTensor. Relies on CTile::multiply_raw.
- Parameters:
other (CTileTensor) – other CTileTensor to multiply by.
- multiply_scalar(*args, **kwargs)#
Overloaded function.
multiply_scalar(self: pyhelayers.CTileTensor, scalar: int) -> None
Multiplies all used tensor elements by a given integer scalar. May consume one chain index. This variant doesn’t clear unknowns. Refer to multiply_scalar(double) that does.
- param scalar:
int value to multiply by.
- type scalar:
int
multiply_scalar(self: pyhelayers.CTileTensor, scalar: float) -> None
Multiplies all used tensor elements by a given scalar. Consumes one chain index. As a side effect, unused elements will be zeroed, thus unknown unused elements will be eliminated.
- param scalar:
double value to multiply by.
- type scalar:
double
- multiply_scalar_raw(self: pyhelayers.CTileTensor, scalar: float) None #
Elementwise multiply_scalar_raw. Relies on CTile.multiply_scalar_raw. This variant doesn’t clear unknowns. Refer to multiply_scalar(double) that does.
- Parameters:
scalar (double) – double value to multiply by.
- negate(self: pyhelayers.CTileTensor) None #
Elementwise negate. Relies on CTile::negate.
- pseudo_rotate_along_dim(self: pyhelayers.CTileTensor, dim: int, offset: int, real_rotate: bool = False) None #
Applies a “pseudo rotation” on this CTileTensor by the given offset along dimension “dim”. If “realRotate” is true, the function verifies that a real rotate is performed, meaning that the values that fall out of one end must cycle back to the other end. If “realRotate” is false, a pseudo rotation is performed, meaning that the values that fall out of one end are not guaranteed to cycle back to the other end. To Perform a real rotation, “dim” must be the first non-trivial dimension and it mustn’t contain any unused slots. In both cases (a real or a pseudo rotate), if the external size of “dim” is not 1, then “dim” must be interleaved. If the external size of “dim” is 1, the rotation works and will have the same effect regardless of the interleaved flag being on or off. :param dim: The dimension to rotate along. :type dim: int :param offset: The rotation offset. :type offset: int :param real_rotate: If true, the function asserts that a true
rotation is performed.
- Raises:
ValueError – If the rotated dimension does not satisfy the
above requirements.
- re_encrypt(self: pyhelayers.CTileTensor) None #
Decrypt the CTileTensor and encrypts it again to bring it to top chain index.
- reduce_chain_index(self: pyhelayers.CTileTensor) None #
Calls corresponding function for every CTile.
- relinearize(self: pyhelayers.CTileTensor) None #
Calls corresponding function for every CTile
- relinearize_and_rescale(self: pyhelayers.CTileTensor) None #
Calls corresponding function for every CTile
- rescale(self: pyhelayers.CTileTensor) None #
Calls corresponding function for every CTile
- rotate_along_dim(self: pyhelayers.CTileTensor, dim: int, rot: int) None #
Rotates this CTileTensor along the specified dimension (index (i+rot) % originalSize moves to i). The elements that fall out of one end cycle back in the other end. If the external size of “dim” is not 1, then “dim” must be interleaved. If the external size of “dim” is 1, the rotation works and will have the same effect regardless of the interleaved flag being on or off. For the rotation to succeed, “dim” must be the first non-trivial” dimension, and it must not contain any unused slots.
- Parameters:
dim (int) – The dimension to rotate along.
rot (int) – The rotation offset.
- Raises:
ValueError – If the rotated dimension does not satisfy the
above requirements.
- set_chain_index(*args, **kwargs)#
Overloaded function.
set_chain_index(self: pyhelayers.CTileTensor, other: pyhelayers.CTileTensor) -> None
Calls corresponding function for every CTile.
- param other:
CTileTensor to get chain index from.
- type other:
CTileTensor
set_chain_index(self: pyhelayers.CTileTensor, chain_index: int) -> None
Calls corresponding function for every CTile.
- param chain_index:
The required chain index.
- type chain_index:
int
- square(self: pyhelayers.CTileTensor) None #
Elementwise square. Relies on CTile::square.
- square_raw(self: pyhelayers.CTileTensor) None #
Elementwise square. Relies on CTile::squareRaw.
- sub(self: pyhelayers.CTileTensor, other: pyhelayers.CTileTensor) None #
Elementwise sub with other CTileTensor. Relies on CTile::sub.
- Parameters:
other (CTileTensor) – other CTileTensor to subtract.
- sub_plain(self: pyhelayers.CTileTensor, other: pyhelayers.PTileTensor) None #
Elementwise sub with other (plaintext) PTileTensor. Relies on CTile::sub_plain.
- Parameters:
other (PTileTensor) – other PTileTensor to subtract.
- sub_plain_raw(self: pyhelayers.CTileTensor, other: pyhelayers.PTileTensor) None #
Elementwise sub with other (plaintext) PTileTensor. Relies on CTile::sub_plain_raw.
- Parameters:
other (PTileTensor) – other PTileTensor to subtract.
- sub_raw(self: pyhelayers.CTileTensor, other: pyhelayers.CTileTensor) None #
Elementwise sub with other CTileTensor. Relies on CTile::sub_raw.
- Parameters:
other (CTileTensor) – other CTileTensor to subtract.
- sum_in_tiles_over_dim(self: pyhelayers.CTileTensor, dim: int) None #
Sums inside tiles over a dimension.
- Parameters:
dim (int) – The dimension to sum inside tiles over it.
- sum_over_dim(self: pyhelayers.CTileTensor, dim: int) None #
Sums over a dimension.
- Parameters:
dim (int) – The dimension to sum over.
- sum_tiles_over_dim(self: pyhelayers.CTileTensor, dim: int) None #
Sums tile over a dimension.
- Parameters:
dim (int) – The dimension to sum over.
-
class CTileTensor : public helayers::TileTensor#
An encrypted tile tensor.
A tile tensor is a data structure for storing tensors (multiply dimensional arrays, e.g., vectors, matrices, or higher dimensional arrays) in a set of fixed size tiles, in this case ciphertexts.
A CTileTensor object contain various methods to manipulate its content, E.g., sumOverDim, multiply, etc…
To implement custom operators use: Option #1 (recommended): Construct an empty result CTileTensor using CTileTensor(const HeContext& he, const TTShape& s) where s is the required result shape. Then use the methods named internalWriteBy* to get write access into individual tiles. Then call internalSetPacked() to signal CTileTensor is ready and in a consistent state. Option #2: Construct a result CTileTensor using the static method internalCreateFromCTileVector given a vector of tiles and shape. Option #3: Manipulate an existing CTileTensor using the methods named internal* which allow write access to tiles and to the shape.
In all these options rigorous tests are required to make sure the resulting tile tensor objects are correct and in a consistent state. Use assertIntegrity() verify consistency with respect to shape.
Public Types
-
typedef boost::numeric::ublas::tensor<CTile, PTileTensor::tensorFormat> ExternalTensorType#
Underlying type used to store the external tensor.
-
using BitwiseEvaluatorMethod = CTile (BitwiseEvaluator::*)(const CTile&, const CTile&) const#
Applies bitwise operation on each two corresponding tiles.
- Param other:
Other encrypted tile tensor
- Param be:
BitwiseEvaluator of the HeContext corresponding to this CTileTensor
- Param method:
A BitwiseEvaluator method to apply. The method must receive two CTiles as input and return a CTile
- Param actionType:
Indication whether this is an ADDITIVE_ACTION_TYPE, a MULTIPLICATIVE_ACTION_TYPE, or OTHER_ACTION_TYPE. The default is OTHER_ACTION_TYPE, the most restrictive.
Public Functions
-
CTileTensor(const CTileTensor &src)#
Copy constructor.
- Parameters:
src – [in] object to copy
-
CTileTensor(CTileTensor &&src)#
Move constructor.
- Parameters:
src – [in] object to move
-
CTileTensor(const HeContext &he, const TTShape &s)#
Construct an object of a certain chape.
- Parameters:
he – [in] the context
s – [in] shape of new object
-
~CTileTensor()#
-
CTileTensor &operator=(const CTileTensor &src)#
Copy other tile tensor to this one.
- Parameters:
src – [in] object to copy
-
CTileTensor &operator=(CTileTensor &&src)#
Move other tile tensor to this one.
- Parameters:
src – [in] object to move
-
void add(const CTileTensor &other)#
Elementwise add with other CTileTensor.
Relies on CTile::add.
- Parameters:
other – [in] other CTileTensor to add.
-
void addRaw(const CTileTensor &other)#
Elementwise add with other CTileTensor.
Relies on CTile::addRaw.
- Parameters:
other – [in] other CTileTensor to add.
-
void sub(const CTileTensor &other)#
Elementwise subtract other CTileTensor from this.
Relies on CTile::sub.
- Parameters:
other – [in] other CTileTensor to subtract.
-
void subTileTensor(const TileTensor &other)#
Elementwise subtract other TileTensor from this.
Relies on CTile::subTile.
- Parameters:
other – Other TileTensor to subtract.
-
void subRaw(const CTileTensor &other)#
Elementwise subtract other CTileTensor from this.
Relies on CTile::subRaw.
- Parameters:
other – [in] other CTileTensor to subtract.
-
void multiply(const CTileTensor &other)#
Elementwise multiply with other CTileTensor.
Relies on CTile::multiply.
- Parameters:
other – [in] other CTileTensor to multiply.
-
void multiplyRaw(const CTileTensor &other)#
Elementwise multiply with other CTileTensor.
Relies on CTile::multiplyRaw.
- Parameters:
other – [in] other CTileTensor to multiply.
-
void addPlain(const PTileTensor &plain)#
Elementwise add with other (plaintext) PTileTensor.
Relies on CTile::addPlain.
- Parameters:
plain – [in] other PTileTensor to add.
-
void addPlainRaw(const PTileTensor &plain)#
Elementwise add with other (plaintext) PTileTensor.
Relies on CTile::addPlainRaw.
- Parameters:
plain – [in] other PTileTensor to add.
-
void subPlain(const PTileTensor &plain)#
Elementwise subtract other (plaintext) PTileTensor from this.
Relies on CTile::subPlain.
- Parameters:
plain – [in] other PTileTensor to subtract.
-
void subPlainRaw(const PTileTensor &plain)#
Elementwise subtract other (plaintext) PTileTensor from this.
Relies on CTile::subPlainRaw.
- Parameters:
plain – [in] other PTileTensor to subtract.
-
void multiplyPlain(const PTileTensor &plain)#
Elementwise multiply with other (plaintext) PTileTensor.
Relies on CTile::multiplyPlain.
- Parameters:
plain – [in] other PTileTensor to multiply.
-
void multiplyPlainRaw(const PTileTensor &plain)#
Elementwise multiply with other (plaintext) PTileTensor.
Relies on CTile::multiplyPlainRaw.
- Parameters:
plain – [in] other PTileTensor to multiply.
-
void addScalar(double val, bool keepUnknownsClear = false)#
Add scalar to all tensor elements.
Relies on CTile::addScalar. Will add unknowns to unused slots, unless the keepUnknownsClear is set, which causes a more costly operation.
- Parameters:
val – [in] Value to add.
keepUnknownsClear – [in] If set and current shape has no unknowns, it will keep it that way.
-
void multiplyScalar(int val)#
Multiplies all used tensor elements by a given integer scalar.
May consume one chain index. This variant doesn’t clear unknowns. Refer to multiplyScalar(double) that does.
- Parameters:
val – [in] Value to multiply by.
-
void multiplyScalar(double val)#
Multiplies all used tensor elements by a given scalar.
Consumes one chain index. As a side effect, unused elements will be zeroed, thus unknown unused elements will be eliminated.
- Parameters:
val – [in] Value to multiply by.
-
void multiplyScalarRaw(double val)#
Elementwise multiplyScalarRaw.
Relies on CTile::multiplyScalarRaw. This variant doesn’t clear unknowns. Refer to multiplyScalar(double) that does.
-
void square()#
Elementwise square. Relies on CTile::square.
-
void squareRaw()#
Elementwise squareRaw. Relies on CTile::squareRaw.
-
void negate()#
Elementwise negate. Relies on CTile::negate.
-
void multiplyAndSum(const CTileTensor &other, int sumDim)#
Performs elementwise multiplication between this and other, then sums over specified dim.
Example usages: If both are vectors of same length, sum over dim 0 to get inner product If this is a matrix [a/t1,b/t2] and other is a vector [a/t1,*/t2], sum over dim 0 will produce the matrix-vector multiplication. Similarly for matrix [a/t1,b/t2] and vector [*/t1,b/t2], sum over dim 1.
For matrix-matrix multiplication use for example: Matrix1 [ a/t1,b/t2,* /t3] and Matrix2 [a/t1,* / t2, c/t3], sum over dim 0. or: Matrix1 [ a/t1,b/t2,* /t3] and Matrix2 [* / t1,b / t2, c/t3], sum over dim 1.
- Parameters:
other – Other encrypted tile tensor
sumDim – Dimension to sum over
-
void multiplyPlainAndSum(const PTileTensor &other, int sumDim)#
Performs elementwise multiplication between this and other, then sums over specified dim.
See CTileTensor::multiplyAndSum for usage examples.
- Parameters:
other – Other encoded tile tensor
sumDim – Dimension to sum over
-
void applyBitwiseMethod(const CTileTensor &other, const BitwiseEvaluator &be, BitwiseEvaluatorMethod method, ActionType actionType = OTHER_ACTION_TYPE)#
-
void sumOverDim(int dim)#
Sums over a dimension.
- Parameters:
dim – [in] Dimension to sum over.
-
void sumTilesOverDim(int dim)#
Sums tile over a dimension.
-
void sumInTilesOverDim(int dim)#
Sum inside tiles.
This method assumes the external size along this dimension is 1. It reduces the original size to 1 by summing inside the remaining tile.
The result will be duplicated if this is the first non-trivial dimension. Note if the originalSize is 1, this call will still incur rotations if this is the first non-trivial dim, to satisfy the duplicated result requirement.
- Parameters:
dim – Dimension to sum over.
-
void multiplyOverDim(int dim)#
Multiplies over a dimension.
- Parameters:
dim – [in] Dimension to multiply over.
-
void multiplyTilesOverDim(int dim)#
Multiplies tile over a dimension.
-
void multiplyImaginaryUnit()#
Multiply all elements of this CTileTensor by the imaginary unit, i.
-
void duplicateOverDim(int dim)#
Cause a dimension to become duplicated.
- Parameters:
dim – [in] Dimension to duplicate.
-
void clearUnknowns()#
Clears all unknowns from this tile tensor.
-
void flatten(int startDim, int endDim)#
Flattens consecutive dimensions, all having original size of 1, into a single dimension.
The result dimension will have tile size equals to the product of tile sizes of all the flattened dimensions. The result dimension will be considered interleaved if and only if all the flattened dimensions are. The result dimension will be fully duplicated if and only if all the flattened dimensions are. The result dimension will have its unused slots unknown in any case other than the following: either all the flattened dimensions are fully duplicated, or all have no duplicated and no unknown slots.
- Parameters:
startDim – [in] The first dimension to be flattened.
endDim – [in] The dimension in which to end the flattening (exclusive). Flatten(a, b) will flatten dimensions [a,b).
- Throws:
runtime_error – If the specified dimensions do not exist, or are not of original size of 1, or if startDim >= endDim.
-
void flattenFullDims(int startDim, int endDim)#
Flattens consucutive dimension that are full, except the first dimension.
All flattened dimensions except the first one must have external size of 1 and no unused slots. The first dimension can have unused slots and external size larger than one. If it has unknown values, so will the resulting flattened dimension. All flattened dimensions must have basic tiling.
- Parameters:
startDim – The first dimension to be flattened.
endDim – The last dimension to be flattened (exclusive).
-
void reorderDims(const std::vector<DimInt> &dimOrder)#
Reorders the dimensions of this tensor.
The relative order of dimensions with tile size > 1 must be kept. For example, given {1,2,0}, the current second dimension will become first, the current third dimension will become second, and the current first dimension will become last.
- Parameters:
dimOrder – New order of dimensions
- Throws:
runtime_error – If dimOrder size doesn’t match number of dims.
runtime_error – If the relative order of dimensions with tile size > 1 is not the same as in dimOrder.
-
void addDim(int place = -1)#
Adds a dim with original size and tile size 1 to this tensor at given place.
- Parameters:
place – Place of the new dimension, default is last.
-
void removeDim(DimInt dim)#
Removes a dim from this tensor.
Only for dim with original size 1 and tile size 1. Number of dims before calling the function must be at least 3.
- Parameters:
dim – Dim to remove
- Throws:
runtime_error – If dim doesn’t exists
runtime_error – If dim is not of size 1
runtime_error – If number of dims is less than 3
-
void setChainIndex(const CTileTensor &other)#
Calls corresponding function for every CTile.
-
virtual int getChainIndex() const override#
Returns chain index of tiles.
They are maintained to have equal chain index.
-
double getScale() const#
Returns the scale of the tiles.
They are maintained to have equal scales.
-
int getSize() const#
Returns the number of polynomials in the ciphertext (as reduced via relinearization)
-
void reEncrypt()#
Decrypt the CTileTensor and encrypts it again to bring it to top chain index.
- Throws:
runtime_error – if HeContext doesn’t have the secret key.
-
void fakeBootstrap()#
A testing method.
-
void bootstrap()#
Performs bootstrap on all the tiles of this tile tensor.
-
inline virtual const CTile &getTileAt(const std::vector<DimInt> &inds) const override#
Returns the tile specified by the given indices.
- Parameters:
inds – Indices of tiles. Their number should match the number of dimensions, except trailing trivial dimensions where the external size is 1 which may be omitted.
-
virtual const CTile &getTileByFlatIndex(DimInt i) const override#
Returns the i’th tile in a flattened order according to the first-order convention.
- Parameters:
ind – Index of tile
-
inline CTile &internalWriteByFlatIndex(DimInt i)#
Get write access to a tile by its flat index.
This method is for implementing operators that modify CTileTensor objects, and requires careful testing. Use assertIntegrity() in tests to make sure the result is in a consistent state.
- Parameters:
i – flat index
-
inline CTile &internalWriteByIndices(const std::vector<DimInt> &inds)#
Get write access to a tile by its external indices.
This method is for implementing operators that modify CTileTensor objects, and requires careful testing. Use assertIntegrity() in tests to make sure the result is in a consistent state.
- Parameters:
inds – External indices
-
inline TTShape &internalGetShape()#
Get write access to the tile tensor’s shape.
This method is for implementing operators that modify CTileTensor objects, and requires careful testing. Use assertIntegrity() in tests to make sure the result is in a consistent state.
-
void internalChangeMetadata(const TTShape &shape)#
Changes the metadata of this tile tensor to given shape.
This method is for implementing operators that modify CTileTensor objects, and requires careful testing. Use assertIntegrity() in tests to make sure the result is in a consistent state.
- Parameters:
shape – new shape
-
void internalSetPacked()#
Change this object’s state to ‘packed’.
It should be used after creating an empty CTileTensor, and filling its tiles manually using internalWriteBy methods. This method is for implementing operators that modify CTileTensor objects, and requires careful testing. Use assertIntegrity() in tests to make sure the result is in a consistent state.
-
virtual CTileTensor getAdd(const CTileTensor &other) const override#
Returns the result of elementwise add of this and other CTileTensor.
Relies on CTile::add.
- Parameters:
other – [in] other CTileTensor to add.
-
virtual CTileTensor getAddRaw(const CTileTensor &other) const override#
Returns the result of elementwise add of this and other CTileTensor.
Relies on CTile::addRaw.
- Parameters:
other – [in] other CTileTensor to add.
-
virtual void addTo(CTileTensor &other) const override#
Equivalent to other.add(*this)
- Parameters:
other – [in] other CTileTensor to add.
-
virtual void addToRaw(CTileTensor &other) const override#
See addTo()
-
virtual void subFrom(CTileTensor &other) const override#
Equivalent to other.sub(*this)
- Parameters:
other – [in] other CTileTensor to subtract from.
-
virtual void subFromRaw(CTileTensor &other) const override#
See subFrom()
-
virtual void multiplyTo(CTileTensor &other) const override#
Equivalent to other.multiply(*this)
- Parameters:
other – [in] other CTileTensor to multiply to
-
virtual void multiplyToRaw(CTileTensor &other) const override#
See multiplyTo()
-
CTileTensor getSub(const CTileTensor &other) const#
Returns the result of elementwise sub of this and other CTileTensor.
Relies on CTile::sub.
- Parameters:
other – [in] other CTileTensor to sub.
-
CTileTensor getSubTileTensor(const TileTensor &other) const#
Returns the result of elementwise sub of this and other TileTensor.
Relies on CTile::subTile.
- Parameters:
other – Other TileTensor to sub.
-
CTileTensor getSubRaw(const CTileTensor &other) const#
Returns the result of elementwise sub of this and other CTileTensor.
Relies on CTile::subRaw.
- Parameters:
other – [in] other CTileTensor to sub.
-
virtual CTileTensor getMultiply(const CTileTensor &other) const override#
Returns the result of elementwise multiplication of this and other CTileTensor.
Relies on CTile::multiply.
- Parameters:
other – [in] other CTileTensor to multiply.
-
virtual CTileTensor getMultiplyRaw(const CTileTensor &other) const override#
Returns the result of elementwise multiplication of this and other CTileTensor.
Relies on CTile::multiplyRaw.
- Parameters:
other – [in] other CTileTensor to multiply.
-
CTileTensor getAddPlain(const PTileTensor &plain) const#
Returns the result of elementwise add with other (plaintext) PTileTensor.
Relies on CTile::addPlain.
- Parameters:
plain – [in] other PTileTensor to add.
-
CTileTensor getAddPlainRaw(const PTileTensor &plain) const#
Returns the result of elementwise add with other (plaintext) PTileTensor.
Relies on CTile::addPlainRaw.
- Parameters:
plain – [in] other PTileTensor to add.
-
CTileTensor getSubPlain(const PTileTensor &plain) const#
Returns the result of elementwise subtract with other (plaintext) PTileTensor.
Relies on CTile::subPlain.
- Parameters:
plain – [in] other PTileTensor to subtract.
-
CTileTensor getSubPlainRaw(const PTileTensor &plain) const#
Returns the result of elementwise subtract with other (plaintext) PTileTensor.
Relies on CTile::subPlainRaw.
- Parameters:
plain – [in] other PTileTensor to subtract.
-
CTileTensor getMultiplyPlain(const PTileTensor &plain) const#
Returns the result of elementwise multiplication with other (plaintext) PTileTensor.
Relies on CTile::multiplyPlain.
- Parameters:
plain – [in] other PTileTensor to multiply.
-
CTileTensor getMultiplyPlainRaw(const PTileTensor &plain) const#
Returns the result of elementwise multiplication with other (plaintext) PTileTensor.
Relies on CTile::multiplyPlainRaw.
- Parameters:
plain – [in] other PTileTensor to multiply.
-
CTileTensor getAddScalar(double val) const#
Returns the result of addition with a scalar.
- Parameters:
val – [in] Scalar to add.
-
CTileTensor getMultiplyScalar(double val) const#
Returns the result of multiplication with a scalar.
- Parameters:
val – [in] Scalar to multiply.
-
CTileTensor getSquare() const#
Returns the result of elementwise squaring.
Relies on CTile::square.
-
CTileTensor getSquareRaw() const#
Returns the result of elementwise squaring.
Relies on CTile::squareRaw.
-
virtual CTileTensor getMultiplyAndSum(const CTileTensor &other, int dim) const override#
Returns the result of elementwise multiplication of this and other and summing over specified dim.
See CTileTensor::multiplyAndSum for usage examples.
- Parameters:
other – Other encrypted tile tensor
dim – Dimension to sum over
-
virtual CTileTensor getMultiplyPlainAndSum(const PTileTensor &other, int dim) const#
Returns the result of elementwise multiplication of this and other and summing over specified dim.
See CTileTensor::multiplyAndSum for usage examples.
- Parameters:
other – Other encoded tile tensor
dim – Dimension to sum over
-
virtual void multiplyAndSumTo(CTileTensor &other, int dim) const override#
Equivalent to other.multiplyAndSum(*this, dim)
- Parameters:
other – Other encrypted tile tensor
dim – Dimension to sum over
-
CTileTensor getMatrixMultiplication(const TileTensor &other, int sumDim) const#
Computes matrix-vector multiplication with other.
For non-diagonalized computation, it calls getMultiplyAndSum() (See documentation in getMultiplyAndSum())
For diagonalization, other shape should be diagonalized. (See TTShape::setDiagonalized()) For example: Other is a matrix [(d)16/t1,6/t2,…] This is a vector [16/t1*t2,…] Result is [*/t1,6/t2,…]
Constraints:
other should be diagonalized
this should not be diagonalized
this tile size 0 should equal other tileSize0*tileSize1
this original size 0 should equal other original size 0
this dims 1..end should be identical to other dims 2..end. (will be extended to support comptability)
sumDim must be 0
- Parameters:
other – Other tile tensor to multiply with
sumDim – Dimension to sum over
-
CTileTensor getRelinearize() const#
Returns result with applying CTile::relinearize to all tiles.
-
CTileTensor getRescale() const#
Returns result with applying CTile::rescale to all tiles.
-
CTileTensor getSumOverDim(int dim) const#
Returns result of summing over a dimension.
- Parameters:
dim – Dimension to sum over
-
CTileTensor getSumTilesOverDim(int dim) const#
Returns results of summing tiles over a dimension.
Note this is function is used as an intermediate step when summing over dim. Most users should call getSumOverDim() directly.
- Parameters:
dim – Dimension to sum over
-
CTileTensor getSumInTilesOverDim(int dim) const#
Returns results of summing inside tiles over a dimension.
Note this is function is used as an intermediate step when summing over dim. Most users should call getSumOverDim() directly.
- Parameters:
dim – Dimension to sum over
-
CTileTensor getMultiplyImaginaryUnit() const#
Returns the result of multiplying all tiles of this CTileTensor by the imaginary unit, i.
-
CTileTensor getDuplicateOverDim(int dim) const#
Returns results of duplicating a dimension.
- Parameters:
dim – Dimension duplicate.
-
CTileTensor getClearUnknowns() const#
Returns results after multiplying with a mask to clear unknowns.
-
CTileTensor getFlatten(int startDim, int endDim) const#
Returns the results after flatting some dimensions.
See flatten()
- Parameters:
startDim – The first dimension to be flattened.
endDim – The dimension in which to end the flattening (exclusive). Flatten(a, b) will flatten dimensions [a,b).
-
CTileTensor getReduceChainIndex() const#
Returns results after applying CTile::reduceChainIndex to all tiles.
-
CTileTensor getSetChainIndex(const CTileTensor &other) const#
Returns the results after setting chain index to equal other object.
- Parameters:
other – Other object to take chain index from.
-
CTileTensor getSetChainIndex(int chainIndex) const#
Returns the results after setting chain index.
- Parameters:
chainIndex – Chain index to set.
-
CTileTensor getConvolution(const CTileTensor &filters, const CTileTensor *biases, int strideRows, int strideCols) const#
Returns the result of convolution between this and filters, with specified strides.
Assumes all tensors are packed in SIMD fashion.
- Parameters:
filters – Convolution filters
biases – Biases to add (optional)
strideRows – Filter strides on rows
strideCols – Filter strides on cols
-
CTileTensor getSlice(DimInt dim, DimInt startIndex, DimInt sliceDepth = 1) const#
Returns a slice of the tensor in specific dimension.
Result has the same number of dimensions as the original tensor. For dim with tile size of 1, or for interleaved dim, getSlice is supported for every valid startIndex and sliceDepth. For a non-interleaved dim with tile size > 1, getSlice is supported only for startIndex which is a multiple of the tile size.
- Parameters:
dim – The dimension to slice along. Specifying negative value will count from the last dim backwards (-1 for the last dim, -2 for the previous one etc.).
startIndex – The index to start slicing at along the dimension
sliceDepth – The depth/size of the slice along the dimension
- Throws:
invalid_argument – If the given dimension is greater or equal to the total number of dimensions in this TileTensor
invalid_argument – If startIndex + sliceDepth is greater than the original size of the given dimension.
invalid_argument – If the tile size of the given dimension is different than 1, unless the conditions described above are fulfilled.
-
CTileTensor getConjugate() const#
Returns the result of applying complex conjugate on all tiles of this CTileTensor.
-
void setDimInterleaved(DimInt dim, bool isInterleaved)#
Turns interleave flag on or off for specific dim without changing the underlying tiling.
Can be used only if dim original size is 1.
- Parameters:
dim – Which dimension to set
isInterleaved – Whether this dimension is interleaved
- Throws:
invalid_argument – If dim doesn’t exists
invalid_argument – If dim original size > 1
-
void rotateAlongDim(int dim, int rot)#
Rotates this CTileTensor along the specified dimension (index (i+rot) % originalSize moves to i).
The elements that fall out of one end cycle back in the other end. If the external size of “dim” is not 1, then “dim” must be interleaved. If the external size of “dim” is 1, the rotation works and will have the same effect regardless of the interleaved flag being on or off. For the rotation to succeed, “dim” must be the first non-trivial” dimension, and it must not contain any unused slots.
- Parameters:
dim – The dimension to rotate along.
rot – The rotation offset.
- Throws:
invalid_argument – If the rotated dimension does not satisfy the above requirements.
-
void pseudoRotateAlongDim(DimInt dim, DimInt offset, bool realRotate = false)#
Applies a “pseudo rotation” on this CTileTensor by the given offset along dimension “dim”.
If “realRotate” is true, the function verifies that a real rotation is performed, meaning that the values that fall out of one end must cycle back to the other end. If “realRotate” is false, a pseudo rotation is performed, meaning that the values that fall out of one end are not guaranteed to cycle back to the other end. To Perform a real rotation, “dim” must be the first non-trivial dimension and it mustn’t contain any unused slots. In both cases (a real or a pseudo rotate), if the external size of “dim” is not 1, then “dim” must be interleaved. If the external size of “dim” is 1, the rotation works and will have the same effect regardless of the interleaved flag being on or off.
- Parameters:
dim – The dimensions to rotate along.
offset – The rotation offset.
realRotate – If true, the function asserts that a true rotation is performed.
- Throws:
invalid_argument – If realRotate is true but the conditions above don’t hold.
-
CTileTensor getPseudoRotateAlongDim(DimInt dim, DimInt offset, bool realRotate = false) const#
Returns the result of calling psuedoRotateAlongDim.
See also psuedoRotateAlongDim().
-
void conjugate()#
Conjugates contents of this CTileTensor in place, tile-wise.
For non-complex numbers this has no effect.
-
virtual double assertIntegrity(double epsilon = 1e-6) const override#
Validates the integrity of the tile tensor.
Used for internal checks only. Returns the maximal diff found. If uninitialized, returns 0
- Parameters:
epsilon – Tolerance for diffs.
- Throws:
runtime_error – if test fails
-
virtual void debugPrint(const std::string &title = "", Verbosity verbosity = VERBOSITY_REGULAR, std::ostream &out = std::cout) const override#
Prints the content of this object.
- Parameters:
title – Text to add to the print
verbosity – Verbosity level
out – Output stream
-
inline virtual int32_t getContextId() const override#
Returns the contextId of the HeContext this object was initialized with.
This contextId can be used, for example, to verify HeContext match when loading a saved Saveable object. Returning -1 signals no HeContext.
-
virtual void sleep(bool shouldSaveToFile = false) override#
Clears data if lazyMode is LAZY_ENCODING or LAZY_LOADING, also saves data to disk if lazyMode is LAZY_LOADING and shouldSaveToFile flag is true, and does nothing otherwise.
- Parameters:
shouldSaveToFile – Whether to also save data to disk if lazyMode is LAZY_LOADING.
-
virtual void wakeup() override#
Encodes data if lazyMode is LAZY_ENCODING, loads data if lazyMode is LAZY_LOADING, and does nothing otherwise.
-
void resizeOriginalDim(DimInt dim, DimInt newSize)#
Change the original size of a tensor along a dimension.
The external-size may change accordingly. If new CTiles need to be added to the tensor they are added as 0s.
- Parameters:
dim – The dimension whose size changes
newSize – The new original size.
-
PTileTensor getPlainScalarMask(double val) const#
Returns a plaintext mask that contains the given value in all the slots that correspond to used slots of this object, and zeros in all the slots correspond to unused slots of this object.
The mask will have the same chain index as this.
- Parameters:
val – the value to put in the scalar mask.
-
inline virtual bool isEncrypted() const override#
Returns whether this tile tensor is encrypted or just encoded.
Public Static Functions
-
static CTileTensor createSingleTile(const HeContext &he, const TTShape &shape, const CTile &tile)#
Creates a CTileTensor with one tile.
- Parameters:
he – The HeContext.
shape – The shape of the CTileTensor to create. Each dimension of this shape must be either incomplete, t_i/t_i or n_i?/t_i for n_i < t_i. If a dimension is incomplete, it will be replaced with t_i/t_i in the resulting CTileTensor.
tile – The only tile of the created CTileTensor.
- Throws:
invalid_argument – If the given shape does not satisfy the requirement above.
-
static CTileTensor internalCreateFromCTileVector(const HeContext &he, const TTShape &shape, const std::vector<CTile> &tilesVec)#
Creates a CTileTensor from the given vector of CTiles.
This method is for implementing operators that modify CTileTensor objects, and requires careful testing. Use assertIntegrity() in tests to make sure the result is in a consistent state. first-order orientation. The created CTileTensor will have the given shape, which is assumed to be complete (i.e. with all original sizes set).
- Parameters:
he – The HeContext to initialize the created CTileTensor with.
shape – The shape of the resulting CTileTensor.
tilesVec – The vector of CTiles, in first-order orientation.
- Throws:
invalid_argument – If “shape” doesn’t satisfy the above assumptions.
-
static CTileTensor combineAlongDim(const std::vector<CTileTensor> &ctts, DimInt dim)#
Combines the given CTileTensors into one by composing them along the specified dimension.
All of the given CTileTensors must have the same shape and chain index. The dimension to combine along mustn’t be duplicated and it mustn’t have any unused slots. Combining along a non-trivial interleaved dimension (i.e. originalSize > 1) is not supported. The resulting CTileTensor has the same number of dimensions as the source CTileTensors. When combining along a trivial interleaved dimension, the combined dimension of the result will not be interleaved. The original size of the combined dimension is multiplied by the number of CTileTensors to combine. Other than that, all aspects of the shape of the result stay the same as the source CTileTensors.
- Parameters:
ctts – The CTileTensors to combine.
dim – The dimension to combine along
- Throws:
invalid_argument – If the conditions above don’t hold, if “ctts” is empty or if “dim” is negative or greater or equal to the order of the given CTileTensors.
-
static CTileTensor combine(const std::vector<std::vector<std::vector<CTileTensor>>> &cts)#
Combines the given CTileTensors into one CTileTensor.
All of the given CTileTensors must have the same shape and chain index. Let cts be of dimensions [d0,d1,d2]. The shape of the combined CTileTensor is given by adding the dimensions [d0/1,d1/2,d2/1] to the shape of the given CTileTensors. cts[i][j][k][…] will be copied into indexes [i,j,k,…] of the combined CTileTensor.
- Parameters:
cts – A 3D tensor of CTileTensors to combine.
- Throws:
invalid_Argument – If “cts” does not represent a 3D tensor (e.g. if cts[i].size() != cts[j].size() for some i,j).
invalid_argument – If one of cts, cts[0] or cts[0][0] is an empty vector.
invalid_argument – If the given CTileTensors don’t have different shapes or different chain indexes.
Friends
- friend class circuit::Runner
-
typedef boost::numeric::ublas::tensor<CTile, PTileTensor::tensorFormat> ExternalTensorType#