void checkSize(CheckedFrom c, const TensorGeometryArg& t, IntList sizes) { checkDim(c, t, sizes.size()); if (!t->sizes().equals(sizes)) { std::ostringstream oss; oss << "Expected tensor of size " << sizes << ", but got tensor of size " << t->sizes() << " for " << t << " (while checking arguments for " << c << ")"; throw std::runtime_error(oss.str()); } }
ALOperator::ALOperator(const std::vector<std::vector<int> > & vars, const Teuchos::RCP<Epetra_Operator> & content, double gamma, const std::string & label) : Teko::Epetra::BlockedEpetraOperator(vars, content, label), pressureMassMatrix_(Teuchos::null), gamma_(gamma) { checkDim(vars); SetContent(vars, content); BuildALOperator(); }
Tensor adaptive_avg_pool1d(const Tensor & self, IntList output_size) { checkDim("adaptive_avg_pool1d", TensorArg(self, "self", 1), 3); check1d("output_size", output_size); auto output = at::adaptive_avg_pool2d( self.unsqueeze(2), {1, output_size[0]}); return output.squeeze(2); }
std::tuple<Tensor,Tensor> adaptive_max_pool1d(const Tensor & self, IntList output_size) { checkDim("adaptive_max_pool1d", TensorArg(self, "self", 1), 3); check1d("output_size", output_size); Tensor output, indices; std::tie(output, indices) = at::adaptive_max_pool2d( self.unsqueeze(2), {1, output_size[0]}); return std::make_tuple(output.squeeze(2), indices.squeeze(2)); }
std::tuple<Tensor,Tensor> max_pool1d( const Tensor & self, IntList kernel_size, IntList stride, IntList padding, IntList dilation, bool ceil_mode) { if (stride.empty()) { stride = kernel_size; } checkDim("max_pool1d", TensorArg(self, "self", 1), 3); check1d("kernel_size", kernel_size); check1d("stride", stride); check1d("padding", padding); check1d("dilation", dilation); Tensor output, indices; std::tie(output, indices) = at::max_pool2d( self.unsqueeze(2), {1, kernel_size[0]}, {1, stride[0]}, {0, padding[0]}, {1, dilation[0]}, ceil_mode); return std::make_tuple(output.squeeze(2), indices.squeeze(2)); }