PyTorch
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
c10::IValue Struct Referencefinal

IValue (Interpreter Value) is a tagged union over the types supported by the TorchScript interpreter. More...

#include <ivalue.h>

Classes

struct  CompAliasedIValues
 
struct  HashAliasedIValue
 

Public Types

template<class T >
using enable_if_ivalue_constructible = std::enable_if_t< std::is_constructible< IValue, T >::value, std::nullptr_t >
 
template<class T >
using enable_if_list_is_ivalue_constructible = std::enable_if_t< std::is_constructible< IValue, T >::value &&!std::is_same< T, c10::SymInt >::value, std::nullptr_t >
 
template<class T >
using enable_if_symint = std::enable_if_t< std::is_same< T, c10::SymInt >::value, std::nullptr_t >
 
template<class T >
using enable_if_ilist_is_ivalue_constructible = std::enable_if_t< std::is_constructible< IValue, T >::value &&std::is_constructible< IValue, typename IListRef< T >::boxed_type >::value &&!std::is_same< T, c10::SymInt >::value, std::nullptr_t >
 
using HashAliasedIValues = std::unordered_set< IValue, HashAliasedIValue, CompAliasedIValues >
 
using HashAliasedIValueMap = std::unordered_map< IValue, IValue, HashAliasedIValue, CompAliasedIValues >
 

Public Member Functions

 IValue (const IValue &rhs)
 
 IValue (IValue &&rhs) noexcept
 
IValueoperator= (IValue &&rhs) &noexcept
 
IValueoperator= (IValue const &rhs) &
 
void dump () const
 
IValue equals (const IValue &rhs) const
 Equality comparison. More...
 
bool is (const IValue &rhs) const
 Identity comparison. More...
 
IValue hash () const
 Hashing for IValues. More...
 
 IValue (at::TensorBase t)
 
bool isTensor () const
 
at::Tensor toTensor () &&
 
at::TensortoTensor () &
 
const at::TensortoTensor () const &
 
at::TensorImpl * unsafeToTensorImpl () const
 
 IValue (at::Storage s)
 
bool isStorage () const
 
c10::Storage toStorage () &&
 
c10::Storage toStorage () const &
 
const IValuetoIValue () const
 
IValuetoIValue ()
 
bool isCapsule () const
 
c10::intrusive_ptr< torch::CustomClassHoldertoCapsule () &&
 
c10::intrusive_ptr< torch::CustomClassHoldertoCapsule () const &
 
template<typename T , std::enable_if_t< std::is_base_of< torch::CustomClassHolder, T >::value, int > = 0>
 IValue (intrusive_ptr< T > custom_class)
 
bool isCustomClass () const
 
template<typename T >
c10::intrusive_ptr< T > toCustomClass () &&
 
template<typename T >
c10::intrusive_ptr< T > toCustomClass () const &
 
 IValue (c10::intrusive_ptr< ivalue::Tuple > v)
 
template<typename... Args, std::enable_if_t< !guts::disjunction< std::is_lvalue_reference< Args >..., guts::negation< std::is_constructible< IValue, Args > >... >::value, std::nullptr_t > = nullptr>
 IValue (const std::tuple< Args... > &t)
 
template<typename... Args, std::enable_if_t< !guts::disjunction< std::is_lvalue_reference< Args >..., guts::negation< std::is_constructible< IValue, Args > >... >::value, std::nullptr_t > = nullptr>
 IValue (std::tuple< Args... > &&t)
 
bool isTuple () const
 
c10::intrusive_ptr< ivalue::Tuple > toTuple () &&
 
c10::intrusive_ptr< ivalue::Tuple > toTuple () const &
 
ivalue::Tuple & toTupleRef () const
 
 IValue (double d)
 
bool isDouble () const
 
double toDouble () const
 
template<typename T >
 IValue (c10::complex< T > c)
 
bool isComplexDouble () const
 
c10::complex< double > toComplexDouble () const
 
 IValue (c10::intrusive_ptr< ivalue::Future > v)
 
bool isFuture () const
 
c10::intrusive_ptr< ivalue::Future > toFuture () &&
 
c10::intrusive_ptr< ivalue::Future > toFuture () const &
 
 IValue (c10::intrusive_ptr< ivalue::Await > v)
 
bool isAwait () const
 
c10::intrusive_ptr< ivalue::Await > toAwait () &&
 
c10::intrusive_ptr< ivalue::Await > toAwait () const &
 
 IValue (c10::intrusive_ptr< c10::RRefInterface > v)
 
bool isRRef () const
 
c10::intrusive_ptr< c10::RRefInterface > toRRef () &&
 
c10::intrusive_ptr< c10::RRefInterface > toRRef () const &
 
 IValue (c10::intrusive_ptr< at::Quantizer > v)
 
