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

Method SetDynamicBinding

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

Source from the content-addressed store, hash-verified

257}
258
259Status XlaBuilder::SetDynamicBinding(int64 dynamic_size_param_num,
260 ShapeIndex dynamic_size_param_index,
261 int64 target_param_num,
262 ShapeIndex target_param_index,
263 int64 target_dim_num) {
264 bool param_exists = false;
265 for (size_t index = 0; index < instructions_.size(); ++index) {
266 HloInstructionProto& instr = instructions_[index];
267 if (instr.opcode() == HloOpcodeString(HloOpcode::kParameter) &&
268 instr.parameter_number() == target_param_num) {
269 param_exists = true;
270 Shape param_shape(instr.shape());
271 Shape* param_shape_ptr = &param_shape;
272 for (int64 index : target_param_index) {
273 param_shape_ptr = param_shape_ptr->mutable_tuple_shapes(index);
274 }
275 param_shape_ptr->set_dynamic_dimension(target_dim_num,
276 /*is_dynamic=*/true);
277 *instr.mutable_shape() = param_shape.ToProto();
278 instruction_shapes_[index] =
279 absl::make_unique<Shape>(std::move(param_shape));
280 }
281 }
282 if (!param_exists) {
283 return InvalidArgument(
284 "Asked to mark parameter %lld as dynamic sized parameter, but the "
285 "doesn't exists",
286 target_param_num);
287 }
288
289 TF_RETURN_IF_ERROR(dynamic_parameter_binding_.Bind(
290 DynamicParameterBinding::DynamicParameter{dynamic_size_param_num,
291 dynamic_size_param_index},
292 DynamicParameterBinding::DynamicDimension{
293 target_param_num, target_param_index, target_dim_num}));
294 return Status::OK();
295}
296
297Status XlaBuilder::SetInstructionFrontendAttribute(const XlaOp op,
298 std::string attribute,

Callers 2

BuildArgumentsMethod · 0.80
TEST_FFunction · 0.80

Calls 11

HloOpcodeStringFunction · 0.85
InvalidArgumentFunction · 0.85
opcodeMethod · 0.80
mutable_tuple_shapesMethod · 0.80
set_dynamic_dimensionMethod · 0.80
BindMethod · 0.80
sizeMethod · 0.45
parameter_numberMethod · 0.45
shapeMethod · 0.45
mutable_shapeMethod · 0.45
ToProtoMethod · 0.45

Tested by 1

TEST_FFunction · 0.64