Skip to content

How to apply a PyTorch Linear layer to a 2D tensor with GGML #297

Answered by ggerganov
sevagh asked this question in Q&A
Discussion options

You must be logged in to vote

Change the order of the input dimensions like this:

struct ggml_tensor *input = ggml_new_tensor_2d(model.ctx, GGML_TYPE_F32, 2974, nb_frames);

Use ggml_mul_mat() like this:

x = ggml_mul_mat(model.ctx, model.fc1_w[0], x);

This is a bit unusual compared to normal frameworks. The ggml_mul_mat() technically computes zT = x * yT.
Hope this helps.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by sevagh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants