未验证 提交 09df022c 编写于 作者: T Twice 提交者: GitHub

cast: return self for same dtype (#6306)

* cast: return self for same dtype

* cast: format
Co-authored-by: Noneflow-ci-bot <69100618+oneflow-ci-bot@users.noreply.github.com>
上级 b06aee7b
......@@ -346,6 +346,8 @@ class CastFunctor {
CastFunctor() { op_ = CHECK_JUST(one::OpBuilder("cast").Input("in").Output("out").Build()); }
Maybe<Tensor> operator()(const std::shared_ptr<one::Tensor>& x,
const Symbol<DType>& dtype) const {
if (x->dtype() == dtype) { return x; }
MutableAttrMap attrs;
JUST(attrs.SetAttr<DataType>("dtype", dtype->data_type()));
return OpInterpUtil::Dispatch<Tensor>(*op_, {x}, attrs);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册