Skip to content

Commit d2c1dc5

Browse files
vksnkxnnpack-bot
authored andcommitted
Adjust bounds for elementwise unary kernels with sub-byte inputs.
PiperOrigin-RevId: 914454486
1 parent d0004f8 commit d2c1dc5

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

ynnpack/subgraph/elementwise.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,11 @@ ynn_status create_unary(const ynn_node& node, ynn_runtime& runtime,
236236
x.make_buffer(runtime);
237237
std::vector<slinky::var> dims = runtime.globals.make_dims(x.rank());
238238
slinky::box_expr bounds = make_elementwise_bounds(dims, a.physical_extents());
239-
239+
if (!bounds.empty() &&
240+
type_element_count(a.type) > type_element_count(x.type)) {
241+
bounds[0] =
242+
bounds[0] * type_element_count(x.type) / type_element_count(a.type);
243+
}
240244
slinky::call_stmt::attributes attrs;
241245
attrs.name = to_string(std::get<ynn_node::unary_elementwise>(node.op).op);
242246
attrs.allow_in_place = compute_allow_in_place(node, *runtime.subgraph);

0 commit comments

Comments
 (0)