Skip to content

Conversation

@joey12300
Copy link
Collaborator

@joey12300 joey12300 commented Aug 10, 2022

PR types

New features

PR changes

APIs

Describe

Add softmax function

Usage

FDTensor input, output;
CheckShape check_shape;
CheckData check_data;
std::vector<float> inputs = {1, 2, 3, 4, 5, 6};
input.SetExternalData({2, 3}, FDDataType::FP32, inputs.data());

// Transpose the input tensor with axis {1, 0}.
// The output result would be
// [[0.04742587, 0.04742587, 0.04742587],
//  [0.95257413, 0.95257413, 0.95257413]]
Softmax(input, &output, 0);

@joey12300 joey12300 marked this pull request as ready for review August 10, 2022 14:58
default: \
FDASSERT(false, "Invalid enum data type.") \
} \
#define FD_VISIT_ALL_TYPES(TYPE, NAME, ...) \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这些宏能加下注释说明下作用吗?或者写明在文档里,我看在写Functions都会用到

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

主要是FDTensor本身是个非模板的结构体,而Functions的底层函数都是模板函数,调用时无法确定使用哪一个实例化的模板函数。而通过FD_VISIT_ALL_TYPES可以去匹配与FDTensor dtype相同的模板函数,调用之。

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

function类的,如果后需拓展的话,可能会有很多单测。可以在tests目录下建一个function目录,把function类的单测都移在目录下。

之后其它如vision/runtime的单测也就都分别加在相应的目录下面

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@joey12300 joey12300 requested a review from jiangjiajun August 11, 2022 03:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants