2019-04-17 10:49:11 +08:00
|
|
|
//
|
|
|
|
|
// CPUTanh.cpp
|
|
|
|
|
// MNN
|
|
|
|
|
//
|
|
|
|
|
// Created by MNN on 2018/08/27.
|
|
|
|
|
// Copyright © 2018, Alibaba Group Holding Limited
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#include "CPUTanh.hpp"
|
|
|
|
|
#include <math.h>
|
2019-08-22 20:13:46 +08:00
|
|
|
#include "CommonOptFunction.h"
|
2019-04-17 10:49:11 +08:00
|
|
|
#include "CPUBackend.hpp"
|
|
|
|
|
#include "Macro.h"
|
|
|
|
|
|
|
|
|
|
namespace MNN {
|
|
|
|
|
|
|
|
|
|
ErrorCode CPUTanh::onExecute(const std::vector<Tensor *> &inputs, const std::vector<Tensor *> &outputs) {
|
|
|
|
|
MNN_ASSERT(1 == inputs.size());
|
|
|
|
|
MNN_ASSERT(1 == outputs.size());
|
|
|
|
|
auto inputData = inputs[0]->host<float>();
|
|
|
|
|
auto outputData = outputs[0]->host<float>();
|
|
|
|
|
|
|
|
|
|
const int dataSize = outputs[0]->elementSize();
|
2019-08-22 20:13:46 +08:00
|
|
|
MNNTanh(outputData, inputData, dataSize);
|
2019-04-17 10:49:11 +08:00
|
|
|
return NO_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class CPUTanhCreator : public CPUBackend::Creator {
|
|
|
|
|
public:
|
|
|
|
|
virtual Execution *onCreate(const std::vector<Tensor *> &inputs, const std::vector<Tensor *> &outputs,
|
|
|
|
|
const MNN::Op *op, Backend *backend) const {
|
|
|
|
|
return new CPUTanh(backend);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
REGISTER_CPU_OP_CREATOR(CPUTanhCreator, OpType_TanH);
|
|
|
|
|
} // namespace MNN
|