KEMBAR78
Added checks for dtype and device of OpInfo's sample_inputs by IvanYashchuk · Pull Request #54949 · pytorch/pytorch · GitHub
Skip to content

Conversation

@IvanYashchuk
Copy link
Collaborator

Currently, it's not tested whether op.sample_inputs actually used the provided dtype and device arguments. This PR fixes that introducing asserts in test_supported_dtypes.
This will help to detect incorrectly generated inputs in the future.

@IvanYashchuk IvanYashchuk added the module: tests Issues related to tests (not the torch.testing module) label Mar 30, 2021
@IvanYashchuk IvanYashchuk requested a review from mruberry March 30, 2021 10:00
@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented Mar 30, 2021

💊 CI failures summary and remediations

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


  • 1/1 failures introduced in this PR

🕵️ 1 new failure recognized by patterns

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

See CircleCI build pytorch-linux-xenial-py3-clang5-android-ndk-r19c-gradle-build-x86_32 (1/1)

Step: "pytorch android gradle build only x86_32 (for PR)" (full log | diagnosis details | 🔁 rerun)

Mar 31 14:24:39 2021-03-31T14:24:25.671+0000 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.
Mar 31 14:24:39 2021-03-31T14:24:24.335+0000 [DEBUG] [org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep] Additional implementations for ExtractAarTransform: /var/lib/jenkins/.gradle/caches/modules-2/files-2.1/androidx.vectordrawable/vectordrawable/1.0.0/eabb75f549c6a6ee4011e15adf04bf8ca33d3762/vectordrawable-1.0.0.aar: []
Mar 31 14:24:39 2021-03-31T14:24:24.339+0000 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Completing Build operation 'Snapshot inputs and outputs before executing ExtractAarTransform: /var/lib/jenkins/.gradle/caches/modules-2/files-2.1/androidx.vectordrawable/vectordrawable/1.0.0/eabb75f549c6a6ee4011e15adf04bf8ca33d3762/vectordrawable-1.0.0.aar'
Mar 31 14:24:39 2021-03-31T14:24:24.339+0000 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Build operation 'Snapshot inputs and outputs before executing ExtractAarTransform: /var/lib/jenkins/.gradle/caches/modules-2/files-2.1/androidx.vectordrawable/vectordrawable/1.0.0/eabb75f549c6a6ee4011e15adf04bf8ca33d3762/vectordrawable-1.0.0.aar' completed
Mar 31 14:24:39 2021-03-31T14:24:24.339+0000 [INFO] [org.gradle.internal.execution.steps.ResolveCachingStateStep] Caching disabled for ExtractAarTransform: /var/lib/jenkins/.gradle/caches/modules-2/files-2.1/androidx.vectordrawable/vectordrawable/1.0.0/eabb75f549c6a6ee4011e15adf04bf8ca33d3762/vectordrawable-1.0.0.aar because:
Mar 31 14:24:39   Build cache is disabled
Mar 31 14:24:39 2021-03-31T14:24:24.339+0000 [DEBUG] [org.gradle.internal.execution.steps.SkipUpToDateStep] Determining if ExtractAarTransform: /var/lib/jenkins/.gradle/caches/modules-2/files-2.1/androidx.vectordrawable/vectordrawable/1.0.0/eabb75f549c6a6ee4011e15adf04bf8ca33d3762/vectordrawable-1.0.0.aar is up-to-date
Mar 31 14:24:39 2021-03-31T14:24:24.339+0000 [INFO] [org.gradle.internal.execution.steps.SkipUpToDateStep] Skipping ExtractAarTransform: /var/lib/jenkins/.gradle/caches/modules-2/files-2.1/androidx.vectordrawable/vectordrawable/1.0.0/eabb75f549c6a6ee4011e15adf04bf8ca33d3762/vectordrawable-1.0.0.aar as it is up-to-date.
Mar 31 14:24:39 2021-03-31T14:24:24.340+0000 [INFO] [org.gradle.api.internal.artifacts.transform.TransformationStep] Transforming vectordrawable-1.0.0.aar (androidx.vectordrawable:vectordrawable:1.0.0) with AarTransform
Mar 31 14:24:39 2021-03-31T14:24:24.340+0000 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Build operation 'Snapshot inputs and outputs before executing AarTransform: /var/lib/jenkins/.gradle/caches/transforms-3/cae983d6090fbb575463eddde5bbe7c7/transformed/vectordrawable-1.0.0' started
Mar 31 14:24:39 2021-03-31T14:24:24.340+0000 [DEBUG] [org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep] Implementation for AarTransform: /var/lib/jenkins/.gradle/caches/transforms-3/cae983d6090fbb575463eddde5bbe7c7/transformed/vectordrawable-1.0.0: com.android.build.gradle.internal.dependency.AarTransform@3a9ca42468047b6ec848e4faf42b2021-03-31T14:24:25.671+0000 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
Mar 31 14:24:39 2021-03-31T14:24:25.671+0000 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.
Mar 31 14:24:39 2021-03-31T14:24:25.671+0000 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
Mar 31 14:24:39 2021-03-31T14:24:25.672+0000 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong:
Mar 31 14:24:39 2021-03-31T14:24:25.672+0000 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Could not determine the dependencies of task ':test_app:lintVitalResnet18LocalBaseRelease'.
Mar 31 14:24:39 2021-03-31T14:24:25.672+0000 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > Could not resolve all artifacts for configuration ':test_app:mnetLocalBaseDebugAndroidTestCompileClasspath'.
Mar 31 14:24:39 2021-03-31T14:24:25.672+0000 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]    > Could not resolve com.facebook.soloader:nativeloader:0.8.0.
Mar 31 14:24:39 2021-03-31T14:24:25.672+0000 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]      Required by:
Mar 31 14:24:39 2021-03-31T14:24:25.672+0000 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]          project :test_app
Mar 31 14:24:39 2021-03-31T14:24:25.672+0000 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]       > No cached version of com.facebook.soloader:nativeloader:0.8.0 available for offline mode.
Mar 31 14:24:39 2021-03-31T14:24:25.672+0000 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]       > No cached version of com.facebook.soloader:nativeloader:0.8.0 available for offline mode.
Mar 31 14:24:39 2021-03-31T14:24:25.672+0000 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]       > No cached version of com.facebook.soloader:nativeloader:0.8.0 available for offline mode.

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.

