-
Notifications
You must be signed in to change notification settings - Fork 79
hir::Allocate node
#6000
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
hir::Allocate node
#6000
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -504,4 +504,39 @@ std::string ForLoop::toInlineString(int indent_size) const { | |||||||
| index, iter_domain->start(), iter_domain->stop()); | ||||||||
| } | ||||||||
|
|
||||||||
| Allocate::Allocate( | ||||||||
| IrBuilderPasskey passkey, | ||||||||
| Val* in, | ||||||||
| MemoryType memory_type, | ||||||||
|
Comment on lines
+509
to
+510
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
| bool zero_init) | ||||||||
| : Expr(passkey) { | ||||||||
| NVF_ERROR(passkey.ir_container_ != nullptr); | ||||||||
| NVF_ERROR(passkey.ir_container_->isA<HostIrContainer>()); | ||||||||
| NVF_ERROR(in->isA<TensorView>(), "hir::Allocate input must be a TensorView."); | ||||||||
|
|
||||||||
| addInput(in); | ||||||||
| addDataAttribute(memory_type); | ||||||||
| addDataAttribute(zero_init); | ||||||||
| } | ||||||||
|
|
||||||||
| NVFUSER_DEFINE_CLONE_AND_CREATE(Allocate) | ||||||||
|
|
||||||||
| std::string Allocate::toString(int indent_size) const { | ||||||||
| std::stringstream ss; | ||||||||
| indent(ss, indent_size) << in()->toString() << " = ALLOCATE(" | ||||||||
| << "mem_type=" << memoryType() << ", " | ||||||||
| << "zero_init=" << std::boolalpha << zeroInit() << ")" | ||||||||
| << std::endl; | ||||||||
| return ss.str(); | ||||||||
| } | ||||||||
|
|
||||||||
| std::string Allocate::toInlineString(int indent_size) const { | ||||||||
| std::stringstream ss; | ||||||||
| indent(ss, indent_size) << in()->toInlineString() << " = ALLOCATE(" | ||||||||
| << "mem_type=" << memoryType() << ", " | ||||||||
| << "zero_init=" << std::boolalpha << zeroInit() | ||||||||
| << ")"; | ||||||||
| return ss.str(); | ||||||||
| } | ||||||||
|
|
||||||||
| } // namespace nvfuser::hir | ||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -756,7 +756,7 @@ class HostIrCompileDispatcher : public OptInDispatch { | |
| smem}); | ||
| } | ||
|
|
||
| void handle(kir::Allocate* allocate) final { | ||
| void handle(hir::Allocate* allocate) final { | ||
| llvm::LLVMContext& context = builder_.getContext(); | ||
| llvm::Module* module = builder_.GetInsertBlock()->getParent()->getParent(); | ||
|
|
||
|
|
@@ -765,14 +765,10 @@ class HostIrCompileDispatcher : public OptInDispatch { | |
| llvm::SmallVector<llvm::Value*, kMaxTensorDim> tensor_sizes; | ||
| llvm::SmallVector<llvm::Value*, kMaxTensorDim> tensor_strides; | ||
| inferTensorShapesAndStrides( | ||
| allocate->buffer()->as<TensorView>(), | ||
| val_to_value_, | ||
| builder_, | ||
| tensor_sizes, | ||
| tensor_strides); | ||
| allocate->in(), val_to_value_, builder_, tensor_sizes, tensor_strides); | ||
|
|
||
| const std::vector<IterDomain*>& logical_domain = TensorDomain::noReductions( | ||
| allocate->buffer()->as<TensorView>()->getLogicalDomain()); | ||
| const std::vector<IterDomain*>& logical_domain = | ||
| TensorDomain::noReductions(allocate->in()->getLogicalDomain()); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider |
||
|
|
||
| NVF_ERROR_EQ(tensor_sizes.size(), logical_domain.size()); | ||
|
|
||
|
|
@@ -811,9 +807,8 @@ class HostIrCompileDispatcher : public OptInDispatch { | |
|
|
||
| // Create constants for type and device from params | ||
| at::ScalarType data_type = data_type_to_aten( | ||
| allocate->buffer()->dtype() == DataType::Index | ||
| ? PrimDataType::Int | ||
| : allocate->buffer()->dtype()); | ||
| allocate->in()->dtype() == DataType::Index ? PrimDataType::Int | ||
| : allocate->in()->dtype()); | ||
| llvm::Value* dtype_constant = | ||
| builder_.getInt32(static_cast<int32_t>(data_type)); | ||
| llvm::Value* device_index_constant = | ||
|
|
@@ -833,7 +828,7 @@ class HostIrCompileDispatcher : public OptInDispatch { | |
| dtype_constant, | ||
| device_index_constant, | ||
| out_tensor}); | ||
| val_to_value_[allocate->buffer()] = out_tensor; | ||
| val_to_value_[allocate->in()] = out_tensor; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
|
|
||
| void handle(hir::Deallocate* deallocate) final { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.