Skip to content

2024-10-10: Proposal: Extend PMT Support for Tensor<T> #1

@RalphSteinhagen

Description

@RalphSteinhagen

Background

The current PMT (Polymorphic Type) property_map in GNU Radio 4 supports 31 types, including base types, vectors of base types, and recursive maps:

using property_map = std::map<std::string, rva::variant< // recursive/nested
    std::monostate, 
    // 15 base types
    bool, unsigned char, unsigned short, unsigned int, unsigned long,
    signed char, short, int, long, float, double,
    std::complex<float>, std::complex<double>, std::string,
    // 15 std::vector of base types and a self-reference
    std::vector<bool>, std::vector<unsigned char>, std::vector<unsigned short>,
    std::vector<unsigned int>, std::vector<unsigned long>, std::vector<signed char>,
    std::vector<short>, std::vector<int>, std::vector<long>, std::vector<float>,
    std::vector<double>, std::vector<std::complex<float>>,
    std::vector<std::complex<double>>, std::vector<std::string>,
    std::vector<rva::self_t>,
    // std::map as a recursive self-reference
    std::map<std::string, rva::self_t>
>>;

PMTs are primarily used in the GNU Radio 4 core for Tags and inter-domain exchange of settings, notably between C/C++ and Python. Limiting the number of canonical types transferred between domains simplifies the API for language bindings and UI integrations and reduces the need for extensive type checking and guarding against corner cases.

However, some blocks require more complex settings types, such as matrices and higher-dimensional data structures, which cannot currently be expressed using PMTs.

Proposal

Introduce a new Tensor<T> storage type in PMT to generalize vectors, matrices, and higher-dimensional data structures. A prototype implementation is available for reference: Godbolt Compiler Explorer.

Open Questions

  1. Pre-condition: Evaluate whether using std::any in PMT reduces compile-time overhead. @jsallay has offered to investigate this.

  2. Implementation Choice: Should we use the provided Tensor<T> implementation or adopt an external library that offers a standard data format in machine learning and linear algebra contexts?

  3. Integration with Existing Types: Should Tensor<T> replace std::vector<T> in PMT, or should both be maintained in parallel?

    • Note: Tensor<T> can be cast to std::vector<T> in language bindings when only 1D data is required.
    • Maintaining both would increase the number of supported types from 31 to 46.
  4. Supported Base Types: Should Tensor<T> support all base types currently in PMT, or only a subset such as float, double, and std::string?

    • Additionally, should complex types like std::complex<float> and std::complex<double> be included?

Next Steps: This proposal aims to enhance PMT's capability to handle more complex data structures required by certain blocks. Input and discussions on the open questions are welcome to refine the approach and implementation details.

Metadata

Metadata

Assignees

No one assigned

    Labels

    GR4 DesignGR 4 Architecture and Interface Design

    Type

    No type

    Projects

    Status

    Scheduled

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions