Skip to content

Commit 3d39332

Browse files
committed
format on "Reapply #11294 and #11295 (improve GLU test and implement using internal views to avoid copying)"
These were reverted due to internal test failures. Sending this as an exported internal diff so that we can make sure we get internal signal. Original summary for #11294 (to make the GLU test input asymmetric): This way it will produce different results along each tested dim. Original summaryfor #11295: GLU requires slicing the input Tensor into two halves. Currently, we accomplish this by copying; ExecuTorch does not support views in general because it requires Tensors to be contiguous. However, nothing stops us from implementing [the ATen that uses views](https://github.com/pytorch/pytorch/blob/main/aten/src/ATen/native/GatedLinearUnit.cpp#L35) entirely internally to the op. To support this, I added `support_noncontiguous_tensors` as an optional template argument to BroadcastIndexesRange and plumbed it through to the elementwise_util functions as an optional SupportNonContiguousTensors parameter. Differential Revision: [D76311585](https://our.internmc.facebook.com/intern/diff/D76311585/) [ghstack-poisoned]
1 parent c4b0b45 commit 3d39332

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

kernels/portable/cpu/op_glu.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ namespace {
2626

2727
struct SplitGLUInputTensor {
2828
explicit SplitGLUInputTensor(const Tensor& self, int64_t dim);
29-
using SizesArray = std::array<executorch::aten::SizesType, kTensorDimensionLimit>;
29+
using SizesArray =
30+
std::array<executorch::aten::SizesType, kTensorDimensionLimit>;
3031
SizesArray half_sizes;
3132
TensorImpl first_half_impl;
3233
TensorImpl second_half_impl;
@@ -57,7 +58,7 @@ SplitGLUInputTensor::SplitGLUInputTensor(const Tensor& self, int64_t dim)
5758
self.dim(),
5859
half_sizes.data(),
5960
reinterpret_cast<char*>(self.mutable_data_ptr()) +
60-
self.strides()[dim] * self.size(dim) / 2 * self.element_size(),
61+
self.strides()[dim] * self.size(dim) / 2 * self.element_size(),
6162
const_cast<executorch::aten::DimOrderType*>(self.dim_order().data()),
6263
const_cast<executorch::aten::StridesType*>(self.strides().data()),
6364
self.shape_dynamism()),

0 commit comments

Comments
 (0)