| 436 | } |
| 437 | |
| 438 | LogicalResult ConvertLSTMCellSimpleToFusedLSTM::Initialize() { |
| 439 | if (failed(InitializeFromFuncAttributes())) { |
| 440 | return fused_func_op_.emitError() |
| 441 | << "Expected function attributes were not set on the function " |
| 442 | "encapsulating the composite op"; |
| 443 | } |
| 444 | |
| 445 | num_gates_ = couple_input_forget_gates_ ? 3 : 4; |
| 446 | |
| 447 | input_ = fused_func_op_.getArgument(0); |
| 448 | bias_ = fused_func_op_.getArgument(2); |
| 449 | |
| 450 | weight_ = fused_func_op_.getArgument(1); |
| 451 | weight_type_ = weight_.getType().cast<RankedTensorType>(); |
| 452 | |
| 453 | if (weight_type_.getRank() != 2) { |
| 454 | return fused_func_op_.emitError() << "The weight tensor was not of rank 2"; |
| 455 | } |
| 456 | |
| 457 | if (weight_type_.getDimSize(1) % num_gates_ != 0) { |
| 458 | return fused_func_op_.emitError() |
| 459 | << "Invalid dimension 1 of weight tensor, " |
| 460 | "should be divisible by the number of gates"; |
| 461 | } |
| 462 | n_cell_ = weight_type_.getDimSize(1) / num_gates_; |
| 463 | |
| 464 | projection_ = fused_func_op_.getArgument(3); |
| 465 | projection_type_ = projection_.getType().cast<RankedTensorType>(); |
| 466 | if (projection_type_.getRank() != 2) { |
| 467 | n_output_ = n_cell_; |
| 468 | } else { |
| 469 | n_output_ = projection_type_.getDimSize(1); |
| 470 | } |
| 471 | n_input_ = weight_type_.getDimSize(0) - n_output_; |
| 472 | num_cols_weight_transposed_ = weight_type_.getDimSize(0); |
| 473 | num_cols_projection_transposed_ = projection_type_.getDimSize(0); |
| 474 | |
| 475 | bias_slice_shape_ = {n_cell_}; |
| 476 | bias_size_values_ = {n_cell_}; |
| 477 | weight_slice_shape_ = {1, num_cols_weight_transposed_}; |
| 478 | weight_slice_size_input_values_ = {n_cell_, n_input_}; |
| 479 | weight_slice_size_recurrent_values_ = {n_cell_, n_output_}; |
| 480 | |
| 481 | return success(); |
| 482 | } |
| 483 | |
| 484 | LogicalResult ConvertLayerNormalizedLSTMCellSimpleToFusedLSTM::Initialize() { |
| 485 | if (failed(ConvertLSTMCellSimpleToFusedLSTM::Initialize())) { |
nothing calls this directly
no test coverage detected