Started inference engine
This commit is contained in:
1 parent
d89095e49b
commit
7797629673
61 files changed
+7832
-200
No files matched your search
Executable
+54
@@ -0,0 +1,54 @@
|
||||
// Runtime Initialization Header File
|
||||
|
||||
//Here's the complete `include/lm/runtime/init.hpp` file:
|
||||
|
||||
//```cpp
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <filesystem>
|
||||
|
||||
namespace lm::runtime {
|
||||
|
||||
class SystemState {
|
||||
public:
|
||||
// Singleton access
|
||||
static SystemState& get_instance();
|
||||
|
||||
// Initialize from JSON config
|
||||
void initialize(const std::filesystem::path& config_path);
|
||||
|
||||
// Configuration accessors
|
||||
const nlohmann::json& config() const noexcept;
|
||||
std::string get_string(const std::string& key) const;
|
||||
int get_int(const std::string& key, int default_val = 0) const;
|
||||
|
||||
// Subsystem states
|
||||
bool is_tokenizer_ready() const noexcept;
|
||||
bool is_model_loaded() const noexcept;
|
||||
|
||||
private:
|
||||
SystemState() = default; // Private constructor
|
||||
nlohmann::json config_;
|
||||
bool tokenizer_ready_ = false;
|
||||
bool model_loaded_ = false;
|
||||
};
|
||||
|
||||
} // namespace lm::runtime
|
||||
/*```
|
||||
|
||||
This header provides the interface for the framework initialization system with:
|
||||
|
||||
1. **Singleton pattern** for global system state access
|
||||
2. **JSON configuration** loading and access methods
|
||||
3. **Subsystem state tracking** for tokenizer and model
|
||||
4. **Type-safe configuration access** with default values
|
||||
|
||||
The implementation (in the corresponding `.cpp` file) handles:
|
||||
- JSON configuration parsing and validation
|
||||
- Subsystem initialization sequencing
|
||||
- Error handling for malformed configurations
|
||||
- State management across the framework
|
||||
|
||||
This initialization system provides a centralized way to configure and manage the LM framework components.*/
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
#include <filesystem>
|
||||
#include <chrono>
|
||||
|
||||
namespace lm::runtime {
|
||||
|
||||
class ShutdownHandler {
|
||||
public:
|
||||
// Serialize state to JSON
|
||||
static void save_state(
|
||||
const std::filesystem::path& output_path,
|
||||
bool include_model_weights = false
|
||||
);
|
||||
|
||||
// Cleanup hooks
|
||||
static void register_cleanup(void (*func)());
|
||||
static void execute_cleanup();
|
||||
};
|
||||
|
||||
} // namespace lm::runtime
|
||||
Reference in new issue
Block a user