From 1802e558adb32a71bba56084a94ba2a7395c833d Mon Sep 17 00:00:00 2001 From: Feiyue Chen Date: Thu, 22 Sep 2022 12:45:52 +0800 Subject: [PATCH] modified cumsum header && resolve conflict in README.md --- include/tim/vx/operation.h | 8 +++++++- include/tim/vx/ops/cumsum.h | 5 ++++- src/tim/vx/operation.cc | 4 ++-- src/tim/vx/ops/README.md | 4 +++- src/tim/vx/ops/cumsum.cc | 2 +- 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/include/tim/vx/operation.h b/include/tim/vx/operation.h index 82b6188..022e1f4 100644 --- a/include/tim/vx/operation.h +++ b/include/tim/vx/operation.h @@ -49,10 +49,16 @@ class Operation { std::unique_ptr& impl(); const std::unique_ptr& impl() const; virtual const std::vector> ConstantInputsTensor() const; - virtual void HandleAfterBindInput(const std::shared_ptr& tensor, int32_t input_idx); + protected: bool IsAllInputsConst() const; std::unique_ptr impl_; + + private: +// Post processing at the final step on BindInput func +// - tensor : input tensor +// - input_idx: the index of input tensor + virtual void OnBindInputPostProc(const std::shared_ptr& tensor, int32_t input_idx); }; } // namespace vx diff --git a/include/tim/vx/ops/cumsum.h b/include/tim/vx/ops/cumsum.h index b33ee19..c75d8ca 100644 --- a/include/tim/vx/ops/cumsum.h +++ b/include/tim/vx/ops/cumsum.h @@ -47,11 +47,14 @@ namespace ops { class CumSum : public BuiltinOp { public: CumSum(Graph* Graph, int32_t axis=0, int32_t exclusive=0, int32_t reverse=0); + std::shared_ptr Clone(std::shared_ptr& graph) const override; - void HandleAfterBindInput(const std::shared_ptr& tensor, int32_t input_idx) override; protected: int32_t axis_, exclusive_, reverse_; + + private: + void OnBindInputPostProc(const std::shared_ptr& tensor, int32_t input_idx) override; }; } // namespace ops diff --git a/src/tim/vx/operation.cc b/src/tim/vx/operation.cc index e1dc6b3..48a8298 100644 --- a/src/tim/vx/operation.cc +++ b/src/tim/vx/operation.cc @@ -42,7 +42,7 @@ const std::unique_ptr& Operation::impl() const { return impl_; } Operation& Operation::BindInput(const std::shared_ptr& tensor) { impl_->BindInput(tensor); impl_->graph_->UpdateTensorConsumersMap(tensor, this); - HandleAfterBindInput(tensor, impl_->input_tensor_index - 1); + OnBindInputPostProc(tensor, impl_->input_tensor_index - 1); return *this; } @@ -90,7 +90,7 @@ const std::vector> Operation::ConstantInputsTensor() con return {}; } } -void Operation::HandleAfterBindInput(const std::shared_ptr& tensor, int32_t input_idx){ +void Operation::OnBindInputPostProc(const std::shared_ptr& tensor, int32_t input_idx){ (void) tensor; (void) input_idx; } diff --git a/src/tim/vx/ops/README.md b/src/tim/vx/ops/README.md index 8725ef1..bc6249c 100644 --- a/src/tim/vx/ops/README.md +++ b/src/tim/vx/ops/README.md @@ -116,10 +116,12 @@ GroupedConv1d|GROUPED_CONV1D|Mapped|[tf.keras.layers.Conv1D](https://tensorflow. Mod|MOD|Mapped|[Onnx.Mod](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Mod) Selu|SELU|Mapped|[tf.keras.activations.selu](https://www.tensorflow.org/api_docs/python/tf/keras/activations/selu) Celu|CELU|Mapped|[Onnx.celu](https://github.com/onnx/onnx/blob/main/docs/Operators.md#Celu) +Sign|SIGN|Mapped|[tf.math.sign](https://www.tensorflow.org/api_docs/python/tf/math/sign) +SoftSign|SOFTSIGN|Mapped|[tf.keras.activations.softsign](https://www.tensorflow.org/api_docs/python/tf/keras/activations/softsign) +CumSum|CUMSUM|Mapped|[tf.math.cumsum](https://www.tensorflow.org/api_docs/python/tf/math/cumsum) Rcp|RCP|Mapped|[tf.math.reciprocal](https://www.tensorflow.org/api_docs/python/tf/math/reciprocal) MaxPool3d|MAX_POOL3D|Mapped|[Onnx.MaxPool](https://github.com/onnx/onnx/blob/main/docs/Operators.md#MaxPool) |UnidirectionalSequenceRNN|UNIDIRECTIONAL_SEQUENCE_RNN|Planned 22Q3|[ANEURALNETWORKS_UNIDIRECTIONAL_SEQUENCE_RNN](https://developer.android.com/ndk/reference/group/neural-networks#group___neural_networks_1ggaabbe492c60331b13038e39d4207940e0ae11aa1d461d2abaa117f6ee2cb503dd8) -CumSum|CUMSUM|Mapped|[tf.math.cumsum](https://www.tensorflow.org/api_docs/python/tf/math/cumsum) |BidirectionalSequenceRNN|BIDIRECTIONAL_SEQUENCE_RNN|Planned 22Q3|[ANEURALNETWORKS_BIDIRECTIONAL_SEQUENCE_RNN](https://developer.android.com/ndk/reference/group/neural-networks#group___neural_networks_1ggaabbe492c60331b13038e39d4207940e0a487fc5ae247de828f13e62b99f259f3c) |BidirectionalSequenceLSTM|BIDIRECTIONAL_SEQUENCE_LSTM|Mapped|[ANEURALNETWORKS_BIDIRECTIONAL_SEQUENCE_LSTM](https://developer.android.com/ndk/reference/group/neural-networks#group___neural_networks_1ggaabbe492c60331b13038e39d4207940e0a492a71cb7aa50b9a1a834a3cb269d778) |UnidirectionalSequenceLSTM|LSTM_OVXLIB|Mapped|[ANEURALNETWORKS_UNIDIRECTIONAL_SEQUENCE_LSTM](https://developer.android.com/ndk/reference/group/neural-networks#group___neural_networks_1ggaabbe492c60331b13038e39d4207940e0aaf30e491ad0b1fc7602cbde695b2c859) diff --git a/src/tim/vx/ops/cumsum.cc b/src/tim/vx/ops/cumsum.cc index d2bafd4..54f2185 100644 --- a/src/tim/vx/ops/cumsum.cc +++ b/src/tim/vx/ops/cumsum.cc @@ -37,7 +37,7 @@ CumSum::CumSum(Graph* graph, int32_t axis, int32_t exclusive, int32_t reverse) this->impl()->node()->nn_param.cumsum.reverse = reverse_; } -void CumSum::HandleAfterBindInput(const std::shared_ptr& tensor, int32_t input_idx){ +void CumSum::OnBindInputPostProc(const std::shared_ptr& tensor, int32_t input_idx){ if (axis_ < 0){ axis_ += tensor->GetShape().size(); (void) input_idx;