├── .clang-format ├── .github └── workflows │ ├── test-coverage.yml │ └── workflows.yml ├── .gitignore ├── CMakeLists.txt ├── LICENSE ├── README.md ├── core ├── include │ ├── attr_io.hpp │ ├── base_object.hpp │ ├── cpu_device.h │ ├── custom_kernel.hpp │ ├── data_type.hpp │ ├── dev_proposal.hpp │ ├── exec_attr.hpp │ ├── exec_context.hpp │ ├── exec_engine.hpp │ ├── generic_factory.hpp │ ├── graph.hpp │ ├── graph_executor.hpp │ ├── graph_perf.hpp │ ├── logger.hpp │ ├── node.hpp │ ├── notify.hpp │ ├── notify_instance.hpp │ ├── operator.hpp │ ├── operator_manager.hpp │ ├── parameter.hpp │ ├── safe_object_manager.hpp │ ├── serializer.hpp │ ├── simple_object_manager.hpp │ ├── static_graph.hpp │ ├── static_graph_interface.hpp │ ├── tengine_c_api.h │ ├── tengine_c_compat.h │ ├── tengine_c_helper.hpp │ ├── tengine_config.hpp │ ├── tengine_errno.hpp │ ├── tengine_op.hpp │ ├── tengine_plugin.hpp │ ├── tensor.hpp │ ├── tensor_shape.hpp │ └── worker_thread.hpp └── lib │ ├── compiler.cpp │ ├── data_type.cpp │ ├── exec_context.cpp │ ├── graph.cpp │ ├── graph_executor.cpp │ ├── logger │ └── logger.cpp │ ├── node.cpp │ ├── notify_instance.cpp │ ├── operator_manager.cpp │ ├── serializer.cpp │ ├── static_graph.cpp │ ├── tengine_c_api.cpp │ ├── tengine_c_compat.cpp │ ├── tengine_c_helper.cpp │ ├── tengine_config.cpp │ ├── tengine_errno.cpp │ ├── tengine_filed_infos.cpp │ ├── tengine_plugin.cpp │ ├── tensor.cpp │ └── tensor_shape.cpp ├── driver ├── cpu │ ├── cpu_driver.cpp │ ├── cpu_driver.hpp │ ├── cpu_executor.cpp │ ├── cpu_executor.hpp │ ├── cpu_probe.cpp │ ├── cpu_runner.cpp │ └── cpu_runner.hpp └── plugin │ └── init.cpp ├── executor ├── engine │ └── generic_engine.cpp ├── include │ ├── cpu_info.hpp │ ├── custom_kernel_ops.hpp │ ├── dev_allocator.hpp │ ├── dev_executor.hpp │ ├── dev_scheduler.hpp │ ├── device_driver.hpp │ ├── generic_dev_executor.hpp │ ├── generic_engine.hpp │ ├── graph_optimizer.hpp │ ├── graph_task.hpp │ ├── kernel_registry.hpp │ ├── node_dev_driver.hpp │ ├── node_dev_executor.hpp │ ├── node_ops.hpp │ └── tensor_mem.hpp ├── lib │ ├── cpu_info.cpp │ ├── custom_kernel.cpp │ ├── custom_kernel_ops.cpp │ ├── dev_allocator.cpp │ ├── dev_executor.cpp │ ├── dev_scheduler.cpp │ ├── device_driver.cpp │ ├── generic_dev_executor.cpp │ ├── graph_optimizer.cpp │ ├── graph_task.cpp │ ├── node_dev_driver.cpp │ ├── node_dev_executor.cpp │ ├── node_ops.cpp │ └── tensor_mem.cpp └── plugin │ └── init.cpp ├── include ├── any.hpp ├── attribute.hpp ├── compiler.hpp ├── named_data.hpp ├── share_lib_parser.hpp ├── te_error.hpp ├── type_name.hpp └── utilities │ ├── class_factory.hpp │ └── non_copyable.hpp ├── megengine.ipynb ├── operator ├── include │ └── operator │ │ ├── absval.hpp │ │ ├── accuracy.hpp │ │ ├── add_n.hpp │ │ ├── addn_param.hpp │ │ ├── argmax.hpp │ │ ├── argmax_param.hpp │ │ ├── argmin.hpp │ │ ├── argmin_param.hpp │ │ ├── batchToSpaceND.hpp │ │ ├── batchToSpaceND_param.hpp │ │ ├── batch_norm.hpp │ │ ├── batch_norm_param.hpp │ │ ├── bias.hpp │ │ ├── bias_param.hpp │ │ ├── broadmul.hpp │ │ ├── cast.hpp │ │ ├── cast_param.hpp │ │ ├── ceil.hpp │ │ ├── clip.hpp │ │ ├── clip_param.hpp │ │ ├── comparison.hpp │ │ ├── comparison_param.hpp │ │ ├── concat.hpp │ │ ├── concat_param.hpp │ │ ├── const_op.hpp │ │ ├── conv_param.hpp │ │ ├── convolution.hpp │ │ ├── copy.hpp │ │ ├── crop.hpp │ │ ├── crop_param.hpp │ │ ├── deconv_param.hpp │ │ ├── deconvolution.hpp │ │ ├── demo_op.hpp │ │ ├── depthtospace.hpp │ │ ├── depthtospace_param.hpp │ │ ├── detection_output.hpp │ │ ├── detection_output_param.hpp │ │ ├── detection_postprocess.hpp │ │ ├── detection_postprocess_param.hpp │ │ ├── dropout.hpp │ │ ├── eltwise.hpp │ │ ├── eltwise_param.hpp │ │ ├── elu.hpp │ │ ├── elu_param.hpp │ │ ├── embed.hpp │ │ ├── embed_param.hpp │ │ ├── expand.hpp │ │ ├── expand_param.hpp │ │ ├── expanddims.hpp │ │ ├── expanddims_param.hpp │ │ ├── fc_param.hpp │ │ ├── feature_match.hpp │ │ ├── flatten.hpp │ │ ├── flatten_param.hpp │ │ ├── floor.hpp │ │ ├── fm_param.hpp │ │ ├── fully_connected.hpp │ │ ├── fused_operator.hpp │ │ ├── gather.hpp │ │ ├── gather_param.hpp │ │ ├── gemm.hpp │ │ ├── gemm_param.hpp │ │ ├── generic.hpp │ │ ├── generic_param.hpp │ │ ├── gru.hpp │ │ ├── gru_param.hpp │ │ ├── hardsigmoid.hpp │ │ ├── hardsigmoid_param.hpp │ │ ├── hardswish.hpp │ │ ├── input_op.hpp │ │ ├── instancenorm.hpp │ │ ├── instancenorm_param.hpp │ │ ├── interp.hpp │ │ ├── interp_param.hpp │ │ ├── l2normalization.hpp │ │ ├── l2pool.hpp │ │ ├── l2pool_param.hpp │ │ ├── layernormlstm.hpp │ │ ├── layernormlstm_param.hpp │ │ ├── log_softmax.hpp │ │ ├── log_softmax_param.hpp │ │ ├── logical.hpp │ │ ├── logical_param.hpp │ │ ├── logistic.hpp │ │ ├── lrn.hpp │ │ ├── lrn_param.hpp │ │ ├── lstm.hpp │ │ ├── lstm_param.hpp │ │ ├── matmul.hpp │ │ ├── maximum.hpp │ │ ├── mean.hpp │ │ ├── minimum.hpp │ │ ├── mish.hpp │ │ ├── mvn.hpp │ │ ├── mvn_param.hpp │ │ ├── nms.hpp │ │ ├── nms_param.hpp │ │ ├── noop.hpp │ │ ├── normalize.hpp │ │ ├── normalize_param.hpp │ │ ├── pad.hpp │ │ ├── pad_param.hpp │ │ ├── permute.hpp │ │ ├── permute_param.hpp │ │ ├── pool_param.hpp │ │ ├── pooling.hpp │ │ ├── power.hpp │ │ ├── power_param.hpp │ │ ├── prelu.hpp │ │ ├── priorbox.hpp │ │ ├── priorbox_param.hpp │ │ ├── psroipooling.hpp │ │ ├── psroipooling_param.hpp │ │ ├── reciprocal.hpp │ │ ├── reducel2.hpp │ │ ├── reducel2_param.hpp │ │ ├── reduction.hpp │ │ ├── reduction_param.hpp │ │ ├── region.hpp │ │ ├── region_param.hpp │ │ ├── relu.hpp │ │ ├── relu1.hpp │ │ ├── relu6.hpp │ │ ├── relu_param.hpp │ │ ├── reorg.hpp │ │ ├── reorg_param.hpp │ │ ├── reshape.hpp │ │ ├── reshape_param.hpp │ │ ├── resize.hpp │ │ ├── resize_param.hpp │ │ ├── reverse.hpp │ │ ├── rnn.hpp │ │ ├── rnn_param.hpp │ │ ├── roi_pooling.hpp │ │ ├── roi_pooling_param.hpp │ │ ├── roialign.hpp │ │ ├── roialign_param.hpp │ │ ├── round.hpp │ │ ├── rpn.hpp │ │ ├── rpn_param.hpp │ │ ├── scale.hpp │ │ ├── scale_param.hpp │ │ ├── scatter.hpp │ │ ├── scatter_param.hpp │ │ ├── selu.hpp │ │ ├── selu_param.hpp │ │ ├── shape.hpp │ │ ├── shuffle_channel.hpp │ │ ├── shuffle_channel_param.hpp │ │ ├── sigmoid.hpp │ │ ├── slice.hpp │ │ ├── slice_param.hpp │ │ ├── softmax.hpp │ │ ├── softmax_param.hpp │ │ ├── softplus.hpp │ │ ├── spaceToBatchND.hpp │ │ ├── spaceToBatchND_param.hpp │ │ ├── spacetodepth.hpp │ │ ├── spacetodepth_param.hpp │ │ ├── sparsetodense.hpp │ │ ├── sparsetodense_param.hpp │ │ ├── spatialtransformer.hpp │ │ ├── spatialtransformer_param.hpp │ │ ├── split.hpp │ │ ├── split_param.hpp │ │ ├── squared_difference.hpp │ │ ├── squeeze.hpp │ │ ├── squeeze_param.hpp │ │ ├── stridedslice.hpp │ │ ├── stridedslice_param.hpp │ │ ├── swap_axis.hpp │ │ ├── swap_axis_param.hpp │ │ ├── tanh.hpp │ │ ├── threshold.hpp │ │ ├── threshold_param.hpp │ │ ├── tile.hpp │ │ ├── tile_param.hpp │ │ ├── topkv2.hpp │ │ ├── topkv2_param.hpp │ │ ├── transpose.hpp │ │ ├── transpose_param.hpp │ │ ├── unary.hpp │ │ ├── unary_param.hpp │ │ ├── unsqueeze.hpp │ │ ├── unsqueeze_param.hpp │ │ ├── upsample.hpp │ │ ├── upsample_param.hpp │ │ ├── where.hpp │ │ └── zeros_like.hpp ├── operator │ ├── absval.cpp │ ├── accuracy.cpp │ ├── addn.cpp │ ├── argmax.cpp │ ├── argmin.cpp │ ├── batchToSpaceND.cpp │ ├── batch_norm.cpp │ ├── bias.cpp │ ├── broadmul.cpp │ ├── cast.cpp │ ├── ceil.cpp │ ├── clip.cpp │ ├── comparison.cpp │ ├── concat.cpp │ ├── const_op.cpp │ ├── convolution.cpp │ ├── copy.cpp │ ├── crop.cpp │ ├── deconvolution.cpp │ ├── demo_op.cpp │ ├── depthtospace.cpp │ ├── detection_output.cpp │ ├── detection_postprocess.cpp │ ├── dropout.cpp │ ├── eltwise.cpp │ ├── elu.cpp │ ├── embed.cpp │ ├── expand.cpp │ ├── expanddims.cpp │ ├── feature_match.cpp │ ├── flatten.cpp │ ├── floor.cpp │ ├── fully_connected.cpp │ ├── fused_operator.cpp │ ├── gather.cpp │ ├── gemm.cpp │ ├── generic.cpp │ ├── gru.cpp │ ├── hardsigmoid.cpp │ ├── hardswish.cpp │ ├── input_op.cpp │ ├── instancenorm.cpp │ ├── interp.cpp │ ├── l2normalization.cpp │ ├── l2pool.cpp │ ├── layernormlstm.cpp │ ├── log_softmax.cpp │ ├── logical.cpp │ ├── logistic.cpp │ ├── lrn.cpp │ ├── lstm.cpp │ ├── matmul.cpp │ ├── maximum.cpp │ ├── mean.cpp │ ├── minimum.cpp │ ├── mish.cpp │ ├── mvn.cpp │ ├── nms.cpp │ ├── noop.cpp │ ├── normalize.cpp │ ├── pad.cpp │ ├── permute.cpp │ ├── pooling.cpp │ ├── power.cpp │ ├── prelu.cpp │ ├── priorbox.cpp │ ├── psroipooling.cpp │ ├── reciprocal.cpp │ ├── reducel2.cpp │ ├── reduction.cpp │ ├── region.cpp │ ├── relu.cpp │ ├── relu1.cpp │ ├── relu6.cpp │ ├── reorg.cpp │ ├── reshape.cpp │ ├── resize.cpp │ ├── reverse.cpp │ ├── rnn.cpp │ ├── roi_pooling.cpp │ ├── roialign.cpp │ ├── round.cpp │ ├── rpn.cpp │ ├── scale.cpp │ ├── scatter.cpp │ ├── selu.cpp │ ├── shape.cpp │ ├── shuffle_channel.cpp │ ├── sigmoid.cpp │ ├── slice.cpp │ ├── softmax.cpp │ ├── softplus.cpp │ ├── spaceToBatchND.cpp │ ├── spacetodepth.cpp │ ├── sparsetodense.cpp │ ├── spatialtransformer.cpp │ ├── split.cpp │ ├── squared_difference.cpp │ ├── squeeze.cpp │ ├── stridedslice.cpp │ ├── swap_axis.cpp │ ├── tanh.cpp │ ├── threshold.cpp │ ├── tile.cpp │ ├── topkv2.cpp │ ├── transpose.cpp │ ├── unary.cpp │ ├── unsqueeze.cpp │ ├── upsample.cpp │ ├── where.cpp │ └── zeros_like.cpp └── plugin │ └── init.cpp ├── serializer ├── include │ ├── tengine │ │ └── v2 │ │ │ ├── tm2_format.h │ │ │ ├── tm2_op_serializer.hpp │ │ │ └── tm2_serializer.hpp │ ├── tm_generate.h │ └── tm_serializer.hpp ├── plugin │ └── init.cpp └── tengine │ ├── tm_generate.c │ ├── tm_serializer.cpp │ └── v2 │ ├── init.cpp │ ├── tm2_op_load.cpp │ ├── tm2_op_save.cpp │ └── tm2_serializer.cpp └── tools ├── CMakeLists.txt ├── caffe ├── caffe_serializer.cpp └── te_caffe.proto ├── config.hpp.in ├── convert_model_to_tm.cpp ├── darknet └── darknet_serializer.cpp ├── helper ├── alphabeta.hpp ├── stb_image.h ├── stb_image_write.h ├── tengine_operations.cpp └── tengine_operations.h ├── include ├── caffe_serializer.hpp ├── darknet_serializer.hpp ├── megengine_serializer.hpp ├── model_patch.h ├── mxnet_serializer.hpp ├── ncnn_serializer.hpp ├── oneflow_serializer.hpp ├── onnx_serializer.hpp ├── paddle_serializer.hpp ├── patch_serializer.hpp ├── src_serializer.hpp ├── src_tm_serializer.hpp ├── te_darknet.hpp ├── tf_lite_serializer.hpp ├── tf_serializer.hpp └── tflite │ ├── flatbuffers │ ├── base.h │ ├── code_generators.h │ ├── flatbuffers.h │ ├── flatc.h │ ├── flexbuffers.h │ ├── grpc.h │ ├── hash.h │ ├── idl.h │ ├── minireflect.h │ ├── reflection.h │ ├── reflection_generated.h │ ├── registry.h │ ├── stl_emulation.h │ └── util.h │ └── schema_generated.h ├── init.cpp ├── megengine └── megengine_serializer.cpp ├── mxnet └── mxnet_serializer.cpp ├── ncnn ├── ncnn_serializer.cpp └── operator_param.txt ├── oneflow ├── CMakeLists.txt ├── oneflow │ ├── core │ │ ├── actor │ │ │ └── act_event.proto │ │ ├── comm_network │ │ │ └── ibverbs │ │ │ │ └── ibverbs.proto │ │ ├── common │ │ │ ├── cfg_reflection_test.proto │ │ │ ├── data_type.proto │ │ │ ├── device_type.proto │ │ │ ├── dtype_signature.proto │ │ │ ├── error.proto │ │ │ ├── range.proto │ │ │ └── shape.proto │ │ ├── control │ │ │ ├── control.proto │ │ │ ├── ctrl_bootstrap.proto │ │ │ └── worker_process_info.proto │ │ ├── eager │ │ │ ├── eager_instruction.proto │ │ │ └── eager_symbol.proto │ │ ├── framework │ │ │ ├── config_def.proto │ │ │ ├── user_op_attr.proto │ │ │ ├── user_op_conf.proto │ │ │ ├── user_op_def.proto │ │ │ └── variable_meta_info.proto │ │ ├── graph │ │ │ ├── boxing │ │ │ │ └── collective_boxing.proto │ │ │ └── exec_sequence.proto │ │ ├── job │ │ │ ├── available_memory_desc.proto │ │ │ ├── blob_lifetime_signature.proto │ │ │ ├── cluster_instruction.proto │ │ │ ├── critical_section.proto │ │ │ ├── distribute_hirarchy.proto │ │ │ ├── dlnet_conf.proto │ │ │ ├── env.proto │ │ │ ├── file_system_conf.proto │ │ │ ├── initializer_conf.proto │ │ │ ├── inter_user_job_info.proto │ │ │ ├── job.proto │ │ │ ├── job_conf.proto │ │ │ ├── job_set.proto │ │ │ ├── job_set_compile_ctx.proto │ │ │ ├── lbi_diff_watcher_info.proto │ │ │ ├── learning_rate_schedule_conf.proto │ │ │ ├── mirrored_parallel.proto │ │ │ ├── parallel_conf_signature.proto │ │ │ ├── parallel_signature.proto │ │ │ ├── placement.proto │ │ │ ├── plan.proto │ │ │ ├── regularizer_conf.proto │ │ │ ├── resource.proto │ │ │ ├── sbp_parallel.proto │ │ │ ├── scope.proto │ │ │ ├── sub_plan.proto │ │ │ └── task.proto │ │ ├── kernel │ │ │ └── kernel.proto │ │ ├── memory │ │ │ ├── memory_block.proto │ │ │ └── memory_case.proto │ │ ├── object_msg │ │ │ └── object_msg_field_list.proto │ │ ├── operator │ │ │ ├── arg_modifier_signature.proto │ │ │ ├── interface_blob_conf.proto │ │ │ ├── op_attribute.proto │ │ │ ├── op_conf.proto │ │ │ └── op_node_signature.proto │ │ ├── record │ │ │ ├── coco.proto │ │ │ └── record.proto │ │ ├── register │ │ │ ├── blob_desc.proto │ │ │ ├── logical_blob_id.proto │ │ │ ├── op_blob_arg.proto │ │ │ ├── pod.proto │ │ │ ├── register_desc.proto │ │ │ └── tensor_slice_view.proto │ │ ├── serving │ │ │ └── saved_model.proto │ │ ├── summary │ │ │ ├── event.proto │ │ │ ├── graph.proto │ │ │ ├── plugin_data.proto │ │ │ ├── projector.proto │ │ │ ├── summary.proto │ │ │ └── tensor.proto │ │ └── vm │ │ │ └── instruction.proto │ └── xrt │ │ ├── types.proto │ │ └── xrt.proto ├── oneflow_serializer.cpp └── sync_proto.py ├── onnx ├── onnx.proto ├── onnx.proto3 └── onnx_serializer.cpp ├── paddle ├── framework.proto └── paddle_serializer.cpp ├── tengine ├── patch_serializer.cpp ├── src_serializer.cpp └── src_tm_serializer.cpp ├── tensorflow ├── CMakeLists.txt ├── attr_value.proto ├── function.proto ├── graph.proto ├── init.cpp ├── node_def.proto ├── op_def.proto ├── resource_handle.proto ├── tensor.proto ├── tensor_shape.proto ├── tf_serializer.cpp ├── types.proto └── versions.proto └── tf_lite ├── tf_lite_serializer.cpp └── util.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | # clion debug directory 2 | cmake-build* 3 | .idea 4 | 5 | # Output debug directory 6 | output*/ 7 | 8 | # CMake build directory 9 | build*/ 10 | 11 | # Backup files. 12 | *~ 13 | 14 | # Prerequisites 15 | *.d 16 | 17 | # Compiled Object files 18 | *.slo 19 | *.lo 20 | *.o 21 | *.obj 22 | 23 | # Precompiled Headers 24 | *.gch 25 | *.pch 26 | 27 | # Compiled Dynamic libraries 28 | *.so 29 | *.dylib 30 | *.dll 31 | 32 | # Fortran module files 33 | *.mod 34 | *.smod 35 | 36 | # Compiled Static libraries 37 | *.lai 38 | *.la 39 | *.a 40 | *.lib 41 | 42 | # Executables 43 | *.exe 44 | *.out 45 | *.app 46 | 47 | # MACOSX 48 | .DS_Store 49 | 50 | # IDE 51 | .vs 52 | .vscode -------------------------------------------------------------------------------- /core/include/data_type.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2017, Open AI Lab 22 | * Author: haitao@openailab.com 23 | */ 24 | #ifndef __DATA_TYPE_HPP__ 25 | #define __DATA_TYPE_HPP__ 26 | 27 | namespace TEngine { 28 | 29 | namespace DataType { 30 | int GetTypeSize(int data_type); 31 | const char* GetTypeName(int data_type); 32 | int GetTypeID(const char* name); 33 | 34 | } // namespace DataType 35 | 36 | } // namespace TEngine 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /core/include/graph_perf.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __GRAPH_PERF_HPP__ 2 | #define __GRAPH_PERF_HPP__ 3 | 4 | #include 5 | 6 | #include "tengine_c_api.h" 7 | 8 | namespace TEngine { 9 | 10 | #define ATTR_GRAPH_PERF_STAT "GraphPerfStat" 11 | 12 | struct GraphPerfMsg 13 | { 14 | int action; 15 | struct perf_info** buf; 16 | int buf_size; 17 | int ret_number; 18 | }; 19 | 20 | } // namespace TEngine 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /core/include/tengine_errno.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2018, Open AI Lab 22 | * Author: haitao@openailab.com 23 | */ 24 | 25 | #ifndef __TENGINE_ERRNO_HPP__ 26 | #define __TENGINE_ERRNO_HPP__ 27 | 28 | #include 29 | 30 | extern "C" { 31 | 32 | extern int get_tengine_errno(void); 33 | 34 | extern void set_tengine_errno(int err_num); 35 | } 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /core/lib/tengine_errno.cpp: -------------------------------------------------------------------------------- 1 | #include "tengine_errno.hpp" 2 | 3 | static __thread int tengine_errno; 4 | 5 | void set_tengine_errno(int err_num) 6 | { 7 | tengine_errno = err_num; 8 | } 9 | 10 | int get_tengine_errno(void) 11 | { 12 | return tengine_errno; 13 | } 14 | -------------------------------------------------------------------------------- /core/lib/tengine_filed_infos.cpp: -------------------------------------------------------------------------------- 1 | #define __TENGINE_ARRT_ENV__ __attribute__((section(".tengine"))) 2 | 3 | #ifdef CONFIG_KERNEL_FP32 4 | #define ST_FP32 "Y" 5 | #else 6 | #define ST_FP32 "N" 7 | #endif 8 | 9 | #ifdef CONFIG_KERNEL_FP16 10 | #define ST_FP16 "Y" 11 | #else 12 | #define ST_FP16 "N" 13 | #endif 14 | 15 | #ifdef CONFIG_KERNEL_INT8 16 | #define ST_INT8 "Y" 17 | #else 18 | #define ST_INT8 "N" 19 | #endif 20 | 21 | #ifdef CONFIG_KERNEL_UINT8 22 | #define ST_UINT8 "Y" 23 | #else 24 | #define ST_UINT8 "N" 25 | #endif 26 | 27 | #ifdef ENABLE_ONLINE_REPORT 28 | #define ST_OLREPORT "Y" 29 | #else 30 | #define ST_OLREPORT "N" 31 | #endif 32 | 33 | char tengine_field_info[1024] __TENGINE_ARRT_ENV__ = { 34 | "TENGINE_FIELD_INFO_" ST_FP32 ST_FP16 ST_INT8 ST_UINT8 ST_OLREPORT}; 35 | -------------------------------------------------------------------------------- /driver/plugin/init.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2018, Open AI Lab 22 | * Author: haitao@openailab.com 23 | */ 24 | #include 25 | #include 26 | 27 | #include "logger.hpp" 28 | 29 | namespace TEngine { 30 | extern void CPUDriverInit(void); 31 | } // namespace TEngine 32 | 33 | using namespace TEngine; 34 | 35 | int driver_plugin_init(void) 36 | { 37 | CPUDriverInit(); 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /executor/include/custom_kernel_ops.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __CUSTOM_KERNEL_OPS_HPP 2 | #define __CUSTOM_KERNEL_OPS_HPP 3 | 4 | #include "custom_kernel.hpp" 5 | 6 | namespace TEngine { 7 | 8 | class CustomKernelNodeOps : public NodeOps 9 | { 10 | public: 11 | CustomKernelNodeOps(Node* node, struct custom_kernel_ops* ops) 12 | { 13 | k_ops_ = ops; 14 | k_inputs_ = nullptr; 15 | k_outputs_ = nullptr; 16 | input_num_ = 0; 17 | output_num_ = 0; 18 | } 19 | 20 | ~CustomKernelNodeOps(void); 21 | 22 | bool OnBind(Node* node) override; 23 | bool Prerun(Node* node) override; 24 | bool Reshape(Node* node) override; 25 | bool Run(Node* node) override; 26 | bool Postrun(Node* node) override; 27 | 28 | static NodeOps* NewOps(Node* node, struct custom_kernel_ops* ops); 29 | 30 | protected: 31 | void PrepareOneTensor(Node* node, Tensor* tensor, struct custom_kernel_tensor* t); 32 | bool PrepareTensors(Node* node); 33 | void ReleaseTensors(Node* node); 34 | 35 | struct custom_kernel_ops* k_ops_; 36 | struct custom_kernel_tensor** k_inputs_; 37 | struct custom_kernel_tensor** k_outputs_; 38 | int input_num_; 39 | int output_num_; 40 | }; 41 | 42 | } // namespace TEngine 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /include/compiler.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __COMPILER_HPP__ 2 | #define __COMPILER_HPP__ 3 | 4 | #include 5 | 6 | #define DLLEXPORT __attribute__((visibility("default"))) 7 | 8 | #ifdef __ANDROID__ 9 | 10 | namespace std { 11 | 12 | template std::string to_string(T); 13 | } 14 | 15 | #endif 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /include/utilities/non_copyable.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OAID/Tengine-Convert-Tools/509dadf6381c544ec880d897c815845bddf4ed92/include/utilities/non_copyable.hpp -------------------------------------------------------------------------------- /operator/include/operator/absval.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2019, Open AI Lab 22 | * Author: ddzhao@openailab.com 23 | */ 24 | #ifndef __ABSVAL_HPP__ 25 | #define __ABSVAL_HPP__ 26 | 27 | #include "operator.hpp" 28 | 29 | namespace TEngine { 30 | 31 | class Absval : public OperatorNoParam 32 | { 33 | public: 34 | Absval() 35 | { 36 | name_ = "Absval"; 37 | } 38 | Absval(const Absval& src) = default; 39 | virtual ~Absval(){}; 40 | 41 | void SetSchema(void) override; 42 | }; 43 | 44 | } // namespace TEngine 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /operator/include/operator/accuracy.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2017, Open AI Lab 22 | * Author: haitao@openailab.com 23 | */ 24 | #ifndef __ACCURACY_HPP__ 25 | #define __ACCURACY_HPP__ 26 | 27 | #include "operator.hpp" 28 | 29 | namespace TEngine { 30 | 31 | class Accuracy : public OperatorNoParam 32 | { 33 | public: 34 | Accuracy() 35 | { 36 | name_ = "Accuracy"; 37 | } 38 | Accuracy(const Accuracy&) = default; 39 | virtual ~Accuracy() {} 40 | 41 | void SetSchema(void) override; 42 | }; 43 | } // namespace TEngine 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /operator/include/operator/addn_param.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2017, Open AI Lab 22 | * Author: haitao@openailab.com 23 | */ 24 | #ifndef __ADDN_PARAM_HPP__ 25 | #define __ADDN_PARAM_HPP__ 26 | 27 | #include "parameter.hpp" 28 | 29 | namespace TEngine { 30 | 31 | struct AddnParam : public NamedParam 32 | { 33 | int axis; 34 | DECLARE_PARSER_STRUCTURE(AddnParam) 35 | { 36 | DECLARE_PARSER_ENTRY(axis); 37 | } 38 | }; 39 | 40 | } // namespace TEngine 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /operator/include/operator/argmax_param.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2017, Open AI Lab 22 | * Author: bhu@openailab.com 23 | */ 24 | #ifndef __ARGMAX_PARAM_HPP__ 25 | #define __ARGMAX_PARAM_HPP__ 26 | 27 | #include "parameter.hpp" 28 | 29 | namespace TEngine { 30 | 31 | struct ArgMaxParam : public NamedParam 32 | { 33 | int axis; 34 | int dimension; 35 | int keepdims; 36 | DECLARE_PARSER_STRUCTURE(ArgMaxParam) 37 | { 38 | DECLARE_PARSER_ENTRY(axis); 39 | DECLARE_PARSER_ENTRY(dimension); 40 | DECLARE_PARSER_ENTRY(keepdims); 41 | } 42 | }; 43 | 44 | } // namespace TEngine 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /operator/include/operator/argmin_param.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2017, Open AI Lab 22 | * Author: bhu@openailab.com 23 | */ 24 | #ifndef __ARGMIN_PARAM_HPP__ 25 | #define __ARGMIN_PARAM_HPP__ 26 | 27 | #include "parameter.hpp" 28 | 29 | namespace TEngine { 30 | 31 | struct ArgMinParam : public NamedParam 32 | { 33 | int axis; 34 | int dimension; 35 | int keepdims; 36 | DECLARE_PARSER_STRUCTURE(ArgMinParam) 37 | { 38 | DECLARE_PARSER_ENTRY(axis); 39 | DECLARE_PARSER_ENTRY(dimension); 40 | DECLARE_PARSER_ENTRY(keepdims); 41 | } 42 | }; 43 | 44 | } // namespace TEngine 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /operator/include/operator/bias.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __BIAS_HPP__ 2 | #define __BIAS_HPP__ 3 | 4 | #include "operator.hpp" 5 | #include "bias_param.hpp" 6 | 7 | namespace TEngine { 8 | 9 | class Bias : public OperatorWithParam 10 | { 11 | public: 12 | Bias() 13 | { 14 | name_ = "Bias"; 15 | } 16 | Bias(const Bias& src) = default; 17 | 18 | void SetSchema(void) override; 19 | 20 | bool InferShape(const std::vector&, std::vector&, int layout) override; 21 | }; 22 | } // namespace TEngine 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /operator/include/operator/bias_param.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __BIAS_PARAM_HPP__ 2 | #define __BIAS_PARAM_HPP__ 3 | 4 | #include "parameter.hpp" 5 | 6 | namespace TEngine { 7 | 8 | struct BiasParam : public NamedParam 9 | { 10 | int bias_size; 11 | 12 | DECLARE_PARSER_STRUCTURE(BiasParam) 13 | { 14 | DECLARE_PARSER_ENTRY(bias_size); 15 | } 16 | }; 17 | } // namespace TEngine 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /operator/include/operator/broadmul.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __BROADMUL_HPP__ 2 | #define __BROADMUL_HPP__ 3 | 4 | #include "operator.hpp" 5 | #include "bias_param.hpp" 6 | 7 | namespace TEngine { 8 | 9 | class BroadMul : public OperatorNoParam 10 | { 11 | public: 12 | BroadMul() 13 | { 14 | name_ = "BroadMul"; 15 | } 16 | BroadMul(const BroadMul& src) = default; 17 | 18 | void SetSchema(void) override; 19 | 20 | bool InferShape(const std::vector&, std::vector&, int layout) override; 21 | }; 22 | } // namespace TEngine 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /operator/include/operator/cast.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2019, Open AI Lab 22 | * Author: ddzhao@openailab.com 23 | */ 24 | #ifndef __CAST_HPP__ 25 | #define __CAST_HPP__ 26 | 27 | #include "operator.hpp" 28 | #include "cast_param.hpp" 29 | 30 | namespace TEngine { 31 | 32 | class Cast : public OperatorWithParam 33 | { 34 | public: 35 | Cast() 36 | { 37 | name_ = "Cast"; 38 | } 39 | Cast(const Cast& src) = default; 40 | virtual ~Cast(){}; 41 | 42 | void SetSchema(void) override; 43 | }; 44 | 45 | } // namespace TEngine 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /operator/include/operator/ceil.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __CEIL_HPP__ 2 | #define __CEIL_HPP__ 3 | 4 | #include "operator.hpp" 5 | 6 | namespace TEngine { 7 | 8 | class Ceil : public OperatorNoParam 9 | { 10 | public: 11 | Ceil() 12 | { 13 | name_ = "Ceil"; 14 | } 15 | Ceil(const Ceil& src) = default; 16 | virtual ~Ceil(){}; 17 | 18 | void SetSchema(void) override; 19 | 20 | bool InferShape(const std::vector& ishape, std::vector& oshape, int layout) override; 21 | }; 22 | 23 | } // namespace TEngine 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /operator/include/operator/clip_param.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2019, Open AI Lab 22 | * Author: bingzhang@openailab.com 23 | */ 24 | #ifndef _CLIP_PARAM_HPP_ 25 | #define _CLIP_PARAM_HPP_ 26 | 27 | #include 28 | #include "parameter.hpp" 29 | 30 | namespace TEngine { 31 | 32 | struct ClipParam : public NamedParam 33 | { 34 | float max; 35 | float min; 36 | 37 | DECLARE_PARSER_STRUCTURE(ClipParam) 38 | { 39 | DECLARE_PARSER_ENTRY(max); 40 | DECLARE_PARSER_ENTRY(min); 41 | }; 42 | }; 43 | 44 | } // namespace TEngine 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /operator/include/operator/comparison.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __COMPARISON_HPP__ 2 | #define __COMPARISON_HPP__ 3 | #include "operator.hpp" 4 | #include "comparison_param.hpp" 5 | 6 | namespace TEngine { 7 | 8 | class Comparison : public OperatorWithParam 9 | { 10 | public: 11 | Comparison() 12 | { 13 | name_ = "Comparison"; 14 | } 15 | Comparison(const Comparison& src) = default; 16 | virtual ~Comparison(){}; 17 | 18 | void SetSchema(void) override; 19 | 20 | bool InferShape(const std::vector& ishape, std::vector& oshape, int layout) override; 21 | }; 22 | 23 | } // namespace TEngine 24 | 25 | #endif -------------------------------------------------------------------------------- /operator/include/operator/comparison_param.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __COMPARISON_PARAM_HPP__ 2 | #define __COMPARISON_PARAM_HPP__ 3 | 4 | #include "parameter.hpp" 5 | 6 | enum CompType 7 | { 8 | COMP_EQUAL, 9 | COMP_NOT_EQUAL, 10 | COMP_GREATER, 11 | COMP_GREATER_EQUAL, 12 | COMP_LESS, 13 | COMP_LESS_EQUAL 14 | }; 15 | 16 | namespace TEngine { 17 | 18 | struct ComparisonParam : public NamedParam 19 | { 20 | int type; 21 | 22 | DECLARE_PARSER_STRUCTURE(ComparisonParam) 23 | { 24 | DECLARE_PARSER_ENTRY(type); 25 | }; 26 | }; 27 | 28 | } // namespace TEngine 29 | #endif -------------------------------------------------------------------------------- /operator/include/operator/concat_param.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2017, Open AI Lab 22 | * Author: haitao@openailab.com 23 | */ 24 | #ifndef __CONCAT_PARAM_HPP__ 25 | #define __CONCAT_PARAM_HPP__ 26 | 27 | #include "parameter.hpp" 28 | 29 | namespace TEngine { 30 | 31 | struct ConcatParam : public NamedParam 32 | { 33 | int axis; 34 | 35 | DECLARE_PARSER_STRUCTURE(ConcatParam) 36 | { 37 | DECLARE_PARSER_ENTRY(axis); 38 | } 39 | }; 40 | 41 | } // namespace TEngine 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /operator/include/operator/const_op.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2017, Open AI Lab 22 | * Author: haitao@openailab.com 23 | */ 24 | #ifndef __CONST_OPERATOR_HPP__ 25 | #define __CONST_OPERATOR_HPP__ 26 | 27 | #include "operator.hpp" 28 | 29 | namespace TEngine { 30 | 31 | class ConstOp : public OperatorNoParam 32 | { 33 | public: 34 | ConstOp() 35 | { 36 | name_ = "Const"; 37 | } 38 | ConstOp(const ConstOp& src) = default; 39 | virtual ~ConstOp(){}; 40 | 41 | void SetSchema(void) override; 42 | }; 43 | 44 | } // namespace TEngine 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /operator/include/operator/demo_op.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2018, Open AI Lab 22 | * Author: haitao@openailab.com 23 | */ 24 | #ifndef __DEMO_OP_HPP__ 25 | #define __DEMO_OP_HPP__ 26 | 27 | #include "operator.hpp" 28 | 29 | namespace TEngine { 30 | 31 | class DemoOp : public OperatorNoParam 32 | { 33 | public: 34 | DemoOp() 35 | { 36 | name_ = "DemoOp"; 37 | } 38 | DemoOp(const DemoOp& src) = default; 39 | 40 | bool InferShape(const std::vector& ishape, std::vector& oshape, int layout) override; 41 | 42 | void SetSchema(void) override; 43 | }; 44 | } // namespace TEngine 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /operator/include/operator/depthtospace.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __DEPTHTOSPACE_HPP__ 2 | #define __DEPTHTOSPACE_HPP__ 3 | 4 | #include "operator.hpp" 5 | #include "operator/depthtospace_param.hpp" 6 | 7 | namespace TEngine { 8 | 9 | class DepthToSpace : public OperatorWithParam 10 | { 11 | public: 12 | DepthToSpace() 13 | { 14 | name_ = "DepthToSpace"; 15 | } 16 | 17 | DepthToSpace(const DepthToSpace& src) = default; 18 | 19 | virtual ~DepthToSpace() {} 20 | 21 | void SetSchema(void) override; 22 | 23 | bool InferShape(const std::vector&, std::vector&, int layout) override; 24 | }; 25 | 26 | } // namespace TEngine 27 | #endif -------------------------------------------------------------------------------- /operator/include/operator/depthtospace_param.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __DEPTHTOSPACE_PARAM_HPP__ 2 | #define __DEPTHTOSPACE_PARAM_HPP__ 3 | 4 | #include "parameter.hpp" 5 | 6 | namespace TEngine { 7 | 8 | struct DepthToSpaceParam : public NamedParam 9 | { 10 | int block_size; 11 | /* data */ 12 | DECLARE_PARSER_STRUCTURE(DepthToSpaceParam) 13 | { 14 | DECLARE_PARSER_ENTRY(block_size); 15 | } 16 | }; 17 | 18 | } // namespace TEngine 19 | #endif -------------------------------------------------------------------------------- /operator/include/operator/dropout.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2017, Open AI Lab 22 | * Author: haitao@openailab.com 23 | */ 24 | #ifndef __DROPOUT_HPP__ 25 | #define __DROPOUT_HPP__ 26 | 27 | #include "operator.hpp" 28 | 29 | namespace TEngine { 30 | 31 | class Dropout : public OperatorNoParam 32 | { 33 | public: 34 | Dropout() 35 | { 36 | name_ = "Dropout"; 37 | } 38 | Dropout(const Dropout& src) = default; 39 | 40 | void SetSchema(void) override; 41 | }; 42 | } // namespace TEngine 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /operator/include/operator/elu.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2019, Open AI Lab 22 | * Author: ddzhao@openailab.com 23 | */ 24 | #ifndef __ELU_HPP__ 25 | #define __ELU_HPP__ 26 | 27 | #include "operator.hpp" 28 | #include "operator/elu_param.hpp" 29 | 30 | namespace TEngine { 31 | 32 | class Elu : public OperatorWithParam 33 | { 34 | public: 35 | Elu() 36 | { 37 | name_ = "Elu"; 38 | } 39 | Elu(const Elu&) = default; 40 | 41 | ~Elu() {} 42 | 43 | void SetSchema(void) override; 44 | }; 45 | 46 | } // namespace TEngine 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /operator/include/operator/elu_param.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2019, Open AI Lab 22 | * Author: ddzhao@openailab.com 23 | */ 24 | #ifndef __ELU_PARAM_HPP__ 25 | #define __ELU_PARAM_HPP__ 26 | 27 | #include "parameter.hpp" 28 | 29 | namespace TEngine { 30 | 31 | struct EluParam : public NamedParam 32 | { 33 | float alpha; 34 | 35 | DECLARE_PARSER_STRUCTURE(EluParam) 36 | { 37 | DECLARE_PARSER_ENTRY(alpha); 38 | }; 39 | }; 40 | 41 | } // namespace TEngine 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /operator/include/operator/embed.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __EMBED_HPP__ 2 | #define __EMBED_HPP__ 3 | 4 | #include "operator.hpp" 5 | #include "embed_param.hpp" 6 | 7 | namespace TEngine { 8 | 9 | class Embed : public OperatorWithParam 10 | { 11 | public: 12 | Embed(void) 13 | { 14 | name_ = "Embedding"; 15 | } 16 | Embed(const Embed&) = default; 17 | void SetSchema(void) override; 18 | bool InferShape(const std::vector&, std::vector&, int layout) override; 19 | }; 20 | 21 | } // namespace TEngine 22 | #endif -------------------------------------------------------------------------------- /operator/include/operator/embed_param.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __EMBED_PARAM_HPP__ 2 | #define __EMBED_PARAM_HPP__ 3 | 4 | #include "parameter.hpp" 5 | 6 | namespace TEngine { 7 | 8 | struct EmbedParam : public NamedParam 9 | { 10 | int num_output; 11 | int input_dim; 12 | int bias_term; // if use bias 13 | int weight_data_size; 14 | 15 | DECLARE_PARSER_STRUCTURE(EmbedParam) 16 | { 17 | DECLARE_PARSER_ENTRY(num_output); 18 | DECLARE_PARSER_ENTRY(input_dim); 19 | DECLARE_PARSER_ENTRY(bias_term); 20 | DECLARE_PARSER_ENTRY(weight_data_size); 21 | }; 22 | }; 23 | } // namespace TEngine 24 | #endif 25 | -------------------------------------------------------------------------------- /operator/include/operator/expand_param.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2020, OPEN AI LAB 22 | * Author: jxyang@openailab.com 23 | */ 24 | #ifndef __EXPAND_PARAM_HPP__ 25 | #define __EXPAND_PARAM_HPP__ 26 | 27 | #include "parameter.hpp" 28 | 29 | namespace TEngine { 30 | 31 | struct ExpandParam : public NamedParam 32 | { 33 | std::vector shape; 34 | int dim_num; 35 | DECLARE_PARSER_STRUCTURE(ExpandParam) 36 | { 37 | DECLARE_PARSER_ENTRY(shape); 38 | } 39 | }; 40 | 41 | } // namespace TEngine 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /operator/include/operator/expanddims_param.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2019, Open AI Lab 22 | * Author: bingzhang@openailab.com 23 | */ 24 | #ifndef __EXPANDDIMS_PARAM_HPP__ 25 | #define __EXPANDDIMS_PARAM_HPP__ 26 | 27 | #include "parameter.hpp" 28 | 29 | namespace TEngine { 30 | 31 | struct ExpandDimsParam : public NamedParam 32 | { 33 | int axis; 34 | DECLARE_PARSER_STRUCTURE(ExpandDimsParam) 35 | { 36 | DECLARE_PARSER_ENTRY(axis); 37 | } 38 | }; 39 | 40 | } // namespace TEngine 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /operator/include/operator/fc_param.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2017, Open AI Lab 22 | * Author: haitao@openailab.com 23 | */ 24 | #ifndef __FULLY_CONNECTED_PARAM_HPP__ 25 | #define __FULLY_CONNECTED_PARAM_HPP__ 26 | 27 | #include "parameter.hpp" 28 | 29 | namespace TEngine { 30 | 31 | struct FCParam : public NamedParam 32 | { 33 | int num_output; 34 | 35 | DECLARE_PARSER_STRUCTURE(FCParam) 36 | { 37 | DECLARE_PARSER_ENTRY(num_output); 38 | }; 39 | }; 40 | 41 | } // namespace TEngine 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /operator/include/operator/flatten_param.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2018, Open AI Lab 22 | * Author: chunyinglv@openailab.com 23 | */ 24 | #ifndef __FLATTEN_PARAM_HPP__ 25 | #define __FLATTEN_PARAM_HPP__ 26 | 27 | #include "parameter.hpp" 28 | 29 | namespace TEngine { 30 | 31 | struct FlattenParam : public NamedParam 32 | { 33 | int axis; 34 | int end_axis; 35 | 36 | DECLARE_PARSER_STRUCTURE(FlattenParam) 37 | { 38 | DECLARE_PARSER_ENTRY(axis); 39 | DECLARE_PARSER_ENTRY(end_axis); 40 | }; 41 | }; 42 | 43 | } // namespace TEngine 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /operator/include/operator/fm_param.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2017, Open AI Lab 22 | * Author: haitao@openailab.com 23 | */ 24 | #ifndef __FEATURE_MATCH_PARAM_HPP__ 25 | #define __FEATURE_MATCH_PARAM_HPP__ 26 | 27 | #include "parameter.hpp" 28 | 29 | namespace TEngine { 30 | 31 | struct FMParam : public NamedParam 32 | { 33 | int num_output; 34 | int refreshed; 35 | 36 | DECLARE_PARSER_STRUCTURE(FMParam) 37 | { 38 | DECLARE_PARSER_ENTRY(num_output); 39 | DECLARE_PARSER_ENTRY(refreshed); 40 | }; 41 | }; 42 | 43 | } // namespace TEngine 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /operator/include/operator/gather.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __GATHER_HPP__ 2 | #define __GATHER_HPP__ 3 | 4 | #include "operator.hpp" 5 | #include "gather_param.hpp" 6 | 7 | namespace TEngine { 8 | 9 | class Gather : public OperatorWithParam 10 | { 11 | public: 12 | Gather() 13 | { 14 | name_ = "Gather"; 15 | } 16 | Gather(const Gather& src) = default; 17 | virtual ~Gather(){}; 18 | bool InferShape(const std::vector&, std::vector&, int) override; 19 | void SetSchema(void) override; 20 | }; 21 | 22 | } // namespace TEngine 23 | 24 | #endif -------------------------------------------------------------------------------- /operator/include/operator/gather_param.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __GATHER_PARAM_HPP__ 2 | #define __GATHER_PARAM_HPP__ 3 | 4 | #include "parameter.hpp" 5 | 6 | namespace TEngine { 7 | 8 | struct GatherParam : public NamedParam 9 | { 10 | int axis; 11 | int indices_num; 12 | bool is_onnx; 13 | DECLARE_PARSER_STRUCTURE(GatherParam) 14 | { 15 | DECLARE_PARSER_ENTRY(axis); 16 | DECLARE_PARSER_ENTRY(indices_num); 17 | DECLARE_PARSER_ENTRY(is_onnx); 18 | }; 19 | }; 20 | 21 | } // namespace TEngine 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /operator/include/operator/gru.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __GRU_HPP__ 2 | #define __GRU_HPP__ 3 | 4 | #include "operator.hpp" 5 | #include "gru_param.hpp" 6 | 7 | namespace TEngine { 8 | 9 | class GRU : public OperatorWithParam 10 | { 11 | public: 12 | GRU(void) 13 | { 14 | name_ = "GRU"; 15 | } 16 | GRU(const GRU&) = default; 17 | void SetSchema(void) override; 18 | bool InferShape(const std::vector&, std::vector&, int layout) override; 19 | const char* GetBiasName(void) 20 | { 21 | return "gates/bias"; 22 | } 23 | const char* GetKernelName(void) 24 | { 25 | return "gates/kernel"; 26 | } 27 | const char* GetInitHiddenName(void) 28 | { 29 | return "init_h"; 30 | } 31 | const char* GetCandidateKernelName(void) 32 | { 33 | return "candidate/kernel"; 34 | } 35 | const char* GetCandidateBiasName(void) 36 | { 37 | return "candidate/bias"; 38 | } 39 | const char* Geti2hweightName(void) 40 | { 41 | return "i2h_weight"; 42 | } 43 | const char* Geti2hbiasName(void) 44 | { 45 | return "i2h_bias"; 46 | } 47 | const char* Geth2hweightName(void) 48 | { 49 | return "h2h_weight"; 50 | } 51 | const char* Geth2hbiasName(void) 52 | { 53 | return "h2h_bias"; 54 | } 55 | const char* GetFusedKernelName(void) 56 | { 57 | return "parameters"; 58 | } 59 | }; 60 | 61 | } // namespace TEngine 62 | 63 | #endif -------------------------------------------------------------------------------- /operator/include/operator/hardsigmoid.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __HARDSIGMOID_HPP__ 2 | #define __HARDSIGMOID_HPP__ 3 | 4 | #include "operator.hpp" 5 | #include "hardsigmoid_param.hpp" 6 | 7 | namespace TEngine { 8 | 9 | class Hardsigmoid : public OperatorWithParam 10 | { 11 | public: 12 | Hardsigmoid(void) 13 | { 14 | name_ = "Hardsigmoid"; 15 | } 16 | 17 | Hardsigmoid(const Hardsigmoid&) = default; 18 | void SetSchema(void) override; 19 | bool InferShape(const std::vector&, std::vector&, int layout) override; 20 | }; 21 | 22 | } // namespace TEngine 23 | #endif -------------------------------------------------------------------------------- /operator/include/operator/hardsigmoid_param.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __HARDSIGMOID_PARAM_HPP__ 2 | #define __HARDSIGMOID_PARAM_HPP__ 3 | 4 | #include "parameter.hpp" 5 | 6 | namespace TEngine { 7 | 8 | struct HardsigmoidParam : public NamedParam 9 | { 10 | float alpha; 11 | float beta; 12 | 13 | DECLARE_PARSER_STRUCTURE(HardsigmoidParam) 14 | { 15 | DECLARE_PARSER_ENTRY(alpha); 16 | DECLARE_PARSER_ENTRY(beta); 17 | }; 18 | }; 19 | 20 | } // namespace TEngine 21 | 22 | #endif -------------------------------------------------------------------------------- /operator/include/operator/hardswish.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2021, OPEN AI LAB 22 | * Author: qtang@openailab.com 23 | */ 24 | #ifndef __HARDSWISH_HPP__ 25 | #define __HARDSWISH_HPP__ 26 | 27 | #include "operator.hpp" 28 | 29 | namespace TEngine { 30 | 31 | class Hardswish : public OperatorNoParam 32 | { 33 | public: 34 | Hardswish() 35 | { 36 | name_ = "HardSwish"; 37 | } 38 | Hardswish(const Hardswish& src) = default; 39 | virtual ~Hardswish(){}; 40 | 41 | void SetSchema(void) override; 42 | }; 43 | 44 | } // namespace TEngine 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /operator/include/operator/input_op.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2017, Open AI Lab 22 | * Author: haitao@openailab.com 23 | */ 24 | #ifndef __INPUT_OPERATOR_HPP__ 25 | #define __INPUT_OPERATOR_HPP__ 26 | 27 | #include "operator.hpp" 28 | 29 | namespace TEngine { 30 | 31 | class InputOp : public OperatorNoParam 32 | { 33 | public: 34 | InputOp() 35 | { 36 | name_ = "Input"; 37 | } 38 | 39 | InputOp(const InputOp& src) = default; 40 | 41 | virtual ~InputOp(){}; 42 | 43 | void SetSchema(void) override; 44 | }; 45 | 46 | } // namespace TEngine 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /operator/include/operator/instancenorm.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __INSTANCENORM_HPP__ 2 | #define __INSTANCENORM_HPP__ 3 | 4 | #include "operator.hpp" 5 | #include "instancenorm_param.hpp" 6 | 7 | namespace TEngine { 8 | 9 | class InstanceNorm : public OperatorWithParam 10 | { 11 | public: 12 | InstanceNorm(void) 13 | { 14 | name_ = "InstanceNorm"; 15 | } 16 | InstanceNorm(const InstanceNorm&) = default; 17 | void SetSchema(void) override; 18 | bool InferShape(const std::vector&, std::vector&, int layout) override; 19 | }; 20 | } // namespace TEngine 21 | #endif -------------------------------------------------------------------------------- /operator/include/operator/instancenorm_param.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __INSTANCENORM_PARAM_HPP__ 2 | #define __INSTANCENORM_PARAM_HPP__ 3 | 4 | #include "parameter.hpp" 5 | 6 | namespace TEngine { 7 | 8 | struct InstanceNormParam : public NamedParam 9 | { 10 | float eps; 11 | DECLARE_PARSER_STRUCTURE(InstanceNormParam) 12 | { 13 | DECLARE_PARSER_ENTRY(eps); 14 | }; 15 | }; 16 | 17 | } // namespace TEngine 18 | #endif -------------------------------------------------------------------------------- /operator/include/operator/log_softmax_param.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2017, Open AI Lab 22 | * Author: haitao@openailab.com 23 | */ 24 | #ifndef __LOG_SOFTMAX_PARAM_HPP__ 25 | #define __LOG_SOFTMAX_PARAM_HPP__ 26 | 27 | #include "parameter.hpp" 28 | 29 | namespace TEngine { 30 | 31 | struct LogSoftmaxParam : public NamedParam 32 | { 33 | int axis; 34 | 35 | DECLARE_PARSER_STRUCTURE(LogSoftmaxParam) 36 | { 37 | DECLARE_PARSER_ENTRY(axis); 38 | } 39 | }; 40 | 41 | } // namespace TEngine 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /operator/include/operator/logical.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __LOGICAL_HPP__ 2 | #define __LOGICAL_HPP__ 3 | 4 | #include "operator.hpp" 5 | #include "logical_param.hpp" 6 | 7 | namespace TEngine { 8 | 9 | class Logical : public OperatorWithParam 10 | { 11 | public: 12 | Logical() 13 | { 14 | name_ = "Logical"; 15 | } 16 | Logical(const Logical& src) = default; 17 | virtual ~Logical(){}; 18 | 19 | void SetSchema(void) override; 20 | 21 | bool InferShape(const std::vector& ishape, std::vector& oshape, int layout) override; 22 | }; 23 | 24 | } // namespace TEngine 25 | 26 | #endif -------------------------------------------------------------------------------- /operator/include/operator/logical_param.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __LOGICAL_PARAM_HPP__ 2 | #define __LOGICAL_PARAM_HPP__ 3 | 4 | #include "parameter.hpp" 5 | 6 | enum LogicalType 7 | { 8 | LOGICAL_AND, 9 | LOGICAL_OR, 10 | }; 11 | 12 | namespace TEngine { 13 | 14 | struct LogicalParam : public NamedParam 15 | { 16 | // std::string method; 17 | // LogicalType type; 18 | int type; 19 | 20 | DECLARE_PARSER_STRUCTURE(LogicalParam) 21 | { 22 | DECLARE_PARSER_ENTRY(type); 23 | }; 24 | }; 25 | 26 | } // namespace TEngine 27 | 28 | #endif -------------------------------------------------------------------------------- /operator/include/operator/logistic.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2018, Open AI Lab 22 | * Author: jingyou@openailab.com 23 | */ 24 | #ifndef __LOGISTIC_HPP__ 25 | #define __LOGISTIC_HPP__ 26 | 27 | #include "operator.hpp" 28 | 29 | namespace TEngine { 30 | 31 | class Logistic : public OperatorNoParam 32 | { 33 | public: 34 | Logistic() 35 | { 36 | name_ = "Logistic"; 37 | } 38 | Logistic(const Logistic& src) = default; 39 | virtual ~Logistic(){}; 40 | void SetSchema(void) override; 41 | }; 42 | 43 | } // namespace TEngine 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /operator/include/operator/lrn.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2017, Open AI Lab 22 | * Author: haitao@openailab.com 23 | */ 24 | #ifndef __LRN_HPP__ 25 | #define __LRN_HPP__ 26 | 27 | #include "operator.hpp" 28 | #include "static_graph.hpp" 29 | #include "operator/lrn_param.hpp" 30 | 31 | namespace TEngine { 32 | 33 | class LRN : public OperatorWithParam 34 | { 35 | public: 36 | LRN() 37 | { 38 | name_ = "LRN"; 39 | } 40 | LRN(const LRN& src) = default; 41 | virtual ~LRN() {} 42 | 43 | void SetSchema(void) override; 44 | }; 45 | 46 | } // namespace TEngine 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /operator/include/operator/maximum.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2019, Open AI Lab 22 | * Author: bhu@openailab.com 23 | */ 24 | #ifndef __MAXIMUM_HPP__ 25 | #define __MAXIMUM_HPP__ 26 | 27 | #include "operator.hpp" 28 | 29 | namespace TEngine { 30 | 31 | class Maximum : public OperatorNoParam 32 | { 33 | public: 34 | Maximum() 35 | { 36 | name_ = "Maximum"; 37 | } 38 | Maximum(const Maximum& src) = default; 39 | virtual ~Maximum(){}; 40 | 41 | void SetSchema(void) override; 42 | }; 43 | 44 | } // namespace TEngine 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /operator/include/operator/mean.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2019, Open AI Lab 22 | * Author: bzhang@openailab.com 23 | */ 24 | 25 | #ifndef __MEAN_HPP__ 26 | #define __MEAN_HPP__ 27 | #include "operator.hpp" 28 | 29 | namespace TEngine { 30 | 31 | class Mean : public OperatorNoParam 32 | { 33 | public: 34 | Mean() 35 | { 36 | name_ = "Mean"; 37 | } 38 | Mean(const Mean& src) = default; 39 | virtual ~Mean() {} 40 | void SetSchema(void) override; 41 | }; 42 | } // namespace TEngine 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /operator/include/operator/minimum.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2019, Open AI Lab 22 | * Author: bhu@openailab.com 23 | */ 24 | #ifndef __MINIMUM_HPP__ 25 | #define __MINIMUM_HPP__ 26 | 27 | #include "operator.hpp" 28 | 29 | namespace TEngine { 30 | 31 | class Minimum : public OperatorNoParam 32 | { 33 | public: 34 | Minimum() 35 | { 36 | name_ = "Minimum"; 37 | } 38 | Minimum(const Minimum& src) = default; 39 | virtual ~Minimum(){}; 40 | 41 | void SetSchema(void) override; 42 | }; 43 | 44 | } // namespace TEngine 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /operator/include/operator/mish.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2019, Open AI Lab 22 | * Author: 942002795@qq.com 23 | */ 24 | 25 | #ifndef __MISH_HPP__ 26 | #define __MISH_HPP__ 27 | #include "operator.hpp" 28 | 29 | namespace TEngine { 30 | 31 | class Mish : public OperatorNoParam 32 | { 33 | public: 34 | Mish() 35 | { 36 | name_ = "Mish"; 37 | } 38 | Mish(const Mish& src) = default; 39 | virtual ~Mish() {} 40 | void SetSchema(void) override; 41 | }; 42 | } // namespace TEngine 43 | 44 | #endif -------------------------------------------------------------------------------- /operator/include/operator/mvn.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __MVN_HPP__ 2 | #define __MVN_HPP__ 3 | 4 | #include "operator.hpp" 5 | #include "operator/mvn_param.hpp" 6 | 7 | namespace TEngine { 8 | class MVN : public OperatorWithParam 9 | { 10 | public: 11 | MVN() 12 | { 13 | name_ = "MVN"; 14 | } 15 | MVN(const MVN& src) = default; 16 | virtual ~MVN(){}; 17 | 18 | void SetSchema(void) override; 19 | }; 20 | 21 | } // namespace TEngine 22 | #endif -------------------------------------------------------------------------------- /operator/include/operator/mvn_param.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __MVN_PARAM_HPP__ 2 | #define __MVN_PARAM_HPP__ 3 | 4 | #include "parameter.hpp" 5 | 6 | namespace TEngine { 7 | 8 | struct MVNParam : public NamedParam 9 | { 10 | int normalize_variance; 11 | int across_channels; 12 | float eps; 13 | 14 | DECLARE_PARSER_STRUCTURE(MVNParam) 15 | { 16 | DECLARE_PARSER_ENTRY(normalize_variance); 17 | DECLARE_PARSER_ENTRY(across_channels); 18 | DECLARE_PARSER_ENTRY(eps); 19 | }; 20 | }; 21 | 22 | } // namespace TEngine 23 | 24 | #endif -------------------------------------------------------------------------------- /operator/include/operator/noop.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __NOOP_HPP__ 2 | #define __NOOP_HPP__ 3 | 4 | #include "operator.hpp" 5 | namespace TEngine { 6 | 7 | class Noop : public OperatorNoParam 8 | { 9 | public: 10 | Noop(void) 11 | { 12 | name_ = "Noop"; 13 | } 14 | 15 | Noop(const Noop&) = default; 16 | 17 | bool InferShape(const std::vector&, std::vector&, int layout) override; 18 | void SetSchema(void) override; 19 | }; 20 | 21 | } // namespace TEngine 22 | #endif -------------------------------------------------------------------------------- /operator/include/operator/normalize.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2018, Open AI Lab 22 | * Author: chunyinglv@openailab.com 23 | */ 24 | #ifndef __NORMALIZE_HPP__ 25 | #define __NORMALIZE_HPP__ 26 | 27 | #include "operator.hpp" 28 | #include "normalize_param.hpp" 29 | namespace TEngine { 30 | 31 | class Normalize : public OperatorWithParam 32 | { 33 | public: 34 | Normalize() 35 | { 36 | name_ = "Normalize"; 37 | } 38 | Normalize(const Normalize& src) = default; 39 | virtual ~Normalize(){}; 40 | 41 | void SetSchema(void) override; 42 | }; 43 | 44 | } // namespace TEngine 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /operator/include/operator/normalize_param.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2018, Open AI Lab 22 | * Author: chunyinglv@openailab.com 23 | */ 24 | #ifndef __NORMALIZE_PARAM_HPP__ 25 | #define __NORMALIZE_PARAM_HPP__ 26 | 27 | #include "parameter.hpp" 28 | 29 | namespace TEngine { 30 | 31 | struct NormalizeParam : public NamedParam 32 | { 33 | int across_spatial; 34 | int channel_shared; 35 | 36 | DECLARE_PARSER_STRUCTURE(NormalizeParam) 37 | { 38 | DECLARE_PARSER_ENTRY(across_spatial); 39 | DECLARE_PARSER_ENTRY(channel_shared); 40 | }; 41 | }; 42 | 43 | } // namespace TEngine 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /operator/include/operator/power_param.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2018, Open AI Lab 22 | * Author: chunyinglv@openailab.com 23 | */ 24 | #ifndef __POWER_PARAM_HPP__ 25 | #define __POWER_PARAM_HPP__ 26 | 27 | #include "parameter.hpp" 28 | 29 | namespace TEngine { 30 | 31 | struct PowerParam : public NamedParam 32 | { 33 | float power; 34 | float scale; 35 | float shift; 36 | 37 | DECLARE_PARSER_STRUCTURE(PowerParam) 38 | { 39 | DECLARE_PARSER_ENTRY(power); 40 | DECLARE_PARSER_ENTRY(scale); 41 | DECLARE_PARSER_ENTRY(shift); 42 | } 43 | }; 44 | 45 | } // namespace TEngine 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /operator/include/operator/reciprocal.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2021, OPEN AI LAB 22 | * Author: qtang@openailab.com 23 | */ 24 | #ifndef __RECIPROCAL_HPP__ 25 | #define __RECIPROCAL_HPP__ 26 | 27 | #include "operator.hpp" 28 | 29 | namespace TEngine { 30 | 31 | class Reciprocal : public OperatorNoParam 32 | { 33 | public: 34 | Reciprocal() 35 | { 36 | name_ = "Reciprocal"; 37 | } 38 | Reciprocal(const Reciprocal& src) = default; 39 | virtual ~Reciprocal(){}; 40 | 41 | void SetSchema(void) override; 42 | }; 43 | 44 | } // namespace TEngine 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /operator/include/operator/reducel2_param.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2019, Open AI Lab 22 | * Author: zpluo@openailab.com 23 | */ 24 | #ifndef __REDUCEL2_PARAM_HPP__ 25 | #define __REDUCEL2_PARAM_HPP__ 26 | 27 | #include "parameter.hpp" 28 | 29 | namespace TEngine { 30 | 31 | struct ReduceL2Param : public NamedParam 32 | { 33 | int axis; 34 | int keepdim; 35 | 36 | DECLARE_PARSER_STRUCTURE(ReduceL2Param) 37 | { 38 | DECLARE_PARSER_ENTRY(axis); 39 | DECLARE_PARSER_ENTRY(keepdim); 40 | }; 41 | }; 42 | 43 | } // namespace TEngine 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /operator/include/operator/region.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2018, Open AI Lab 22 | * Author: chunyinglv@openailab.com 23 | */ 24 | #ifndef __REGION_HPP__ 25 | #define __REGION_HPP__ 26 | 27 | #include "operator.hpp" 28 | #include "region_param.hpp" 29 | namespace TEngine { 30 | 31 | class Region : public OperatorWithParam 32 | { 33 | public: 34 | Region() 35 | { 36 | name_ = "Region"; 37 | } 38 | Region(const Region& src) = default; 39 | virtual ~Region(){}; 40 | void SetSchema(void) override; 41 | }; 42 | 43 | } // namespace TEngine 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /operator/include/operator/relu1.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2019, Open AI Lab 22 | * Author: zpluo@openailab.com 23 | */ 24 | 25 | #ifndef __RELU1_HPP__ 26 | #define __RELU1_HPP__ 27 | #include "operator.hpp" 28 | 29 | namespace TEngine { 30 | 31 | class ReLU1 : public OperatorNoParam 32 | { 33 | public: 34 | ReLU1() 35 | { 36 | name_ = "ReLU1"; 37 | } 38 | ReLU1(const ReLU1& src) = default; 39 | virtual ~ReLU1() {} 40 | void SetSchema(void) override; 41 | }; 42 | } // namespace TEngine 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /operator/include/operator/relu_param.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2018, Open AI Lab 22 | * Author: chunyinglv@openailab.com 23 | */ 24 | #ifndef __RELU_PARAM_HPP__ 25 | #define __RELU_PARAM_HPP__ 26 | 27 | #include "parameter.hpp" 28 | 29 | namespace TEngine { 30 | 31 | struct ReLuParam : public NamedParam 32 | { 33 | float negative_slope; 34 | 35 | DECLARE_PARSER_STRUCTURE(ReLuParam) 36 | { 37 | DECLARE_PARSER_ENTRY(negative_slope); 38 | } 39 | }; 40 | 41 | } // namespace TEngine 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /operator/include/operator/reorg_param.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2018, Open AI Lab 22 | * Author: chunyinglv@openailab.com 23 | */ 24 | #ifndef __REORG_PARAM_HPP__ 25 | #define __REORG_PARAM_HPP__ 26 | 27 | #include "parameter.hpp" 28 | 29 | namespace TEngine { 30 | 31 | struct ReorgParam : public NamedParam 32 | { 33 | int stride; 34 | 35 | DECLARE_PARSER_STRUCTURE(ReorgParam) 36 | { 37 | DECLARE_PARSER_ENTRY(stride); 38 | } 39 | }; 40 | 41 | } // namespace TEngine 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /operator/include/operator/rnn.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __RNN_HPP__ 2 | #define __RNN_HPP__ 3 | 4 | #include "operator.hpp" 5 | #include "rnn_param.hpp" 6 | 7 | namespace TEngine { 8 | 9 | class RNN : public OperatorWithParam 10 | { 11 | public: 12 | RNN(void) 13 | { 14 | name_ = "RNN"; 15 | } 16 | RNN(const RNN&) = default; 17 | void SetSchema(void) override; 18 | bool InferShape(const std::vector&, std::vector&, int layout) override; 19 | const char* GetBiasName(void) 20 | { 21 | return "bias"; 22 | } 23 | const char* GetInitHiddenName(void) 24 | { 25 | return "init_h"; 26 | } 27 | }; 28 | 29 | } // namespace TEngine 30 | 31 | #endif -------------------------------------------------------------------------------- /operator/include/operator/roi_pooling_param.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2018, Open AI Lab 22 | * Author: chunyinglv@openailab.com 23 | */ 24 | #ifndef __ROIPOOLING_PARAM_HPP__ 25 | #define __ROIPOOLING_PARAM_HPP__ 26 | 27 | #include "parameter.hpp" 28 | 29 | namespace TEngine { 30 | 31 | struct ROIPoolingParam : public NamedParam 32 | { 33 | int pooled_h; 34 | int pooled_w; 35 | float spatial_scale; 36 | 37 | DECLARE_PARSER_STRUCTURE(ROIPoolingParam) 38 | { 39 | DECLARE_PARSER_ENTRY(spatial_scale); 40 | }; 41 | }; 42 | 43 | } // namespace TEngine 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /operator/include/operator/round.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __ROUND_HPP__ 2 | #define __ROUND_HPP__ 3 | 4 | #include "operator.hpp" 5 | 6 | namespace TEngine { 7 | 8 | class Round : public OperatorNoParam 9 | { 10 | public: 11 | Round() 12 | { 13 | name_ = "Round"; 14 | } 15 | Round(const Round& src) = default; 16 | virtual ~Round(){}; 17 | 18 | void SetSchema(void) override; 19 | 20 | bool InferShape(const std::vector& ishape, std::vector& oshape, int layout) override; 21 | }; 22 | 23 | } // namespace TEngine 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /operator/include/operator/scale.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2017, Open AI Lab 22 | * Author: haitao@openailab.com 23 | */ 24 | #ifndef __SCALE_HPP__ 25 | #define __SCALE_HPP__ 26 | 27 | #include "operator.hpp" 28 | #include "operator/scale_param.hpp" 29 | 30 | namespace TEngine { 31 | 32 | class Scale : public OperatorWithParam 33 | { 34 | public: 35 | Scale() 36 | { 37 | name_ = "Scale"; 38 | } 39 | Scale(const Scale&) = default; 40 | 41 | ~Scale() {} 42 | 43 | void SetSchema(void) override; 44 | }; 45 | 46 | } // namespace TEngine 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /operator/include/operator/scale_param.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2017, Open AI Lab 22 | * Author: haitao@openailab.com 23 | */ 24 | #ifndef __SCALE_PARAM_HPP__ 25 | #define __SCALE_PARAM_HPP__ 26 | 27 | #include "parameter.hpp" 28 | 29 | namespace TEngine { 30 | 31 | struct ScaleParam : public NamedParam 32 | { 33 | int axis; 34 | int num_axes; 35 | int bias_term; 36 | 37 | DECLARE_PARSER_STRUCTURE(ScaleParam) 38 | { 39 | DECLARE_PARSER_ENTRY(axis); 40 | DECLARE_PARSER_ENTRY(num_axes); 41 | DECLARE_PARSER_ENTRY(bias_term); 42 | }; 43 | }; 44 | 45 | } // namespace TEngine 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /operator/include/operator/scatter_param.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2019, Open AI Lab 22 | * Author: bzhang@openailab.com 23 | */ 24 | #ifndef __SCATTER_PARAM_HPP__ 25 | #define __SCATTER_PARAM_HPP__ 26 | 27 | #include "parameter.hpp" 28 | 29 | namespace TEngine { 30 | 31 | struct ScatterParam : public NamedParam 32 | { 33 | int axis; 34 | bool is_onnx; 35 | DECLARE_PARSER_STRUCTURE(ScatterParam) 36 | { 37 | DECLARE_PARSER_ENTRY(axis); 38 | DECLARE_PARSER_ENTRY(is_onnx); 39 | } 40 | }; 41 | 42 | } // namespace TEngine 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /operator/include/operator/selu.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2019, Open AI Lab 22 | * Author: ddzhao@openailab.com 23 | */ 24 | #ifndef __SELU_HPP__ 25 | #define __SELU_HPP__ 26 | 27 | #include "operator.hpp" 28 | #include "operator/selu_param.hpp" 29 | 30 | namespace TEngine { 31 | 32 | class Selu : public OperatorWithParam 33 | { 34 | public: 35 | Selu() 36 | { 37 | name_ = "Selu"; 38 | } 39 | Selu(const Selu&) = default; 40 | 41 | ~Selu() {} 42 | 43 | void SetSchema(void) override; 44 | }; 45 | 46 | } // namespace TEngine 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /operator/include/operator/selu_param.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2019, Open AI Lab 22 | * Author: ddzhao@openailab.com 23 | */ 24 | #ifndef __SELU_PARAM_HPP__ 25 | #define __SELU_PARAM_HPP__ 26 | 27 | #include "parameter.hpp" 28 | 29 | namespace TEngine { 30 | 31 | struct SeluParam : public NamedParam 32 | { 33 | float alpha; 34 | float gamma; 35 | 36 | DECLARE_PARSER_STRUCTURE(SeluParam) 37 | { 38 | DECLARE_PARSER_ENTRY(alpha); 39 | DECLARE_PARSER_ENTRY(gamma); 40 | }; 41 | }; 42 | 43 | } // namespace TEngine 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /operator/include/operator/shuffle_channel_param.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2019, Open AI Lab 22 | * Author: zpluo@openailab.com 23 | */ 24 | #ifndef __SHUFFLE_CHANNEL_PARAM_HPP__ 25 | #define __SHUFFLE_CHANNEL_PARAM_HPP__ 26 | 27 | #include "parameter.hpp" 28 | 29 | namespace TEngine { 30 | 31 | struct ShuffleChannelParam : public NamedParam 32 | { 33 | int group; 34 | 35 | DECLARE_PARSER_STRUCTURE(ShuffleChannelParam) 36 | { 37 | DECLARE_PARSER_ENTRY(group); 38 | }; 39 | }; 40 | 41 | } // namespace TEngine 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /operator/include/operator/softmax.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2017, Open AI Lab 22 | * Author: haitao@openailab.com 23 | */ 24 | #ifndef __SOFTMAX_HPP__ 25 | #define __SOFTMAX_HPP__ 26 | 27 | #include "operator.hpp" 28 | #include "softmax_param.hpp" 29 | namespace TEngine { 30 | 31 | class Softmax : public OperatorWithParam 32 | { 33 | public: 34 | Softmax() 35 | { 36 | name_ = "Softmax"; 37 | } 38 | Softmax(const Softmax& src) = default; 39 | virtual ~Softmax(){}; 40 | 41 | void SetSchema(void) override; 42 | }; 43 | 44 | } // namespace TEngine 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /operator/include/operator/softmax_param.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2017, Open AI Lab 22 | * Author: haitao@openailab.com 23 | */ 24 | #ifndef __SOFTMAX_PARAM_HPP__ 25 | #define __SOFTMAX_PARAM_HPP__ 26 | 27 | #include "parameter.hpp" 28 | 29 | namespace TEngine { 30 | 31 | struct SoftmaxParam : public NamedParam 32 | { 33 | int axis; 34 | 35 | DECLARE_PARSER_STRUCTURE(SoftmaxParam) 36 | { 37 | DECLARE_PARSER_ENTRY(axis); 38 | } 39 | }; 40 | 41 | } // namespace TEngine 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /operator/include/operator/softplus.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2021, OPEN AI LAB 22 | * Author: qtang@openailab.com 23 | */ 24 | #ifndef __SOFTPLUS_HPP__ 25 | #define __SOFTPLUS_HPP__ 26 | 27 | #include "operator.hpp" 28 | 29 | namespace TEngine { 30 | 31 | class Softplus : public OperatorNoParam 32 | { 33 | public: 34 | Softplus() 35 | { 36 | name_ = "Softplus"; 37 | } 38 | Softplus(const Softplus& src) = default; 39 | virtual ~Softplus(){}; 40 | 41 | void SetSchema(void) override; 42 | }; 43 | 44 | } // namespace TEngine 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /operator/include/operator/spacetodepth.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __SPACETODEPTH_HPP__ 2 | #define __SPACETODEPTH_HPP__ 3 | 4 | #include "operator.hpp" 5 | #include "operator/spacetodepth_param.hpp" 6 | 7 | namespace TEngine { 8 | 9 | class SpaceToDepth : public OperatorWithParam 10 | { 11 | public: 12 | SpaceToDepth() 13 | { 14 | name_ = "SpaceToDepth"; 15 | } 16 | 17 | SpaceToDepth(const SpaceToDepth& src) = default; 18 | 19 | virtual ~SpaceToDepth() {} 20 | 21 | void SetSchema(void) override; 22 | 23 | bool InferShape(const std::vector&, std::vector&, int layout) override; 24 | }; 25 | 26 | } // namespace TEngine 27 | #endif -------------------------------------------------------------------------------- /operator/include/operator/spacetodepth_param.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __SPACETODEPTH_PARAM_HPP__ 2 | #define __SPACETODEPTH_PARAM_HPP__ 3 | 4 | #include "parameter.hpp" 5 | 6 | namespace TEngine { 7 | 8 | struct SpaceToDepthParam : public NamedParam 9 | { 10 | int block_size; 11 | /* data */ 12 | DECLARE_PARSER_STRUCTURE(SpaceToDepthParam) 13 | { 14 | DECLARE_PARSER_ENTRY(block_size); 15 | } 16 | }; 17 | 18 | } // namespace TEngine 19 | #endif -------------------------------------------------------------------------------- /operator/include/operator/sparsetodense.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __SPARSETODENSE_HPP__ 2 | #define __SPARSETODENSE_HPP__ 3 | 4 | #include "operator.hpp" 5 | #include "sparsetodense_param.hpp" 6 | 7 | namespace TEngine { 8 | 9 | class SparseToDense : public OperatorWithParam 10 | { 11 | public: 12 | SparseToDense() 13 | { 14 | name_ = "SparseToDense"; 15 | } 16 | SparseToDense(const SparseToDense& src) = default; 17 | 18 | virtual ~SparseToDense() {} 19 | bool InferShape(const std::vector& ishape, std::vector& oshape, 20 | int layout) override; 21 | void SetSchema(void) override; 22 | }; 23 | 24 | } // namespace TEngine 25 | 26 | #endif -------------------------------------------------------------------------------- /operator/include/operator/sparsetodense_param.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __SPARSETODENSE_PARAM_HPP__ 2 | #define __SPARSETODENSE_PARAM_HPP__ 3 | 4 | #include "parameter.hpp" 5 | 6 | namespace TEngine { 7 | 8 | struct SparseToDenseParam : public NamedParam 9 | { 10 | int output_shape_size0; 11 | int output_shape_size1; 12 | int default_value; 13 | 14 | DECLARE_PARSER_STRUCTURE(SparseToDenseParam) 15 | { 16 | DECLARE_PARSER_ENTRY(output_shape_size0); 17 | DECLARE_PARSER_ENTRY(output_shape_size1); 18 | DECLARE_PARSER_ENTRY(default_value); 19 | } 20 | }; 21 | 22 | } // namespace TEngine 23 | 24 | #endif -------------------------------------------------------------------------------- /operator/include/operator/squared_difference.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __SQUARED_DIFFERENCE_HPP__ 2 | #define __SQUARED_DIFFERENCE_HPP__ 3 | 4 | #include "operator.hpp" 5 | 6 | namespace TEngine { 7 | 8 | class SquaredDifference : public OperatorNoParam 9 | { 10 | public: 11 | SquaredDifference() 12 | { 13 | name_ = "SquaredDifference"; 14 | } 15 | SquaredDifference(const SquaredDifference& src) = default; 16 | virtual ~SquaredDifference(){}; 17 | 18 | void SetSchema(void) override; 19 | 20 | bool InferShape(const std::vector& ishape, std::vector& oshape, int layout) override; 21 | }; 22 | 23 | } // namespace TEngine 24 | 25 | #endif -------------------------------------------------------------------------------- /operator/include/operator/swap_axis_param.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2018, Open AI Lab 22 | * Author: haoluo@openailab.com 23 | */ 24 | #ifndef __SWAP_AXIS_PARAM_HPP__ 25 | #define __SWAP_AXIS_PARAM_HPP__ 26 | 27 | #include "parameter.hpp" 28 | 29 | namespace TEngine { 30 | 31 | struct SwapAxisParam : public NamedParam 32 | { 33 | int dim_0; 34 | int dim_1; 35 | DECLARE_PARSER_STRUCTURE(SwapAxisParam) 36 | { 37 | DECLARE_PARSER_ENTRY(dim_0); 38 | DECLARE_PARSER_ENTRY(dim_1); 39 | }; 40 | }; 41 | 42 | } // namespace TEngine 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /operator/include/operator/tanh.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2019, Open AI Lab 22 | * Author: haoluo@openailab.com 23 | */ 24 | #ifndef __TANH_HPP__ 25 | #define __TANH_HPP__ 26 | 27 | #include "operator.hpp" 28 | 29 | namespace TEngine { 30 | 31 | class Tanh : public OperatorNoParam 32 | { 33 | public: 34 | Tanh() 35 | { 36 | name_ = "Tanh"; 37 | } 38 | Tanh(const Tanh& src) = default; 39 | virtual ~Tanh(){}; 40 | 41 | void SetSchema(void) override; 42 | }; 43 | 44 | } // namespace TEngine 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /operator/include/operator/threshold.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __THRESHOLD_HPP__ 2 | #define __THRESHOLD_HPP__ 3 | 4 | #include "operator.hpp" 5 | #include "threshold_param.hpp" 6 | namespace TEngine { 7 | 8 | class Threshold : public OperatorWithParam 9 | { 10 | public: 11 | Threshold() 12 | { 13 | name_ = "Threshold"; 14 | } 15 | Threshold(const Threshold& src) = default; 16 | virtual ~Threshold() {} 17 | 18 | bool InferShape(const std::vector& ishape, std::vector& oshape, int layout) override; 19 | 20 | void SetSchema(void) override; 21 | }; 22 | 23 | } // namespace TEngine 24 | #endif -------------------------------------------------------------------------------- /operator/include/operator/threshold_param.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __THRESHOLD_PARAM_HPP__ 2 | #define __THRESHOLD_PARAM_HPP__ 3 | 4 | #include "parameter.hpp" 5 | namespace TEngine { 6 | 7 | struct ThresholdParam : public NamedParam 8 | { 9 | float threshold; 10 | 11 | DECLARE_PARSER_STRUCTURE(ThresholdParam) 12 | { 13 | DECLARE_PARSER_ENTRY(threshold); 14 | } 15 | }; 16 | 17 | } // namespace TEngine 18 | #endif -------------------------------------------------------------------------------- /operator/include/operator/tile_param.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2019, Open AI Lab 22 | * Author: bingzhang@openailab.com 23 | */ 24 | #ifndef _TILE_PARAM_HPP_ 25 | #define _TILE_PARAM_HPP_ 26 | 27 | #include 28 | #include "parameter.hpp" 29 | 30 | namespace TEngine { 31 | 32 | struct TileParam : public NamedParam 33 | { 34 | int frame_flag; // 0: caffe , 1: onnx 35 | std::vector reps; 36 | 37 | DECLARE_PARSER_STRUCTURE(TileParam) 38 | { 39 | DECLARE_PARSER_ENTRY(frame_flag); 40 | DECLARE_PARSER_ENTRY(reps); 41 | }; 42 | }; 43 | 44 | } // namespace TEngine 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /operator/include/operator/topkv2_param.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2019, Open AI Lab 22 | * Author: bhu@openailab.com 23 | */ 24 | #ifndef __TOPKV2_PARAM_HPP__ 25 | #define __TOPKV2_PARAM_HPP__ 26 | 27 | #include "parameter.hpp" 28 | 29 | namespace TEngine { 30 | 31 | struct TopKV2Param : public NamedParam 32 | { 33 | int k; 34 | bool sorted; 35 | 36 | DECLARE_PARSER_STRUCTURE(TopKV2Param) 37 | { 38 | DECLARE_PARSER_ENTRY(k); 39 | DECLARE_PARSER_ENTRY(sorted); 40 | } 41 | }; 42 | 43 | } // namespace TEngine 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /operator/include/operator/unsqueeze_param.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2019, Open AI Lab 22 | * Author: zpluo@openailab.com 23 | */ 24 | #ifndef __UNSQUEEZE_PARAM_HPP__ 25 | #define __UNSQUEEZE_PARAM_HPP__ 26 | 27 | #include "parameter.hpp" 28 | 29 | namespace TEngine { 30 | 31 | struct UnsqueezeParam : public NamedParam 32 | { 33 | std::vector axises; 34 | 35 | DECLARE_PARSER_STRUCTURE(UnsqueezeParam) 36 | { 37 | DECLARE_PARSER_ENTRY(axises); 38 | } 39 | }; 40 | 41 | } // namespace TEngine 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /operator/include/operator/upsample_param.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2018, Open AI Lab 22 | * Author: zhangrui@openailab.com 23 | */ 24 | #ifndef __UPSAMPLE_PARAM_HPP__ 25 | #define __UPSAMPLE_PARAM_HPP__ 26 | 27 | #include "parameter.hpp" 28 | 29 | namespace TEngine { 30 | 31 | struct UpsampleParam : public NamedParam 32 | { 33 | float scale; 34 | DECLARE_PARSER_STRUCTURE(UpsampleParam) 35 | { 36 | DECLARE_PARSER_ENTRY(scale); 37 | } 38 | }; 39 | 40 | } // namespace TEngine 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /operator/include/operator/where.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2019, Open AI Lab 22 | * Author: qwang02@openailab.com 23 | */ 24 | #ifndef __WHERE_HPP__ 25 | #define __WHERE_HPP__ 26 | 27 | #include "operator.hpp" 28 | namespace TEngine { 29 | 30 | class Where : public OperatorNoParam 31 | { 32 | public: 33 | Where() 34 | { 35 | name_ = "Where"; 36 | } 37 | Where(const Where& src) = default; 38 | virtual ~Where() {} 39 | 40 | void SetSchema(void) override; 41 | }; 42 | 43 | } // namespace TEngine 44 | #endif 45 | -------------------------------------------------------------------------------- /operator/include/operator/zeros_like.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __ZEROS_LIKE_HPP__ 2 | #define __ZEROS_LIKE_HPP__ 3 | 4 | #include "operator.hpp" 5 | 6 | namespace TEngine { 7 | 8 | class ZerosLike : public OperatorNoParam 9 | { 10 | public: 11 | ZerosLike() 12 | { 13 | name_ = "ZerosLike"; 14 | } 15 | ZerosLike(const ZerosLike& src) = default; 16 | virtual ~ZerosLike(){}; 17 | 18 | void SetSchema(void) override; 19 | 20 | bool InferShape(const std::vector& ishape, std::vector& oshape, int layout) override; 21 | }; 22 | 23 | } // namespace TEngine 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /operator/operator/absval.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2019, Open AI Lab 22 | * Author: ddzhao@openailab.com 23 | */ 24 | #include "operator/absval.hpp" 25 | 26 | namespace TEngine { 27 | 28 | void Absval::SetSchema(void) 29 | { 30 | Input({"input:float32"}).Output({"output:float32"}).SetDoc(R"DOC(Absval Layer)DOC"); 31 | } 32 | 33 | } // namespace TEngine 34 | -------------------------------------------------------------------------------- /operator/operator/accuracy.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2017, Open AI Lab 22 | * Author: haitao@openailab.com 23 | */ 24 | #include "operator/accuracy.hpp" 25 | 26 | namespace TEngine { 27 | 28 | void Accuracy::SetSchema(void) 29 | { 30 | Input({"input:float32"}).Output({"output:float32"}).SetDoc(R"DOC(Accuracy Operator)DOC"); 31 | } 32 | 33 | } // namespace TEngine 34 | -------------------------------------------------------------------------------- /operator/operator/addn.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2017, Open AI Lab 22 | * Author: haitao@openailab.com 23 | */ 24 | #include "operator/add_n.hpp" 25 | #include "static_graph.hpp" 26 | 27 | namespace TEngine { 28 | 29 | bool Addn::InferShape(const std::vector& ishape, std::vector& oshape, int layout) 30 | { 31 | oshape[0] = ishape[0]; 32 | return true; 33 | } 34 | 35 | void Addn::SetSchema(void) 36 | { 37 | Input({"input:float32"}).Output({"output:float32"}).SetDoc(R"DOC(Addn Operator)DOC"); 38 | } 39 | 40 | } // namespace TEngine 41 | -------------------------------------------------------------------------------- /operator/operator/bias.cpp: -------------------------------------------------------------------------------- 1 | #include "operator/bias.hpp" 2 | 3 | namespace TEngine { 4 | 5 | bool Bias::InferShape(const std::vector& ishape, std::vector& oshape, int layout) 6 | { 7 | const TShape& input_shape = ishape[0]; 8 | int input_h = input_shape.GetH(); 9 | int input_w = input_shape.GetW(); 10 | 11 | int output_h = input_h; 12 | int output_w = input_w; 13 | 14 | TShape shape; 15 | if (layout == TENGINE_LAYOUT_NCHW) 16 | { 17 | std::vector dim = {input_shape.GetN(), input_shape.GetC(), output_h, output_w}; 18 | 19 | shape.SetDim(dim); 20 | shape.SetDataLayout(TENGINE_LAYOUT_NCHW); 21 | } 22 | else 23 | { 24 | std::vector dim = {input_shape.GetN(), output_h, output_w, input_shape.GetC()}; 25 | 26 | shape.SetDim(dim); 27 | shape.SetDataLayout(TENGINE_LAYOUT_NHWC); 28 | } 29 | oshape[0] = shape; 30 | 31 | return true; 32 | } 33 | 34 | void Bias::SetSchema(void) 35 | { 36 | Input({"input:float", "bias:float"}).Output({"output:float"}).SetAttr("bias_size", 0); 37 | } 38 | 39 | } // namespace TEngine -------------------------------------------------------------------------------- /operator/operator/broadmul.cpp: -------------------------------------------------------------------------------- 1 | #include "operator/broadmul.hpp" 2 | 3 | namespace TEngine { 4 | 5 | bool BroadMul::InferShape(const std::vector& ishape, std::vector& oshape, int layout) 6 | { 7 | const TShape& input_shape = ishape[0]; 8 | 9 | TShape shape; 10 | if (layout == TENGINE_LAYOUT_NCHW) 11 | { 12 | shape.SetDim(input_shape.GetDim()); 13 | shape.SetDataLayout(TENGINE_LAYOUT_NCHW); 14 | } 15 | else 16 | { 17 | return false; 18 | } 19 | 20 | const TShape& input_shape1 = ishape[1]; 21 | const std::vector dim1 = input_shape1.GetDim(); 22 | 23 | oshape[0] = shape; 24 | 25 | return true; 26 | } 27 | 28 | void BroadMul::SetSchema(void) 29 | { 30 | Input({"input0:float", "input1:float"}).Output({"output:float"}); 31 | } 32 | 33 | } // namespace TEngine 34 | -------------------------------------------------------------------------------- /operator/operator/cast.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2019, Open AI Lab 22 | * Author: ddzhao@openailab.com 23 | */ 24 | #include "operator/cast.hpp" 25 | 26 | namespace TEngine { 27 | 28 | void Cast::SetSchema(void) 29 | { 30 | Input({"input:float32"}) 31 | .Output({"output:float32"}) 32 | .SetAttr("type_from", 0) 33 | .SetAttr("type_to", 0) 34 | .SetDoc(R"DOC(Cast Operator)DOC"); 35 | } 36 | 37 | } // namespace TEngine 38 | -------------------------------------------------------------------------------- /operator/operator/ceil.cpp: -------------------------------------------------------------------------------- 1 | #include "operator/ceil.hpp" 2 | #include "static_graph.hpp" 3 | #include 4 | 5 | namespace TEngine { 6 | bool Ceil::InferShape(const std::vector& ishape, std::vector& oshape, int layout) 7 | { 8 | const TShape& input = ishape[0]; 9 | const std::vector& in_dim = input.GetDim(); 10 | 11 | TShape shape; 12 | 13 | shape.SetDim(in_dim); 14 | shape.SetDataLayout(input.GetDataLayout()); 15 | 16 | oshape[0] = shape; 17 | 18 | return true; 19 | } 20 | void Ceil::SetSchema(void) 21 | { 22 | Input({"input:float32"}).Output({"output:int32"}).SetDoc(R"DOC(Ceil Operator)DOC"); 23 | } 24 | 25 | } // namespace TEngine -------------------------------------------------------------------------------- /operator/operator/comparison.cpp: -------------------------------------------------------------------------------- 1 | #include "operator/comparison.hpp" 2 | #include "static_graph.hpp" 3 | #include 4 | 5 | namespace TEngine { 6 | 7 | bool Comparison::InferShape(const std::vector& ishape, std::vector& oshape, int layout) 8 | { 9 | if (ishape.size() == 1) 10 | { 11 | oshape = ishape; 12 | return true; 13 | } 14 | 15 | if (ishape.size() != 2) 16 | { 17 | return false; 18 | } 19 | 20 | int i0_size = ishape[0].GetSize(); 21 | int i1_size = ishape[1].GetSize(); 22 | 23 | if (i0_size >= i1_size) 24 | { 25 | oshape[0] = ishape[0]; 26 | } 27 | else if (i0_size < i1_size) 28 | { 29 | oshape[0] = ishape[1]; 30 | } 31 | 32 | return true; 33 | } 34 | 35 | void Comparison::SetSchema(void) 36 | { 37 | Input({"input:float32"}).Output({"output:float32"}).SetAttr("type", 1); 38 | } 39 | 40 | } // namespace TEngine -------------------------------------------------------------------------------- /operator/operator/const_op.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2017, Open AI Lab 22 | * Author: haitao@openailab.com 23 | */ 24 | #include "operator/const_op.hpp" 25 | 26 | namespace TEngine { 27 | 28 | void ConstOp::SetSchema(void) 29 | { 30 | SetDoc(R"DOC(Const Operator)DOC"); 31 | } 32 | 33 | } // namespace TEngine 34 | -------------------------------------------------------------------------------- /operator/operator/dropout.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2017, Open AI Lab 22 | * Author: haitao@openailab.com 23 | */ 24 | #include "operator/dropout.hpp" 25 | 26 | namespace TEngine { 27 | 28 | void Dropout::SetSchema(void) 29 | { 30 | Input({"input:float32"}).Output({"output:float32"}).SetDoc(R"DOC(Dropout Operator)DOC"); 31 | } 32 | 33 | } // namespace TEngine 34 | -------------------------------------------------------------------------------- /operator/operator/elu.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2019, Open AI Lab 22 | * Author: ddzhao@openailab.com 23 | */ 24 | #include "operator/elu.hpp" 25 | 26 | namespace TEngine { 27 | 28 | void Elu::SetSchema(void) 29 | { 30 | Input({"input:float32"}).Output({"output:float32"}).SetAttr("alpha", 0.1f).SetDoc(R"DOC(Elu Operator)DOC"); 31 | } 32 | 33 | } // namespace TEngine 34 | -------------------------------------------------------------------------------- /operator/operator/embed.cpp: -------------------------------------------------------------------------------- 1 | #include "operator/embed.hpp" 2 | namespace TEngine { 3 | 4 | bool Embed::InferShape(const std::vector& ishape, std::vector& oshape, int layout) 5 | { 6 | const TShape input_shape = ishape[0]; 7 | int word_szie = input_shape.GetSize(); 8 | 9 | std::vector dims(2); 10 | dims[0] = word_szie; 11 | dims[1] = param_.num_output; 12 | oshape[0].SetDim(dims); 13 | 14 | return true; 15 | } 16 | 17 | void Embed::SetSchema(void) 18 | { 19 | Input({"input:float32", "weight:float32", "bias:float32"}) 20 | .Output({"output:float32"}) 21 | .SetAttr("num_output", 0) 22 | .SetAttr("input_dim", 0) 23 | .SetAttr("bias_term", 0) 24 | .SetAttr("weight_data_size", 0); 25 | } 26 | 27 | } // namespace TEngine -------------------------------------------------------------------------------- /operator/operator/floor.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2019, Open AI Lab 22 | * Author: zpluo@openailab.com 23 | */ 24 | #include "operator/floor.hpp" 25 | 26 | namespace TEngine { 27 | 28 | float Floor::GetFops(const std::vector& inputs, const std::vector& outputs) 29 | { 30 | return inputs[0].GetSize(); 31 | } 32 | 33 | void Floor::SetSchema(void) 34 | { 35 | Input({"input:float32"}).Output({"output:float32"}).SetDoc(R"DOC(Floor Operator)DOC"); 36 | } 37 | 38 | } // namespace TEngine -------------------------------------------------------------------------------- /operator/operator/hardsigmoid.cpp: -------------------------------------------------------------------------------- 1 | #include "operator/hardsigmoid.hpp" 2 | 3 | namespace TEngine { 4 | 5 | bool Hardsigmoid::InferShape(const std::vector& ishape, std::vector& oshape, 6 | int layout) 7 | { 8 | const TShape& input_shape = ishape[0]; 9 | int input_h = input_shape.GetH(); 10 | int input_w = input_shape.GetW(); 11 | 12 | int output_h = input_h; 13 | int output_w = input_w; 14 | 15 | TShape shape; 16 | if (layout == TENGINE_LAYOUT_NCHW) 17 | { 18 | std::vector dim = {input_shape.GetN(), input_shape.GetC(), output_h, output_w}; 19 | 20 | shape.SetDim(dim); 21 | shape.SetDataLayout(TENGINE_LAYOUT_NCHW); 22 | } 23 | else 24 | { 25 | std::vector dim = {input_shape.GetN(), output_h, output_w, input_shape.GetC()}; 26 | 27 | shape.SetDim(dim); 28 | shape.SetDataLayout(TENGINE_LAYOUT_NHWC); 29 | } 30 | oshape[0] = shape; 31 | 32 | return true; 33 | } 34 | 35 | void Hardsigmoid::SetSchema(void) 36 | { 37 | Input({"input:float"}).Output({"output:float"}).SetAttr("alpha", 0.2f).SetAttr("beta", 0.5f); 38 | } 39 | 40 | } // namespace TEngine -------------------------------------------------------------------------------- /operator/operator/hardswish.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2021, OPEN AI LAB 22 | * Author: qtang@openailab.com 23 | */ 24 | #include "operator/hardswish.hpp" 25 | 26 | namespace TEngine { 27 | 28 | void Hardswish::SetSchema(void) 29 | { 30 | Input({"input:float32"}).Output({"output:float32"}).SetDoc(R"DOC(HardSwish Operator)DOC"); 31 | } 32 | 33 | } // namespace TEngine 34 | -------------------------------------------------------------------------------- /operator/operator/input_op.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2017, Open AI Lab 22 | * Author: haitao@openailab.com 23 | */ 24 | #include "operator/input_op.hpp" 25 | 26 | namespace TEngine { 27 | 28 | void InputOp::SetSchema(void) 29 | { 30 | SetDoc(R"DOC(Input Data Operator)DOC"); 31 | } 32 | 33 | } // namespace TEngine 34 | -------------------------------------------------------------------------------- /operator/operator/instancenorm.cpp: -------------------------------------------------------------------------------- 1 | #include "operator/instancenorm.hpp" 2 | 3 | namespace TEngine { 4 | 5 | bool InstanceNorm::InferShape(const std::vector& ishape, std::vector& oshape, 6 | int layout) 7 | { 8 | const TShape& input_shape = ishape[0]; 9 | int input_h = input_shape.GetH(); 10 | int input_w = input_shape.GetW(); 11 | 12 | int output_h = input_h; 13 | int output_w = input_w; 14 | 15 | TShape shape; 16 | if (layout == TENGINE_LAYOUT_NCHW) 17 | { 18 | std::vector dim = {input_shape.GetN(), input_shape.GetC(), output_h, output_w}; 19 | 20 | shape.SetDim(dim); 21 | shape.SetDataLayout(TENGINE_LAYOUT_NCHW); 22 | } 23 | else 24 | { 25 | std::vector dim = {input_shape.GetN(), output_h, output_w, input_shape.GetC()}; 26 | 27 | shape.SetDim(dim); 28 | shape.SetDataLayout(TENGINE_LAYOUT_NHWC); 29 | } 30 | oshape[0] = shape; 31 | 32 | return true; 33 | } 34 | 35 | void InstanceNorm::SetSchema(void) 36 | { 37 | Input({"input:float", "gamma:float", "beta:float"}).Output({"output:float"}).SetAttr("eps", 0.001f); 38 | } 39 | 40 | } // namespace TEngine -------------------------------------------------------------------------------- /operator/operator/l2normalization.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2019, Open AI Lab 22 | * Author: lmzhang@openailab.com 23 | */ 24 | #include "operator/l2normalization.hpp" 25 | 26 | namespace TEngine { 27 | 28 | void L2Normalization::SetSchema(void) 29 | { 30 | Input({"input:float32"}).Output({"output:float32"}).SetDoc(R"DOC(input: L2Normalization Layer)DOC"); 31 | } 32 | 33 | } // namespace TEngine 34 | -------------------------------------------------------------------------------- /operator/operator/log_softmax.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2017, Open AI Lab 22 | * Author: haitao@openailab.com 23 | */ 24 | #include "operator/log_softmax.hpp" 25 | 26 | namespace TEngine { 27 | 28 | void LogSoftmax::SetSchema(void) 29 | { 30 | Input({"input:float32"}).Output({"output:float32"}).SetAttr("axis", 3).SetDoc(R"DOC(LogSoftmax Operator)DOC"); 31 | } 32 | 33 | } // namespace TEngine 34 | -------------------------------------------------------------------------------- /operator/operator/logical.cpp: -------------------------------------------------------------------------------- 1 | #include "operator/logical.hpp" 2 | #include "operator/logical_param.hpp" 3 | #include "static_graph.hpp" 4 | #include 5 | 6 | namespace TEngine { 7 | 8 | bool Logical::InferShape(const std::vector& ishape, std::vector& oshape, int layout) 9 | { 10 | if (ishape.size() == 1) 11 | { 12 | oshape = ishape; 13 | return true; 14 | } 15 | 16 | if (ishape.size() != 2) 17 | { 18 | return false; 19 | } 20 | 21 | int i0_size = ishape[0].GetSize(); 22 | int i1_size = ishape[1].GetSize(); 23 | 24 | if (i0_size >= i1_size) 25 | { 26 | oshape[0] = ishape[0]; 27 | } 28 | else if (i0_size < i1_size) 29 | { 30 | oshape[0] = ishape[1]; 31 | } 32 | 33 | return true; 34 | } 35 | 36 | void Logical::SetSchema(void) 37 | { 38 | Input({"input:float32"}).Output({"output:float32"}).SetAttr("type", 0).SetDoc(R"DOC(Logical Layer)DOC"); 39 | } 40 | 41 | } // namespace TEngine -------------------------------------------------------------------------------- /operator/operator/logistic.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2018, Open AI Lab 22 | * Author: jingyou@openailab.com 23 | */ 24 | #include "operator/logistic.hpp" 25 | 26 | namespace TEngine { 27 | 28 | void Logistic::SetSchema(void) 29 | { 30 | Input({"input:float32"}).Output({"output:float32"}).SetDoc(R"DOC(Logistic Layer)DOC"); 31 | } 32 | 33 | } // namespace TEngine 34 | -------------------------------------------------------------------------------- /operator/operator/maximum.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2019, Open AI Lab 22 | * Author: bhu@openailab.com 23 | */ 24 | #include "operator/maximum.hpp" 25 | 26 | namespace TEngine { 27 | 28 | void Maximum::SetSchema(void) 29 | { 30 | Input({"input:float32"}).Output({"output:float32"}).SetDoc(R"DOC(Maximum Layer)DOC"); 31 | } 32 | 33 | } // namespace TEngine 34 | -------------------------------------------------------------------------------- /operator/operator/mean.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2018, Open AI Lab 22 | * Author: bzhang@openailab.com 23 | */ 24 | #include "operator/mean.hpp" 25 | 26 | namespace TEngine { 27 | 28 | void Mean::SetSchema(void) 29 | { 30 | Input({"input:float32"}).Output({"output:float32"}).SetDoc(R"DOC(Mean Operator)DOC"); 31 | } 32 | 33 | } // namespace TEngine 34 | -------------------------------------------------------------------------------- /operator/operator/minimum.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2019, Open AI Lab 22 | * Author: bhu@openailab.com 23 | */ 24 | #include "operator/minimum.hpp" 25 | 26 | namespace TEngine { 27 | 28 | void Minimum::SetSchema(void) 29 | { 30 | Input({"input:float32"}).Output({"output:float32"}).SetDoc(R"DOC(Minimum Layer)DOC"); 31 | } 32 | 33 | } // namespace TEngine 34 | -------------------------------------------------------------------------------- /operator/operator/mish.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2019, Open AI Lab 22 | * Author: 942002795@qq.com 23 | */ 24 | #include "operator/mish.hpp" 25 | 26 | namespace TEngine { 27 | 28 | void Mish::SetSchema(void) 29 | { 30 | Input({"input:float32"}).Output({"output:float32"}).SetDoc(R"DOC(output is tanh(ln(1+e^x)))DOC"); 31 | } 32 | 33 | } // namespace TEngine 34 | -------------------------------------------------------------------------------- /operator/operator/mvn.cpp: -------------------------------------------------------------------------------- 1 | #include "operator/mvn.hpp" 2 | 3 | namespace TEngine { 4 | 5 | void MVN::SetSchema(void) 6 | { 7 | Input({"input:float32"}) 8 | .Output({"output:float32"}) 9 | .SetAttr("normalize_variance", 0) 10 | .SetAttr("across", 0) 11 | .SetAttr("eps", 0.0001f); 12 | } 13 | 14 | } // namespace TEngine -------------------------------------------------------------------------------- /operator/operator/nms.cpp: -------------------------------------------------------------------------------- 1 | #include "operator/nms.hpp" 2 | 3 | namespace TEngine { 4 | 5 | bool NMS::InferShape(const std::vector& ishape, std::vector& oshape, int layout) 6 | { 7 | const TShape& input_shape = ishape[0]; 8 | int dim_num = input_shape.GetSize(); 9 | TShape shape; 10 | std::vector dim = {param_.max_class, dim_num}; 11 | shape.SetDim(dim); 12 | shape.SetDataLayout(TENGINE_LAYOUT_NCHW); 13 | oshape[0] = shape; 14 | return true; 15 | } 16 | 17 | void NMS::SetSchema(void) 18 | { 19 | Input({"input:float32"}) 20 | .Output({"output:float32"}) 21 | .SetAttr("max_class", 0) 22 | .SetAttr("iou_threshold", 0.f) 23 | .SetAttr("score_threshold", 0.f); 24 | } 25 | 26 | } // namespace TEngine -------------------------------------------------------------------------------- /operator/operator/noop.cpp: -------------------------------------------------------------------------------- 1 | #include "operator/noop.hpp" 2 | 3 | namespace TEngine { 4 | 5 | bool Noop::InferShape(const std::vector& ishape, std::vector& oshape, int layout) 6 | { 7 | const TShape& input_shape = ishape[0]; 8 | int input_h = input_shape.GetH(); 9 | int input_w = input_shape.GetW(); 10 | 11 | int output_h = input_h; 12 | int output_w = input_w; 13 | 14 | TShape shape; 15 | if (layout == TENGINE_LAYOUT_NCHW) 16 | { 17 | std::vector dim = {input_shape.GetN(), input_shape.GetC(), output_h, output_w}; 18 | 19 | shape.SetDim(dim); 20 | shape.SetDataLayout(TENGINE_LAYOUT_NCHW); 21 | } 22 | else 23 | { 24 | std::vector dim = {input_shape.GetN(), output_h, output_w, input_shape.GetC()}; 25 | 26 | shape.SetDim(dim); 27 | shape.SetDataLayout(TENGINE_LAYOUT_NHWC); 28 | } 29 | oshape[0] = shape; 30 | 31 | return true; 32 | } 33 | 34 | void Noop::SetSchema(void) 35 | { 36 | Input({"input:float"}).Output({"output:float"}); 37 | } 38 | 39 | } // namespace TEngine -------------------------------------------------------------------------------- /operator/operator/normalize.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2018, Open AI Lab 22 | * Author: chunyinglv@openailab.com 23 | */ 24 | #include "operator/normalize.hpp" 25 | 26 | namespace TEngine { 27 | 28 | void Normalize::SetSchema(void) 29 | { 30 | Input({"input:float32", "scale:float32"}) 31 | .Output({"output:float32"}) 32 | .SetAttr("across_spatial", 0) 33 | .SetAttr("channel_shared", 0) 34 | .SetDoc(R"DOC(Normalize Operator)DOC"); 35 | } 36 | 37 | } // namespace TEngine 38 | -------------------------------------------------------------------------------- /operator/operator/prelu.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2018, Open AI Lab 22 | * Author: chunyinglv@openailab.com 23 | */ 24 | #include "operator/prelu.hpp" 25 | 26 | namespace TEngine { 27 | 28 | float PReLU::GetFops(const std::vector& inputs, const std::vector& outputs) 29 | { 30 | return inputs[0].GetSize(); // to check 31 | } 32 | 33 | void PReLU::SetSchema(void) 34 | { 35 | Input({"input:float32", "slope:float32"}).Output({"output:float32"}).SetDoc(R"DOC(PreLu Operator)DOC"); 36 | } 37 | 38 | } // namespace TEngine 39 | -------------------------------------------------------------------------------- /operator/operator/reciprocal.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2021, OPEN AI LAB 22 | * Author: qtang@openailab.com 23 | */ 24 | #include "operator/reciprocal.hpp" 25 | 26 | namespace TEngine { 27 | 28 | void Reciprocal::SetSchema(void) 29 | { 30 | Input({"input:float32"}).Output({"output:float32"}).SetDoc(R"DOC(Reciprocal Operator)DOC"); 31 | } 32 | 33 | } // namespace TEngine 34 | -------------------------------------------------------------------------------- /operator/operator/region.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2018, Open AI Lab 22 | * Author: chunyinglv@openailab.com 23 | */ 24 | #include "operator/region.hpp" 25 | 26 | namespace TEngine { 27 | 28 | void Region::SetSchema(void) 29 | { 30 | Input({"input:float32"}).Output({"output:float32"}).SetAttr("num_classes", 1).SetDoc(R"DOC(Region Operator)DOC"); 31 | } 32 | 33 | } // namespace TEngine 34 | -------------------------------------------------------------------------------- /operator/operator/relu.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2017, Open AI Lab 22 | * Author: haitao@openailab.com 23 | */ 24 | #include "operator/relu.hpp" 25 | 26 | namespace TEngine { 27 | 28 | float ReLu::GetFops(const std::vector& inputs, const std::vector& outputs) 29 | { 30 | return inputs[0].GetSize(); 31 | } 32 | 33 | void ReLu::SetSchema(void) 34 | { 35 | Input({"input:float32"}).Output({"output:float32"}).SetAttr("negative_slope", 0.f).SetDoc(R"DOC(ReLu Operator)DOC"); 36 | } 37 | 38 | } // namespace TEngine 39 | -------------------------------------------------------------------------------- /operator/operator/relu1.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2019, Open AI Lab 22 | * Author: zpluo@openailab.com 23 | */ 24 | #include "operator/relu1.hpp" 25 | 26 | namespace TEngine { 27 | 28 | void ReLU1::SetSchema(void) 29 | { 30 | Input({"input:float32"}).Output({"output:float32"}).SetDoc(R"DOC(output is max(-1, min(input, 1))DOC"); 31 | } 32 | 33 | } // namespace TEngine 34 | -------------------------------------------------------------------------------- /operator/operator/relu6.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2018, Open AI Lab 22 | * Author: jingyou@openailab.com 23 | */ 24 | #include "operator/relu6.hpp" 25 | 26 | namespace TEngine { 27 | 28 | float ReLu6::GetFops(const std::vector& inputs, const std::vector& outputs) 29 | { 30 | return inputs[0].GetSize(); 31 | } 32 | 33 | void ReLu6::SetSchema(void) 34 | { 35 | Input({"input:float32"}).Output({"output:float32"}).SetDoc(R"DOC(ReLu6 Operator)DOC"); 36 | } 37 | 38 | } // namespace TEngine 39 | -------------------------------------------------------------------------------- /operator/operator/round.cpp: -------------------------------------------------------------------------------- 1 | #include "operator/round.hpp" 2 | #include "static_graph.hpp" 3 | #include 4 | 5 | namespace TEngine { 6 | bool Round::InferShape(const std::vector& ishape, std::vector& oshape, int layout) 7 | { 8 | const TShape& input = ishape[0]; 9 | const std::vector& in_dim = input.GetDim(); 10 | 11 | TShape shape; 12 | 13 | shape.SetDim(in_dim); 14 | shape.SetDataLayout(input.GetDataLayout()); 15 | 16 | oshape[0] = shape; 17 | 18 | return true; 19 | } 20 | void Round::SetSchema(void) 21 | { 22 | Input({"input:float32"}).Output({"output:int32"}).SetDoc(R"DOC(Round Operator)DOC"); 23 | } 24 | 25 | } // namespace TEngine -------------------------------------------------------------------------------- /operator/operator/scale.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2017, Open AI Lab 22 | * Author: haitao@openailab.com 23 | */ 24 | #include "operator/scale.hpp" 25 | #include "static_graph.hpp" 26 | 27 | namespace TEngine { 28 | 29 | void Scale::SetSchema(void) 30 | { 31 | Input({"input:float32", "gamma:float32", "bias:float32"}) 32 | .Output({"output:float32"}) 33 | .SetAttr("axis", 1) 34 | .SetAttr("num_axes", 1) 35 | .SetAttr("bias_term", 0) 36 | .SetDoc(R"DOC(Scale: only caffe flavor scale)DOC"); 37 | } 38 | 39 | } // namespace TEngine 40 | -------------------------------------------------------------------------------- /operator/operator/selu.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2019, Open AI Lab 22 | * Author: ddzhao@openailab.com 23 | */ 24 | #include "operator/selu.hpp" 25 | 26 | namespace TEngine { 27 | 28 | void Selu::SetSchema(void) 29 | { 30 | Input({"input:float32"}) 31 | .Output({"output:float32"}) 32 | .SetAttr("alpha", 1.67326324f) 33 | .SetAttr("gamma", 1.050700987f) 34 | .SetDoc(R"DOC(Selu Operator)DOC"); 35 | } 36 | 37 | } // namespace TEngine 38 | -------------------------------------------------------------------------------- /operator/operator/shuffle_channel.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2017, Open AI Lab 22 | * Author: haitao@openailab.com 23 | */ 24 | #include "operator/shuffle_channel.hpp" 25 | 26 | namespace TEngine { 27 | 28 | void ShuffleChannel::SetSchema(void) 29 | { 30 | Input({"input:float32"}).Output({"output:float32"}).SetAttr("group", 1).SetDoc(R"DOC(Shuffle Channel)DOC"); 31 | } 32 | 33 | } // namespace TEngine 34 | -------------------------------------------------------------------------------- /operator/operator/sigmoid.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2019, Open AI Lab 22 | * Author: haoluo@openailab.com 23 | */ 24 | #include "operator/sigmoid.hpp" 25 | 26 | namespace TEngine { 27 | 28 | float Sigmoid::GetFops(const std::vector& inputs, const std::vector& outputs) 29 | { 30 | return inputs[0].GetSize(); 31 | } 32 | 33 | void Sigmoid::SetSchema(void) 34 | { 35 | Input({"input:float32"}).Output({"output:float32"}).SetDoc(R"DOC(ReLu Operator)DOC"); 36 | } 37 | 38 | } // namespace TEngine 39 | -------------------------------------------------------------------------------- /operator/operator/softmax.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2017, Open AI Lab 22 | * Author: haitao@openailab.com 23 | */ 24 | #include "operator/softmax.hpp" 25 | 26 | namespace TEngine { 27 | 28 | void Softmax::SetSchema(void) 29 | { 30 | Input({"input:float32"}).Output({"output:float32"}).SetAttr("axis", 1).SetDoc(R"DOC(Softmax Operator)DOC"); 31 | } 32 | 33 | } // namespace TEngine 34 | -------------------------------------------------------------------------------- /operator/operator/softplus.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2021, OPEN AI LAB 22 | * Author: qtang@openailab.com 23 | */ 24 | #include "operator/softplus.hpp" 25 | 26 | namespace TEngine { 27 | 28 | void Softplus::SetSchema(void) 29 | { 30 | Input({"input:float32"}).Output({"output:float32"}).SetDoc(R"DOC(Softplus Operator)DOC"); 31 | } 32 | 33 | } // namespace TEngine 34 | -------------------------------------------------------------------------------- /operator/operator/squared_difference.cpp: -------------------------------------------------------------------------------- 1 | #include "operator/squared_difference.hpp" 2 | #include "static_graph.hpp" 3 | #include 4 | 5 | namespace TEngine { 6 | 7 | bool SquaredDifference::InferShape(const std::vector& ishape, std::vector& oshape, int layout) 8 | { 9 | TShape input1 = ishape[0]; 10 | TShape input2 = ishape[1]; 11 | 12 | if (input1.GetDim().size() != input2.GetDim().size()) 13 | { 14 | return false; 15 | } 16 | 17 | int dim_size = input1.GetDim().size(); 18 | for (int i = 0; i < dim_size; i++) 19 | { 20 | if (input1.GetDim()[i] != input2.GetDim()[i]) 21 | { 22 | return false; 23 | } 24 | } 25 | 26 | oshape[0] = input1; 27 | 28 | return true; 29 | } 30 | 31 | void SquaredDifference::SetSchema(void) 32 | { 33 | Input({"input:float32"}).Output({"output:float32"}).SetDoc(R"DOC(SquaredDifference Layer)DOC"); 34 | } 35 | 36 | } // namespace TEngine -------------------------------------------------------------------------------- /operator/operator/tanh.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2019, Open AI Lab 22 | * Author: haoluo@openailab.com 23 | */ 24 | #include "operator/tanh.hpp" 25 | 26 | namespace TEngine { 27 | 28 | void Tanh::SetSchema(void) 29 | { 30 | Input({"input:float32"}).Output({"output:float32"}).SetDoc(R"DOC(Tanh Layer)DOC"); 31 | } 32 | 33 | } // namespace TEngine 34 | -------------------------------------------------------------------------------- /operator/operator/threshold.cpp: -------------------------------------------------------------------------------- 1 | #include "operator/threshold.hpp" 2 | 3 | namespace TEngine { 4 | 5 | bool Threshold::InferShape(const std::vector& ishape, std::vector& oshape, int layout) 6 | { 7 | const TShape& input_shape = ishape[0]; 8 | int input_h = input_shape.GetH(); 9 | int input_w = input_shape.GetW(); 10 | 11 | int output_h = input_h; 12 | int output_w = input_w; 13 | 14 | TShape shape; 15 | if (layout == TENGINE_LAYOUT_NCHW) 16 | { 17 | std::vector dim = {input_shape.GetN(), input_shape.GetC(), output_h, output_w}; 18 | 19 | shape.SetDim(dim); 20 | shape.SetDataLayout(TENGINE_LAYOUT_NCHW); 21 | } 22 | else 23 | { 24 | std::vector dim = {input_shape.GetN(), output_h, output_w, input_shape.GetC()}; 25 | 26 | shape.SetDim(dim); 27 | shape.SetDataLayout(TENGINE_LAYOUT_NHWC); 28 | } 29 | oshape[0] = shape; 30 | 31 | return true; 32 | } 33 | 34 | void Threshold::SetSchema(void) 35 | { 36 | Input({"input:float"}).Output({"output:float"}).SetAttr("threshold", 0); 37 | } 38 | 39 | } // namespace TEngine -------------------------------------------------------------------------------- /operator/operator/unary.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2019, Open AI Lab 22 | * Author: bzhang@openailab.com 23 | */ 24 | #include "operator/unary.hpp" 25 | 26 | namespace TEngine { 27 | 28 | void Unary::SetSchema(void) 29 | { 30 | Input({"input:float32"}).Output({"output:float32"}).SetAttr("type", 0).SetDoc(R"DOC(Unary Operator)DOC"); 31 | } 32 | 33 | } // namespace TEngine 34 | -------------------------------------------------------------------------------- /operator/operator/where.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2019, Open AI Lab 22 | * Author: qwang02@openailab.com 23 | */ 24 | #include "operator/where.hpp" 25 | 26 | namespace TEngine { 27 | 28 | void Where::SetSchema(void) 29 | { 30 | Input({"input:float32"}).Output({"output:float32"}).SetDoc(R"DOC(Where Layer)DOC"); 31 | } 32 | 33 | } // namespace TEngine 34 | -------------------------------------------------------------------------------- /operator/operator/zeros_like.cpp: -------------------------------------------------------------------------------- 1 | #include "operator/zeros_like.hpp" 2 | #include "static_graph.hpp" 3 | #include 4 | 5 | namespace TEngine { 6 | bool ZerosLike::InferShape(const std::vector& ishape, std::vector& oshape, int layout) 7 | { 8 | const TShape& input = ishape[0]; 9 | const std::vector& in_dim = input.GetDim(); 10 | 11 | TShape shape; 12 | 13 | shape.SetDim(in_dim); 14 | shape.SetDataLayout(input.GetDataLayout()); 15 | 16 | oshape[0] = shape; 17 | 18 | return true; 19 | } 20 | void ZerosLike::SetSchema(void) 21 | { 22 | Input({"input:float32"}).Output({"output:float32"}).SetDoc(R"DOC(Zeros_like Operator)DOC"); 23 | } 24 | 25 | } // namespace TEngine -------------------------------------------------------------------------------- /tools/config.hpp.in: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #cmakedefine BUILD_MEGENGINE_SERIALIZER 4 | #cmakedefine BUILD_ONEFLOW_SERIALIZER 5 | -------------------------------------------------------------------------------- /tools/include/darknet_serializer.hpp: -------------------------------------------------------------------------------- 1 | #ifndef __DARKNET_SERIALIZER_HPP__ 2 | #define __DARKNET_SERIALIZER_HPP__ 3 | 4 | #include "serializer.hpp" 5 | #include "te_darknet.hpp" 6 | namespace TEngine { 7 | 8 | class DarkNetSerializer : public Serializer 9 | { 10 | public: 11 | bool LoadModel(const std::vector& file_list, StaticGraph* static_graph) override; 12 | 13 | unsigned int GetFileNum(void) final 14 | { 15 | return 2; 16 | } 17 | 18 | bool LoadConstTensor(const std::string& fname, StaticTensor* const_tensor) override 19 | { 20 | return false; 21 | } 22 | bool LoadConstTensor(int fd, StaticTensor* const_tensor) override 23 | { 24 | return false; 25 | } 26 | DarkNetSerializer(void) 27 | { 28 | name_ = "DarkNet"; 29 | } 30 | protected: 31 | 32 | bool ConstructGraph(StaticGraph* graph,const char*weight_file,list* sections); 33 | 34 | }; 35 | 36 | } // namespace TEngine 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /tools/include/model_patch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2018, Open AI Lab 22 | * Author: haitao@openailab.com 23 | */ 24 | #ifndef __MODEL_PATCH_HPP__ 25 | #define __MODEL_PATCH_HPP__ 26 | 27 | #include 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | #define MAX_MODEL_NAME_LEN (64 - 1) 34 | 35 | struct model_patch 36 | { 37 | char model_name[MAX_MODEL_NAME_LEN + 1]; 38 | uint32_t vendor_id; 39 | uint32_t nn_id; 40 | uint32_t total_size; 41 | uint32_t patch_off; 42 | uint32_t patch_size; 43 | void* addr; 44 | }; 45 | 46 | #ifdef __cplusplus 47 | }; 48 | #endif 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /tools/include/src_tm_serializer.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * License); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | /* 21 | * Copyright (c) 2018, Open AI Lab 22 | * Author: haitao@openailab.com 23 | */ 24 | #ifndef __SRC_TM_SERIALIZER_HPP__ 25 | #define __SRC_TM_SERIALIZER_HPP__ 26 | 27 | #include "patch_serializer.hpp" 28 | 29 | namespace TEngine { 30 | 31 | class SrcTmSerializer : public PatchSerializer 32 | { 33 | public: 34 | SrcTmSerializer(void); 35 | int GetPatchNumber(void) final; 36 | uint32_t GetVendorId(void) final; 37 | uint32_t GetNNId(void) final; 38 | }; 39 | 40 | } // namespace TEngine 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /tools/oneflow/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_package(Protobuf REQUIRED) 2 | 3 | FILE(GLOB_RECURSE ONEFLOW_SERIALIZER_PROTOS "*.proto") 4 | # It is a undocumented variable 5 | set(PROTOBUF_GENERATE_CPP_APPEND_PATH FALSE) 6 | protobuf_generate_cpp(ONEFLOW_PROTO_SRCS ONEFLOW_PROTO_HDRS ${ONEFLOW_SERIALIZER_PROTOS}) 7 | 8 | FILE(GLOB_RECURSE ONEFLOW_SERIALIZER_SRCS "*.cpp") 9 | add_library(oneflow2tengine ${ONEFLOW_SERIALIZER_SRCS} ${ONEFLOW_PROTO_SRCS}) 10 | if (${CMAKE_VERSION} VERSION_LESS "3.9.0") 11 | target_link_libraries(oneflow2tengine ${CMAKE_PROJECT_NAME} ${Protobuf_LIBRARIES}) 12 | target_include_directories(oneflow2tengine PUBLIC ${Protobuf_INCLUDE_DIRS}) 13 | else() 14 | target_link_libraries(oneflow2tengine ${CMAKE_PROJECT_NAME} protobuf::libprotobuf) 15 | endif() 16 | target_include_directories(oneflow2tengine PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) 17 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/actor/act_event.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | message ReadableRegstInfo { 5 | required int64 regst_desc_id = 1; 6 | required int64 act_id = 2; 7 | } 8 | 9 | message ActEvent { 10 | required bool is_experiment_phase = 1; 11 | required int64 actor_id = 2; 12 | required int64 work_stream_id = 3; 13 | required int64 act_id = 4; 14 | required double ready_time = 5; 15 | required double start_time = 6; 16 | required double stop_time = 7; 17 | repeated ReadableRegstInfo readable_regst_infos = 10; 18 | } 19 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/comm_network/ibverbs/ibverbs.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | message IBVerbsMemDescProto { 5 | repeated uint64 mem_ptr = 1; 6 | repeated uint32 mr_rkey = 2; 7 | } 8 | 9 | message IBVerbsConnectionInfo { 10 | required uint32 lid = 1; 11 | required uint32 qp_num = 2; 12 | required uint64 subnet_prefix = 3; 13 | required uint64 interface_id = 4; 14 | } 15 | 16 | message IBVerbsTokensMsg { 17 | map token2mem_desc = 1; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/common/cfg_reflection_test.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package oneflow; 4 | 5 | message ReflectionTestFoo { 6 | required int32 required_int32 = 1; 7 | optional string optional_string = 2 [default = "undefined"]; 8 | 9 | repeated int32 repeated_int32 = 3; 10 | repeated string repeated_string = 4; 11 | map map_int32 = 5; 12 | oneof type { 13 | int32 oneof_int32 = 6; 14 | int32 another_oneof_int32 = 7; 15 | } 16 | } 17 | 18 | message ReflectionTestBar { 19 | required ReflectionTestFoo required_foo = 1; 20 | optional ReflectionTestFoo optional_foo = 2; 21 | 22 | repeated ReflectionTestFoo repeated_foo = 3; 23 | map map_foo = 4; 24 | oneof type { 25 | ReflectionTestFoo oneof_foo = 5; 26 | ReflectionTestFoo another_oneof_foo = 6; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/common/data_type.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | enum DataType { 5 | kInvalidDataType = 0; 6 | kChar = 1; 7 | kFloat = 2; 8 | kDouble = 3; 9 | kInt8 = 4; 10 | kInt32 = 5; 11 | kInt64 = 6; 12 | kUInt8 = 7; 13 | kOFRecord = 8; 14 | kFloat16 = 9; 15 | kTensorBuffer = 10; 16 | } 17 | 18 | message OptInt64 { 19 | optional int64 value = 1 [ default = -1 ]; 20 | } 21 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/common/device_type.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | enum DeviceType { 5 | kInvalidDevice = 0; 6 | kCPU = 1; 7 | kGPU = 2; 8 | } 9 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/common/dtype_signature.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | import "oneflow/core/common/data_type.proto"; 5 | 6 | message DTypeSignature { 7 | map name2dtype = 1; 8 | } 9 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/common/range.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | message RangeProto { 5 | required int64 begin = 1; 6 | required int64 end = 2; 7 | } 8 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/common/shape.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | message ShapeProto { 5 | repeated int64 dim = 1; 6 | } 7 | 8 | message ShapeSignature { 9 | optional string name = 1; 10 | map field2shape_proto = 2; 11 | } 12 | 13 | message ShapeSignatureList { 14 | repeated ShapeSignature shape_signature = 1; 15 | } 16 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/control/ctrl_bootstrap.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | message Address { 5 | required string host = 1; 6 | required int32 port = 2; 7 | } 8 | 9 | message ProcessCtx { 10 | repeated Address ctrl_addr = 1; 11 | required int64 rank = 2; 12 | required int64 node_size = 3; 13 | } 14 | 15 | message BootstrapConf { 16 | required Address master_addr = 1; 17 | required int64 rank = 2; 18 | required int64 world_size = 3; 19 | optional string host = 4; 20 | optional int32 ctrl_port = 5 [default = -1]; 21 | optional int64 node_size = 6 [default = -1]; 22 | optional NumProcessPerNode num_process_per_node = 7; 23 | } 24 | 25 | message NumProcessPerNode { 26 | required int64 value = 1; 27 | } 28 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/control/worker_process_info.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | message WorkerProcessInfo { 5 | required int64 rank = 1; 6 | required int64 port = 2; 7 | optional string host = 3; 8 | } 9 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/eager/eager_instruction.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow.eager; 3 | 4 | import "oneflow/core/vm/instruction.proto"; 5 | import "oneflow/core/eager/eager_symbol.proto"; 6 | 7 | message EagerInstruction { 8 | optional vm.InstructionListProto instruction_list = 1; 9 | optional EagerSymbolList eager_symbol_list = 2; 10 | }; 11 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/eager/eager_symbol.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow.eager; 3 | 4 | import "oneflow/core/job/job_conf.proto"; 5 | import "oneflow/core/job/placement.proto"; 6 | import "oneflow/core/job/scope.proto"; 7 | import "oneflow/core/operator/op_conf.proto"; 8 | import "oneflow/core/operator/op_node_signature.proto"; 9 | 10 | message EagerSymbol { 11 | required int64 symbol_id = 1; 12 | oneof eager_symbol_type { 13 | string string_symbol = 2; 14 | ScopeProto scope_symbol = 3; 15 | JobConfigProto job_conf_symbol = 4; 16 | ParallelConf parallel_conf_symbol = 5; 17 | OperatorConf op_conf_symbol = 6; 18 | OpNodeSignature op_node_signature_symbol = 7; 19 | } 20 | } 21 | 22 | message EagerSymbolList { 23 | repeated EagerSymbol eager_symbol = 1; 24 | } 25 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/framework/config_def.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | import "oneflow/core/framework/user_op_attr.proto"; 5 | 6 | enum ConfigDefType { 7 | kEnvConfigDefType = 1; 8 | kSessionConfigDefType = 2; 9 | kFunctionConfigDefType = 3; 10 | kScopeConfigDefType = 4; 11 | } 12 | 13 | message ConfigDef { 14 | map attr_name2attr_def = 1; 15 | } 16 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/framework/user_op_conf.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | import "oneflow/core/framework/user_op_attr.proto"; 5 | 6 | message UserOpConf { 7 | message ListString { 8 | repeated string s = 1; 9 | } 10 | required string op_type_name = 1; 11 | map input = 2; 12 | map output = 3; 13 | map attr = 4; 14 | } 15 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/framework/user_op_def.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | import "oneflow/core/framework/user_op_attr.proto"; 5 | 6 | message UserOpDef { 7 | required string name = 1; 8 | 9 | message ArgDef { 10 | required string name = 1; 11 | optional bool is_optional = 2 [default = false]; 12 | required int32 num = 3; 13 | required bool num_as_min = 4; 14 | } 15 | repeated ArgDef input = 2; 16 | repeated ArgDef output = 3; 17 | 18 | message AttrDef { 19 | required string name = 1; 20 | required AttrType type = 2; 21 | optional AttrValue default_val = 3; 22 | } 23 | repeated AttrDef attr = 4; 24 | } 25 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/framework/variable_meta_info.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | import "oneflow/core/common/shape.proto"; 5 | import "oneflow/core/common/data_type.proto"; 6 | 7 | message VariableMetaInfo { 8 | required ShapeProto shape = 2; 9 | required DataType data_type = 3; 10 | } 11 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/graph/exec_sequence.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | import "oneflow/core/kernel/kernel.proto"; 5 | 6 | message ExecNodeProto { 7 | required KernelConf kernel_conf = 1; 8 | map bn_in_op2regst_desc_id = 2; 9 | } 10 | 11 | message ExecSequence { 12 | repeated ExecNodeProto exec_node = 1; 13 | } 14 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/job/available_memory_desc.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | message AvailableMemDescOfMachine { 5 | repeated uint64 zone_size = 1; 6 | } 7 | 8 | message AvailableMemDesc { 9 | repeated AvailableMemDescOfMachine machine_amd = 1; 10 | } 11 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/job/blob_lifetime_signature.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | message BlobLastUsedSignature { 5 | map bn_in_op2blob_last_used = 1; 6 | } 7 | 8 | message BlobBackwardUsedSignature { 9 | map bn_in_op2blob_backward_used = 1; 10 | } 11 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/job/cluster_instruction.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | import "oneflow/core/eager/eager_instruction.proto"; 5 | 6 | message ClusterCtrlSessionStart {} 7 | message ClusterCtrlHalt {} 8 | message ClusterCtrlAbort {} 9 | 10 | message ClusterInstructionProto { 11 | oneof instruction_type { 12 | ClusterCtrlSessionStart cluster_ctrl_session_start = 1; 13 | ClusterCtrlHalt cluster_ctrl_halt = 2; // normal exit 14 | eager.EagerInstruction eager_instruction = 3; 15 | ClusterCtrlAbort cluster_ctrl_abort = 5; // error exit 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/job/critical_section.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | message TotalJobCriticalSection {} 5 | message InputOutputCriticalSection { 6 | repeated string lbi_producer_op_name = 1; 7 | } 8 | 9 | message CriticalSection { 10 | required int64 job_id = 1; 11 | map machine_id2source_tick_op_name = 2; 12 | map machine_id2sink_tick_op_name = 3; 13 | repeated int64 mem_block_id = 4; 14 | repeated int64 chunk_id = 5; 15 | oneof type { 16 | TotalJobCriticalSection total_job_critical_section = 6; 17 | InputOutputCriticalSection input_output_critical_section = 7; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/job/distribute_hirarchy.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | import "oneflow/core/job/sbp_parallel.proto"; 5 | 6 | enum DistributeType { 7 | kInvalidDistributeType = 0; 8 | kSpaceDistribute = 2; 9 | kTimeDistribute = 3; 10 | } 11 | 12 | message DistributeDim { 13 | required DistributeType distribute_type = 1; 14 | required SbpParallel sbp_parallel = 2; 15 | required int64 distribute_num = 3; 16 | } 17 | 18 | message DistributeHirarchy { 19 | repeated DistributeDim dim = 1; 20 | } -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/job/dlnet_conf.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | import "oneflow/core/operator/op_conf.proto"; 5 | 6 | message DLNetConf { 7 | repeated OperatorConf op = 1; 8 | } 9 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/job/env.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | import "oneflow/core/control/ctrl_bootstrap.proto"; 5 | 6 | message Machine { 7 | required int64 id = 1; 8 | required string addr = 2; // domain name or ip 9 | optional int32 ctrl_port_agent = 3 [default = -1]; 10 | optional int32 data_port_agent = 4 [default = -1]; 11 | } 12 | 13 | message CppLoggingConf { 14 | optional string log_dir = 1 [default = "./log"]; 15 | optional int32 logtostderr = 2 [default = 0]; 16 | optional int32 logbuflevel = 3 [default = -1]; 17 | } 18 | 19 | message EnvProto { 20 | repeated Machine machine = 1; 21 | required int32 ctrl_port = 2; 22 | optional int32 data_port = 3 [default = -1]; 23 | optional CppLoggingConf cpp_logging_conf = 4; 24 | optional BootstrapConf ctrl_bootstrap_conf = 5; 25 | } 26 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/job/file_system_conf.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | message LocalFsConf { 5 | } 6 | 7 | message NetworkFsConf { 8 | } 9 | 10 | message HdfsConf { 11 | required string namenode = 1; 12 | } 13 | 14 | message FileSystemConf { 15 | oneof fs_type { 16 | LocalFsConf localfs_conf = 1; 17 | NetworkFsConf networkfs_conf = 2; 18 | HdfsConf hdfs_conf = 3; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/job/inter_user_job_info.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | message InterUserJobInfo { 5 | map input_or_var_op_name2push_job_name = 1; 6 | map output_or_var_op_name2pull_job_name = 2; 7 | required string global_model_init_job_name = 4; 8 | required string global_model_load_job_name = 5; 9 | required string global_model_save_job_name = 6; 10 | } 11 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/job/job.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | import "oneflow/core/job/dlnet_conf.proto"; 5 | import "oneflow/core/job/placement.proto"; 6 | import "oneflow/core/job/job_conf.proto"; 7 | import "oneflow/core/register/logical_blob_id.proto"; 8 | import "oneflow/core/register/op_blob_arg.proto"; 9 | import "oneflow/core/register/blob_desc.proto"; 10 | import "oneflow/core/operator/op_conf.proto"; 11 | import "oneflow/core/job/sbp_parallel.proto"; 12 | import "oneflow/core/job/lbi_diff_watcher_info.proto"; 13 | 14 | message JobParallelViewConf { 15 | map op_name2sbp_signature_conf = 1; 16 | map op_name2is_mirrored_parallel_view = 2; 17 | map op_name2parallel_distribution_signature_conf = 3; 18 | } 19 | 20 | message JobHelperConf { 21 | map tag2lbi_relations = 1; 22 | map tag2op_name_relations = 2; 23 | map lbn2logical_blob_desc = 4; 24 | map lbn2logical_object_id = 5; 25 | optional LbiDiffWatcherInfo lbi_diff_watcher_info = 8; 26 | map op_name2arg_signature = 9; 27 | } 28 | 29 | message Job { 30 | required DLNetConf net = 1; 31 | required Placement placement = 2; 32 | required JobConfigProto job_conf = 3; 33 | optional JobParallelViewConf job_parallel_view_conf = 4; 34 | optional JobHelperConf helper = 5; 35 | } 36 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/job/job_set_compile_ctx.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | message JobSetCompileCtxProto { 5 | map var_op_name2random_seed = 1; 6 | } 7 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/job/lbi_diff_watcher_info.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | import "oneflow/core/register/logical_blob_id.proto"; 5 | 6 | message LbiAndDiffWatcherUuidPair { 7 | required LogicalBlobId lbi = 1; 8 | required string watcher_uuid = 2; 9 | } 10 | 11 | message LbiAndDiffWatcherUuidPairList { 12 | repeated LbiAndDiffWatcherUuidPair lbi_and_uuid_pair = 1; 13 | } 14 | 15 | message LbiDiffWatcherInfo { 16 | map job_name2lbi_and_watcher_uuids = 1; 17 | } 18 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/job/mirrored_parallel.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | message MirroredParallel { 5 | } 6 | 7 | message OptMirroredParallel { 8 | optional MirroredParallel mirrored_parallel = 1; 9 | } 10 | 11 | message MirroredSignature { 12 | map bn_in_op2opt_mirrored_parallel = 1; 13 | } 14 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/job/parallel_conf_signature.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | import "oneflow/core/job/placement.proto"; 5 | 6 | message ParallelConfSignature { 7 | optional ParallelConf op_parallel_conf = 1; 8 | map bn_in_op2parallel_conf = 2; 9 | } 10 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/job/parallel_signature.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | message ParallelSignature { 5 | optional int64 op_parallel_desc_symbol_id = 1; 6 | map bn_in_op2parallel_desc_symbol_id = 2; 7 | } 8 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/job/placement.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | import "oneflow/core/register/logical_blob_id.proto"; 5 | import "oneflow/core/common/shape.proto"; 6 | 7 | message ParallelContext { 8 | required int64 parallel_id = 1; 9 | required int64 parallel_num = 2; 10 | } 11 | 12 | message ParallelConf { 13 | repeated string device_name = 1; 14 | required string device_tag = 2; 15 | optional ShapeProto hierarchy = 3; 16 | } 17 | 18 | message OpNameSet { 19 | repeated string op_name = 1; 20 | } 21 | 22 | message PlacementGroup { 23 | required OpNameSet op_set = 1; 24 | required ParallelConf parallel_conf = 2; 25 | } 26 | 27 | message BlobPlacementGroup { 28 | repeated LogicalBlobId lbi = 1; 29 | required ParallelConf parallel_conf = 2; 30 | } 31 | 32 | message Placement { 33 | repeated PlacementGroup placement_group = 1; 34 | repeated BlobPlacementGroup blob_placement_group = 2; 35 | } 36 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/job/plan.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | import "oneflow/core/job/task.proto"; 5 | import "oneflow/core/job/job_conf.proto"; 6 | import "oneflow/core/memory/memory_block.proto"; 7 | import "oneflow/core/graph/boxing/collective_boxing.proto"; 8 | import "oneflow/core/operator/op_attribute.proto"; 9 | 10 | message MachineIds { 11 | repeated int64 machine_id = 1; 12 | } 13 | 14 | message NetTopo { 15 | map peer_machine_ids = 1; 16 | } 17 | 18 | message JobConfs { 19 | map job_id2job_conf = 1; 20 | } 21 | 22 | message CollectiveBoxingPlan { 23 | map job_id2request_set = 1; 24 | } 25 | 26 | message CtrlRegstDescInfo { 27 | map ctrl_regst_desc_id2producer_task_id = 6; 28 | } 29 | 30 | message OpAttributeRefTable { 31 | map op_name2op_attribute = 1; 32 | } 33 | 34 | message OpAttributeInfo { 35 | map job_id2op_attribute_ref_table = 1; 36 | } 37 | 38 | message Plan { 39 | repeated TaskProto task = 1; 40 | required MemBlockAndChunkList block_chunk_list = 2; 41 | required NetTopo net_topo = 3; 42 | required JobConfs job_confs = 4; 43 | required CollectiveBoxingPlan collective_boxing_plan= 5; 44 | required CtrlRegstDescInfo ctrl_regst_desc_info = 6; 45 | map job_id2op_attribute_ref_table = 7; 46 | } 47 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/job/regularizer_conf.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | message L1L2RegularizerConf { 5 | optional float l1 = 1 [default = 0.0]; 6 | optional float l2 = 2 [default = 0.0]; 7 | } 8 | 9 | message RegularizerConf { 10 | oneof type { 11 | L1L2RegularizerConf l1_l2_conf = 1; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/job/scope.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | import "oneflow/core/job/mirrored_parallel.proto"; 5 | import "oneflow/core/framework/user_op_attr.proto"; 6 | 7 | message ScopeProto { 8 | required int64 job_desc_symbol_id = 20; 9 | required int64 device_parallel_desc_symbol_id = 30; 10 | required int64 host_parallel_desc_symbol_id = 40; 11 | optional bool enable_cpu_alternative_op = 41 [default = true]; 12 | required OptMirroredParallel opt_mirrored_parallel_conf = 50; 13 | repeated string scope_op_name_prefixes = 60; 14 | optional int64 parent_scope_symbol_id = 70; 15 | required int64 session_id = 80; 16 | map attr_name2attr_value = 90; 17 | optional string calculation_pass_name = 100 [default = "forward_pass"]; 18 | } 19 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/job/sub_plan.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | import "oneflow/core/job/task.proto"; 5 | 6 | message ThrdIds { 7 | repeated int64 thrd_id = 1; 8 | } 9 | 10 | message ClusterThrdIds { 11 | map machine_id2thrd_ids = 1; 12 | } 13 | 14 | message SubPlan { 15 | repeated TaskProto task = 1; 16 | } 17 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/memory/memory_block.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | import "oneflow/core/memory/memory_case.proto"; 5 | 6 | message MemBlockProto { 7 | required int64 mem_block_id = 1; 8 | repeated int64 job_id = 2; 9 | required int64 machine_id = 3; 10 | required MemoryCase mem_case = 4; 11 | required bool enable_reuse_mem = 5; 12 | optional int64 chunk_id = 6 [default = -1]; 13 | optional int64 chunk_offset = 7 [default = -1]; 14 | required int64 mem_size = 8; 15 | // NOTE(chengcheng): thrd id hint is used by packed separated block group order. 16 | optional int64 thrd_id_hint = 9 [default = -1]; 17 | } 18 | 19 | message ChunkProto { 20 | required int64 chunk_id = 1; 21 | repeated int64 job_id = 2; 22 | required int64 machine_id = 3; 23 | required MemoryCase mem_case = 4; 24 | required int64 mem_size = 5; 25 | } 26 | 27 | message MemBlockAndChunkList { 28 | repeated MemBlockProto mem_block = 1; 29 | repeated ChunkProto chunk = 2; 30 | } 31 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/memory/memory_case.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | message CudaPinnedMemory { 5 | required int64 device_id = 1; 6 | } 7 | 8 | message HostMemory { 9 | optional CudaPinnedMemory cuda_pinned_mem = 1; 10 | optional bool used_by_network = 2 [default = false]; 11 | } 12 | 13 | message DeviceCudaMemory { 14 | required int64 device_id = 1; 15 | } 16 | 17 | message MemoryCase { 18 | oneof case { 19 | HostMemory host_mem = 1; 20 | DeviceCudaMemory device_cuda_mem = 2; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/object_msg/object_msg_field_list.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | message ObjectMsgFieldTypeAndName { 5 | required string field_type = 1; 6 | required string field_name = 2; 7 | optional string pointer_removed_field_type = 3; 8 | }; 9 | 10 | message ObjectMsgUnionFieldList { 11 | required string union_name = 1; 12 | repeated ObjectMsgFieldTypeAndName union_field = 2; 13 | } 14 | 15 | message ObjectMsgField { 16 | oneof field_type { 17 | ObjectMsgUnionFieldList union_field_list = 1; 18 | ObjectMsgFieldTypeAndName struct_field = 2; 19 | } 20 | } 21 | 22 | message ObjectMsgFieldList { 23 | repeated ObjectMsgField object_msg_field = 1; 24 | } 25 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/operator/arg_modifier_signature.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | message InputBlobModifier { 5 | optional bool is_mutable = 1 [default = false]; 6 | optional bool requires_grad = 3 [default = false]; 7 | } 8 | 9 | message OutputBlobModifier { 10 | optional bool is_mutable = 1 [default = false]; 11 | optional bool requires_grad = 2 [default = false]; 12 | optional bool header_infered_before_compute = 3 [default = true]; 13 | oneof inplace_type { 14 | string mutable_inplace_ibn = 20; 15 | string const_inplace_ibn = 21; 16 | } 17 | } 18 | 19 | message ArgModifierSignature { 20 | map ibn2input_blob_modifier = 1; 21 | map obn2output_blob_modifier = 2; 22 | } 23 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/operator/interface_blob_conf.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | import "oneflow/core/common/shape.proto"; 5 | import "oneflow/core/common/data_type.proto"; 6 | import "oneflow/core/job/sbp_parallel.proto"; 7 | 8 | message InterfaceBlobConf { 9 | optional ShapeProto shape = 1; 10 | optional DataType data_type = 2; 11 | optional bool is_dynamic = 3; 12 | optional ParallelDistribution parallel_distribution = 4; 13 | } 14 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/operator/op_node_signature.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | import "oneflow/core/job/sbp_parallel.proto"; 5 | import "oneflow/core/job/mirrored_parallel.proto"; 6 | import "oneflow/core/register/blob_desc.proto"; 7 | import "oneflow/core/job/parallel_signature.proto"; 8 | 9 | message OpNodeSignature { 10 | optional SbpSignature sbp_signature = 1; 11 | optional MirroredSignature mirrored_signature = 2; 12 | optional BlobDescSignature logical_blob_desc_signature = 3; 13 | optional ParallelSignature parallel_signature = 5; 14 | } 15 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/record/coco.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | import "oneflow/core/record/record.proto"; 5 | 6 | message PolygonList { 7 | repeated FloatList polygons = 1; 8 | } 9 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/record/record.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | message BytesList { 5 | repeated bytes value = 1; 6 | } 7 | 8 | message FloatList { 9 | repeated float value = 1 [packed = true]; 10 | } 11 | 12 | message DoubleList { 13 | repeated double value = 1 [packed = true]; 14 | } 15 | 16 | message Int32List { 17 | repeated int32 value = 1 [packed = true]; 18 | } 19 | 20 | message Int64List { 21 | repeated int64 value = 1 [packed = true]; 22 | } 23 | 24 | message Feature { 25 | oneof kind { 26 | BytesList bytes_list = 1; 27 | FloatList float_list = 2; 28 | DoubleList double_list = 3; 29 | Int32List int32_list = 4; 30 | Int64List int64_list = 5; 31 | } 32 | } 33 | 34 | message OFRecord { 35 | map feature = 1; 36 | } 37 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/register/blob_desc.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | import "oneflow/core/common/shape.proto"; 5 | import "oneflow/core/common/data_type.proto"; 6 | 7 | message BlobDescProto { 8 | required ShapeProto shape = 1; 9 | required DataType data_type = 2; 10 | required bool is_dynamic = 3; 11 | } 12 | 13 | message BlobDescSignature { 14 | map bn_in_op2blob_desc = 1; 15 | } 16 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/register/logical_blob_id.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | message LogicalBlobId { 5 | optional string op_name = 1; 6 | optional string blob_name = 2; 7 | } 8 | 9 | message LogicalBlobIdPair { 10 | required LogicalBlobId first = 1; 11 | required LogicalBlobId second = 2; 12 | } 13 | 14 | message LogicalBlobIdPairs { 15 | repeated LogicalBlobIdPair pair = 1; 16 | } 17 | 18 | message LogicalBlobIdGroups { 19 | message LogicalBlobIdGroup { 20 | repeated LogicalBlobId lbi = 1; 21 | } 22 | repeated LogicalBlobIdGroup lbi_group = 2; 23 | } 24 | 25 | message ArgSignature { 26 | map bn_in_op2lbi = 1; 27 | } 28 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/register/op_blob_arg.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | message OpBlobArg { 5 | required string op_name = 1; 6 | // blob name in op 7 | required string bn_in_op = 2; 8 | } 9 | 10 | message OpBlobArgPair { 11 | required OpBlobArg first = 1; 12 | required OpBlobArg second = 2; 13 | } 14 | 15 | message OpBlobArgPairs { 16 | repeated OpBlobArgPair pair = 1; 17 | } 18 | 19 | message OpBlobArgList { 20 | repeated OpBlobArg oba = 1; 21 | } 22 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/register/pod.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | import "oneflow/core/common/shape.proto"; 5 | import "oneflow/core/common/data_type.proto"; 6 | import "oneflow/core/register/logical_blob_id.proto"; 7 | 8 | message TensorPodProto { 9 | required ShapeProto shape = 1; 10 | required DataType data_type = 2; 11 | } 12 | 13 | message StructPodProto { 14 | repeated FieldPodProto field = 1; 15 | } 16 | 17 | enum FieldKey { 18 | kInvalidFieldKey = 0; 19 | kTensorShape = 1; 20 | kFieldKeySize = 2; 21 | } 22 | 23 | message FieldId { 24 | oneof field_id_type { 25 | FieldKey key = 1; 26 | LogicalBlobId lbi = 2; 27 | } 28 | } 29 | 30 | message FieldPodProto { 31 | required FieldId field_id = 1; 32 | required int32 alignment = 2; 33 | required PodProto pod = 3; 34 | } 35 | 36 | message PodProto { 37 | oneof pod_type { 38 | TensorPodProto tensor_pod = 1; 39 | StructPodProto struct_pod = 2; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/register/tensor_slice_view.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | import "oneflow/core/common/range.proto"; 5 | 6 | message TensorSliceViewProto { 7 | repeated RangeProto dim = 1; 8 | } 9 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/serving/saved_model.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow; 3 | 4 | import "oneflow/core/operator/op_conf.proto"; 5 | import "oneflow/core/job/job_conf.proto"; 6 | 7 | message SavedModel { 8 | required string name = 1; 9 | required int64 version = 2; 10 | required string checkpoint_dir = 3; 11 | map graphs = 4; 12 | optional string default_graph_name = 5; 13 | } 14 | 15 | message GraphDef { 16 | repeated OperatorConf op_list = 1; 17 | map signatures = 2; 18 | optional string default_signature_name = 3; 19 | } 20 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/summary/event.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow.summary; 3 | 4 | import "oneflow/core/summary/summary.proto"; 5 | 6 | message Event { 7 | required double wall_time = 1; 8 | optional int64 step = 2; 9 | oneof what { 10 | string file_version = 3; 11 | bytes graph_def = 4; 12 | Summary summary = 5; 13 | bytes meta_graph_def = 9; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/summary/graph.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow.summary; 3 | 4 | import "oneflow/core/framework/user_op_attr.proto"; 5 | 6 | message GraphDef { 7 | repeated NodeDef node = 1; 8 | required int32 version = 2 [deprecated = true]; 9 | } 10 | 11 | 12 | message NodeDef { 13 | required string name = 1; 14 | required string op = 2; 15 | repeated string input = 3; 16 | optional string device = 4; 17 | map attr = 5; 18 | } 19 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/summary/plugin_data.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow.summary; 3 | 4 | import "google/protobuf/struct.proto"; 5 | 6 | message HParamsPluginData { 7 | required int32 version = 1; 8 | oneof data { 9 | SessionStartInfo session_start_info = 3; 10 | } 11 | } 12 | 13 | message SessionStartInfo { 14 | map hparams = 1; 15 | required string group_name = 4; 16 | required double start_time_secs = 5; 17 | map metrics = 6; 18 | } 19 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/summary/projector.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow.summary; 3 | 4 | message MetaData { 5 | enum ProjectorType { 6 | EMBEDDING = 0; 7 | EXCEPTION = 1; 8 | } 9 | required ProjectorType type = 1; 10 | //Metadata specific information 11 | optional string content = 2; 12 | } 13 | 14 | message Tensor { 15 | message TensorShape { 16 | message Dim { 17 | required int64 size = 1; 18 | optional string name = 2; 19 | } 20 | repeated Dim dim = 1; 21 | } 22 | required string dtype = 1; 23 | required TensorShape shape = 2; 24 | optional bytes content = 3; 25 | } 26 | 27 | message Sample{ 28 | enum SampleType { 29 | IMAGE = 0; 30 | AUDIO = 1; 31 | TEXT = 2; 32 | } 33 | required string name = 1; 34 | required SampleType type = 2; 35 | required Tensor X = 3; 36 | } 37 | 38 | message Projector { 39 | required string tag = 1; 40 | optional int64 step = 2; 41 | required double WALL_TIME = 3; 42 | required Tensor value = 4; 43 | optional Tensor label = 5; 44 | } 45 | 46 | message SummaryProjector { 47 | required MetaData metadata = 6; 48 | optional Sample sample = 2; 49 | repeated Projector projector = 1; 50 | } 51 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/summary/summary.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow.summary; 3 | 4 | import "oneflow/core/summary/tensor.proto"; 5 | 6 | message SummaryMetadata { 7 | message PluginData { 8 | required string plugin_name = 1; 9 | optional bytes content = 2; 10 | } 11 | required PluginData plugin_data = 1; 12 | optional string display_name = 2; 13 | optional string summary_description = 3; 14 | }; 15 | 16 | message HistogramProto { 17 | required double min = 1; 18 | required double max = 2; 19 | required double num = 3; 20 | required double sum = 4; 21 | required double sum_squares = 5; 22 | repeated double bucket_limit = 6 [packed = true]; 23 | repeated double bucket = 7 [packed = true]; 24 | }; 25 | 26 | message Image { 27 | required int32 height = 1; 28 | required int32 width = 2; 29 | required int32 colorspace = 3; 30 | required bytes encoded_image_string = 4; 31 | }; 32 | 33 | message Summary { 34 | message Value { 35 | optional string node_name = 7; 36 | required string tag = 1; 37 | optional SummaryMetadata metadata = 9; 38 | oneof value { 39 | float simple_value = 2; 40 | bytes obsolete_old_style_histogram = 3; 41 | Image image = 4; 42 | HistogramProto histo = 5; 43 | //Audio audio = 6; 44 | TensorProto tensor = 8; 45 | } 46 | } 47 | repeated Value value = 1; 48 | } 49 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/summary/tensor.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow.summary; 3 | 4 | message TensorProto { 5 | required TensorDataType dtype = 1; 6 | required TensorShapeProto tensor_shape = 2; 7 | optional int32 version_number = 3; 8 | optional bytes tensor_content = 4; 9 | repeated float float_val = 5 [packed = true]; 10 | repeated double double_val = 6 [packed = true]; 11 | repeated int32 int_val = 7 [packed = true]; 12 | repeated bytes string_val = 8; 13 | repeated int64 int64_val = 9 [packed = true]; 14 | repeated bool bool_val = 10 [packed = true]; 15 | repeated uint32 uint32_val = 11 [packed = true]; 16 | repeated uint64 uint64_val = 12 [packed = true]; 17 | repeated int32 half_val = 13 [packed = true]; 18 | }; 19 | 20 | message TensorShapeProto { 21 | message Dim { 22 | required int64 size = 1; 23 | optional string name = 2; 24 | }; 25 | repeated Dim dim = 2; 26 | }; 27 | 28 | 29 | enum TensorDataType { 30 | DT_INVALID = 0; 31 | DT_FLOAT = 1; 32 | DT_DOUBLE = 2; 33 | DT_INT32 = 3; 34 | DT_UINT8 = 4; 35 | DT_INT16 = 5; 36 | DT_INT8 = 6; 37 | DT_STRING = 7; 38 | DT_INT64 = 8; 39 | DT_UINT16 = 9; 40 | DT_HALF = 10; 41 | DT_UINT32 = 11; 42 | DT_UINT64 = 12; 43 | } 44 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/core/vm/instruction.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | package oneflow.vm; 3 | 4 | message CurrentGlobalDeviceIdProto {} 5 | message SoleMirroredObjectProto {} 6 | message AllMirroredObjectProto {} 7 | 8 | message OperandProto { 9 | required int64 logical_object_id = 1; 10 | oneof operand_type { 11 | CurrentGlobalDeviceIdProto current_global_device_id = 2; 12 | SoleMirroredObjectProto sole_mirrored_object = 3; 13 | AllMirroredObjectProto all_mirrored_object = 4; 14 | } 15 | } 16 | 17 | message OperandSeparatorProto { } 18 | 19 | message InstructionOperandProto { 20 | oneof type { 21 | // read only object 22 | OperandProto const_operand = 1; 23 | // writeable object 24 | OperandProto mut_operand = 2; 25 | // mut2 writeable object 26 | OperandProto mut2_operand = 3; 27 | OperandProto del_operand = 4; 28 | // read only symbol 29 | OperandProto symbol_operand = 5; 30 | // initializable symbol 31 | OperandProto init_symbol_operand = 6; 32 | 33 | OperandSeparatorProto separator = 7; 34 | double double_operand = 8; 35 | int64 int64_operand = 9; 36 | uint64 uint64_operand = 10; 37 | bool bool_operand = 11; 38 | } 39 | } 40 | 41 | message InstructionProto { 42 | required string instr_type_name = 1; 43 | optional int64 parallel_desc_symbol_id = 2 [default = 0]; 44 | repeated InstructionOperandProto operand = 3; 45 | }; 46 | 47 | message InstructionListProto { 48 | repeated InstructionProto instruction = 1; 49 | } 50 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/xrt/types.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package oneflow.xrt; 4 | 5 | enum XrtDevice { 6 | CPU_X86 = 1; 7 | GPU_CUDA = 2; 8 | GPU_CL = 3; 9 | CPU_ARM = 4; 10 | GPU_ARM = 5; 11 | } 12 | 13 | enum XrtEngine { 14 | DEFAULT = 1; 15 | XLA = 2; 16 | TENSORRT = 3; 17 | TVM = 4; 18 | } 19 | 20 | message XrtField { 21 | required XrtDevice device = 1; 22 | required XrtEngine engine = 2; 23 | } 24 | -------------------------------------------------------------------------------- /tools/oneflow/oneflow/xrt/xrt.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto2"; 2 | 3 | package oneflow.xrt; 4 | 5 | import "oneflow/xrt/types.proto"; 6 | 7 | message ClusteringOptionProto { 8 | optional int32 minimum_nodes = 1 [default = 1]; 9 | optional int32 maximum_nodes = 2 [default = 1000]; 10 | optional bool strict_clustering = 3 [default = true]; 11 | } 12 | 13 | message ExecutionOptionProto { 14 | optional XrtDevice device = 1 [default = CPU_X86]; 15 | optional XrtEngine engine = 2 [default = XLA]; 16 | } 17 | -------------------------------------------------------------------------------- /tools/oneflow/sync_proto.py: -------------------------------------------------------------------------------- 1 | import shutil 2 | import argparse 3 | from pathlib import Path 4 | 5 | 6 | def parse_args(): 7 | args = argparse.ArgumentParser() 8 | args.add_argument("--source", type=str, required=True) 9 | return args.parse_args() 10 | 11 | 12 | if __name__ == "__main__": 13 | args = parse_args() 14 | src_path = Path(args.source) / "oneflow" 15 | src_path_str = str(src_path.absolute()) 16 | dst_path_str = str((Path(".") / "oneflow").absolute()) 17 | for proto_path in src_path.glob("**/*.proto"): 18 | proto_path_str = str(proto_path) 19 | dst_proto_path_str = proto_path_str.replace(src_path_str, dst_path_str) 20 | dst_proto_path = Path(dst_proto_path_str) 21 | if not dst_proto_path.parent.exists(): 22 | dst_proto_path.parent.mkdir(parents=True) 23 | shutil.copy2(proto_path_str, dst_proto_path_str) 24 | -------------------------------------------------------------------------------- /tools/tensorflow/resource_handle.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "ResourceHandle"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | // Protocol buffer representing a handle to a tensorflow resource. Handles are 10 | // not valid across executions, but can be serialized back and forth from within 11 | // a single run. 12 | message ResourceHandleProto { 13 | // Unique name for the device containing the resource. 14 | string device = 1; 15 | 16 | // Container in which this resource is placed. 17 | string container = 2; 18 | 19 | // Unique name of this resource. 20 | string name = 3; 21 | 22 | // Hash code for the type of the resource. Is only valid in the same device 23 | // and in the same execution. 24 | uint64 hash_code = 4; 25 | 26 | // For debug-only, the name of the type pointed to by this handle, if 27 | // available. 28 | string maybe_type_name = 5; 29 | }; 30 | -------------------------------------------------------------------------------- /tools/tensorflow/versions.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | 3 | package tensorflow; 4 | option cc_enable_arenas = true; 5 | option java_outer_classname = "VersionsProtos"; 6 | option java_multiple_files = true; 7 | option java_package = "org.tensorflow.framework"; 8 | 9 | // Version information for a piece of serialized data 10 | // 11 | // There are different types of versions for each type of data 12 | // (GraphDef, etc.), but they all have the same common shape 13 | // described here. 14 | // 15 | // Each consumer has "consumer" and "min_producer" versions (specified 16 | // elsewhere). A consumer is allowed to consume this data if 17 | // 18 | // producer >= min_producer 19 | // consumer >= min_consumer 20 | // consumer not in bad_consumers 21 | // 22 | message VersionDef { 23 | // The version of the code that produced this data. 24 | int32 producer = 1; 25 | 26 | // Any consumer below this version is not allowed to consume this data. 27 | int32 min_consumer = 2; 28 | 29 | // Specific consumer versions which are disallowed (e.g. due to bugs). 30 | repeated int32 bad_consumers = 3; 31 | }; 32 | --------------------------------------------------------------------------------