halide 19.0.0__cp313-cp313-macosx_11_0_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- halide/__init__.py +39 -0
- halide/_generator_helpers.py +835 -0
- halide/bin/adams2019_retrain_cost_model +0 -0
- halide/bin/adams2019_weightsdir_to_weightsfile +0 -0
- halide/bin/anderson2021_retrain_cost_model +0 -0
- halide/bin/anderson2021_weightsdir_to_weightsfile +0 -0
- halide/bin/featurization_to_sample +0 -0
- halide/bin/gengen +0 -0
- halide/bin/get_host_target +0 -0
- halide/halide_.cpython-313-darwin.so +0 -0
- halide/imageio.py +60 -0
- halide/include/Halide.h +35293 -0
- halide/include/HalideBuffer.h +2618 -0
- halide/include/HalidePyTorchCudaHelpers.h +64 -0
- halide/include/HalidePyTorchHelpers.h +120 -0
- halide/include/HalideRuntime.h +2221 -0
- halide/include/HalideRuntimeCuda.h +89 -0
- halide/include/HalideRuntimeD3D12Compute.h +91 -0
- halide/include/HalideRuntimeHexagonDma.h +104 -0
- halide/include/HalideRuntimeHexagonHost.h +157 -0
- halide/include/HalideRuntimeMetal.h +112 -0
- halide/include/HalideRuntimeOpenCL.h +119 -0
- halide/include/HalideRuntimeQurt.h +32 -0
- halide/include/HalideRuntimeVulkan.h +137 -0
- halide/include/HalideRuntimeWebGPU.h +44 -0
- halide/lib/cmake/Halide/FindHalide_LLVM.cmake +152 -0
- halide/lib/cmake/Halide/FindV8.cmake +33 -0
- halide/lib/cmake/Halide/Halide-shared-deps.cmake +0 -0
- halide/lib/cmake/Halide/Halide-shared-targets-release.cmake +29 -0
- halide/lib/cmake/Halide/Halide-shared-targets.cmake +154 -0
- halide/lib/cmake/Halide/HalideConfig.cmake +162 -0
- halide/lib/cmake/Halide/HalideConfigVersion.cmake +65 -0
- halide/lib/cmake/HalideHelpers/FindHalide_WebGPU.cmake +27 -0
- halide/lib/cmake/HalideHelpers/Halide-Interfaces-release.cmake +116 -0
- halide/lib/cmake/HalideHelpers/Halide-Interfaces.cmake +236 -0
- halide/lib/cmake/HalideHelpers/HalideGeneratorHelpers.cmake +1056 -0
- halide/lib/cmake/HalideHelpers/HalideHelpersConfig.cmake +28 -0
- halide/lib/cmake/HalideHelpers/HalideHelpersConfigVersion.cmake +54 -0
- halide/lib/cmake/HalideHelpers/HalideTargetHelpers.cmake +99 -0
- halide/lib/cmake/HalideHelpers/MutexCopy.ps1 +31 -0
- halide/lib/cmake/HalideHelpers/TargetExportScript.cmake +55 -0
- halide/lib/cmake/Halide_Python/Halide_Python-targets-release.cmake +30 -0
- halide/lib/cmake/Halide_Python/Halide_Python-targets.cmake +125 -0
- halide/lib/cmake/Halide_Python/Halide_PythonConfig.cmake +26 -0
- halide/lib/cmake/Halide_Python/Halide_PythonConfigVersion.cmake +65 -0
- halide/lib/libHalide.dylib +0 -0
- halide/lib/libHalidePyStubs.a +0 -0
- halide/lib/libHalide_GenGen.a +0 -0
- halide/lib/libautoschedule_adams2019.so +0 -0
- halide/lib/libautoschedule_anderson2021.so +0 -0
- halide/lib/libautoschedule_li2018.so +0 -0
- halide/lib/libautoschedule_mullapudi2016.so +0 -0
- halide/share/doc/Halide/LICENSE.txt +233 -0
- halide/share/doc/Halide/README.md +439 -0
- halide/share/doc/Halide/doc/BuildingHalideWithCMake.md +626 -0
- halide/share/doc/Halide/doc/CodeStyleCMake.md +393 -0
- halide/share/doc/Halide/doc/FuzzTesting.md +104 -0
- halide/share/doc/Halide/doc/HalideCMakePackage.md +812 -0
- halide/share/doc/Halide/doc/Hexagon.md +73 -0
- halide/share/doc/Halide/doc/Python.md +844 -0
- halide/share/doc/Halide/doc/RunGen.md +283 -0
- halide/share/doc/Halide/doc/Testing.md +125 -0
- halide/share/doc/Halide/doc/Vulkan.md +287 -0
- halide/share/doc/Halide/doc/WebAssembly.md +228 -0
- halide/share/doc/Halide/doc/WebGPU.md +128 -0
- halide/share/tools/RunGen.h +1470 -0
- halide/share/tools/RunGenMain.cpp +642 -0
- halide/share/tools/adams2019_autotune_loop.sh +227 -0
- halide/share/tools/anderson2021_autotune_loop.sh +591 -0
- halide/share/tools/halide_benchmark.h +240 -0
- halide/share/tools/halide_image.h +31 -0
- halide/share/tools/halide_image_info.h +318 -0
- halide/share/tools/halide_image_io.h +2794 -0
- halide/share/tools/halide_malloc_trace.h +102 -0
- halide/share/tools/halide_thread_pool.h +161 -0
- halide/share/tools/halide_trace_config.h +559 -0
- halide-19.0.0.data/data/share/cmake/Halide/HalideConfig.cmake +6 -0
- halide-19.0.0.data/data/share/cmake/Halide/HalideConfigVersion.cmake +65 -0
- halide-19.0.0.data/data/share/cmake/HalideHelpers/HalideHelpersConfig.cmake +6 -0
- halide-19.0.0.data/data/share/cmake/HalideHelpers/HalideHelpersConfigVersion.cmake +54 -0
- halide-19.0.0.dist-info/METADATA +301 -0
- halide-19.0.0.dist-info/RECORD +84 -0
- halide-19.0.0.dist-info/WHEEL +5 -0
- halide-19.0.0.dist-info/licenses/LICENSE.txt +233 -0
@@ -0,0 +1,559 @@
|
|
1
|
+
#ifndef HALIDE_TRACE_CONFIG_H
|
2
|
+
#define HALIDE_TRACE_CONFIG_H
|
3
|
+
|
4
|
+
#include <cmath>
|
5
|
+
#include <functional>
|
6
|
+
#include <iostream>
|
7
|
+
#include <limits>
|
8
|
+
#include <sstream>
|
9
|
+
#include <string>
|
10
|
+
#include <vector>
|
11
|
+
|
12
|
+
#include "HalideRuntime.h"
|
13
|
+
|
14
|
+
namespace Halide {
|
15
|
+
namespace Trace {
|
16
|
+
|
17
|
+
using ErrorFunc = std::function<void(const std::string &)>;
|
18
|
+
|
19
|
+
inline void default_error(const std::string &err) {
|
20
|
+
std::cerr << "Error: " << err << "\n";
|
21
|
+
exit(1);
|
22
|
+
}
|
23
|
+
|
24
|
+
inline std::string replace_all(const std::string &str, const std::string &find, const std::string &replace) {
|
25
|
+
size_t pos = 0;
|
26
|
+
std::string result = str;
|
27
|
+
while ((pos = result.find(find, pos)) != std::string::npos) {
|
28
|
+
result.replace(pos, find.length(), replace);
|
29
|
+
pos += replace.length();
|
30
|
+
}
|
31
|
+
return result;
|
32
|
+
}
|
33
|
+
|
34
|
+
inline std::string escape_spaces(const std::string &str) {
|
35
|
+
// Note: if the source string already contains '\x20', we'll
|
36
|
+
// end up unescaping that back into a space. That's acceptable.
|
37
|
+
return replace_all(str, " ", "\\x20");
|
38
|
+
}
|
39
|
+
|
40
|
+
inline std::string unescape_spaces(const std::string &str) {
|
41
|
+
// Note: if the source string already contains '\x20', we'll
|
42
|
+
// end up unescaping that back into a space. That's acceptable.
|
43
|
+
return replace_all(str, "\\x20", " ");
|
44
|
+
}
|
45
|
+
|
46
|
+
inline std::ostream &operator<<(std::ostream &os, const halide_type_t &t) {
|
47
|
+
os << (int)t.code << " " << (int)t.bits << " " << t.lanes;
|
48
|
+
return os;
|
49
|
+
}
|
50
|
+
|
51
|
+
inline std::istream &operator>>(std::istream &is, halide_type_t &t) {
|
52
|
+
// type.code is an enum; type.bits is a uint8 and might be read as char.
|
53
|
+
int type_code, type_bits;
|
54
|
+
is >> type_code >> type_bits >> t.lanes;
|
55
|
+
t.code = (halide_type_code_t)type_code;
|
56
|
+
t.bits = (uint8_t)type_bits;
|
57
|
+
return is;
|
58
|
+
}
|
59
|
+
|
60
|
+
template<typename T>
|
61
|
+
std::ostream &operator<<(std::ostream &os, const std::vector<T> &v) {
|
62
|
+
os << v.size() << " ";
|
63
|
+
for (const T &t : v) {
|
64
|
+
os << t << " ";
|
65
|
+
}
|
66
|
+
return os;
|
67
|
+
}
|
68
|
+
|
69
|
+
template<typename T>
|
70
|
+
std::istream &operator>>(std::istream &is, std::vector<T> &v) {
|
71
|
+
v.clear();
|
72
|
+
size_t size;
|
73
|
+
is >> size;
|
74
|
+
for (size_t i = 0; i < size; ++i) {
|
75
|
+
T tmp;
|
76
|
+
is >> tmp;
|
77
|
+
v.push_back(tmp);
|
78
|
+
}
|
79
|
+
return is;
|
80
|
+
}
|
81
|
+
|
82
|
+
struct Point {
|
83
|
+
int x = 0, y = 0;
|
84
|
+
|
85
|
+
Point() = default;
|
86
|
+
Point(int x, int y)
|
87
|
+
: x(x), y(y) {
|
88
|
+
}
|
89
|
+
|
90
|
+
friend std::ostream &operator<<(std::ostream &os, const Point &pt) {
|
91
|
+
os << pt.x << " " << pt.y;
|
92
|
+
return os;
|
93
|
+
}
|
94
|
+
|
95
|
+
friend std::istream &operator>>(std::istream &is, Point &pt) {
|
96
|
+
is >> pt.x >> pt.y;
|
97
|
+
return is;
|
98
|
+
}
|
99
|
+
};
|
100
|
+
|
101
|
+
// A struct specifying a text label that will appear on the screen at some point.
|
102
|
+
struct Label {
|
103
|
+
std::string text;
|
104
|
+
Point pos;
|
105
|
+
int fade_in_frames = 0;
|
106
|
+
float h_scale = 1.0f;
|
107
|
+
|
108
|
+
Label() = default;
|
109
|
+
Label(const std::string &text, const Point &pos = {0, 0}, int fade_in_frames = 0, float h_scale = 1.f)
|
110
|
+
: text(text), pos(pos), fade_in_frames(fade_in_frames), h_scale(h_scale) {
|
111
|
+
}
|
112
|
+
|
113
|
+
friend std::ostream &operator<<(std::ostream &os, const Label &label) {
|
114
|
+
os << escape_spaces(label.text) << " " << label.pos << " " << label.fade_in_frames << " " << label.h_scale;
|
115
|
+
return os;
|
116
|
+
}
|
117
|
+
|
118
|
+
friend std::istream &operator>>(std::istream &is, Label &label) {
|
119
|
+
is >> label.text >> label.pos >> label.fade_in_frames >> label.h_scale;
|
120
|
+
label.text = unescape_spaces(label.text);
|
121
|
+
return is;
|
122
|
+
}
|
123
|
+
};
|
124
|
+
|
125
|
+
// Configuration for how a func should be rendered in HalideTraceViz.
|
126
|
+
struct FuncConfig {
|
127
|
+
// Note that every field in this struct is initialized to a value which
|
128
|
+
// means "no value specified"; this is allows us to merge configs
|
129
|
+
// from several sources (auto-layout, embedded trace-tags, and command-line)
|
130
|
+
// in a way that we can selectively add or override some-but-not-all configuration
|
131
|
+
// values (e.g., use auto-layout's positioning, but customizing labels
|
132
|
+
// and changing rgb vs gray rendering). In all cases, if a field is
|
133
|
+
// the initial "no value specified" value at rendering time, HalideTraceViz
|
134
|
+
// will choose a reasonable value for that field.
|
135
|
+
|
136
|
+
// Each value of a Func will draw as a zoom x zoom
|
137
|
+
// box in the output. Fractional values are allowed.
|
138
|
+
//
|
139
|
+
// Valid values: 0.0 < zoom <= HUGEVAL or so
|
140
|
+
float zoom = -1.f;
|
141
|
+
|
142
|
+
// Each load from a Func costs the given number of ticks.
|
143
|
+
// Legal values are 0.0 < zoom <= 1000 or so
|
144
|
+
//
|
145
|
+
// Valid values: load_cost >= 0
|
146
|
+
int load_cost = -1;
|
147
|
+
|
148
|
+
// Each store to a Func costs the given number of ticks.
|
149
|
+
//
|
150
|
+
// Valid values: store_cost >= 0
|
151
|
+
int store_cost = -1;
|
152
|
+
|
153
|
+
// The position on the screen corresponding to the Func's 0, 0 coordinate.
|
154
|
+
//
|
155
|
+
// Valid values: pos.x and pos.y > std::numeric_limits<int>::lowest()
|
156
|
+
Point pos = {std::numeric_limits<int>::lowest(), std::numeric_limits<int>::lowest()};
|
157
|
+
|
158
|
+
// Specifies the matrix that maps the coordinates of the
|
159
|
+
// Func to screen pixels. Specified column major. For example,
|
160
|
+
// { {1, 0}, {0, 1}, {0, 0} } specifies that the Func has three
|
161
|
+
// dimensions where the first one maps to screen-space x
|
162
|
+
// coordinates, the second one maps to screen-space y coordinates,
|
163
|
+
// and the third one does not affect screen-space coordinates.
|
164
|
+
//
|
165
|
+
// Valid values: strize.size() > 0
|
166
|
+
std::vector<Point> strides;
|
167
|
+
|
168
|
+
// Specify the dimension to use for rendering the color channels of the Func.
|
169
|
+
//
|
170
|
+
// Valid values: color_dim == -1 -> render as grayscale
|
171
|
+
// color_dim >= 0 -> render as RGB using that dimension as color channel
|
172
|
+
int color_dim = -2;
|
173
|
+
|
174
|
+
// The minimum value taken on by a Func; maps to black.
|
175
|
+
// TODO: this doesn't give enough range to allow for the full range of int64 or uint64. Do we care?
|
176
|
+
//
|
177
|
+
// Valid values: min-of-type <= min <= max-of-type
|
178
|
+
double min = std::numeric_limits<double>::quiet_NaN();
|
179
|
+
|
180
|
+
// The maximum value taken on by a Func; maps to white.
|
181
|
+
// TODO: this doesn't give enough range to allow for the full range of int64 or uint64. Do we care?
|
182
|
+
//
|
183
|
+
// Valid values: min-of-type <= min <= max-of-type
|
184
|
+
double max = std::numeric_limits<double>::quiet_NaN();
|
185
|
+
|
186
|
+
// Label(s) to be rendered with the Func. The Label's position
|
187
|
+
// is an offset from the Func's position, so (0, 0) means render
|
188
|
+
// at the top-left of the Func itself.
|
189
|
+
//
|
190
|
+
// Valid values: Any
|
191
|
+
std::vector<Label> labels;
|
192
|
+
|
193
|
+
// If blank_on_end_realization > 0, the output occupied by a Func will be set to
|
194
|
+
// black on its end-realization event; if blank_on_end_realization == 0, the
|
195
|
+
// Func's values will be left on the screen.
|
196
|
+
//
|
197
|
+
// Valid values: 0 or 1.
|
198
|
+
int blank_on_end_realization = -1;
|
199
|
+
|
200
|
+
// Specifies the on-screen color corresponding to uninitialized memory,
|
201
|
+
// in 0x00BBGGRR format. 0x00010101 is a "magic" value that will actually
|
202
|
+
// fill with a checkerboard pattern.
|
203
|
+
//
|
204
|
+
// Valid values: Any uint32 with 0x00 in the upper 8 bits.
|
205
|
+
uint32_t uninitialized_memory_color = 0xFFFFFFFF;
|
206
|
+
|
207
|
+
// For each field in 'from':
|
208
|
+
// -- if it has a well-defined value, replace the corresponding field in 'this'
|
209
|
+
// -- if it does not have a well-defined value, leave untouched the corresponding field in 'this'
|
210
|
+
void merge_from(const FuncConfig &from) {
|
211
|
+
if (from.zoom >= 0.f) {
|
212
|
+
this->zoom = from.zoom;
|
213
|
+
}
|
214
|
+
if (from.load_cost >= 0) {
|
215
|
+
this->load_cost = from.load_cost;
|
216
|
+
}
|
217
|
+
if (from.store_cost > 0) {
|
218
|
+
this->store_cost = from.store_cost;
|
219
|
+
}
|
220
|
+
if (from.pos.x > std::numeric_limits<int>::lowest()) {
|
221
|
+
this->pos.x = from.pos.x;
|
222
|
+
}
|
223
|
+
if (from.pos.y > std::numeric_limits<int>::lowest()) {
|
224
|
+
this->pos.y = from.pos.y;
|
225
|
+
}
|
226
|
+
if (!from.strides.empty()) {
|
227
|
+
this->strides = from.strides;
|
228
|
+
}
|
229
|
+
if (from.color_dim >= -1) {
|
230
|
+
this->color_dim = from.color_dim;
|
231
|
+
}
|
232
|
+
if (!std::isnan(from.min)) {
|
233
|
+
this->min = from.min;
|
234
|
+
}
|
235
|
+
if (!std::isnan(from.max)) {
|
236
|
+
this->max = from.max;
|
237
|
+
}
|
238
|
+
if (!from.labels.empty()) {
|
239
|
+
this->labels = from.labels;
|
240
|
+
}
|
241
|
+
if (from.blank_on_end_realization >= 0) {
|
242
|
+
this->blank_on_end_realization = from.blank_on_end_realization;
|
243
|
+
}
|
244
|
+
if (!(from.uninitialized_memory_color & 0xff000000)) {
|
245
|
+
this->uninitialized_memory_color = from.uninitialized_memory_color;
|
246
|
+
}
|
247
|
+
}
|
248
|
+
|
249
|
+
static std::string tag_start_text() {
|
250
|
+
return std::string("htv_func_config:");
|
251
|
+
}
|
252
|
+
|
253
|
+
static bool match(const std::string &trace_tag) {
|
254
|
+
return trace_tag.find(tag_start_text()) == 0;
|
255
|
+
}
|
256
|
+
|
257
|
+
void dump(std::ostream &os, const std::string &name) const {
|
258
|
+
os << std::boolalpha
|
259
|
+
<< "Func: " << name << "\n"
|
260
|
+
<< " zoom: " << zoom << "\n"
|
261
|
+
<< " load cost: " << load_cost << "\n"
|
262
|
+
<< " store cost: " << store_cost << "\n"
|
263
|
+
<< " pos: " << pos << "\n"
|
264
|
+
<< " strides: " << strides << "\n"
|
265
|
+
<< " color_dim: " << color_dim << "\n"
|
266
|
+
<< " min: " << min << " max: " << max << "\n"
|
267
|
+
<< " labels: " << labels << "\n"
|
268
|
+
<< " blank: " << blank_on_end_realization << "\n"
|
269
|
+
<< " uninit: " << uninitialized_memory_color << "\n";
|
270
|
+
}
|
271
|
+
|
272
|
+
friend std::ostream &operator<<(std::ostream &os, const FuncConfig &config) {
|
273
|
+
// The 'format' here is intentionally simple:
|
274
|
+
// a space-separated iostream text string,
|
275
|
+
// in an assumed order rather than freeform.
|
276
|
+
os
|
277
|
+
<< tag_start_text() << " "
|
278
|
+
<< config.zoom << " "
|
279
|
+
<< config.load_cost << " "
|
280
|
+
<< config.store_cost << " "
|
281
|
+
<< config.pos << " "
|
282
|
+
<< config.strides << " "
|
283
|
+
<< config.color_dim << " "
|
284
|
+
<< config.min << " "
|
285
|
+
<< config.max << " "
|
286
|
+
<< config.labels << " "
|
287
|
+
<< config.blank_on_end_realization << " "
|
288
|
+
<< config.uninitialized_memory_color;
|
289
|
+
return os;
|
290
|
+
}
|
291
|
+
|
292
|
+
friend std::istream &operator>>(std::istream &is, FuncConfig &config) {
|
293
|
+
std::string start_text;
|
294
|
+
// Conforming C++ implementations are allowed to fail when reading
|
295
|
+
// 'nan', 'inf', etc for floating-point values, so read these as
|
296
|
+
// text and reality-check them ourselves.
|
297
|
+
std::string min_text, max_text;
|
298
|
+
is >>
|
299
|
+
start_text >>
|
300
|
+
config.zoom >>
|
301
|
+
config.load_cost >>
|
302
|
+
config.store_cost >>
|
303
|
+
config.pos >>
|
304
|
+
config.strides >>
|
305
|
+
config.color_dim >>
|
306
|
+
min_text >>
|
307
|
+
max_text >>
|
308
|
+
config.labels >>
|
309
|
+
config.blank_on_end_realization >>
|
310
|
+
config.uninitialized_memory_color;
|
311
|
+
|
312
|
+
const auto parse_double = [](const std::string &s) -> double {
|
313
|
+
double d;
|
314
|
+
std::istringstream iss(s);
|
315
|
+
iss >> d;
|
316
|
+
if (iss.fail() || iss.get() != EOF) {
|
317
|
+
// If it fails, just use nan for the value.
|
318
|
+
// (Could upgrade to guess at +-Inf if we ever care.)
|
319
|
+
d = std::numeric_limits<double>::quiet_NaN();
|
320
|
+
}
|
321
|
+
return d;
|
322
|
+
};
|
323
|
+
config.min = parse_double(min_text);
|
324
|
+
config.max = parse_double(max_text);
|
325
|
+
|
326
|
+
if (start_text != tag_start_text()) {
|
327
|
+
is.setstate(std::ios::failbit);
|
328
|
+
}
|
329
|
+
return is;
|
330
|
+
}
|
331
|
+
|
332
|
+
std::string to_trace_tag() const {
|
333
|
+
// The 'format' here is intentionally simple:
|
334
|
+
// a space-separated iostream text string,
|
335
|
+
// in an assumed order rather than freeform.
|
336
|
+
std::ostringstream os;
|
337
|
+
os << *this;
|
338
|
+
return os.str();
|
339
|
+
}
|
340
|
+
|
341
|
+
FuncConfig() = default;
|
342
|
+
|
343
|
+
explicit FuncConfig(const std::string &trace_tag, const ErrorFunc &error = default_error) {
|
344
|
+
std::istringstream is(trace_tag);
|
345
|
+
is >> *this;
|
346
|
+
if (is.fail() || is.get() != EOF) {
|
347
|
+
error("FuncConfig trace_tag parsing error");
|
348
|
+
}
|
349
|
+
}
|
350
|
+
};
|
351
|
+
|
352
|
+
// Configuration for top-level visualization config settings.
|
353
|
+
// If more than one of these is encountered, the last one wins.
|
354
|
+
struct GlobalConfig {
|
355
|
+
// The size of the output frames.
|
356
|
+
Point frame_size = {1920, 1080};
|
357
|
+
|
358
|
+
// How quickly should the yellow and blue highlights decay
|
359
|
+
// over time. This is a two-stage exponential decay with a knee in
|
360
|
+
// it. decay_factor_during_compute controls the rate at which they
|
361
|
+
// decay while a value is in the process of being computed,
|
362
|
+
// and decay_factor_after_compute controls the rate at which
|
363
|
+
// they decay over time after the corresponding value has finished
|
364
|
+
// being computed. 1 means never decay, 2 means halve in opacity
|
365
|
+
// every frame, and 256 or larger means instant decay. The default
|
366
|
+
// values produce a highlight that holds while the value is being computed,
|
367
|
+
// and then decays slowly.
|
368
|
+
int decay_factor_during_compute = 1;
|
369
|
+
int decay_factor_after_compute = 2;
|
370
|
+
|
371
|
+
// How many frames to output after the end of the trace.
|
372
|
+
int hold_frames = 250;
|
373
|
+
|
374
|
+
// How many Halide computations should be covered by each frame.
|
375
|
+
int timestep = 10000;
|
376
|
+
|
377
|
+
// If true, automatically layout every realized func we see, in left-to-right,
|
378
|
+
// top-to-bottom order as they are first touched.
|
379
|
+
bool auto_layout = false;
|
380
|
+
|
381
|
+
// If doing auto-layout, divide the frame into this many rows and columns,
|
382
|
+
// filling in each cell in left-to-right, top-to-bottom order. If either
|
383
|
+
// value is -1, calculate a cell size based on the number of boxes touched.
|
384
|
+
Point auto_layout_grid = {-1, -1};
|
385
|
+
|
386
|
+
// If doing auto-layout, the padding to use between each cell.
|
387
|
+
Point auto_layout_pad = {32, 32};
|
388
|
+
|
389
|
+
// Specifies the default on-screen color corresponding to uninitialized memory,
|
390
|
+
// in 0x00BBGGRR format. 0x00010101 is a "magic" value that will actually
|
391
|
+
// fill with a checkerboard pattern. This will be used for any Func that doesn't
|
392
|
+
// override it in its FuncConfig.
|
393
|
+
//
|
394
|
+
// Valid values: Any uint32 with 0x00 in the upper 8 bits.
|
395
|
+
uint32_t default_uninitialized_memory_color = 0xFFFFFFFF;
|
396
|
+
|
397
|
+
static std::string tag_start_text() {
|
398
|
+
return std::string("htv_global_config:");
|
399
|
+
}
|
400
|
+
|
401
|
+
static bool match(const std::string &trace_tag) {
|
402
|
+
return trace_tag.find(tag_start_text()) == 0;
|
403
|
+
}
|
404
|
+
|
405
|
+
void dump(std::ostream &os) const {
|
406
|
+
os << std::boolalpha
|
407
|
+
<< "Global:\n"
|
408
|
+
<< " frame_size: " << frame_size << "\n"
|
409
|
+
<< " decay_factor_during_compute: " << decay_factor_during_compute << "\n"
|
410
|
+
<< " decay_factor_after_compute: " << decay_factor_after_compute << "\n"
|
411
|
+
<< " hold_frames: " << hold_frames << "\n"
|
412
|
+
<< " timestep: " << timestep << "\n"
|
413
|
+
<< " auto_layout: " << auto_layout << "\n"
|
414
|
+
<< " auto_layout_grid: " << auto_layout_grid << "\n"
|
415
|
+
<< " auto_layout_pad: " << auto_layout_grid << "\n"
|
416
|
+
<< " default_uninitialized_memory_color: " << default_uninitialized_memory_color << "\n";
|
417
|
+
}
|
418
|
+
|
419
|
+
friend std::ostream &operator<<(std::ostream &os, const GlobalConfig &config) {
|
420
|
+
// The 'format' here is intentionally simple:
|
421
|
+
// a space-separated iostream text string,
|
422
|
+
// in an assumed order rather than freeform.
|
423
|
+
os
|
424
|
+
<< tag_start_text() << " "
|
425
|
+
<< config.frame_size << " "
|
426
|
+
<< config.decay_factor_during_compute << " "
|
427
|
+
<< config.decay_factor_after_compute << " "
|
428
|
+
<< config.hold_frames << " "
|
429
|
+
<< config.timestep << " "
|
430
|
+
<< config.auto_layout << " "
|
431
|
+
<< config.auto_layout_grid << " "
|
432
|
+
<< config.auto_layout_pad << " "
|
433
|
+
<< config.default_uninitialized_memory_color;
|
434
|
+
return os;
|
435
|
+
}
|
436
|
+
|
437
|
+
friend std::istream &operator>>(std::istream &is, GlobalConfig &config) {
|
438
|
+
std::string start_text;
|
439
|
+
is >>
|
440
|
+
start_text >>
|
441
|
+
config.frame_size >>
|
442
|
+
config.decay_factor_during_compute >>
|
443
|
+
config.decay_factor_after_compute >>
|
444
|
+
config.hold_frames >>
|
445
|
+
config.timestep >>
|
446
|
+
config.auto_layout >>
|
447
|
+
config.auto_layout_grid >>
|
448
|
+
config.auto_layout_pad >>
|
449
|
+
config.default_uninitialized_memory_color;
|
450
|
+
if (start_text != tag_start_text()) {
|
451
|
+
is.setstate(std::ios::failbit);
|
452
|
+
}
|
453
|
+
return is;
|
454
|
+
}
|
455
|
+
|
456
|
+
std::string to_trace_tag() const {
|
457
|
+
// The 'format' here is intentionally simple:
|
458
|
+
// a space-separated iostream text string,
|
459
|
+
// in an assumed order rather than freeform.
|
460
|
+
std::ostringstream os;
|
461
|
+
os << *this;
|
462
|
+
return os.str();
|
463
|
+
}
|
464
|
+
|
465
|
+
GlobalConfig() = default;
|
466
|
+
|
467
|
+
explicit GlobalConfig(const std::string &trace_tag, const ErrorFunc &error = default_error) {
|
468
|
+
std::istringstream is(trace_tag);
|
469
|
+
is >> *this;
|
470
|
+
if (is.fail() || is.get() != EOF) {
|
471
|
+
error("GlobalConfig trace_tag parsing error");
|
472
|
+
}
|
473
|
+
}
|
474
|
+
};
|
475
|
+
|
476
|
+
// We don't use halide_dimension_t here because we don't want stride.
|
477
|
+
struct Range {
|
478
|
+
int min = 0, extent = 0;
|
479
|
+
|
480
|
+
Range() = default;
|
481
|
+
Range(int min, int extent)
|
482
|
+
: min(min), extent(extent) {
|
483
|
+
}
|
484
|
+
|
485
|
+
friend std::ostream &operator<<(std::ostream &os, const Range &dim) {
|
486
|
+
os << dim.min << " " << dim.extent;
|
487
|
+
return os;
|
488
|
+
}
|
489
|
+
|
490
|
+
friend std::istream &operator>>(std::istream &is, Range &dim) {
|
491
|
+
is >> dim.min >> dim.extent;
|
492
|
+
return is;
|
493
|
+
}
|
494
|
+
};
|
495
|
+
|
496
|
+
// TODO name is terrible
|
497
|
+
struct FuncTypeAndDim {
|
498
|
+
std::vector<halide_type_t> types;
|
499
|
+
std::vector<Range> dims;
|
500
|
+
|
501
|
+
static std::string tag_start_text() {
|
502
|
+
return std::string("func_type_and_dim:");
|
503
|
+
}
|
504
|
+
|
505
|
+
static bool match(const std::string &trace_tag) {
|
506
|
+
return trace_tag.find(tag_start_text()) == 0;
|
507
|
+
}
|
508
|
+
|
509
|
+
void dump(std::ostream &os, const std::string &name) const {
|
510
|
+
static const char *const type_name[4] = {"int", "uint", "float", "handle"};
|
511
|
+
os << "FuncTypeAndDim: " << name << "\n";
|
512
|
+
os << " types:";
|
513
|
+
for (const auto &type : types) {
|
514
|
+
os << " " << type_name[type.code & 3] << (int)type.bits;
|
515
|
+
if (type.lanes > 1) {
|
516
|
+
os << "x" << type.lanes;
|
517
|
+
}
|
518
|
+
}
|
519
|
+
os << "\n";
|
520
|
+
os << " dims: " << dims << "\n";
|
521
|
+
}
|
522
|
+
|
523
|
+
friend std::ostream &operator<<(std::ostream &os, const FuncTypeAndDim &types_and_ranges) {
|
524
|
+
os << tag_start_text()
|
525
|
+
<< " " << types_and_ranges.types
|
526
|
+
<< " " << types_and_ranges.dims;
|
527
|
+
return os;
|
528
|
+
}
|
529
|
+
|
530
|
+
friend std::istream &operator>>(std::istream &is, FuncTypeAndDim &types_and_ranges) {
|
531
|
+
std::string start_text;
|
532
|
+
is >> start_text >> types_and_ranges.types >> types_and_ranges.dims;
|
533
|
+
if (start_text != tag_start_text()) {
|
534
|
+
is.setstate(std::ios::failbit);
|
535
|
+
}
|
536
|
+
return is;
|
537
|
+
}
|
538
|
+
|
539
|
+
std::string to_trace_tag() const {
|
540
|
+
std::ostringstream os;
|
541
|
+
os << *this;
|
542
|
+
return os.str();
|
543
|
+
}
|
544
|
+
|
545
|
+
FuncTypeAndDim() = default;
|
546
|
+
|
547
|
+
explicit FuncTypeAndDim(const std::string &trace_tag, const ErrorFunc &error = default_error) {
|
548
|
+
std::istringstream is(trace_tag);
|
549
|
+
is >> *this;
|
550
|
+
if (is.fail() || is.get() != EOF) {
|
551
|
+
error("FuncTypeAndDim trace_tag parsing error");
|
552
|
+
}
|
553
|
+
}
|
554
|
+
};
|
555
|
+
|
556
|
+
} // namespace Trace
|
557
|
+
} // namespace Halide
|
558
|
+
|
559
|
+
#endif // HALIDE_TRACE_CONFIG_H
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# This is a basic version file for the Config-mode of find_package().
|
2
|
+
# It is used by write_basic_package_version_file() as input file for configure_file()
|
3
|
+
# to create a version-file which can be installed along a config.cmake file.
|
4
|
+
#
|
5
|
+
# The created file sets PACKAGE_VERSION_EXACT if the current version string and
|
6
|
+
# the requested version string are exactly the same and it sets
|
7
|
+
# PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version,
|
8
|
+
# but only if the requested major version is the same as the current one.
|
9
|
+
# The variable CVF_VERSION must be set before calling configure_file().
|
10
|
+
|
11
|
+
|
12
|
+
set(PACKAGE_VERSION "19.0.0")
|
13
|
+
|
14
|
+
if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
|
15
|
+
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
16
|
+
else()
|
17
|
+
|
18
|
+
if("19.0.0" MATCHES "^([0-9]+)\\.")
|
19
|
+
set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}")
|
20
|
+
if(NOT CVF_VERSION_MAJOR VERSION_EQUAL 0)
|
21
|
+
string(REGEX REPLACE "^0+" "" CVF_VERSION_MAJOR "${CVF_VERSION_MAJOR}")
|
22
|
+
endif()
|
23
|
+
else()
|
24
|
+
set(CVF_VERSION_MAJOR "19.0.0")
|
25
|
+
endif()
|
26
|
+
|
27
|
+
if(PACKAGE_FIND_VERSION_RANGE)
|
28
|
+
# both endpoints of the range must have the expected major version
|
29
|
+
math (EXPR CVF_VERSION_MAJOR_NEXT "${CVF_VERSION_MAJOR} + 1")
|
30
|
+
if (NOT PACKAGE_FIND_VERSION_MIN_MAJOR STREQUAL CVF_VERSION_MAJOR
|
31
|
+
OR ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND NOT PACKAGE_FIND_VERSION_MAX_MAJOR STREQUAL CVF_VERSION_MAJOR)
|
32
|
+
OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND NOT PACKAGE_FIND_VERSION_MAX VERSION_LESS_EQUAL CVF_VERSION_MAJOR_NEXT)))
|
33
|
+
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
34
|
+
elseif(PACKAGE_FIND_VERSION_MIN_MAJOR STREQUAL CVF_VERSION_MAJOR
|
35
|
+
AND ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_LESS_EQUAL PACKAGE_FIND_VERSION_MAX)
|
36
|
+
OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION_MAX)))
|
37
|
+
set(PACKAGE_VERSION_COMPATIBLE TRUE)
|
38
|
+
else()
|
39
|
+
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
40
|
+
endif()
|
41
|
+
else()
|
42
|
+
if(PACKAGE_FIND_VERSION_MAJOR STREQUAL CVF_VERSION_MAJOR)
|
43
|
+
set(PACKAGE_VERSION_COMPATIBLE TRUE)
|
44
|
+
else()
|
45
|
+
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
46
|
+
endif()
|
47
|
+
|
48
|
+
if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
|
49
|
+
set(PACKAGE_VERSION_EXACT TRUE)
|
50
|
+
endif()
|
51
|
+
endif()
|
52
|
+
endif()
|
53
|
+
|
54
|
+
|
55
|
+
# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
|
56
|
+
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "8" STREQUAL "")
|
57
|
+
return()
|
58
|
+
endif()
|
59
|
+
|
60
|
+
# check that the installed version has the same 32/64bit-ness as the one which is currently searching:
|
61
|
+
if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "8")
|
62
|
+
math(EXPR installedBits "8 * 8")
|
63
|
+
set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
|
64
|
+
set(PACKAGE_VERSION_UNSUITABLE TRUE)
|
65
|
+
endif()
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# This is a basic version file for the Config-mode of find_package().
|
2
|
+
# It is used by write_basic_package_version_file() as input file for configure_file()
|
3
|
+
# to create a version-file which can be installed along a config.cmake file.
|
4
|
+
#
|
5
|
+
# The created file sets PACKAGE_VERSION_EXACT if the current version string and
|
6
|
+
# the requested version string are exactly the same and it sets
|
7
|
+
# PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version,
|
8
|
+
# but only if the requested major version is the same as the current one.
|
9
|
+
# The variable CVF_VERSION must be set before calling configure_file().
|
10
|
+
|
11
|
+
|
12
|
+
set(PACKAGE_VERSION "19.0.0")
|
13
|
+
|
14
|
+
if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
|
15
|
+
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
16
|
+
else()
|
17
|
+
|
18
|
+
if("19.0.0" MATCHES "^([0-9]+)\\.")
|
19
|
+
set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}")
|
20
|
+
if(NOT CVF_VERSION_MAJOR VERSION_EQUAL 0)
|
21
|
+
string(REGEX REPLACE "^0+" "" CVF_VERSION_MAJOR "${CVF_VERSION_MAJOR}")
|
22
|
+
endif()
|
23
|
+
else()
|
24
|
+
set(CVF_VERSION_MAJOR "19.0.0")
|
25
|
+
endif()
|
26
|
+
|
27
|
+
if(PACKAGE_FIND_VERSION_RANGE)
|
28
|
+
# both endpoints of the range must have the expected major version
|
29
|
+
math (EXPR CVF_VERSION_MAJOR_NEXT "${CVF_VERSION_MAJOR} + 1")
|
30
|
+
if (NOT PACKAGE_FIND_VERSION_MIN_MAJOR STREQUAL CVF_VERSION_MAJOR
|
31
|
+
OR ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND NOT PACKAGE_FIND_VERSION_MAX_MAJOR STREQUAL CVF_VERSION_MAJOR)
|
32
|
+
OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND NOT PACKAGE_FIND_VERSION_MAX VERSION_LESS_EQUAL CVF_VERSION_MAJOR_NEXT)))
|
33
|
+
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
34
|
+
elseif(PACKAGE_FIND_VERSION_MIN_MAJOR STREQUAL CVF_VERSION_MAJOR
|
35
|
+
AND ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_LESS_EQUAL PACKAGE_FIND_VERSION_MAX)
|
36
|
+
OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION_MAX)))
|
37
|
+
set(PACKAGE_VERSION_COMPATIBLE TRUE)
|
38
|
+
else()
|
39
|
+
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
40
|
+
endif()
|
41
|
+
else()
|
42
|
+
if(PACKAGE_FIND_VERSION_MAJOR STREQUAL CVF_VERSION_MAJOR)
|
43
|
+
set(PACKAGE_VERSION_COMPATIBLE TRUE)
|
44
|
+
else()
|
45
|
+
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
46
|
+
endif()
|
47
|
+
|
48
|
+
if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
|
49
|
+
set(PACKAGE_VERSION_EXACT TRUE)
|
50
|
+
endif()
|
51
|
+
endif()
|
52
|
+
endif()
|
53
|
+
|
54
|
+
|