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

Support bf16 weight and dynamic shape #242

Merged
merged 2 commits into from
Nov 12, 2024
Merged
Changes from 1 commit
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 @@ -157,10 +157,10 @@ def print_tensor(self, tensor: torch.Tensor, size_limit: int = 16):
total_size *= dim

if size_limit < 0 or size_limit >= total_size:
return json.dumps(tensor.cpu().detach().numpy().tolist())
return json.dumps(tensor.cpu().detach().to(torch.float32).numpy().tolist())

return json.dumps(
(tensor.cpu().detach().numpy().flatten())[:size_limit].tolist()
(tensor.cpu().detach().to(torch.float32).numpy().flatten())[:size_limit].tolist()
)

def add_node_attrs(self, fx_node: torch.fx.node.Node, node: GraphNode):
Expand Down Expand Up @@ -204,7 +204,7 @@ def add_outputs_metadata(self, fx_node: torch.fx.node.Node, node: GraphNode):
node.outputsMetadata.append(metadata)
elif isinstance(out_vals, torch.Tensor):
dtype = str(out_vals.dtype)
shape = json.dumps(out_vals.shape)
shape = json.dumps(list(map(lambda x: int(x) if str(x).isdigit() else str(x), out_vals.shape)))
metadata = MetadataItem(
id='0', attrs=[KeyValue(key='tensor_shape', value=dtype + shape)]
)
Expand Down
Loading