@codecov
Copy link

codecov bot commented Mar 30, 2021

Codecov Report

Merging #54949 (6cb630b) into master (6d87b36) will increase coverage by 36.10%.
The diff coverage is n/a.

❗ Current head 6cb630b differs from pull request most recent head fb24dbe. Consider uploading reports for the commit fb24dbe to get more accurate results

@@             Coverage Diff             @@
##           master   #54949       +/-   ##
===========================================
+ Coverage   40.88%   76.98%   +36.10%     
===========================================
  Files         564     1892     +1328     
  Lines       69995   186418   +116423     
===========================================
+ Hits        28620   143521   +114901     
- Misses      41375    42897     +1522     

@H-Huang H-Huang added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Mar 30, 2021
Copy link
Collaborator

@mruberry mruberry left a comment

Choose a reason for hiding this comment

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

Neat. Note that, in general, when requesting a sample input for a CUDA device not ALL tensors are expected to be on CUDA. But requiring the "input" tensor be on the device and of the correct dtype seems reasonable, and this would be easy to modify in the future.

@facebook-github-bot
Copy link
Contributor

@mruberry has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@mruberry
Copy link
Collaborator

cc @heitorschueroff for a pointer

This is going to need a rebase to handle tensor lists inputs, too

@IvanYashchuk
Copy link
Collaborator Author

@mruberry I modified the code for checking of tensor lists input. Only the first tensor in the list is checked.

@facebook-github-bot
Copy link
Contributor

@mruberry has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@mruberry merged this pull request in 2798f38.

facebook-github-bot pushed a commit that referenced this pull request Apr 13, 2021
Summary:
#### Reason for relanding
Line 1607 of `torch/testing/_internal/common_methods_invocations.py` of #50999  had `dtype` instead of `dtype=torch.bool`, so 4 of the 9 sample inputs for `bool` had incorrect dtype. This bug was caught by #54949.

