    async def _to_proto_impl(
        self, obj: ext.NpNDArray, *, version: str
    ) -> _message.Message:
        """
        Process given objects and convert it to grpc protobuf response.

        Args:
            obj: ``np.array`` that will be serialized to protobuf.
        Returns:
            ``pb.NDArray``:
                Protobuf representation of given ``np.ndarray``
        """
        try:
            obj = self.validate_array(obj)
        except BadInput as e:
            raise e from None

        pb, _ = import_generated_stubs(version)

        try:
            fieldpb = npdtype_to_fieldpb_map()[obj.dtype]
            dtypepb = npdtype_to_dtypepb_map(version=version)[obj.dtype]
            return pb.NDArray(
                dtype=dtypepb,
                shape=tuple(obj.shape),
                **{fieldpb: obj.ravel().tolist()},
            )
        except KeyError:
            raise BadInput(
                f"Unsupported dtype '{obj.dtype}' for response message.",
            ) from None
Process given objects and convert it to grpc protobuf response.

Args:
obj: ``np.array`` that will be serialized to protobuf.
Returns:
``pb.NDArray``:
Protobuf representation of given ``np.ndarray``
src/bentoml/_internal/io_descriptors/numpy.py