Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Relay][Frontend][Torch] fix pytorch frontend linspace op #16417

Merged

Conversation

taomiao
Copy link
Contributor

@taomiao taomiao commented Jan 17, 2024

torch.linspace(0, 8, 10) output 10 elements array, but tvm output 11 elements array. #16416

inline Tensor arange(const PrimExpr& start, const PrimExpr& stop, const PrimExpr& step,
                     DataType dtype, std::string name = "T_arange", std::string tag = kInjective) {
  PrimExpr num_elem = tvm::cast(
      tvm::DataType::Int(32), tvm::ceil(tvm::cast(tvm::DataType::Float(32), stop - start) / step));
  Array<PrimExpr> shape;
  return compute(
      {num_elem},
      [&](const Array<Var>& indices) { return tvm::cast(dtype, start + step * indices[0]); }, name,
      tag);
}

float number precision deviation leads to this error.

@taomiao
Copy link
Contributor Author

taomiao commented Jan 17, 2024

@masahi @siju-samuel would you help check this change is ok?

@taomiao taomiao changed the title fix pytorch frontend linspace op [Relay][Frontend][Torch] fix pytorch frontend linspace op Jan 17, 2024
@masahi
Copy link
Member

masahi commented Jan 17, 2024

can you fix the lint issue?

@taomiao taomiao force-pushed the fix/pytorch_frontend_linspace_get_wrong_result branch from d8a3fd5 to b733703 Compare January 18, 2024 03:34
@taomiao
Copy link
Contributor Author

taomiao commented Jan 18, 2024

can you fix the lint issue?

ok

@taomiao taomiao force-pushed the fix/pytorch_frontend_linspace_get_wrong_result branch from b733703 to 59b77cd Compare January 18, 2024 03:36
@masahi masahi merged commit e1c430c into apache:main Jan 18, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants