Skip to content

Commit 4a4138a

Browse files
authored
The parameter will be out of scope (#28)
* Cannot use the input dil tensor to check is_public_format or not because it out of scope
1 parent d5acd80 commit 4a4138a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

torch_ipex/csrc/cpu/dbl/Common.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,26 +54,26 @@ at::Tensor gen_aten_tensor_by(dil::tensor&& dil_tensor) {
5454
shade_data_context->dil_tensor = std::forward<dil::tensor>(dil_tensor);
5555
shade_data_context->data_type = cpu::SHADE_DATA_TYPE::DIL;
5656
void *tensor_data = nullptr;
57-
if (dil_tensor.is_public_format()) {
57+
if (shade_data_context->dil_tensor->is_public_format()) {
5858
// The buffer of a tensor with public format is shared between CPU and DNNL
59-
tensor_data = dil_tensor.get_data_handle();
60-
shade_data_context->cpu_raw_data = dil_tensor.get_data_handle();
59+
tensor_data = shade_data_context->dil_tensor->get_data_handle();
60+
shade_data_context->cpu_raw_data = shade_data_context->dil_tensor->get_data_handle();
6161
shade_data_context->cpu_del_fun = &(c10::detail::deleteNothing);
6262
}
6363
c10::DataPtr shade_data_ptr(
6464
tensor_data,
6565
shade_data_context,
6666
cpu::ShadeDataContext::freeShadeDataContext,
6767
at::DeviceType::DPCPP);
68-
auto at_data_type = get_at_data_type(dil_tensor.get_data_type());
68+
auto at_data_type = get_at_data_type(shade_data_context->dil_tensor->get_data_type());
6969
auto storage_impl = c10::make_intrusive<at::StorageImpl>(
7070
at::scalarTypeToTypeMeta(at_data_type),
71-
dil_tensor.get_nelems(),
71+
shade_data_context->dil_tensor->get_nelems(),
7272
std::move(shade_data_ptr),
7373
nullptr,
7474
/*resizeable=*/false);
7575
auto _tensor = at::detail::make_tensor<torch_ipex::IPEXTensorImpl>(storage_impl, at::DispatchKey::DPCPPTensorId);
76-
dbl::comm::sync_shape_from_dil_to_aten(_tensor, dil_tensor);
76+
dbl::comm::sync_shape_from_dil_to_aten(_tensor, shade_data_context->dil_tensor.value());
7777
TORCH_INTERNAL_ASSERT_DEBUG_ONLY(_tensor.layout() == c10::kStrided);
7878
return _tensor;
7979
}

0 commit comments

Comments
 (0)