Skip to content
Merged
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
12 changes: 11 additions & 1 deletion python/tvm/relax/frontend/onnx/onnx_frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -2435,8 +2435,18 @@ def _impl_v15(cls, bb, inputs, attr, params):
mean = inputs[3]
var = inputs[4]
epsilon = attr.get("epsilon", 1e-05)
momentum = attr.get("momentum", 0.9)
training_mode = attr.get("training_mode", 0)
return relax.op.nn.batch_norm(
data, gamma=scale, beta=bias, moving_mean=mean, moving_var=var, epsilon=epsilon, axis=1
data,
gamma=scale,
beta=bias,
moving_mean=mean,
moving_var=var,
axis=1,
epsilon=epsilon,
momentum=momentum,
training=training_mode,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For clarity and type safety, it's better to explicitly cast training_mode to a boolean. The training parameter of relax.op.nn.batch_norm expects a boolean, and while Python's truthiness handles the integer 0 or 1 correctly, an explicit cast makes the intent clearer and guards against potential issues if the operator's signature becomes stricter in the future.

Suggested change
training=training_mode,
training=bool(training_mode),

)


Expand Down