mirror of
https://github.com/sgjzfzzf/triton-tvm-ffi.git
synced 2026-07-01 08:51:56 +08:00
@@ -0,0 +1,45 @@
|
||||
#ifndef TRITON_TVM_FFI_VALUE_H_
|
||||
#define TRITON_TVM_FFI_VALUE_H_
|
||||
|
||||
#include "macro.h"
|
||||
#include "type.h"
|
||||
#include <tvm/ffi/any.h>
|
||||
#include <tvm/ffi/object.h>
|
||||
|
||||
namespace triton_tvm_ffi {
|
||||
|
||||
class TypedValueObj : public tvm::ffi::Object {
|
||||
public:
|
||||
TypedValueObj(Type type, const tvm::ffi::Any &value);
|
||||
TypedValueObj(Type type, tvm::ffi::Any &&value);
|
||||
TypedValueObj(const TypedValueObj &other) = default;
|
||||
TypedValueObj(TypedValueObj &&other) = default;
|
||||
TypedValueObj &operator=(const TypedValueObj &other) = default;
|
||||
TypedValueObj &operator=(TypedValueObj &&other) = default;
|
||||
TVM_FFI_DECLARE_OBJECT_INFO_FINAL("triton_tvm_ffi.TypedValue", TypedValueObj,
|
||||
tvm::ffi::Object);
|
||||
TRITON_TVM_FFI_INLINE Type GetType() const { return type_; }
|
||||
TRITON_TVM_FFI_INLINE const tvm::ffi::Any &GetValue() const { return value_; }
|
||||
|
||||
private:
|
||||
Type type_;
|
||||
tvm::ffi::Any value_;
|
||||
};
|
||||
|
||||
class TypedValue : public tvm::ffi::ObjectRef {
|
||||
public:
|
||||
TypedValue(Type type, const tvm::ffi::Any &value);
|
||||
TypedValue(Type type, tvm::ffi::Any &&value);
|
||||
using tvm::ffi::ObjectRef::ObjectRef;
|
||||
using tvm::ffi::ObjectRef::operator=;
|
||||
TVM_FFI_DEFINE_OBJECT_REF_METHODS_NOTNULLABLE(TypedValue, tvm::ffi::ObjectRef,
|
||||
TypedValueObj);
|
||||
TRITON_TVM_FFI_INLINE Type GetType() const { return get()->GetType(); }
|
||||
TRITON_TVM_FFI_INLINE const tvm::ffi::Any &GetValue() const {
|
||||
return get()->GetValue();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace triton_tvm_ffi
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user