-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
151 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
onnxruntime/contrib_ops/cuda/collective/distributed_expand.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
// Distributed computation. | ||
#include "distributed_expand.h" | ||
#include "sharding.h" | ||
#include "sharding_spec.h" | ||
#include "nccl_kernels.h" | ||
#include "mpi_include.h" | ||
|
||
// ORT system. | ||
#include "core/providers/cuda/tensor/expand.h" | ||
|
||
// std C++. | ||
#include <iostream> | ||
|
||
namespace onnxruntime { | ||
namespace contrib { | ||
namespace cuda { | ||
|
||
#if defined(ORT_USE_NCCL) | ||
|
||
template <typename T> | ||
DistributedExpand<T>::DistributedExpand(const OpKernelInfo& info) : DistributedKernel(info) {} | ||
|
||
template <typename T> | ||
Status DistributedExpand<T>::ComputeInternal(OpKernelContext* context) const { | ||
ORT_ENFORCE(context != nullptr); | ||
return Status(common::ONNXRUNTIME, common::NOT_IMPLEMENTED, "Encounter unsupported expand pattern."); | ||
} | ||
|
||
ONNX_OPERATOR_TYPED_KERNEL_EX( | ||
DistributedExpand, | ||
kMSDomain, | ||
1, | ||
int64_t, | ||
kCudaExecutionProvider, | ||
(*KernelDefBuilder::Create()) | ||
.TypeConstraint("T", DataTypeImpl::GetTensorType<int64_t>()) | ||
.InputMemoryType(OrtMemTypeCPUInput, 1), | ||
DistributedExpand<int64_t>); | ||
|
||
ONNX_OPERATOR_TYPED_KERNEL_EX( | ||
DistributedExpand, | ||
kMSDomain, | ||
1, | ||
float, | ||
kCudaExecutionProvider, | ||
(*KernelDefBuilder::Create()) | ||
.TypeConstraint("T", DataTypeImpl::GetTensorType<float>()) | ||
.InputMemoryType(OrtMemTypeCPUInput, 1), | ||
DistributedExpand<float>); | ||
|
||
ONNX_OPERATOR_TYPED_KERNEL_EX( | ||
DistributedExpand, | ||
kMSDomain, | ||
1, | ||
MLFloat16, | ||
kCudaExecutionProvider, | ||
(*KernelDefBuilder::Create()) | ||
.TypeConstraint("T", DataTypeImpl::GetTensorType<MLFloat16>()) | ||
.InputMemoryType(OrtMemTypeCPUInput, 1), | ||
DistributedExpand<MLFloat16>); | ||
|
||
#endif | ||
|
||
} // namespace cuda | ||
} // namespace contrib | ||
} // namespace onnxruntime |
35 changes: 35 additions & 0 deletions
35
onnxruntime/contrib_ops/cuda/collective/distributed_expand.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
#include "sharding_spec.h" | ||
#include "sharding.h" | ||
#include "core/providers/cuda/cuda_kernel.h" | ||
|
||
#include <algorithm> | ||
#include <tuple> | ||
#include <optional> | ||
#include <string> | ||
#include <nccl.h> | ||
#include <sstream> | ||
|
||
#pragma once | ||
|
||
namespace onnxruntime { | ||
namespace contrib { | ||
namespace cuda { | ||
|
||
#if defined(ORT_USE_NCCL) | ||
|
||
template <typename T> | ||
class DistributedExpand final : public DistributedKernel { | ||
public: | ||
explicit DistributedExpand(const OpKernelInfo& info); | ||
|
||
Status ComputeInternal(OpKernelContext* context) const override; | ||
}; | ||
|
||
#endif | ||
|
||
} // namespace cuda | ||
} // namespace contrib | ||
} // namespace onnxruntime |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters