Skip to content

sgprocessing/tensor_interpreter.hpp

Converts raw SGProcessingManager output bytes to text. More...

Namespaces

Name
sgns
sgns::neoswarm
sgns::neoswarm::core

Classes

Name
class sgns::neoswarm::core::TensorInterpreter
Converts raw MNN tensor output bytes to a human-readable string.

Detailed Description

Converts raw SGProcessingManager output bytes to text.

Date: 2026-05-06

Source code

#ifndef NEOSWARM_CORE_SGPROCESSING_TENSORINTERPRETER_HPP
#define NEOSWARM_CORE_SGPROCESSING_TENSORINTERPRETER_HPP

#include "common/error.hpp"
#include "core/tokenizer/tokenizer.hpp"
#include <cstdint>
#include <memory>
#include <string>
#include <vector>

namespace sgns
{
    enum class InputFormat : int;
} // namespace sgns

namespace sgns::neoswarm::core
{
    class TensorInterpreter
    {
        public:
        TensorInterpreter() = default;
        ~TensorInterpreter() = default;

        void SetTokenizer( std::shared_ptr<Tokenizer> tok );

        outcome::result<std::string> Interpret( const std::vector<uint8_t>& bytes, sgns::InputFormat format ) const;

        private:
        std::shared_ptr<Tokenizer> m_tokenizer;

        outcome::result<std::string> InterpretFloat32( const std::vector<uint8_t>& bytes ) const;
        outcome::result<std::string> InterpretFloat16( const std::vector<uint8_t>& bytes ) const;
        outcome::result<std::string> InterpretInt32( const std::vector<uint8_t>& bytes ) const;
        outcome::result<std::string> InterpretInt8( const std::vector<uint8_t>& bytes ) const;
        outcome::result<std::string> DecodeLogits( const std::vector<float>& logits ) const;
    };

} // namespace sgns::neoswarm::core

#endif // NEOSWARM_CORE_SGPROCESSING_TENSORINTERPRETER_HPP

Updated on 2026-07-25 at 22:56:57 +0000