TVMRuntime.h 1.21 KB
Newer Older
Tianqi Chen committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
/*!
 *  Copyright (c) 2017 by Contributors
 * \file TVMRuntime.h
 */
#import <Foundation/Foundation.h>
// Customize logging mechanism, redirect to NSLOG
#define DMLC_LOG_CUSTOMIZE 1
#define TVM_METAL_RUNTIME 1

#include <tvm/runtime/registry.h>
#include <tvm/runtime/packed_func.h>
#include <functional>

namespace tvm {
namespace runtime {

/*!
 * \brief Message handling function for event driven server.
 *
 * \param in_bytes The incoming bytes.
 * \param event_flag  1: read_available, 2: write_avaiable.
 * \return State flag.
 *     1: continue running, no need to write,
 *     2: need to write
 *     0: shutdown
 */
using FEventHandler = std::function<int(const std::string& in_bytes, int event_flag)>;

/*!
 * \brief Create a server event handler.
 *
 * \param outputStream The output stream used to send outputs.
 * \param name The name of the server.
34
 * \param remote_key The remote key
Tianqi Chen committed
35 36
 * \return The event handler.
 */
37 38 39
FEventHandler CreateServerEventHandler(NSOutputStream *outputStream,
                                       std::string name,
                                       std::string remote_key);
Tianqi Chen committed
40 41 42 43 44 45 46 47 48

}  // namespace runtime
}  // namespace tvm

@interface TVMRuntime : NSObject

+ (void)launchSyncServer;

@end