MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / validate

Method validate

src/gpu/cl/kernels/ClScatterKernel.cpp:56–112  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54}
55
56Status ClScatterKernel::validate(const ITensorInfo *updates,
57 const ITensorInfo *indices,
58 const ITensorInfo *dst,
59 const ScatterInfo &info)
60{
61 ARM_COMPUTE_UNUSED(info);
62 ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(updates, indices, dst);
63 ARM_COMPUTE_RETURN_ERROR_ON_SIZE_UNSUPPORTED(updates, indices, dst);
64
65 const TensorShape &ind_shape = indices->tensor_shape();
66 const TensorShape &upt_shape = updates->tensor_shape();
67 const TensorShape &dst_shape = dst->tensor_shape();
68
69 const int32_t upt_dims = upt_shape.num_dimensions();
70 const int32_t dst_dims = dst_shape.num_dimensions();
71 const int32_t ind_dims = ind_shape.num_dimensions();
72 const int32_t data_dim = upt_dims - (ind_dims - 1); // Number of batch dims is the number of indices dims - 1
73
74 const int32_t index_len = ind_shape[0];
75 bool unsupported_padding_config =
76 (dst_dims == index_len) && index_len > 1 && (dst->has_padding() || updates->has_padding());
77
78 ARM_COMPUTE_RETURN_ERROR_ON_MSG(unsupported_padding_config, "Padding is not supported with these shapes.");
79 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(updates, dst);
80 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_NOT_IN(indices, DataType::S32);
81 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_NOT_IN(dst, DataType::F32, DataType::F16, DataType::S32, DataType::S16,
82 DataType::S8, DataType::U32, DataType::U16, DataType::U8);
83
84 // Check data dims in update tensor and output tensor are equal
85 for (int32_t i = 0; i < data_dim; i++)
86 {
87 ARM_COMPUTE_RETURN_ERROR_ON_MSG(upt_shape[i] != dst_shape[i],
88 "Data dims should be same size in both updates and ouput tensor.");
89 }
90
91 // Check if batch dims in indices and updates tensor are equal.
92 for (int32_t i = 0; i < ind_dims - 1; i++)
93 {
94 ARM_COMPUTE_RETURN_ERROR_ON_MSG(upt_shape[data_dim + i] != ind_shape[i + 1],
95 "Batch dimensions should be the same in updates and indices tensor.");
96 }
97
98 ARM_COMPUTE_RETURN_ERROR_ON_MSG(ind_shape[1] != upt_shape[data_dim],
99 "Height of indices tensor should match size of highest dimension in updates tensor "
100 "(Excluding batch dimension)");
101
102 ARM_COMPUTE_RETURN_ERROR_ON_MSG(
103 data_dim >= dst_dims, "Update tensor cannot have more dims than output tensor. (Excluding batch dimensions)");
104 ARM_COMPUTE_RETURN_ERROR_ON(index_len != dst_dims - data_dim);
105 ARM_COMPUTE_RETURN_ERROR_ON_MSG((ind_dims < 2), "Shape of Indices tensor must be at least 2D");
106
107 ARM_COMPUTE_RETURN_ERROR_ON_MSG(index_len > max_index_length, "Maximum supported index length is 5!");
108 ARM_COMPUTE_RETURN_ERROR_ON_MSG(index_len > dst_dims && dst_dims != 1,
109 "Index length should be smaller than or equal to number of output dims");
110
111 return Status{};
112}
113

Callers

nothing calls this directly

Calls 2

num_dimensionsMethod · 0.45
has_paddingMethod · 0.45

Tested by

no test coverage detected