Make Tensor::Move() forward quantization parameters.
PiperOrigin-RevId: 509951145
This commit is contained in:
parent
796a96d842
commit
3d4ed305bc
|
@ -399,6 +399,7 @@ void Tensor::Move(Tensor* src) {
|
|||
valid_ = src->valid_;
|
||||
src->valid_ = kValidNone;
|
||||
shape_ = src->shape();
|
||||
quantization_parameters_ = src->quantization_parameters();
|
||||
element_type_ = src->element_type();
|
||||
src->element_type_ = ElementType::kNone; // Mark as invalidated.
|
||||
cpu_buffer_ = src->cpu_buffer_;
|
||||
|
|
|
@ -42,7 +42,8 @@ TEST(Cpu, TestMemoryAllocation) {
|
|||
}
|
||||
|
||||
TEST(Cpu, TestTensorMove) {
|
||||
Tensor t1(Tensor::ElementType::kFloat32, Tensor::Shape{4, 3, 2, 3});
|
||||
Tensor t1(Tensor::ElementType::kFloat32, Tensor::Shape{4, 3, 2, 3},
|
||||
Tensor::QuantizationParameters(0.5, 127));
|
||||
void* p1 = t1.GetCpuWriteView().buffer<float>();
|
||||
EXPECT_NE(p1, nullptr);
|
||||
Tensor t2(std::move(t1));
|
||||
|
@ -50,6 +51,10 @@ TEST(Cpu, TestTensorMove) {
|
|||
EXPECT_EQ(t1.bytes(), 0); // NOLINT
|
||||
void* p2 = t2.GetCpuWriteView().buffer<float>();
|
||||
EXPECT_EQ(p1, p2);
|
||||
EXPECT_EQ(t1.quantization_parameters().scale,
|
||||
t2.quantization_parameters().scale);
|
||||
EXPECT_EQ(t1.quantization_parameters().zero_point,
|
||||
t2.quantization_parameters().zero_point);
|
||||
}
|
||||
|
||||
TEST(Cpu, TestViewMove) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user