From 79a4199be5b87eb6220b6688b02f5f6cbebb6131 Mon Sep 17 00:00:00 2001 From: Kevin Cheng Date: Tue, 31 Aug 2021 16:04:40 -0700 Subject: Adding Conv attribute to Conv3d. - Rename attribute: Pool2d, Conv2d, TransposeConv2d -> Pool, Conv, TransposeConv Signed-off-by: Kevin Cheng Change-Id: If47dfd1ffc57843018d81d674e4386212fd8d4b4 --- include/attribute.def | 6 +- include/operator.def | 12 +-- include/tosa_generated.h | 170 ++++++++++++++++---------------- python/tosa/Attribute.py | 6 +- python/tosa/Conv2dAttribute.py | 130 ------------------------ python/tosa/ConvAttribute.py | 130 ++++++++++++++++++++++++ python/tosa/Pool2dAttribute.py | 130 ------------------------ python/tosa/PoolAttribute.py | 130 ++++++++++++++++++++++++ python/tosa/TransposeConv2dAttribute.py | 159 ----------------------------- python/tosa/TransposeConvAttribute.py | 159 +++++++++++++++++++++++++++++ schema/tosa.fbs | 12 +-- 11 files changed, 522 insertions(+), 522 deletions(-) delete mode 100644 python/tosa/Conv2dAttribute.py create mode 100644 python/tosa/ConvAttribute.py delete mode 100644 python/tosa/Pool2dAttribute.py create mode 100644 python/tosa/PoolAttribute.py delete mode 100644 python/tosa/TransposeConv2dAttribute.py create mode 100644 python/tosa/TransposeConvAttribute.py diff --git a/include/attribute.def b/include/attribute.def index 12b9c96..d77a687 100644 --- a/include/attribute.def +++ b/include/attribute.def @@ -26,17 +26,17 @@ ...: variadic variables for more arguments, depending on NUM_ARGS_IN_ATTRIBUTES */ -DEF_ATTRIBUTE(Pool2d, 3, +DEF_ATTRIBUTE(Pool, 3, int32_t, V, padding, int32_t, V, kernel, int32_t, V, stride) -DEF_ATTRIBUTE(Conv2d, 3, +DEF_ATTRIBUTE(Conv, 3, int32_t, V, padding, int32_t, V, stride, int32_t, V, dilation) -DEF_ATTRIBUTE(TransposeConv2d, 4, +DEF_ATTRIBUTE(TransposeConv, 4, int32_t, V, outpad, int32_t, V, stride, int32_t, V, dilation, diff --git a/include/operator.def b/include/operator.def index 83155d8..386e72a 100644 --- a/include/operator.def +++ b/include/operator.def @@ -28,14 +28,14 @@ /* tensor operators */ DEF_OPERATOR(argmax, ARGMAX, ArgMax, Axis, None) -DEF_OPERATOR(avg_pool2d, AVG_POOL2D, AvgPool2d, Pool2d, Unary) -DEF_OPERATOR(conv2d, CONV2D, Conv2d, Conv2d, Conv) -DEF_OPERATOR(conv3d, CONV3D, Conv3d, None, None) -DEF_OPERATOR(depthwise_conv2d, DEPTHWISE_CONV2D, DepthwiseConv2d, Conv2d, Conv) +DEF_OPERATOR(avg_pool2d, AVG_POOL2D, AvgPool2d, Pool, Unary) +DEF_OPERATOR(conv2d, CONV2D, Conv2d, Conv, Conv) +DEF_OPERATOR(conv3d, CONV3D, Conv3d, Conv, Conv) +DEF_OPERATOR(depthwise_conv2d, DEPTHWISE_CONV2D, DepthwiseConv2d, Conv, Conv) DEF_OPERATOR(fully_connected, FULLY_CONNECTED, FullyConnected, None, Conv) DEF_OPERATOR(matmul, MATMUL, MatMul, None, MatMul) -DEF_OPERATOR(max_pool2d, MAX_POOL2D, MaxPool2d, Pool2d, None) -DEF_OPERATOR(transpose_conv2d, TRANSPOSE_CONV2D, TransposeConv2d, TransposeConv2d, Conv) +DEF_OPERATOR(max_pool2d, MAX_POOL2D, MaxPool2d, Pool, None) +DEF_OPERATOR(transpose_conv2d, TRANSPOSE_CONV2D, TransposeConv2d, TransposeConv, Conv) /* activation */ DEF_OPERATOR(clamp, CLAMP, Clamp, Clamp, None) diff --git a/include/tosa_generated.h b/include/tosa_generated.h index af8b5bb..56ebbf2 100644 --- a/include/tosa_generated.h +++ b/include/tosa_generated.h @@ -23,14 +23,14 @@ namespace tosa { -struct Pool2dAttribute; -struct Pool2dAttributeBuilder; +struct PoolAttribute; +struct PoolAttributeBuilder; -struct Conv2dAttribute; -struct Conv2dAttributeBuilder; +struct ConvAttribute; +struct ConvAttributeBuilder; -struct TransposeConv2dAttribute; -struct TransposeConv2dAttributeBuilder; +struct TransposeConvAttribute; +struct TransposeConvAttributeBuilder; struct ReluNAttribute; struct ReluNAttributeBuilder; @@ -412,9 +412,9 @@ inline const char *EnumNameOp(Op e) { enum Attribute { Attribute_NONE = 0, - Attribute_Pool2dAttribute = 1, - Attribute_Conv2dAttribute = 2, - Attribute_TransposeConv2dAttribute = 3, + Attribute_PoolAttribute = 1, + Attribute_ConvAttribute = 2, + Attribute_TransposeConvAttribute = 3, Attribute_ReluNAttribute = 4, Attribute_AxisAttribute = 5, Attribute_ReshapeAttribute = 6, @@ -434,9 +434,9 @@ enum Attribute { inline const Attribute (&EnumValuesAttribute())[16] { static const Attribute values[] = { Attribute_NONE, - Attribute_Pool2dAttribute, - Attribute_Conv2dAttribute, - Attribute_TransposeConv2dAttribute, + Attribute_PoolAttribute, + Attribute_ConvAttribute, + Attribute_TransposeConvAttribute, Attribute_ReluNAttribute, Attribute_AxisAttribute, Attribute_ReshapeAttribute, @@ -456,9 +456,9 @@ inline const Attribute (&EnumValuesAttribute())[16] { inline const char * const *EnumNamesAttribute() { static const char * const names[17] = { "NONE", - "Pool2dAttribute", - "Conv2dAttribute", - "TransposeConv2dAttribute", + "PoolAttribute", + "ConvAttribute", + "TransposeConvAttribute", "ReluNAttribute", "AxisAttribute", "ReshapeAttribute", @@ -486,16 +486,16 @@ template struct AttributeTraits { static const Attribute enum_value = Attribute_NONE; }; -template<> struct AttributeTraits { - static const Attribute enum_value = Attribute_Pool2dAttribute; +template<> struct AttributeTraits { + static const Attribute enum_value = Attribute_PoolAttribute; }; -template<> struct AttributeTraits { - static const Attribute enum_value = Attribute_Conv2dAttribute; +template<> struct AttributeTraits { + static const Attribute enum_value = Attribute_ConvAttribute; }; -template<> struct AttributeTraits { - static const Attribute enum_value = Attribute_TransposeConv2dAttribute; +template<> struct AttributeTraits { + static const Attribute enum_value = Attribute_TransposeConvAttribute; }; template<> struct AttributeTraits { @@ -611,8 +611,8 @@ template<> struct QuantInfoTraits { bool VerifyQuantInfo(flatbuffers::Verifier &verifier, const void *obj, QuantInfo type); bool VerifyQuantInfoVector(flatbuffers::Verifier &verifier, const flatbuffers::Vector> *values, const flatbuffers::Vector *types); -struct Pool2dAttribute FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef Pool2dAttributeBuilder Builder; +struct PoolAttribute FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef PoolAttributeBuilder Builder; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_PADDING = 4, VT_KERNEL = 6, @@ -639,44 +639,44 @@ struct Pool2dAttribute FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { } }; -struct Pool2dAttributeBuilder { - typedef Pool2dAttribute Table; +struct PoolAttributeBuilder { + typedef PoolAttribute Table; flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_padding(flatbuffers::Offset> padding) { - fbb_.AddOffset(Pool2dAttribute::VT_PADDING, padding); + fbb_.AddOffset(PoolAttribute::VT_PADDING, padding); } void add_kernel(flatbuffers::Offset> kernel) { - fbb_.AddOffset(Pool2dAttribute::VT_KERNEL, kernel); + fbb_.AddOffset(PoolAttribute::VT_KERNEL, kernel); } void add_stride(flatbuffers::Offset> stride) { - fbb_.AddOffset(Pool2dAttribute::VT_STRIDE, stride); + fbb_.AddOffset(PoolAttribute::VT_STRIDE, stride); } - explicit Pool2dAttributeBuilder(flatbuffers::FlatBufferBuilder &_fbb) + explicit PoolAttributeBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - Pool2dAttributeBuilder &operator=(const Pool2dAttributeBuilder &); - flatbuffers::Offset Finish() { + PoolAttributeBuilder &operator=(const PoolAttributeBuilder &); + flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); + auto o = flatbuffers::Offset(end); return o; } }; -inline flatbuffers::Offset CreatePool2dAttribute( +inline flatbuffers::Offset CreatePoolAttribute( flatbuffers::FlatBufferBuilder &_fbb, flatbuffers::Offset> padding = 0, flatbuffers::Offset> kernel = 0, flatbuffers::Offset> stride = 0) { - Pool2dAttributeBuilder builder_(_fbb); + PoolAttributeBuilder builder_(_fbb); builder_.add_stride(stride); builder_.add_kernel(kernel); builder_.add_padding(padding); return builder_.Finish(); } -inline flatbuffers::Offset CreatePool2dAttributeDirect( +inline flatbuffers::Offset CreatePoolAttributeDirect( flatbuffers::FlatBufferBuilder &_fbb, const std::vector *padding = nullptr, const std::vector *kernel = nullptr, @@ -684,15 +684,15 @@ inline flatbuffers::Offset CreatePool2dAttributeDirect( auto padding__ = padding ? _fbb.CreateVector(*padding) : 0; auto kernel__ = kernel ? _fbb.CreateVector(*kernel) : 0; auto stride__ = stride ? _fbb.CreateVector(*stride) : 0; - return tosa::CreatePool2dAttribute( + return tosa::CreatePoolAttribute( _fbb, padding__, kernel__, stride__); } -struct Conv2dAttribute FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef Conv2dAttributeBuilder Builder; +struct ConvAttribute FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef ConvAttributeBuilder Builder; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_PADDING = 4, VT_STRIDE = 6, @@ -719,44 +719,44 @@ struct Conv2dAttribute FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { } }; -struct Conv2dAttributeBuilder { - typedef Conv2dAttribute Table; +struct ConvAttributeBuilder { + typedef ConvAttribute Table; flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_padding(flatbuffers::Offset> padding) { - fbb_.AddOffset(Conv2dAttribute::VT_PADDING, padding); + fbb_.AddOffset(ConvAttribute::VT_PADDING, padding); } void add_stride(flatbuffers::Offset> stride) { - fbb_.AddOffset(Conv2dAttribute::VT_STRIDE, stride); + fbb_.AddOffset(ConvAttribute::VT_STRIDE, stride); } void add_dilation(flatbuffers::Offset> dilation) { - fbb_.AddOffset(Conv2dAttribute::VT_DILATION, dilation); + fbb_.AddOffset(ConvAttribute::VT_DILATION, dilation); } - explicit Conv2dAttributeBuilder(flatbuffers::FlatBufferBuilder &_fbb) + explicit ConvAttributeBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - Conv2dAttributeBuilder &operator=(const Conv2dAttributeBuilder &); - flatbuffers::Offset Finish() { + ConvAttributeBuilder &operator=(const ConvAttributeBuilder &); + flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); + auto o = flatbuffers::Offset(end); return o; } }; -inline flatbuffers::Offset CreateConv2dAttribute( +inline flatbuffers::Offset CreateConvAttribute( flatbuffers::FlatBufferBuilder &_fbb, flatbuffers::Offset> padding = 0, flatbuffers::Offset> stride = 0, flatbuffers::Offset> dilation = 0) { - Conv2dAttributeBuilder builder_(_fbb); + ConvAttributeBuilder builder_(_fbb); builder_.add_dilation(dilation); builder_.add_stride(stride); builder_.add_padding(padding); return builder_.Finish(); } -inline flatbuffers::Offset CreateConv2dAttributeDirect( +inline flatbuffers::Offset CreateConvAttributeDirect( flatbuffers::FlatBufferBuilder &_fbb, const std::vector *padding = nullptr, const std::vector *stride = nullptr, @@ -764,15 +764,15 @@ inline flatbuffers::Offset CreateConv2dAttributeDirect( auto padding__ = padding ? _fbb.CreateVector(*padding) : 0; auto stride__ = stride ? _fbb.CreateVector(*stride) : 0; auto dilation__ = dilation ? _fbb.CreateVector(*dilation) : 0; - return tosa::CreateConv2dAttribute( + return tosa::CreateConvAttribute( _fbb, padding__, stride__, dilation__); } -struct TransposeConv2dAttribute FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { - typedef TransposeConv2dAttributeBuilder Builder; +struct TransposeConvAttribute FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { + typedef TransposeConvAttributeBuilder Builder; enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { VT_OUTPAD = 4, VT_STRIDE = 6, @@ -805,41 +805,41 @@ struct TransposeConv2dAttribute FLATBUFFERS_FINAL_CLASS : private flatbuffers::T } }; -struct TransposeConv2dAttributeBuilder { - typedef TransposeConv2dAttribute Table; +struct TransposeConvAttributeBuilder { + typedef TransposeConvAttribute Table; flatbuffers::FlatBufferBuilder &fbb_; flatbuffers::uoffset_t start_; void add_outpad(flatbuffers::Offset> outpad) { - fbb_.AddOffset(TransposeConv2dAttribute::VT_OUTPAD, outpad); + fbb_.AddOffset(TransposeConvAttribute::VT_OUTPAD, outpad); } void add_stride(flatbuffers::Offset> stride) { - fbb_.AddOffset(TransposeConv2dAttribute::VT_STRIDE, stride); + fbb_.AddOffset(TransposeConvAttribute::VT_STRIDE, stride); } void add_dilation(flatbuffers::Offset> dilation) { - fbb_.AddOffset(TransposeConv2dAttribute::VT_DILATION, dilation); + fbb_.AddOffset(TransposeConvAttribute::VT_DILATION, dilation); } void add_output_shape(flatbuffers::Offset> output_shape) { - fbb_.AddOffset(TransposeConv2dAttribute::VT_OUTPUT_SHAPE, output_shape); + fbb_.AddOffset(TransposeConvAttribute::VT_OUTPUT_SHAPE, output_shape); } - explicit TransposeConv2dAttributeBuilder(flatbuffers::FlatBufferBuilder &_fbb) + explicit TransposeConvAttributeBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); } - TransposeConv2dAttributeBuilder &operator=(const TransposeConv2dAttributeBuilder &); - flatbuffers::Offset Finish() { + TransposeConvAttributeBuilder &operator=(const TransposeConvAttributeBuilder &); + flatbuffers::Offset Finish() { const auto end = fbb_.EndTable(start_); - auto o = flatbuffers::Offset(end); + auto o = flatbuffers::Offset(end); return o; } }; -inline flatbuffers::Offset CreateTransposeConv2dAttribute( +inline flatbuffers::Offset CreateTransposeConvAttribute( flatbuffers::FlatBufferBuilder &_fbb, flatbuffers::Offset> outpad = 0, flatbuffers::Offset> stride = 0, flatbuffers::Offset> dilation = 0, flatbuffers::Offset> output_shape = 0) { - TransposeConv2dAttributeBuilder builder_(_fbb); + TransposeConvAttributeBuilder builder_(_fbb); builder_.add_output_shape(output_shape); builder_.add_dilation(dilation); builder_.add_stride(stride); @@ -847,7 +847,7 @@ inline flatbuffers::Offset CreateTransposeConv2dAttrib return builder_.Finish(); } -inline flatbuffers::Offset CreateTransposeConv2dAttributeDirect( +inline flatbuffers::Offset CreateTransposeConvAttributeDirect( flatbuffers::FlatBufferBuilder &_fbb, const std::vector *outpad = nullptr, const std::vector *stride = nullptr, @@ -857,7 +857,7 @@ inline flatbuffers::Offset CreateTransposeConv2dAttrib auto stride__ = stride ? _fbb.CreateVector(*stride) : 0; auto dilation__ = dilation ? _fbb.CreateVector(*dilation) : 0; auto output_shape__ = output_shape ? _fbb.CreateVector(*output_shape) : 0; - return tosa::CreateTransposeConv2dAttribute( + return tosa::CreateTransposeConvAttribute( _fbb, outpad__, stride__, @@ -2059,14 +2059,14 @@ struct TosaOperator FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { return GetPointer(VT_ATTRIBUTE); } template const T *attribute_as() const; - const tosa::Pool2dAttribute *attribute_as_Pool2dAttribute() const { - return attribute_type() == tosa::Attribute_Pool2dAttribute ? static_cast(attribute()) : nullptr; + const tosa::PoolAttribute *attribute_as_PoolAttribute() const { + return attribute_type() == tosa::Attribute_PoolAttribute ? static_cast(attribute()) : nullptr; } - const tosa::Conv2dAttribute *attribute_as_Conv2dAttribute() const { - return attribute_type() == tosa::Attribute_Conv2dAttribute ? static_cast(attribute()) : nullptr; + const tosa::ConvAttribute *attribute_as_ConvAttribute() const { + return attribute_type() == tosa::Attribute_ConvAttribute ? static_cast(attribute()) : nullptr; } - const tosa::TransposeConv2dAttribute *attribute_as_TransposeConv2dAttribute() const { - return attribute_type() == tosa::Attribute_TransposeConv2dAttribute ? static_cast(attribute()) : nullptr; + const tosa::TransposeConvAttribute *attribute_as_TransposeConvAttribute() const { + return attribute_type() == tosa::Attribute_TransposeConvAttribute ? static_cast(attribute()) : nullptr; } const tosa::ReluNAttribute *attribute_as_ReluNAttribute() const { return attribute_type() == tosa::Attribute_ReluNAttribute ? static_cast(attribute()) : nullptr; @@ -2148,16 +2148,16 @@ struct TosaOperator FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table { } }; -template<> inline const tosa::Pool2dAttribute *TosaOperator::attribute_as() const { - return attribute_as_Pool2dAttribute(); +template<> inline const tosa::PoolAttribute *TosaOperator::attribute_as() const { + return attribute_as_PoolAttribute(); } -template<> inline const tosa::Conv2dAttribute *TosaOperator::attribute_as() const { - return attribute_as_Conv2dAttribute(); +template<> inline const tosa::ConvAttribute *TosaOperator::attribute_as() const { + return attribute_as_ConvAttribute(); } -template<> inline const tosa::TransposeConv2dAttribute *TosaOperator::attribute_as() const { - return attribute_as_TransposeConv2dAttribute(); +template<> inline const tosa::TransposeConvAttribute *TosaOperator::attribute_as() const { + return attribute_as_TransposeConvAttribute(); } template<> inline const tosa::ReluNAttribute *TosaOperator::attribute_as() const { @@ -2486,16 +2486,16 @@ inline bool VerifyAttribute(flatbuffers::Verifier &verifier, const void *obj, At case Attribute_NONE: { return true; } - case Attribute_Pool2dAttribute: { - auto ptr = reinterpret_cast(obj); + case Attribute_PoolAttribute: { + auto ptr = reinterpret_cast(obj); return verifier.VerifyTable(ptr); } - case Attribute_Conv2dAttribute: { - auto ptr = reinterpret_cast(obj); + case Attribute_ConvAttribute: { + auto ptr = reinterpret_cast(obj); return verifier.VerifyTable(ptr); } - case Attribute_TransposeConv2dAttribute: { - auto ptr = reinterpret_cast(obj); + case Attribute_TransposeConvAttribute: { + auto ptr = reinterpret_cast(obj); return verifier.VerifyTable(ptr); } case Attribute_ReluNAttribute: { diff --git a/python/tosa/Attribute.py b/python/tosa/Attribute.py index e70c0ac..334b4ae 100644 --- a/python/tosa/Attribute.py +++ b/python/tosa/Attribute.py @@ -19,9 +19,9 @@ class Attribute(object): NONE = 0 - Pool2dAttribute = 1 - Conv2dAttribute = 2 - TransposeConv2dAttribute = 3 + PoolAttribute = 1 + ConvAttribute = 2 + TransposeConvAttribute = 3 ReluNAttribute = 4 AxisAttribute = 5 ReshapeAttribute = 6 diff --git a/python/tosa/Conv2dAttribute.py b/python/tosa/Conv2dAttribute.py deleted file mode 100644 index c5ae257..0000000 --- a/python/tosa/Conv2dAttribute.py +++ /dev/null @@ -1,130 +0,0 @@ -# automatically generated by the FlatBuffers compiler, do not modify - -# Copyright (c) 2020-2021, ARM Limited. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -# namespace: tosa - -import flatbuffers -from flatbuffers.compat import import_numpy -np = import_numpy() - -class Conv2dAttribute(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAsConv2dAttribute(cls, buf, offset): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = Conv2dAttribute() - x.Init(buf, n + offset) - return x - - @classmethod - def Conv2dAttributeBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x4F\x53\x41", size_prefixed=size_prefixed) - - # Conv2dAttribute - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # Conv2dAttribute - def Padding(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) - return 0 - - # Conv2dAttribute - def PaddingAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o) - return 0 - - # Conv2dAttribute - def PaddingLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # Conv2dAttribute - def PaddingIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - return o == 0 - - # Conv2dAttribute - def Stride(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) - return 0 - - # Conv2dAttribute - def StrideAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o) - return 0 - - # Conv2dAttribute - def StrideLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # Conv2dAttribute - def StrideIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - return o == 0 - - # Conv2dAttribute - def Dilation(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) - return 0 - - # Conv2dAttribute - def DilationAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o) - return 0 - - # Conv2dAttribute - def DilationLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # Conv2dAttribute - def DilationIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - return o == 0 - -def Conv2dAttributeStart(builder): builder.StartObject(3) -def Conv2dAttributeAddPadding(builder, padding): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(padding), 0) -def Conv2dAttributeStartPaddingVector(builder, numElems): return builder.StartVector(4, numElems, 4) -def Conv2dAttributeAddStride(builder, stride): builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(stride), 0) -def Conv2dAttributeStartStrideVector(builder, numElems): return builder.StartVector(4, numElems, 4) -def Conv2dAttributeAddDilation(builder, dilation): builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(dilation), 0) -def Conv2dAttributeStartDilationVector(builder, numElems): return builder.StartVector(4, numElems, 4) -def Conv2dAttributeEnd(builder): return builder.EndObject() diff --git a/python/tosa/ConvAttribute.py b/python/tosa/ConvAttribute.py new file mode 100644 index 0000000..8dfb3d1 --- /dev/null +++ b/python/tosa/ConvAttribute.py @@ -0,0 +1,130 @@ +# automatically generated by the FlatBuffers compiler, do not modify + +# Copyright (c) 2020-2021, ARM Limited. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +# namespace: tosa + +import flatbuffers +from flatbuffers.compat import import_numpy +np = import_numpy() + +class ConvAttribute(object): + __slots__ = ['_tab'] + + @classmethod + def GetRootAsConvAttribute(cls, buf, offset): + n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) + x = ConvAttribute() + x.Init(buf, n + offset) + return x + + @classmethod + def ConvAttributeBufferHasIdentifier(cls, buf, offset, size_prefixed=False): + return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x4F\x53\x41", size_prefixed=size_prefixed) + + # ConvAttribute + def Init(self, buf, pos): + self._tab = flatbuffers.table.Table(buf, pos) + + # ConvAttribute + def Padding(self, j): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) + if o != 0: + a = self._tab.Vector(o) + return self._tab.Get(flatbuffers.number_types.Int32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) + return 0 + + # ConvAttribute + def PaddingAsNumpy(self): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) + if o != 0: + return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o) + return 0 + + # ConvAttribute + def PaddingLength(self): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) + if o != 0: + return self._tab.VectorLen(o) + return 0 + + # ConvAttribute + def PaddingIsNone(self): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) + return o == 0 + + # ConvAttribute + def Stride(self, j): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) + if o != 0: + a = self._tab.Vector(o) + return self._tab.Get(flatbuffers.number_types.Int32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) + return 0 + + # ConvAttribute + def StrideAsNumpy(self): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) + if o != 0: + return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o) + return 0 + + # ConvAttribute + def StrideLength(self): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) + if o != 0: + return self._tab.VectorLen(o) + return 0 + + # ConvAttribute + def StrideIsNone(self): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) + return o == 0 + + # ConvAttribute + def Dilation(self, j): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) + if o != 0: + a = self._tab.Vector(o) + return self._tab.Get(flatbuffers.number_types.Int32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) + return 0 + + # ConvAttribute + def DilationAsNumpy(self): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) + if o != 0: + return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o) + return 0 + + # ConvAttribute + def DilationLength(self): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) + if o != 0: + return self._tab.VectorLen(o) + return 0 + + # ConvAttribute + def DilationIsNone(self): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) + return o == 0 + +def ConvAttributeStart(builder): builder.StartObject(3) +def ConvAttributeAddPadding(builder, padding): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(padding), 0) +def ConvAttributeStartPaddingVector(builder, numElems): return builder.StartVector(4, numElems, 4) +def ConvAttributeAddStride(builder, stride): builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(stride), 0) +def ConvAttributeStartStrideVector(builder, numElems): return builder.StartVector(4, numElems, 4) +def ConvAttributeAddDilation(builder, dilation): builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(dilation), 0) +def ConvAttributeStartDilationVector(builder, numElems): return builder.StartVector(4, numElems, 4) +def ConvAttributeEnd(builder): return builder.EndObject() diff --git a/python/tosa/Pool2dAttribute.py b/python/tosa/Pool2dAttribute.py deleted file mode 100644 index 72c09b4..0000000 --- a/python/tosa/Pool2dAttribute.py +++ /dev/null @@ -1,130 +0,0 @@ -# automatically generated by the FlatBuffers compiler, do not modify - -# Copyright (c) 2020-2021, ARM Limited. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -# namespace: tosa - -import flatbuffers -from flatbuffers.compat import import_numpy -np = import_numpy() - -class Pool2dAttribute(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAsPool2dAttribute(cls, buf, offset): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = Pool2dAttribute() - x.Init(buf, n + offset) - return x - - @classmethod - def Pool2dAttributeBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x4F\x53\x41", size_prefixed=size_prefixed) - - # Pool2dAttribute - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # Pool2dAttribute - def Padding(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) - return 0 - - # Pool2dAttribute - def PaddingAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o) - return 0 - - # Pool2dAttribute - def PaddingLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # Pool2dAttribute - def PaddingIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - return o == 0 - - # Pool2dAttribute - def Kernel(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) - return 0 - - # Pool2dAttribute - def KernelAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o) - return 0 - - # Pool2dAttribute - def KernelLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # Pool2dAttribute - def KernelIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - return o == 0 - - # Pool2dAttribute - def Stride(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) - return 0 - - # Pool2dAttribute - def StrideAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o) - return 0 - - # Pool2dAttribute - def StrideLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # Pool2dAttribute - def StrideIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - return o == 0 - -def Pool2dAttributeStart(builder): builder.StartObject(3) -def Pool2dAttributeAddPadding(builder, padding): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(padding), 0) -def Pool2dAttributeStartPaddingVector(builder, numElems): return builder.StartVector(4, numElems, 4) -def Pool2dAttributeAddKernel(builder, kernel): builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(kernel), 0) -def Pool2dAttributeStartKernelVector(builder, numElems): return builder.StartVector(4, numElems, 4) -def Pool2dAttributeAddStride(builder, stride): builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(stride), 0) -def Pool2dAttributeStartStrideVector(builder, numElems): return builder.StartVector(4, numElems, 4) -def Pool2dAttributeEnd(builder): return builder.EndObject() diff --git a/python/tosa/PoolAttribute.py b/python/tosa/PoolAttribute.py new file mode 100644 index 0000000..214cc82 --- /dev/null +++ b/python/tosa/PoolAttribute.py @@ -0,0 +1,130 @@ +# automatically generated by the FlatBuffers compiler, do not modify + +# Copyright (c) 2020-2021, ARM Limited. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +# namespace: tosa + +import flatbuffers +from flatbuffers.compat import import_numpy +np = import_numpy() + +class PoolAttribute(object): + __slots__ = ['_tab'] + + @classmethod + def GetRootAsPoolAttribute(cls, buf, offset): + n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) + x = PoolAttribute() + x.Init(buf, n + offset) + return x + + @classmethod + def PoolAttributeBufferHasIdentifier(cls, buf, offset, size_prefixed=False): + return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x4F\x53\x41", size_prefixed=size_prefixed) + + # PoolAttribute + def Init(self, buf, pos): + self._tab = flatbuffers.table.Table(buf, pos) + + # PoolAttribute + def Padding(self, j): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) + if o != 0: + a = self._tab.Vector(o) + return self._tab.Get(flatbuffers.number_types.Int32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) + return 0 + + # PoolAttribute + def PaddingAsNumpy(self): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) + if o != 0: + return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o) + return 0 + + # PoolAttribute + def PaddingLength(self): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) + if o != 0: + return self._tab.VectorLen(o) + return 0 + + # PoolAttribute + def PaddingIsNone(self): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) + return o == 0 + + # PoolAttribute + def Kernel(self, j): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) + if o != 0: + a = self._tab.Vector(o) + return self._tab.Get(flatbuffers.number_types.Int32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) + return 0 + + # PoolAttribute + def KernelAsNumpy(self): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) + if o != 0: + return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o) + return 0 + + # PoolAttribute + def KernelLength(self): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) + if o != 0: + return self._tab.VectorLen(o) + return 0 + + # PoolAttribute + def KernelIsNone(self): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) + return o == 0 + + # PoolAttribute + def Stride(self, j): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) + if o != 0: + a = self._tab.Vector(o) + return self._tab.Get(flatbuffers.number_types.Int32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) + return 0 + + # PoolAttribute + def StrideAsNumpy(self): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) + if o != 0: + return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o) + return 0 + + # PoolAttribute + def StrideLength(self): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) + if o != 0: + return self._tab.VectorLen(o) + return 0 + + # PoolAttribute + def StrideIsNone(self): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) + return o == 0 + +def PoolAttributeStart(builder): builder.StartObject(3) +def PoolAttributeAddPadding(builder, padding): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(padding), 0) +def PoolAttributeStartPaddingVector(builder, numElems): return builder.StartVector(4, numElems, 4) +def PoolAttributeAddKernel(builder, kernel): builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(kernel), 0) +def PoolAttributeStartKernelVector(builder, numElems): return builder.StartVector(4, numElems, 4) +def PoolAttributeAddStride(builder, stride): builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(stride), 0) +def PoolAttributeStartStrideVector(builder, numElems): return builder.StartVector(4, numElems, 4) +def PoolAttributeEnd(builder): return builder.EndObject() diff --git a/python/tosa/TransposeConv2dAttribute.py b/python/tosa/TransposeConv2dAttribute.py deleted file mode 100644 index 02af44d..0000000 --- a/python/tosa/TransposeConv2dAttribute.py +++ /dev/null @@ -1,159 +0,0 @@ -# automatically generated by the FlatBuffers compiler, do not modify - -# Copyright (c) 2020-2021, ARM Limited. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -# namespace: tosa - -import flatbuffers -from flatbuffers.compat import import_numpy -np = import_numpy() - -class TransposeConv2dAttribute(object): - __slots__ = ['_tab'] - - @classmethod - def GetRootAsTransposeConv2dAttribute(cls, buf, offset): - n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) - x = TransposeConv2dAttribute() - x.Init(buf, n + offset) - return x - - @classmethod - def TransposeConv2dAttributeBufferHasIdentifier(cls, buf, offset, size_prefixed=False): - return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x4F\x53\x41", size_prefixed=size_prefixed) - - # TransposeConv2dAttribute - def Init(self, buf, pos): - self._tab = flatbuffers.table.Table(buf, pos) - - # TransposeConv2dAttribute - def Outpad(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) - return 0 - - # TransposeConv2dAttribute - def OutpadAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o) - return 0 - - # TransposeConv2dAttribute - def OutpadLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # TransposeConv2dAttribute - def OutpadIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) - return o == 0 - - # TransposeConv2dAttribute - def Stride(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) - return 0 - - # TransposeConv2dAttribute - def StrideAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o) - return 0 - - # TransposeConv2dAttribute - def StrideLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # TransposeConv2dAttribute - def StrideIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) - return o == 0 - - # TransposeConv2dAttribute - def Dilation(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) - return 0 - - # TransposeConv2dAttribute - def DilationAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o) - return 0 - - # TransposeConv2dAttribute - def DilationLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # TransposeConv2dAttribute - def DilationIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) - return o == 0 - - # TransposeConv2dAttribute - def OutputShape(self, j): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - if o != 0: - a = self._tab.Vector(o) - return self._tab.Get(flatbuffers.number_types.Int32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) - return 0 - - # TransposeConv2dAttribute - def OutputShapeAsNumpy(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - if o != 0: - return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o) - return 0 - - # TransposeConv2dAttribute - def OutputShapeLength(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - if o != 0: - return self._tab.VectorLen(o) - return 0 - - # TransposeConv2dAttribute - def OutputShapeIsNone(self): - o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) - return o == 0 - -def TransposeConv2dAttributeStart(builder): builder.StartObject(4) -def TransposeConv2dAttributeAddOutpad(builder, outpad): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(outpad), 0) -def TransposeConv2dAttributeStartOutpadVector(builder, numElems): return builder.StartVector(4, numElems, 4) -def TransposeConv2dAttributeAddStride(builder, stride): builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(stride), 0) -def TransposeConv2dAttributeStartStrideVector(builder, numElems): return builder.StartVector(4, numElems, 4) -def TransposeConv2dAttributeAddDilation(builder, dilation): builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(dilation), 0) -def TransposeConv2dAttributeStartDilationVector(builder, numElems): return builder.StartVector(4, numElems, 4) -def TransposeConv2dAttributeAddOutputShape(builder, outputShape): builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(outputShape), 0) -def TransposeConv2dAttributeStartOutputShapeVector(builder, numElems): return builder.StartVector(4, numElems, 4) -def TransposeConv2dAttributeEnd(builder): return builder.EndObject() diff --git a/python/tosa/TransposeConvAttribute.py b/python/tosa/TransposeConvAttribute.py new file mode 100644 index 0000000..2aed61f --- /dev/null +++ b/python/tosa/TransposeConvAttribute.py @@ -0,0 +1,159 @@ +# automatically generated by the FlatBuffers compiler, do not modify + +# Copyright (c) 2020-2021, ARM Limited. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +# namespace: tosa + +import flatbuffers +from flatbuffers.compat import import_numpy +np = import_numpy() + +class TransposeConvAttribute(object): + __slots__ = ['_tab'] + + @classmethod + def GetRootAsTransposeConvAttribute(cls, buf, offset): + n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset) + x = TransposeConvAttribute() + x.Init(buf, n + offset) + return x + + @classmethod + def TransposeConvAttributeBufferHasIdentifier(cls, buf, offset, size_prefixed=False): + return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x4F\x53\x41", size_prefixed=size_prefixed) + + # TransposeConvAttribute + def Init(self, buf, pos): + self._tab = flatbuffers.table.Table(buf, pos) + + # TransposeConvAttribute + def Outpad(self, j): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) + if o != 0: + a = self._tab.Vector(o) + return self._tab.Get(flatbuffers.number_types.Int32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) + return 0 + + # TransposeConvAttribute + def OutpadAsNumpy(self): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) + if o != 0: + return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o) + return 0 + + # TransposeConvAttribute + def OutpadLength(self): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) + if o != 0: + return self._tab.VectorLen(o) + return 0 + + # TransposeConvAttribute + def OutpadIsNone(self): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4)) + return o == 0 + + # TransposeConvAttribute + def Stride(self, j): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) + if o != 0: + a = self._tab.Vector(o) + return self._tab.Get(flatbuffers.number_types.Int32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) + return 0 + + # TransposeConvAttribute + def StrideAsNumpy(self): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) + if o != 0: + return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o) + return 0 + + # TransposeConvAttribute + def StrideLength(self): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) + if o != 0: + return self._tab.VectorLen(o) + return 0 + + # TransposeConvAttribute + def StrideIsNone(self): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6)) + return o == 0 + + # TransposeConvAttribute + def Dilation(self, j): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) + if o != 0: + a = self._tab.Vector(o) + return self._tab.Get(flatbuffers.number_types.Int32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) + return 0 + + # TransposeConvAttribute + def DilationAsNumpy(self): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) + if o != 0: + return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o) + return 0 + + # TransposeConvAttribute + def DilationLength(self): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) + if o != 0: + return self._tab.VectorLen(o) + return 0 + + # TransposeConvAttribute + def DilationIsNone(self): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8)) + return o == 0 + + # TransposeConvAttribute + def OutputShape(self, j): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) + if o != 0: + a = self._tab.Vector(o) + return self._tab.Get(flatbuffers.number_types.Int32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4)) + return 0 + + # TransposeConvAttribute + def OutputShapeAsNumpy(self): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) + if o != 0: + return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Int32Flags, o) + return 0 + + # TransposeConvAttribute + def OutputShapeLength(self): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) + if o != 0: + return self._tab.VectorLen(o) + return 0 + + # TransposeConvAttribute + def OutputShapeIsNone(self): + o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10)) + return o == 0 + +def TransposeConvAttributeStart(builder): builder.StartObject(4) +def TransposeConvAttributeAddOutpad(builder, outpad): builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(outpad), 0) +def TransposeConvAttributeStartOutpadVector(builder, numElems): return builder.StartVector(4, numElems, 4) +def TransposeConvAttributeAddStride(builder, stride): builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(stride), 0) +def TransposeConvAttributeStartStrideVector(builder, numElems): return builder.StartVector(4, numElems, 4) +def TransposeConvAttributeAddDilation(builder, dilation): builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(dilation), 0) +def TransposeConvAttributeStartDilationVector(builder, numElems): return builder.StartVector(4, numElems, 4) +def TransposeConvAttributeAddOutputShape(builder, outputShape): builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(outputShape), 0) +def TransposeConvAttributeStartOutputShapeVector(builder, numElems): return builder.StartVector(4, numElems, 4) +def TransposeConvAttributeEnd(builder): return builder.EndObject() diff --git a/schema/tosa.fbs b/schema/tosa.fbs index daf6475..6e84b22 100644 --- a/schema/tosa.fbs +++ b/schema/tosa.fbs @@ -139,9 +139,9 @@ enum Op:uint32 { } union Attribute { - Pool2dAttribute, - Conv2dAttribute, - TransposeConv2dAttribute, + PoolAttribute, + ConvAttribute, + TransposeConvAttribute, ReluNAttribute, AxisAttribute, ReshapeAttribute, @@ -156,19 +156,19 @@ union Attribute { WhileLoopAttribute, } -table Pool2dAttribute { +table PoolAttribute { padding: [int32]; kernel: [int32]; stride: [int32]; } -table Conv2dAttribute { +table ConvAttribute { padding: [int32]; stride: [int32]; dilation: [int32]; } -table TransposeConv2dAttribute { +table TransposeConvAttribute { outpad: [int32]; stride: [int32]; dilation: [int32]; -- cgit v1.2.1