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

Function validate_shape

src/framework/core/module.cpp:212–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

210 }
211 if (has_backend_addressable_layout(value.tensor)) {
212 return value;
213 }
214 return wrap_tensor(ggml_cont(ctx.ggml, value.tensor), value.shape, value.type);
215}
216
217void validate_shape(const TensorValue & value, const TensorShape & expected, const char * name) {
218 if (!value.valid()) {
219 throw std::runtime_error(name_or_default(name) + " is invalid");
220 }
221 if (value.shape.rank != expected.rank) {
222 throw std::runtime_error(name_or_default(name) + " rank mismatch: expected " + expected.to_string() +
223 ", got " + value.shape.to_string());
224 }
225 for (size_t i = 0; i < expected.rank; ++i) {
226 if (value.shape.dims[i] != expected.dims[i]) {
227 throw std::runtime_error(name_or_default(name) + " shape mismatch: expected " + expected.to_string() +
228 ", got " + value.shape.to_string());
229 }

Callers 15

buildMethod · 0.85
build_time_mask_4dFunction · 0.85
variance_rms_normFunction · 0.85
buildMethod · 0.85
buildMethod · 0.85
validate_weight_shapesFunction · 0.85
build_lstm_sequenceFunction · 0.85
buildMethod · 0.85
apply_affineFunction · 0.85
repeat_channelsFunction · 0.85
buildMethod · 0.85

Calls 3

name_or_defaultFunction · 0.85
validMethod · 0.80
to_stringMethod · 0.80

Tested by

no test coverage detected