bool isQuantizer () const
 
c10::intrusive_ptr< at::Quantizer > toQuantizer () &&
 
c10::intrusive_ptr< at::Quantizer > toQuantizer () const &
 
 IValue (int64_t i)
 
 IValue (c10::SymInt i)
 
bool isSymInt () const
 
c10::SymInt toSymInt () &&
 
c10::SymInt toSymInt () const &
 
 IValue (c10::SymFloat i)
 
bool isSymFloat () const
 
c10::SymFloat toSymFloat () &&
 
c10::SymFloat toSymFloat () const &
 
 IValue (int32_t i)
 
bool isInt () const
 
int64_t toInt () const
 
 IValue (bool b)
 
bool isBool () const
 
bool toBool () const
 
bool isIntList () const
 
c10::List< int64_t > toIntList () &&
 
c10::List< int64_t > toIntList () const &
 
std::vector< int64_t > toIntVector () const
 
at::DimVector toDimVector () const
 
 IValue (c10::intrusive_ptr< ivalue::ConstantString > v)
 
 IValue (std::string v)
 
 IValue (const char *v)
 
 IValue (c10::string_view v)
 
bool isString () const
 
c10::intrusive_ptr< ivalue::ConstantString > toString () &&
 
c10::intrusive_ptr< ivalue::ConstantString > toString () const &
 
const std::string & toStringRef () const
 
c10::optional< std::reference_wrapper< const std::string > > toOptionalStringRef () const
 
c10::string_view toStringView () const
 
bool isDoubleList () const
 
c10::List< double > toDoubleList () &&
 
c10::List< double > toDoubleList () const &
 
std::vector< double > toDoubleVector () const
 
bool isComplexDoubleList () const
 
c10::List< c10::complex< double > > toComplexDoubleList () &&
 
c10::List< c10::complex< double > > toComplexDoubleList () const &
 
std::vector< c10::complex< double > > toComplexDoubleVector () const
 
bool isBoolList () const
 
c10::List< bool > toBoolList () &&
 
c10::List< bool > toBoolList () const &
 
bool isTensorList () const
 
c10::List< at::TensortoTensorList () &&
 
c10::List< at::TensortoTensorList () const &
 
std::vector< at::TensortoTensorVector () const
 
bool isOptionalTensorList () const
 
c10::List< c10::optional< at::Tensor > > toOptionalTensorList () &&
 
c10::List< c10::optional< at::Tensor > > toOptionalTensorList () const &
 
std::vector< c10::optional< at::Tensor > > toOptionalTensorVector () const
 
 IValue (c10::List< IValue > v)
 
bool isList () const
 
c10::List< IValuetoList () &&
 
c10::List< IValuetoList () const &
 
c10::ArrayRef< IValuetoListRef () const
 
template<class T , enable_if_list_is_ivalue_constructible< T > = nullptr>
 IValue (c10::List< T > &&v)
 
template<class T , enable_if_list_is_ivalue_constructible< T > = nullptr>
 IValue (const c10::List< T > &v)
 
template<class T , enable_if_list_is_ivalue_constructible< T > = nullptr>
 IValue (at::ArrayRef< T > v)
 
template<class T , enable_if_list_is_ivalue_constructible< T > = nullptr>
 IValue (const std::vector< T > &v)
 
template<class T , size_t N>
 IValue (std::array< T, N > v)
 
template<class T , enable_if_symint< T > = nullptr>
 IValue (at::ArrayRef< T > v)
 
template<class T , enable_if_symint< T > = nullptr>
 IValue (at::OptionalArrayRef< T > v)
 
template<class T , enable_if_symint< T > = nullptr>
 IValue (const std::vector< T > &v)
 
template<class T , enable_if_ilist_is_ivalue_constructible< T > = nullptr>
 IValue (c10::IListRef< T > v)
 
 IValue (c10::Dict< IValue, IValue > v)
 
bool isGenericDict () const
 
c10::Dict< IValue, IValuetoGenericDict () &&
 
c10::Dict< IValue, IValuetoGenericDict () const &
 
template<class Key , class Value >
 IValue (c10::Dict< Key, Value > v)
 
template<class Key , class Value >
 IValue (std::unordered_map< Key, Value > v)
 
template<class T , enable_if_ivalue_constructible< T > = nullptr>
 IValue (c10::optional< T > v)
 
template<class T , enable_if_list_is_ivalue_constructible< T > = nullptr>
 IValue (c10::OptionalArrayRef< T > v)
 
 IValue (c10::nullopt_t)
 
 IValue (c10::intrusive_ptr< ivalue::Object > v)
 
bool isObject () const
 
c10::intrusive_ptr< ivalue::Object > toObject () &&
 
c10::intrusive_ptr< ivalue::Object > toObject () const &
 
ivalue::Object & toObjectRef () const
 
