Skip to content
Open
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
9 changes: 9 additions & 0 deletions kernels/portable/cpu/op_convolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,15 @@ void convolution_wrapper(
bool transposed,
int64_t groups,
Tensor& out) {
// Defense-in-depth: get_load_to_compute_fn returns nullptr (and sets
// ctx.fail()) when bias' scalar_type is outside the dispatcher's
// supported set. check_convolution_args() in kernel_ops_util.cpp now
// rejects such bias tensors at the trust boundary, but we keep this guard
// so any future caller of convolution_wrapper is safe; load_bias is
// dereferenced inside the wrapper / conv2d_impl whenever bias has data.
if (bias.has_value() && load_bias == nullptr) {
return;
}
SizesArrayRef in_sizes = in.sizes();
SizesArrayRef weight_sizes = weight.sizes();
SizesArrayRef out_sizes = out.sizes();
Expand Down
8 changes: 8 additions & 0 deletions kernels/portable/cpu/op_cumsum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ void cumsum_tensors(
if (self.numel() == 0) {
return;
}
// Defense-in-depth: get_load_to_compute_fn returns nullptr (and sets
// ctx.fail()) when the input tensor's scalar_type is outside the dispatcher's
// supported set. check_cumsum_args() in kernel_ops_util.cpp now rejects such
// inputs at the trust boundary, but we keep this guard so any future caller
// of cumsum_tensors is safe.
if (load_self == nullptr) {
return;
}

const char* const input_data_base =
reinterpret_cast<const char*>(self.const_data_ptr());
Expand Down
8 changes: 8 additions & 0 deletions kernels/portable/cpu/util/kernel_ops_util.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
Expand Down Expand Up @@ -380,6 +380,8 @@
int64_t groups,
const Tensor& out) {
ET_LOG_AND_RETURN_IF_FALSE(tensors_have_same_dtype(in, weight, out));
ET_LOG_AND_RETURN_IF_FALSE(
executorch::runtime::tensor_is_realhbf16_type(in));

ET_LOG_AND_RETURN_IF_FALSE(tensor_is_default_or_channels_last_dim_order(in));
ET_LOG_AND_RETURN_IF_FALSE(
Expand All @@ -395,6 +397,8 @@

if (bias.has_value()) {
ET_LOG_AND_RETURN_IF_FALSE(tensor_is_rank(bias.value(), 1));
ET_LOG_AND_RETURN_IF_FALSE(
executorch::runtime::tensor_is_realhbf16_type(bias.value()));
ET_CHECK_OR_RETURN_FALSE(
bias.value().size(0) == transposed ? groups * weight.size(1)
: weight.size(0),
Expand Down Expand Up @@ -510,6 +514,10 @@
optional<ScalarType> dtype,
Tensor& out) {
ET_LOG_AND_RETURN_IF_FALSE(dim_is_valid(dim, in.dim()));
ET_LOG_AND_RETURN_IF_FALSE(
executorch::runtime::tensor_is_realhbbf16_type(in));
ET_LOG_AND_RETURN_IF_FALSE(
executorch::runtime::tensor_is_realhbbf16_type(out));

if (dtype.has_value()) {
ET_LOG_AND_RETURN_IF_FALSE(dtype.value() == out.scalar_type());
Expand Down
Loading