Constant¶
Constant // Literal constant tensor
Description¶
The output is a tensor initialized from the values
attribute.
Attributes¶
Name | Type | Notes |
---|---|---|
type |
ngraph::element::type |
The element type of the value in the computation |
shape |
ngraph::Shape |
The shape of the constant |
values |
const std::vector<T>& |
Constant elements in row-major order. T must be compatible with the element type |
Outputs¶
Name | Element Type | Shape |
---|---|---|
output |
type |
shape |
C++ Interface¶
-
class
Constant
: public ngraph::Node¶ Class for constants.
Subclassed by ngraph::op::ScalarConstantLikeBase
Public Functions
-
template <typename T>
Constant
(const element::Type &type, Shape shape, const std::vector<T> &values)¶ Constructs a tensor constant.
- Parameters
type
: The element type of the tensor constant.shape
: The shape of the tensor constant.values
: A vector of literals for initializing the tensor constant. The size of values must match the size of the shape.
-
Constant
(const element::Type &type, Shape shape, const std::vector<std::string> &values)¶ Constructs a tensor constant This constructor is mainly to support deserialization of constants.
- Parameters
type
: The element type of the tensor constant.shape
: The shape of the tensor constant.values
: A list of string values to use as the constant data.
-
Constant
(const element::Type &type, const Shape &shape, const void *data)¶ Constructs a tensor constant with the same initialization value copied across.
- Parameters
type
: The element type of the tensor constant.shape
: The shape of the tensor constant.data
: A void* to constant data.
-
void
validate_and_infer_types
()¶ Throws if the node is invalid.
-
vector<string>
get_value_strings
() const¶ - Return
- The initialization literals for the tensor constant.
Public Static Functions
-
template <typename T>
static std::shared_ptr<op::Constant>create
(const element::Type &type, Shape shape, const std::vector<T> values)¶ Wrapper around constructing a shared_ptr of a Constant.
- Parameters
type
: The element type of the tensor constant.shape
: The shape of the tensor constant.values
: A vector of values to use as the constant data.
-
template <typename T>
static std::shared_ptr<op::Constant>create
(const element::Type &type, Shape shape, std::initializer_list<T> values)¶ Wrapper around constructing a shared_ptr of a Constant.
- Parameters
type
: The element type of the tensor constant.shape
: The shape of the tensor constant.values
: An initializer_list of values to use as the constant data.
-
template <typename T>