Skip to content
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
31 changes: 22 additions & 9 deletions backends/arm/runtime/VGFSetup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ namespace vgf {
/* static function to map format to byte count */
static uint32_t get_format_size(VkFormat format);

// SPV_ARM_tensor does not support rank-0 representations according to the spec.
// Use an unsqueezed dimension when the resource table contains an empty
// shape. Tensors are output as rank 0 when copied back from the vgf backend.
namespace {
constexpr int64_t kScalarSentinelDimension = 1;
}

// Debug function to inspect memory properties
static string memory_flags_to_string(VkMemoryPropertyFlags flags) {
if (flags == 0)
Expand Down Expand Up @@ -264,7 +271,11 @@ static void debug_print_resources(
the_shape.size(),
the_stride.size());
for (int j = 0; j < the_shape.size(); j++) {
ET_LOG(Info, " %d: dim %ld", j, the_shape[j]);
ET_LOG(
Info,
" %d: dim %lld",
j,
static_cast<long long>(the_shape[j]));
}
// Allocate a tensor with bound memory
break;
Expand Down Expand Up @@ -387,6 +398,7 @@ bool VgfRepr::process_vgf(const char* vgf_data, ArrayRef<CompileSpec> specs) {
// Get tensor shape and strides
auto shape = resource_decoder->getTensorShape(i);
auto stride = resource_decoder->getTensorStride(i);
const auto shape_size = shape.size();

switch (resource_decoder->getCategory(i)) {
case vgflib::ResourceCategory::INPUT:
Expand All @@ -409,9 +421,9 @@ bool VgfRepr::process_vgf(const char* vgf_data, ArrayRef<CompileSpec> specs) {
result = allocate_tensor(
vk_physical,
vk_device,
vgflib::ToVkFormat(resource_decoder->getVkFormat(i)),
static_cast<uint32_t>(shape.size()),
shape.begin(),
resource_format,
shape_size == 0 ? 1 : static_cast<uint32_t>(shape_size),
shape_size == 0 ? &kScalarSentinelDimension : shape.begin(),
static_cast<uint32_t>(stride.size()),
stride.begin(),
&tensor_description,
Expand All @@ -422,8 +434,7 @@ bool VgfRepr::process_vgf(const char* vgf_data, ArrayRef<CompileSpec> specs) {
ET_LOG(Error, "Failed to allocate tensor for VGF resource %d", i);
return false;
}
size_t e_size = get_format_size(
vgflib::ToVkFormat(resource_decoder->getVkFormat(i)));
size_t e_size = get_format_size(resource_format);
if (0 == e_size) {
ET_LOG(Error, "failed to get element size of VkFormat");
return false;
Expand All @@ -449,9 +460,11 @@ bool VgfRepr::process_vgf(const char* vgf_data, ArrayRef<CompileSpec> specs) {
.sType = VK_STRUCTURE_TYPE_TENSOR_DESCRIPTION_ARM,
.pNext = nullptr,
.tiling = VK_TENSOR_TILING_LINEAR_ARM,
.format = vgflib::ToVkFormat(resource_decoder->getVkFormat(i)),
.dimensionCount = static_cast<uint32_t>(shape.size()),
.pDimensions = shape.begin(),
.format = resource_format,
.dimensionCount =
shape_size == 0 ? 1 : static_cast<uint32_t>(shape_size),
.pDimensions =
shape_size == 0 ? &kScalarSentinelDimension : shape.begin(),
// Note: stride_data of 0's causes size==0, null means stride==size
.pStrides = (0 == stride.size() ? nullptr : stride.begin()),
.usage = VK_TENSOR_USAGE_DATA_GRAPH_BIT_ARM,
Expand Down
2 changes: 0 additions & 2 deletions backends/arm/test/ops/test_addmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ def test_addmm_u85_INT(test_data: Tuple):

@common.parametrize("test_data", test_data_suite)
@common.SkipIfNoModelConverter
@pytest.mark.xfail(reason="MLETORCH-1410: Tensor dimension count not supported: 0")
def test_addmm_vgf_FP(test_data: input_t1):
pipeline = VgfPipeline[input_t1](
Addmm(),
Expand All @@ -181,7 +180,6 @@ def test_addmm_vgf_FP(test_data: input_t1):

@common.parametrize("test_data", test_data_suite)
@common.SkipIfNoModelConverter
@pytest.mark.xfail(reason="MLETORCH-1410: Tensor dimension count not supported: 0")
def test_addmm_vgf_INT(test_data: input_t1):
pipeline = VgfPipeline[input_t1](
Addmm(),
Expand Down
4 changes: 0 additions & 4 deletions backends/arm/test/ops/test_amax.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ def test_max_dim_tosa_FP_not_delegated():

@common.parametrize("test_data", Amax.test_data)
@common.SkipIfNoModelConverter
@pytest.mark.xfail(reason="MLETORCH-1410: Tensor dimension count not supported: 0")
def test_amax_vgf_FP(test_data: Amax.input_t):
data, dim, keep_dims = test_data()
module = Amax(dim, keep_dims)
Expand All @@ -154,7 +153,6 @@ def test_amax_vgf_FP(test_data: Amax.input_t):

@common.parametrize("test_data", Amax.test_data)
@common.SkipIfNoModelConverter
@pytest.mark.xfail(reason="MLETORCH-1410: Tensor dimension count not supported: 0")
def test_amax_vgf_INT(test_data: Amax.input_t):
data, dim, keep_dims = test_data()
module = Amax(dim, keep_dims)
Expand All @@ -169,7 +167,6 @@ def test_amax_vgf_INT(test_data: Amax.input_t):

@common.parametrize("test_data", Max.test_data)
@common.SkipIfNoModelConverter
@pytest.mark.xfail(reason="MLETORCH-1410: Tensor dimension count not supported: 0")
def test_max_dim_vgf_FP_to_amax(test_data: Max.input_t):
data, dim = test_data()
pipeline = VgfPipeline[Max.input_t](
Expand All @@ -183,7 +180,6 @@ def test_max_dim_vgf_FP_to_amax(test_data: Max.input_t):

@common.parametrize("test_data", Max.test_data)
@common.SkipIfNoModelConverter
@pytest.mark.xfail(reason="MLETORCH-1410: Tensor dimension count not supported: 0")
def test_max_dim_vgf_INT_to_amax(test_data: Max.input_t):
data, dim = test_data()
pipeline = VgfPipeline[Max.input_t](
Expand Down
4 changes: 0 additions & 4 deletions backends/arm/test/ops/test_amin.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ def test_min_dim_tosa_FP_not_delegated():

@common.parametrize("test_data", Amin.test_data)
@common.SkipIfNoModelConverter
@pytest.mark.xfail(reason="MLETORCH-1410: Tensor dimension count not supported: 0")
def test_amin_vgf_FP(test_data: Amin.input_t):
data, dim, keep_dims = test_data()
pipeline = VgfPipeline[Amin.input_t](
Expand All @@ -166,7 +165,6 @@ def test_amin_vgf_FP(test_data: Amin.input_t):

@common.parametrize("test_data", Amin.test_data)
@common.SkipIfNoModelConverter
@pytest.mark.xfail(reason="MLETORCH-1410: Tensor dimension count not supported: 0")
def test_amin_vgf_INT(test_data: Amin.input_t):
data, dim, keep_dims = test_data()
pipeline = VgfPipeline[Amin.input_t](
Expand All @@ -180,7 +178,6 @@ def test_amin_vgf_INT(test_data: Amin.input_t):

@common.parametrize("test_data", Min.test_data)
@common.SkipIfNoModelConverter
@pytest.mark.xfail(reason="MLETORCH-1410: Tensor dimension count not supported: 0")
def test_min_dim_vgf_FP_to_amin(test_data: Min.input_t):
data, dim = test_data()
pipeline = VgfPipeline[Min.input_t](
Expand All @@ -194,7 +191,6 @@ def test_min_dim_vgf_FP_to_amin(test_data: Min.input_t):

@common.parametrize("test_data", Min.test_data)
@common.SkipIfNoModelConverter
@pytest.mark.xfail(reason="MLETORCH-1410: Tensor dimension count not supported: 0")
def test_min_dim_vgf_INT_to_amin(test_data: Min.input_t):
data, dim = test_data()
pipeline = VgfPipeline[Min.input_t](
Expand Down
3 changes: 0 additions & 3 deletions backends/arm/test/ops/test_any.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

from typing import List, Tuple

import pytest
import torch
from executorch.backends.arm.test import common
from executorch.backends.arm.test.tester.test_pipeline import (
Expand Down Expand Up @@ -189,7 +188,6 @@ def test_any_u85_INT(test_data: input_t1):

@common.parametrize("test_data", test_data)
@common.SkipIfNoModelConverter
@pytest.mark.xfail(reason="MLETORCH-1410: Tensor dimension count not supported: 0")
def test_any_vgf_FP(test_data: input_t1):
op, data_fn = test_data()
pipeline = VgfPipeline[input_t1](
Expand All @@ -204,7 +202,6 @@ def test_any_vgf_FP(test_data: input_t1):

@common.parametrize("test_data", test_data)
@common.SkipIfNoModelConverter
@pytest.mark.xfail(reason="MLETORCH-1410: Tensor dimension count not supported: 0")
def test_any_vgf_INT(test_data: input_t1):
op, data_fn = test_data()
pipeline = VgfPipeline[input_t1](
Expand Down
5 changes: 0 additions & 5 deletions backends/arm/test/ops/test_mean_dim.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import pytest
import torch
from executorch.backends.arm.test import common
from executorch.backends.arm.test.tester.test_pipeline import (
Expand Down Expand Up @@ -84,7 +83,6 @@ def test_adaptive_avg_pool2d_u85_INT(test_data):

@common.parametrize("test_data", AdaptiveAveragePool2d.test_data_suite)
@common.SkipIfNoModelConverter
@pytest.mark.xfail(reason="MLETORCH-1410: Tensor dimension count not supported: 0")
def test_adaptive_avg_pool2d_vgf_FP(test_data):
pipeline = VgfPipeline[input_t](
AdaptiveAveragePool2d(),
Expand All @@ -98,7 +96,6 @@ def test_adaptive_avg_pool2d_vgf_FP(test_data):

@common.parametrize("test_data", AdaptiveAveragePool2d.test_data_suite)
@common.SkipIfNoModelConverter
@pytest.mark.xfail(reason="MLETORCH-1410: Tensor dimension count not supported: 0")
def test_adaptive_avg_pool2d_vgf_INT(test_data):
pipeline = VgfPipeline[input_t](
AdaptiveAveragePool2d(),
Expand Down Expand Up @@ -331,7 +328,6 @@ def test_mean_dim_u85_INT(test_data):

@common.parametrize("test_data", MeanDim.test_data_suite)
@common.SkipIfNoModelConverter
@pytest.mark.xfail(reason="MLETORCH-1410: Tensor dimension count not supported: 0")
def test_mean_dim_vgf_FP(test_data):
test_data_val, dim, keep_dim = test_data()
pipeline = VgfPipeline[input_t](
Expand All @@ -346,7 +342,6 @@ def test_mean_dim_vgf_FP(test_data):

@common.parametrize("test_data", MeanDim.test_data_suite)
@common.SkipIfNoModelConverter
@pytest.mark.xfail(reason="MLETORCH-1410: Tensor dimension count not supported: 0")
def test_mean_dim_vgf_INT(test_data):
test_data_val, dim, keep_dim = test_data()
pipeline = VgfPipeline[input_t](
Expand Down
3 changes: 0 additions & 3 deletions backends/arm/test/ops/test_scalar_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import pytest
import torch
from executorch.backends.arm.test import common

Expand Down Expand Up @@ -102,7 +101,6 @@ def test_scalar_tensor_u85_INT(test_data):

@common.parametrize("test_data", float_test_data_suite)
@common.SkipIfNoModelConverter
@pytest.mark.xfail(reason="MLETORCH-1410: Tensor dimension count not supported: 0")
def test_scalar_tensor_vgf_FP(test_data):
scalar, dtype, data = test_data()
pipeline = VgfPipeline(
Expand All @@ -116,7 +114,6 @@ def test_scalar_tensor_vgf_FP(test_data):

@common.parametrize("test_data", int_test_data_suite)
@common.SkipIfNoModelConverter
@pytest.mark.xfail(reason="MLETORCH-1410: Tensor dimension count not supported: 0")
def test_scalar_tensor_vgf_INT(test_data):
scalar, dtype, data = test_data()
pipeline = VgfPipeline(
Expand Down
5 changes: 0 additions & 5 deletions backends/arm/test/ops/test_select.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

from typing import Tuple

import pytest
import torch

from executorch.backends.arm.test import common
Expand Down Expand Up @@ -170,7 +169,6 @@ def test_select_int_u85_INT(test_data: Tuple):

@common.parametrize("test_data", test_data_suite)
@common.SkipIfNoModelConverter
@pytest.mark.xfail(reason="MLETORCH-1410: Tensor dimension count not supported: 0")
def test_select_int_vgf_FP_copy(test_data: Tuple):
pipeline = VgfPipeline[input_t1](
SelectCopy(), test_data(), aten_op_copy, [], tosa_version="TOSA-1.0+FP"
Expand All @@ -180,7 +178,6 @@ def test_select_int_vgf_FP_copy(test_data: Tuple):

@common.parametrize("test_data", test_data_suite)
@common.SkipIfNoModelConverter
@pytest.mark.xfail(reason="MLETORCH-1410: Tensor dimension count not supported: 0")
def test_select_int_vgf_FP(test_data: Tuple):
pipeline = VgfPipeline[input_t1](
SelectInt(), test_data(), aten_op_int, [], tosa_version="TOSA-1.0+FP"
Expand All @@ -190,7 +187,6 @@ def test_select_int_vgf_FP(test_data: Tuple):

@common.parametrize("test_data", test_data_suite)
@common.SkipIfNoModelConverter
@pytest.mark.xfail(reason="MLETORCH-1410: Tensor dimension count not supported: 0")
def test_select_int_vgf_INT_copy(test_data: Tuple):
pipeline = VgfPipeline[input_t1](
SelectCopy(),
Expand All @@ -204,7 +200,6 @@ def test_select_int_vgf_INT_copy(test_data: Tuple):

@common.parametrize("test_data", test_data_suite)
@common.SkipIfNoModelConverter
@pytest.mark.xfail(reason="MLETORCH-1410: Tensor dimension count not supported: 0")
def test_select_int_vgf_INT(test_data: Tuple):
pipeline = VgfPipeline[input_t1](
SelectInt(),
Expand Down
7 changes: 0 additions & 7 deletions backends/arm/test/ops/test_var.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

from typing import Tuple

import pytest
import torch

from executorch.backends.arm.test import common
Expand Down Expand Up @@ -214,7 +213,6 @@ def test_var_dim_u85_INT_no_dim(test_data: Tuple):

@common.parametrize("test_data", Var.test_parameters)
@common.SkipIfNoModelConverter
@pytest.mark.xfail(reason="MLETORCH-1410: Tensor dimension count not supported: 0")
def test_var_dim_vgf_FP_no_dim(test_data: Tuple):
data, keepdim, correction = test_data()
pipeline = VgfPipeline[input_t1](
Expand All @@ -225,7 +223,6 @@ def test_var_dim_vgf_FP_no_dim(test_data: Tuple):

@common.parametrize("test_data", Var.test_parameters)
@common.SkipIfNoModelConverter
@pytest.mark.xfail(reason="MLETORCH-1410: Tensor dimension count not supported: 0")
def test_var_dim_vgf_INT_no_dim(test_data: Tuple):
data, keepdim, correction = test_data()
pipeline = VgfPipeline[input_t1](
Expand Down Expand Up @@ -296,7 +293,6 @@ def test_var_dim_u85_INT(test_data: Tuple):

@common.parametrize("test_data", VarDim.test_parameters)
@common.SkipIfNoModelConverter
@pytest.mark.xfail(reason="MLETORCH-1410: Tensor dimension count not supported: 0")
def test_var_dim_vgf_FP(test_data: Tuple):
data, dim, keepdim, unbiased = test_data()
pipeline = VgfPipeline[input_t1](
Expand All @@ -307,7 +303,6 @@ def test_var_dim_vgf_FP(test_data: Tuple):

@common.parametrize("test_data", VarDim.test_parameters)
@common.SkipIfNoModelConverter
@pytest.mark.xfail(reason="MLETORCH-1410: Tensor dimension count not supported: 0")
def test_var_dim_vgf_INT(test_data: Tuple):
data, dim, keepdim, unbiased = test_data()
pipeline = VgfPipeline[input_t1](
Expand Down Expand Up @@ -377,7 +372,6 @@ def test_var_dim_u85_INT_correction(test_data: Tuple):

@common.parametrize("test_data", VarCorrection.test_parameters)
@common.SkipIfNoModelConverter
@pytest.mark.xfail(reason="MLETORCH-1410: Tensor dimension count not supported: 0")
def test_var_dim_vgf_FP_correction(test_data: Tuple):
data, dim, keepdim, corr = test_data()
pipeline = VgfPipeline[input_t1](
Expand All @@ -388,7 +382,6 @@ def test_var_dim_vgf_FP_correction(test_data: Tuple):

@common.parametrize("test_data", VarCorrection.test_parameters)
@common.SkipIfNoModelConverter
@pytest.mark.xfail(reason="MLETORCH-1410: Tensor dimension count not supported: 0")
def test_var_dim_vgf_INT_correction(test_data: Tuple):
data, dim, keepdim, corr = test_data()
pipeline = VgfPipeline[input_t1](
Expand Down
Loading