Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
RalphSteinhagen opened this issue Oct 31, 2024 · 0 comments
Open

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

RalphSteinhagen opened this issue Oct 31, 2024 · 0 comments
Labels
GR4 Design GR 4 Architecture and Interface Design

Comments

@RalphSteinhagen
Copy link
Collaborator

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.

@RalphSteinhagen RalphSteinhagen added the GR4 Design GR 4 Architecture and Interface Design label Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GR4 Design GR 4 Architecture and Interface Design
Projects
Development

No branches or pull requests

1 participant