Skip to content

Commit fda3b64

Browse files
committed
fix debug only assert
1 parent 2b1b54e commit fda3b64

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

tests/cpu/test_lazy_reorder.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ def test_seq_deconv(self):
153153

154154
class TestBinaryOp(TestCase):
155155
def test_add(self):
156+
# rand_seed = 1599794793172034560: AssertionError: tensor(1.5259e-05) not less than or equal to 1e-05
156157
ipex.core.enable_auto_dnnl()
157158
rand_seed = int(get_rand_seed())
158159
print("{} rand sed: {}".format(sys._getframe().f_code.co_name, rand_seed))

torch_ipex/csrc/cpu/ShadeDataContext.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,11 @@ struct ShadeDataContext {
201201
static inline bool isTensorMixPrecision(const at::Tensor &tensor) {
202202
auto dil_tensor_type = getDilStorage(tensor).get_data_type();
203203
auto aten_tensor_type = tensor.scalar_type();
204-
TORCH_INTERNAL_ASSERT_DEBUG_ONLY(aten_tensor_type == at::kFloat || aten_tensor_type == at::kBFloat16
205-
|| aten_tensor_type == at::kByte || aten_tensor_type == at::kChar);
206-
TORCH_INTERNAL_ASSERT_DEBUG_ONLY(dil_tensor_type == dil::data_type::bf16 || dil_tensor_type == dil::data_type::f32
204+
if (aten_tensor_type != at::kFloat) {
205+
return false;
206+
}
207+
auto res = (dil_tensor_type == dil::data_type::bf16
207208
|| dil_tensor_type == dil::data_type::u8 || dil_tensor_type == dil::data_type::s8);
208-
auto res = (dil_tensor_type == dil::data_type::bf16 || dil_tensor_type == dil::data_type::u8
209-
|| dil_tensor_type == dil::data_type::s8) && aten_tensor_type == at::kFloat ;
210209

211210
// Check mix_precision
212211
void *raw_context = tensor.storage().data_ptr().get_context();

torch_ipex/csrc/cpu/dbl/Common.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,7 @@ void reorder_to_public(const at::Tensor& tensor, bool remain_dtype) {
296296
bool is_public_format = dil_buffer.is_public_format();
297297
bool is_public_dtype = !cpu::ShadeDataContext::isTensorMixPrecision(tensor);
298298

299-
TORCH_INTERNAL_ASSERT_DEBUG_ONLY(
300-
is_public_dtype && (aten_dtype == at::kFloat || aten_dtype == at::kBFloat16) || !is_public_dtype && aten_dtype == at::kFloat)
299+
TORCH_INTERNAL_ASSERT_DEBUG_ONLY(is_public_dtype || (!is_public_dtype && aten_dtype == at::kFloat));
301300

302301
bool should_reorder_format = !is_public_format;
303302
bool should_reorder_dtype = !is_public_dtype && !remain_dtype;

0 commit comments

Comments
 (0)