MLCompilerBridge
Tools for streamlining communication with ML models for compiler optimizations.
Loading...
Searching...
No Matches
protobufSerDes.h
Go to the documentation of this file.
1//=== SerDes/protobufSerDes.h - Protobuf Serialization/Deserialization C++-===//
2//
3// Part of the MLCompilerBridge Project, under the Apache License v2.0 with LLVM
4// Exceptions. See the LICENSE file for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
12//===----------------------------------------------------------------------===//
13
14#ifndef PROTOBUF_SERIALIZER_H
15#define PROTOBUF_SERIALIZER_H
16
17#include "SerDes/baseSerDes.h"
18#include "google/protobuf/extension_set.h"
19#include "google/protobuf/message.h"
20
21using namespace google::protobuf;
22
23namespace MLBridge {
26class ProtobufSerDes : public BaseSerDes {
27public:
29
30 static bool classof(const BaseSerDes *S) {
31 return S->getKind() == SerDesKind::Protobuf;
32 }
33
34 void setRequest(void *Request) override;
35 void setResponse(void *Response) override;
36
37 void *getRequest() override { return Request; }
38
39 void *getResponse() override { return Response; }
40
41#define SET_FEATURE(TYPE, _) \
42 virtual void setFeature(const std::string &, const TYPE) override; \
43 virtual void setFeature(const std::string &, const std::vector<TYPE> &) \
44 override;
46#undef SET_FEATURE
47
48 void setFeature(const std::string &name,
49 const google::protobuf::Message *value) override;
50 void
51 setFeature(const std::string &name,
52 const std::vector<google::protobuf::Message *> &value) override;
53
54 void *getSerializedData() override;
55 void cleanDataStructures() override;
56
57 Message *getMessage() { return Response; };
58
59private:
60 void *deserializeUntyped(void *data) override;
61 Message *Response;
62 Message *Request;
63};
64} // namespace MLBridge
65
66#endif
Supporting new SerDes:
#define SUPPORTED_TYPES(M)
Definition baseSerDes.h:32
#define SET_FEATURE(TYPE, _)
setFeature() is used to set the features of the data structure used for communication.
Definition baseSerDes.h:54
SerDesKind getKind() const
Definition baseSerDes.h:49
ProtobufSerDes - Protobuf Serialization/Deserialization to support gRPC communication.
void setFeature(const std::string &name, const google::protobuf::Message *value) override
void setResponse(void *Response) override
void setRequest(void *Request) override
static bool classof(const BaseSerDes *S)
void cleanDataStructures() override
void * getResponse() override
void * deserializeUntyped(void *data) override
void * getRequest() override
void * getSerializedData() override
SerDesKind
This is the base class for SerDes.
Definition baseSerDes.h:46