Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[luci-interpreter] Support TransposeConv activation #11474

Merged
merged 1 commit into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions compiler/luci-interpreter/src/core/KernelParams.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ struct TransposeConvParams
Padding padding;
int32_t stride_height;
int32_t stride_width;
Activation activation;
};

struct UnidirectionalSequenceLSTMParams
Expand Down
5 changes: 5 additions & 0 deletions compiler/luci-interpreter/src/kernels/TransposeConv.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ void Check(std::initializer_list<int32_t> output_shape_shape,
params.padding = padding;
params.stride_height = stride_height;
params.stride_width = stride_width;
params.activation = luci::FusedActFunc::NONE;

if (bias_data.size() != 0)
{
Expand Down Expand Up @@ -164,6 +165,7 @@ TEST(TransposeConvTest, UInt8)
params.padding = Padding::VALID;
params.stride_height = 2;
params.stride_width = 2;
params.activation = luci::FusedActFunc::NONE;

TransposeConv kernel(&output_shape_tensor, &filter_tensor, &input_tensor, &bias_tensor,
&output_tensor, &scratch_tensor, params);
Expand Down Expand Up @@ -232,6 +234,7 @@ TEST(TransposeConvTest, UInt8_CWQ)
params.padding = Padding::VALID;
params.stride_height = 2;
params.stride_width = 2;
params.activation = luci::FusedActFunc::NONE;

TransposeConv kernel(&output_shape_tensor, &filter_tensor, &input_tensor, &bias_tensor,
&output_tensor, &scratch_tensor, params);
Expand Down Expand Up @@ -278,6 +281,7 @@ TEST(TransposeConvTest, SInt16)
params.padding = Padding::VALID;
params.stride_height = 2;
params.stride_width = 2;
params.activation = luci::FusedActFunc::NONE;

TransposeConv kernel(&output_shape_tensor, &filter_tensor, &input_tensor, &bias_tensor,
&output_tensor, &scratch_tensor, params);
Expand Down Expand Up @@ -336,6 +340,7 @@ TEST(TransposeConvTest, SInt16_CWQ_weights)
params.padding = Padding::VALID;
params.stride_height = 2;
params.stride_width = 2;
params.activation = luci::FusedActFunc::NONE;

TransposeConv kernel(&output_shape_tensor, &filter_tensor, &input_tensor, &bias_tensor,
&output_tensor, &scratch_tensor, params);
Expand Down
2 changes: 2 additions & 0 deletions compiler/luci-interpreter/src/loader/KernelBuilder.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1319,6 +1319,7 @@ TEST_F(KernelBuilderTest, TransposeConv)
op->padding(luci::Padding::SAME);
op->stride()->h(11);
op->stride()->w(13);
op->fusedActivationFunction(luci::FusedActFunc::NONE);

auto kernel = buildKernel<kernels::TransposeConv>(op);
ASSERT_THAT(kernel, NotNull());
Expand All @@ -1331,6 +1332,7 @@ TEST_F(KernelBuilderTest, TransposeConv)
EXPECT_THAT(kernel->params().padding, Eq(op->padding()));
EXPECT_THAT(kernel->params().stride_height, Eq(op->stride()->h()));
EXPECT_THAT(kernel->params().stride_width, Eq(op->stride()->w()));
EXPECT_THAT(kernel->params().activation, Eq(op->fusedActivationFunction()));
}

TEST_F(KernelBuilderTest, Unpack)
Expand Down
7 changes: 7 additions & 0 deletions compiler/luci-interpreter/src/loader/nodes/TransposeConv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ std::unique_ptr<Kernel> build_kernel_CircleTransposeConv(const luci::CircleNode
params.padding = node->padding();
params.stride_height = node->stride()->h();
params.stride_width = node->stride()->w();
params.activation = node->fusedActivationFunction();

// TODO support activation
if (params.activation != luci::FusedActFunc::NONE)
{
throw std::runtime_error("Unsupported activation of TransposeConv");
}

return std::make_unique<kernels::TransposeConv>(input_sizes, filter, out_backprop, bias, output,
tmp, params);
Expand Down