.. _program_listing_file_src_microsoft_quicksand.h: Program Listing for File quicksand.h ==================================== |exhale_lsh| :ref:`Return to documentation for file ` (``src/microsoft/quicksand.h``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #pragma once #include #include #include #include #include #include namespace marian { template using Ptr = std::shared_ptr; class Options; namespace quicksand { typedef uint32_t IndexType; typedef IndexType WordIndex; typedef std::vector WordIndices; typedef std::vector QSBatch; typedef std::vector>> AlignmentSets; // [trgPos] -> set of (srcPos, P(srcPos|trgPos)) typedef std::tuple QSSentenceWithProb; typedef std::vector QSNBest; typedef std::vector QSNBestBatch; enum class DecoderCpuAvxVersion { AVX, AVX2, AVX512 }; Ptr newOptions(); template void set(Ptr options, const std::string& key, const T& value); class IVocabWrapper { public: virtual WordIndex encode(const std::string& word) const = 0; virtual std::string decode(WordIndex id) const = 0; virtual size_t size() const = 0; virtual void transcodeToShortlistInPlace(WordIndex* ptr, size_t num) const = 0; }; class IBeamSearchDecoder { protected: Ptr options_; std::vector ptrs_; public: IBeamSearchDecoder(Ptr options, const std::vector& ptrs) : options_(options), ptrs_(ptrs) {} virtual ~IBeamSearchDecoder() {} virtual QSNBestBatch decode(const QSBatch& qsBatch, size_t maxLength, const std::unordered_set& shortlist) = 0; virtual void setWorkspace(uint8_t* data, size_t size) = 0; }; Ptr newDecoder(Ptr options, const std::vector& ptrs, const std::vector>& vocabs, WordIndex eos/*dummy --@TODO: remove*/); // load src and tgt vocabs std::vector> loadVocabs(const std::vector& vocabPaths); // query CPU AVX version DecoderCpuAvxVersion getCpuAvxVersion(); DecoderCpuAvxVersion parseCpuAvxVersion(std::string name); // MJD: added "addLsh" which will now break whatever compilation after update. That's on purpose. // The calling code should be adapted, not this interface. If you need to fix things in QS because of this // talk to me first! bool convertModel(std::string inputFile, std::string outputFile, int32_t targetPrec, int32_t lshNBits); } // namespace quicksand } // namespace marian