Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
gate_counter.hpp
Go to the documentation of this file.
1
#pragma once
2
#include <cstdint>
3
#include <utility>
4
#include <vector>
5
6
namespace
acir_format
{
7
12
template
<
typename
Builder>
class
GateCounter
{
13
public
:
14
GateCounter
(
Builder
*
builder
,
bool
collect_gates_per_opcode
)
15
:
builder
(
builder
)
16
,
collect_gates_per_opcode
(
collect_gates_per_opcode
)
17
{}
18
19
size_t
compute_diff
()
20
{
21
if
(!
collect_gates_per_opcode
) {
22
return
0;
23
}
24
size_t
new_gate_count =
builder
->get_num_finalized_gates_inefficient(
/*ensure_nonzero=*/
false
);
25
size_t
diff = new_gate_count -
prev_gate_count
;
26
prev_gate_count
= new_gate_count;
27
return
diff;
28
}
29
30
void
track_diff
(std::vector<size_t>& gates_per_opcode,
size_t
opcode_index)
31
{
32
if
(
collect_gates_per_opcode
) {
33
gates_per_opcode[opcode_index] =
compute_diff
();
34
}
35
}
36
37
private
:
38
Builder
*
builder
;
39
bool
collect_gates_per_opcode
;
40
size_t
prev_gate_count
{};
41
};
42
}
// namespace acir_format
acir_format::GateCounter
Utility class for tracking the gate count of acir constraints.
Definition
gate_counter.hpp:12
acir_format::GateCounter::collect_gates_per_opcode
bool collect_gates_per_opcode
Definition
gate_counter.hpp:39
acir_format::GateCounter::compute_diff
size_t compute_diff()
Definition
gate_counter.hpp:19
acir_format::GateCounter::builder
Builder * builder
Definition
gate_counter.hpp:38
acir_format::GateCounter::track_diff
void track_diff(std::vector< size_t > &gates_per_opcode, size_t opcode_index)
Definition
gate_counter.hpp:30
acir_format::GateCounter::GateCounter
GateCounter(Builder *builder, bool collect_gates_per_opcode)
Definition
gate_counter.hpp:14
acir_format::GateCounter::prev_gate_count
size_t prev_gate_count
Definition
gate_counter.hpp:40
bb::ECCVMCircuitBuilder
Definition
eccvm_circuit_builder.hpp:24
acir_format
Definition
acir_format.cpp:30
src
barretenberg
dsl
acir_format
gate_counter.hpp
Generated by
1.9.8