forked from NVIDIA/cuda-quantum
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTrace.h
More file actions
52 lines (40 loc) · 1.9 KB
/
Trace.h
File metadata and controls
52 lines (40 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/****************************************************************-*- C++ -*-****
* Copyright (c) 2022 - 2025 NVIDIA Corporation & Affiliates. *
* All rights reserved. *
* *
* This source code and the accompanying materials are made available under *
* the terms of the Apache License 2.0 which accompanies this distribution. *
******************************************************************************/
#pragma once
#include "cudaq/qis/execution_manager.h"
#include <string>
#include <vector>
namespace cudaq {
struct QuditInfo;
/// @brief A trace is a circuit representation of the executed computation, as
/// seen by the execution manager. (Here, a circuit is represented as a list
/// of instructions on qudits). Since the execution manager cannot "see" control
/// flow, the trace of a kernel with control flow represents a single execution
/// path, and thus two calls to the same kernel might produce traces.
class Trace {
public:
struct Instruction {
std::string name;
std::vector<double> params;
std::vector<QuditInfo> controls;
std::vector<QuditInfo> targets;
Instruction(std::string_view name, std::vector<double> params,
std::vector<QuditInfo> controls, std::vector<QuditInfo> targets)
: name(name), params(params), controls(controls), targets(targets) {}
};
void appendInstruction(std::string_view name, std::vector<double> params,
std::vector<QuditInfo> controls,
std::vector<QuditInfo> targets);
auto getNumQudits() const { return numQudits; }
auto begin() const { return instructions.begin(); }
auto end() const { return instructions.end(); }
private:
std::size_t numQudits = 0;
std::vector<Instruction> instructions;
};
} // namespace cudaq