Skip to content

Commit

Permalink
Add GELU (#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
LiyangLingIntel authored and YangleiZouIntel committed Feb 2, 2021
1 parent 398f5b8 commit fb314b7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
22 changes: 22 additions & 0 deletions inference-engine/src/plaidml_plugin/ops/gelu.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (C) 2020 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

#include "ngraph/opsets/opset.hpp"
#include "ngraph/opsets/opset1.hpp"
#include "plaidml/op/op.h"
#include "plaidml_ops.hpp"

using namespace plaidml; // NOLINT[build/namespaces]
using namespace InferenceEngine; // NOLINT[build/namespaces]

namespace PlaidMLPlugin {

static OpRegistration reg("gelu", [](const Context& ctx) {
IE_ASSERT(ctx.operands.size() == 1);
auto I = ctx.operands.at(0);
auto O = I * 0.5 * (1 + edsl::erf(I / sqrt(2)));
return edsl::make_tuple(O);
});

} // namespace PlaidMLPlugin
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const std::map<ActivationTypes, std::vector<std::vector<float>>> activationTypes
{Selu, {{1.6732f, 1.0507f}}},
{Ceiling, {{}}},
{Swish, {{1.0f}}},
{Gelu, {{}}},
// {Mish, {{}}},
{HSwish, {{}}}
// {SoftPlus, {{}}}
Expand Down

0 comments on commit fb314b7

Please sign in to comment.