Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/pytorch/pytorch
Browse files Browse the repository at this point in the history
  • Loading branch information
ynonaolga committed Nov 15, 2022
2 parents d840579 + ee05f47 commit 1d2bc5c
Show file tree
Hide file tree
Showing 72 changed files with 1,937 additions and 277 deletions.
7 changes: 6 additions & 1 deletion .github/actions/setup-rocm/action.yml
Expand Up @@ -36,7 +36,12 @@ runs:
run: |
ngpu=$(rocminfo | grep -c -E 'Name:.*\sgfx')
if [[ "x$ngpu" != "x2" && "x$ngpu" != "x4" ]]; then
echo "Failed to detect GPUs on the runner"
if [[ $ngpu -eq 0 ]]; then
echo "Error: Failed to detect any GPUs on the runner"
else
echo "Error: Detected $ngpu GPUs on the runner, when only 2 or 4 were expected"
fi
echo "Please file an issue on pytorch/pytorch reporting the faulty runner. Include a link to the runner logs so the runner can be identified"
exit 1
fi
Expand Down
7 changes: 6 additions & 1 deletion .github/templates/common.yml.j2
Expand Up @@ -78,7 +78,12 @@ concurrency:
run: |
ngpu=$(rocminfo | grep -c -E 'Name:.*\sgfx')
if [[ "x$ngpu" != "x2" && "x$ngpu" != "x4" ]]; then
echo "Failed to detect GPUs on the runner"
if [[ $ngpu -eq 0 ]]; then
echo "Error: Failed to detect any GPUs on the runner"
else
echo "Error: Detected $ngpu GPUs on the runner, when only 2 or 4 were expected"
fi
echo "Please file an issue on pytorch/pytorch reporting the faulty runner. Include a link to the runner logs so the runner can be identified"
exit 1
fi
- name: Runner health check disconnect on failure
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 48 additions & 8 deletions .github/workflows/generated-linux-binary-manywheel-nightly.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .jenkins/pytorch/test.sh
Expand Up @@ -249,7 +249,7 @@ test_inductor_distributed() {
}

test_inductor() {
python test/run_test.py --include test_modules --verbose
python test/run_test.py --include test_modules test_ops --verbose
# TODO: investigate "RuntimeError: CUDA driver API confirmed a leak"
# seen intest_ops_gradients.py
# pytest test/test_ops_gradients.py --verbose -k "not _complex and not test_inplace_grad_acos_cuda_float64"
Expand Down
31 changes: 15 additions & 16 deletions aten/src/ATen/native/ComplexHelper.h
Expand Up @@ -18,19 +18,18 @@ namespace at { namespace native {
// View tensor with new dtype, storage offset, sizes and strides
inline Tensor view_tensor(
const Tensor &tensor, ScalarType dtype,
int64_t offset, IntArrayRef sizes, IntArrayRef strides) {
c10::SymInt offset, SymIntArrayRef sizes, SymIntArrayRef strides) {
Storage storage = tensor.storage();
auto key_set = tensor.key_set().remove(DispatchKey::Conjugate);
auto new_tensor = detail::make_tensor<TensorImpl>(
c10::TensorImpl::VIEW, std::move(storage), key_set, scalarTypeToTypeMeta(dtype));
auto * impl = new_tensor.unsafeGetTensorImpl();
impl->set_storage_offset(offset);
impl->set_sizes_and_strides(sizes, strides);
impl->set_sizes_and_strides(sizes, strides, offset);
return new_tensor;
}

inline DimVector computeStrideForViewAsReal(IntArrayRef oldstride) {
DimVector res(oldstride.size() + 1);
inline SymDimVector computeStrideForViewAsReal(SymIntArrayRef oldstride) {
SymDimVector res(oldstride.size() + 1);
for (const auto i : c10::irange(oldstride.size())) {
res[i] = oldstride[i] * 2;
}
Expand All @@ -40,13 +39,13 @@ inline DimVector computeStrideForViewAsReal(IntArrayRef oldstride) {

Tensor _view_as_real_physical(const Tensor& self) {
TORCH_CHECK(self.is_complex(), "view_as_real is only supported for complex tensors");
auto old_sizes = self.sizes();
DimVector new_sizes(old_sizes.size() + 1);
auto old_sizes = self.sym_sizes();
SymDimVector new_sizes(old_sizes.size() + 1);
std::copy(old_sizes.begin(), old_sizes.end(), new_sizes.begin());
// last dimension will always have two elements containing the real and imag vals
new_sizes.back() = 2;
auto new_strides = computeStrideForViewAsReal(self.strides());
auto new_storage_offset = 2 * self.storage_offset();
auto new_strides = computeStrideForViewAsReal(self.sym_strides());
auto new_storage_offset = self.sym_storage_offset() * 2;
const auto float_type = c10::toRealValueType(self.scalar_type());
auto real_tensor = view_tensor(self, float_type, new_storage_offset, new_sizes, new_strides);
return real_tensor;
Expand All @@ -60,11 +59,11 @@ Tensor view_as_real(const Tensor& self) {
return _view_as_real_physical(self);
}

inline DimVector computeStrideForViewAsComplex(IntArrayRef oldstride) {
inline SymDimVector computeStrideForViewAsComplex(SymIntArrayRef oldstride) {
const int64_t dim = oldstride.size();
TORCH_CHECK(oldstride[dim-1] == 1, "Tensor must have a last dimension with stride 1");

DimVector res(dim - 1);
SymDimVector res(dim - 1);
for (const auto i : c10::irange(res.size())) {
TORCH_CHECK(oldstride[i] % 2 == 0, "Tensor must have a stride divisible by 2 for all but last dimension");
res[i] = oldstride[i] / 2;
Expand All @@ -79,16 +78,16 @@ Tensor view_as_complex(const Tensor& self) {
self.scalar_type() == kFloat || self.scalar_type() == kDouble || self.scalar_type() == kHalf,
"view_as_complex is only supported for half, float and double tensors, but got a tensor of scalar type: ", self.scalar_type());

auto old_sizes = self.sizes();
auto old_sizes = self.sym_sizes();
TORCH_CHECK(old_sizes.size() != 0, "Input tensor must have one or more dimensions");
TORCH_CHECK(old_sizes[old_sizes.size()-1] == 2, "Tensor must have a last dimension of size 2");
DimVector new_sizes(old_sizes.begin(), old_sizes.end() - 1);
SymDimVector new_sizes(old_sizes.begin(), old_sizes.end() - 1);

const auto new_strides = computeStrideForViewAsComplex(self.strides());
const auto new_strides = computeStrideForViewAsComplex(self.sym_strides());
const auto complex_type = c10::toComplexType(self.scalar_type());

TORCH_CHECK(self.storage_offset() % 2 == 0, "Tensor must have a storage_offset divisible by 2");
const auto new_storage_offset = self.storage_offset() / 2;
TORCH_CHECK(self.sym_storage_offset() % 2 == 0, "Tensor must have a storage_offset divisible by 2");
const auto new_storage_offset = self.sym_storage_offset() / 2;

return view_tensor(self, complex_type, new_storage_offset, new_sizes, new_strides);
}
Expand Down

0 comments on commit 1d2bc5c

Please sign in to comment.