Skip to content
Merged
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
11 changes: 6 additions & 5 deletions paddle/fluid/framework/attribute.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ limitations under the License. */
namespace paddle {
namespace framework {

paddle::any GetAttrValue(const Attribute& attr);
TEST_API paddle::any GetAttrValue(const Attribute& attr);

Attribute GetAttrValue(const proto::OpDesc::Attr& attr_desc);
TEST_API Attribute GetAttrValue(const proto::OpDesc::Attr& attr_desc);

Attribute GetAttrValue(const proto::VarDesc::Attr& attr_desc);

Expand Down Expand Up @@ -350,9 +350,10 @@ class AttrReader {
};

paddle::experimental::Scalar MakeScalarFromProto(const proto::Scalar& v);
proto::Scalar MakeScalarProto(const paddle::experimental::Scalar& v);
paddle::experimental::Scalar MakeScalarFromAttribute(const Attribute& v);
std::vector<paddle::experimental::Scalar> MakeScalarsFromAttribute(
TEST_API proto::Scalar MakeScalarProto(const paddle::experimental::Scalar& v);
TEST_API paddle::experimental::Scalar MakeScalarFromAttribute(
const Attribute& v);
TEST_API std::vector<paddle::experimental::Scalar> MakeScalarsFromAttribute(
const Attribute& v);
void CanonicalizeScalarAttrs(const proto::OpProto& op_proto,
AttributeMap* attrs);
Expand Down
10 changes: 5 additions & 5 deletions paddle/fluid/framework/data_layout_transform.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ struct CastDataLayout {

std::vector<int> GetAxis(const DataLayout& from, const DataLayout& to);

void TransDataLayout(const phi::KernelKey& kernel_type_for_var,
const phi::KernelKey& expected_kernel_type,
const phi::DenseTensor& in,
phi::DenseTensor* out,
const phi::Place& place);
TEST_API void TransDataLayout(const phi::KernelKey& kernel_type_for_var,
const phi::KernelKey& expected_kernel_type,
const phi::DenseTensor& in,
phi::DenseTensor* out,
const phi::Place& place);

void TransDataLayout(phi::DataLayout from_layout,
phi::DataLayout to_layout,
Expand Down
4 changes: 2 additions & 2 deletions paddle/fluid/framework/data_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace paddle {
namespace framework {

TEST_API std::string DataTypeToString(const proto::VarType::Type type);
extern size_t SizeOfType(proto::VarType::Type type);
TEST_API extern size_t SizeOfType(proto::VarType::Type type);

template <typename T>
struct IsComplex : public std::false_type {};
Expand Down Expand Up @@ -123,7 +123,7 @@ _ForEachDataType_(DefineDataTypeTrait);

#undef DefineDataTypeTrait

extern proto::VarType::Type ToDataType(std::type_index type);
TEST_API extern proto::VarType::Type ToDataType(std::type_index type);
extern std::type_index ToTypeIndex(proto::VarType::Type type);

template <typename Visitor>
Expand Down
8 changes: 4 additions & 4 deletions paddle/fluid/framework/data_type_transform.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ class OpKernelType;

using KernelTypePair = std::pair<OpKernelType, OpKernelType>;

void TransDataType(const phi::KernelKey& kernel_type_for_var,
const phi::KernelKey& expected_kernel_type,
const phi::DenseTensor& in,
phi::DenseTensor* out);
TEST_API void TransDataType(const phi::KernelKey& kernel_type_for_var,
const phi::KernelKey& expected_kernel_type,
const phi::DenseTensor& in,
phi::DenseTensor* out);
void TransDataType(const phi::DenseTensor& in,
const paddle::framework::proto::VarType::Type& type,
phi::DenseTensor* out);
Expand Down
29 changes: 15 additions & 14 deletions paddle/fluid/framework/device_worker.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,21 @@ class Scope;
namespace paddle {
namespace framework {

std::string PrintLodTensor(phi::DenseTensor* tensor,
int64_t start,
int64_t end,
char separator = ',',
bool need_leading_separator = false);
void PrintLodTensor(phi::DenseTensor* tensor,
int64_t start,
int64_t end,
std::string& output_str, // NOLINT
char separator = ',',
bool need_leading_separator = false,
int num_decimals = 9);
std::pair<int64_t, int64_t> GetTensorBound(phi::DenseTensor* tensor, int index);
bool CheckValidOutput(phi::DenseTensor* tensor, size_t batch_size);
TEST_API std::string PrintLodTensor(phi::DenseTensor* tensor,
int64_t start,
int64_t end,
char separator = ',',
bool need_leading_separator = false);
TEST_API void PrintLodTensor(phi::DenseTensor* tensor,
int64_t start,
int64_t end,
std::string& output_str, // NOLINT
char separator = ',',
bool need_leading_separator = false,
int num_decimals = 9);
TEST_API std::pair<int64_t, int64_t> GetTensorBound(phi::DenseTensor* tensor,
int index);
TEST_API bool CheckValidOutput(phi::DenseTensor* tensor, size_t batch_size);

class FleetWrapper;

Expand Down
3 changes: 2 additions & 1 deletion paddle/fluid/framework/dlpack_tensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ class DLPackTensor {
std::remove_reference<decltype(::DLTensor::shape[0])>::type; // int64_t

// lanes is only used in CPU to enable vectorization
explicit DLPackTensor(const phi::DenseTensor& tensor, LaneType lanes = 1);
TEST_API explicit DLPackTensor(const phi::DenseTensor& tensor,
LaneType lanes = 1);

inline operator const ::DLTensor&() const { return t_; }

Expand Down
20 changes: 11 additions & 9 deletions paddle/fluid/framework/lod_tensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,19 @@ limitations under the License. */
#include "paddle/fluid/platform/place.h"
#include "paddle/phi/core/dense_tensor.h"
#include "paddle/phi/core/mixed_vector.h"
#include "paddle/utils/test_macros.h"

namespace paddle {
namespace framework {

// Split phi::DenseTensor and copy to each place specified in places.
std::vector<phi::DenseTensor> SplitLoDTensor(
TEST_API std::vector<phi::DenseTensor> SplitLoDTensor(
const phi::DenseTensor& src, const std::vector<platform::Place> places);

void MergeLoDTensor(phi::DenseTensor* target,
const std::vector<const phi::DenseTensor*>& lod_tensors,
platform::Place dst_place);
TEST_API void MergeLoDTensor(
phi::DenseTensor* target,
const std::vector<const phi::DenseTensor*>& lod_tensors,
platform::Place dst_place);

/*
* LoD is short for Level of Details.
Expand Down Expand Up @@ -65,7 +67,7 @@ LoD SliceInLevel(const LoD& in,
/*
* Transform an LoD from relative offsets to absolute offsets.
*/
LoD ToAbsOffset(const LoD& in);
TEST_API LoD ToAbsOffset(const LoD& in);

TEST_API bool operator==(const LoD& a, const LoD& b);

Expand All @@ -85,7 +87,7 @@ TEST_API bool operator==(const LoD& a, const LoD& b);
* tensor_height>0.
*/

bool CheckLoD(const LoD& in, int tensor_height = -1);
TEST_API bool CheckLoD(const LoD& in, int tensor_height = -1);
/*
* Check whether this absolute lod's format is valid.
*
Expand All @@ -99,7 +101,7 @@ bool CheckLoD(const LoD& in, int tensor_height = -1);
* same(the height of underlying tensor) or `tensor_height` if
* tensor_height>0.
*/
bool CheckAbsLoD(const LoD& in, int tensor_height = -1);
TEST_API bool CheckAbsLoD(const LoD& in, int tensor_height = -1);

/*
* Expand the `source` to fit the LoD of `lod`. For example, a `source`
Expand Down Expand Up @@ -162,7 +164,7 @@ phi::DenseTensor LodExpand(const phi::DenseTensor& source,
// Returns:
// LoD = [[1, 4], [2, 4, 2, 3, 2]]
// pair<size_t, size_t> = {11, 24}
std::pair<LoD, std::pair<size_t, size_t>> GetSubLoDAndAbsoluteOffset(
TEST_API std::pair<LoD, std::pair<size_t, size_t>> GetSubLoDAndAbsoluteOffset(
const LoD& lod, size_t start_idx, size_t end_idx, size_t start_level);

/*
Expand All @@ -182,7 +184,7 @@ void DeserializeFromStream(std::istream& is,
const size_t& seek,
const std::vector<int64_t>& shape);

LoD ConvertToOffsetBasedLoD(const LoD& length_lod);
TEST_API LoD ConvertToOffsetBasedLoD(const LoD& length_lod);

void SerializeToStream(std::ostream& os, const phi::DenseTensor& tensor);

Expand Down
14 changes: 7 additions & 7 deletions paddle/fluid/framework/reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ class ReaderBase {
"and need_check_feed"));
}

virtual void ReadNext(paddle::framework::LoDTensorArray* out);
TEST_API virtual void ReadNext(paddle::framework::LoDTensorArray* out);

virtual void Shutdown();
TEST_API virtual void Shutdown();

virtual void Start();
TEST_API virtual void Start();

// Return the readers which are the end of decorating chain. Basically
// they are readers just before read op.
std::unordered_set<ReaderBase*> GetEndPoints();
TEST_API std::unordered_set<ReaderBase*> GetEndPoints();

// Returns the shapes of the fed variables
const std::vector<DDim>& Shapes() const { return shapes_; }
Expand All @@ -70,7 +70,7 @@ class ReaderBase {
// This function returns whether you have the check shape for this Reader.
const std::vector<bool>& NeedCheckFeed() const { return need_check_feed_; }

virtual ~ReaderBase();
TEST_API virtual ~ReaderBase();

protected:
virtual void ReadNextImpl(paddle::framework::LoDTensorArray* out UNUSED) {}
Expand Down Expand Up @@ -98,7 +98,7 @@ class ReaderBase {
friend class DecoratedReader;
// These methods can be only invoked inside DecoratedReader to record the
// decorating chain.
void InsertDecoratedReader(
TEST_API void InsertDecoratedReader(
const std::shared_ptr<ReaderBase>& decorated_reader);
// A set of which readers that decorated this reader.
std::vector<std::weak_ptr<ReaderBase>> decorated_readers_;
Expand All @@ -121,7 +121,7 @@ class DecoratedReader : public ReaderBase,
reader_->InsertDecoratedReader(shared_from_this());
}

~DecoratedReader();
TEST_API ~DecoratedReader();

const std::shared_ptr<ReaderBase>& UnderlyingReader() const {
return reader_;
Expand Down
15 changes: 8 additions & 7 deletions paddle/fluid/framework/tensor_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ class PrintOptions {
PrintOptions() {}
};

void TensorToStream(std::ostream& os,
const phi::DenseTensor& tensor,
const platform::DeviceContext& dev_ctx);
void TensorFromStream(std::istream& is,
phi::DenseTensor* tensor,
const platform::DeviceContext& dev_ctx);
TEST_API void TensorToStream(std::ostream& os,
const phi::DenseTensor& tensor,
const platform::DeviceContext& dev_ctx);
TEST_API void TensorFromStream(std::istream& is,
phi::DenseTensor* tensor,
const platform::DeviceContext& dev_ctx);
void TensorFromStream(std::istream& is,
phi::DenseTensor* tensor,
const platform::DeviceContext& dev_ctx,
Expand Down Expand Up @@ -107,7 +107,8 @@ void TesnorToVector(const phi::DenseTensor& src, std::vector<T>* dst);

// convert dlpack's DLTensor to tensor

void TensorFromDLPack(const ::DLTensor& dl_tensor, phi::DenseTensor* dst);
TEST_API void TensorFromDLPack(const ::DLTensor& dl_tensor,
phi::DenseTensor* dst);
void TensorFromDLPack(const DLManagedTensor* src, phi::DenseTensor* dst);

//
Expand Down
4 changes: 2 additions & 2 deletions paddle/fluid/framework/var_type_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ namespace paddle {
namespace framework {

TEST_API const char *ToTypeName(int var_id);
const std::type_index &VarTraitIdToTypeIndex(int var_id);
int TypeIndexToVarTraitId(const std::type_index &type);
TEST_API const std::type_index &VarTraitIdToTypeIndex(int var_id);
TEST_API int TypeIndexToVarTraitId(const std::type_index &type);

namespace detail {

Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/memory/memcpy.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace memory {
*
*/
template <typename DstPlace, typename SrcPlace>
void Copy(DstPlace, void* dst, SrcPlace, const void* src, size_t num);
TEST_API void Copy(DstPlace, void* dst, SrcPlace, const void* src, size_t num);

/**
* \brief Copy memory from one place to another place.
Expand Down
4 changes: 2 additions & 2 deletions paddle/phi/common/scalar.h
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,9 @@ void CopyScalar(const ScalarBase<T1>& src, ScalarBase<T2>* dst) {
}

using Scalar = paddle::experimental::ScalarBase<Tensor>;
bool operator==(const Scalar& lhs, const Scalar& rhs);
TEST_API bool operator==(const Scalar& lhs, const Scalar& rhs);

std::ostream& operator<<(std::ostream& os, const Scalar& s);
TEST_API std::ostream& operator<<(std::ostream& os, const Scalar& s);

template <typename T>
std::vector<T> ExtractPlainVector(
Expand Down
2 changes: 1 addition & 1 deletion paddle/phi/core/compat/convert_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace phi {
const std::string& TransToPhiKernelName(const std::string& fluid_op_name);
const std::string& TransToFluidOpName(const std::string& phi_kernel_name);

Backend TransToPhiBackend(const phi::Place& place);
TEST_API Backend TransToPhiBackend(const phi::Place& place);
phi::Place TransToPhiPlace(const Backend& backend, bool set_device_id = true);

#ifdef PADDLE_WITH_DNNL
Expand Down
6 changes: 4 additions & 2 deletions paddle/phi/core/lod_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include <cstddef>
#include <vector>

#include "paddle/utils/test_macros.h"

namespace phi {
using LoD = std::vector<std::vector<std::size_t>>;

Expand All @@ -24,7 +26,7 @@ using LoD = std::vector<std::vector<std::size_t>>;
*/
LoD ToAbsOffset(const LoD& in);

void AppendLoD(LoD* lod, const LoD& lod_length);
TEST_API void AppendLoD(LoD* lod, const LoD& lod_length);

/*
* Convert between length-based LoD and offset-based LoD.
Expand All @@ -36,6 +38,6 @@ void AppendLoD(LoD* lod, const LoD& lod_length);
* If offset_lod = [[0, 2, 3],[0, 3, 5, 9]]
* then length_lod = [[2, 1], [3, 2, 4]]
*/
LoD ConvertToLengthBasedLoD(const LoD& offset_lod);
TEST_API LoD ConvertToLengthBasedLoD(const LoD& offset_lod);

} // namespace phi
3 changes: 2 additions & 1 deletion paddle/phi/core/tensor_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ void TensorToVector(const phi::DenseTensor& src,
const phi::DeviceContext& ctx,
std::vector<T>* dst);

phi::DenseTensor ReshapeToMatrix(const phi::DenseTensor& src, int num_col_dims);
TEST_API phi::DenseTensor ReshapeToMatrix(const phi::DenseTensor& src,
int num_col_dims);

template <typename T>
T GetValue(const phi::DenseTensor* x);
Expand Down
2 changes: 1 addition & 1 deletion paddle/phi/core/threadpool.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class ThreadPool {
std::packaged_task<std::unique_ptr<common::enforce::EnforceNotMet>()>;

// Returns the singleton of ThreadPool.
static ThreadPool* GetInstance();
TEST_API static ThreadPool* GetInstance();

~ThreadPool();

Expand Down
3 changes: 2 additions & 1 deletion paddle/phi/kernels/funcs/data_layout_transform.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ void TransDataLayoutFromOneDNN(DataLayout in_layout,
DenseTensor* out,
Place place,
bool always_copy = false);
void* GetDataFromTensor(const DenseTensor& tensor, OneDNNDataType type);
TEST_API void* GetDataFromTensor(const DenseTensor& tensor,
OneDNNDataType type);

dnnl::memory::desc make_memory_desc(const phi::DenseTensor& ref_tensor,
phi::DataLayout target_layout);
Expand Down
2 changes: 1 addition & 1 deletion paddle/phi/kernels/isfinite_kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace phi {

#define DEFINE_ISFINITE_KERNEL(isfinite_kernel) \
template <typename T, typename Context> \
void isfinite_kernel( \
TEST_API void isfinite_kernel( \
const Context& ctx, const DenseTensor& x, DenseTensor* out);

DEFINE_ISFINITE_KERNEL(IsinfKernel)
Expand Down
10 changes: 5 additions & 5 deletions paddle/phi/kernels/reduce_all_kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ void AllRawKernel(const Context& dev_ctx,
DenseTensor* out);

template <typename T, typename Context>
void AllKernel(const Context& dev_ctx,
const DenseTensor& x,
const std::vector<int64_t>& dims,
bool keep_dim,
DenseTensor* out);
TEST_API void AllKernel(const Context& dev_ctx,
const DenseTensor& x,
const std::vector<int64_t>& dims,
bool keep_dim,
DenseTensor* out);

} // namespace phi
Loading