-
Notifications
You must be signed in to change notification settings - Fork 104
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
Memory-mapped Utility for PECOS XLinear Model #166
Memory-mapped Utility for PECOS XLinear Model #166
Conversation
bool b_has_explicit_bias; // Whether or not this chunk has an explicit bias term | ||
index_type nnz_rows; // The number of non-zero rows in this chunk | ||
// Using index_type for struct padding | ||
index_type b_has_explicit_bias; // Whether or not this chunk has an explicit bias term, 0=false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
given that this variable is no longer a boolean, we might want to consider to remove the "b_" prefix.
|
||
shutil.copyfile(path.join(npz_folder, "param.json"), path.join(mmap_folder, "param.json")) | ||
|
||
HierarchicalMLModel.compile_mmap_model( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is compile_mmap_model
implemented in HierarchicalMLModel
? Also the namenpz_folder
is kind of misleading.
def xlinear_load_predict_only( | ||
self, | ||
folder, | ||
weight_matrix_type="BINARY_SEARCH_CHUNKED", | ||
is_mmap=False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add docstrings for the new kwargs here and HierarchicalMLModel.load
and XLinearModel.load
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, can this be inferred from the saved configs rather than given by the user?
""" | ||
import shutil | ||
|
||
shutil.copyfile(path.join(npz_folder, "param.json"), path.join(mmap_folder, "param.json")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add "compiled_format": "memory_map"
in the params.json
so that user need not to know the format before calling load
?
Issue #, if available:
N/A
Description of changes:
This pull request will consist of following 3 commits:
Usage:
User needs to have a XLinear Model saved on disk (in original
.npz
format), and manually compile into mmap format by callingcompile_mmap_model
:Then user can load the memory-mapped model and do inference:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.