3#include <nlohmann/json.hpp>
27 std::vector<long long>
axes;
48 std::vector<std::size_t>
axes;
84 is_nditer_call(
const nlohmann::json &node,
const nlohmann::json &ast);
87 void create(
const std::string &name,
const nlohmann::json &
call);
94 bool bind(
const nlohmann::json &target,
const nlohmann::json &value);
96 std::optional<exprt>
attribute(
const nlohmann::json &node);
97 std::optional<exprt>
call(
const nlohmann::json &node);
98 std::optional<exprt>
read_item(
const nlohmann::json &name);
99 std::optional<exprt>
subscript(
const nlohmann::json &node);
101 bool write(
const nlohmann::json &target,
const nlohmann::json &value);
105 void keep_sources(
const std::string &rebound_id,
const std::string &heir_id);
107 static std::string
key(
const std::string &
function,
const std::string &name);
115 std::optional<numpy_nditer_state>
116 describe(
const nlohmann::json &
call,
const std::string &state);
117 std::vector<nlohmann::json> evaluate_operands(
118 const std::vector<nlohmann::json> &ops,
119 const std::vector<std::vector<std::string>> &op_flags);
121 nlohmann::json named_operand(
const nlohmann::json &node, std::size_t index);
124 template <
class Info>
126 template <
class Info>
128 std::string invalid_setup(
129 const std::vector<std::string> &flag_list,
130 const std::string &order_name)
const;
131 std::string invalid_tracking(
const std::vector<std::string> &flag_list)
const;
132 nlohmann::json flat_index(
134 const std::vector<nlohmann::json> &axis_index)
const;
135 bool writable_operands_fit(
137 const std::vector<std::vector<std::string>> &op_flags);
139 std::vector<std::string> flags(
const nlohmann::json &
call);
140 std::string order(
const nlohmann::json &
call);
145 std::string invalid_op_axes(
147 const std::vector<long long> &axes,
148 std::size_t op)
const;
151 nlohmann::json
value(
154 const nlohmann::json &element_position);
160 std::vector<nlohmann::json> indices(
162 const nlohmann::json &element_position)
const;
163 nlohmann::json element(
166 const nlohmann::json &element_position)
const;
169 nlohmann::json prebuilt(
const exprt &expr);
171 bool substitute_chunks(nlohmann::json &node);
173 void assign(
const std::string &name,
const nlohmann::json &value);
174 void raise(
const std::string &exception,
const std::string &message);
176 const nlohmann::json &
cond,
177 const std::string &exception,
178 const std::string &message);
184 const nlohmann::json &target,
186 const std::string &iterator,
189 const nlohmann::json &target,
191 const std::string &iterator,
192 const nlohmann::json &index);
194 const nlohmann::json &target,
196 const std::string &iterator);
204 std::tuple<const numpy_nditer_state *, std::size_t, nlohmann::json>>
205 written(
const nlohmann::json &target);
206 nlohmann::json call_method(
208 const std::string &method,
209 const nlohmann::json &node);
std::optional< exprt > read_item(const nlohmann::json &name)
Definition numpy_nditer.cpp:1718
std::optional< exprt > call(const nlohmann::json &node)
Definition numpy_nditer.cpp:1656
void keep_sources(const std::string &rebound_id, const std::string &heir_id)
Before the array rebound_id names is rebound: the iterators over it keep the old storage,...
Definition numpy_nditer.cpp:1850
std::optional< exprt > subscript(const nlohmann::json &node)
Definition numpy_nditer.cpp:1732
bool write(const nlohmann::json &target, const nlohmann::json &value)
x[...] = value on what the iterator yields; false for other targets.
Definition numpy_nditer.cpp:1815
std::optional< exprt > attribute(const nlohmann::json &node)
Definition numpy_nditer.cpp:1622
exprt as_list(const nlohmann::json &call)
The elements a bare np.nditer(...) yields, in visiting order.
Definition numpy_nditer.cpp:1887
bool bind(const nlohmann::json &target, const nlohmann::json &value)
target = <iterator>.
Definition numpy_nditer.cpp:1463
void create(const std::string &name, const nlohmann::json &call)
name = np.nditer(...): validates the call and creates the iterator.
Definition numpy_nditer.cpp:1184
static bool is_nditer_call(const nlohmann::json &node, const nlohmann::json &ast)
Definition numpy_nditer.cpp:279
numpy_nditer(python_converter &converter)
Definition numpy_nditer.cpp:275
Main converter for transforming Python AST into ESBMC's intermediate representation.
Definition python_converter.h:76
pthread_cond_t cond
Definition cuda.h:50
void * value
Definition solidity_mapping.c:2
uint256_t key
Definition solidity_mapping.c:1
A name bound to what an nditer yields: the element (or the external-loop chunk) of one operand at the...
Definition numpy_nditer.h:68
std::string position
Definition numpy_nditer.h:71
std::string iterator
Definition numpy_nditer.h:69
std::size_t operand
Definition numpy_nditer.h:70
One operand of an nditer: a named array or view and its layout in elements (a negative stride walks b...
Definition numpy_nditer.h:18
std::vector< long long > shape
Definition numpy_nditer.h:21
std::string buffer
A writable operand read through a cast is buffered: the hidden list its items live in,...
Definition numpy_nditer.h:33
nlohmann::json array
Definition numpy_nditer.h:19
nlohmann::json stride
Definition numpy_nditer.h:24
std::vector< long long > strides
Definition numpy_nditer.h:22
nlohmann::json extent
Definition numpy_nditer.h:23
typet dtype
The dtype reads are cast to (op_dtypes); empty for the operand's own.
Definition numpy_nditer.h:29
bool writable
Definition numpy_nditer.h:20
std::vector< long long > axes
The operand axis each iteration axis reads (op_axes), -1 for a new axis; empty for the default alignm...
Definition numpy_nditer.h:27
The static description of an np.nditer: its operands, the iteration shape, and the order the position...
Definition numpy_nditer.h:40
std::string state
Definition numpy_nditer.h:41
bool multi_index
Definition numpy_nditer.h:54
long long chunk
Elements per item: the chunk an external loop yields, 1 otherwise.
Definition numpy_nditer.h:60
std::vector< std::size_t > axes
Iteration axes, outermost first.
Definition numpy_nditer.h:48
std::string index
"C" or "F" for the index c_index or f_index tracks, empty for none.
Definition numpy_nditer.h:56
long long size
Definition numpy_nditer.h:61
std::vector< numpy_nditer_operand > operands
Definition numpy_nditer.h:45
bool flip_negative
Definition numpy_nditer.h:53
std::vector< bool > flipped
Axes visited from their last index down to 0.
Definition numpy_nditer.h:50
bool buffered
Definition numpy_nditer.h:58
bool external_loop
Definition numpy_nditer.h:57
std::vector< long long > shape
Definition numpy_nditer.h:46
bool runtime
A 1-D iteration whose extent and direction are run-time values.
Definition numpy_nditer.h:52
std::string alias
The name numpy is imported under, for the arrays an external loop yields.
Definition numpy_nditer.h:44