torch::jit::Module toModule () const
 
bool isModule () const
 
 IValue (c10::intrusive_ptr< ivalue::PyObjectHolder > v)
 
bool isPyObject () const
 
c10::intrusive_ptr< ivalue::PyObjectHolder > toPyObjectHolder () &&
 
c10::intrusive_ptr< ivalue::PyObjectHolder > toPyObjectHolder () const &
 
PyObject * toPyObject () const
 
 IValue (c10::intrusive_ptr< ivalue::EnumHolder > v)
 
bool isEnum () const
 
c10::intrusive_ptr< ivalue::EnumHolder > toEnumHolder () &&
 
c10::intrusive_ptr< ivalue::EnumHolder > toEnumHolder () const &
 
 IValue ()
 
bool isNone () const
 
std::string toNone () const
 
 IValue (const at::Scalar &s)
 
bool isScalar () const
 
at::Scalar toScalar () const
 
 IValue (c10::Device d)
 
bool isDevice () const
 
c10::Device toDevice () const
 
 IValue (c10::Stream s)
 
c10::Stream toStream () &&
 
c10::Stream toStream () const &
 
bool isStream () const
 
 IValue (ScalarType t)
 
at::ScalarType toScalarType () const
 
 IValue (Layout l)
 
at::Layout toLayout () const
 
 IValue (MemoryFormat m)
 
at::MemoryFormat toMemoryFormat () const
 
 IValue (at::QScheme qscheme)
 
at::QScheme toQScheme () const
 
 IValue (at::Dimname dimname)
 
at::Dimname toDimname () const
 
 IValue (at::Generator g)
 
bool isGenerator () const
 
at::Generator toGenerator () &&
 
at::Generator toGenerator () const &
 
std::string tagKind () const
 
template<typename T >
to () &&
 
template<typename T >
c10::detail::ivalue_to_const_ref_overload_return< T >::type to () const &
 
template<typename T >
optional< T > toOptional ()
 
template<typename T >
optional< T > toOptional () const
 
std::ostream & repr (std::ostream &stream, std::function< bool(std::ostream &, const IValue &v)> customFormatter) const
 
bool isPtrType () const
 
template<typename T = c10::PlatformType>
TypePtr type () const
 
bool overlaps (const IValue &rhs) const
 
void getSubValues (HashAliasedIValues &subValues) const
 
void visit (const std::function< bool(const IValue &)> &visitor) const
 
IValue deepcopy () const
 
IValue deepcopy (HashAliasedIValueMap &memo) const
 

Static Public Member Functions

static size_t hash (const IValue &iv)
 
static IValue make_capsule (intrusive_ptr< torch::CustomClassHolder > blob)
 
static IValue uninitialized ()
 

Friends

struct WeakIValue
 
bool operator== (const IValue &lhs, const IValue &rhs)
 This implements the same semantics as bool(lhs == rhs) in Python. More...
 
bool operator!= (const IValue &lhs, const IValue &rhs)
 
bool _fastEqualsForContainer (const IValue &lhs, const IValue &rhs)
 [doxygen private] [container equality] This is an equality implementation that assumes objects with the same identity equal themselves, for efficiency reasons. More...
 
std::ostream & operator<< (std::ostream &out, const IValue &v)
 

Detailed Description

IValue (Interpreter Value) is a tagged union over the types supported by the TorchScript interpreter.

IValues contain their values as an IValue::Payload, which holds primitive types (int64_t, bool, double, Device) and Tensor as values, and all other types as a c10::intrusive_ptr. In order to optimize performance of the destructor and related operations by making the Tensor and c10::intrusive_ptr paths generate the same code, we represent a null c10::intrusive_ptr as UndefinedTensorImpl::singleton(), not nullptr.

IValues are used as inputs to and outputs from the TorchScript interpreter. To retrieve the value contained within an IValue, use the .toX() methods, where X is the type you are trying to get. Note that neither the .toX() methods nor the templated .to<T> functions do any kind of casting, they only unwrap the contained value. For example:

embed:rst:leading-asterisk
*  .. code-block:: cpp
* 
*    // Make the IValue
*    torch::IValue my_ivalue(26);
*    std::cout << my_ivalue << "\n";
* 
*    // Unwrap the IValue
*    int64_t my_int = my_ivalue.toInt();
*    std::cout << my_int << "\n";
* 
*    // This will throw an error!
*    // `my_ivalue` is tagged as an int and cannot be used as another type
*    torch::Tensor my_tensor = my_ivalue.toTensor();
*  

Member Typedef Documentation

◆ enable_if_ilist_is_ivalue_constructible

template<class T >
using c10::IValue::enable_if_ilist_is_ivalue_constructible = std::enable_if_t< std::is_constructible<IValue, T>::value && std::is_constructible<IValue, typename IListRef<T>::boxed_type>::value && !std::is_same<T, c10::SymInt>::value, std::nullptr_t>

