From 647154f82ac2c57769f080c41452b3e5960ab94f Mon Sep 17 00:00:00 2001 From: Gregory Chanan Date: Mon, 25 Mar 2019 08:38:11 -0700 Subject: [PATCH] Assert tensor isn't sparse in enforce_invariants. (#18338) Summary: There's no reason we can't check this, but I'm punting on implementing it for now. But it currently segfaults, so this is an improvements. Pull Request resolved: https://github.com/pytorch/pytorch/pull/18338 Differential Revision: D14580308 Pulled By: gchanan fbshipit-source-id: 44d4cafeab12e1beeb3453a2d4068d221c2e9c4f --- aten/src/ATen/core/Tensor.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/aten/src/ATen/core/Tensor.cpp b/aten/src/ATen/core/Tensor.cpp index 776b4bb..d575423 100644 --- a/aten/src/ATen/core/Tensor.cpp +++ b/aten/src/ATen/core/Tensor.cpp @@ -20,6 +20,9 @@ void Tensor::enforce_invariants() { impl_->dtype_initialized(), "Partially-initialized tensor not supported by at::Tensor"); AT_ASSERTM( + !impl_->is_sparse(), + "Sparse Tensors are supported by at::Tensor, but invariant checking isn't implemented. Please file a bug."); + AT_ASSERTM( impl_->storage_initialized(), "Partially-initialized tensor not supported by at::Tensor"); } -- 2.7.4