Namespace faiss::nn

namespace nn

Typedefs

using Tensor2D = Tensor2DTemplate<float>
using Int32Tensor2D = Tensor2DTemplate<int32_t>
template<typename T>
struct Tensor2DTemplate

Public Functions

Tensor2DTemplate(size_t n0, size_t n1, const T *data = nullptr)
Tensor2DTemplate &operator+=(const Tensor2DTemplate&)
Tensor2DTemplate column(size_t j) const

get column #j as a 1-column Tensor2D

inline size_t numel() const
inline T *data()
inline const T *data() const

Public Members

size_t shape[2]
std::vector<T> v
struct Linear
#include <NeuralNet.h>

minimal translation of nn.Linear

Public Functions

Linear(size_t in_features, size_t out_features, bool bias = true)
Tensor2D operator()(const Tensor2D &x) const

Public Members

size_t in_features
size_t out_features
std::vector<float> weight
std::vector<float> bias
struct Embedding
#include <NeuralNet.h>

minimal translation of nn.Embedding

Public Functions

Embedding(size_t num_embeddings, size_t embedding_dim)
Tensor2D operator()(const Int32Tensor2D&) const
inline float *data()
inline const float *data() const

Public Members

size_t num_embeddings
size_t embedding_dim
std::vector<float> weight
struct FFN
#include <NeuralNet.h>

Feed forward layer that expands to a hidden dimension, applies a ReLU non linearity and maps back to the orignal dimension

Public Functions

inline FFN(int d, int h)
Tensor2D operator()(const Tensor2D &x) const

Public Members

Linear linear1
Linear linear2