MLIR Passes v1.0
Loading...
Searching...
No Matches
Quake.hpp File Reference

Go to the source code of this file.

Functions

Value mqss::support::quakeDialect::createFloatValue (OpBuilder &builder, Location loc, double value)
 Function that creates an mlir::Value associated to a numeric value.
 
double mqss::support::quakeDialect::extractDoubleArgumentValue (Operation *op)
 Function that extracts a double numeric value from a numeric value in an MLIR module.
 
int64_t mqss::support::quakeDialect::extractIndexFromQuakeExtractRefOp (Operation *op)
 Function that extracts an index of a given ExtractRefOp operation.
 
int mqss::support::quakeDialect::getNumberOfQubits (func::FuncOp circuit)
 Function that get the number of qubits used by a given quantum kernel.
 
int mqss::support::quakeDialect::getNumberOfClassicalBits (func::FuncOp circuit, std::map< int, int > &measurements)
 Function that get the number of classical bits used by a given quantum kernel.
 
int mqss::support::quakeDialect::getNumberOfClassicalBits (func::FuncOp circuit)
 Function that get the number of classical bits used by a given quantum kernel.
 
std::vector< int > mqss::support::quakeDialect::getIndicesOfValueRange (mlir::ValueRange array)
 Function that get a vector of indices associated with a given mlir::ValueRange.
 
std::vector< double > mqss::support::quakeDialect::getParametersValues (mlir::ValueRange array)
 Function that get a vector of numerical values associated with a given mlir::ValueRange.
 
mlir::Operation * mqss::support::quakeDialect::getPreviousOperationOnTarget (mlir::Operation *currentOp, mlir::Value targetQubit)
 Function get the previous operation on a given target qubit.
 
mlir::Operation * mqss::support::quakeDialect::getNextOperationOnTarget (mlir::Operation *currentOp, mlir::Value targetQubit)
 Function get the next operation on a given target qubit.
 

Detailed Description

This header defines a set of functions that are useful to get information from MLIR modules. E.g., extract the number of qubits, the classical registers. Moreover, it also allows to define variables as MLIR constructs.

This header must be included to use the available functions to manipulate MLIR modules.

Function Documentation

◆ createFloatValue()

Value mqss::support::quakeDialect::createFloatValue ( OpBuilder & builder,
Location loc,
double value )

Function that creates an mlir::Value associated to a numeric value.

This functions appends an mlir::Value into an MLIR module associated to the input OpBuilder.

Parameters
[out]builderis an OpBuilder object associated with a MLIR module. It is used to insert new instructions to the corresponding MLIR module.
[in]locis the location of the new inserted instruction.
[in]valueis the numeric value to be defined into the MLIR module.
Returns
an mlir::Value object of the inserted numerical value.

◆ extractDoubleArgumentValue()

double mqss::support::quakeDialect::extractDoubleArgumentValue ( Operation * op)

Function that extracts a double numeric value from a numeric value in an MLIR module.

This functions extracts a double from an MLIR Operation.

Parameters
[in]opis the MLIR Operation containing a numerical value.
Returns
a double with the numerical value of op.

◆ extractIndexFromQuakeExtractRefOp()

int64_t mqss::support::quakeDialect::extractIndexFromQuakeExtractRefOp ( Operation * op)

Function that extracts an index of a given ExtractRefOp operation.

Given an ExtractRefOp, this function extracts the integer of the index pointing that reference (qubit index), returns -1 when fail.

Parameters
[in]opis the MLIR ExtractRefOp.
Returns
a int with the index of the given ExtractRefOp.

◆ getIndicesOfValueRange()

std::vector< int > mqss::support::quakeDialect::getIndicesOfValueRange ( mlir::ValueRange array)

Function that get a vector of indices associated with a given mlir::ValueRange.

Given a mlir::ValueRange that stores a list of indices. This function converts the mlir::ValueRange to a vector of int.

Parameters
[in]arrayis the input mlir::ValueRange.
Returns
a vector of indices stored in the input mlir::ValueRange object.

◆ getNextOperationOnTarget()

mlir::Operation * mqss::support::quakeDialect::getNextOperationOnTarget ( mlir::Operation * currentOp,
mlir::Value targetQubit )

Function get the next operation on a given target qubit.

Given a mlir::Operation and a target qubit. This function get the next operation on the given target qubit, starting from currentOp.

Parameters
[in]currentOpis current quantum gate.
[in]targetQubitis the target qubit to be used as reference.
Returns
an mlir::Operation which is the next operation on the given target qubit.

◆ getNumberOfClassicalBits() [1/2]

int mqss::support::quakeDialect::getNumberOfClassicalBits ( func::FuncOp circuit)

Function that get the number of classical bits used by a given quantum kernel.

Given a func::FuncOp that stores a quantum kernel in Quake. This function returns the number of declared classical bits within the given quantum kernel.

Parameters
[in]circuitis the input quantum kernel
Returns
the number of classical bits declared in the given quantum kernel.

◆ getNumberOfClassicalBits() [2/2]

int mqss::support::quakeDialect::getNumberOfClassicalBits ( func::FuncOp circuit,
std::map< int, int > & measurements )

Function that get the number of classical bits used by a given quantum kernel.

Given a func::FuncOp that stores a quantum kernel in Quake. This function returns the number of declared classical bits within the given quantum kernel.

Parameters
[in]circuitis the input quantum kernel
[out]measurementsis a std::map<int, int>. This map maps the qubits with its corresponding classical bit. The key is the qubit index and the value is the classical bit index.
Returns
the number of classical bits declared in the given quantum kernel.

◆ getNumberOfQubits()

int mqss::support::quakeDialect::getNumberOfQubits ( func::FuncOp circuit)

Function that get the number of qubits used by a given quantum kernel.

Given a func::FuncOp that stores a quantum kernel in Quake. This function returns the number of declared qubits within the given quantum kernel.

Parameters
[in]circuitis the input quantum kernel
Returns
a int with the number of declared qubits.

◆ getParametersValues()

std::vector< double > mqss::support::quakeDialect::getParametersValues ( mlir::ValueRange array)

Function that get a vector of numerical values associated with a given mlir::ValueRange.

Given a mlir::ValueRange that stores a list of parameters, i.e., rotation angles. This function converts the mlir::ValueRange to a vector of double.

Parameters
[in]arrayis the input mlir::ValueRange containing the parameters.
Returns
a vector of double stored in the input mlir::ValueRange object.

◆ getPreviousOperationOnTarget()

mlir::Operation * mqss::support::quakeDialect::getPreviousOperationOnTarget ( mlir::Operation * currentOp,
mlir::Value targetQubit )

Function get the previous operation on a given target qubit.

Given a mlir::Operation and a target qubit. This function get the previous operation on the given target qubit, starting from currentOp.

Parameters
[in]currentOpis current quantum gate.
[in]targetQubitis the target qubit to be used as reference.
Returns
an mlir::Operation which is the previous operation on the given target qubit.