void appendReLU(::arm_compute::ICLTensor *tensor);
void appendReLU6(::arm_compute::ICLTensor *tensor);
void appendReLU1(::arm_compute::ICLTensor *tensor);
+ void appendTanh(::arm_compute::ICLTensor *tensor);
public:
void append(FuseCode code, ::arm_compute::ICLTensor *tensor);
_builder.append("ReLU6", std::move(fn));
}
+void ActivationBuilder::appendTanh(::arm_compute::ICLTensor *ifm_alloc)
+{
+ const ::arm_compute::ActivationLayerInfo act_info{
+ ::arm_compute::ActivationLayerInfo::ActivationFunction::TANH, 1.0f, 1.0f};
+
+ auto fn = nnfw::make_unique<::arm_compute::CLActivationLayer>();
+
+ fn->configure(ifm_alloc, nullptr, act_info);
+
+ _builder.append("Tanh", std::move(fn));
+}
+
void ActivationBuilder::append(FuseCode code, ::arm_compute::ICLTensor *ifm_alloc)
{
switch (code)
{
VERBOSE(Tanh) << "Configure Tanh operation" << std::endl;
- throw std::runtime_error{"Not supported operation"};
+ const ::internal::tflite::operand::Index ofm_index{node.param().ofm_index};
+ const ::internal::tflite::operand::Index ifm_index{node.param().ifm_index};
+
+ // Set shape constraints
+ _builder.addShapeConstr(ofm_index,
+ asTensorInfo(_ctx.at(ofm_index).shape(), _ctx.at(ofm_index).type()));
+ _builder.addShapeConstr(ifm_index,
+ asTensorInfo(_ctx.at(ifm_index).shape(), _ctx.at(ifm_index).type()));
+
+ struct Param
+ {
+ int ofm_index;
+ int ifm_index;
+ };
+
+ Param param;
+
+ param.ofm_index = ofm_index.asInt();
+ param.ifm_index = ifm_index.asInt();
+
+ auto stage = [param](const IAllocationContext &ctx, IExecutionBuilder &builder) {
+ auto ofm_alloc = ctx.at(::internal::tflite::operand::Index{param.ofm_index});
+ auto ifm_alloc = ctx.at(::internal::tflite::operand::Index{param.ifm_index});
+
+ const ::arm_compute::ActivationLayerInfo act_info{
+ ::arm_compute::ActivationLayerInfo::ActivationFunction::TANH, 1.0f, 1.0f};
+
+ auto fn = nnfw::make_unique<::arm_compute::CLActivationLayer>();
+
+ fn->configure(ifm_alloc, ofm_alloc, act_info);
+
+ builder.append("Tanh", std::move(fn));
+ };
+
+ _builder.addStage(stage);
}
class AllocationContext final : public IAllocationContext