Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfae41c7

Browse files
Merge pull request#59998 from tensorflow/fix-bad-cherrypick-again
Fix bad cherrypick
2 parentsc78616f +2757416 commitfae41c7

File tree

2 files changed

+0
-132
lines changed

2 files changed

+0
-132
lines changed

‎tensorflow/core/tpu/ops/tpu_partitioned_input_op.cc‎

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -124,85 +124,4 @@ REGISTER_OP("TPUPartitionedInput")
124124
returnOkStatus();
125125
});
126126

127-
REGISTER_OP("TPUPartitionedInputV2")
128-
.Input("inputs: N * T")
129-
.Output("output: T")
130-
.Attr("N: int >= 1")
131-
.Attr("T: type")
132-
.Attr("partition_dims: list(int)")
133-
.Attr("is_packed: bool = false")
134-
.SetShapeFn([](InferenceContext* c) {
135-
DataType dtype;
136-
TF_RETURN_IF_ERROR(c->GetAttr("T", &dtype));
137-
std::vector<int> partition_dims;
138-
TF_RETURN_IF_ERROR(c->GetAttr("partition_dims", &partition_dims));
139-
bool is_packed;
140-
TF_RETURN_IF_ERROR(c->GetAttr("is_packed", &is_packed));
141-
142-
int num_partitions =1;
143-
for (constint& partition_dim : partition_dims) {
144-
num_partitions *= partition_dim;
145-
}
146-
147-
bool replicated = partition_dims.empty();
148-
int num_inputs_expected = is_packed ?1 : num_partitions;
149-
if (!((replicated && !is_packed) ||
150-
(c->num_inputs() == num_inputs_expected))) {
151-
// we cannot validate the number of inputs for replicated, unpacked ops
152-
// since we cannot infer the number of partitions from partition_dims
153-
returnerrors::InvalidArgument("Expected", num_inputs_expected,
154-
" inputs, got", c->num_inputs(),".");
155-
}elseif (c->num_inputs() ==0) {
156-
returnerrors::InvalidArgument(
157-
"Expected at least one input to TPUPartitionedInputV2.");
158-
}
159-
160-
ShapeHandle output_shape;
161-
if (dtype == DT_RESOURCE) {
162-
ShapeHandle previous_shape_handle;
163-
const std::vector<shape_inference::ShapeAndType>* shapes_and_types =
164-
nullptr;
165-
for (int i = c->num_inputs() -1; i >=0; --i) {
166-
shapes_and_types = c->input_handle_shapes_and_types(i);
167-
if (shapes_and_types) {
168-
ShapeHandle shape_handle = shapes_and_types->at(0).shape;
169-
if (!c->FullyDefined(shape_handle)) {
170-
returnerrors::InvalidArgument("Inputs must have static shape,",
171-
"input[", i,
172-
"] has unknown dimension.");
173-
}
174-
175-
if (i != c->num_inputs() -1) {
176-
ShapeHandle tmp;
177-
if (!c->Merge(shape_handle, previous_shape_handle, &tmp).ok()) {
178-
returnerrors::InvalidArgument(
179-
"Inputs must have the same shape.");
180-
}
181-
}else {
182-
previous_shape_handle = shape_handle;
183-
}
184-
}
185-
}
186-
187-
if (shapes_and_types) {
188-
TF_ASSIGN_OR_RETURN(
189-
output_shape,
190-
_ComputeOutputShape(c, previous_shape_handle, partition_dims));
191-
std::vector<shape_inference::ShapeAndType> output_shapes_and_types;
192-
output_shapes_and_types.push_back(shape_inference::ShapeAndType(
193-
output_shape, shapes_and_types->at(0).dtype));
194-
c->set_output_handle_shapes_and_types(0, output_shapes_and_types);
195-
}
196-
}
197-
198-
if (!c->FullyDefined(output_shape)) {
199-
TF_ASSIGN_OR_RETURN(
200-
output_shape,_ComputeOutputShape(c, c->input(0), partition_dims));
201-
}
202-
203-
c->set_output(0, output_shape);
204-
205-
returnOkStatus();
206-
});
207-
208127
}// namespace tensorflow

‎tensorflow/core/tpu/ops/tpu_partitioned_output_op.cc‎

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -70,55 +70,4 @@ REGISTER_OP("TPUPartitionedOutput")
7070
returnOkStatus();
7171
});
7272

73-
REGISTER_OP("TPUPartitionedOutputV2")
74-
.Input("inputs: T")
75-
.Output("output: num_splits * T")
76-
.Attr("T: type")
77-
.Attr("num_splits: int >= 1")
78-
.Attr("partition_dims: list(int)")
79-
.SetShapeFn([](InferenceContext* c) {
80-
DataType dtype;
81-
TF_RETURN_IF_ERROR(c->GetAttr("T", &dtype));
82-
std::vector<int> partition_dims;
83-
TF_RETURN_IF_ERROR(c->GetAttr("partition_dims", &partition_dims));
84-
int num_splits;
85-
TF_RETURN_IF_ERROR(c->GetAttr("num_splits", &num_splits));
86-
if (dtype == DT_RESOURCE) {
87-
returnerrors::Unimplemented("Not implemented.");
88-
}elseif (c->num_inputs() ==0) {
89-
returnerrors::InvalidArgument(
90-
"Expected at least one input to TPUPartitionedOutputV2.");
91-
}
92-
93-
ShapeHandle handle = c->input(0);
94-
int rank =InferenceContext::Rank(handle);
95-
int num_cores_per_replica =1;
96-
for (constint& partition_dim : partition_dims) {
97-
num_cores_per_replica *= partition_dim;
98-
}
99-
100-
if (num_splits != num_cores_per_replica) {
101-
returnerrors::InvalidArgument("Expected", num_cores_per_replica,
102-
" splits.");
103-
}elseif (rank > (int)partition_dims.size()) {
104-
returnerrors::InvalidArgument("Expected at least", rank,
105-
" partition dimensions.");
106-
}
107-
108-
for (int i =0; i < rank; ++i) {
109-
shape_inference::DimensionHandle dim;
110-
TF_RETURN_WITH_CONTEXT_IF_ERROR(
111-
c->Divide(c->Dim(handle, i), partition_dims[i],
112-
true/* evenly_divisible*/, &dim),
113-
"Number of ways to split should evenly divide the split dimension");
114-
TF_CHECK_OK(c->ReplaceDim(handle, i, dim, &handle));
115-
}
116-
117-
for (int i = num_splits -1; i >=0; --i) {
118-
c->set_output(i, handle);
119-
}
120-
121-
returnOkStatus();
122-
});
123-
12473
}// namespace tensorflow

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp