MNN/source/shape/ShapeSize.cpp

31 lines
794 B
C++
Raw Normal View History

2019-04-17 10:49:11 +08:00
//
// ShapeSize.cpp
// MNN
//
// Created by MNN on 2019/01/10.
// Copyright © 2018, Alibaba Group Holding Limited
//
2020-11-05 16:41:56 +08:00
#include "shape/SizeComputer.hpp"
2019-12-27 22:16:57 +08:00
#include "core/Macro.h"
#include "core/TensorUtils.hpp"
2019-04-17 10:49:11 +08:00
namespace MNN {
class SizeOpComputer : public SizeComputer {
virtual bool onComputeSize(const MNN::Op* op, const std::vector<Tensor*>& inputs,
const std::vector<Tensor*>& outputs) const override {
// Scalar
outputs[0]->buffer().dimensions = 0;
outputs[0]->setType(DataType_DT_INT32);
TensorUtils::getDescribe(outputs[0])->dimensionFormat = op->defaultDimentionFormat();
2019-04-17 10:49:11 +08:00
return true;
}
};
REGISTER_SHAPE(SizeOpComputer, OpType_Size);
REGISTER_SHAPE(SizeOpComputer, OpType_Rank);
2019-04-17 10:49:11 +08:00
} // namespace MNN