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

[PyTorch] Make c10::str(const char*) return const char* #52222

Closed
wants to merge 4 commits into from

Conversation

swolchok
Copy link
Contributor

@swolchok swolchok commented Feb 12, 2021

Stack from ghstack:

c10::str() is often used with variadic macros. It can be more efficient to get a C string out if you put a C string in, like if you are able to defer std::string creation to an outlined function or even never do it at all. Meanwhile, there is an implicit conversion from const char* to std::string, so users who expected a std::string will still make one.

Differential Revision: D26419663

`c10::str()` is often used with variadic macros. It can be more efficient to get a C string out if you put a C string in, like if you are able to defer std::string creation to an outlined function or even never do it at all. Meanwhile, there is an implicit conversion from const char* to std::string, so users who expected a std::string will still make one.

Differential Revision: [D26419663](https://our.internmc.facebook.com/intern/diff/D26419663/)

[ghstack-poisoned]
@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented Feb 12, 2021

💊 CI failures summary and remediations

As of commit fc6714d (more details on the Dr. CI page):


  • 3/3 failures possibly* introduced in this PR
    • 1/3 non-CircleCI failure(s)

🕵️ 2 new failures recognized by patterns

The following CI failures do not appear to be due to upstream breakages:

See CircleCI build pytorch_linux_xenial_py3_6_gcc5_4_test (1/2)

Step: "Run tests" (full log | diagnosis details | 🔁 rerun)

Feb 17 20:43:08 AssertionError: mypy failed: torch/testing/_internal/common_quantized.py:147: error: Module has no attribute "_set_default_mobile_cpu_allocator" [attr-defined]
Feb 17 20:42:05 Test results will be stored in test-reports/python-unittest
Feb 17 20:42:11   test_doc_examples (__main__.TestTypeHints) ... ok (6.516s)
Feb 17 20:43:08   test_run_mypy (__main__.TestTypeHints) ... FAIL (56.625s)
Feb 17 20:43:08 
Feb 17 20:43:08 ======================================================================
Feb 17 20:43:08 FAIL [56.625s]: test_run_mypy (__main__.TestTypeHints) [mypy.ini]
Feb 17 20:43:08 ----------------------------------------------------------------------
Feb 17 20:43:08 Traceback (most recent call last):
Feb 17 20:43:08   File "test_type_hints.py", line 171, in test_run_mypy
Feb 17 20:43:08     self.fail(f"mypy failed: {stdout} {stderr}")
Feb 17 20:43:08 AssertionError: mypy failed: torch/testing/_internal/common_quantized.py:147: error: Module has no attribute "_set_default_mobile_cpu_allocator"  [attr-defined]
Feb 17 20:43:08 torch/testing/_internal/common_quantized.py:151: error: Module has no attribute "_unset_default_mobile_cpu_allocator"  [attr-defined]
Feb 17 20:43:08 caffe2/contrib/aten/aten_test.py:28: error: Argument 2 to "given" has incompatible type "**Dict[str, object]"; expected "Union[SearchStrategy[Any], InferType]"  [arg-type]
Feb 17 20:43:08 Found 3 errors in 2 files (checked 1238 source files)
Feb 17 20:43:08  
Feb 17 20:43:08 
Feb 17 20:43:08 ----------------------------------------------------------------------
Feb 17 20:43:08 Ran 2 tests in 63.141s
Feb 17 20:43:08 
Feb 17 20:43:08 FAILED (failures=1)
Feb 17 20:43:08 

See CircleCI build pytorch_linux_xenial_cuda10_2_cudnn7_py3_gcc7_test2 (2/2)

Step: "Run tests" (full log | diagnosis details | 🔁 rerun)

Feb 18 00:29:13 AssertionError: 'aten::addmm' != 'aten::linear'
Feb 18 00:29:13 AssertionError: True is not false
Feb 18 00:29:13 
Feb 18 00:29:13 ======================================================================
Feb 18 00:29:13 FAIL [0.005s]: test_profiler_shapes (__main__.TestAutograd)
Feb 18 00:29:13 ----------------------------------------------------------------------
Feb 18 00:29:13 Traceback (most recent call last):
Feb 18 00:29:13   File "test_autograd.py", line 3234, in test_profiler_shapes
Feb 18 00:29:13     self.assertEqual(event.name, name_expected)
Feb 18 00:29:13   File "/opt/conda/lib/python3.6/site-packages/torch/testing/_internal/common_utils.py", line 1187, in assertEqual
Feb 18 00:29:13     super().assertEqual(x, y, msg=self._get_assert_msg(msg, debug_msg=debug_msg))
Feb 18 00:29:13 AssertionError: 'aten::addmm' != 'aten::linear'
Feb 18 00:29:13 - aten::addmm
Feb 18 00:29:13 + aten::linear
Feb 18 00:29:13  : Attempted to compare [string] types: Expected: 'aten::addmm'; Actual: 'aten::linear'.
Feb 18 00:29:13 
Feb 18 00:29:13 ----------------------------------------------------------------------
Feb 18 00:29:13 Ran 2691 tests in 3126.878s
Feb 18 00:29:13 
Feb 18 00:29:13 FAILED (failures=2, skipped=19, expected failures=1)
Feb 18 00:29:13 
Feb 18 00:29:13 Generating XML reports...

ci.pytorch.org: 1 failed


This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions to the (internal) Dr. CI Users group.

`c10::str()` is often used with variadic macros. It can be more efficient to get a C string out if you put a C string in, like if you are able to defer std::string creation to an outlined function or even never do it at all. Meanwhile, there is an implicit conversion from const char* to std::string, so users who expected a std::string will still make one.

Differential Revision: [D26419663](https://our.internmc.facebook.com/intern/diff/D26419663/)

[ghstack-poisoned]
Copy link

@bhosmer bhosmer left a comment

Choose a reason for hiding this comment

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

😍

`c10::str()` is often used with variadic macros. It can be more efficient to get a C string out if you put a C string in, like if you are able to defer std::string creation to an outlined function or even never do it at all. Meanwhile, there is an implicit conversion from const char* to std::string, so users who expected a std::string will still make one.

Differential Revision: [D26419663](https://our.internmc.facebook.com/intern/diff/D26419663/)

[ghstack-poisoned]
`c10::str()` is often used with variadic macros. It can be more efficient to get a C string out if you put a C string in, like if you are able to defer std::string creation to an outlined function or even never do it at all. Meanwhile, there is an implicit conversion from const char* to std::string, so users who expected a std::string will still make one.

Differential Revision: [D26419663](https://our.internmc.facebook.com/intern/diff/D26419663/)

[ghstack-poisoned]
@facebook-github-bot
Copy link
Contributor

This pull request has been merged in d675593.

@facebook-github-bot facebook-github-bot deleted the gh/swolchok/127/head branch February 23, 2021 15:16
iramazanli pushed a commit to iramazanli/pytorch that referenced this pull request Feb 23, 2021
Summary:
Pull Request resolved: pytorch#52222

`c10::str()` is often used with variadic macros. It can be more efficient to get a C string out if you put a C string in, like if you are able to defer std::string creation to an outlined function or even never do it at all. Meanwhile, there is an implicit conversion from const char* to std::string, so users who expected a std::string will still make one.
ghstack-source-id: 121877052

(Note: this ignores all push blocking failures!)

Test Plan: CI

Reviewed By: bhosmer

Differential Revision: D26419663

fbshipit-source-id: 400bef71e6a0004b5914f5f511ea0e04e0d7599b
aocsa pushed a commit to Quansight/pytorch that referenced this pull request Mar 15, 2021
Summary:
Pull Request resolved: pytorch#52222

`c10::str()` is often used with variadic macros. It can be more efficient to get a C string out if you put a C string in, like if you are able to defer std::string creation to an outlined function or even never do it at all. Meanwhile, there is an implicit conversion from const char* to std::string, so users who expected a std::string will still make one.
ghstack-source-id: 121877052

(Note: this ignores all push blocking failures!)

Test Plan: CI

Reviewed By: bhosmer

Differential Revision: D26419663

fbshipit-source-id: 400bef71e6a0004b5914f5f511ea0e04e0d7599b
xsacha pushed a commit to xsacha/pytorch that referenced this pull request Mar 31, 2021
Summary:
Pull Request resolved: pytorch#52222

`c10::str()` is often used with variadic macros. It can be more efficient to get a C string out if you put a C string in, like if you are able to defer std::string creation to an outlined function or even never do it at all. Meanwhile, there is an implicit conversion from const char* to std::string, so users who expected a std::string will still make one.
ghstack-source-id: 121877052

(Note: this ignores all push blocking failures!)

Test Plan: CI

Reviewed By: bhosmer

Differential Revision: D26419663

fbshipit-source-id: 400bef71e6a0004b5914f5f511ea0e04e0d7599b
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.

3 participants