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

[IFRT] Compile error hotfix #641

Open
wants to merge 2 commits into
base: ss/ifrt
Choose a base branch
from
Open
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 deps/ReactantExtra/src/ifrt/LoadedExecutable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ extern "C" ExecuteOptions* ifrt_executeoptions_ctor(int32_t launch_id, span<int>
absl::flat_hash_set<int> non_donatable_input_indices; // TODO conversion
std::optional<AttributeMap> custom_options = std::nullopt;

return new ExecuteOptions(launch_id, non_donatable_input_indices, fill_status, custom_options);
return new ExecuteOptions{launch_id, non_donatable_input_indices, fill_status, custom_options};
}

extern "C" void ifrt_executeoptions_dtor(ExecuteOptions* exec_opts)
Expand Down
8 changes: 4 additions & 4 deletions deps/ReactantExtra/src/memory_management.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
#include <memory>
#include "src/memory_management.hpp"
#include "llvm/Support/ExtensibleRTTI.h"
#include "xla/tsl/concurrency/ref_count.h"
#include "xla/python/ifrt/array.h"

std::map<void*, std::shared_ptr<void>> captured_shared_ptr;
std::map<void*, tsl::RCReference<void>> captured_rcreference;
std::map<void*, tsl::RCReference<xla::ifrt::Array>> captured_rcreference;

extern "C" void reactant_release_shared(void* ptr) {
captured_shared_ptr.erase(ptr);
Expand All @@ -22,7 +22,7 @@ void* reactant::capture_shared(std::shared_ptr<void> ptr) {
}

template<>
void* reactant::capture_rcreference(tsl::RCReference<void> ptr) {
void* reactant::capture_rcreference(tsl::RCReference<xla::ifrt::Array> ptr) {
captured_rcreference[ptr.get()] = ptr;
return ptr.get();
}
Expand All @@ -40,7 +40,7 @@ std::shared_ptr<void> reactant::get_shared(void* ptr) {
return captured_shared_ptr[ptr];
}

tsl::RCReference<void> reactant::get_rcreference(void* ptr) {
tsl::RCReference<xla::ifrt::Array> reactant::get_rcreference(void* ptr) {
return captured_rcreference[ptr];
}

Expand Down
10 changes: 8 additions & 2 deletions deps/ReactantExtra/src/memory_management.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ extern "C" bool reactant_contains_shared(void* ptr);
extern "C" void reactant_release_rcreference(void* ptr);
extern "C" bool reactant_contains_rcreference(void* ptr);

namespace xla {
namespace ifrt {
class Array;
} // namespace ifrt
} // namespace xla

namespace reactant {
template <typename T, typename G = std::remove_cv_t<T>>
inline G* capture_shared(std::shared_ptr<T> ptr) {
Expand All @@ -30,7 +36,7 @@ inline G* capture_rcreference(tsl::RCReference<T> ptr) {
}

template<>
void* capture_rcreference(tsl::RCReference<void> ptr);
void* capture_rcreference(tsl::RCReference<xla::ifrt::Array> ptr);

template<typename T>
inline void destruct_or_release_if_shared(T* ptr) {
Expand Down Expand Up @@ -64,7 +70,7 @@ std::shared_ptr<T> get_or_insert_rcreference(T* ptr) {
return std::reinterpret_pointer_cast<T>(get_rcreference(ptr));
}

std::shared_ptr<void> get_rcreference(void* ptr);
tsl::RCReference<xla::ifrt::Array> get_rcreference(void* ptr);

// TODO here we might have `std::shared_ptr` but also `tsl::RCReference`. what do we put?
// do we use polymorphism here and return a `Holder*` (pointer to abstract base class) or do we explicitly return a `StdSharedHolder*`/`TslRCReferenceHolder*` (pointer to derived class)?
Expand Down