Hi Sam,
Thanks for your suggestions. I guess you mean the "unary_op.h" and the operator inherent from this one? And I spent some time writing the padding operator. I think I stuck into some problems. Can you kindly offer some help?
The main modification is
1. I create a new file in "smaug/core/operators/padding_op.h", The content is
```
template <typename Backend>
class PaddingOperator : public Operator {
public:
PaddingOperator(const std::string& name,
Workspace* workspace,
const std::vector<int> _padders)
: Operator(name, OpType::Repeat, workspace), padders(_padders),
padders(_padders) {
inputs.resize(1, nullptr);
outputs.resize(1, nullptr);
}
void setPadders(const std::vector<std::vector<int>>& _padders) {
padders = _padders;
}
auto getPadders() {
return padders;
}
void run() override {}
enum { Inputs, kNumInputs };
enum { Outputs, kNumOutputs };
protected:
std::vector<std::vector<int>> padders;
};
```
2. In "types.proto" I add `Padding = 29;` in OpType.
3. In "backend.h" I add `template <typename Backend> class PaddingOp;` Meanwhile, I add `DECL_CREATE_OP(PaddingOp);` for Reference and SMV
4. In "bachend.cpp" I add `#include "smaug/operators/padding_op.h"` and `DEF_CREATE_OP(PaddingOp, ReferenceBackend)`, `DEF_CREATE_OP(PaddingOp, SmvBackend)`
5. In "network_builder.cpp", I add a new brach for padding operator.
```
else if (type == OpType::Padding) { // how to set this
auto op = Backend::createPaddingOp(name, workspace);
network->addOperator(op);
```
However, I can't get this work, the error message as,
build/smaug/core/backend.cpp: In static member function 'static smaug::PaddingOp<smaug::ReferenceBackend>* smaug::ReferenceBackend::createPaddingOp(const string&, smaug::Workspace*)':
build/smaug/core/backend.cpp:43:51: error: invalid use of incomplete type 'class smaug::PaddingOp<smaug::ReferenceBackend>'
return new OpType<Backend>(name, workspace); \
^
build/smaug/core/backend.cpp:83:1: note: in expansion of macro 'DEF_CREATE_OP'
DEF_CREATE_OP(PaddingOp, ReferenceBackend)
^
In file included from build/smaug/core/backend.cpp:1:0:
build/smaug/core/backend.h:90:7: note: declaration of 'class smaug::PaddingOp<smaug::ReferenceBackend>'
class PaddingOp;
^~~~~~~~~
build/smaug/core/backend.cpp: In static member function 'static smaug::PaddingOp<smaug::SmvBackend>* smaug::SmvBackend::createPaddingOp(const string&, smaug::Workspace*)':
build/smaug/core/backend.cpp:43:51: error: invalid use of incomplete type 'class smaug::PaddingOp<smaug::SmvBackend>'
return new OpType<Backend>(name, workspace); \
^
build/smaug/core/backend.cpp:113:1: note: in expansion of macro 'DEF_CREATE_OP'
DEF_CREATE_OP(PaddingOp, SmvBackend)
^
In file included from build/smaug/core/backend.cpp:1:0:
build/smaug/core/backend.h:90:7: note: declaration of 'class smaug::PaddingOp<smaug::SmvBackend>'
class PaddingOp;
^~~~~~~~~
make/Makefile.native:41: recipe for target 'build/smaug/core/backend.o' failed
make[2]: *** [build/smaug/core/backend.o] Error 1
make/Makefile.native:66: recipe for target 'tests' failed
make[1]: *** [tests] Error 2
Makefile:16: recipe for target 'test' failed
make: *** [test] Error 2
root@a5b0bbeb0475:/workspace/smaug# make test
make[2]: Nothing to be done for 'protos'.
g++ -c -std=c++17 -O3 -g -DDMA_MODE -DDMA_INTERFACE_V3 -msse3 -msse2 -mno-ssse3 -mno-sse4.1 -mno-sse4.2 -Wno-deprecated-declarations -Ibuild -Ibuild/gem5 -I/workspace/gem5-aladdin/src/aladdin/gem5 -I/workspace/gem5-aladdin/src/aladdin/../..//include -I/usr/include/include -Ithird_party/Catch2/single_include -Ithird_party/FP16/include build/smaug/operators/ref/ref_padding_op.cpp -o build/smaug/operators/ref/ref_padding_op.o
build/smaug/operators/ref/ref_padding_op.cpp:8:39: error: invalid use of incomplete type 'class smaug::PaddingOp<smaug::ReferenceBackend>'
void PaddingOp<ReferenceBackend>::run() {
^
In file included from build/smaug/operators/ref/ref_padding_op.cpp:1:0:
build/smaug/core/backend.h:90:7: note: declaration of 'class smaug::PaddingOp<smaug::ReferenceBackend>'
class PaddingOp;
^~~~~~~~~
make/Makefile.native:41: recipe for target 'build/smaug/operators/ref/ref_padding_op.o' failed
make[2]: *** [build/smaug/operators/ref/ref_padding_op.o] Error 1
make/Makefile.native:66: recipe for target 'tests' failed
make[1]: *** [tests] Error 2
Makefile:16: recipe for target 'test' failed
make: *** [test] Error 2