Skip to content

Commit

Permalink
Swish (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
mwyi authored and YangleiZouIntel committed Feb 2, 2021
1 parent 1e9bd8a commit 31dc258
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
25 changes: 25 additions & 0 deletions inference-engine/src/plaidml_plugin/ops/swish.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (C) 2020 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

#include "plaidml_ops.hpp"

#include "ngraph/opsets/opset.hpp"
#include "ngraph/opsets/opset4.hpp"

#include "plaidml/op/op.h"

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

namespace PlaidMLPlugin {

static OpRegistration reg("swish", [](const Context& ctx) {
IE_ASSERT(ctx.operands.size() == 2);
auto I = ctx.operands.at(0);
auto beta = ctx.operands.at(1);

return edsl::make_tuple(I / (1.0 + edsl::exp(-(beta * I))));
});

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

0 comments on commit 31dc258

Please sign in to comment.