Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【paddle_test No.30】replace cc_test with paddle_test #61462

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from 18 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
31 changes: 16 additions & 15 deletions paddle/fluid/distributed/auto_parallel/dist_attr.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ using phi::distributed::auto_parallel::OperatorDistAttrProto;

constexpr const char* kDefault = "default";

std::vector<int64_t> get_tensor_shape(const VarDesc* tensor);
TEST_API std::vector<int64_t> get_tensor_shape(const VarDesc* tensor);

class OperatorDistAttr {
public:
OperatorDistAttr() = default;

explicit OperatorDistAttr(const OpDesc& op);
TEST_API explicit OperatorDistAttr(const OpDesc& op);

OperatorDistAttr(const OperatorDistAttr& dist_attr);

Expand Down Expand Up @@ -90,7 +90,7 @@ class OperatorDistAttr {
return output_dist_attrs_;
}

void set_output_dist_attrs(
TEST_API void set_output_dist_attrs(
const std::map<std::string, TensorDistAttr>& dist_attrs);

const TensorDistAttr& input_dist_attr(const std::string& name) const {
Expand All @@ -101,8 +101,8 @@ class OperatorDistAttr {
return input_dist_attrs_.at(name);
}

void set_input_dist_attr(const std::string& name,
const TensorDistAttr& dist_attr);
TEST_API void set_input_dist_attr(const std::string& name,
const TensorDistAttr& dist_attr);

const TensorDistAttr& output_dist_attr(const std::string& name) const {
return output_dist_attrs_.at(name);
Expand All @@ -112,12 +112,12 @@ class OperatorDistAttr {
return output_dist_attrs_.at(name);
}

void set_output_dist_attr(const std::string& name,
const TensorDistAttr& dist_attr);
TEST_API void set_output_dist_attr(const std::string& name,
const TensorDistAttr& dist_attr);

const ProcessMesh& process_mesh() const { return process_mesh_; }

void set_process_mesh(const ProcessMesh& process_mesh);
TEST_API void set_process_mesh(const ProcessMesh& process_mesh);

const std::string& op_type() const { return op_type_; }

Expand Down Expand Up @@ -185,9 +185,9 @@ class OperatorDistAttr {
return annotated_.count(name) == 1 && annotated_.at(name) == true;
}

void mark_annotated(const std::string& name);
TEST_API void mark_annotated(const std::string& name);

void clear_annotated();
TEST_API void clear_annotated();

const std::vector<int64_t>& input_dims_mapping(const std::string& name) const;

Expand All @@ -211,18 +211,18 @@ class OperatorDistAttr {

bool verify_annotated(const std::map<std::string, bool>& annotated) const;

bool verify(const OpDesc* op = nullptr) const;
TEST_API bool verify(const OpDesc* op = nullptr) const;

void rename_input(const std::string& old_name, const std::string& new_name);

void rename_output(const std::string& old_name, const std::string& new_name);

// OperatorDistAttr from_string(const std::string& dist_str);
std::string to_string() const;
TEST_API std::string to_string() const;

void from_proto(const OperatorDistAttrProto& proto);
TEST_API void from_proto(const OperatorDistAttrProto& proto);

OperatorDistAttrProto to_proto() const;
TEST_API OperatorDistAttrProto to_proto() const;

std::string serialize_to_string();

Expand Down Expand Up @@ -262,7 +262,8 @@ inline std::ostream& operator<<(std::ostream& os, const OperatorDistAttr& obj) {
return os;
}

bool operator==(const OperatorDistAttr& lhs, const OperatorDistAttr& rhs);
TEST_API bool operator==(const OperatorDistAttr& lhs,
const OperatorDistAttr& rhs);

inline bool operator!=(const OperatorDistAttr& lhs,
const OperatorDistAttr& rhs) {
Expand Down
32 changes: 16 additions & 16 deletions paddle/phi/core/distributed/auto_parallel/device_mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class DeviceCapabilityProto;
class DeviceProto;
class LinkCapabilityProto;
class LinkProto;
class DeviceMeshProto;
class TEST_API DeviceMeshProto;

struct DeviceCapability {
double single_precision_flops = 0.0;
Expand Down Expand Up @@ -77,7 +77,7 @@ class Device {
}

// Device from_string(const std::string& mesh_str);
std::string to_string() const;
TEST_API std::string to_string() const;

static Device from_proto(const DeviceProto& proto);
void to_proto(DeviceProto* proto) const;
Expand All @@ -95,7 +95,7 @@ inline std::ostream& operator<<(std::ostream& os, const Device& obj) {
return os;
}

bool operator==(const Device& lhs, const Device& rhs);
TEST_API bool operator==(const Device& lhs, const Device& rhs);

inline bool operator!=(const Device& lhs, const Device& rhs) {
return !operator==(lhs, rhs);
Expand Down Expand Up @@ -134,7 +134,7 @@ class Link {
}

// Link from_string(const std::string& str);
std::string to_string() const;
TEST_API std::string to_string() const;

static Link from_proto(const LinkProto& proto);
void to_proto(LinkProto* proto) const;
Expand All @@ -151,7 +151,7 @@ inline std::ostream& operator<<(std::ostream& os, const Link& obj) {
return os;
}

bool operator==(const Link& lhs, const Link& rhs);
TEST_API bool operator==(const Link& lhs, const Link& rhs);

inline bool operator!=(const Link& lhs, const Link& rhs) {
return !operator==(lhs, rhs);
Expand Down Expand Up @@ -203,10 +203,10 @@ class DeviceMesh {
public:
DeviceMesh() = default;

DeviceMesh(const std::string& name,
const std::vector<int64_t>& shape,
const std::vector<int64_t>& device_ids,
const std::vector<std::string>& dim_names);
TEST_API DeviceMesh(const std::string& name,
const std::vector<int64_t>& shape,
const std::vector<int64_t>& device_ids,
const std::vector<std::string>& dim_names);

const std::string& name() const { return name_; }

Expand Down Expand Up @@ -251,7 +251,7 @@ class DeviceMesh {
return machines_.at(machine_id);
}

int64_t size() const;
TEST_API int64_t size() const;
int64_t ndim() const { return shape_.size(); }

int64_t dim_size(int64_t dim) const {
Expand All @@ -270,15 +270,15 @@ class DeviceMesh {
}

bool empty() const { return (shape_.empty() || device_ids_.empty()); }
bool contains(int64_t device_id) const;
TEST_API bool contains(int64_t device_id) const;

void add_device(const Device& device);
void add_link(const Link& link);
TEST_API void add_device(const Device& device);
TEST_API void add_link(const Link& link);

// DeviceMesh from_string(const std::string& mesh_str);
std::string to_string() const;
TEST_API std::string to_string() const;

static DeviceMesh from_proto(const DeviceMeshProto& proto);
TEST_API static DeviceMesh from_proto(const DeviceMeshProto& proto);
void to_proto(DeviceMeshProto* proto) const;

private:
Expand All @@ -296,7 +296,7 @@ inline std::ostream& operator<<(std::ostream& os, const DeviceMesh& obj) {
return os;
}

bool operator==(const DeviceMesh& lhs, const DeviceMesh& rhs);
TEST_API bool operator==(const DeviceMesh& lhs, const DeviceMesh& rhs);

inline bool operator!=(const DeviceMesh& lhs, const DeviceMesh& rhs) {
return !operator==(lhs, rhs);
Expand Down
4 changes: 2 additions & 2 deletions paddle/phi/core/distributed/auto_parallel/dist_attr.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace phi {
namespace distributed {

namespace auto_parallel {
class TensorDistAttrProto;
class TEST_API TensorDistAttrProto;
}

constexpr int kReplicateDim = -1;
Expand Down Expand Up @@ -216,7 +216,7 @@ inline std::ostream& operator<<(std::ostream& os, const TensorDistAttr& obj) {
return os;
}

bool operator==(const TensorDistAttr& lhs, const TensorDistAttr& rhs);
TEST_API bool operator==(const TensorDistAttr& lhs, const TensorDistAttr& rhs);

inline bool operator!=(const TensorDistAttr& lhs, const TensorDistAttr& rhs) {
return !operator==(lhs, rhs);
Expand Down
19 changes: 10 additions & 9 deletions paddle/phi/core/distributed/auto_parallel/process_mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,24 @@ namespace phi {
namespace distributed {

namespace auto_parallel {
class ProcessMeshProto;
class TEST_API ProcessMeshProto;
}

class ProcessMesh {
public:
ProcessMesh() = default;

ProcessMesh(const std::vector<int64_t>& shape,
const std::vector<int64_t>& process_ids,
const std::vector<std::string>& dim_names);
TEST_API ProcessMesh(const std::vector<int64_t>& shape,
const std::vector<int64_t>& process_ids,
const std::vector<std::string>& dim_names);

const std::vector<int64_t>& shape() const { return shape_; }

const std::vector<int64_t>& process_ids() const { return process_ids_; }

const std::vector<std::string>& dim_names() const { return dim_names_; }

int64_t size() const;
TEST_API int64_t size() const;

int64_t ndim() const { return shape_.size(); }

Expand All @@ -65,12 +65,13 @@ class ProcessMesh {
}

bool empty() const { return (shape_.empty() || process_ids_.empty()); }
bool contains(int64_t process_id) const;
TEST_API bool contains(int64_t process_id) const;

// ProcessMesh from_string(const std::string& mesh_str);
std::string to_string() const;
TEST_API std::string to_string() const;

static ProcessMesh from_proto(const auto_parallel::ProcessMeshProto& proto);
TEST_API static ProcessMesh from_proto(
const auto_parallel::ProcessMeshProto& proto);
void to_proto(auto_parallel::ProcessMeshProto* proto) const;

private:
Expand All @@ -84,7 +85,7 @@ inline std::ostream& operator<<(std::ostream& os, const ProcessMesh& obj) {
return os;
}

bool operator==(const ProcessMesh& lhs, const ProcessMesh& rhs);
TEST_API bool operator==(const ProcessMesh& lhs, const ProcessMesh& rhs);

inline bool operator!=(const ProcessMesh& lhs, const ProcessMesh& rhs) {
return !operator==(lhs, rhs);
Expand Down
3 changes: 2 additions & 1 deletion paddle/phi/core/distributed/auto_parallel/proto_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
namespace phi {
namespace distributed {

auto_parallel::TensorDistAttrProto to_proto(const TensorDistAttr& dist_attr) {
TEST_API auto_parallel::TensorDistAttrProto to_proto(
const TensorDistAttr& dist_attr) {
Liyulingyue marked this conversation as resolved.
Show resolved Hide resolved
TO_PROTO_HELPER(dist_attr, auto_parallel::TensorDistAttrProto);
}

Expand Down
3 changes: 2 additions & 1 deletion paddle/phi/core/distributed/auto_parallel/proto_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#pragma once
#include "paddle/phi/core/distributed/auto_parallel/auto_parallel.pb.h"
#include "paddle/utils/test_macros.h"
namespace phi {
namespace distributed {
class TensorDistAttr;
Expand All @@ -27,7 +28,7 @@ class DeviceMesh;
class DistributedMapper;
} // namespace auto_parallel
auto_parallel::TensorDistAttrProto to_proto(const TensorDistAttr& dist_attr);
auto_parallel::ProcessMeshProto to_proto(const ProcessMesh& dist_attr);
TEST_API auto_parallel::ProcessMeshProto to_proto(const ProcessMesh& dist_attr);

auto_parallel::DeviceCapabilityProto to_proto(
const auto_parallel::DeviceCapability& device_capibilty);
Expand Down
14 changes: 4 additions & 10 deletions test/cpp/auto_parallel/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
cc_test(device_mesh_test SRCS device_mesh_test.cc)
paddle_test(device_mesh_test SRCS device_mesh_test.cc)

cc_test(process_mesh_test SRCS process_mesh_test.cc)
paddle_test(process_mesh_test SRCS process_mesh_test.cc)

cc_test(
dist_attr_test
SRCS dist_attr_test.cc
DEPS proto_desc)
paddle_test(dist_attr_test SRCS dist_attr_test.cc)

if(WITH_DISTRIBUTE)
cc_library(spmd_rule_test_util SRCS spmd_rule_test_util.cc)
add_dependencies(spmd_rule_test_util spmd_rules)
cc_test(
dist_tensor_test
SRCS dist_tensor_test.cc
DEPS phi common)
paddle_test(dist_tensor_test SRCS dist_tensor_test.cc DEPS common)

paddle_test(spmd_rule_test SRCS spmd_rule_test.cc DEPS spmd_rule_test_util
spmd_rules)
Expand Down