Deconv1d+LeakyRelu shape inference error
MESeraph opened this issue · comments
I write a UT only use Deconv1d and LeakyRelu:
#include "tim/vx/context.h"
#include "tim/vx/graph.h"
#include "tim/vx/ops/deconv1d.h"
#include "tim/vx/ops/activations.h"
#include "gtest/gtest.h"
TEST(DeConv1dLeakyRelu, shape_3_2_1) {
auto ctx = tim::vx::Context::Create();
auto graph = ctx->CreateGraph();
tim::vx::ShapeType input_shape ({3, 2, 1}); //whcn
tim::vx::ShapeType kernel_shape({3, 2, 1}); //whc1 same as depthwise convolution
tim::vx::ShapeType transient_shape({5, 2, 1}); //whcn
tim::vx::ShapeType output_shape({5, 2, 1}); //whcn
tim::vx::TensorSpec input_spec (tim::vx::DataType::FLOAT32, input_shape, tim::vx::TensorAttribute::INPUT);
tim::vx::TensorSpec kernel_spec (tim::vx::DataType::FLOAT32, kernel_shape, tim::vx::TensorAttribute::CONSTANT);
tim::vx::TensorSpec transisent_spec (tim::vx::DataType::FLOAT32, transient_shape, tim::vx::TensorAttribute::TRANSIENT);
tim::vx::TensorSpec output_spec (tim::vx::DataType::FLOAT32, output_shape, tim::vx::TensorAttribute::OUTPUT);
auto input_tensor = graph->CreateTensor(input_spec);
auto output_tensor = graph->CreateTensor(output_spec);
auto transient_tensor = graph->CreateTensor(transisent_spec);
auto kernel_tensor = graph->CreateTensor(kernel_spec);
std::vector<float> input_data = { 3.0f, 9.0f, 3.0f,
7.0f, 5.0f, 9.0f, };
std::vector<float> kernel_data = { 9.0f, 0.0f, 1.0f,
3.0f, 0.0f, 0.0f, };
std::vector<float> output_data(10);
EXPECT_TRUE(input_tensor->CopyDataToTensor(input_data.data(), input_data.size()*4));
EXPECT_TRUE(kernel_tensor->CopyDataToTensor(kernel_data.data(), kernel_data.size()*4));
auto op = graph->CreateOperation<tim::vx::ops::DeConv1d>(
2, tim::vx::PadType::SAME, 3, 1, 1, std::array<uint32_t, 2>({0, 0}), 2);
(*op).BindInputs({input_tensor, kernel_tensor}).BindOutputs({transient_tensor});
auto leakyrelu = graph->CreateOperation<tim::vx::ops::LeakyRelu>(0.01f);
(*leakyrelu).BindInputs({transient_tensor}).BindOutputs({output_tensor});
EXPECT_TRUE(graph->Compile());
EXPECT_TRUE(graph->Run());
EXPECT_TRUE(output_tensor->CopyDataFromTensor(output_data.data()));
}