Skip to content

Commit

Permalink
update modelwriter and operator doc
Browse files Browse the repository at this point in the history
  • Loading branch information
nihui committed Sep 2, 2024
1 parent b5a3053 commit 03a186c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/developer-guide/operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -837,11 +837,13 @@ y = embedding(x)
| 1 | input_dim | int | 0 | |
| 2 | bias_term | int | 0 | |
| 3 | weight_data_size | int | 0 | |
| 18 | int8_scale_term| int | 0 | |

| weight | type | shape |
| ------------- | ----- | --------------------- |
| weight_data | float | [weight_data_size] |
| bias_term | float | [num_output] |
| weight_data_int8_scales| float | [1] |

# Exp
```
Expand Down
11 changes: 11 additions & 0 deletions tools/modelwriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -1676,9 +1676,20 @@ int ModelWriter::save(const char* parampath, const char* binpath)
fprintf_param_value(" 1=%d", input_dim)
fprintf_param_value(" 2=%d", bias_term)
fprintf_param_value(" 3=%d", weight_data_size)
fprintf_param_value(" 18=%d", int8_scale_term)

fwrite_weight_tag_data(op->weight_data, bp);
fwrite_weight_data(op->bias_data, bp);

#if NCNN_INT8
// write int8_scale data
if (op->int8_scale_term)
{
ncnn::Mat weight_data_int8_scales(1);
weight_data_int8_scales[0] = op->weight_data_int8_scale;
fwrite_weight_data(weight_data_int8_scales, bp, 90, 100);
}
#endif // NCNN_INT8
}
else if (layer->type == "Exp")
{
Expand Down

0 comments on commit 03a186c

Please sign in to comment.