Files
concrete/compiler/include/concretelang/ServerLib/ServerLambda.h
Andi Drebes a7051c2c9c enhance(client/server): Add support for scalar results
This patch adds support for scalar results to the client/server
protocol and tests. In addition to `TensorData`, a new type
`ScalarData` is added. Previous representations of scalar values using
one-dimensional `TensorData` instances have been replaced with proper
instantiations of `ScalarData`.

The generic use of `TensorData` for scalar and tensor values has been
replaced with uses of a new variant `ScalarOrTensorData`, which can
either hold an instance of `TensorData` or `ScalarData`.
2022-10-04 14:40:40 +02:00

54 lines
1.6 KiB
C++

// 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.
#ifndef CONCRETELANG_SERVERLIB_SERVER_LAMBDA_H
#define CONCRETELANG_SERVERLIB_SERVER_LAMBDA_H
#include <cassert>
#include "boost/outcome.h"
#include "concretelang/ClientLib/ClientParameters.h"
#include "concretelang/ClientLib/PublicArguments.h"
#include "concretelang/ClientLib/Types.h"
#include "concretelang/Common/Error.h"
#include "concretelang/ServerLib/DynamicModule.h"
namespace concretelang {
namespace serverlib {
using concretelang::clientlib::ScalarOrTensorData;
/// ServerLambda is a utility class that allows to call a function of a
/// compilation result.
class ServerLambda {
public:
/// Load the symbol `funcName` from the shared lib in the artifacts folder
/// located in `outputPath`
static outcome::checked<ServerLambda, concretelang::error::StringError>
load(std::string funcName, std::string outputPath);
/// Load the symbol `funcName` of the dynamic loaded library
static outcome::checked<ServerLambda, concretelang::error::StringError>
loadFromModule(std::shared_ptr<DynamicModule> module, std::string funcName);
/// Call the ServerLambda with public arguments.
std::unique_ptr<clientlib::PublicResult>
call(clientlib::PublicArguments &args,
clientlib::EvaluationKeys &evaluationKeys);
protected:
ClientParameters clientParameters;
void *(*func)(void *...);
/// Retain module and open shared lib alive
std::shared_ptr<DynamicModule> module;
};
} // namespace serverlib
} // namespace concretelang
#endif