op_proto_test.cc 921 字节
Newer Older
Y
Yu Yang 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
#include <gtest/gtest.h>
#include <paddle/framework/op_proto.pb.h>

TEST(TestOpProto, ALL) {
  paddle::framework::OpProto proto;
  {
    auto ipt = proto.mutable_inputs()->Add();
    *ipt->mutable_name() = "a";
    *ipt->mutable_comment() = "the one input of cosine op";
  }
  {
    auto ipt = proto.mutable_inputs()->Add();
    *ipt->mutable_name() = "b";
    *ipt->mutable_comment() = "the other input of cosine op";
  }
  {
    auto opt = proto.mutable_outputs()->Add();
    *opt->mutable_name() = "output";
    *opt->mutable_comment() = "the output of cosine op";
  }
  {
    auto attr = proto.mutable_attrs()->Add();
    *attr->mutable_name() = "scale";
    attr->set_type(paddle::framework::AttrType::FLOAT);
    *attr->mutable_comment() = "the scale attribute of cosine op";
  }
  proto.set_type("cos");
  *proto.mutable_comment() = "cosine op, output = scale * cos(a, b)";

  ASSERT_TRUE(proto.IsInitialized());
}