My Project
Public Types | Public Member Functions | Static Public Member Functions | List of all members
mlir::SparseElementsAttr Class Reference

#include <Attributes.h>

Inheritance diagram for mlir::SparseElementsAttr:
Inheritance graph
[legend]
Collaboration diagram for mlir::SparseElementsAttr:
Collaboration graph
[legend]

Public Types

template<typename T >
using iterator = llvm::mapped_iterator< llvm::detail::value_sequence_iterator< ptrdiff_t >, std::function< T(ptrdiff_t)> >
 
- Public Types inherited from mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT >
using Base = StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT >
 Utility declarations for the concrete attribute class. More...
 
using ImplType = StorageT
 

Public Member Functions

DenseIntElementsAttr getIndices () const
 
DenseElementsAttr getValues () const
 
template<typename T >
llvm::iterator_range< iterator< T > > getValues () const
 
Attribute getValue (ArrayRef< uint64_t > index) const
 Return the value of the element at the given index. More...
 

Static Public Member Functions

static SparseElementsAttr get (ShapedType type, DenseElementsAttr indices, DenseElementsAttr values)
 'type' must be a vector or tensor with static shape. More...
 
static bool kindof (unsigned kind)
 Method for support type inquiry through isa, cast and dyn_cast. More...
 
- Static Public Member Functions inherited from mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT >
static ClassIDgetClassID ()
 Return a unique identifier for the concrete type. More...
 
template<typename T >
static bool classof (T val)
 

Additional Inherited Members

- Protected Member Functions inherited from mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT >
ImplTypegetImpl () const
 Utility for easy access to the storage instance. More...
 
- Static Protected Member Functions inherited from mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT >
template<typename... Args>
static ConcreteT get (MLIRContext *ctx, unsigned kind, Args... args)
 
template<typename... Args>
static ConcreteT getChecked (const Location &loc, MLIRContext *ctx, unsigned kind, Args... args)
 
template<typename... Args>
static LogicalResult verifyConstructionInvariants (Args... args)
 Default implementation that just returns success. More...
 

Detailed Description

An attribute that represents a reference to a sparse vector or tensor object.

This class uses COO (coordinate list) encoding to represent the sparse elements in an element attribute. Specifically, the sparse vector/tensor stores the indices and values as two separate dense elements attributes of tensor type (even if the sparse attribute is of vector type, in order to support empty lists). The dense elements attribute indices is a 2-D tensor of 64-bit integer elements with shape [N, ndims], which specifies the indices of the elements in the sparse tensor that contains nonzero values. The dense elements attribute values is a 1-D tensor with shape [N], and it supplies the corresponding values for the indices.

For example, sparse<tensor<3x4xi32>, [[0, 0], [1, 2]], [1, 5]> represents tensor [[1, 0, 0, 0], [0, 0, 5, 0], [0, 0, 0, 0]].

Member Typedef Documentation

◆ iterator

template<typename T >
using mlir::SparseElementsAttr::iterator = llvm::mapped_iterator<llvm::detail::value_sequence_iterator<ptrdiff_t>, std::function<T(ptrdiff_t)> >

Member Function Documentation

◆ get()

SparseElementsAttr SparseElementsAttr::get ( ShapedType  type,
DenseElementsAttr  indices,
DenseElementsAttr  values 
)
static

'type' must be a vector or tensor with static shape.

◆ getIndices()

DenseIntElementsAttr SparseElementsAttr::getIndices ( ) const

◆ getValue()

Attribute SparseElementsAttr::getValue ( ArrayRef< uint64_t >  index) const

Return the value of the element at the given index.

Return the value of the element at the given index. The 'index' is expected to refer to a valid element.

◆ getValues() [1/2]

DenseElementsAttr SparseElementsAttr::getValues ( ) const

◆ getValues() [2/2]

template<typename T >
llvm::iterator_range<iterator<T> > mlir::SparseElementsAttr::getValues ( ) const
inline

Return the values of this attribute in the form of the given type 'T'. 'T' may be any of Attribute, APInt, APFloat, c++ integer/float types, etc.

◆ kindof()

static bool mlir::SparseElementsAttr::kindof ( unsigned  kind)
inlinestatic

Method for support type inquiry through isa, cast and dyn_cast.


The documentation for this class was generated from the following files: