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

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