-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'gt/master' into gt/kedeng/imatmul
- Loading branch information
Showing
77 changed files
with
3,528 additions
and
634 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
#include "contrib_ops/cpu/fused_activation.h" | ||
|
||
namespace onnxruntime { | ||
|
||
common::Status GetFusedActivationAttr(const OpKernelInfo& info, MLAS_ACTIVATION& activation) { | ||
// Convert the activation parameters from the node into a MLAS_ACTIVATION. | ||
activation.ActivationKind = MlasIdentityActivation; | ||
|
||
std::string activation_type; | ||
if (info.GetAttr<std::string>("activation", &activation_type).IsOK()) { | ||
if (activation_type == "Relu") { | ||
activation.ActivationKind = MlasReluActivation; | ||
} else if (activation_type == "LeakyRelu") { | ||
activation.ActivationKind = MlasLeakyReluActivation; | ||
activation.alpha = info.GetAttrOrDefault<float>("alpha", 0.01f); | ||
} else if (activation_type == "Tanh") { | ||
activation.ActivationKind = MlasTanhActivation; | ||
} else if (activation_type == "Sigmoid") { | ||
activation.ActivationKind = MlasLogisticActivation; | ||
} else { | ||
return Status(common::ONNXRUNTIME, common::INVALID_ARGUMENT, "Unimplemented activation: " + activation_type); | ||
} | ||
} | ||
|
||
return Status::OK(); | ||
} | ||
|
||
} // 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
#pragma once | ||
#include "core/common/common.h" | ||
#include "core/framework/op_kernel.h" | ||
#include "core/util/math.h" | ||
#include "core/mlas/inc/mlas.h" | ||
|
||
namespace onnxruntime { | ||
|
||
common::Status GetFusedActivationAttr(const OpKernelInfo& info, MLAS_ACTIVATION& activation); | ||
|
||
} // 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,26 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
#include "fused_conv.h" | ||
#include "core/providers/cpu/nn/conv.h" | ||
#include "contrib_ops/cpu/fused_activation.h" | ||
|
||
namespace onnxruntime { | ||
namespace contrib { | ||
|
||
class FusedConvFloat final : public Conv<float> { | ||
public: | ||
FusedConvFloat(const OpKernelInfo& info) : Conv<float>(info) { | ||
ORT_ENFORCE(GetFusedActivationAttr(info, activation_).IsOK()); | ||
} | ||
}; | ||
|
||
ONNX_CPU_OPERATOR_TYPED_MS_KERNEL( | ||
FusedConv, | ||
1, | ||
float, | ||
KernelDefBuilder() | ||
.TypeConstraint("T", DataTypeImpl::GetTensorType<float>()), | ||
FusedConv<float>); | ||
FusedConvFloat); | ||
|
||
} // namespace contrib | ||
} // namespace onnxruntime |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,15 +1,26 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
#include "fused_gemm.h" | ||
#include "core/providers/cpu/math/gemm.h" | ||
|
||
namespace onnxruntime { | ||
namespace contrib { | ||
|
||
template <typename T> | ||
class FusedGemm final : public Gemm<T> { | ||
public: | ||
FusedGemm(const OpKernelInfo& info) : Gemm<T>(info) { | ||
Gemm<T>::activation_ = info.GetAttrOrDefault<std::string>("activation", ""); | ||
Gemm<T>::leaky_relu_alpha_ = info.GetAttrOrDefault("leaky_relu_alpha", 0.01f); | ||
} | ||
}; | ||
|
||
ONNX_CPU_OPERATOR_TYPED_MS_KERNEL( | ||
FusedGemm, | ||
1, | ||
float, | ||
KernelDefBuilder().TypeConstraint("T", DataTypeImpl::GetTensorType<float>()), | ||
FusedGemm<float, float, float, float>); | ||
FusedGemm<float>); | ||
|
||
} // namespace contrib | ||
} // namespace onnxruntime |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.