Skip to content
Snippets Groups Projects
ContextModule.hpp 818 B
#ifndef CONTEXTMODULE__H
#define CONTEXTMODULE__H

#include <torch/torch.h>
#include "Submodule.hpp"
#include "MyModule.hpp"
#include "GRU.hpp"
#include "LSTM.hpp"

class ContextModuleImpl : public Submodule
{
  private :

  torch::nn::Embedding wordEmbeddings{nullptr};
  std::shared_ptr<MyModule> myModule{nullptr};
  std::vector<std::string> columns;
  std::vector<int> bufferContext;
  std::vector<int> stackContext;
  int inSize;

  public :

  ContextModuleImpl(std::string name, const std::string & definition);
  torch::Tensor forward(torch::Tensor input);
  std::size_t getOutputSize() override;
  std::size_t getInputSize() override;
  void addToContext(std::vector<std::vector<long>> & context, const Config & config) override;
  void registerEmbeddings() override;
};
TORCH_MODULE(ContextModule);

#endif