Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to load xa_nnlib_gru_biases_t properly #20

Open
Evanok opened this issue Feb 12, 2024 · 0 comments
Open

How to load xa_nnlib_gru_biases_t properly #20

Evanok opened this issue Feb 12, 2024 · 0 comments

Comments

@Evanok
Copy link

Evanok commented Feb 12, 2024

Small question about the biais header definition of nnlib-hifi4.

My original model using pytorch is defining this weigths and biases like this:

weight_ih_l -> (W_ir|W_iz|W_in)
weight_hh_l -> (W_hr|W_hz|W_hn)
bias_ih_l -> (b_ir|b_iz|b_in)
bias_hh_l -> (b_hr|b_hz|b_hn)

I can see that some c implementation are optimizing memory and computation by merging some bias like this:

b_r -> b_ir + b_hr
b_z -> b_iz + b_hz

This is logical after reviewing the original GRU formula (https://pytorch.org/docs/stable/generated/torch.nn.GRU.html)

So I am expecting 4 fields for the biais header:
b_r, b_z, b_hn and b_in.

But the biais header implementation for nnlib is only using 3 biases:

typedef struct _xa_nnlib_gru_biases_t
{
  void *b_z; xa_nnlib_shape_t shape_b_z;
  void *b_r; xa_nnlib_shape_t shape_b_r;
  void *b_h; xa_nnlib_shape_t shape_b_h;
} xa_nnlib_gru_biases_t;

How can I obtain this b_h? What did I miss?

@Evanok Evanok changed the title How to load xa_nnlib_gru_weights_t and xa_nnlib_gru_biases_t properly How to load xa_nnlib_gru_biases_t properly Feb 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant