MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / TridiagonalSolveShapeFn

Function TridiagonalSolveShapeFn

tensorflow/core/ops/linalg_ops.cc:261–287  ·  view source on GitHub ↗

The first input is [...,3,M] and second input is [...,M,K]. Output is [...,M,K].

Source from the content-addressed store, hash-verified

259// The first input is [...,3,M] and second input is [...,M,K].
260// Output is [...,M,K].
261Status TridiagonalSolveShapeFn(InferenceContext* c) {
262 ShapeHandle lhs;
263 ShapeHandle rhs;
264 // Check that rank is at least 2.
265 TF_RETURN_IF_ERROR(c->WithRankAtLeast(c->input(0), 2, &lhs));
266 TF_RETURN_IF_ERROR(c->WithRankAtLeast(c->input(1), 2, &rhs));
267
268 // Extract batch dimensions and check they are the same.
269 ShapeHandle lhs_batch_shape;
270 ShapeHandle rhs_batch_shape;
271 TF_RETURN_IF_ERROR(c->Subshape(lhs, 0, -2, &lhs_batch_shape));
272 TF_RETURN_IF_ERROR(c->Subshape(rhs, 0, -2, &rhs_batch_shape));
273 TF_RETURN_IF_ERROR(
274 c->Merge(lhs_batch_shape, rhs_batch_shape, &lhs_batch_shape));
275
276 // Check that "M" is the same in both inputs.
277 DimensionHandle m_lhs = c->Dim(lhs, -1);
278 DimensionHandle m_rhs = c->Dim(rhs, -2);
279 TF_RETURN_IF_ERROR(c->Merge(m_lhs, m_rhs, &m_lhs));
280
281 // Check that next-to-last dimension of the first input is 3.
282 TF_RETURN_IF_ERROR(c->WithValue(c->Dim(lhs, -2), 3, &m_lhs));
283
284 // The output shape is the same as rhs shape.
285 c->set_output(0, rhs);
286 return Status::OK();
287}
288
289} // namespace
290

Callers

nothing calls this directly

Calls 7

WithRankAtLeastMethod · 0.80
SubshapeMethod · 0.80
WithValueMethod · 0.80
inputMethod · 0.45
MergeMethod · 0.45
DimMethod · 0.45
set_outputMethod · 0.45

Tested by

no test coverage detected