summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--prelude/slang-torch-prelude.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/prelude/slang-torch-prelude.h b/prelude/slang-torch-prelude.h
index dee116261..8d978642d 100644
--- a/prelude/slang-torch-prelude.h
+++ b/prelude/slang-torch-prelude.h
@@ -87,6 +87,10 @@ TensorView make_tensor_view(torch::Tensor val, const char* name, torch::ScalarTy
if (val.dtype() != targetScalarType)
throw std::runtime_error(std::string(name).append(": tensor is not of the expected type.").c_str());
+ // Check that the tensor is contiguous
+ if (!val.is_contiguous())
+ throw std::runtime_error(std::string(name).append(": tensor is not contiguous.").c_str());
+
TensorView res = {};
res.dimensionCount = val.dim();
res.data = nullptr;