◆ enable_if_ivalue_constructible

template<class T >
using c10::IValue::enable_if_ivalue_constructible = std::enable_if_t<std::is_constructible<IValue, T>::value, std::nullptr_t>

◆ enable_if_list_is_ivalue_constructible

template<class T >
using c10::IValue::enable_if_list_is_ivalue_constructible = std::enable_if_t<std::is_constructible<IValue, T>::value && !std::is_same<T, c10::SymInt>::value, std::nullptr_t>

◆ enable_if_symint

template<class T >
using c10::IValue::enable_if_symint = std::enable_if_t<std::is_same<T, c10::SymInt>::value, std::nullptr_t>

◆ HashAliasedIValueMap

◆ HashAliasedIValues

Constructor & Destructor Documentation

◆ IValue() [1/52]

c10::IValue::IValue ( const IValue rhs)
inline

◆ IValue() [2/52]

c10::IValue::IValue ( IValue &&  rhs)
inlinenoexcept

◆ IValue() [3/52]

c10::IValue::IValue ( at::TensorBase  t)
inline

◆ IValue() [4/52]

c10::IValue::IValue ( at::Storage  s)
inline

◆ IValue() [5/52]

template<typename T , std::enable_if_t< std::is_base_of< torch::CustomClassHolder, T >::value, int > = 0>
c10::IValue::IValue ( intrusive_ptr< T >  custom_class)

◆ IValue() [6/52]

c10::IValue::IValue ( c10::intrusive_ptr< ivalue::Tuple >  v)

◆ IValue() [7/52]

template<typename... Args, std::enable_if_t< !guts::disjunction< std::is_lvalue_reference< Args >..., guts::negation< std::is_constructible< IValue, Args > >... >::value, std::nullptr_t > = nullptr>
c10::IValue::IValue ( const std::tuple< Args... > &  t)

◆ IValue() [8/52]

template<typename... Args, std::enable_if_t< !guts::disjunction< std::is_lvalue_reference< Args >..., guts::negation< std::is_constructible< IValue, Args > >... >::value, std::nullptr_t > = nullptr>
c10::IValue::IValue ( std::tuple< Args... > &&  t)

◆ IValue() [9/52]

c10::IValue::IValue ( double  d)
inline

◆ IValue() [10/52]

template<typename T >
c10::IValue::IValue ( c10::complex< T >  c)

◆ IValue() [11/52]

c10::IValue::IValue ( c10::intrusive_ptr< ivalue::Future >  v)

◆ IValue() [12/52]

c10::IValue::IValue ( c10::intrusive_ptr< ivalue::Await >  v)

◆ IValue() [13/52]

c10::IValue::IValue ( c10::intrusive_ptr< c10::RRefInterface >  v)

◆ IValue() [14/52]

c10::IValue::IValue ( c10::intrusive_ptr< at::Quantizer >  v)

◆ IValue() [15/52]

c10::IValue::IValue ( int64_t  i)
inline

◆ IValue() [16/52]

c10::IValue::IValue ( c10::SymInt  i)
inline

◆ IValue() [17/52]

c10::IValue::IValue ( c10::SymFloat  i)
inline

◆ IValue() [18/52]

c10::IValue::IValue ( int32_t  i)
inline

◆ IValue() [19/52]

c10::IValue::IValue ( bool  b)
inline

◆ IValue() [20/52]

c10::IValue::IValue ( c10::intrusive_ptr< ivalue::ConstantString >  v)

◆ IValue() [21/52]

c10::IValue::IValue ( std::string  v)

◆ IValue() [22/52]

c10::IValue::IValue ( const char *  v)
inline

◆ IValue() [23/52]

c10::IValue::IValue ( c10::string_view  v)
inline

◆ IValue() [24/52]

c10::IValue::IValue ( c10::List< IValue v)

◆ IValue() [25/52]

template<class T , enable_if_list_is_ivalue_constructible< T > = nullptr>
c10::IValue::IValue ( c10::List< T > &&  v)

◆ IValue() [26/52]

template<class T , enable_if_list_is_ivalue_constructible< T > = nullptr>
c10::IValue::IValue ( const c10::List< T > &  v)

◆ IValue() [27/52]

template<class T , enable_if_list_is_ivalue_constructible< T > = nullptr>
c10::IValue::IValue ( at::ArrayRef< T >  v)

◆ IValue() [28/52]

template<class T , enable_if_list_is_ivalue_constructible< T > = nullptr>
c10::IValue::IValue ( const std::vector< T > &  v)

◆ IValue() [29/52]

template<class T , size_t N>
c10::IValue::IValue ( std::array< T, N >  v)

◆ IValue() [30/52]

