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

Docstrings with backslashes are not set as raw strings #983

Open
andrei-stoian-zama opened this issue Jul 9, 2024 · 1 comment
Open

Comments

@andrei-stoian-zama
Copy link
Contributor

andrei-stoian-zama commented Jul 9, 2024

Two docstrings in core/scaling/pre_scaling.py contain backslashes which, when brevitas is imported during a pytest, issue errors:

  File "/__w/concrete-ml/concrete-ml/.venv/lib/python3.8/site-packages/brevitas/core/scaling/__init__.py", line 9, in <module>
    from .pre_scaling import AccumulatorAwareParameterPreScaling
  File "/__w/concrete-ml/concrete-ml/.venv/lib/python3.8/site-packages/brevitas/core/scaling/pre_scaling.py", line 198
    """Takes weights, input bit-width, and input sign as input and returns the pre-clipping
    ^
SyntaxError: invalid escape sequence \c

The solution is to make them raw strings:

    @brevitas.jit.script_method
    def forward(self, weights: Tensor, input_bit_width: Tensor, input_is_signed: bool) -> Tensor:
        r"""Takes weights, input bit-width, and input sign as input and returns the pre-clipping
        scaling factor per-channel, which is $s \cdot \Vert v - \mu_v \Vert_1 / g$"""

Two occurrences found for now: pre_scaling.py: 198 and 265.

Weirdly simply importing from brevitas.core.scaling import AccumulatorAwareParameterPreScaling (not in pytest) works fine. It seems to be something related to doctest but it's not very clear.

@Giuseppe5
Copy link
Collaborator

The only thing I'm wondering about is how these would look like in the documentation after the change to raw string. I will look into that. Thanks for spotting this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants