Skip to content

CXX Interface

Devin Matthews edited this page Nov 14, 2016 · 15 revisions

Overview

The TBLIS [C interface](C Interface) is complicated by requiring explicit user specification and management of tensor layouts, generic typing, etc. The C++ interface is designed to streamline this process by providing convenient tensor, matrix, and vector container and view objects. TBLIS containers behave similarly to STL containers in that they own the tensor/matrix/vector data and handle allocation and deallocation based on the container lifetime. Views offer a similar interface for accessing the underlying data, but do not imply ownership and are relatively lightweight. View come in two flavors: const_views that do not allow modification of the underlying data (but can be shifted, resized, etc.), and non-const views, that do allow modification. Container and view objects are templated over the underlying data type.

Tensor, Matrix, and Vector Objects

Object Type Tensor Matrix Vector
container tensor<T, Allocator=...> matrix<T, Allocator=...> row<T, Allocator=...>
const view const_tensor_view<T> const_matrix_view<T> const_row_view<T>
non-const view tensor_view<T> matrix_view<T> row_view<T>

C++ Interface for Tensor Operations

The six basic [tensor operations](Tensor Operations) (and their matrix and vector counterparts) are accessible via:

Operation Interface
add
template 
void add(T alpha, const_row_view A, T beta, row_view B);
template 
void add(single_t s,
T alpha, const_row_view A, T beta, row_view B);
template 
void add(const communicator& comm,
T alpha, const_row_view A, T beta, row_view B);
template 
void add(T alpha, const_matrix_view A, T beta, matrix_view B);
template 
void add(single_t s,
T alpha, const_matrix_view A, T beta, matrix_view B);
template 
void add(const communicator& comm,
T alpha, const_matrix_view A, T beta, matrix_view B);
template 
void add(T alpha, const_tensor_view A, const label_type* idx_A,
T  beta,       tensor_view B, const label_type* idx_B);
template 
void add(single_t s,
T alpha, const_tensor_view A, const label_type* idx_A,
T  beta,       tensor_view B, const label_type* idx_B);
template 
void add(const communicator& comm,
T alpha, const_tensor_view A, const label_type* idx_A,
T  beta,       tensor_view B, const label_type* idx_B);
dot
template 
void dot(const_row_view A, const_row_view B, T& result);
template 
void dot(single_t s,
const_row_view A, const_row_view B, T& result);
template 
void dot(const communicator& comm,
const_row_view A, const_row_view B, T& result);
template 
T dot(const_row_view A, const_row_view B);
template 
T dot(single_t s,
const_row_view A, const_row_view B);
template 
T dot(const communicator& comm,
const_row_view A, const_row_view B);
template 
void dot(const_matrix_view A, const_matrix_view B, T& result);
template 
void dot(single_t s,
const_matrix_view A, const_matrix_view B, T& result);
template 
void dot(const communicator& comm,
const_matrix_view A, const_matrix_view B, T& result);
template 
T dot(const_matrix_view A, const_matrix_view B);
template 
T dot(single_t s,
const_matrix_view A, const_matrix_view B);
template 
T dot(const communicator& comm,
const_matrix_view A, const_matrix_view B);
template 
void dot(const_tensor_view A, const label_type* idx_A,
const_tensor_view B, const label_type* idx_B, T& result);
template 
void dot(single_t s,
const_tensor_view A, const label_type* idx_A,
const_tensor_view B, const label_type* idx_B, T& result);
template 
void dot(const communicator& comm,
const_tensor_view A, const label_type* idx_A,
const_tensor_view B, const label_type* idx_B, T& result);
template 
T dot(const_tensor_view A, const label_type* idx_A,
const_tensor_view B, const label_type* idx_B);
template 
T dot(single_t s,
const_tensor_view A, const label_type* idx_A,
const_tensor_view B, const label_type* idx_B);
template 
T dot(const communicator& comm,
const_tensor_view A, const label_type* idx_A,
const_tensor_view B, const label_type* idx_B);
reduce
template 
void reduce(reduce_t op, const_row_view A, T& result, len_type& idx);
template 
void reduce(single_t s,
reduce_t op, const_row_view A, T& result, len_type& idx);
template 
void reduce(const communicator& comm,
reduce_t op, const_row_view A, T& result, len_type& idx);
template 
std::pair<T,len_type> reduce(reduce_t op, const_row_view A);
template 
std::pair<T,len_type> reduce(single_t s,
reduce_t op, const_row_view A);
template 
std::pair<T,len_type> reduce(const communicator& comm,
reduce_t op, const_row_view A);
template 
void reduce(reduce_t op, const_matrix_view A, T& result, len_type& idx);
template 
void reduce(single_t s,
reduce_t op, const_matrix_view A, T& result, len_type& idx)
template 
void reduce(const communicator& comm,
reduce_t op, const_matrix_view A, T& result, len_type& idx);
template 
std::pair<T,len_type> reduce(reduce_t op, const_matrix_view A);
template 
std::pair<T,len_type> reduce(single_t s,
reduce_t op, const_matrix_view A);
template 
std::pair<T,len_type> reduce(const communicator& comm,
reduce_t op, const_matrix_view A);
template 
void reduce(reduce_t op, const_tensor_view A, const label_type* idx_A,
T& result, len_type& idx);
template 
void reduce(single_t s, reduce_t op,
const_tensor_view A, const label_type* idx_A,
T& result, len_type& idx);
template 
void reduce(const communicator& comm, reduce_t op,
const_tensor_view A, const label_type* idx_A,
T& result, len_type& idx);
template 
std::pair<T,len_type> reduce(reduce_t op,
const_tensor_view A, const label_type* idx_A);
template 
std::pair<T,len_type> reduce(single_t s, reduce_t op,
const_tensor_view A, const label_type* idx_A);
template 
std::pair<T,len_type> reduce(const communicator& comm, reduce_t op,
const_tensor_view A, const label_type* idx_A);
scale
template 
void scale(T alpha, row_view A);
template 
void scale(single_t s, T alpha, row_view A);
template 
void scale(const communicator& comm, T alpha, row_view A);
template 
void scale(T alpha, matrix_view A);
template 
void scale(single_t s, T alpha, matrix_view A);
template 
void scale(const communicator& comm, T alpha, matrix_view A);
template 
void scale(T alpha, tensor_view A, const label_type* idx_A);
template 
void scale(single_t s,
T alpha, tensor_view A, const label_type* idx_A);
template 
void scale(const communicator& comm,
T alpha, tensor_view A, const label_type* idx_A);
set
template 
void set(T alpha, row_view A);
template 
void set(single_t s, T alpha, row_view A);
template 
void set(const communicator& comm, T alpha, row_view A);
template 
void set(T alpha, matrix_view A);
template 
void set(single_t s, T alpha, matrix_view A);
template 
void set(const communicator& comm, T alpha, matrix_view A);
template 
void set(T alpha, tensor_view A, const label_type* idx_A);
template 
void set(single_t s,
T alpha, tensor_view A, const label_type* idx_A);
template 
void set(const communicator& comm,
T alpha, tensor_view A, const label_type* idx_A);
mult
template 
void mult(T alpha, const_matrix_view A, const_matrix_view B,
          T beta, matrix_view C);
template 
void mult(single_t s,
T alpha, const_matrix_view A, const_matrix_view B,
T beta, matrix_view C);
template 
void mult(const communicator& comm,
T alpha, const_matrix_view A, const_matrix_view B,
T beta, matrix_view C);
template 
void mult(T alpha, const_tensor_view A, const label_type* idx_A,
const_tensor_view B, const label_type* idx_B,
T  beta,       tensor_view C, const label_type* idx_C);
template 
void mult(single_t s,
T alpha, const_tensor_view A, const label_type* idx_A,
const_tensor_view B, const label_type* idx_B,
T  beta,       tensor_view C, const label_type* idx_C);
template 
void mult(const communicator& comm,
T alpha, const_tensor_view A, const label_type* idx_A,
const_tensor_view B, const label_type* idx_B,
T  beta,       tensor_view C, const label_type* idx_C);

Containers and Views

Examples

Clone this wiki locally