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

Function make_tensor

src/framework/core/module.cpp:108–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106}
107
108TensorValue make_tensor(ModuleBuildContext & ctx, ggml_type type, const TensorShape & shape) {
109 if (ctx.ggml == nullptr) {
110 throw std::runtime_error("ModuleBuildContext.ggml is null");
111 }
112
113 ensure_positive_dims(shape);
114 const auto ggml_dims = to_ggml_dims(shape);
115
116 ggml_tensor * tensor = nullptr;
117 switch (shape.rank) {
118 case 1:
119 tensor = ggml_new_tensor_1d(ctx.ggml, type, ggml_dims[0]);
120 break;
121 case 2:
122 tensor = ggml_new_tensor_2d(ctx.ggml, type, ggml_dims[0], ggml_dims[1]);
123 break;
124 case 3:
125 tensor = ggml_new_tensor_3d(ctx.ggml, type, ggml_dims[0], ggml_dims[1], ggml_dims[2]);
126 break;
127 case 4:
128 tensor = ggml_new_tensor_4d(ctx.ggml, type, ggml_dims[0], ggml_dims[1], ggml_dims[2], ggml_dims[3]);
129 break;
130 default:
131 throw std::runtime_error("Unsupported tensor rank");
132 }
133
134 return wrap_tensor(tensor, shape, type);
135}
136
137int logical_axis_to_ggml_axis(size_t rank, int logical_axis) {
138 if (logical_axis < 0 || logical_axis >= static_cast<int>(rank)) {

Callers 15

ensure_graphMethod · 0.85
ensure_graphMethod · 0.85
CampplusBackendRunnerMethod · 0.85
GraphMethod · 0.85
GraphMethod · 0.85
make_f32_tensorMethod · 0.85
make_i32_tensorMethod · 0.85
FlashSrGraphMethod · 0.85
RnnoiseFrameGraphMethod · 0.85
RnnoiseSequenceGraphMethod · 0.85

Calls 7

ensure_positive_dimsFunction · 0.85
to_ggml_dimsFunction · 0.85
ggml_new_tensor_1dFunction · 0.85
ggml_new_tensor_2dFunction · 0.85
ggml_new_tensor_3dFunction · 0.85
ggml_new_tensor_4dFunction · 0.85
wrap_tensorFunction · 0.85

Tested by 3

make_f32Method · 0.68
make_f32Method · 0.68
make_i32Method · 0.68