template<class T , enable_if_symint< T > = nullptr>
c10::IValue::IValue ( at::ArrayRef< T >  v)

◆ IValue() [31/52]

template<class T , enable_if_symint< T > = nullptr>
c10::IValue::IValue ( at::OptionalArrayRef< T >  v)

◆ IValue() [32/52]

template<class T , enable_if_symint< T > = nullptr>
c10::IValue::IValue ( const std::vector< T > &  v)

◆ IValue() [33/52]

template<class T , enable_if_ilist_is_ivalue_constructible< T > = nullptr>
c10::IValue::IValue ( c10::IListRef< T >  v)

◆ IValue() [34/52]

c10::IValue::IValue ( c10::Dict< IValue, IValue v)

◆ IValue() [35/52]

template<class Key , class Value >
c10::IValue::IValue ( c10::Dict< Key, Value >  v)

◆ IValue() [36/52]

template<class Key , class Value >
c10::IValue::IValue ( std::unordered_map< Key, Value >  v)

◆ IValue() [37/52]

template<class T , enable_if_ivalue_constructible< T > = nullptr>
c10::IValue::IValue ( c10::optional< T >  v)

◆ IValue() [38/52]

template<class T , enable_if_list_is_ivalue_constructible< T > = nullptr>
c10::IValue::IValue ( c10::OptionalArrayRef< T >  v)

◆ IValue() [39/52]

c10::IValue::IValue ( c10::nullopt_t  )

◆ IValue() [40/52]

c10::IValue::IValue ( c10::intrusive_ptr< ivalue::Object >  v)

◆ IValue() [41/52]

c10::IValue::IValue ( c10::intrusive_ptr< ivalue::PyObjectHolder >  v)

◆ IValue() [42/52]

c10::IValue::IValue ( c10::intrusive_ptr< ivalue::EnumHolder >  v)
explicit

◆ IValue() [43/52]

c10::IValue::IValue ( )
inline

◆ IValue() [44/52]

c10::IValue::IValue ( const at::Scalar &  s)
inline

◆ IValue() [45/52]

c10::IValue::IValue ( c10::Device  d)
inline

◆ IValue() [46/52]

c10::IValue::IValue ( c10::Stream  s)
inline

◆ IValue() [47/52]

c10::IValue::IValue ( ScalarType  t)
inline

◆ IValue() [48/52]

c10::IValue::IValue ( Layout  l)
inline

◆ IValue() [49/52]

c10::IValue::IValue ( MemoryFormat  m)
inline

◆ IValue() [50/52]

c10::IValue::IValue ( at::QScheme  qscheme)
inline

◆ IValue() [51/52]

c10::IValue::IValue ( at::Dimname  dimname)
inline

◆ IValue() [52/52]

c10::IValue::IValue ( at::Generator  g)
inline

Member Function Documentation

◆ deepcopy() [1/2]

IValue c10::IValue::deepcopy ( ) const

◆ deepcopy() [2/2]

IValue c10::IValue::deepcopy ( HashAliasedIValueMap memo) const

◆ dump()

void c10::IValue::dump ( ) const

◆ equals()

IValue c10::IValue::equals ( const IValue rhs) const

Equality comparison.

The semantics are the same as Python's ==:

  1. Numerical types are compared by value.
  2. Tensors compute element-wise equality, returning a BoolTensor (see: torch.eq())
  3. Strings are compared by value.
  4. Sequence types (list, tuple) are compared lexicographically by comparing their elements. Different sequence types never compare equal.
  5. Mappings (dict) must have equal (key, value) pairs.
  6. If not listed above, the default behavior for is to test identity equality (e.g. pointer equality).

Why does this return an IValue instead of a bool? Because in PyTorch, tensor1 == tensor2 returns a BoolTensor, not a bool.

NOTE: we (like Python) assume that identity equality implies value equality for efficiency. TODO: need to support customizing equality

◆ getSubValues()

void c10::IValue::getSubValues ( HashAliasedIValues subValues) const

◆ hash() [1/2]

IValue c10::IValue::hash ( ) const
inline

Hashing for IValues.

Returns an IValue-boxed int.

Some notes:

  • Like eager, Tensors are hashed by looking at the pointer. This is not strictly correct because two value-equal tensors with different tensor pointers will hash differently, but we choose to reproduce the eager semantics.
  • Hashing is not defined on all built-in IValue types (e.g. list and dict), following Python. Calling hash() on these types will throw.

◆ hash() [2/2]

static size_t c10::IValue::hash ( const IValue iv)
static

◆ is()

bool c10::IValue::is ( const IValue rhs) const

Identity comparison.

Checks if this is the same object as rhs. The semantics are the same as Python's is operator.

NOTE: Like in Python, this operation is poorly defined for primitive types like numbers and strings. Prefer to use == unless you really want to check identity equality.

