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

Function graph_run_downsampled_encoder

src/framework/audio/zipenhancer.cpp:795–825  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

793}
794
795core::TensorValue graph_run_downsampled_encoder(
796 core::ModuleBuildContext & ctx,
797 std::vector<GraphConstant> & constants,
798 const core::TensorValue & input,
799 const std::unordered_map<std::string, Param> & params,
800 const std::string & root,
801 int64_t ds) {
802 const int64_t frames = input.shape.dims[2];
803 const int64_t freq = input.shape.dims[3];
804 auto t_seq = graph_transpose(ctx, input, {{2, 3, 0, 1}}, 4);
805 t_seq = graph_reshape(ctx, t_seq, core::TensorShape::from_dims({frames, freq, kDense}));
806 auto td = graph_downsample(ctx, t_seq, require_param(params, root + ".downsample_t.bias"));
807 const int64_t d_frames = td.shape.dims[0];
808 auto f_seq = graph_transpose(ctx, td, {{1, 0, 2, 3}}, 3);
809 auto fd = graph_downsample(ctx, f_seq, require_param(params, root + ".downsample_f.bias"));
810 const int64_t d_freq = fd.shape.dims[0];
811 auto x = graph_transpose(ctx, fd, {{2, 1, 0, 3}}, 3);
812 x = graph_reshape(ctx, x, core::TensorShape::from_dims({1, kDense, d_frames, d_freq}));
813 x = graph_run_dual_encoder(ctx, constants, x, params, root + ".encoder");
814
815 auto f_up = graph_transpose(ctx, x, {{3, 2, 0, 1}}, 4);
816 f_up = graph_reshape(ctx, f_up, core::TensorShape::from_dims({d_freq, d_frames, kDense}));
817 f_up = graph_upsample_slice(ctx, f_up, ds, freq);
818 auto t_up = graph_transpose(ctx, f_up, {{1, 0, 2, 3}}, 3);
819 t_up = graph_upsample_slice(ctx, t_up, ds, frames);
820 auto orig = graph_transpose(ctx, input, {{2, 3, 0, 1}}, 4);
821 orig = graph_reshape(ctx, orig, core::TensorShape::from_dims({frames, freq, kDense}));
822 auto combined = graph_bypass(ctx, orig, t_up, require_param(params, root + ".out_combiner.bypass_scale"));
823 auto out = graph_transpose(ctx, combined, {{2, 0, 1, 3}}, 3);
824 return graph_reshape(ctx, out, core::TensorShape::from_dims({1, kDense, frames, freq}));
825}
826
827core::TensorValue graph_tsconformer(
828 core::ModuleBuildContext & ctx,

Callers 1

graph_tsconformerFunction · 0.85

Calls 6

graph_downsampleFunction · 0.85
graph_run_dual_encoderFunction · 0.85
graph_upsample_sliceFunction · 0.85
graph_bypassFunction · 0.85
graph_transposeFunction · 0.70
graph_reshapeFunction · 0.70

Tested by

no test coverage detected