24#ifndef TVM_TIRX_EXPR_H_
25#define TVM_TIRX_EXPR_H_
27#include <tvm/ffi/container/array.h>
28#include <tvm/ffi/reflection/registry.h>
29#include <tvm/ffi/string.h>
56 <<
"Expected a non-null Var with TensorType";
63 const ffi::Array<PrimExpr>&
shape()
const {
return ty()->shape; }
95inline constexpr bool use_default_type_traits_v<tirx::TensorVar> =
false;
98struct TypeTraits<tirx::TensorVar> :
public ObjectRefTypeTraitsBase<tirx::TensorVar> {
99 using Base = ObjectRefTypeTraitsBase<tirx::TensorVar>;
100 using Base::CopyFromAnyViewAfterCheck;
101 using Base::CopyToAnyView;
102 using Base::GetMismatchTypeInfo;
103 using Base::MoveFromAnyAfterCheck;
104 using Base::MoveToAny;
105 using Base::TypeSchema;
109 if (src->type_index == TypeIndex::kTVMFFINone) {
112 if (src->type_index != tvm::VarObj::RuntimeTypeIndex()) {
116 detail::ObjectUnsafe::ObjectPtrFromUnowned<Object>(src->v_obj).get());
117 return detail::AnyUnsafe::CheckAnyStrict<tirx::TensorType>(var->ExprObj::ty);
121 if (CheckAnyStrict(src)) {
122 return detail::ObjectUnsafe::ObjectRefFromObjectPtr<tirx::TensorVar>(
123 detail::ObjectUnsafe::ObjectPtrFromUnowned<tvm::VarObj>(src->v_obj));
#define TVM_TIRX_DLL
Definition base.h:55
Managed reference to CallObj.
Definition expr.h:825
Managed reference to ExprObj.
Definition expr.h:101
Non-nullable source-location metadata.
Definition location.h:91
Reference to the shared immutable unknown location.
Definition location.h:105
A local variable in the IR.
Definition expr.h:552
Managed reference to VarObj.
Definition expr.h:571
A registered memory space, independent of backend allocation policy.
Definition memory_scope.h:65
Structural type of a TIRx tensor variable.
Definition type.h:59
Managed reference to TensorTypeObj.
Definition type.h:129
Checked zero-state view over an ordinary VarObj with TensorType.
Definition expr.h:48
Expr data() const
Project the physical pointer established by the definition site.
Definition expr.h:69
const ffi::Array< PrimExpr > & shape() const
Return the shape of the tensor.
Definition expr.h:63
TensorVar(Var var)
Create a checked tensor view over an existing ordinary Var.
Definition expr.h:54
TensorVar(ffi::UnsafeInit tag)
Definition expr.h:75
runtime::MemoryScope scope() const
Return the storage scope associated with this tensor.
Definition expr.h:72
TVM_FFI_DEFINE_DEFAULT_COPY_MOVE_AND_ASSIGN(TensorVar)
TensorVar(ffi::ObjectPtr< VarObj > node)
Definition expr.h:74
static constexpr bool _type_container_is_exact
Definition expr.h:79
static constexpr bool _type_is_nullable
Definition expr.h:78
TensorType ty() const
Return the tensor type carried by the ordinary variable.
Definition expr.h:60
PrimType dtype() const
Return the primitive element type.
Definition expr.h:66
TVM_TIRX_DLL TensorVar(ffi::String name, TensorType type, Location loc=UnknownLoc())
Construct a fresh tensor variable from an explicit TensorType.
Definition nested_msg.h:600
TVM_TIRX_DLL const Op & tensor_data_ptr_op()
Project the physical pointer associated with a TensorVar definition.
bool operator!=(const TensorVar &lhs, const TensorVar &rhs)
Definition expr.h:87
bool operator==(const TensorVar &lhs, const TensorVar &rhs)
Definition expr.h:85
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition analysis.h:41
static TVM_FFI_INLINE bool CheckAnyStrict(const TVMFFIAny *src)
Definition expr.h:108
static TVM_FFI_INLINE std::optional< tirx::TensorVar > TryCastFromAnyView(const TVMFFIAny *src)
Definition expr.h:120
ObjectRefTypeTraitsBase< tirx::TensorVar > Base
Definition expr.h:99
Memory operations for TIRx.