def test_gather_static_overflow_int16(self, overflow_uint16):
        """Indices cannot be represented by int16 range, but might be represented by uint16."""
        max_index = 65536 if overflow_uint16 else 32768

        @mb.program(opset_version=ct.target.iOS17)
        def prog():
            params = np.array([[1, 2]] * (max_index + 1), dtype=np.float32)
            indices = np.array([max_index, 0], dtype=np.int32)
            return mb.gather(x=params, indices=indices, axis=0)

        prev_prog, _, block = apply_pass_and_basic_check(prog, "common::add_int16_cast")
        if overflow_uint16:
            assert get_op_types_in_program(prog) == get_op_types_in_program(prev_prog)
        else:
            assert get_op_types_in_program(prog) == ["cast", "gather"]
            cast_op = block.find_ops(op_type="cast")[0]
            assert cast_op.dtype.val == "uint16"
            assert cast_op.outputs[0] == block.find_ops(op_type="gather")[0].indices
Indices cannot be represented by int16 range, but might be represented by uint16.
coremltools/converters/mil/mil/passes/tests/test_quantization_passes.py