Skip to content

Commit

Permalink
Merged PR 1139: conv op: set some default values, until we can guaran…
Browse files Browse the repository at this point in the history
…tee node attribute values are always available

set some default values, until we can guarantee node attribute values are always available to op constructor.
assumes kernel_shape attribute is set. spec says otherwise, but in practice I suspect converters always fill it.
  • Loading branch information
jywu-msft committed Mar 29, 2018
1 parent b7f0c97 commit d32b606
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions lotus/core/providers/cpu/nn/conv_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,34 @@ namespace Lotus {
class ConvBase : public OpKernel {
public:
ConvBase(const OpKernelInfo& info) : OpKernel(info) {
std::string auto_pad;
auto status = info.GetAttr<std::string>("auto_pad", &auto_pad);
auto_pad_ = status.IsOK() ? StringToAutoPadType(auto_pad) : AutoPadType::NOTSET;

LOTUS_ENFORCE(info.GetAttrs<int64_t>("kernel_shape", kernel_shape_).IsOK());

status = info.GetAttrs<int64_t>("strides", strides_);
if (!status.IsOK()) {
strides_.resize(kernel_shape_.size(), 1);
}

status = info.GetAttrs<int64_t>("pads", pads_);
if (!status.IsOK()) {
pads_.resize(kernel_shape_.size() * 2, 0);
}

status = info.GetAttrs<int64_t>("dilations", dilations_);
if (!status.IsOK()) {
dilations_.resize(kernel_shape_.size(), 1);
}

status = info.GetAttr<int64_t>("group", &group_);
if (!status.IsOK()) {
group_ = 1;
}

#if false
// TODO: Re-enable when attributes values are guaranteed to be filled.
std::string auto_pad;
LOTUS_ENFORCE(info.GetAttr<std::string>("auto_pad", &auto_pad).IsOK());
auto_pad_ = StringToAutoPadType(auto_pad);
Expand All @@ -19,6 +47,7 @@ class ConvBase : public OpKernel {
LOTUS_ENFORCE(info.GetAttrs<int64_t>("strides", strides_).IsOK());
LOTUS_ENFORCE(info.GetAttrs<int64_t>("pads", pads_).IsOK());
LOTUS_ENFORCE(info.GetAttrs<int64_t>("dilations", dilations_).IsOK());
#endif
}

virtual ~ConvBase() {}
Expand Down

0 comments on commit d32b606

Please sign in to comment.