◆ isAwait()

bool c10::IValue::isAwait ( ) const
inline

◆ isBool()

bool c10::IValue::isBool ( ) const
inline

◆ isBoolList()

bool c10::IValue::isBoolList ( ) const

◆ isCapsule()

bool c10::IValue::isCapsule ( ) const
inline

◆ isComplexDouble()

bool c10::IValue::isComplexDouble ( ) const
inline

◆ isComplexDoubleList()

bool c10::IValue::isComplexDoubleList ( ) const

◆ isCustomClass()

bool c10::IValue::isCustomClass ( ) const

◆ isDevice()

bool c10::IValue::isDevice ( ) const
inline

◆ isDouble()

bool c10::IValue::isDouble ( ) const
inline

◆ isDoubleList()

bool c10::IValue::isDoubleList ( ) const

◆ isEnum()

bool c10::IValue::isEnum ( ) const
inline

◆ isFuture()

bool c10::IValue::isFuture ( ) const
inline

◆ isGenerator()

bool c10::IValue::isGenerator ( ) const
inline

◆ isGenericDict()

bool c10::IValue::isGenericDict ( ) const
inline

◆ isInt()

bool c10::IValue::isInt ( ) const
inline

◆ isIntList()

bool c10::IValue::isIntList ( ) const

◆ isList()

bool c10::IValue::isList ( ) const
inline

◆ isModule()

bool c10::IValue::isModule ( ) const

◆ isNone()

bool c10::IValue::isNone ( ) const
inline

◆ isObject()

bool c10::IValue::isObject ( ) const
inline

◆ isOptionalTensorList()

bool c10::IValue::isOptionalTensorList ( ) const

◆ isPtrType()

bool c10::IValue::isPtrType ( ) const
inline

◆ isPyObject()

bool c10::IValue::isPyObject ( ) const
inline

◆ isQuantizer()

bool c10::IValue::isQuantizer ( ) const
inline

◆ isRRef()

bool c10::IValue::isRRef ( ) const
inline

◆ isScalar()

bool c10::IValue::isScalar ( ) const
inline

◆ isStorage()

bool c10::IValue::isStorage ( ) const
inline

◆ isStream()

bool c10::IValue::isStream ( ) const
inline

◆ isString()

bool c10::IValue::isString ( ) const
inline

◆ isSymFloat()

bool c10::IValue::isSymFloat ( ) const
inline

◆ isSymInt()

bool c10::IValue::isSymInt ( ) const
inline

◆ isTensor()

bool c10::IValue::isTensor ( ) const
inline

◆ isTensorList()

bool c10::IValue::isTensorList ( ) const

◆ isTuple()

bool c10::IValue::isTuple ( ) const
inline

◆ make_capsule()

static IValue c10::IValue::make_capsule ( intrusive_ptr< torch::CustomClassHolder blob)
inlinestatic

◆ operator=() [1/2]

IValue & c10::IValue::operator= ( IValue &&  rhs) &
inlinenoexcept

◆ operator=() [2/2]

IValue & c10::IValue::operator= ( IValue const &  rhs) &
inline

◆ overlaps()

bool c10::IValue::overlaps ( const IValue rhs) const

◆ repr()

std::ostream & c10::IValue::repr ( std::ostream &  stream,
std::function< bool(std::ostream &, const IValue &v)>  customFormatter 
) const

◆ tagKind()

std::string c10::IValue::tagKind ( ) const
inline

◆ to() [1/2]

template<typename T >
T c10::IValue::to ( ) &&

◆ to() [2/2]

template<typename T >
c10::detail::ivalue_to_const_ref_overload_return< T >::type c10::IValue::to ( ) const &

◆ toAwait() [1/2]

c10::intrusive_ptr< ivalue::Await > c10::IValue::toAwait ( ) &&

◆ toAwait() [2/2]

c10::intrusive_ptr< ivalue::Await > c10::IValue::toAwait ( ) const &

◆ toBool()

bool c10::IValue::toBool ( ) const
inline

◆ toBoolList() [1/2]

c10::List< bool > c10::IValue::toBoolList ( ) &&

◆ toBoolList() [2/2]

c10::List< bool > c10::IValue::toBoolList ( ) const &

◆ toCapsule() [1/2]

c10::intrusive_ptr< torch::CustomClassHolder > c10::IValue::toCapsule ( ) &&

◆ toCapsule() [2/2]

c10::intrusive_ptr< torch::CustomClassHolder > c10::IValue::toCapsule ( ) const &

◆ toComplexDouble()

c10::complex< double > c10::IValue::toComplexDouble ( ) const

◆ toComplexDoubleList() [1/2]

c10::List< c10::complex< double > > c10::IValue::toComplexDoubleList ( ) &&

◆ toComplexDoubleList() [2/2]

