3#include <ATen/core/DimVector.h>
5#include <ATen/core/blob.h>
6#include <ATen/core/custom_class.h>
7#include <ATen/core/ivalue_to.h>
8#include <ATen/core/jit_type_base.h>
9#include <ATen/core/type_factory.h>
10#include <c10/core/SymFloat.h>
11#include <c10/macros/Export.h>
12#include <c10/util/C++17.h>
13#include <c10/util/MaybeOwned.h>
14#include <c10/util/intrusive_ptr.h>
21using ::torch::CustomClassHolder;
23struct CompilationUnit;
28template <
class Key,
class Value>
46 std::stringstream& why_not);
71 val = convert<
decltype(
val), c10::complex<T>>(c);
74 c10::complex<double>
val;
84 struct c10::StreamData3
val;
104 list = std::vector<T>(ref->begin(), ref->end());
114 list = std::vector<T>(ref->begin(), ref->end());
144 c10::intrusive_ptr<torch::CustomClassHolder>
obj_ptr;
145 explicit Capsule(c10::intrusive_ptr<torch::CustomClassHolder> ptr)
156#define TORCH_FORALL_TAGS(_) \
222 :
IValue(rhs.payload, rhs.tag) {
223 if (isIntrusivePtr() && payload.u.as_intrusive_ptr != c10::UndefinedTensorImpl::singleton()) {
224 c10::raw::intrusive_ptr::incref(payload.u.as_intrusive_ptr);
229 moveFrom(std::move(rhs));
243 moveFrom(std::move(rhs));
303 return (int64_t)IValue::hash(*
this);
333 return isAliasOf(a.
values(), b) ||
338 return isAliasOf(a, b.
values()) ||
353 template <
typename T>
354 bool isListOf()
const;
358 bool isAliasOf(
const IValue& rhs)
const {
359 if (this->tag != rhs.tag) {
365 if (this->isTensor()) {
366 return isAliasOf(this->toTensor(), rhs.toTensor());
369 if (!isIntrusivePtr()) {
377 return this->payload.u.as_intrusive_ptr == rhs.payload.u.as_intrusive_ptr;
381 size_t use_count() const noexcept {
383 return payload.as_tensor.use_count();
386 if (!isIntrusivePtrLegacyBehavior()) {
390 if (payload.u.as_intrusive_ptr == c10::UndefinedTensorImpl::singleton()) {
393 return c10::raw::intrusive_ptr::use_count(payload.u.as_intrusive_ptr);
397 void swap(IValue& rhs)
noexcept {
398 if (isTensor() && rhs.isTensor()) {
399 std::swap(payload.as_tensor, rhs.payload.as_tensor);
400 }
else if (isTensor()) {
411 payload.u = rhs.payload.u;
412 new (&rhs.payload.as_tensor)
at::Tensor(std::move(t));
413 }
else if (rhs.isTensor()) {
417 std::swap(payload.u, rhs.payload.u);
419 std::swap(tag, rhs.tag);
427 new (&payload.as_tensor)
at::Tensor(std::move(t));
430 return Tag::Tensor == tag;
435 [[noreturn]]
void reportToTensorTypeError()
const;
441 at::TensorImpl* unsafeToTensorImpl()
const {
443 return payload.as_tensor.unsafeGetTensorImpl();
446 IValue(at::Storage s) : tag(Tag::Storage) {
447 payload.u.as_intrusive_ptr = null_to_undefined_tensor(s.unsafeReleaseStorageImpl());
450 return Tag::Storage == tag;
463 IValue(intrusive_ptr<caffe2::Blob> blob)
467 payload.u.as_intrusive_ptr = null_to_undefined_tensor(blob.release());
471 bool isBlob()
const {
472 return Tag::Blob == tag;
476 c10::intrusive_ptr<caffe2::Blob> toBlob() &&;
479 c10::intrusive_ptr<caffe2::Blob> toBlob() const&;
484 intrusive_ptr<
torch::CustomClassHolder> blob);
485 bool isCapsule()
const {
486 return Tag::Capsule == tag;
488 c10::intrusive_ptr<torch::CustomClassHolder>
toCapsule() &&;
489 c10::intrusive_ptr<torch::CustomClassHolder>
toCapsule() const&;
495 std::is_base_of<
torch::CustomClassHolder, T>::value,
498 bool isCustomClass() const;
499 template <typename T>
500 c10::intrusive_ptr<T> toCustomClass() &&;
501 template <typename T>
502 c10::intrusive_ptr<T> toCustomClass() const&;
511 std::is_lvalue_reference<Args>...,
512 guts::negation<
std::is_constructible<
IValue, Args>>...>::value,
513 std::nullptr_t> =
nullptr>
519 std::is_lvalue_reference<Args>...,
520 guts::negation<
std::is_constructible<
IValue, Args>>...>::value,
521 std::nullptr_t> =
nullptr>
523 bool isTuple()
const {
524 return Tag::Tuple == tag;
526 c10::intrusive_ptr<ivalue::Tuple>
toTuple() &&;
527 c10::intrusive_ptr<ivalue::Tuple>
toTuple() const&;
528 C10_NODISCARD ivalue::Tuple& toTupleRef() const;
532 payload.u.as_double = d;
535 return Tag::Double == tag;
539 return payload.u.as_double;
543 template <
typename T>
549 IValue(c10::intrusive_ptr<ivalue::Future> v);
551 return Tag::Future == tag;
554 c10::intrusive_ptr<ivalue::Future>
toFuture() const&;
557 bool isAwait()
const {
558 return Tag::Await == tag;
560 c10::intrusive_ptr<ivalue::Await>
toAwait() &&;
561 c10::intrusive_ptr<ivalue::Await>
toAwait() const&;
565 bool isRRef()
const {
566 return Tag::RRef == tag;
568 c10::intrusive_ptr<c10::RRefInterface>
toRRef() &&;
569 c10::intrusive_ptr<c10::RRefInterface>
toRRef() const&;
573 bool isQuantizer()
const {
574 return Tag::Quantizer == tag;
581 payload.u.as_int = i;
585 if (i.is_symbolic()) {
587 payload.u.as_intrusive_ptr = i.toSymNodeImpl().release();
590 payload.u.as_int = i.as_int_unchecked();
595 return Tag::SymInt == tag;
602 if (i.is_symbolic()) {
604 payload.u.as_intrusive_ptr = i.toSymNodeImpl().release();
607 payload.u.as_double = i.as_float_unchecked();
612 return Tag::SymFloat == tag;
622 return Tag::Int == tag;
627 return payload.u.as_int;
632#if defined(__clang__) && defined(__x86_64__)
636 payload.u.as_int = b;
638 payload.u.as_bool = b;
642 return Tag::Bool == tag;
646 return payload.u.as_bool;
653 std::vector<int64_t> toIntVector() const;
654 at::DimVector toDimVector() const;
662 return Tag::String == tag;
664 c10::intrusive_ptr<ivalue::ConstantString>
toString() &&;
665 c10::intrusive_ptr<ivalue::ConstantString>
toString() const&;
666 const
std::
string& toStringRef() const;
669 c10::string_view toStringView() const;
672 bool isDoubleList() const;
675 std::vector<
double> toDoubleVector() const;
678 bool isComplexDoubleList() const;
680 c10::
List<
c10::complex<
double>> toComplexDoubleList() const&;
681 std::vector<
c10::complex<
double>> toComplexDoubleVector() const;
684 bool isBoolList() const;
689 bool isTensorList() const;
692 std::vector<
at::Tensor> toTensorVector() const;
695 bool isOptionalTensorList() const;
702 bool isList()
const {
703 return Tag::GenericList == tag;
713 std::enable_if_t<
std::is_constructible<
IValue, T>::value,
std::nullptr_t>;
725 std::enable_if_t<
std::is_constructible<
IValue, T>::value &&
726 !
std::is_same<T,
c10::SymInt>::value,
std::nullptr_t>;
736 template <class T,
size_t N>
744 std::enable_if_t<
std::is_same<T,
c10::SymInt>::value,
std::nullptr_t>;
755 std::is_constructible<
IValue, T>::value &&
757 !
std::is_same<T,
c10::SymInt>::value,
765 bool isGenericDict()
const {
766 return Tag::GenericDict == tag;
771 template <class Key, class Value>
774 template <class Key, class Value>
777 C10_DEPRECATED_MESSAGE(
778 "IValues based on
std::unordered_map<K, V> are slow and deprecated. Please use
c10::
Dict<K, V> instead.")
790 bool isObject()
const {
791 return tag == Tag::Object;
794 c10::intrusive_ptr<ivalue::Object>
toObject() const&;
795 ivalue::Object& toObjectRef() const;
797 torch::jit::Module toModule() const;
798 bool isModule() const;
802 bool isPyObject()
const {
803 return tag == Tag::PyObject;
807 PyObject* toPyObject() const;
810 explicit
IValue(
c10::intrusive_ptr<ivalue::EnumHolder> v);
811 bool isEnum()
const {
812 return tag == Tag::Enum;
820 return Tag::None == tag;
829 i.tag = Tag::Uninitialized;
839 payload.u.as_intrusive_ptr = s.
toSymInt().toSymNodeImpl().release();
840 }
else if (s.isSymFloat()) {
842 payload.u.as_intrusive_ptr = s.toSymFloat().toSymNodeImpl().release();
843 }
else if (s.isFloatingPoint()) {
845 payload.u.as_double = s.toDouble();
846 }
else if (s.isComplex()) {
847 *
this = s.toComplexDouble();
848 }
else if (s.isBoolean()) {
850 payload.u.as_bool = s.toBool();
854 payload.u.as_int = s.toLong();
859 return isDouble() || isInt() || isComplexDouble() || isBool() || isSymInt() || isSymFloat();
867 else if (isComplexDouble())
868 return toComplexDouble();
873 else if (isSymFloat())
875 throw std::runtime_error(
"IValue is not a Scalar");
880 payload.u.as_device.type = d.
type();
881 payload.u.as_device.index = d.
index();
884 return Tag::Device == tag;
888 return c10::Device(payload.u.as_device.type, payload.u.as_device.index);
894 auto v = c10::make_intrusive<ivalue::StreamData3Holder>(s.pack3());
895 payload.u.as_intrusive_ptr = v.release();
899 bool isStream()
const {
return Tag::Stream == tag; }
903 :
IValue(static_cast<
std::underlying_type<ScalarType>::type>(t)) {}
905 return static_cast<at::ScalarType
>(toInt());
910 :
IValue(static_cast<
std::underlying_type<Layout>::type>(l)) {}
912 return static_cast<at::Layout
>(toInt());
917 :
IValue(static_cast<
std::underlying_type<MemoryFormat>::type>(m)) {}
919 return static_cast<at::MemoryFormat
>(toInt());
923 IValue(at::QScheme qscheme) : tag(Tag::Int) {
924 payload.u.as_int =
static_cast<int64_t
>(qscheme);
928 return static_cast<at::QScheme
>(toInt());
932 IValue(at::Dimname dimname) :
IValue(dimname.symbol().toQualString()) {}
935 return at::Dimname::fromSymbol(Symbol::fromQualString(toStringRef()));
939 IValue(at::Generator g) : tag(Tag::Generator) {
940 payload.u.as_intrusive_ptr = null_to_undefined_tensor(g.unsafeReleaseGeneratorImpl());
943 return Tag::Generator == tag;
949 std::
string tagKind()
const {
951#define DEFINE_CASE(x) \
957 return "InvalidTag(" + c10::guts::to_string(
static_cast<int>(tag)) +
")";
970 template <
typename T>
972 template <
typename T>
973 typename c10::detail::ivalue_to_const_ref_overload_return<T>::type to() const&;
977 template <typename T>
979 template <typename T>
984 bool isSameIdentity(const
IValue& rhs) const;
997 std::ostream& stream,
998 std::function<
bool(
std::ostream&, const
IValue& v)> customFormatter)
1006 TORCH_API friend
std::ostream& operator<<(
1010 bool isPtrType()
const {
1012 return payload.as_tensor.defined();
1014 return isIntrusivePtrLegacyBehavior();
1018 const void* internalToPointer()
const {
1020 isPtrType(),
"Can only call internalToPointer() for pointer types");
1022 return payload.as_tensor.unsafeGetTensorImpl();
1024 return payload.u.as_intrusive_ptr != c10::UndefinedTensorImpl::singleton()
1025 ? payload.u.as_intrusive_ptr :
nullptr;
1029 template <
typename T = c10::PlatformType>
1030 TypePtr type()
const;
1034 size_t hashTensor(
const at::Tensor& ten)
const {
1039 return hashTensor(ten.
_values());
1044 return hashTensor(ten.
values());
1051 return reinterpret_cast<size_t>(
1052 ten.
storage().unsafeGetStorageImpl());
1055 size_t operator()(
const IValue& val)
const {
1061 return val.payload.u.as_int;
1066 bool operator()(
const IValue& lhs,
const IValue& rhs)
const {
1067 return lhs.isAliasOf(rhs);
1072 std::unordered_set<IValue, HashAliasedIValue, CompAliasedIValues>;
1074 std::unordered_map<IValue, IValue, HashAliasedIValue, CompAliasedIValues>;
1078 bool overlaps(
const IValue& rhs)
const;
1086 void visit(
const std::function<
bool(
const IValue&)>& visitor)
const;
1091 static c10::intrusive_ptr_target* null_to_undefined_tensor(c10::intrusive_ptr_target* p) {
1092 return p ? p :
static_cast<c10::intrusive_ptr_target*
>(c10::UndefinedTensorImpl::singleton());
1095 static bool ptrEqual(
const IValue& lhs,
const IValue& rhs);
1102 enum class Tag : uint32_t {
1103#define DEFINE_TAG(x) x,
1110 class NullType = c10::detail::intrusive_target_default_null_type<T>>
1111 c10::intrusive_ptr<T, NullType> moveToIntrusivePtr();
1114 class NullType = c10::detail::intrusive_target_default_null_type<T>>
1115 c10::intrusive_ptr<T, NullType> toIntrusivePtr()
const;
1122 if (isTensor() || isIntrusivePtr()) {
1123 c10::intrusive_ptr_target* p = isTensor() ? payload.as_tensor.unsafeGetTensorImpl() : payload.u.as_intrusive_ptr;
1124 c10::intrusive_ptr<intrusive_ptr_target, c10::UndefinedTensorImpl>::reclaim(p);
1130 C10_ALWAYS_INLINE
void moveFrom(IValue&& rhs)
noexcept {
1131 if (rhs.isTensor()) {
1132 new (&payload.as_tensor)
at::Tensor(std::move(rhs.payload.as_tensor));
1143 payload.u = rhs.payload.u;
1149 void clearToNone() noexcept {
1150 payload.u.as_int = 0;
1154 bool isIntrusivePtr()
const {
1162 case Tag::Generator:
1166 case Tag::ComplexDouble:
1182 case Tag::GenericList:
1184 case Tag::GenericDict:
1198 case Tag::Uninitialized:
1204 case Tag::Quantizer:
1216 bool isIntrusivePtrLegacyBehavior()
const {
1217 if (tag == Tag::Storage || tag == Tag::Generator) {
1218 return payload.u.as_intrusive_ptr != c10::UndefinedTensorImpl::singleton();
1220 return isIntrusivePtr();
1239 c10::intrusive_ptr_target* as_intrusive_ptr;
1250 IValue(
const Payload& p, Tag t) : tag(
t) {
1252 new (&payload.as_tensor)
at::Tensor(p.as_tensor);
1258 template <
typename T>
1261 friend MaybeOwnedTraits<IValue>;
1264 Tag tag{IValue::Tag::None};
1272 : payload(rhs.payload),
1274 is_intrusive_ptr(rhs.is_intrusive_ptr) {
1275 if (is_intrusive_ptr && payload.as_intrusive_ptr != c10::UndefinedTensorImpl::singleton()) {
1276 c10::raw::weak_intrusive_ptr::incref(payload.as_intrusive_ptr);
1279 WeakIValue(
const IValue& rhs)
1281 is_intrusive_ptr(rhs.isIntrusivePtrLegacyBehavior()) {
1282 if (rhs.isTensor()) {
1283 payload.as_intrusive_ptr = rhs.unsafeToTensorImpl();
1284 is_intrusive_ptr =
true;
1286 payload = rhs.payload.u;
1288 if (is_intrusive_ptr) {
1289 if (payload.as_intrusive_ptr != c10::UndefinedTensorImpl::singleton()) {
1290 c10::raw::weak_intrusive_ptr::incref(payload.as_intrusive_ptr);
1294 WeakIValue(WeakIValue&& rhs) noexcept : WeakIValue() {
1298 if (is_intrusive_ptr && payload.as_intrusive_ptr != c10::UndefinedTensorImpl::singleton()) {
1299 c10::raw::weak_intrusive_ptr::decref(payload.as_intrusive_ptr);
1302 WeakIValue& operator=(WeakIValue&& rhs) &
noexcept {
1303 WeakIValue(std::move(rhs)).swap(*
this);
1311 std::swap(payload, rhs.payload);
1312 std::swap(is_intrusive_ptr, rhs.is_intrusive_ptr);
1313 std::swap(tag, rhs.tag);
1316 bool isSameIdentity(
const WeakIValue& rhs)
const {
1317 return payload.as_int == rhs.payload.
as_int && tag == rhs.tag &&
1318 is_intrusive_ptr == rhs.is_intrusive_ptr;
1322 if (!is_intrusive_ptr) {
1323 IValue::Payload newPayload;
1324 newPayload.u = payload;
1325 return IValue(newPayload, tag);
1327 if (IValue::Tag::Tensor == tag) {
1328 auto temp = c10::weak_intrusive_ptr<at::TensorImpl, c10::UndefinedTensorImpl>::reclaim(
1329 static_cast<at::TensorImpl*
>(payload.as_intrusive_ptr));
1330 c10::intrusive_ptr<at::TensorImpl, c10::UndefinedTensorImpl> ip(temp.lock());
1338 auto temp = c10::weak_intrusive_ptr<c10::intrusive_ptr_target>::reclaim(
1339 payload.as_intrusive_ptr == c10::UndefinedTensorImpl::singleton()
1341 : payload.as_intrusive_ptr);
1343 pl.u.as_intrusive_ptr = temp.lock().release();
1345 if (!pl.u.as_intrusive_ptr) {
1348 return IValue(pl, tag);
1353 size_t use_count() const noexcept {
1354 if (!is_intrusive_ptr) {
1357 auto temp = c10::weak_intrusive_ptr<c10::intrusive_ptr_target, c10::UndefinedTensorImpl>::reclaim(
1358 payload.as_intrusive_ptr);
1359 size_t result = temp.use_count();
1364 size_t weak_use_count() const noexcept {
1365 if (!is_intrusive_ptr) {
1368 auto temp = c10::weak_intrusive_ptr<c10::intrusive_ptr_target, c10::UndefinedTensorImpl>::reclaim(
1369 payload.as_intrusive_ptr);
1370 size_t result = temp.weak_use_count();
1374 size_t hash()
const {
1375 return payload.as_int;
1379 using Payload = IValue::Payload::TriviallyCopyablePayload;
1381 IValue::Tag tag{IValue::Tag::None};
1382 bool is_intrusive_ptr{
false};
1390 std::shared_ptr<torch::jit::CompilationUnit> cu,
1393 std::shared_ptr<torch::jit::CompilationUnit> cu_;
1404 std::weak_ptr<torch::jit::CompilationUnit> cu,
1407 std::weak_ptr<torch::jit::CompilationUnit> cu_;
1449 : cu_(
std::move(cu)), type_(
std::move(type)) {}
1455 bool holds_strong_ref()
const {
1459 bool holds_empty_strong_ref()
const {
1467#include <ATen/core/ivalue_inl.h>
#define TORCH_INTERNAL_ASSERT_DEBUG_ONLY(...)
Definition: Exception.h:534
#define TORCH_INTERNAL_ASSERT(cond,...)
Definition: Exception.h:377
#define AT_ASSERT(...)
Definition: Exception.h:654
Definition: TensorBase.h:79
bool is_sparse() const
Returns if a Tensor has sparse backend.
Definition: TensorBase.h:449
bool has_storage() const
Definition: TensorBase.h:334
const Storage & storage() const
Definition: TensorBase.h:337
bool is_sparse_csr() const
Returns is a Tensor has a sparse CSR backend.
Definition: TensorBase.h:455
bool is_alias_of(const at::TensorBase &other) const
Definition: TensorBase.h:340
TensorImpl * unsafeGetTensorImpl() const
Definition: TensorBase.h:184
Definition: TensorBody.h:90
at::Tensor _values() const
Definition: TensorBody.h:4000
at::Tensor col_indices() const
Definition: TensorBody.h:4025
at::Tensor crow_indices() const
Definition: TensorBody.h:4020
at::Tensor _indices() const
Definition: TensorBody.h:3995
at::Tensor values() const
Definition: TensorBody.h:4015
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:40
Definition: OptionalArrayRef.h:20
Definition: Optional.h:549
#define TORCH_FORALL_TAGS(_)
Definition: ivalue.h:156
#define DEFINE_TAG(x)
Definition: ivalue.h:1102
Definition: TensorBase.h:34
at::Tensor t(const at::Tensor &self)
Definition: Functions.h:7681
bool _fastEqualsForContainer(const IValue &lhs, const IValue &rhs)
IValueComparator getLessThanComparator(const IValue &v)
std::function< bool(const IValue &a, const IValue &b)> IValueComparator
Definition: ivalue.h:49
constexpr nullopt_t nullopt
Definition: Optional.h:163
int8_t DeviceIndex
An index representing a specific device; e.g., the 1 in GPU 1.
Definition: Device.h:18
DeviceType
Definition: DeviceType.h:33
IValueComparator getGreaterThanComparator(const IValue &v)
std::shared_ptr< ClassType > ClassTypePtr
Definition: ivalue.h:40
void swap(optional< T > &x, optional< T > &y) noexcept(noexcept(x.swap(y)))
Definition: Optional.h:1218
torch::jit::Function * checkObjectSortSchema(const c10::ClassTypePtr &t, std::stringstream &why_not)
Capsule(c10::intrusive_ptr< torch::CustomClassHolder > ptr)
Definition: ivalue.h:145
c10::intrusive_ptr< torch::CustomClassHolder > obj_ptr
Definition: ivalue.h:144
Represents a a compute device on which a tensor is located.
Definition: Device.h:30
DeviceIndex index() const noexcept
Returns the optional index.
Definition: Device.h:70
DeviceType type() const noexcept
Returns the type of device this is.
Definition: Device.h:65
Definition: ivalue.h:1064
Definition: ivalue.h:1032
IValue (Interpreter Value) is a tagged union over the types supported by the TorchScript interpreter.
Definition: ivalue.h:220
c10::intrusive_ptr< c10::RRefInterface > toRRef() &&
std::unordered_set< IValue, HashAliasedIValue, CompAliasedIValues > HashAliasedIValues
Definition: ivalue.h:1071
IValue(at::Generator g)
Definition: ivalue.h:939
c10::Dict< IValue, IValue > toGenericDict() const &
c10::intrusive_ptr< ivalue::ConstantString > toString() &&
c10::SymFloat toSymFloat() const &
c10::intrusive_ptr< torch::CustomClassHolder > toCapsule() const &
std::unordered_map< IValue, IValue, HashAliasedIValue, CompAliasedIValues > HashAliasedIValueMap
Definition: ivalue.h:1073
bool isNone() const
Definition: ivalue.h:819
IValue(IValue &&rhs) noexcept
Definition: ivalue.h:228
c10::Stream toStream() &&
IValue hash() const
Hashing for IValues.
Definition: ivalue.h:302
c10::intrusive_ptr< at::Quantizer > toQuantizer() &&
IValue(const at::Scalar &s)
Definition: ivalue.h:834
c10::SymInt toSymInt() &&
IValue(bool b)
Definition: ivalue.h:631
IValue(c10::Stream s)
Definition: ivalue.h:892
c10::SymFloat toSymFloat() &&
friend bool operator!=(const IValue &lhs, const IValue &rhs)
double toDouble() const
Definition: ivalue.h:537
c10::Dict< IValue, IValue > toGenericDict() &&
c10::intrusive_ptr< at::Quantizer > toQuantizer() const &
IValue(c10::Device d)
Definition: ivalue.h:879
bool is(const IValue &rhs) const
Identity comparison.
c10::intrusive_ptr< ivalue::Object > toObject() const &
c10::SymInt toSymInt() const &
bool isStorage() const
Definition: ivalue.h:449
std::enable_if_t< std::is_same< T, c10::SymInt >::value, std::nullptr_t > enable_if_symint
Definition: ivalue.h:744
at::Generator toGenerator() const &
at::Dimname toDimname() const
Definition: ivalue.h:934
c10::intrusive_ptr< ivalue::Tuple > toTuple() const &
IValue equals(const IValue &rhs) const
Equality comparison.
c10::complex< double > toComplexDouble() const
bool isSymFloat() const
Definition: ivalue.h:611
c10::intrusive_ptr< ivalue::EnumHolder > toEnumHolder() const &
std::enable_if_t< std::is_constructible< IValue, T >::value, std::nullptr_t > enable_if_ivalue_constructible
Definition: ivalue.h:713
IValue(ScalarType t)
Definition: ivalue.h:902
std::string toNone() const
Definition: ivalue.h:822
IValue deepcopy(HashAliasedIValueMap &memo) const
bool isScalar() const
Definition: ivalue.h:858
c10::intrusive_ptr< ivalue::PyObjectHolder > toPyObjectHolder() &&
c10::List< int64_t > toIntList() const &
bool isDouble() const
Definition: ivalue.h:534
c10::intrusive_ptr< ivalue::Tuple > toTuple() &&
c10::List< int64_t > toIntList() &&
static IValue uninitialized()
Definition: ivalue.h:827
c10::intrusive_ptr< ivalue::Await > toAwait() const &
IValue(c10::SymInt i)
Definition: ivalue.h:584
IValue(at::TensorBase t)
Definition: ivalue.h:426
IValue(c10::intrusive_ptr< ivalue::Future > v)
c10::intrusive_ptr< ivalue::ConstantString > toString() const &
IValue(at::Storage s)
Definition: ivalue.h:446
bool isSymInt() const
Definition: ivalue.h:594
c10::Device toDevice() const
Definition: ivalue.h:886
c10::intrusive_ptr< ivalue::Future > toFuture() const &
IValue(c10::string_view v)
Definition: ivalue.h:660
bool isBool() const
Definition: ivalue.h:641
c10::List< IValue > toList() const &
IValue(Layout l)
Definition: ivalue.h:909
IValue & toIValue()
Definition: ivalue.h:458
bool isTensor() const
Definition: ivalue.h:429
c10::intrusive_ptr< torch::CustomClassHolder > toCapsule() &&
bool isInt() const
Definition: ivalue.h:621
friend bool operator==(const IValue &lhs, const IValue &rhs)
This implements the same semantics as bool(lhs == rhs) in Python.
at::Scalar toScalar() const
Definition: ivalue.h:862
std::enable_if_t< std::is_constructible< IValue, T >::value &&!std::is_same< T, c10::SymInt >::value, std::nullptr_t > enable_if_list_is_ivalue_constructible
Definition: ivalue.h:726
bool isString() const
Definition: ivalue.h:661
c10::intrusive_ptr< ivalue::PyObjectHolder > toPyObjectHolder() const &
at::Generator toGenerator() &&
friend bool _fastEqualsForContainer(const IValue &lhs, const IValue &rhs)
[doxygen private] [container equality] This is an equality implementation that assumes objects with t...
at::ScalarType toScalarType() const
Definition: ivalue.h:904
bool isFuture() const
Definition: ivalue.h:550
at::Layout toLayout() const
Definition: ivalue.h:911
at::MemoryFormat toMemoryFormat() const
Definition: ivalue.h:918
c10::intrusive_ptr< ivalue::Await > toAwait() &&
bool isComplexDouble() const
Definition: ivalue.h:545
IValue(at::Dimname dimname)
Definition: ivalue.h:932
IValue & operator=(IValue const &rhs) &
Definition: ivalue.h:247
c10::List< IValue > toList() &&
c10::Storage toStorage() &&
IValue(MemoryFormat m)
Definition: ivalue.h:916
IValue(at::QScheme qscheme)
Definition: ivalue.h:923
c10::Stream toStream() const &
IValue(const IValue &rhs)
Definition: ivalue.h:221
c10::intrusive_ptr< ivalue::Object > toObject() &&
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_ilist_is_ivalue_constructible
Definition: ivalue.h:758
IValue(c10::complex< T > c)
at::QScheme toQScheme() const
Definition: ivalue.h:927
bool isGenerator() const
Definition: ivalue.h:942
at::Tensor & toTensor() &
IValue & operator=(IValue &&rhs) &noexcept
Definition: ivalue.h:237
c10::intrusive_ptr< ivalue::Future > toFuture() &&
static size_t hash(const IValue &iv)
bool toBool() const
Definition: ivalue.h:644
const at::Tensor & toTensor() const &
c10::Storage toStorage() const &
bool isDevice() const
Definition: ivalue.h:883
c10::intrusive_ptr< c10::RRefInterface > toRRef() const &
int64_t toInt() const
Definition: ivalue.h:625
c10::intrusive_ptr< ivalue::EnumHolder > toEnumHolder() &&
OptionalArray & operator=(c10::OptionalArrayRef< T > ref)
Definition: ivalue.h:112
OptionalArray & operator=(c10::optional< ArrayRef< T > > ref)
Definition: ivalue.h:102
OptionalArray(std::vector< T > val)
Definition: ivalue.h:99
c10::optional< std::vector< T > > list
Definition: ivalue.h:96
Definition: ivalue.h:1386
Definition: ivalue.h:1266
void swap(WeakIValue &rhs) noexcept
Definition: ivalue.h:1308
WeakIValue(const WeakIValue &rhs)
Definition: ivalue.h:1269
Definition: ivalue.h:1410
std::shared_ptr< torch::jit::CompilationUnit > getStrongRefOrThrow() const
Definition: ivalue.h:1417
c10::optional< std::weak_ptr< torch::jit::CompilationUnit > > weak_ptr_
Definition: ivalue.h:1436
std::weak_ptr< torch::jit::CompilationUnit > getWeakRefOrThrow() const
Definition: ivalue.h:1422
bool holdingStrongRef() const
Definition: ivalue.h:1427
bool holdingEmptyStrongRef() const
Definition: ivalue.h:1431
c10::optional< std::shared_ptr< torch::jit::CompilationUnit > > strong_ptr_
Definition: ivalue.h:1435
Definition: ivalue.h:1441
WeakOrStrongTypePtr(StrongTypePtr strong)
Definition: ivalue.h:1444
WeakOrStrongTypePtr(WeakOrStrongCompilationUnit cu, TypePtr type)
Definition: ivalue.h:1446
Definition: ivalue.h:1400
c10::complex< double > val
Definition: ivalue.h:74
ComplexHolder(c10::complex< T > c)
Definition: ivalue.h:70
struct c10::StreamData3 val
Definition: ivalue.h:84
StreamData3Holder()=delete
StreamData3Holder(struct c10::StreamData3 d)
Definition: ivalue.h:80
Definition: Optional.h:160
Definition: ivalue.h:1229
int64_t as_int
Definition: ivalue.h:1231