MCPcopy Create free account
hub / github.com/NVIDIA/DALI / Process

Method Process

dali/operators/util/axis_args.cc:101–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99}
100
101void AxisArgs::Process(int ndim, SmallVector<int, 6> &axes) {
102 if (axes.empty()) {
103 if (!(flags_ & AllowEmpty))
104 DALI_FAIL("Need to specify at least one axis");
105 if (flags_ & AllIfEmpty) {
106 axes.resize(ndim);
107 std::iota(axes.begin(), axes.end(), 0);
108 }
109 }
110
111 if (flags_ & AllowNegative) {
112 for (auto &axis : axes) {
113 DALI_ENFORCE(axis >= -ndim && axis < ndim,
114 make_string("Axis ", axis, " out of range. Expected range is [", -ndim, ", ",
115 ndim - 1, "] for a ", ndim, "D input"));
116 if (axis < 0)
117 axis += ndim;
118 }
119 } else {
120 for (auto &axis : axes) {
121 DALI_ENFORCE(axis >= 0 && axis < ndim,
122 make_string("Axis ", axis, " out of range. Expected range is [0, ", ndim - 1,
123 "] for a ", ndim, "D input"));
124 }
125 }
126
127 if (!(flags_ & AllowEmpty) && axes.empty())
128 DALI_FAIL("Need to specify at least one axis");
129
130
131 SmallVector<bool, 6> axes_check;
132 for (auto axis : axes) {
133 if (axes_check[axis])
134 DALI_FAIL(make_string("Axis index ", axis,
135 " occurs more than once in ``axes`` "
136 "(might include negative indices referring to the same axis"));
137 axes_check[axis] = true;
138 }
139}
140
141} // namespace dali

Callers 4

__init__Method · 0.80
teardown_functionFunction · 0.80
setup_queue_and_workerFunction · 0.80
test_no_segfaultFunction · 0.80

Calls 5

make_stringFunction · 0.50
emptyMethod · 0.45
resizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by 3

teardown_functionFunction · 0.64
setup_queue_and_workerFunction · 0.64
test_no_segfaultFunction · 0.64