MCPcopy Create free account
hub / github.com/Oneflow-Inc/oneflow / InferAdamUpdateTensorDesc

Function InferAdamUpdateTensorDesc

oneflow/user/ops/model_update_ops.cpp:185–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

183}
184
185Maybe<void> InferAdamUpdateTensorDesc(user_op::InferContext* ctx) {
186 const user_op::TensorDesc& model = ctx->InputTensorDesc("model", 0);
187 const Shape& shape = model.shape();
188 const user_op::TensorDesc& model_diff = ctx->InputTensorDesc("model_diff", 0);
189 CHECK_EQ_OR_RETURN(model_diff.shape(), shape);
190 const user_op::TensorDesc& m = ctx->InputTensorDesc("m", 0);
191 JUST(CheckShapeLike(&m, &model));
192 const user_op::TensorDesc& v = ctx->InputTensorDesc("v", 0);
193 JUST(CheckShapeLike(&v, &model));
194 JUST(CheckLearningRateShape(ctx));
195 if (ctx->has_input("model_copy", 0)) {
196 CHECK_EQ_OR_RETURN(ctx->InputTensorDesc("model_copy", 0).shape(), shape)
197 << "Model copy shape should be equal to Model shape. ";
198 }
199 if (ctx->has_input("scale_by_tensor", 0)) {
200 const auto& scale_by_tensor = ctx->InputTensorDesc("scale_by_tensor", 0);
201 JUST(CheckScalarShape(&scale_by_tensor));
202 }
203 return Maybe<void>::Ok();
204}
205Maybe<void> InferAdamUpdateDataType(user_op::InferContext* ctx) {
206 const user_op::TensorDesc& model = ctx->InputTensorDesc("model", 0);
207 const user_op::TensorDesc& m = ctx->InputTensorDesc("m", 0);

Callers 1

Calls 5

CheckShapeLikeFunction · 0.70
CheckLearningRateShapeFunction · 0.70
CheckScalarShapeFunction · 0.70
shapeMethod · 0.45
has_inputMethod · 0.45

Tested by

no test coverage detected