forked from pytorch/xla
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make sure the real sizes are accounted when averaging reduces, to dea…
…l with dynamic shapes.
- Loading branch information
Showing
12 changed files
with
190 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include "torch_xla/csrc/ops/get_dimensions_size.h" | ||
|
||
#include "absl/strings/str_join.h" | ||
#include "tensorflow/compiler/xla/shape_util.h" | ||
#include "tensorflow/compiler/xla/xla_client/util.h" | ||
#include "torch_xla/csrc/helpers.h" | ||
#include "torch_xla/csrc/lowering_context.h" | ||
#include "torch_xla/csrc/ops/xla_ops.h" | ||
|
||
namespace torch_xla { | ||
namespace ir { | ||
namespace ops { | ||
|
||
GetDimensionsSize::GetDimensionsSize(const Value& input, | ||
std::vector<xla::int64> dimensions) | ||
: Node(xla_get_dimensions_size, {input}, | ||
xla::ShapeUtil::MakeShape(xla::PrimitiveType::S32, {}), | ||
/*num_outputs=*/1, xla::util::MHash(dimensions)), | ||
dimensions_(std::move(dimensions)) {} | ||
|
||
NodePtr GetDimensionsSize::Clone(OpList operands) const { | ||
return MakeNode<GetDimensionsSize>(operands.at(0), dimensions_); | ||
} | ||
|
||
XlaOpVector GetDimensionsSize::Lower(LoweringContext* loctx) const { | ||
xla::XlaOp input = loctx->GetOutputOp(operand(0)); | ||
xla::XlaOp output = XlaHelpers::GetDimensionsSize({input}, dimensions_); | ||
return ReturnOp(output, loctx); | ||
} | ||
|
||
std::string GetDimensionsSize::ToString() const { | ||
std::stringstream ss; | ||
ss << Node::ToString() << ", dimensions=(" << absl::StrJoin(dimensions_, ", ") | ||
<< ")"; | ||
return ss.str(); | ||
} | ||
|
||
} // namespace ops | ||
} // namespace ir | ||
} // namespace torch_xla |
10 changes: 6 additions & 4 deletions
10
torch_xla/csrc/ops/get_dimension_size.h → torch_xla/csrc/ops/get_dimensions_size.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.