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

Method GetProgramShape

tensorflow/compiler/xla/client/xla_builder.cc:163–192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

161}
162
163StatusOr<ProgramShape> XlaBuilder::GetProgramShape(int64 root_id) const {
164 TF_RETURN_IF_ERROR(first_error_);
165 TF_ASSIGN_OR_RETURN(const HloInstructionProto* root_proto,
166 LookUpInstructionByHandle(root_id));
167
168 ProgramShape program_shape;
169
170 *program_shape.mutable_result() = Shape(root_proto->shape());
171
172 // Check that the parameter numbers are continuous from 0, and add parameter
173 // shapes and names to the program shape.
174 const int64 param_count = parameter_numbers_.size();
175 for (int64 i = 0; i < param_count; i++) {
176 program_shape.add_parameters();
177 program_shape.add_parameter_names();
178 }
179 for (const HloInstructionProto& instr : instructions_) {
180 // Parameter number uniqueness is guaranteed in XlaBuilder::Parameter(). So
181 // to verify continuity, we just need to verify that every parameter is in
182 // the right range.
183 if (instr.opcode() == HloOpcodeString(HloOpcode::kParameter)) {
184 const int64 index = instr.parameter_number();
185 TF_RET_CHECK(index >= 0 && index < param_count)
186 << "invalid parameter number: " << index;
187 *program_shape.mutable_parameters(index) = Shape(instr.shape());
188 *program_shape.mutable_parameter_names(index) = instr.name();
189 }
190 }
191 return program_shape;
192}
193
194StatusOr<ProgramShape> XlaBuilder::GetProgramShape() const {
195 TF_RET_CHECK(!instructions_.empty());

Callers 3

TESTFunction · 0.45
TESTFunction · 0.45
ConditionalImplMethod · 0.45

Calls 15

HloOpcodeStringFunction · 0.85
InvalidArgumentFunction · 0.85
mutable_resultMethod · 0.80
add_parametersMethod · 0.80
add_parameter_namesMethod · 0.80
opcodeMethod · 0.80
mutable_parametersMethod · 0.80
nameMethod · 0.65
ShapeFunction · 0.50
shapeMethod · 0.45
sizeMethod · 0.45

Tested by 2

TESTFunction · 0.36
TESTFunction · 0.36