MCPcopy Create free account
hub / github.com/MotrixLab/AiOS / _skip_loss

Method _skip_loss

detrsmpl/models/registrants/smplify.py:802–829  ·  view source on GitHub ↗

Whether to skip loss computation. If loss is None, it will directly skip the loss to avoid RuntimeError. If loss is not None, the table below shows the return value. If the return value is True, it means the computation of loss can be skipped. As the result is 0 even if it is

(loss, loss_weight_override)

Source from the content-addressed store, hash-verified

800
801 @staticmethod
802 def _skip_loss(loss, loss_weight_override):
803 """Whether to skip loss computation. If loss is None, it will directly
804 skip the loss to avoid RuntimeError. If loss is not None, the table
805 below shows the return value. If the return value is True, it means the
806 computation of loss can be skipped. As the result is 0 even if it is
807 calculated, we can skip it to save computational cost.
808
809 | loss.loss_weight | loss_weight_override | returns |
810 | ---------------- | -------------------- | ------- |
811 | == 0 | None | True |
812 | != 0 | None | False |
813 | == 0 | == 0 | True |
814 | != 0 | == 0 | True |
815 | == 0 | != 0 | False |
816 | != 0 | != 0 | False |
817
818 Args:
819 loss: loss is an object that has attribute loss_weight.
820 loss.loss_weight is assigned when loss is initialized.
821 loss_weight_override: loss_weight used to override loss.loss_weight
822
823 Returns:
824 bool: True means skipping loss computation, and vice versa
825 """
826 if (loss is None) or (loss.loss_weight == 0 and loss_weight_override is
827 None) or (loss_weight_override == 0):
828 return True
829 return False

Callers 1

_compute_lossMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected