Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update on "[quant][graphmode][fx] Add functional conv2d + relu"
Summary: Added support for functional conv2d + relu, will add conv1d and conv3d in future PR Test Plan: python test/test_quantization.py TestQuantizeFxOps.test_functional_conv Reviewers: Subscribers: Tasks: Tags: Differential Revision: [D26089964](https://our.internmc.facebook.com/intern/diff/D26089964) [ghstack-poisoned]
- Loading branch information
Showing
150 changed files
with
5,467 additions
and
1,452 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include <ATen/core/Vitals.h> | ||
#include <cstdlib> | ||
|
||
TorchVitalAttr& TorchVital::create(const std::string& attr) { | ||
if (!torchVitalEnabled()) { | ||
static TorchVitalAttr disabled; | ||
return disabled; | ||
} | ||
auto iter = attrs.find(attr); | ||
if (iter == attrs.end()) { | ||
auto r = attrs.emplace(std::make_pair(attr, TorchVitalAttr())); | ||
return r.first->second; | ||
} | ||
return iter->second; | ||
} | ||
|
||
bool torchVitalEnabled() { | ||
// If this is a performance hit, make `enabled` variable static | ||
// and return `const bool&` instead | ||
bool enabled = []() { | ||
auto e = getenv("TORCH_VITAL"); | ||
if (e != nullptr) { | ||
return strlen(e) > 0; | ||
} | ||
return false; | ||
}(); | ||
return enabled; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#pragma once | ||
#include <cstring> | ||
#include <iostream> | ||
#include <sstream> | ||
#include <unordered_map> | ||
|
||
bool torchVitalEnabled(); | ||
|
||
struct TorchVitalAttr { | ||
// always initialized to empty | ||
std::string value = ""; | ||
template <typename T> | ||
TorchVitalAttr& operator<<(const T& t) { | ||
if (torchVitalEnabled()) { | ||
std::stringstream ss; | ||
ss << t; | ||
value += ss.str(); | ||
} | ||
return *this; | ||
} | ||
}; | ||
|
||
struct TorchVital { | ||
std::string name; | ||
std::unordered_map<std::string, TorchVitalAttr> attrs; | ||
|
||
explicit TorchVital(std::string n) : name(std::move(n)) {} | ||
TorchVital() = delete; | ||
|
||
TorchVitalAttr& create(const std::string& attr); | ||
|
||
~TorchVital() { | ||
for (const auto& m : attrs) { | ||
std::cout << "[TORCH_VITAL] " << name << "." << m.first << "\t\t " | ||
<< m.second.value << "\n"; | ||
} | ||
} | ||
}; | ||
|
||
#define TORCH_VITAL_DECLARE(name) extern TorchVital TorchVital_##name; | ||
|
||
#define TORCH_VITAL_DEFINE(name) TorchVital TorchVital_##name(#name); | ||
|
||
#define TORCH_VITAL(name, attr) TorchVital_##name.create(#attr) |
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
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
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
Oops, something went wrong.