mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Also Back out "Revert D39075159: [acc_tensor] Use SymIntArrayRef for overloaded empty.memory_format's signature" Original commit changeset: dab4a9dba4fa Original commit changeset: dcaf16c037a9 Original Phabricator Diff: D38984222 Original Phabricator Diff: D39075159 Also update Metal registrations for C++ registration changes. Also update NNPI registration to account for tightened schema checking Differential Revision: [D39084762](https://our.internmc.facebook.com/intern/diff/D39084762/) **NOTE FOR REVIEWERS**: This PR has internal Facebook specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D39084762/)! Pull Request resolved: https://github.com/pytorch/pytorch/pull/84173 Approved by: https://github.com/Krovatkin
42 lines
923 B
C++
42 lines
923 B
C++
#include <torch/custom_class.h>
|
|
#include <torch/script.h>
|
|
|
|
namespace torch {
|
|
namespace jit {
|
|
|
|
struct ScalarTypeClass : public torch::CustomClassHolder {
|
|
ScalarTypeClass(at::ScalarType s) : scalar_type_(s) {}
|
|
at::ScalarType scalar_type_;
|
|
};
|
|
|
|
template <class T>
|
|
struct MyStackClass : torch::CustomClassHolder {
|
|
std::vector<T> stack_;
|
|
MyStackClass(std::vector<T> init) : stack_(init.begin(), init.end()) {}
|
|
|
|
void push(T x) {
|
|
stack_.push_back(x);
|
|
}
|
|
T pop() {
|
|
auto val = stack_.back();
|
|
stack_.pop_back();
|
|
return val;
|
|
}
|
|
|
|
c10::intrusive_ptr<MyStackClass> clone() const {
|
|
return c10::make_intrusive<MyStackClass>(stack_);
|
|
}
|
|
|
|
void merge(const c10::intrusive_ptr<MyStackClass>& c) {
|
|
for (auto& elem : c->stack_) {
|
|
push(elem);
|
|
}
|
|
}
|
|
|
|
std::tuple<double, int64_t> return_a_tuple() const {
|
|
return std::make_tuple(1337.0f, 123);
|
|
}
|
|
};
|
|
} // namespace jit
|
|
} // namespace torch
|