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

Function wrap_tensor

src/framework/core/module.cpp:144–158  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

142}
143
144TensorValue wrap_tensor(ggml_tensor * tensor, const TensorShape & shape, ggml_type type) {
145 if (tensor == nullptr) {
146 throw std::runtime_error("Cannot wrap null ggml tensor");
147 }
148
149 ensure_positive_dims(shape);
150 const auto ggml_dims = to_ggml_dims(shape);
151 for (size_t i = 0; i < shape.rank; ++i) {
152 if (tensor->ne[i] != ggml_dims[i]) {
153 throw std::runtime_error("Wrapped ggml tensor shape does not match logical shape " + shape.to_string());
154 }
155 }
156
157 return TensorValue{tensor, shape, type};
158}
159
160TensorValue reshape_tensor(ModuleBuildContext & ctx, const TensorValue & value, const TensorShape & new_shape) {
161 if (!value.valid()) {

Callers 15

buildMethod · 0.85
whisper_attentionFunction · 0.85
calc_subsampled_lengthsFunction · 0.85
build_time_mask_4dFunction · 0.85
apply_channel_affine_btcFunction · 0.85
buildMethod · 0.85
repeat_likeFunction · 0.85
add_tensorsFunction · 0.85
mulFunction · 0.85
scale_tensorFunction · 0.85
apply_adalnFunction · 0.85

Calls 3

ensure_positive_dimsFunction · 0.85
to_ggml_dimsFunction · 0.85
to_stringMethod · 0.80