Skip to content

Commit

Permalink
[JIT] Optimize FunctionSchema::checkArg for the Tensor case. (#48034)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #48034

The Tensor case is one of the most common and the existing check can be
made faster. This results in a ~21% improvement on DeepAndWide model and
would improve other models as well.

Before the change:
```
505[ms]
491[ms]
514[ms]
538[ms]
514[ms]
554[ms]
556[ms]
512[ms]
516[ms]
527[ms]
```

After the change:
```
406[ms]
394[ms]
414[ms]
423[ms]
449[ms]
397[ms]
410[ms]
389[ms]
395[ms]
414[ms]
```

Differential Revision: D24999486

Test Plan: Imported from OSS

Reviewed By: zdevito

Pulled By: ZolotukhinM

fbshipit-source-id: 7139a3a38f9c44e8ea793afe2fc662ff51cc0460
  • Loading branch information
Mikhail Zolotukhin authored and facebook-github-bot committed Nov 17, 2020
1 parent 7b2c78f commit 3611d26
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions aten/src/ATen/core/function_schema_inl.h
Expand Up @@ -151,6 +151,10 @@ inline void FunctionSchema::checkArg(
const IValue& value,
const Argument& argument,
optional<size_t> pos) const {
if (value.isTensor() && argument.type() == TensorType::get()) {
// Fast-path for the common case
return;
}
if (!value.type()->isSubtypeOf(argument.type())) {
TORCH_CHECK(
false,
Expand Down

0 comments on commit 3611d26

Please sign in to comment.