ComputeRequest Class

The ComputeRequest class represents a request sent to the OpenVector network to perform a computation. It encapsulates the operation to be performed, along with the operands required for the computation.

Public Member Classes and Enums

enum class ComputeOperationType

Specifies the parity of the compute operation.

  • Values:

    • UNARY: Operation with one operand.

    • BINARY: Operation with two operands.

    • TERNARY: Operation with three operands.

enum class ComputeOperation

Specifies the type of computation to perform.

  • Values:

    • DECRYPT

    • ADD

    • SUBTRACT

    • MULTIPLY

    • DIVIDE

enum class DataType

Specifies the type of data being used.

  • Values:

    • SINGLE: Single data element.

    • TENSOR: Tensor data.

    • TENSOR_ID: Reference to a tensor ID (data encryption type is ignored).

enum class DataEncrytionType

Specifies whether the data is in plaintext or ciphertext form.

  • Values:

    • PLAINTEXT

    • CIPHERTEXT

class ComputeOperationOperand

Represents an operand in a compute operation.

Constructors

  • ComputeOperationOperand(DataType data_type, DataEncrytionType encryption_type, std::string data);

    Creates an operand with the specified data type, encryption type, and data.

Member Functions

  • DataType& data_type();

    Returns a reference to the data type.

  • const DataType& data_type() const;

    Returns a constant reference to the data type.

  • DataEncrytionType& encryption_type();

    Returns a reference to the encryption type.

  • const DataEncrytionType& encryption_type() const;

    Returns a constant reference to the encryption type.

  • std::string& data();

    Returns a reference to the data string.

  • const std::string& data() const;

    Returns a constant reference to the data string.

  • std::string to_string() const;

    Serializes the operand to a string.

  • static ComputeOperationOperand from_string(const std::string& str);

    Deserializes an operand from a string.

  • static std::vector<ComputeOperationOperand> from_string(const std::string& str, size_t num_operands);

    Deserializes multiple operands from a string.

class ComputeOperationInstance

Represents an instance of a compute operation, including its type and operands.

Constructors

  • ComputeOperationInstance(const ComputeOperationType& operation_type, const ComputeOperation& operation, const std::vector<ComputeOperationOperand>& operands);

    Creates a compute operation instance.

Member Functions

  • ComputeOperationType& operation_type();

    Returns a reference to the operation type.

  • const ComputeOperationType& operation_type() const;

    Returns a constant reference to the operation type.

  • ComputeOperation& operation();

    Returns a reference to the operation.

  • const ComputeOperation& operation() const;

    Returns a constant reference to the operation.

  • std::vector<ComputeOperationOperand>& operands();

    Returns a reference to the vector of operands.

  • const std::vector<ComputeOperationOperand>& operands() const;

    Returns a constant reference to the vector of operands.

  • std::string to_string() const;

    Serializes the operation instance to a string.

  • static ComputeOperationInstance from_string(const std::string& str);

    Deserializes an operation instance from a string.

Constructors

ComputeRequest(const ComputeOperationInstance& operation);

Creates a compute request with the specified operation instance.

Member Functions

  • ComputeOperationInstance& operation();

    Returns a reference to the compute operation instance.

  • const ComputeOperationInstance& operation() const;

    Returns a constant reference to the compute operation instance.

  • std::string to_string() const;

    Serializes the compute request to a string.

  • static ComputeRequest from_string(const std::string& str);

    Deserializes a compute request from a string.

Usage Example

Notes

  • When creating a ComputeRequest, ensure that the data in operands is correctly serialized and corresponds to the expected encryption and data types.

  • The ComputeOperation enum defines basic arithmetic operations and decryption. More operations can be added as needed.

See Also

Last updated