Skip to content

tenzr::UFunc

More...

#include <ufunc.h>

Public Types

Name
using std::function< Tensor(const Tensor &, const Tensor &)> BinaryFn
using std::function< Tensor(const Tensor &)> UnaryFn

Public Functions

Name
UFunc(std::string name, UFuncOp op, BinaryFn binary_impl)
UFunc(std::string name, UFuncOp op, UnaryFn unary_impl)
const std::string & Name() const
The ufunc's registered name.
UFuncOp Op() const
The built-in op this ufunc maps to.
bool IsBinary() const
Whether the ufunc takes two operands.
Tensor operator()(const Tensor & a, const Tensor & b) const
Tensor operator()(const Tensor & a) const

Detailed Description

class tenzr::UFunc;

Named elementwise operation with either a unary or a binary implementation over arrays.

Public Types Documentation

using BinaryFn

using tenzr::UFunc::BinaryFn =  std::function<Tensor(const Tensor&, const Tensor&)>;

using UnaryFn

using tenzr::UFunc::UnaryFn =  std::function<Tensor(const Tensor&)>;

Public Functions Documentation

function UFunc

UFunc(
    std::string name,
    UFuncOp op,
    BinaryFn binary_impl
)

Parameters:

  • name Ufunc name.
  • op Ufunc kind tag.
  • binary_impl Two-argument implementation.

Construct a binary ufunc.

function UFunc

UFunc(
    std::string name,
    UFuncOp op,
    UnaryFn unary_impl
)

Parameters:

  • name Ufunc name.
  • op Ufunc kind tag.
  • unary_impl One-argument implementation.

Construct a unary ufunc.

function Name

inline const std::string & Name() const

The ufunc's registered name.

function Op

inline UFuncOp Op() const

The built-in op this ufunc maps to.

function IsBinary

inline bool IsBinary() const

Whether the ufunc takes two operands.

function operator()

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

function operator()

Tensor operator()(
    const Tensor & a
) const