IRGenerator

class IRGenerator : public xacc::Instruction

The IRGenerator interface provides a mechanism for generating common algorithms modeled as an XACC Function instance.

Author

Alex McCaskey

Subclassed by xacc::quantum::InverseQFT, xacc::quantum::QFT, xacc::rbm::RBMGenerator

Public Functions

virtual std::shared_ptr<Function> generate(std::shared_ptr<AcceleratorBuffer> buffer, std::vector<InstructionParameter> parameters = std::vector<InstructionParameter>{}) = 0

Implementations of this method generate a Function IR instance corresponding to the implementation’s modeled algorithm. The algorithm is specified to operate over the provided AcceleratorBuffer and can take an optional vector of InstructionParameters.

Return

function The algorithm represented as an IR Function

Parameters
  • bits: The bits this algorithm operates on

const std::string toString(const std::string &bufferVarName)

Persist this Instruction to an assembly-like string with a given bit buffer variable name.

Return

str The assembly-like string.

Parameters

const std::string toString()

Persist this Instruction to an assembly-like string.

Return

str The assembly-like string.

const std::vector<int> bits()

Return the indices of the bits that this Instruction operates on.

Return

bits The bits this Instruction operates on.

InstructionParameter getParameter(const int idx) const

Return this Instruction’s parameter at the given index.

Return

param The InstructionParameter at the given index.

Parameters
  • idx: The index of the parameter.

std::vector<InstructionParameter> getParameters()

Return all of this Instruction’s parameters.

Return

params This instructions parameters.

void setParameter(const int idx, InstructionParameter &inst)

Set this Instruction’s parameter at the given index.

Parameters
  • idx: The index of the parameter

  • inst: The instruction.

const int nParameters()

Return the number of InstructionParameters this Instruction contains.

Return

nInsts The number of instructions.

bool isParameterized()

Return true if this Instruction is parameterized.

Return

parameterized True if this Instruction has parameters.

void mapBits(std::vector<int> bitMap)

Map bits [0,1,2,…] to [bitMap[0],bitMap[1],…]

Parameters
  • bitMap: The bits to map to

void setOption(const std::string optName, InstructionParameter option)

Set the value of an option with the given name.

Parameters
  • optName: The name of the option.

  • option: The value of the option

InstructionParameter getOption(const std::string optName)

Get the value of an option with the given name.

Return

option The value of the option.

Parameters
  • optName: Then name of the option.

std::map<std::string, InstructionParameter> getOptions()

Return all the Instructions options as a map.

Return

optMap The options map.

virtual ~IRGenerator()

The destructor