Skip to content

Commit 37b4256

Browse files
authored
check dtype before convert to dil tensor and add backend
* check dtype before convert to dil tensor * add backend * dil only receive float tensor
1 parent a5bdeb0 commit 37b4256

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

torch_ipex/csrc/cpu/dbl/Common.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@ namespace dbl {
1717
namespace comm {
1818

1919
dil::tensor dil_tensor_from_dense(const at::Tensor& tensor) {
20-
AT_ASSERTM(
20+
TORCH_CHECK(
2121
tensor.layout() == at::Layout::Strided,
22-
"dil_tensor_view_from_dense expects dense tensor input");
22+
"dil_tensor_from_dense expects dense tensor input");
23+
TORCH_CHECK(tensor.scalar_type() == at::ScalarType::Float
24+
"dil_tensor_from_dense expects tensor of at::ScalarType::Float");
25+
TORCH_CHECK(tensor.dim() <= 5,
26+
"Can't convert cpu tensor with the number of dimensions > 5");
2327
at::ScalarType cur_type = tensor.scalar_type();
2428
return {tensor.sizes().vec(), get_dil_data_type(cur_type), tensor.strides().vec(), tensor.data_ptr()};
2529
}

0 commit comments

Comments
 (0)