Files
pytorch/torch/csrc/lazy/ts_backend/ops/expand.cpp
Bin Bao 8f5cdc6d5d Revert "Revert "[LT] Store OpKind for each IR subclass in a static field""
Summary: Re-land https://github.com/pytorch/pytorch/pull/76711 by
fixing internal build errors.
Generate class-level opkind as a static method instead of a static
member.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/77102

Approved by: https://github.com/wconstab, https://github.com/JackCaoG, https://github.com/antoniojkim
2022-05-11 12:27:05 +00:00

30 lines
726 B
C++

#include <torch/csrc/lazy/ts_backend/ops/expand.h>
namespace torch {
namespace lazy {
Expand::Expand(
const Value& input,
std::vector<int64_t> size,
bool is_scalar_expand)
: TsNode(
ClassOpKind(),
{input},
/*num_outputs=*/1,
MHash(size, is_scalar_expand)),
size_(std::move(size)),
is_scalar_expand_(is_scalar_expand) {
addComputedShape(
[&]() { return Shape(input.shape().scalar_type(), size_); });
}
std::string Expand::ToString() const {
std::stringstream ss;
ss << TsNode::ToString() << ", size=(" << c10::Join(", ", size_)
<< "), is_scalar_expand=" << is_scalar_expand_;
return ss.str();
}
} // namespace lazy
} // namespace torch