【发布时间】:2022-01-09 13:44:16
【问题描述】:
我正在向 XLA 编写一个纯 C FFI 层,并希望返回一个指向 GlobalData 的指针,由 xla::LocalClient.TransferToServer(...) 生成。我尝试在免费商店创建一个新的GlobalData,因为源代码中的 cmets 说
// Unregisters the wrapped handle, which causes the service to
// deallocate the associated data.
~GlobalData();
我也释放栈拷贝的句柄,如
xla::GlobalData* fn(xla::LocalClient* client, xla::Literal literal) {
std::unique_ptr<xla::GlobalData> global_data =
client.TransferToServer(literal).ConsumeValueOrDie();
xla::GlobalData* global_data_non_stack =
new xla::GlobalData(client.stub(), global_data->handle());
std::vector<std::unique_ptr<xla::GlobalData>> to_release;
to_release.push_back(std::move(global_data));
xla::GlobalData::Release(std::move(to_release));
return global_data_non_stack;
}
但它不起作用。它似乎仍在释放句柄,所以当我 client.ExecuteAndTransfer(...) 看到时
2022-01-09 13:42:23.862961: F tensorflow/core/platform/statusor.cc:33] Attempting to fetch value instead of handling error Invalid argument: global data handle 1 was previously deallocated, failed to resolve allocation for parameter 0
我也尝试过client.Unregister(*global_data),但没有帮助。
【问题讨论】:
标签: c++ tensorflow tensorflow-xla