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

Method Compute

tensorflow/core/kernels/rnn/lstm_ops.cc:1076–1296  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1074 }
1075
1076 void Compute(OpKernelContext* ctx) override {
1077 const Tensor* seq_len_max_tensor = nullptr;
1078 OP_REQUIRES_OK(ctx, ctx->input("seq_len_max", &seq_len_max_tensor));
1079
1080 const Tensor* x;
1081 OP_REQUIRES_OK(ctx, ctx->input("x", &x));
1082 OP_REQUIRES(ctx, x->dims() == 3, errors::InvalidArgument("x must be 3D"));
1083 const int64 timelen = x->dim_size(0);
1084 const int64 batch_size = x->dim_size(1);
1085 const int64 input_size = x->dim_size(2);
1086
1087 const Tensor* cs_prev_tensor = nullptr;
1088 OP_REQUIRES_OK(ctx, ctx->input("cs_prev", &cs_prev_tensor));
1089
1090 const Tensor* h_prev_tensor = nullptr;
1091 OP_REQUIRES_OK(ctx, ctx->input("h_prev", &h_prev_tensor));
1092
1093 const Tensor* w_tensor = nullptr;
1094 OP_REQUIRES_OK(ctx, ctx->input("w", &w_tensor));
1095 const int64 cell_size = w_tensor->dim_size(1) / 4;
1096 OP_REQUIRES(ctx, input_size + cell_size == w_tensor->dim_size(0),
1097 errors::InvalidArgument(
1098 "w matrix rows don't match: ", input_size + cell_size,
1099 " vs. ", w_tensor->dim_size(0)));
1100
1101 const Tensor* wci_tensor = nullptr;
1102 OP_REQUIRES_OK(ctx, ctx->input("wci", &wci_tensor));
1103
1104 const Tensor* wcf_tensor = nullptr;
1105 OP_REQUIRES_OK(ctx, ctx->input("wcf", &wcf_tensor));
1106
1107 const Tensor* wco_tensor = nullptr;
1108 OP_REQUIRES_OK(ctx, ctx->input("wco", &wco_tensor));
1109
1110 const Tensor* b_tensor = nullptr;
1111 OP_REQUIRES_OK(ctx, ctx->input("b", &b_tensor));
1112 OP_REQUIRES(
1113 ctx, cell_size == b_tensor->dim_size(0) / 4,
1114 errors::InvalidArgument("w and b cell_size don't match: ", cell_size,
1115 " vs. ", b_tensor->dim_size(0)));
1116
1117 const Tensor* i_out = nullptr;
1118 OP_REQUIRES_OK(ctx, ctx->input("i", &i_out));
1119
1120 const Tensor* cs_out = nullptr;
1121 OP_REQUIRES_OK(ctx, ctx->input("cs", &cs_out));
1122
1123 const Tensor* f_out = nullptr;
1124 OP_REQUIRES_OK(ctx, ctx->input("f", &f_out));
1125
1126 const Tensor* o_out = nullptr;
1127 OP_REQUIRES_OK(ctx, ctx->input("o", &o_out));
1128
1129 const Tensor* ci_out = nullptr;
1130 OP_REQUIRES_OK(ctx, ctx->input("ci", &ci_out));
1131
1132 const Tensor* co_out = nullptr;
1133 OP_REQUIRES_OK(ctx, ctx->input("co", &co_out));

Callers

nothing calls this directly

Calls 12

InvalidArgumentFunction · 0.85
allocate_outputMethod · 0.80
InputSliceMethod · 0.80
OutputSliceMethod · 0.80
FinishTimeStepMethod · 0.80
TensorShapeClass · 0.50
inputMethod · 0.45
dimsMethod · 0.45
dim_sizeMethod · 0.45
shapeMethod · 0.45
allocate_tempMethod · 0.45
SliceMethod · 0.45

Tested by

no test coverage detected