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

Function replicate_pad1d

src/framework/audio/flashsr.cpp:209–234  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207}
208
209core::TensorValue replicate_pad1d(
210 core::ModuleBuildContext & ctx,
211 const core::TensorValue & input,
212 int64_t left,
213 int64_t right) {
214 if (left < 0 || right < 0) {
215 throw std::runtime_error("FlashSR replicate padding must be non-negative");
216 }
217 auto output = input;
218 constexpr int axis = 2;
219 if (left > 0) {
220 auto edge = modules::SliceModule({axis, 0, 1}).build(ctx, input);
221 auto pad_shape = edge.shape;
222 pad_shape.dims[axis] = left;
223 auto pad = modules::RepeatModule({pad_shape}).build(ctx, edge);
224 output = modules::ConcatModule({axis}).build(ctx, pad, output);
225 }
226 if (right > 0) {
227 auto edge = modules::SliceModule({axis, input.shape.dims[axis] - 1, 1}).build(ctx, input);
228 auto pad_shape = edge.shape;
229 pad_shape.dims[axis] = right;
230 auto pad = modules::RepeatModule({pad_shape}).build(ctx, edge);
231 output = modules::ConcatModule({axis}).build(ctx, output, pad);
232 }
233 return output;
234}
235
236core::TensorValue activation1d(
237 core::ModuleBuildContext & ctx,

Callers 1

activation1dFunction · 0.85

Calls 4

SliceModuleClass · 0.85
RepeatModuleClass · 0.85
ConcatModuleClass · 0.85
buildMethod · 0.45

Tested by

no test coverage detected