Skip to content

Commit 6701c0c

Browse files
authored
Add cache_support flag (#9)
Signed-off-by: Greg Clark <[email protected]>
1 parent 7bf009b commit 6701c0c

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

nemo2riva/args.py

+6
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ def get_args(argv):
2929
parser.add_argument("--onnx-opset", type=int, default=14, help="ONNX opset for model export")
3030
parser.add_argument("--device", default="cuda", help="Device to export for")
3131
parser.add_argument("--export-subnet", default=None, help="Export specified subnetwork/layer")
32+
parser.add_argument(
33+
"--cache-support",
34+
type=lambda x: bool(strtobool(x)),
35+
default=None,
36+
help="cache support for models that support it"
37+
)
3238

3339
args = parser.parse_args(argv)
3440
return args

nemo2riva/cookbook.py

+4
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ def export_model(model, cfg, args, artifacts, metadata):
5151
runtime = format_meta["runtime"]
5252
metadata.update({"runtime": runtime})
5353

54+
if cfg.cache_support and hasattr(model, "encoder") and hasattr(model.encoder, "export_cache_support"):
55+
model.encoder.export_cache_support = True
56+
logging.info("Caching support is enabled.")
57+
5458
with tempfile.TemporaryDirectory() as tmpdir:
5559
export_filename = cfg.export_file
5660
export_file = os.path.join(tmpdir, export_filename)

nemo2riva/schema.py

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class ExportConfig:
3131
encryption: Optional[str] = None
3232
autocast: bool = False
3333
max_dim: int = None
34+
cache_support: bool = False
3435

3536

3637
@dataclass
@@ -90,6 +91,9 @@ def get_export_config(export_obj, args):
9091
"Format `{}` is invalid. Please pick one of the ({})".format(conf.export_format, supported_formats)
9192
)
9293

94+
if args.cache_support is not None:
95+
conf.cache_support = args.cache_support
96+
9397
return conf
9498

9599

0 commit comments

Comments
 (0)