bool RunOnDevice() override {
MPI_Comm comm = OperatorBase::Input<MPICommonWorldWrapper>(0).comm();
auto& input = Input(1);
- auto* output = Output(0);
- output->ResizeLike(input);
+ auto* output = Output(0, input.sizes(), at::dtype<T>());
MPI_CHECK(MPI_Reduce(
const_cast<T*>(input.template data<T>()),
output->template mutable_data<T>(),
bool RunOnDevice() override {
MPI_Comm comm = OperatorBase::Input<MPICommonWorldWrapper>(0).comm();
auto& input = Input(1);
- auto* output = Output(0);
- output->ResizeLike(input);
+ auto* output = Output(0, input.sizes(), at::dtype<T>());
void* source;
if (output->template mutable_data<T>() == input.template data<T>()) {
// We are doing in-place call. Special case handling.
template <typename T>
bool DoRunWithType() {
const auto& X = Input(0);
- auto* Y = Output(0);
- Y->ResizeLike(X);
+
+ auto* Y = Output(0, X.sizes(), at::dtype<T>());
if (X.numel() == 0) {
Y->template mutable_data<T>();
return true;
bool DoRunWithType() {
const auto& Y = Input(0);
const auto& dY = Input(1);
- auto* dX = Output(0);
- dX->ResizeLike(Y);
+
+ auto* dX = Output(0, Y.sizes(), at::dtype<T>());
if (Y.numel() == 0) {
dX->template mutable_data<T>();
return true;
bool AffineChannelGradientOp<float, CPUContext>::RunOnDeviceWithOrderNCHW() {
const auto& dY = Input(0);
const auto& scale = is_learnable_ ? Input(2) : Input(1);
- auto* dX = Output(0);
- dX->ResizeLike(dY);
+
+ auto* dX = Output(0, dY.sizes(), at::dtype<float>());
const int N = dY.dim32(0);
const int C = dY.dim32(1);
const int HxW = dY.numel() / (N * C);
if (is_learnable_) {
const auto& X = Input(1);
const float* X_data = X.data<float>();
- auto* dscale = Output(1);
- auto* dbias = Output(2);
- dscale->ResizeLike(scale);
- dbias->ResizeLike(scale);
+
+ auto* dscale = Output(1, scale.sizes(), at::dtype<float>());
+ auto* dbias = Output(2, scale.sizes(), at::dtype<float>());
AffineChannelScaleBiasBackwardNCHW<float>(
N,
C,
bool AffineChannelGradientOp<float, CPUContext>::RunOnDeviceWithOrderNHWC() {
const auto& dY = Input(0);
const auto& scale = is_learnable_ ? Input(2) : Input(1);
- auto* dX = Output(0);
- dX->ResizeLike(dY);
+
+ auto* dX = Output(0, dY.sizes(), at::dtype<float>());
const int ndim = dY.dim();
const int C = dY.dim32(ndim - 1);
const int rows = dY.numel() / C;
const float* X_data = X.data<float>();
const int N = X.dim32(0);
const int HxW = rows / N;
- auto* dscale = Output(1);
- auto* dbias = Output(2);
- dscale->ResizeLike(scale);
- dbias->ResizeLike(scale);
+
+ auto* dscale = Output(1, scale.sizes(), at::dtype<float>());
+ auto* dbias = Output(2, scale.sizes(), at::dtype<float>());
AffineChannelScaleBiasBackwardNHWC<float>(
N,
C,
const auto& X = Input(0);
const auto& scale = Input(1);
const auto& bias = Input(2);
- auto* Y = Output(0);
+
if (is_learnable_) {
- CAFFE_ENFORCE_NE(
- Y,
- &X,
+ CAFFE_ENFORCE(
+ !IsInputOutputAlias(0, 0),
"In-place affine_channel_op is not supported when "
"is_learnable = true.");
}
const int N = X.dim32(0);
const int C = X.dim32(1);
const int HxW = X.numel() / (N * C);
- Y->ResizeLike(X);
+ auto* Y = Output(0, X.sizes(), at::dtype<T>());
math::AffineChannel<T, Context, StorageOrder::NCHW>(
N,
C,
const auto& X = Input(0);
const auto& scale = Input(1);
const auto& bias = Input(2);
- auto* Y = Output(0);
+
if (is_learnable_) {
- CAFFE_ENFORCE_NE(
- Y,
- &X,
+ CAFFE_ENFORCE(
+ !IsInputOutputAlias(0, 0),
"In-place affine_channel_op is not supported when "
"is_learnable = true.");
}
const int N = X.dim32(0);
const int C = X.dim32(ndim - 1);
const int HxW = X.numel() / (N * C);
- Y->ResizeLike(X);
+ auto* Y =
+ Output(0, X.sizes(), at::dtype<T>());
math::AffineChannel<T, Context, StorageOrder::NHWC>(
N,
C,
auto N = data.size(0);
auto D = data.size_from_dim(1);
- auto* output = Output(0);
- output->ResizeLike(Input(DATA));
+ auto* output = Output(0, Input(DATA).sizes(), at::dtype<T>());
auto* output_ptr = output->template mutable_data<T>();
if (data.numel() <= 0) {
auto& data = Input(DATA);
auto& indices = Input(INDICES);
auto& grad = Input(GRAD);
- auto* output = Output(0);
// ONNX allows negative axis to index from the back, valid range: [-r, r].
int axis = axis_;
"batch gather outer dimensions should match");
}
- output->ResizeLike(data);
+ auto* output = Output(0, data.sizes(), at::dtype<TData>());
TData* out_data = output->template mutable_data<TData>();
if (data.numel() <= 0) {
return true;
const auto& dmu = Input(0);
const auto& dvar = Input(1);
const auto& X = Input(2);
- auto* dX = Output(0);
+
const int ndim = X.dim();
const int N = X.dim32(0);
const int C = order_ == StorageOrder::NCHW ? X.dim32(1) : X.dim32(ndim - 1);
const int HxW = X.numel() / (N * C);
- dX->ResizeLike(X);
+ auto* dX = Output(0, X.sizes(), at::dtype<T>());
const T* dmu_data = dmu.template data<T>();
const T* dvar_data = dvar.template data<T>();
const T* X_data = X.template data<T>();
const auto& roi_in = Input(0);
const auto& delta_in = Input(1);
const auto& iminfo_in = Input(2);
- auto* box_out = Output(0);
const int box_dim = rotated_ ? 5 : 4;
const int N = roi_in.dim32(0);
Eigen::Map<const ERArrXXf> iminfo(
iminfo_in.data<float>(), iminfo_in.size(0), iminfo_in.size(1));
- box_out->ResizeLike(delta_in);
+ auto* box_out = Output(0, delta_in.sizes(), at::dtype<float>());
Eigen::Map<ERArrXXf> new_boxes(
box_out->template mutable_data<float>(),
box_out->dim32(0),
const float* raw_data = raw.template data<float>();
// Output
- auto* pct = Output(PCT);
- pct->ResizeLike(raw);
+
+ auto* pct = Output(PCT, raw.sizes(), at::dtype<float>());
float* pct_output = pct->template mutable_data<float>();
// Compute percentile for each raw feature value
bool DoRunWithType() {
auto& lengths = Input(0);
auto& mask = Input(1);
- auto* lengthsOut = Output(0);
+
CAFFE_ENFORCE(lengths.dim() == 1);
CAFFE_ENFORCE(mask.dim() == 1);
const auto* lengthsPtr = lengths.template data<T>();
auto totalLength =
std::accumulate(lengthsPtr, lengthsPtr + lengths.numel(), 0);
CAFFE_ENFORCE(mask.numel() == totalLength);
- lengthsOut->ResizeLike(lengths);
+ auto* lengthsOut = Output(0, lengths.sizes(), at::dtype<T>());
auto* lengthsOutPtr = lengthsOut->template mutable_data<T>();
int p = 0;
for (int i = 0; i < lengths.numel(); ++i) {
window_centers = &Input(1);
}
- auto* output = Output(0);
- output->ResizeLike(*input);
+ auto* output = Output(0, input->sizes(), at::dtype<T>());
const auto canonical_axis = input->canonical_axis_index(axis_);