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

Mark tfdf ops as supported by tfjs-converter #7141

Merged
merged 3 commits into from
Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -455,15 +455,13 @@ def _copy_assets(saved_model_dir, output_dir):
if gfile.isdir(tmp_dir):
gfile.rmtree(tmp_dir)

# TFDF stores the necessary files for its binary in the assets folder.
ASSET_REQUIRING_OPS = frozenset([
'SimpleMLCreateModelResource'
'SimpleMLLoadModelFromPathWithHandle',
'SimpleMLInferenceOpWithHandle',
])

def _is_assets_required(model_ops):
return not ASSET_REQUIRING_OPS.isdisjoint(model_ops)
# TFDF stores the necessary files for its binary in the assets folder.
# Check if any TFDF ops are used in the model.
with resource_loader.open_file('op_list/tfdf.json') as tfdf_json:
ops = json.load(tfdf_json)
opNames = frozenset([x['tfOpName'] for x in ops])
return not opNames.isdisjoint(model_ops)

def _get_frozen_graph_ops(frozen_graph):
if frozen_graph is None:
Expand Down
11 changes: 11 additions & 0 deletions tfjs-converter/python/tensorflowjs/op_list/tfdf.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[
{
"tfOpName": "SimpleMLCreateModelResource"
},
{
"tfOpName": "SimpleMLLoadModelFromPathWithHandle"
},
{
"tfOpName": "SimpleMLInferenceOpWithHandle"
}
]