Last active
April 10, 2020 19:43
-
-
Save ailzhang/5129517bd630579ef69536afe33255cb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c10::optional<std::function<at::Tensor(const at::Tensor&)>> func=c10::nullopt; | |
if (!self.unsafeGetTensorImpl()->support_as_strided()) { | |
func = [=](const at::Tensor& input_base) { | |
return at::alias(input_base); | |
}; | |
} | |
c10::optional<std::function<at::Tensor(const at::Tensor&)>> func=c10::nullopt; | |
if (!self.unsafeGetTensorImpl()->support_as_strided()) { | |
auto size_vec = size.vec(); | |
auto stride_vec = stride.vec(); | |
auto storage_offset_val = storage_offset.value_or(0); | |
func = [=](const at::Tensor& input_base) { | |
return at::as_strided(input_base, size_vec, stride_vec, storage_offset_val); | |
}; | |
} | |
c10::optional<std::function<at::Tensor(const at::Tensor&)>> func=c10::nullopt; | |
if (!self.unsafeGetTensorImpl()->support_as_strided()) { | |
func = [=](const at::Tensor& input_base) { | |
return at::diagonal(input_base, offset, dim1, dim2); | |
}; | |
} | |
c10::optional<std::function<at::Tensor(const at::Tensor&)>> func=c10::nullopt; | |
if (!self.unsafeGetTensorImpl()->support_as_strided()) { | |
auto size_vec = size.vec(); | |
func = [=](const at::Tensor& input_base) { | |
return input_base.expand(size_vec, implicit); | |
}; | |
} | |
c10::optional<std::function<at::Tensor(const at::Tensor&)>> func=c10::nullopt; | |
if (!self.unsafeGetTensorImpl()->support_as_strided()) { | |
auto dims_vec = dims.vec(); | |
func = [=](const at::Tensor& input_base) { | |
return input_base.permute(dims_vec); | |
}; | |
} | |
c10::optional<std::function<at::Tensor(const at::Tensor&)>> func=c10::nullopt; | |
if (!self.unsafeGetTensorImpl()->support_as_strided()) { | |
func = [=](const at::Tensor& input_base) { | |
return at::select(input_base, dim, index); | |
}; | |
} | |
c10::optional<std::function<at::Tensor(const at::Tensor&)>> func=c10::nullopt; | |
if (!self.unsafeGetTensorImpl()->support_as_strided()) { | |
func = [=](const at::Tensor& input_base) { | |
return at::slice(input_base, dim, start, end, step); | |
}; | |
} | |
c10::optional<std::function<at::Tensor(const at::Tensor&)>> func=c10::nullopt; | |
if (!self.unsafeGetTensorImpl()->support_as_strided()) { | |
func = [=](const at::Tensor& input_base) { | |
return at::squeeze(input_base); | |
}; | |
} | |
c10::optional<std::function<at::Tensor(const at::Tensor&)>> func=c10::nullopt; | |
if (!self.unsafeGetTensorImpl()->support_as_strided()) { | |
func = [=](const at::Tensor& input_base) { | |
return at::squeeze(input_base, dim); | |
}; | |
} | |
c10::optional<std::function<at::Tensor(const at::Tensor&)>> func=c10::nullopt; | |
if (!self.unsafeGetTensorImpl()->support_as_strided()) { | |
func = [=](const at::Tensor& input_base) { | |
return at::t(input_base); | |
}; | |
} | |
c10::optional<std::function<at::Tensor(const at::Tensor&)>> func=c10::nullopt; | |
if (!self.unsafeGetTensorImpl()->support_as_strided()) { | |
func = [=](const at::Tensor& input_base) { | |
return at::transpose(input_base, dim0, dim1); | |
}; | |
} | |
c10::optional<std::function<at::Tensor(const at::Tensor&)>> func=c10::nullopt; | |
if (!self.unsafeGetTensorImpl()->support_as_strided()) { | |
func = [=](const at::Tensor& input_base) { | |
return input_base.unfold(dimension, size, step); | |
}; | |
} | |
c10::optional<std::function<at::Tensor(const at::Tensor&)>> func=c10::nullopt; | |
if (!self.unsafeGetTensorImpl()->support_as_strided()) { | |
func = [=](const at::Tensor& input_base) { | |
return at::unsqueeze(input_base, dim); | |
}; | |
} | |
c10::optional<std::function<at::Tensor(const at::Tensor&)>> func=c10::nullopt; | |
if (!self.unsafeGetTensorImpl()->support_as_strided()) { | |
func = [=](const at::Tensor& input_base) { | |
return input_base.values(); | |
}; | |
} | |
c10::optional<std::function<at::Tensor(const at::Tensor&)>> func=c10::nullopt; | |
if (!self.unsafeGetTensorImpl()->support_as_strided()) { | |
auto size_vec = size.vec(); | |
func = [=](const at::Tensor& input_base) { | |
return input_base.view(size_vec); | |
}; | |
} | |
c10::optional<std::function<at::Tensor(const at::Tensor&)>> func=c10::nullopt; | |
if (!self.unsafeGetTensorImpl()->support_as_strided()) { | |
auto size_vec = size.vec(); | |
func = [=](const at::Tensor& input_base) { | |
return input_base.expand(size_vec, implicit); | |
}; | |
} | |
c10::optional<std::function<at::Tensor(const at::Tensor&)>> func=c10::nullopt; | |
if (!self.unsafeGetTensorImpl()->support_as_strided()) { | |
auto dims_vec = dims.vec(); | |
func = [=](const at::Tensor& input_base) { | |
return input_base.permute(dims_vec); | |
}; | |
} | |
c10::optional<std::function<at::Tensor(const at::Tensor&)>> func=c10::nullopt; | |
if (!self.unsafeGetTensorImpl()->support_as_strided()) { | |
func = [=](const at::Tensor& input_base) { | |
return at::select(input_base, dim, index); | |
}; | |
} | |
c10::optional<std::function<at::Tensor(const at::Tensor&)>> func=c10::nullopt; | |
if (!self.unsafeGetTensorImpl()->support_as_strided()) { | |
func = [=](const at::Tensor& input_base) { | |
return at::squeeze(input_base); | |
}; | |
} | |
c10::optional<std::function<at::Tensor(const at::Tensor&)>> func=c10::nullopt; | |
if (!self.unsafeGetTensorImpl()->support_as_strided()) { | |
func = [=](const at::Tensor& input_base) { | |
return at::squeeze(input_base, dim); | |
}; | |
} | |
c10::optional<std::function<at::Tensor(const at::Tensor&)>> func=c10::nullopt; | |
if (!self.unsafeGetTensorImpl()->support_as_strided()) { | |
func = [=](const at::Tensor& input_base) { | |
return at::diagonal(input_base, offset, dim1, dim2); | |
}; | |
} | |
c10::optional<std::function<at::Tensor(const at::Tensor&)>> func=c10::nullopt; | |
if (!self.unsafeGetTensorImpl()->support_as_strided()) { | |
func = [=](const at::Tensor& input_base) { | |
return at::t(input_base); | |
}; | |
} | |
c10::optional<std::function<at::Tensor(const at::Tensor&)>> func=c10::nullopt; | |
if (!self.unsafeGetTensorImpl()->support_as_strided()) { | |
func = [=](const at::Tensor& input_base) { | |
return at::transpose(input_base, dim0, dim1); | |
}; | |
} | |
c10::optional<std::function<at::Tensor(const at::Tensor&)>> func=c10::nullopt; | |
if (!self.unsafeGetTensorImpl()->support_as_strided()) { | |
func = [=](const at::Tensor& input_base) { | |
return input_base.values(); | |
}; | |
} | |
c10::optional<std::function<at::Tensor(const at::Tensor&)>> func=c10::nullopt; | |
if (!self.unsafeGetTensorImpl()->support_as_strided()) { | |
func = [=](const at::Tensor& input_base) { | |
return at::alias(input_base); | |
}; | |
} | |
c10::optional<std::function<at::Tensor(const at::Tensor&)>> func=c10::nullopt; | |
if (!self.unsafeGetTensorImpl()->support_as_strided()) { | |
func = [=](const at::Tensor& input_base) { | |
return at::unsqueeze(input_base, dim); | |
}; | |
} | |
c10::optional<std::function<at::Tensor(const at::Tensor&)>> func=c10::nullopt; | |
if (!self.unsafeGetTensorImpl()->support_as_strided()) { | |
auto size_vec = size.vec(); | |
auto stride_vec = stride.vec(); | |
auto storage_offset_val = storage_offset.value_or(0); | |
func = [=](const at::Tensor& input_base) { | |
return at::as_strided(input_base, size_vec, stride_vec, storage_offset_val); | |
}; | |
} | |
c10::optional<std::function<at::Tensor(const at::Tensor&)>> func=c10::nullopt; | |
if (!self.unsafeGetTensorImpl()->support_as_strided()) { | |
func = [=](const at::Tensor& input_base) { | |
return at::slice(input_base, dim, start, end, step); | |
}; | |
} | |
c10::optional<std::function<at::Tensor(const at::Tensor&)>> func=c10::nullopt; | |
if (!self.unsafeGetTensorImpl()->support_as_strided()) { | |
func = [=](const at::Tensor& input_base) { | |
return input_base.unfold(dimension, size, step); | |
}; | |
} | |
c10::optional<std::function<at::Tensor(const at::Tensor&)>> func=c10::nullopt; | |
if (!self.unsafeGetTensorImpl()->support_as_strided()) { | |
auto size_vec = size.vec(); | |
func = [=](const at::Tensor& input_base) { | |
return input_base.view(size_vec); | |
}; | |
} | |
c10::optional<std::function<at::Tensor(const at::Tensor&)>> func=c10::nullopt; | |
if (!self.unsafeGetTensorImpl()->support_as_strided()) { | |
func = [=](const at::Tensor& input_base) { | |
return at::alias(input_base); | |
}; | |
} | |
c10::optional<std::function<at::Tensor(const at::Tensor&)>> func=c10::nullopt; | |
if (!self.unsafeGetTensorImpl()->support_as_strided()) { | |
auto size_vec = size.vec(); | |
auto stride_vec = stride.vec(); | |
auto storage_offset_val = storage_offset.value_or(0); | |
func = [=](const at::Tensor& input_base) { | |
return at::as_strided(input_base, size_vec, stride_vec, storage_offset_val); | |
}; | |
} | |
c10::optional<std::function<at::Tensor(const at::Tensor&)>> func=c10::nullopt; | |
if (!self.unsafeGetTensorImpl()->support_as_strided()) { | |
func = [=](const at::Tensor& input_base) { | |
return at::diagonal(input_base, offset, dim1, dim2); | |
}; | |
} | |
c10::optional<std::function<at::Tensor(const at::Tensor&)>> func=c10::nullopt; | |
if (!self.unsafeGetTensorImpl()->support_as_strided()) { | |
auto size_vec = size.vec(); | |
func = [=](const at::Tensor& input_base) { | |
return input_base.expand(size_vec, implicit); | |
}; | |
} | |
c10::optional<std::function<at::Tensor(const at::Tensor&)>> func=c10::nullopt; | |
if (!self.unsafeGetTensorImpl()->support_as_strided()) { | |
auto dims_vec = dims.vec(); | |
func = [=](const at::Tensor& input_base) { | |
return input_base.permute(dims_vec); | |
}; | |
} | |
c10::optional<std::function<at::Tensor(const at::Tensor&)>> func=c10::nullopt; | |
if (!self.unsafeGetTensorImpl()->support_as_strided()) { | |
func = [=](const at::Tensor& input_base) { | |
return at::select(input_base, dim, index); | |
}; | |
} | |
c10::optional<std::function<at::Tensor(const at::Tensor&)>> func=c10::nullopt; | |
if (!self.unsafeGetTensorImpl()->support_as_strided()) { | |
func = [=](const at::Tensor& input_base) { | |
return at::slice(input_base, dim, start, end, step); | |
}; | |
} | |
c10::optional<std::function<at::Tensor(const at::Tensor&)>> func=c10::nullopt; | |
if (!self.unsafeGetTensorImpl()->support_as_strided()) { | |
func = [=](const at::Tensor& input_base) { | |
return at::squeeze(input_base); | |
}; | |
} | |
c10::optional<std::function<at::Tensor(const at::Tensor&)>> func=c10::nullopt; | |
if (!self.unsafeGetTensorImpl()->support_as_strided()) { | |
func = [=](const at::Tensor& input_base) { | |
return at::squeeze(input_base, dim); | |
}; | |
} | |
c10::optional<std::function<at::Tensor(const at::Tensor&)>> func=c10::nullopt; | |
if (!self.unsafeGetTensorImpl()->support_as_strided()) { | |
func = [=](const at::Tensor& input_base) { | |
return at::t(input_base); | |
}; | |
} | |
c10::optional<std::function<at::Tensor(const at::Tensor&)>> func=c10::nullopt; | |
if (!self.unsafeGetTensorImpl()->support_as_strided()) { | |
func = [=](const at::Tensor& input_base) { | |
return at::transpose(input_base, dim0, dim1); | |
}; | |
} | |
c10::optional<std::function<at::Tensor(const at::Tensor&)>> func=c10::nullopt; | |
if (!self.unsafeGetTensorImpl()->support_as_strided()) { | |
func = [=](const at::Tensor& input_base) { | |
return input_base.unfold(dimension, size, step); | |
}; | |
} | |
c10::optional<std::function<at::Tensor(const at::Tensor&)>> func=c10::nullopt; | |
if (!self.unsafeGetTensorImpl()->support_as_strided()) { | |
func = [=](const at::Tensor& input_base) { | |
return at::unsqueeze(input_base, dim); | |
}; | |
} | |
c10::optional<std::function<at::Tensor(const at::Tensor&)>> func=c10::nullopt; | |
if (!self.unsafeGetTensorImpl()->support_as_strided()) { | |
func = [=](const at::Tensor& input_base) { | |
return input_base.values(); | |
}; | |
} | |
c10::optional<std::function<at::Tensor(const at::Tensor&)>> func=c10::nullopt; | |
if (!self.unsafeGetTensorImpl()->support_as_strided()) { | |
auto size_vec = size.vec(); | |
func = [=](const at::Tensor& input_base) { | |
return input_base.view(size_vec); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment