Skip to content

Commit 73632de

Browse files
authored
Polish the documentation for uniform_random and top_k ops (#5353)
1 parent 83c2281 commit 73632de

File tree

2 files changed

+33
-21
lines changed

2 files changed

+33
-21
lines changed

paddle/operators/top_k_op.cc

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,20 @@ class TopkOpMaker : public framework::OpProtoAndCheckerMaker {
4848
public:
4949
TopkOpMaker(framework::OpProto *proto, framework::OpAttrChecker *op_checker)
5050
: OpProtoAndCheckerMaker(proto, op_checker) {
51-
AddInput("X", "The input of Topk op");
52-
AddOutput("Out", "The output tensor of Topk op");
53-
AddOutput("Indices", "The indices of Topk elements of input");
54-
AddComment(
55-
R"DOC(If the input is a vector (1d tensor),
56-
finds the k largest entries in the vector
57-
and outputs their values and indices as vectors.
58-
Thus values[j] is the j-th largest entry in input,
59-
and its index is indices[j].
51+
AddInput("X", "(Tensor) The input of Topk op");
52+
AddOutput("Out", "(Tensor) The output tensor of Topk op");
53+
AddOutput("Indices", "(Tensor) The indices of Topk elements of input");
54+
AddComment(R"DOC(
55+
Top K operator
6056
61-
For matrices, computes the top k entries in each row. )DOC");
57+
If the input is a vector (1d tensor), this operator finds the k largest
58+
entries in the vector and outputs their values and indices as vectors.
59+
Thus values[j] is the j-th largest entry in input, and its index is indices[j].
60+
61+
For matrices, this operator computes the top k entries in each row. )DOC");
6262
AddAttr<int>("k",
63-
"Number of top elements to look for along the last "
64-
"dimension (along each row for matrices).")
63+
"(int, default 1) Number of top elements to look for along "
64+
"the last dimension (along each row for matrices).")
6565
.SetDefault(1);
6666
}
6767
};

paddle/operators/uniform_random_op.cc

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,30 @@ class UniformRandomOpMaker : public framework::OpProtoAndCheckerMaker {
7474
UniformRandomOpMaker(framework::OpProto* proto,
7575
framework::OpAttrChecker* op_checker)
7676
: framework::OpProtoAndCheckerMaker(proto, op_checker) {
77-
AddOutput("Out", "The output tensor of uniform random op");
78-
AddComment(R"DOC(Uniform random operator.
79-
Used to initialize tensor with uniform random generator.
77+
AddOutput("Out", "(Tensor) The output tensor of uniform random op");
78+
AddComment(R"DOC(
79+
Uniform random operator.
80+
81+
This operator initializes a tensor with random values sampled from a
82+
uniform distribution.
83+
8084
)DOC");
81-
AddAttr<std::vector<int>>("shape", "the dimension of random tensor");
82-
AddAttr<float>("min", "Minimum value of uniform random").SetDefault(-1.0f);
83-
AddAttr<float>("max", "Maximun value of uniform random").SetDefault(1.0f);
85+
AddAttr<std::vector<int>>("shape",
86+
"(vector<int>) The shape of the output tensor");
87+
AddAttr<float>("min",
88+
"(float, default -1.0) "
89+
"Minimum value of uniform random")
90+
.SetDefault(-1.0f);
91+
AddAttr<float>("max",
92+
"(float, default 1.0) "
93+
"Maximun value of uniform random")
94+
.SetDefault(1.0f);
8495
AddAttr<int>("seed",
85-
"Random seed of uniform random. "
86-
"0 means generate a seed by system")
96+
"(int, default 0) "
97+
"Random seed used for generating samples. "
98+
"0 means use a seed generated by the system.")
8799
.SetDefault(0);
88-
AddAttr<int>("data_type", "output tensor data type")
100+
AddAttr<int>("data_type", "(int, default 5(FP32)) Output tensor data type")
89101
.SetDefault(framework::DataType::FP32);
90102
}
91103
};

0 commit comments

Comments
 (0)