// Part of the Concrete Compiler Project, under the BSD3 License with Zama // Exceptions. See // https://github.com/zama-ai/concrete-compiler-internal/blob/main/LICENSE.txt // for license information. #include "concretelang/Common/Protocol.h" #include "concrete-protocol.capnp.h" #include "concretelang/Common/Error.h" #include "llvm/ADT/Hashing.h" #include #include namespace concretelang { namespace protocol { /// Helper function turning a protocol `Shape` object into a vector of /// dimensions. std::vector protoShapeToDimensions(const Message &shape) { auto output = std::vector(); for (auto dim : shape.asReader().getDimensions()) { output.push_back(dim); } return output; } /// Helper function turning a protocol `Shape` object into a vector of /// dimensions. Message dimensionsToProtoShape(const std::vector &input) { auto output = Message(); auto dimensions = output.asBuilder().initDimensions(input.size()); for (size_t i = 0; i < input.size(); i++) { dimensions.set(i, input[i]); } return output; } template size_t hashMessage(Message &mess) { return llvm::hash_value(MessageToJSONString(mess)); } } // namespace protocol } // namespace concretelang