forked from ggerganov/llama.cpp
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make yaml formatter and extractor working. TODO: yaml-parser needs to…
… take care of data type of args correctly instead of treat everything as string
- Loading branch information
Showing
45 changed files
with
4,674 additions
and
491 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#ifndef ANCHOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 | ||
#define ANCHOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 | ||
|
||
#if defined(_MSC_VER) || \ | ||
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ | ||
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 | ||
#pragma once | ||
#endif | ||
|
||
#include <cstddef> | ||
|
||
namespace YAML { | ||
using anchor_t = std::size_t; | ||
const anchor_t NullAnchor = 0; | ||
} | ||
|
||
#endif // ANCHOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#ifndef BASE64_H_62B23520_7C8E_11DE_8A39_0800200C9A66 | ||
#define BASE64_H_62B23520_7C8E_11DE_8A39_0800200C9A66 | ||
|
||
#if defined(_MSC_VER) || \ | ||
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ | ||
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 | ||
#pragma once | ||
#endif | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
#include "yaml-cpp/dll.h" | ||
|
||
namespace YAML { | ||
YAML_CPP_API std::string EncodeBase64(const unsigned char *data, | ||
std::size_t size); | ||
YAML_CPP_API std::vector<unsigned char> DecodeBase64(const std::string &input); | ||
|
||
class YAML_CPP_API Binary { | ||
public: | ||
Binary(const unsigned char *data_, std::size_t size_) | ||
: m_data{}, m_unownedData(data_), m_unownedSize(size_) {} | ||
Binary() : Binary(nullptr, 0) {} | ||
Binary(const Binary &) = default; | ||
Binary(Binary &&) = default; | ||
Binary &operator=(const Binary &) = default; | ||
Binary &operator=(Binary &&) = default; | ||
|
||
bool owned() const { return !m_unownedData; } | ||
std::size_t size() const { return owned() ? m_data.size() : m_unownedSize; } | ||
const unsigned char *data() const { | ||
return owned() ? &m_data[0] : m_unownedData; | ||
} | ||
|
||
void swap(std::vector<unsigned char> &rhs) { | ||
if (m_unownedData) { | ||
m_data.swap(rhs); | ||
rhs.clear(); | ||
rhs.resize(m_unownedSize); | ||
std::copy(m_unownedData, m_unownedData + m_unownedSize, rhs.begin()); | ||
m_unownedData = nullptr; | ||
m_unownedSize = 0; | ||
} else { | ||
m_data.swap(rhs); | ||
} | ||
} | ||
|
||
bool operator==(const Binary &rhs) const { | ||
const std::size_t s = size(); | ||
if (s != rhs.size()) | ||
return false; | ||
const unsigned char *d1 = data(); | ||
const unsigned char *d2 = rhs.data(); | ||
for (std::size_t i = 0; i < s; i++) { | ||
if (*d1++ != *d2++) | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
bool operator!=(const Binary &rhs) const { return !(*this == rhs); } | ||
|
||
private: | ||
std::vector<unsigned char> m_data; | ||
const unsigned char *m_unownedData; | ||
std::size_t m_unownedSize; | ||
}; | ||
} // namespace YAML | ||
|
||
#endif // BASE64_H_62B23520_7C8E_11DE_8A39_0800200C9A66 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#ifndef ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 | ||
#define ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 | ||
|
||
#if defined(_MSC_VER) || \ | ||
(defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ | ||
(__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 | ||
#pragma once | ||
#endif | ||
|
||
#include <vector> | ||
|
||
#include "../anchor.h" | ||
|
||
namespace YAML { | ||
/** | ||
* An object that stores and retrieves values correlating to {@link anchor_t} | ||
* values. | ||
* | ||
* <p>Efficient implementation that can make assumptions about how | ||
* {@code anchor_t} values are assigned by the {@link Parser} class. | ||
*/ | ||
template <class T> | ||
class AnchorDict { | ||
public: | ||
AnchorDict() : m_data{} {} | ||
void Register(anchor_t anchor, T value) { | ||
if (anchor > m_data.size()) { | ||
m_data.resize(anchor); | ||
} | ||
m_data[anchor - 1] = value; | ||
} | ||
|
||
T Get(anchor_t anchor) const { return m_data[anchor - 1]; } | ||
|
||
private: | ||
std::vector<T> m_data; | ||
}; | ||
} // namespace YAML | ||
|
||
#endif // ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66 |
Oops, something went wrong.