-
Notifications
You must be signed in to change notification settings - Fork 8
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
[feat] add tdm serving tree & remove recall_num in gen tree #2
Open
tiankongdeguiji
wants to merge
7
commits into
alibaba:master
Choose a base branch
from
tiankongdeguiji:features/tdm_serving_tree
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
dda0e4a
add tdm serving tree & remove recall_num in gen tree
tiankongdeguiji 8a95f19
add asset_files to export entry
tiankongdeguiji 8ff0836
remove success=True in test
tiankongdeguiji 8053882
fix tree search test
tiankongdeguiji 3146bf0
add failed exit 1 to test runner
tiankongdeguiji ec8ef1d
make serving tree use tree_output_dir as directory, node_edge_output_…
tiankongdeguiji 6172e5c
fix tests
tiankongdeguiji File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
import itertools | ||
import json | ||
import os | ||
import shutil | ||
from collections import OrderedDict | ||
from queue import Queue | ||
from threading import Thread | ||
|
@@ -747,7 +748,10 @@ def _script_model( | |
|
||
|
||
def export( | ||
pipeline_config_path: str, export_dir: str, checkpoint_path: Optional[str] = None | ||
pipeline_config_path: str, | ||
export_dir: str, | ||
checkpoint_path: Optional[str] = None, | ||
asset_files: Optional[str] = None, | ||
) -> None: | ||
"""Export a EasyRec model. | ||
|
||
|
@@ -756,6 +760,7 @@ def export( | |
export_dir (str): base directory where the model should be exported. | ||
checkpoint_path (str, optional): if specified, will use this model instead of | ||
model specified by model_dir in pipeline_config_path. | ||
asset_files (str, optional): more files will be copy to export_dir. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. more files will be copied to export_dir. |
||
""" | ||
pipeline_config = config_util.load_pipeline_config(pipeline_config_path) | ||
ori_pipeline_config = copy.copy(pipeline_config) | ||
|
@@ -766,6 +771,10 @@ def export( | |
if os.path.exists(export_dir): | ||
raise RuntimeError(f"directory {export_dir} already exist.") | ||
|
||
assets = [] | ||
if asset_files: | ||
assets = asset_files.split(",") | ||
|
||
data_config = pipeline_config.data_config | ||
# Build feature | ||
features = _create_features(list(pipeline_config.feature_configs), data_config) | ||
|
@@ -832,13 +841,16 @@ def export( | |
for name, module in cpu_model.named_children(): | ||
if isinstance(module, MatchTower): | ||
tower = ScriptWrapper(TowerWrapper(module, name)) | ||
tower_export_dir = os.path.join(export_dir, name.replace("_tower", "")) | ||
_script_model( | ||
ori_pipeline_config, | ||
tower, | ||
cpu_state_dict, | ||
dataloader, | ||
os.path.join(export_dir, name.replace("_tower", "")), | ||
tower_export_dir, | ||
) | ||
for asset in assets: | ||
shutil.copy(asset, tower_export_dir) | ||
elif isinstance(cpu_model, TDM): | ||
for name, module in cpu_model.named_children(): | ||
if isinstance(module, EmbeddingGroup): | ||
|
@@ -857,7 +869,8 @@ def export( | |
dataloader, | ||
export_dir, | ||
) | ||
|
||
for asset in assets: | ||
shutil.copy(asset, export_dir) | ||
else: | ||
_script_model( | ||
ori_pipeline_config, | ||
|
@@ -866,6 +879,8 @@ def export( | |
dataloader, | ||
export_dir, | ||
) | ||
for asset in assets: | ||
shutil.copy(asset, export_dir) | ||
|
||
|
||
def predict( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
GL的全称是什么?