mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[BE][10/16] fix typos in torch/ (torch/csrc/jit/) (#156320)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/156320 Approved by: https://github.com/albanD ghstack dependencies: #156318
This commit is contained in:
committed by
PyTorch MergeBot
parent
541584d22e
commit
d5cdc36943
@ -1177,7 +1177,6 @@ exclude_patterns = [
|
||||
'torch/distributed/tensor/**',
|
||||
'torch/[j-o]*/**',
|
||||
'torch/utils/**',
|
||||
'torch/csrc/jit/[a-o]*/**',
|
||||
]
|
||||
init_command = [
|
||||
'python3',
|
||||
|
@ -10,6 +10,7 @@ ElementE
|
||||
followings
|
||||
fro
|
||||
froms
|
||||
Halfs
|
||||
hsa
|
||||
nd
|
||||
nin
|
||||
@ -28,3 +29,4 @@ requestor
|
||||
ser'de
|
||||
supercedes
|
||||
te
|
||||
WONT
|
||||
|
@ -147,7 +147,7 @@ struct TORCH_API GraphFunction : public Function {
|
||||
mutable std::array<std::shared_ptr<Graph>, SpecializationKey::TotalCount>
|
||||
optimized_graphs_;
|
||||
|
||||
// GraphFunctions are invokable from multiple threads, so this lock needs to
|
||||
// GraphFunctions are invocable from multiple threads, so this lock needs to
|
||||
// be held when we're initializing graph executor for the first time or
|
||||
// computing the optimized graph. We're using reentrant mutex so that we don't
|
||||
// need to worry about causing a deadlock by calling one method from another
|
||||
|
@ -67,7 +67,7 @@ struct TORCH_API Method : public torch::IMethod {
|
||||
private:
|
||||
void setArgumentNames(std::vector<std::string>&) const override;
|
||||
|
||||
// Methods are uniqued onwed by a single module. This raw pointer allows
|
||||
// Methods are uniqued owned by a single module. This raw pointer allows
|
||||
// looking up the module.
|
||||
ObjectPtr owner_;
|
||||
|
||||
|
@ -327,7 +327,7 @@ struct TORCH_API Module : public Object {
|
||||
// Map of function names to the traced inputs that they have been traced with
|
||||
c10::Dict<std::string, c10::impl::GenericList> traced_inputs_;
|
||||
|
||||
// Mutex to keep registring buffer or parameter thread safe.
|
||||
// Mutex to keep registering buffer or parameter thread safe.
|
||||
std::shared_ptr<std::mutex> register_mutex_ = std::make_shared<std::mutex>();
|
||||
};
|
||||
|
||||
|
@ -26,7 +26,7 @@ int64_t BackendDebugInfoRecorder::getNextDebugHandle(const Node* node) {
|
||||
BackendDebugInfoMapType BackendDebugInfoRecorder::stopRecording() {
|
||||
// Note that this is return by copy and since
|
||||
// InlinedCallStackPtrs are intrusive ptr it will result in
|
||||
// bump of refcount. Not performant, but this is not intented
|
||||
// bump of refcount. Not performant, but this is not intended
|
||||
// to be used in perf critical path.
|
||||
// Alternate might be do move but that will be destructive
|
||||
return handles_to_inlined_callstack_ptrs_;
|
||||
|
@ -18,7 +18,7 @@ namespace torch::jit {
|
||||
* Effectively debug handles are something that is given to backend and later
|
||||
* when an exception occurs in the backend, backend can tell, using debug
|
||||
* handle, that an exception occurred here. Then the runtime can generate
|
||||
* callstack correspoding to the exception.
|
||||
* callstack corresponding to the exception.
|
||||
* There are two parts to BackendDebugHandleManager:
|
||||
* 1. static std::atomic debug_handle
|
||||
* 2. Map of [debug-handle, DebugInfoTuple]
|
||||
|
@ -16,13 +16,13 @@ class TORCH_API BackendRuntimeException : public c10::Error {
|
||||
}
|
||||
// If rethrowing, can push another debug_handle
|
||||
// This is useful in couple of scenarios.
|
||||
// 1. A submodule is lowered and lite interperter has CallMethod
|
||||
// 1. A submodule is lowered and lite interpreter has CallMethod
|
||||
// to lowered module's method. In this case lowered module will throw with
|
||||
// a handle, plus there will be another debug handle corresponding
|
||||
// to the CallMethod node in lite interpreter. Both together give complete
|
||||
// trace. This function allows lite interpreter to rethrow with debug
|
||||
// handle it has for CallMethod.
|
||||
// 2. Another scenarios is when lite interperter can make function calls or
|
||||
// 2. Another scenarios is when lite interpreter can make function calls or
|
||||
// the lowered backend also has function call ability. Thus we have
|
||||
// multiple function frames. Now we need a stack of handles to symbolicate
|
||||
// entire stack trace.
|
||||
|
@ -37,7 +37,7 @@ class XNNSerializer {
|
||||
|
||||
// Serialize add node, we are serializing the argument needed to call
|
||||
// xnn_define_add2. Serializing these values, and at run time we build
|
||||
// teh graph by re running xnn_define_add2
|
||||
// the graph by re running xnn_define_add2
|
||||
void serializeAddNode(
|
||||
uint32_t input1_id,
|
||||
uint32_t input2_id,
|
||||
|
@ -34,7 +34,7 @@ class XNNPackBackend : public PyTorchBackendInterface {
|
||||
c10::impl::GenericDict method_compile_spec) override {
|
||||
auto dict = processed.toGenericDict();
|
||||
|
||||
// Compiling and wrapping exeuction object
|
||||
// Compiling and wrapping execution object
|
||||
const std::string& ser_model = dict.at("ser_model").toStringRef();
|
||||
XNNExecutor executor;
|
||||
XNNCompiler::compileModel(ser_model.data(), ser_model.length(), &executor);
|
||||
|
@ -78,7 +78,7 @@ Graph print out is straight forward and you should look for `prim::CudaFusionGro
|
||||
return (%o.5)
|
||||
```
|
||||
|
||||
Note that one thing that could prevents fusion when you are running training is autodiff. Fusion pass only runs within `prim::DifferentiableGraph`, so the first thing you should check is to that targetted ops are within differentiable graph subgraphs.
|
||||
Note that one thing that could prevents fusion when you are running training is autodiff. Fusion pass only runs within `prim::DifferentiableGraph`, so the first thing you should check is to that targeted ops are within differentiable graph subgraphs.
|
||||
Graph dump could be quite confusing to look at, since it naively dumps all graphs executed by profiling executor and differentiable graphs are executed via a nested graph executor. So for each graph, you might see a few segmented `Optimized Graph` where each corresponds to a differentiable node in the original graph.
|
||||
|
||||
#### 2. Cuda Fusion Graphs
|
||||
|
@ -635,7 +635,7 @@ std::string generateKernel(
|
||||
}
|
||||
|
||||
// Includes headers
|
||||
// Note: CUDA kernels support halfs and random generation, CPU kernels do not
|
||||
// Note: CUDA kernels support Halfs and random generation, CPU kernels do not
|
||||
if (has_half_tensor) {
|
||||
env.s("HalfHeader", cuda::half_support_literal);
|
||||
} else {
|
||||
|
@ -28,7 +28,7 @@ static std::optional<std::vector<int64_t>> getMapSize(
|
||||
// exactly how much storage do we need, so this could be fixed in-place at
|
||||
// every step. We're just missing a few functions for ATen, but the fix
|
||||
// should be straightforward.
|
||||
// Note: left unitialized since empty shape is broadcastable to any shape
|
||||
// Note: left uninitialized since empty shape is broadcastable to any shape
|
||||
std::vector<int64_t> map_size;
|
||||
map_size.reserve(8);
|
||||
for (const auto arg_idx : arg_subset) {
|
||||
@ -201,7 +201,7 @@ static void launchFusion(
|
||||
for (const auto& c : fusion.concatDesc())
|
||||
flat_outputs_size += c.nSubTensors();
|
||||
|
||||
// Fails if the elements of the first (any) tensor are not expressable as
|
||||
// Fails if the elements of the first (any) tensor are not expressible as
|
||||
// a 32-bit integer.
|
||||
// Note: this code assumes that inputs are 32-bit addressable
|
||||
// Note: this code assumes that all inputs are of the same size
|
||||
|
@ -40,7 +40,7 @@ struct FusedKernel {
|
||||
// CUDA code), and the remainder are pointers to the TensorInfo<T> structs
|
||||
// that compiled code uses to load Tensor data.
|
||||
// launch_with_tensors handles packing at::Tensors into this arguments array.
|
||||
// CPU code uses the same convension so that launch_with_tensors can be
|
||||
// CPU code uses the same convention so that launch_with_tensors can be
|
||||
// shared.
|
||||
virtual void launch_raw(const uint32_t numel, std::vector<void*>& arguments)
|
||||
const = 0;
|
||||
|
@ -70,7 +70,7 @@ Operator LlgaGraphHelper::makeBinaryOp(Node* node, opkind kind) {
|
||||
// third_party/ideep/mkl-dnn/src/interface/op_def.hpp.
|
||||
Operator LlgaGraphHelper::createOperator(Node* node) {
|
||||
auto nodeKind = node->kind();
|
||||
// we're using an if-else clause instead of a switch staement
|
||||
// we're using an if-else clause instead of a switch statement
|
||||
// because we would soon be adding custom ops with function schemas.
|
||||
// We would have to use Symbol::fromQualString at that time anyway,
|
||||
// but we are okay with this choice, since this code is not in the hot-path.
|
||||
|
@ -84,9 +84,9 @@ ArgSpecs LlgaKernel::initializeInputSpecs(const TensorArgs& inputs) {
|
||||
for (const auto i : c10::irange(nGraphInputs_)) {
|
||||
auto spec = ArgSpec(graph_->inputs()[i]).supplementTensorInfo(inputs[i]);
|
||||
initializedInputIds_.insert(spec.tid());
|
||||
int64_t occurence = tensorIdToOccurence[spec.tid()];
|
||||
inputSpecs.insert(inputSpecs.end(), occurence, spec);
|
||||
runArgsIdx_.insert(runArgsIdx_.end(), occurence, i);
|
||||
int64_t occurrence = tensorIdToOccurence[spec.tid()];
|
||||
inputSpecs.insert(inputSpecs.end(), occurrence, spec);
|
||||
runArgsIdx_.insert(runArgsIdx_.end(), occurrence, i);
|
||||
}
|
||||
GRAPH_DEBUG("Initializing constant input tensors");
|
||||
initializeConstantInputs();
|
||||
|
@ -371,7 +371,7 @@ TorchScript class, or a `ScriptModule`. Owns other its attribute types
|
||||
**`Object`**: An instance of a particular class. Own the `CompilationUnit`
|
||||
that owns its `ClassType`. This is to ensure that if the user passes the
|
||||
object around in C++, all its code will stay around and methods will be
|
||||
invokable.
|
||||
invocable.
|
||||
|
||||
**`Module`**: A view over a `ClassType` and the `Object` that holds its state.
|
||||
Also responsible for turning unqualified names (e.g. `forward()`) into
|
||||
|
@ -103,10 +103,10 @@ struct BuiltinFunctionRegistry {
|
||||
// re-lock, the mutex without waiting), and report no loaded builtins during
|
||||
// init.
|
||||
std::lock_guard<std::recursive_mutex> guard(mutex);
|
||||
if (state == INTIIALIZING) {
|
||||
if (state == INITIALIZING) {
|
||||
return empty;
|
||||
} else if (state == UNINITIALIZED) {
|
||||
state = INTIIALIZING;
|
||||
state = INITIALIZING;
|
||||
loadBuiltinFunctions();
|
||||
state = INITIALIZED;
|
||||
}
|
||||
@ -168,10 +168,16 @@ struct BuiltinFunctionRegistry {
|
||||
loadSource(aten_ops_additional, "aten");
|
||||
|
||||
// These are under `prim` instead of `aten` since they exist to bind certain
|
||||
// tensor property getters to correpsonding methods
|
||||
// tensor property getters to corresponding methods
|
||||
loadSource(tensor_properties, "prim");
|
||||
}
|
||||
enum { UNINITIALIZED, INTIIALIZING, INITIALIZED } state = UNINITIALIZED;
|
||||
enum {
|
||||
UNINITIALIZED = 0,
|
||||
INITIALIZING = 1,
|
||||
// typo in the original code, keeping for compatibility
|
||||
INTIIALIZING = 1, // codespell:ignore
|
||||
INITIALIZED = 2
|
||||
} state = UNINITIALIZED;
|
||||
std::recursive_mutex mutex;
|
||||
std::vector<std::shared_ptr<CompilationUnit>> modules;
|
||||
std::unordered_map<Symbol, std::vector<Function*>> builtins_by_name_;
|
||||
|
@ -333,7 +333,7 @@ struct ExitTransformer {
|
||||
std::vector<Value*> exit_block_vals;
|
||||
// after an exit, the only values that will get used
|
||||
// are the hasExited() and exitValues(), so we match the existing
|
||||
// block outputs with unitialized
|
||||
// block outputs with uninitialized
|
||||
exit_block_vals = matchValuesWithUnitialized(block->outputs());
|
||||
|
||||
// Set the new if to have the same outputs of the original block,
|
||||
@ -362,7 +362,7 @@ struct ExitTransformer {
|
||||
// break
|
||||
// j = j + 1
|
||||
// where the j + 1 value will be a block output, but since they will
|
||||
// never be used, it is safe to replace them with unitialized value
|
||||
// never be used, it is safe to replace them with uninitialized value
|
||||
void destroyNodeAfterExit(Node* n) {
|
||||
for (auto output : n->outputs()) {
|
||||
if (!output->uses().empty()) {
|
||||
|
@ -959,7 +959,7 @@ struct to_ir {
|
||||
emitDef(
|
||||
def,
|
||||
nullptr,
|
||||
closure_block); // ignore schema return, we just wont use it for now
|
||||
closure_block); // ignore schema return, we just won't use it for now
|
||||
// since we never create a Method for the closure
|
||||
};
|
||||
auto closure_value = emitClosure(emit_body);
|
||||
@ -1578,7 +1578,7 @@ struct to_ir {
|
||||
/*default_to_union=*/true,
|
||||
elem_type_hint);
|
||||
|
||||
// Case: The list comprehension generated heterogenous values,
|
||||
// Case: The list comprehension generated heterogeneous values,
|
||||
// and we don't have a type hint to suggest that this is what the
|
||||
// user expected
|
||||
if (!type_hint && (*unified_elem_type)->isUnionType()) {
|
||||
@ -1701,7 +1701,7 @@ struct to_ir {
|
||||
<< "the first generated key was " << k->type()->repr_str());
|
||||
} else if (
|
||||
first_generated_key_type && first_generated_key_type != k->type()) {
|
||||
// Values can be heterogenous, so we only need to check that the
|
||||
// Values can be heterogeneous, so we only need to check that the
|
||||
// key types are all the same
|
||||
throw(
|
||||
ErrorReport(dc)
|
||||
@ -2118,7 +2118,7 @@ struct to_ir {
|
||||
// Try to unify the types. If we found a type annotation earlier
|
||||
// in the environment, and if that type annotation is some form
|
||||
// of union, then we need to tell `unifyTypes` not to throw an
|
||||
// error if the branched return types we found are heterogenous
|
||||
// error if the branched return types we found are heterogeneous
|
||||
bool default_to_union = full_type &&
|
||||
(full_type->kind() == UnionType::Kind ||
|
||||
full_type->kind() == OptionalType::Kind ||
|
||||
@ -2440,7 +2440,7 @@ struct to_ir {
|
||||
SugaredValuePtr iterable = sv->iter(loc, method);
|
||||
|
||||
// We unroll the loop for iterables that contain ModuleLists so that we can
|
||||
// compile Heterogenous module lists.
|
||||
// compile Heterogeneous module lists.
|
||||
if (!iterable->shouldEmitUnrolled()) {
|
||||
emitLoopCommon(loc, emit_body, iterable, targets, {});
|
||||
} else {
|
||||
@ -4260,7 +4260,7 @@ struct to_ir {
|
||||
}
|
||||
|
||||
std::shared_ptr<SugaredValue> emitRpcExpr(const Apply& apply, Symbol rpc_op) {
|
||||
// TODO: This is a temporary apporoach to enable calling user fucntion
|
||||
// TODO: This is a temporary apporoach to enable calling user function
|
||||
// through RPC in TorchScript,
|
||||
// Ideally, function value in JIT IR is first-class citizen and
|
||||
// The RPC C++ entry API can take c10::Function directly.
|
||||
@ -5399,7 +5399,7 @@ struct FunctionResolver : public Resolver {
|
||||
|
||||
CompilationUnit::CompilationUnit(const std::string& source)
|
||||
: CompilationUnit() {
|
||||
// calles the define with native resolver to generate the graph for functions
|
||||
// calls the define with native resolver to generate the graph for functions
|
||||
define(std::nullopt, source, nativeResolver(), nullptr);
|
||||
}
|
||||
|
||||
|
@ -333,12 +333,12 @@ bool isBlockListedSchema(const FunctionSchema& schema) {
|
||||
// Currently JIT does not distinguish ScalarType vs int, so there is really
|
||||
// no way to distinguish x.view(1) vs x.view(torch.int8). So we have to
|
||||
// hardcode the aten::view.dtype here to block this overload. This blocklist
|
||||
// should be removed when JIT fully suports ScalarType as its own type.
|
||||
// should be removed when JIT fully supports ScalarType as its own type.
|
||||
if (schema.name() == "aten::view" && schema.overload_name() == "dtype") {
|
||||
return true;
|
||||
}
|
||||
// Note (@tugsbayasgalan)
|
||||
// TorchScript doesn't suport kwargs so this op collides with aten.max.others
|
||||
// TorchScript doesn't support kwargs so this op collides with aten.max.others
|
||||
// since both of them have 2 Tensor inputs. Since we don't expect users to
|
||||
// use this op in TS, we just skip it
|
||||
if (schema.name() == "aten::max" && schema.overload_name() == "unary_out") {
|
||||
|
@ -448,7 +448,7 @@ std::vector<Argument> ScriptTypeParser::parseArgsFromDecl(
|
||||
}
|
||||
|
||||
std::vector<Argument> ScriptTypeParser::parseReturnFromDecl(const Decl& decl) {
|
||||
// we represent no annoation on a return type as having no values in the
|
||||
// we represent no annotation on a return type as having no values in the
|
||||
// schema's return() list
|
||||
// in emitReturn we take the actual return value to be the value of the
|
||||
// return statement if no one was provided here
|
||||
|
@ -42,12 +42,12 @@ size_t StringCordView::find(const std::string& tok, size_t start) const {
|
||||
size_t offset = start;
|
||||
for (; begin != end_iter; ++begin, ++offset) {
|
||||
if (*begin == tok[0]) {
|
||||
auto mis = std::mismatch(begin, end_iter, tok.begin(), tok.end());
|
||||
if (mis.second == tok.end()) {
|
||||
auto mismatch = std::mismatch(begin, end_iter, tok.begin(), tok.end());
|
||||
if (mismatch.second == tok.end()) {
|
||||
// no mismatch, and second string (tok) is exhausted.
|
||||
return offset;
|
||||
}
|
||||
if (mis.first == end_iter) {
|
||||
if (mismatch.first == end_iter) {
|
||||
// this str is exhausted but tok is not
|
||||
return std::string::npos;
|
||||
}
|
||||
@ -312,7 +312,7 @@ void SourceRange::print_with_context(
|
||||
}
|
||||
out << "\n";
|
||||
}
|
||||
// print out inital context
|
||||
// print out initial context
|
||||
out << str.substr(begin_context, start() - begin_context);
|
||||
size_t line_start = start();
|
||||
size_t line_end = range_end;
|
||||
|
@ -118,7 +118,7 @@ struct TORCH_API SugaredValue
|
||||
|
||||
// If we are iterating over a Sugared Value and it returns a value from this
|
||||
// function, then we emit an unrolled loop over the variable. This allows us
|
||||
// to support containers of Heterogenous types, like Module Containers &
|
||||
// to support containers of Heterogeneous types, like Module Containers &
|
||||
// Tuples
|
||||
virtual std::optional<int64_t> staticLen() {
|
||||
return std::nullopt;
|
||||
@ -140,7 +140,7 @@ struct TORCH_API SugaredValue
|
||||
<< " object is not iterable");
|
||||
}
|
||||
|
||||
// expression for ith elemement for iterable value
|
||||
// expression for ith element for iterable value
|
||||
virtual std::shared_ptr<SugaredValue> getitem(
|
||||
const SourceRange& loc,
|
||||
GraphFunction& m,
|
||||
@ -297,7 +297,7 @@ struct TORCH_API SugaredTupleValue : public SugaredValue {
|
||||
return shared_from_this();
|
||||
}
|
||||
|
||||
// Because this is used to contain SugaredValues of Heterogenous types,
|
||||
// Because this is used to contain SugaredValues of Heterogeneous types,
|
||||
// we define staticLen() so that when this is iterated over it is emitted
|
||||
// as an unrolled loop.
|
||||
std::optional<int64_t> staticLen() override {
|
||||
@ -319,7 +319,7 @@ struct TORCH_API BuiltinModule : public SugaredValue {
|
||||
GraphFunction& m,
|
||||
const std::string& field) override {
|
||||
if (field == "autograd") {
|
||||
// When refering torch.autograd, it is also considered to be a
|
||||
// When referring torch.autograd, it is also considered to be a
|
||||
// BuiltinModule and we will dispatch to the aten operators for the
|
||||
// methods under its module.
|
||||
return std::make_shared<BuiltinModule>("aten", version);
|
||||
@ -331,12 +331,12 @@ struct TORCH_API BuiltinModule : public SugaredValue {
|
||||
|
||||
private:
|
||||
std::string name;
|
||||
// when we add operator versioning, emit this op as it exising at 'version'
|
||||
// when we add operator versioning, emit this op as it existing at 'version'
|
||||
// if not set, use the latest version
|
||||
std::optional<int64_t> version;
|
||||
};
|
||||
|
||||
// Represents a class, analagous to `int` or `dict`. Instances of classes,
|
||||
// Represents a class, analogous to `int` or `dict`. Instances of classes,
|
||||
// like `1` or `{"foo": 5}`, are represented as SimpleValues
|
||||
struct TORCH_API ClassValue : public SugaredValue {
|
||||
explicit ClassValue(ClassTypePtr type) : type_(std::move(type)) {}
|
||||
|
@ -557,7 +557,7 @@ void TracingState::setValue(const IValue& v, Value* value) {
|
||||
|
||||
// If the value comes from a CallFunction or CallMethod, it may not have
|
||||
// shape information attached. For debuggability, we enhance the type
|
||||
// information by assigning the concrete value's tupe to the jit::Value.
|
||||
// information by assigning the concrete value's type to the jit::Value.
|
||||
if (auto tensor_type = value->type()->cast<TensorType>()) {
|
||||
if (!tensor_type->isComplete()) {
|
||||
value->inferTypeFrom(var);
|
||||
|
@ -53,7 +53,7 @@ class MutableTypePtrHelper {
|
||||
// Tensor with shape information removed. For example, a Tensor
|
||||
// of dimension 4 would map to the same type as a Tensor of
|
||||
// dimension 1. This allows us to treat all subclasses of Tensor
|
||||
// as a single, homogenous "Tensor" type.
|
||||
// as a single, homogeneous "Tensor" type.
|
||||
std::optional<AliasTypeSet> mapTypeToAliasTypeSet(const TypePtr& type) {
|
||||
if (mutable_type_cache_) {
|
||||
const AliasTypeSet* result = mapTypeToBorrowedAliasTypeSet(type);
|
||||
|
@ -48,7 +48,7 @@ class ValueAndMemoryLocationSet;
|
||||
*
|
||||
* `descendFunctionCalls` - recursively analyze function and method calls
|
||||
* instead of conservative analysis. Generally analysis should be done after
|
||||
* inlining so the implmentation for recursive analysis is unoptimized.
|
||||
* inlining so the implementation for recursive analysis is unoptimized.
|
||||
*/
|
||||
class AliasDb {
|
||||
public:
|
||||
@ -102,7 +102,7 @@ class AliasDb {
|
||||
// Do any nodes write to an alias set output by `n`?
|
||||
TORCH_API bool hasOutputWriters(const Node* n) const;
|
||||
|
||||
// Do any nodes write to an alias set inputed/outputed by `n`?
|
||||
// Do any nodes write to an alias set inputted/outputted by `n`?
|
||||
TORCH_API bool hasWriters(const Node* n) const;
|
||||
|
||||
// Do any nodes write to `v`s memory location?
|
||||
@ -338,7 +338,7 @@ TORCH_API void Lint(const AliasDb* db);
|
||||
* * The AliasDb must not be mutated after construction of a
|
||||
* ValueAndMemoryLocationsSet, or else the MemoryLocations stored in the
|
||||
* ValueAndMemoryLocationSet will no longer be accurate.
|
||||
* * A ValueAndMemoryLocationsSet is tied to an instsance of AliasDb but
|
||||
* * A ValueAndMemoryLocationsSet is tied to an instance of AliasDb but
|
||||
* does not own the AliasDb. It is the user's responsibility to ensure
|
||||
* that the AliasDb outlives the ValuesAndMemoryLocationsSet.
|
||||
*
|
||||
|
@ -1143,7 +1143,7 @@ bool Node::isNondeterministic() const {
|
||||
if (!kind().is_aten()) {
|
||||
return false;
|
||||
}
|
||||
// All aten ops are expecte to have a schema. However this is left as a
|
||||
// All aten ops are expected to have a schema. However this is left as a
|
||||
// warning instead of an assert to ensure that previous use cases do not
|
||||
// break.
|
||||
if (!schema) {
|
||||
@ -1648,7 +1648,7 @@ Block* Node::findCommonAncestorBlockWith(Node* n) {
|
||||
n2 = n2->owningBlock()->owningNode();
|
||||
}
|
||||
|
||||
// Now they are the same numer of blocks from the graph block,
|
||||
// Now they are the same number of blocks from the graph block,
|
||||
// recurse upwards, checking if they are on the same block
|
||||
while (true) {
|
||||
if (n1->owningBlock() == n2->owningBlock()) {
|
||||
|
@ -616,7 +616,7 @@ struct TORCH_API Node {
|
||||
// as the equivalents phi-nodes in standard SSA form,
|
||||
// defining a new Value to represent any term that has multiple
|
||||
// definitions depending on how control flowed. Outputs of the node containing
|
||||
// control flow serve a similiar purpose defining new values for variables
|
||||
// control flow serve a similar purpose defining new values for variables
|
||||
// that would have different definitions depending on which way control
|
||||
// flowed.
|
||||
|
||||
@ -1374,7 +1374,7 @@ struct Graph : std::enable_shared_from_this<Graph> {
|
||||
// kwargs using Python argument matching rules, and checks that the op matches
|
||||
// a known schema.
|
||||
//
|
||||
// If this node successfully completes, it guarentees the node
|
||||
// If this node successfully completes, it guarantees the node
|
||||
// is a correctly-formed invocation of opname
|
||||
TORCH_API Value* insert(
|
||||
Symbol opname,
|
||||
|
@ -143,7 +143,7 @@ struct LoopView {
|
||||
private:
|
||||
Node* node_;
|
||||
|
||||
// adjust index_ordering by adding indices 0 - thorugh adjust, and
|
||||
// adjust index_ordering by adding indices 0 - thorough adjust, and
|
||||
// incrementing all existing inputs by adjust
|
||||
static std::vector<size_t> adjustIndices(
|
||||
size_t adjust,
|
||||
|
@ -13,7 +13,7 @@ struct Value;
|
||||
|
||||
// \brief Parse IR from \p STR constructing the corresponding IR in\ GRAPH.
|
||||
// if parse_tensor_constants is true will construct empty tensors
|
||||
// for Tensor constants with random or unitialized contents, otherwise will
|
||||
// for Tensor constants with random or uninitialized contents, otherwise will
|
||||
// throw
|
||||
TORCH_API void parseIR(
|
||||
const std::string& str,
|
||||
@ -25,7 +25,7 @@ TORCH_API void parseIR(
|
||||
* \p VMAP is filled with String to Value pairs allowing to index Values in the
|
||||
* newly created graph by their name in the original IR string.
|
||||
* if parse_tensor_constants is true will construct empty tensors
|
||||
* for Tensor constants with random or unitialized contents, otherwise will
|
||||
* for Tensor constants with random or uninitialized contents, otherwise will
|
||||
* throw
|
||||
*/
|
||||
TORCH_API void parseIR(
|
||||
|
@ -16,7 +16,7 @@ namespace torch::jit {
|
||||
namespace {
|
||||
|
||||
bool tensorEqual(const at::Tensor& lhs, const at::Tensor& rhs) {
|
||||
// type_equal doesnt distinguish between mkldnn/pytorch cpu tensors,
|
||||
// type_equal doesn't distinguish between mkldnn/pytorch cpu tensors,
|
||||
// and we dont want to coalesce mkldnn tensors bc they do layout
|
||||
// transformations based on usage
|
||||
if (lhs.is_mkldnn() || rhs.is_mkldnn()) {
|
||||
|
@ -208,7 +208,7 @@ struct TORCH_API InlinedCallStack : public c10::intrusive_ptr_target {
|
||||
};
|
||||
|
||||
// {source range, node name, InlinedCallStack}
|
||||
// We store node name because same debug infor will be used for
|
||||
// We store node name because same debug info will be used for
|
||||
// profiling as well, so we need to know op names as well.
|
||||
using DebugInfoTuple =
|
||||
std::tuple<SourceRange, std::string, InlinedCallStackPtr>;
|
||||
|
@ -11,7 +11,7 @@ namespace torch::jit {
|
||||
* \brief A structure describing a match of a pattern in a graph.
|
||||
*
|
||||
* The structure contains an anchor node, from which the match was found, and
|
||||
* match-maps for nodes and values. A match-map specifies the correspondance
|
||||
* match-maps for nodes and values. A match-map specifies the correspondence
|
||||
* between nodes in the pattern graph (match-map keys) with nodes in the actual
|
||||
* graph (match-map values). We keep such maps for both nodes and values.
|
||||
*/
|
||||
@ -38,7 +38,7 @@ struct Match {
|
||||
* graph are ignored during matching (IOW, we're essentially performing DCE on
|
||||
* the pattern).
|
||||
* - Pattern graph nodes cannot alias. TODO: the check not implemented yet.
|
||||
* - Aliasing nodes in the graph cannot consitute a match (i.e. through all
|
||||
* - Aliasing nodes in the graph cannot constitute a match (i.e. through all
|
||||
* found matches, no nodes in the subgraph alias with each other). TODO: check
|
||||
* not implemented yet.
|
||||
* - The matcher will not mutate either the pattern graph or the matched graph.
|
||||
|
@ -125,7 +125,7 @@ void write_archive_current(
|
||||
std::string fname = tensor_dir + tensor_names[i++];
|
||||
if (use_storage_context &&
|
||||
pre_serialized_files.find(fname) != pre_serialized_files.end()) {
|
||||
// storage has been serialzed already, skip
|
||||
// storage has been serialized already, skip
|
||||
continue;
|
||||
}
|
||||
writer.writeRecord(fname, writable_td.data(), writable_td.sizeInBytes());
|
||||
@ -230,7 +230,7 @@ std::stringstream update_bytecode_version(
|
||||
|
||||
How to add backport_v{i}_to_v{i-1} ?
|
||||
There are two options:
|
||||
1) [Format change only, recommended] Constrcut a reader with the
|
||||
1) [Format change only, recommended] Construct a reader with the
|
||||
input_model_stream, modify the file, and use PyTorchWriter to write it to
|
||||
output_model_stream. See backport_v5_to_v4.
|
||||
|
||||
@ -322,7 +322,7 @@ std::stringstream backport_v5_to_v4(std::stringstream& input_model_stream) {
|
||||
|
||||
// The export function to generate bytecode.pkl for version 4. After bytecode
|
||||
// version bump, the old export function doesn't exist anymore, so keep a copy
|
||||
// here for backport pupose.
|
||||
// here for backport purpose.
|
||||
auto writeArchiveV4 = [](PyTorchStreamWriter& writer,
|
||||
const std::string& archive_name,
|
||||
const c10::IValue& value) {
|
||||
@ -502,7 +502,7 @@ std::stringstream backport_v9_to_v8(std::stringstream& input_model_stream) {
|
||||
torch::jit::load(input_model_stream, std::nullopt, extra_files);
|
||||
std::stringstream intermediate_model_stream;
|
||||
// TODO(@pavithran) : Check if debug info is available and use load/save while
|
||||
// backporting hardcode debaug info to be false untill supported.
|
||||
// backporting hardcode debaug info to be false until supported.
|
||||
bool hasBytecodeDebug = false;
|
||||
{
|
||||
BytecodeEmitModeGuard argNumGuard(
|
||||
|
@ -393,7 +393,7 @@ ModelCompatCheckResult is_compatible(
|
||||
OperatorInfo runtime_op_info = runtime_info.operator_info.at(op_name);
|
||||
|
||||
// If the runtime op has no schema information its a false alarm and isn't
|
||||
// actually useable
|
||||
// actually usable
|
||||
if (!runtime_op_info.num_schema_args.has_value()) {
|
||||
result.status = ModelCompatibilityStatus::ERROR;
|
||||
std::ostringstream s;
|
||||
|
@ -76,7 +76,7 @@ std::pair<std::vector<StackEntry>, std::string> getStackTraceWithModuleHierarchy
|
||||
// This function construct stacktrace with module hierarchy
|
||||
// Module hierarchy will contain information about where in the
|
||||
// module hierarchy this source is. For example if conv2d op
|
||||
// exist in hierarcy A->B->C->Conv2d with type annotations of
|
||||
// exist in hierarchy A->B->C->Conv2d with type annotations of
|
||||
// A -> TopM, B->MyModule, C->SomeModule, then module hierarchy
|
||||
// will be TopM(A).MyModule(B).SomeModule(C).Conv2d(conv)
|
||||
// Source level stack information will be from model source code.
|
||||
|
@ -14,7 +14,7 @@ namespace torch::jit {
|
||||
* exception of BackendRuntimeException should raised using debug handles.
|
||||
* getSourceDebugString method is responsible for translating debug
|
||||
* handles to correspond debug information.
|
||||
* This debug informatin includes stack trace of model level source code and
|
||||
* This debug information includes stack trace of model level source code and
|
||||
* module hierarchy where the exception occurred.
|
||||
*/
|
||||
class MobileDebugTable {
|
||||
|
@ -48,7 +48,7 @@ using ExtraFilesMap = std::unordered_map<std::string, std::string>;
|
||||
// shared_ptr overload of this function.
|
||||
//
|
||||
// If should_copy_tensor_memory is true, then the returned module will NOT have
|
||||
// refences to `data`, so `data` can be freed immediately.
|
||||
// references to `data`, so `data` can be freed immediately.
|
||||
//
|
||||
// If should_copy_tensor_memory is false, then returned module will have tensors
|
||||
// that points inside of `data`; the caller will need to make sure that `data`
|
||||
@ -93,7 +93,7 @@ TORCH_API mobile::Module parse_and_initialize_mobile_module_for_jit(
|
||||
//
|
||||
// This function does steps 1+2+3 described above.
|
||||
//
|
||||
// We need to have this as a convienience because Python API will need to wrap
|
||||
// We need to have this as a convenience because Python API will need to wrap
|
||||
// this. C++ clients should use one of the versions of
|
||||
// parse_and_initialize_mobile_module() so they can manage the raw data more
|
||||
// directly.
|
||||
@ -110,7 +110,7 @@ TORCH_API mobile::ModuleInfo get_module_info_from_flatbuffer(
|
||||
char* flatbuffer_content);
|
||||
|
||||
// The methods below are less efficient because it need to read the stream in
|
||||
// its entirity to a buffer
|
||||
// its entirety to a buffer
|
||||
TORCH_API mobile::Module load_mobile_module_from_stream_with_copy(
|
||||
std::istream& in,
|
||||
std::optional<at::Device> device = std::nullopt,
|
||||
|
@ -105,7 +105,7 @@ std::unordered_map<std::string, std::string> MobileModelRunner::
|
||||
function_and_info_dict[key.toStringRef()] = data_list;
|
||||
}
|
||||
|
||||
// Could store the full mapping of std types, but the 'info' section isnt
|
||||
// Could store the full mapping of std types, but the 'info' section isn't
|
||||
// needed here
|
||||
std::string input_function =
|
||||
function_and_info_dict["get_inputs_function_name"][0];
|
||||
|
@ -38,7 +38,7 @@ class TORCH_API KinetoEdgeCPUProfiler {
|
||||
*
|
||||
* Thus, when KinetoEdgeCPUProfiler is used as RAII to do profiling
|
||||
* within certain scope. In that scope, the captured reference to
|
||||
* Module will outlive KinetoEdgeCPUProfiler. This is gauranteed because
|
||||
* Module will outlive KinetoEdgeCPUProfiler. This is guaranteed because
|
||||
* KinetoEdgeCPUProfiler must be constructed later than Module, on stack.
|
||||
*
|
||||
* An example of the anti-pattern and wrong usage is:
|
||||
|
@ -36,7 +36,7 @@ TypeParser::TypeParser(std::vector<std::string>& pythonStrs)
|
||||
// instruction. In nested type, the lowest level type will be at the beginning
|
||||
// of the type list. It is possible to parse it without worrying about
|
||||
// ordering, but it also introduces 1) extra cost to process nested type to
|
||||
// the correct order 2) lost the benifit that the instruction order is likely
|
||||
// the correct order 2) lost the benefit that the instruction order is likely
|
||||
// problematic if type list parsing fails.
|
||||
std::vector<TypePtr> TypeParser::parseList() {
|
||||
std::vector<TypePtr> typePtrs;
|
||||
|
@ -11,7 +11,7 @@ You can determine if your change in the operator is BC breaking, if it fails `te
|
||||
|
||||
### Some examples BC breaking changes
|
||||
|
||||
When making changes to the operators, the first thing to identify is if it's BC/FC breaking. Again, we only targetting for BC breaking changes on this guidance. Here are some examples to help understanding what a BC changes may look like:
|
||||
When making changes to the operators, the first thing to identify is if it's BC/FC breaking. Again, we only targeting for BC breaking changes on this guidance. Here are some examples to help understanding what a BC changes may look like:
|
||||
|
||||
#### Backward Compatibility Breakage:
|
||||
|
||||
@ -32,7 +32,7 @@ When making changes to the operators, the first thing to identify is if it's BC/
|
||||
|
||||
### 1.Preparation
|
||||
|
||||
[Build PyTorch from souce](https://github.com/pytorch/pytorch#from-source) and prepare a test model before making changes to the operator, following the process below. A test model before making the operator changes is needed to test the upgrader. Otherwise, after the change to operator, the new runtime will no longer be able to produce a model with the historic operator and can't test it anymore.
|
||||
[Build PyTorch from source](https://github.com/pytorch/pytorch#from-source) and prepare a test model before making changes to the operator, following the process below. A test model before making the operator changes is needed to test the upgrader. Otherwise, after the change to operator, the new runtime will no longer be able to produce a model with the historic operator and can't test it anymore.
|
||||
|
||||
1. Add a test module in `test/jit/fixtures_srcs/fixtures_src.py`. In `test/jit/fixtures_srcs/generate_models.py`,
|
||||
```
|
||||
|
Reference in New Issue
Block a user