def compress(
        cls, val: np.ndarray, axis: int, mode: str, dtype: type
    ) -> "optimize_utils.QuantParamsIos16":
        """
        [Legacy] Per-channel quantization on axis.

        This API is for backward compatibility only. It's no longer used inside the coremltools.
        It's recommended to use `blockwise_compress` instead, which is more general.
        """
        if not isinstance(val, (np.ndarray, np.generic)):
            raise ValueError("Only numpy arrays are supported")
        if isinstance(dtype, np.dtype):
            dtype = types.numpy_type_to_builtin_type(dtype)
        if not types.is_builtin(dtype):
            raise ValueError(f"The input dtype is should be a built-in type, but got {type(dtype)}")

        block_sizes = [0] * len(val.shape)
        block_sizes[axis] = 1
        quant_params = cls.blockwise_compress(
            val,
            nbits=dtype.get_bitwidth(),
            mode=mode,
            signed=not dtype.is_unsigned(),
            block_sizes=block_sizes,
        )
        if quant_params is None:
            raise ValueError("Failed to quantize.")

        return optimize_utils.ios18_quant_params_to_ios16(quant_params)

        [Legacy] Per-channel quantization on axis.

        This API is for backward compatibility only. It's no longer used inside the coremltools.
        It's recommended to use `blockwise_compress` instead, which is more general.
        
coremltools/optimize/coreml/_quantization_passes.py