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

Remove parenthesis from asserts #699

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
Remove parenthesis from asserts
The 'assert' syntax is that this statement doesn’t require a pair of parentheses to group the expression and the optional message. In Python, 'assert' is a statement instead of a function.

The parentheses turn the assertion expression and message into a two-item tuple, which always evaluates to true, making the assertion useless.
  • Loading branch information
miguelusque authored Jul 2, 2023
commit 36ef5ce3221e1b194b137cf0de59c0cbebabe0e4
4 changes: 2 additions & 2 deletions examples/pytorch/gpt/utils/gpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(self, head_num, size_per_head, layer_num, vocab_size, max_seq_len,
has_post_decoder_layernorm: bool = True,
int8_mode: int = 0,
inter_size: int = 0):
assert(head_num % tensor_para_size == 0)
assert head_num % tensor_para_size == 0

if int8_mode == 1:
torch_infer_dtype = str_type_map[inference_data_type]
Expand Down Expand Up @@ -218,7 +218,7 @@ def __len__(self):
return len(self.w)

def _map(self, func):
assert(self.pre_embed_idx < self.post_embed_idx, "Pre decoder embedding index should be lower than post decoder embedding index.")
assert self.pre_embed_idx < self.post_embed_idx, "Pre decoder embedding index should be lower than post decoder embedding index."
for i in range(len(self.w)):
if isinstance(self.w[i], list):
for j in range(len(self.w[i])):
Expand Down