Skip to content

Fix for windows builds with python 3.10 , getting rid of ssize_t #1627

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

Merged
merged 1 commit into from
Feb 23, 2022

Conversation

atalman
Copy link
Contributor

@atalman atalman commented Feb 23, 2022

Fix for windows builds with python 3.10 , getting rid of ssize_t. Since its not a standart type.

This is to fix error when building with Python 3.10 on windows:
Ref: https://app.circleci.com/pipelines/github/pytorch/text/4984/workflows/5df0236c-4758-412d-8a08-e50aa120be39/jobs/166014

Error details:

C:\Users\circleci\project\torchtext\csrc\register_pybindings.cpp(123): error C2065: 'ssize_t': undeclared identifier
C:\Users\circleci\project\torchtext\csrc\register_pybindings.cpp(123): error C2146: syntax error: missing ';' before identifier 'length'
C:\Users\circleci\project\torchtext\csrc\register_pybindings.cpp(123): error C2065: 'length': undeclared identifier
C:\Users\circleci\project\torchtext\csrc\register_pybindings.cpp(124): error C2065: 'length': undeclared identifier
C:\Users\circleci\project\torchtext\csrc\register_pybindings.cpp(125): error C2065: 'length': undeclared identifier
C:\Users\circleci\project\torchtext\csrc\register_pybindings.cpp(130): error C2065: 'ssize_t': undeclared identifier
C:\Users\circleci\project\torchtext\csrc\register_pybindings.cpp(130): error C2146: syntax error: missing ';' before identifier 'length'
C:\Users\circleci\project\torchtext\csrc\register_pybindings.cpp(130): error C2065: 'length': undeclared identifier
C:\Users\circleci\project\torchtext\csrc\register_pybindings.cpp(131): error C2065: 'length': undeclared identifier
C:\Users\circleci\project\torchtext\csrc\register_pybindings.cpp(132): error C2065: 'length': undeclared identifier
C:\Users\circleci\project\torchtext\csrc\register_pybindings.cpp(147): error C2065: 'ssize_t': undeclared identifier
C:\Users\circleci\project\torchtext\csrc\register_pybindings.cpp(147): error C2146: syntax error: missing ';' before identifier 'length'
C:\Users\circleci\project\torchtext\csrc\register_pybindings.cpp(147): error C2065: 'length': undeclared identifier
C:\Users\circleci\project\torchtext\csrc\register_pybindings.cpp(148): error C2065: 'length': undeclared identifier
C:\Users\circleci\project\torchtext\csrc\register_pybindings.cpp(150): error C2065: 'length': undeclared identifier
ninja: build stopped: subcommand failed.
Traceback (most recent call last):
  File "C:\Users\circleci\project\env\lib\site-packages\torch\utils\cpp_extension.py", line 1726, in _run_ninja_build
    subprocess.run(
  File "C:\Users\circleci\project\env\lib\subprocess.py", line 524, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.

Similar PR for pytorch core here and here

Summary for usage guidelines:
Use Py_ssize_t when calling Python API
Use c10::irange to automatically infer loop type
Use size_t or unsigned for unsigned type

Reference issue: here

@codecov
Copy link

codecov bot commented Feb 23, 2022

Codecov Report

Merging #1627 (1bf8a51) into main (81212ba) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1627   +/-   ##
=======================================
  Coverage   85.31%   85.31%           
=======================================
  Files          58       58           
  Lines        2492     2492           
=======================================
  Hits         2126     2126           
  Misses        366      366           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 81212ba...1bf8a51. Read the comment docs.

@malfet
Copy link
Contributor

malfet commented Feb 23, 2022

Can you please pass a reference to similar PR for PyTorch and explain why ssize_t should not be used in codebase?

@atalman
Copy link
Contributor Author

atalman commented Feb 23, 2022

Similar PR for pytorch core here and here

Summary for usage guidelines:
Use Py_ssize_t when calling Python API
Use c10::irange to automatically infer loop type
Use size_t or unsigned for unsigned type

Reference issue: here

@atalman atalman merged commit 7dcdbc9 into pytorch:main Feb 23, 2022
parmeet added a commit that referenced this pull request Feb 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants