native_neural_network 0.3.1

Lib no_std Rust for native neural network (.rnn)
Documentation
#pragma once

#include <cstddef>
#include <cstdint>
#include <stdexcept>
#include <string>
#include <vector>

#include "../../../include/rnn_api.h"

namespace rnn {

class FfiError final : public std::runtime_error {
public:
  FfiError(int code, const std::string& message)
      : std::runtime_error("RNN FFI error " + std::to_string(code) + ": " + message), code_(code) {}

  int code() const noexcept { return code_; }

private:
  int code_;
};

struct BenchmarkRecord {
  std::string model_name;
  std::string precision;
  std::uint64_t elapsed_ms{};
  std::uint64_t iterations{};
  float avg_loss{};
  float last_loss{};
  std::uint64_t output_bytes{};
  std::uint64_t train_samples{};
  std::uint64_t total_params{};
  std::uint32_t layer_count{};
  std::uint32_t input_dim{};
  std::uint32_t output_dim{};
  std::uint64_t benchmark_flags{};
  std::uint64_t weights_bytes{};
  std::uint64_t biases_bytes{};
  float min_loss{};
  float max_loss{};
  float loss_stddev{};
  float iterations_per_sec{};
  float samples_per_sec{};
};

using BenchmarkView = BenchmarkRecord;

std::uint32_t api_version();
std::string error_message(int code);
std::size_t benchmark_encoded_size(const BenchmarkRecord& record);
std::vector<std::uint8_t> encode_benchmark_blob(const BenchmarkRecord& record);
BenchmarkView decode_benchmark_blob(const std::vector<std::uint8_t>& blob);

} // namespace rnn