1. Added support for pow() on CPU for `float16` (`Half`) and `bfloat16` types.
Both `pow(Tensor, Scalar)` and `pow(Tensor, Tensor)` are now supported for the aforementioned types.
However autograd isn't supported for `Float16` on CPU yet, as `log_vml_cpu` can't be enabled for it.
2. heitorschueroff added `pow_tensor_scalar_optimized_kernel` to refactor & simplify `PowKernel.cpp`.
It provides a common path for all the complex types & floating point types (except Float16, due to lack of complete AVX2 vectorization support for it).  It replaced code that had previously been duplicated for (float, double) and complex types,
so PowKernel.cpp looks a lot cleaner now.
3. Enabled (unskipped) some tests for `erf`, `erfc`,`erfinv`, `tan` and `linalg.vector.norm` which were being skipped earlier due to `pow()` not having been implemented for `float16` & `bfloat16`.
4. Added an OpInfo for `pow()` & enabled some test cases for `pow()`.
5. Extended the coverage of existing tests for `pow` in `test_binary_ufuncs.py` in order to enable comparison with `numpy`, even with discontiguous tensors, and added a test to ensure that a runtime error is raised for `pow`'s inplace variant if resizing the base tensor is required during its invocation.
6. Added `float16` & `bfloat16` to `square`'s dtype lists in its `UnaryUfuncInfo`.
7. Removed redundant `dtypesIfCPU` and `dtypesIfCUDA` from `OpInfo`s where they are equal to `dtypes`.

Pull Request resolved: #55280

Reviewed By: jbschlosser

Differential Revision: D27591772

Pulled By: heitorschueroff

fbshipit-source-id: c7420811b32595bb3353149a61e54a73f2eb352b
krshrimali pushed a commit to krshrimali/pytorch that referenced this pull request May 19, 2021
…orch#55280)

Summary:
#### Reason for relanding
Line 1607 of `torch/testing/_internal/common_methods_invocations.py` of pytorch#50999  had `dtype` instead of `dtype=torch.bool`, so 4 of the 9 sample inputs for `bool` had incorrect dtype. This bug was caught by pytorch#54949.

1. Added support for pow() on CPU for `float16` (`Half`) and `bfloat16` types.
Both `pow(Tensor, Scalar)` and `pow(Tensor, Tensor)` are now supported for the aforementioned types.
However autograd isn't supported for `Float16` on CPU yet, as `log_vml_cpu` can't be enabled for it.
2. heitorschueroff added `pow_tensor_scalar_optimized_kernel` to refactor & simplify `PowKernel.cpp`.
It provides a common path for all the complex types & floating point types (except Float16, due to lack of complete AVX2 vectorization support for it).  It replaced code that had previously been duplicated for (float, double) and complex types,
so PowKernel.cpp looks a lot cleaner now.
3. Enabled (unskipped) some tests for `erf`, `erfc`,`erfinv`, `tan` and `linalg.vector.norm` which were being skipped earlier due to `pow()` not having been implemented for `float16` & `bfloat16`.
4. Added an OpInfo for `pow()` & enabled some test cases for `pow()`.
5. Extended the coverage of existing tests for `pow` in `test_binary_ufuncs.py` in order to enable comparison with `numpy`, even with discontiguous tensors, and added a test to ensure that a runtime error is raised for `pow`'s inplace variant if resizing the base tensor is required during its invocation.
6. Added `float16` & `bfloat16` to `square`'s dtype lists in its `UnaryUfuncInfo`.
7. Removed redundant `dtypesIfCPU` and `dtypesIfCUDA` from `OpInfo`s where they are equal to `dtypes`.

Pull Request resolved: pytorch#55280

Reviewed By: jbschlosser

Differential Revision: D27591772

Pulled By: heitorschueroff

fbshipit-source-id: c7420811b32595bb3353149a61e54a73f2eb352b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla signed Merged module: tests Issues related to tests (not the torch.testing module) open source triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants