Skip to content

Commit

Permalink
Triton ensemble export (#2251)
Browse files Browse the repository at this point in the history
  • Loading branch information
abidwael authored Aug 16, 2022
1 parent d25124f commit ed8d9cf
Show file tree
Hide file tree
Showing 5 changed files with 791 additions and 174 deletions.
3 changes: 2 additions & 1 deletion ludwig/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ def export_triton(model_path, output_path="model_repository", model_name="ludwig

model = LudwigModel.load(model_path)
os.makedirs(output_path, exist_ok=True)
utils_export_triton(model, output_path, model_name, model_version)

utils_export_triton(model=model, output_path=output_path, model_name=model_name, model_version=model_version)

logger.info(f"Saved to: {output_path}")

Expand Down
4 changes: 4 additions & 0 deletions ludwig/utils/misc_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,7 @@ def set_saved_weights_in_checkpoint_flag(config):
"""
for input_feature in config.get("input_features", []):
input_feature["saved_weights_in_checkpoint"] = True


def remove_empty_lines(str):
return "\n".join([line.rstrip() for line in str.split("\n") if line.rstrip()])
11 changes: 10 additions & 1 deletion ludwig/utils/torch_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ def input_dtype(self):
@abstractmethod
def input_shape(self) -> torch.Size:
"""Returns size of the input tensor without the batch dimension."""
raise NotImplementedError("Abstract class.")
pass
# raise NotImplementedError("Abstract class.")

@property
def output_shape(self) -> torch.Size:
Expand Down Expand Up @@ -307,3 +308,11 @@ def _set_torch_init_params(params: Optional[Tuple]):

def _get_torch_init_params() -> Optional[Tuple]:
return _TORCH_INIT_PARAMS


def model_size(model: nn.Module):
"""Computes PyTorch model size in bytes."""
size = 0
size += sum(param.nelement() * param.element_size() for param in model.parameters())
size += sum(buffer.nelement() * buffer.element_size() for buffer in model.buffers())
return size
Loading

0 comments on commit ed8d9cf

Please sign in to comment.