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

Function permute_tensor

src/models/chatterbox/s3_tokenizer_impl.cpp:80–97  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78 return engine::core::ensure_backend_addressable_layout(ctx, input);
79}
80
81engine::core::TensorValue permute_tensor(
82 engine::core::ModuleBuildContext & ctx,
83 const engine::core::TensorValue & input,
84 std::array<int, engine::core::kMaxTensorRank> axes) {
85 std::array<int, engine::core::kMaxTensorRank> ggml_axes = {0, 1, 2, 3};
86 engine::core::TensorShape output_shape = {};
87 output_shape.rank = input.shape.rank;
88 for (size_t out_logical_axis = 0; out_logical_axis < input.shape.rank; ++out_logical_axis) {
89 const int in_logical_axis = axes[out_logical_axis];
90 output_shape.dims[out_logical_axis] = input.shape.dims[in_logical_axis];
91 const int out_ggml_axis = static_cast<int>(input.shape.rank) - 1 - static_cast<int>(out_logical_axis);
92 ggml_axes[out_ggml_axis] = engine::core::logical_axis_to_ggml_axis(input.shape.rank, in_logical_axis);
93 }
94 return engine::core::wrap_tensor(
95 ggml_permute(ctx.ggml, input.tensor, ggml_axes[0], ggml_axes[1], ggml_axes[2], ggml_axes[3]),
96 output_shape,
97 input.type);
98}
99
100engine::core::TensorValue transpose_last_two(

Callers 4

transpose_last_twoFunction · 0.70
bct_to_btcFunction · 0.70
btc_to_bctFunction · 0.70

Calls 3

wrap_tensorFunction · 0.85
ggml_permuteFunction · 0.85

Tested by

no test coverage detected