From cfc70c48dfc1573fad03fd61c6896c417f665609 Mon Sep 17 00:00:00 2001 From: Kainan Cha Date: Thu, 18 Mar 2021 14:24:10 +0800 Subject: [PATCH] Use auto shape for virtual tensors Use auto shape for virtual tensors so that TIM-VX can perform its internal shape inference and graph optimizations. Signed-off-by: Kainan Cha --- src/tim/vx/tensor.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/tim/vx/tensor.cc b/src/tim/vx/tensor.cc index d4c9ee5..06ac7e1 100644 --- a/src/tim/vx/tensor.cc +++ b/src/tim/vx/tensor.cc @@ -154,6 +154,12 @@ bool TensorImpl::Init() { attr.is_const = static_cast(spec_.attr_ & TensorAttribute::CONSTANT); attr.vtl = static_cast(spec_.attr_ & TensorAttribute::TRANSIENT); + // Use auto shape for virtual tensors so that tim-vx can perform it's own + // shape inference + if (attr.vtl) { + attr.dim_num = VSI_NN_DIM_AUTO; + } + for (ShapeType::size_type i = 0; i < spec_.shape_.size(); i++) { attr.size[i] = spec_.shape_[i]; } @@ -195,4 +201,4 @@ bool TensorImpl::IsReadable() { } } // namespace vx -} // namespace tim \ No newline at end of file +} // namespace tim