Skip to content
Closed
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
2 changes: 1 addition & 1 deletion kernels/quantized/cpu/op_embedding4b.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ void resize_out_tensor(
for (size_t i = 0; i < indices.dim(); i++) {
expected_output_size[i] = indices.size(i);
}
const size_t embedding_dim = weight.size(1);
const size_t embedding_dim = weight.size(1) * 2;
expected_output_size[out.dim() - 1] = embedding_dim;

exec_aten::ArrayRef<exec_aten::SizesType> output_size{
Expand Down
15 changes: 15 additions & 0 deletions kernels/quantized/test/op_embedding4b_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using namespace ::testing;
using exec_aten::ArrayRef;
using exec_aten::optional;
using exec_aten::RuntimeContext;
using exec_aten::ScalarType;
using exec_aten::Tensor;
using torch::executor::native::quantized_embedding_4bit_out;
Expand Down Expand Up @@ -60,6 +61,20 @@ TEST(OpQuantizedEmbedding4bTest, TestGroupWiseQuantizedEmbedding) {

EXPECT_TENSOR_EQ(out, expected);

out = tf.zeros({3, 4});
auto context = RuntimeContext();
torch::executor::native::quantized_embedding_4bit_out(
context,
qweight,
weight_scales,
weight_zero_points,
quant_min,
quant_max,
indices,
out);

EXPECT_TENSOR_EQ(out, expected);

// Groupwise quantization. groupsize = 2
weight_scales = tf.make({3, 2}, {0.5, 1.0, 1.5, 2.0, 2.5, 3.0});
weight_zero_points = tf.make({3, 2}, {1, -5, 0, 2, -3, -1});
Expand Down