Skip to content

Composing expressions (of unary functions in particular) #18

@oir

Description

@oir
  • Should I prefer free functions (current) or member functions, or both (or a mixture of both for different subsets)? For instance, Eigen uses a.cwiseProd(b) instead of CwiseProd(a, b), similarly PyTorch.
  • If member functions, is it a member function of Ptr<Node> or Node?

Some examples for all three:

NodePtr<> a, b;
auto c = CwiseProd(a, b);
auto c = a.cwise_prod(b);
auto c = a->cwise_prod(b);
NodePtr<> a;
auto b = Exp(Sum(Log(a), /*axis*/ 1));
auto b = a.log().sum(/*axis*/ 1).exp();
auto b = a->log()->sum(/*axis*/ 1)->exp();

Considering that we want expressions to be extensible by user, we can only use a library supporting fixed subset as possible member functions which is a drawback.

Due to some early discussions, leaning towards the third option (chaining by -> with pointer semantics, no changes to Ptr).

Another consideration here is that since this is going to be part of the core interface (either Ptr or Node), these core types will need to know about some derived node types which can lead to wonky forward declarations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Design question

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions