Link Search Menu Expand Document

SparseMatMul


tensorflow C++ API

tensorflow::ops::SparseMatMul

Multiply matrix “a” by matrix “b”.


Summary

The inputs must be two-dimensional matrices and the inner dimension of “a” must match the outer dimension of “b”. This op is optimized for the case where at least one of “a” or “b” is sparse. The breakeven for using this versus a dense matrix multiply on one platform was 30% zero values in the sparse matrix.

The gradient computation of this operation will only take advantage of sparsity in the input gradient when that gradient comes from a Relu.

Arguments:

  • scope: A Scope object
  • a : float or bfloat16
  • b : float or bfloat16

Returns:

Constructor

  • SparseMatMul(const ::tensorflow::Scope & scope, ::tensorflow::Input a, ::tensorflow::Input b, const MatMul::Attrs & attrs)

Public attributes

  • tensorflow::Output product

SparseMatMul block

Source link : https://github.com/EXPNUNI/enuSpaceTensorflow/blob/master/enuSpaceTensorflow/tf_math.cpp

Argument:

  • Scope scope : A Scope object(A scope is generated automatically each page. A scope is not connected.).
  • Input a : connect Input node.
  • Input b : connect Input node.
  • SparseMatMul::Attrs attrs : Input attrs in value. ex) transpose_a_ = false;transpose_b_ = false;a_is_sparse_ = false;b_is_sparse_ = false;

Return:

  • Output product : Output object of SparseMatMul class object.

Result:

  • std::vector(Tensor) product_result : Returned object of executed result by calling session.

Using Method