c10::List< c10::complex< double > > c10::IValue::toComplexDoubleList ( ) const &

◆ toComplexDoubleVector()

std::vector< c10::complex< double > > c10::IValue::toComplexDoubleVector ( ) const

◆ toCustomClass() [1/2]

template<typename T >
c10::intrusive_ptr< T > c10::IValue::toCustomClass ( ) &&

◆ toCustomClass() [2/2]

template<typename T >
c10::intrusive_ptr< T > c10::IValue::toCustomClass ( ) const &

◆ toDevice()

c10::Device c10::IValue::toDevice ( ) const
inline

◆ toDimname()

at::Dimname c10::IValue::toDimname ( ) const
inline

◆ toDimVector()

at::DimVector c10::IValue::toDimVector ( ) const

◆ toDouble()

double c10::IValue::toDouble ( ) const
inline

◆ toDoubleList() [1/2]

c10::List< double > c10::IValue::toDoubleList ( ) &&

◆ toDoubleList() [2/2]

c10::List< double > c10::IValue::toDoubleList ( ) const &

◆ toDoubleVector()

std::vector< double > c10::IValue::toDoubleVector ( ) const

◆ toEnumHolder() [1/2]

c10::intrusive_ptr< ivalue::EnumHolder > c10::IValue::toEnumHolder ( ) &&

◆ toEnumHolder() [2/2]

c10::intrusive_ptr< ivalue::EnumHolder > c10::IValue::toEnumHolder ( ) const &

◆ toFuture() [1/2]

c10::intrusive_ptr< ivalue::Future > c10::IValue::toFuture ( ) &&

◆ toFuture() [2/2]

c10::intrusive_ptr< ivalue::Future > c10::IValue::toFuture ( ) const &

◆ toGenerator() [1/2]

at::Generator c10::IValue::toGenerator ( ) &&

◆ toGenerator() [2/2]

at::Generator c10::IValue::toGenerator ( ) const &

◆ toGenericDict() [1/2]

c10::Dict< IValue, IValue > c10::IValue::toGenericDict ( ) &&

◆ toGenericDict() [2/2]

c10::Dict< IValue, IValue > c10::IValue::toGenericDict ( ) const &

◆ toInt()

int64_t c10::IValue::toInt ( ) const
inline

◆ toIntList() [1/2]

c10::List< int64_t > c10::IValue::toIntList ( ) &&

◆ toIntList() [2/2]

c10::List< int64_t > c10::IValue::toIntList ( ) const &

◆ toIntVector()

std::vector< int64_t > c10::IValue::toIntVector ( ) const

◆ toIValue() [1/2]

IValue & c10::IValue::toIValue ( )
inline

◆ toIValue() [2/2]

const IValue & c10::IValue::toIValue ( ) const
inline

◆ toLayout()

at::Layout c10::IValue::toLayout ( ) const
inline

◆ toList() [1/2]

c10::List< IValue > c10::IValue::toList ( ) &&

◆ toList() [2/2]

c10::List< IValue > c10::IValue::toList ( ) const &

◆ toListRef()

c10::ArrayRef< IValue > c10::IValue::toListRef ( ) const

◆ toMemoryFormat()

at::MemoryFormat c10::IValue::toMemoryFormat ( ) const
inline

◆ toModule()

torch::jit::Module c10::IValue::toModule ( ) const

◆ toNone()

std::string c10::IValue::toNone ( ) const
inline

◆ toObject() [1/2]

c10::intrusive_ptr< ivalue::Object > c10::IValue::toObject ( ) &&

◆ toObject() [2/2]

c10::intrusive_ptr< ivalue::Object > c10::IValue::toObject ( ) const &

◆ toObjectRef()

ivalue::Object & c10::IValue::toObjectRef ( ) const

◆ toOptional() [1/2]

template<typename T >
optional< T > c10::IValue::toOptional ( )

◆ toOptional() [2/2]

template<typename T >
optional< T > c10::IValue::toOptional ( ) const

◆ toOptionalStringRef()

c10::optional< std::reference_wrapper< const std::string > > c10::IValue::toOptionalStringRef ( ) const

◆ toOptionalTensorList() [1/2]

c10::List< c10::optional< at::Tensor > > c10::IValue::toOptionalTensorList ( ) &&

◆ toOptionalTensorList() [2/2]

c10::List< c10::optional< at::Tensor > > c10::IValue::toOptionalTensorList ( ) const &

◆ toOptionalTensorVector()

std::vector< c10::optional< at::Tensor > > c10::IValue::toOptionalTensorVector ( ) const

◆ toPyObject()

PyObject * c10::IValue::toPyObject ( ) const

◆ toPyObjectHolder() [1/2]

c10::intrusive_ptr< ivalue::PyObjectHolder > c10::IValue::toPyObjectHolder ( ) &&

