Skip to content

QuantizeAndDequantizeV3 with non-scalar input_min/input_max and axis=-1 crashes (tensor.cc:865) instead of raising InvalidArgumentError #99458

@panda123dd

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

No response

Bazel version

No response

GCC/compiler version

No response

CUDA/cuDNN version

No response

GPU model and memory

No response

Current behavior?

Running the code causes the entire Python process to terminate with a fatal CHECK failure, instead of raising a catchable TensorFlow exception.

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)

Expected behavior
TensorFlow should raise a proper Python exception (e.g., InvalidArgumentError) indicating that input_min and input_max must be scalars when using axis = -1. The current hard crash via CHECK makes it impossible to catch this error in user code and causes the process to abort.

Related issues:

I found a related report: [tensorflow/tensorflow#94116](https://github.com/tensorflow/tensorflow/issues/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 (not scalar for input_min/input_max)
input_data = tf.random.uniform(
    shape=[1, 2, 3, 2],
    dtype=tf.float32,
    minval=0,
    maxval=1,
)

# This call causes a hard 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

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)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions