MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / build

Method build

src/framework/modules/primitive_modules.cpp:171–197  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

169 const int in_logical_axis = axes[out_logical_axis];
170 const int out_ggml_axis = static_cast<int>(value.shape.rank) - 1 - static_cast<int>(out_logical_axis);
171 ggml_axes[out_ggml_axis] = core::logical_axis_to_ggml_axis(value.shape.rank, in_logical_axis);
172 }
173
174 return core::wrap_tensor(
175 ggml_permute(ctx.ggml, value.tensor, ggml_axes[0], ggml_axes[1], ggml_axes[2], ggml_axes[3]),
176 transpose_last_two(value.shape),
177 value.type);
178}
179
180int normalize_reduce_axis(int axis, size_t rank) {
181 if (rank == 0) {
182 throw std::runtime_error("Reduce input rank must be positive");
183 }
184 const int normalized = axis < 0 ? static_cast<int>(rank) + axis : axis;
185 if (normalized < 0 || normalized >= static_cast<int>(rank)) {
186 throw std::runtime_error("Reduce axis out of range");
187 }
188 return normalized;
189}
190
191core::TensorShape reduced_shape(const core::TensorShape & shape, int axis) {
192 core::TensorShape out = shape;
193 out.dims[static_cast<size_t>(axis)] = 1;
194 return out;
195}
196
197template <typename Fn>
198core::TensorValue reduce_axis(
199 core::ModuleBuildContext & ctx,
200 const core::TensorValue & input,

Callers 1

reduce_axisFunction · 0.45

Calls 9

validate_rank_betweenFunction · 0.85
ggml_mul_matFunction · 0.85
wrap_tensorFunction · 0.85
validate_same_shapeFunction · 0.85
ggml_addFunction · 0.85
ggml_mulFunction · 0.85
reduce_axisFunction · 0.85
transpose_last_twoFunction · 0.70

Tested by

no test coverage detected