// Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #pragma once #include "paddle/phi/core/dense_tensor.h" namespace paddle { namespace framework { namespace ir { void Assign(const DenseTensor& in, DenseTensor* out); void Transpose2D(DenseTensor* in, DenseTensor* out = nullptr); void CastTo(DenseTensor* in, DenseTensor* out, DataType dtype); void CastToFp32(DenseTensor* in, DenseTensor* out = nullptr); void CastToFp16(DenseTensor* in, DenseTensor* out = nullptr); void CastToInt32(DenseTensor* in, DenseTensor* out = nullptr); template void ConvertWithoutQuant(DenseTensor* weight, DenseTensor* weight_max, DenseTensor* scale_max, bool transpose, const std::vector& weight_scales); template ::value, Tcpu>::type* ptr = nullptr> void ConvertWithQuant(DenseTensor* weight, DenseTensor* weight_max, DenseTensor* scale_max, bool transpose, bool per_channel_quant = false); template ::value, Tcpu>::type* ptr = nullptr> void ConvertWithQuant(DenseTensor* weight, DenseTensor* weight_max, DenseTensor* scale_max, bool transpose, const std::vector& weight_scales, bool per_channel_quant = false); bool IsPerTensorQuant(const std::vector& weight_max); } // namespace ir } // namespace framework } // namespace paddle