Skip to content

tenzr::UFuncRegistry

Process-wide registry of named ufuncs, including the standard built-ins.

#include <ufunc.h>

Public Functions

Name
UFuncRegistry & Instance()
The process-wide singleton registry.
void RegisterUfunc(std::shared_ptr< UFunc > ufunc)
Register (or replace) ufunc by name.
std::shared_ptr< UFunc > Find(const std::string & name) const
Find the ufunc named name, or nullptr when absent.
bool Has(const std::string & name) const
Whether a ufunc named name is registered.
Tensor Add(const Tensor & a, const Tensor & b)
Tensor Subtract(const Tensor & a, const Tensor & b)
Tensor Multiply(const Tensor & a, const Tensor & b)
Tensor Divide(const Tensor & a, const Tensor & b)
Tensor Negative(const Tensor & a)
Tensor Absolute(const Tensor & a)
Tensor Exponential(const Tensor & a)
Tensor Logarithm(const Tensor & a)
Tensor SquareRoot(const Tensor & a)
Tensor Sin(const Tensor & a)
Tensor Cos(const Tensor & a)
Tensor tanh(const Tensor & a)
Tensor sigmoid(const Tensor & a)

Public Functions Documentation

function Instance

static UFuncRegistry & Instance()

The process-wide singleton registry.

Return: Reference to the singleton UFuncRegistry.

Get the process-wide ufunc registry.

function RegisterUfunc

void RegisterUfunc(
    std::shared_ptr< UFunc > ufunc
)

Register (or replace) ufunc by name.

Parameters:

  • ufunc Ufunc to register; must not be null.

Add or replace a ufunc, keyed by its name.

function Find

std::shared_ptr< UFunc > Find(
    const std::string & name
) const

Find the ufunc named name, or nullptr when absent.

Parameters:

  • name Ufunc name.

Return: The ufunc, or nullptr when absent.

Look up a ufunc by name.

function Has

bool Has(
    const std::string & name
) const

Whether a ufunc named name is registered.

Parameters:

  • name Ufunc name.

Return: true when present.

Test whether a ufunc is registered.

function Add

Tensor Add(
    const Tensor & a,
    const Tensor & b
)

Parameters:

  • a Left operand.
  • b Right operand.

Return: a + b.

Elementwise addition.

function Subtract

Tensor Subtract(
    const Tensor & a,
    const Tensor & b
)

Parameters:

  • a Left operand.
  • b Right operand.

Return: a - b.

Elementwise subtraction.

function Multiply

Tensor Multiply(
    const Tensor & a,
    const Tensor & b
)

Parameters:

  • a Left operand.
  • b Right operand.

Return: a * b.

Elementwise multiplication.

function Divide

Tensor Divide(
    const Tensor & a,
    const Tensor & b
)

Parameters:

  • a Left operand.
  • b Right operand.

Return: a / b.

Elementwise division.

function Negative

Tensor Negative(
    const Tensor & a
)

Parameters:

  • a Input tensor.

Return: -a.

Elementwise negation.

function Absolute

Tensor Absolute(
    const Tensor & a
)

Parameters:

  • a Input tensor.

Return: |a|.

Elementwise absolute value.

function Exponential

Tensor Exponential(
    const Tensor & a
)

Parameters:

  • a Input tensor.

Return: exp(a).

Elementwise exponential.

function Logarithm

Tensor Logarithm(
    const Tensor & a
)

Parameters:

  • a Input tensor.

Return: log(a).

Elementwise natural logarithm.

function SquareRoot

Tensor SquareRoot(
    const Tensor & a
)

Parameters:

  • a Input tensor.

Return: sqrt(a).

Elementwise square root.

function Sin

Tensor Sin(
    const Tensor & a
)

Parameters:

  • a Input tensor.

Return: sin(a).

Elementwise sine.

function Cos

Tensor Cos(
    const Tensor & a
)

Parameters:

  • a Input tensor.

Return: cos(a).

Elementwise cosine.

function tanh

Tensor tanh(
    const Tensor & a
)

Parameters:

  • a Input tensor.

Return: tanh(a).

Elementwise hyperbolic tangent.

function sigmoid

Tensor sigmoid(
    const Tensor & a
)

Parameters:

  • a Input tensor.

Return: sigmoid(a).

Elementwise logistic sigmoid.