Skip to content

QuantizeAndDequantizeV3 causes hard crash instead of InvalidArgumentError when axis=-1 with non-scalar input_min/input_max #99456

Closed

Description

@panda123dd

Issue type

Bug

Have you reproduced the bug with TensorFlow Nightly?

Yes

Source

binary

TensorFlow version

tf2.19, tf2.20, tf-nightly 2.21.0-dev20250827

Custom code

Yes

OS platform and distribution

Linux Ubuntu 22.04

Mobile device

No response

Python version

3.10

Bazel version

No response

GCC/compiler version

No response

CUDA/cuDNN version

No response

GPU model and memory

No response

Current behavior?

When I run the minimal reproduction code, the Python process terminates with a fatal CHECK failure instead of raising a catchable TensorFlow exception. Full error log:
2025-08-27 12:25:51.910891: F tensorflow/core/framework/tensor.cc:865]
Check failed: 1 == NumElements() (1 vs. 12) Must have a one element tensor
Aborted (core dumped)
This means the entire process crashes, which makes it impossible to catch the error in Python code (unlike a normal InvalidArgumentError)

Related issues:
I found a related report: tensorflow/tensorflow#94116
, which crashes with
tensorflow/core/framework/tensor_shape.cc:358] Check failed: d >= 0 (0 vs. -2)
My case is different: the crash happens in tensorflow/core/framework/tensor.cc:865 with a NumElements mismatch (1 vs. 12, must have a one element tensor).
Although both are shape-related CHECK failures, they are triggered in different code paths and should be considered distinct issues.

Standalone code to reproduce the issue

import tensorflow as tf

# 4D tensor input
input_data = tf.random.uniform(
    shape=[1, 2, 3, 2],
    dtype=tf.dtypes.float32,
    minval=0,
    maxval=1,
)

# Trigger crash
tf.raw_ops.QuantizeAndDequantizeV3(
    input=input_data,
    input_min=input_data,  # non-scalar
    input_max=input_data,  # non-scalar
    num_bits=8,
    signed_input=True,
    range_given=True,
    narrow_range=False,
    axis=-1,
)

Relevant log output

Activity

  1. google-ml-butler commented on Aug 27, 2025

    @google-ml-butler

    Are you satisfied with the resolution of your issue?
    Yes
    No

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions