Template Class TNCudaGateCache¶
Defined in File TNCudaGateCache.hpp
Nested Relationships¶
Nested Types¶
Class Documentation¶
-
template<class PrecisionT>
class TNCudaGateCache¶ Memory management for gate tensor data on device and its id in the compute graph.
- Template Parameters:
PrecisionT – Floating point precision.
Public Types
-
using CFP_t = decltype(cuUtil::getCudaType(PrecisionT{}))¶
-
using gate_key_info = std::pair<const std::string, std::vector<PrecisionT>>¶
-
using gate_info = std::pair<gate_key_info, TensorCuda<PrecisionT>>¶
Public Functions
-
TNCudaGateCache() = delete¶
-
TNCudaGateCache(const TNCudaGateCache &other) = delete¶
-
TNCudaGateCache(TNCudaGateCache &&other) = delete¶
-
inline TNCudaGateCache(int device_id = 0, cudaStream_t stream_id = 0)¶
-
inline TNCudaGateCache(const DevTag<int> device_tag)¶
-
inline ~TNCudaGateCache()¶
-
inline void add_gate(const std::size_t gate_id, const std::string &gate_name, std::vector<PrecisionT> gate_param = {}, bool adjoint = false)¶
Add gate numerical value to the cache, indexed by the id of gate tensor operator in the graph and its name and parameter value are recorded as well.
- Parameters:
gate_id – The id of gate tensor operator in the computate graph.
gate_name – String representing the name of the given gate.
gate_param – Vector of parameter values.
{}if non-parametric gate.adjoint – Boolean value indicating whether the adjoint of the gate is to be appended. The default is false.
-
inline void add_gate(const std::size_t gate_id, gate_key_info gate_key, const std::vector<CFP_t> &gate_data_host, bool adjoint = false)¶
Add gate numerical value to the cache, indexed by the id of gate tensor operator in the graph and its name and parameter value as well as the gate data on host.
- Parameters:
gate_id – The id of gate tensor operator in the computate graph.
gate_key – String representing the name of the given gate as well as its associated parameter value.
gate_data_host – Vector of complex floating point values representing the gate data on host.
adjoint – Boolean value indicating whether the adjoint of the gate is to be appended. The default is false.
-
inline CFP_t *get_gate_device_ptr(const std::size_t gate_id)¶
Returns a pointer to the GPU device memory where the gate is stored.
- Parameters:
gate_id – The id of gate tensor operator in the computate graph.
- Returns:
const CFP_t* Pointer to gate values on device.
-
inline auto size() const -> std::size_t¶
Returns the size of the
device_gates_.- Returns:
std::size_t Size of
device_gates_.
-
inline void update_key(const std::size_t old_key, const std::size_t new_key)¶
Update an existing key with a new one.
- Parameters:
old_key – The old key to be updated.
new_key – The new key to be updated.