def _get_weight_to_compress_size(self, op: Operation) -> int:
        """
        For joint compression, the constexpr op is the intermediate compressed result, so we
        need to go along the constexpr op chain to get the op which actually is the weight need
        to be compressed.

        For example, the op could be a const feed into constexpr_lut_to_dense as indices, and the
        constexpr_lut_to_dense is fed into a conv op. In this case, we need to find the original
        weight of the conv op, instead of using the const indices to determine if we want to
        compress the op.
        """
        if not (op.op_type == "const" or op.op_type.startswith("constexpr_")):
            raise ValueError(f"Only support const or constexpr ops, but got {op.op_type}")

        if self.joint_compression:
            for op_output in op.outputs:
                # If the current const/constexpr is used in multiple ops, we do a depth-first
                # search to find the endpoint of the chained const/constexpr ops.
                for child_op in op_output.child_ops:
                    if child_op.op_type.startswith("constexpr_"):
                        return self._get_weight_to_compress_size(child_op)
                    else:
                        # The child op is not constexpr, which means the current op is the real
                        # weight (not intermediate constexpr) that need compression.
                        return np.prod(op.outputs[0].shape)

        if op.op_type != "const":
            raise ValueError("Only const weight can be compressed")
        return np.prod(op.outputs[0].shape)

        For joint compression, the constexpr op is the intermediate compressed result, so we
        need to go along the constexpr op chain to get the op which actually is the weight need
        to be compressed.

        For example, the op could be a const feed into constexpr_lut_to_dense as indices, and the
        constexpr_lut_to_dense is fed into a conv op. In this case, we need to find the original
        weight of the conv op, instead of using the const indices to determine if we want to
        compress the op.
        
coremltools/optimize/coreml/_quantization_passes.py