◆ toPyObjectHolder() [2/2]

c10::intrusive_ptr< ivalue::PyObjectHolder > c10::IValue::toPyObjectHolder ( ) const &

◆ toQScheme()

at::QScheme c10::IValue::toQScheme ( ) const
inline

◆ toQuantizer() [1/2]

c10::intrusive_ptr< at::Quantizer > c10::IValue::toQuantizer ( ) &&

◆ toQuantizer() [2/2]

c10::intrusive_ptr< at::Quantizer > c10::IValue::toQuantizer ( ) const &

◆ toRRef() [1/2]

c10::intrusive_ptr< c10::RRefInterface > c10::IValue::toRRef ( ) &&

◆ toRRef() [2/2]

c10::intrusive_ptr< c10::RRefInterface > c10::IValue::toRRef ( ) const &

◆ toScalar()

at::Scalar c10::IValue::toScalar ( ) const
inline

◆ toScalarType()

at::ScalarType c10::IValue::toScalarType ( ) const
inline

◆ toStorage() [1/2]

c10::Storage c10::IValue::toStorage ( ) &&

◆ toStorage() [2/2]

c10::Storage c10::IValue::toStorage ( ) const &

◆ toStream() [1/2]

c10::Stream c10::IValue::toStream ( ) &&

◆ toStream() [2/2]

c10::Stream c10::IValue::toStream ( ) const &

◆ toString() [1/2]

c10::intrusive_ptr< ivalue::ConstantString > c10::IValue::toString ( ) &&

◆ toString() [2/2]

c10::intrusive_ptr< ivalue::ConstantString > c10::IValue::toString ( ) const &

◆ toStringRef()

const std::string & c10::IValue::toStringRef ( ) const

◆ toStringView()

c10::string_view c10::IValue::toStringView ( ) const

◆ toSymFloat() [1/2]

c10::SymFloat c10::IValue::toSymFloat ( ) &&

◆ toSymFloat() [2/2]

c10::SymFloat c10::IValue::toSymFloat ( ) const &

◆ toSymInt() [1/2]

c10::SymInt c10::IValue::toSymInt ( ) &&

◆ toSymInt() [2/2]

c10::SymInt c10::IValue::toSymInt ( ) const &

◆ toTensor() [1/3]

at::Tensor & c10::IValue::toTensor ( ) &

◆ toTensor() [2/3]

at::Tensor c10::IValue::toTensor ( ) &&

◆ toTensor() [3/3]

const at::Tensor & c10::IValue::toTensor ( ) const &

◆ toTensorList() [1/2]

c10::List< at::Tensor > c10::IValue::toTensorList ( ) &&

◆ toTensorList() [2/2]

c10::List< at::Tensor > c10::IValue::toTensorList ( ) const &

◆ toTensorVector()

std::vector< at::Tensor > c10::IValue::toTensorVector ( ) const

◆ toTuple() [1/2]

c10::intrusive_ptr< ivalue::Tuple > c10::IValue::toTuple ( ) &&

◆ toTuple() [2/2]

c10::intrusive_ptr< ivalue::Tuple > c10::IValue::toTuple ( ) const &

◆ toTupleRef()

ivalue::Tuple & c10::IValue::toTupleRef ( ) const

◆ type()

template<typename T = c10::PlatformType>
TypePtr c10::IValue::type ( ) const

◆ uninitialized()

static IValue c10::IValue::uninitialized ( )
inlinestatic

◆ unsafeToTensorImpl()

at::TensorImpl * c10::IValue::unsafeToTensorImpl ( ) const
inline

◆ visit()

void c10::IValue::visit ( const std::function< bool(const IValue &)> &  visitor) const

Friends And Related Function Documentation

◆ _fastEqualsForContainer

bool _fastEqualsForContainer ( const IValue lhs,
const IValue rhs 
)
friend

[doxygen private] [container equality] This is an equality implementation that assumes objects with the same identity equal themselves, for efficiency reasons.

We primarily have this for consistency, because Python does the same thing. This actually provokes user-visible changes in behavior due to quirks in torch: [tensor1] == [tensor1] -> True (because container equality will first compare identity) [tensor1] == [tensor1_copy] -> RuntimeError: Boolean value of Tensor with more than one value is ambiguous

◆ operator!=

bool operator!= ( const IValue lhs,
const IValue rhs 
)
friend

◆ operator<<

std::ostream & operator<< ( std::ostream &  out,
const IValue v 
)
friend

◆ operator==

bool operator== ( const IValue lhs,
const IValue rhs 
)
friend

This implements the same semantics as bool(lhs == rhs) in Python.

which is the same as equals() except for Tensor types.

◆ WeakIValue

friend struct WeakIValue
friend

The documentation for this struct was generated from the following file: