diff --git a/_static/pygments.css b/_static/pygments.css index de7af262ffb..20c4814dcf0 100644 --- a/_static/pygments.css +++ b/_static/pygments.css @@ -1,10 +1,5 @@ -pre { line-height: 125%; } -td.linenos pre { color: #000000; background-color: #f0f0f0; padding-left: 5px; padding-right: 5px; } -span.linenos { color: #000000; background-color: #f0f0f0; padding-left: 5px; padding-right: 5px; } -td.linenos pre.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } -span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } .highlight .hll { background-color: #ffffcc } -.highlight { background: #eeffcc; } +.highlight { background: #eeffcc; } .highlight .c { color: #408090; font-style: italic } /* Comment */ .highlight .err { border: 1px solid #FF0000 } /* Error */ .highlight .k { color: #007020; font-weight: bold } /* Keyword */ diff --git a/deepsparse/.buildinfo b/deepsparse/.buildinfo index 3b04e9d0c59..be20e0084e9 100644 --- a/deepsparse/.buildinfo +++ b/deepsparse/.buildinfo @@ -1,4 +1,4 @@ # Sphinx build info version 1 # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. -config: c0e84c5bd7f1ae1547decebf78328f3b +config: 09cf2dae090a5215faeb91fd805fe11e tags: 645f666f9bcd5a90fca523b33c5a78b7 diff --git a/deepsparse/_static/doctools.js b/deepsparse/_static/doctools.js index 144884ea651..61ac9d266f9 100644 --- a/deepsparse/_static/doctools.js +++ b/deepsparse/_static/doctools.js @@ -29,9 +29,14 @@ if (!window.console || !console.firebug) { /** * small helper function to urldecode strings + * + * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent#Decoding_query_parameters_from_a_URL */ jQuery.urldecode = function(x) { - return decodeURIComponent(x).replace(/\+/g, ' '); + if (!x) { + return x + } + return decodeURIComponent(x.replace(/\+/g, ' ')); }; /** diff --git a/deepsparse/_static/language_data.js b/deepsparse/_static/language_data.js index 0e7dc7e9ef0..863704b310d 100644 --- a/deepsparse/_static/language_data.js +++ b/deepsparse/_static/language_data.js @@ -13,7 +13,8 @@ var stopwords = ["a","and","are","as","at","be","but","by","for","if","in","into","is","it","near","no","not","of","on","or","such","that","the","their","then","there","these","they","this","to","was","will","with"]; -/* Non-minified version JS is _stemmer.js if file is provided */ +/* Non-minified version is copied as a separate JS file, is available */ + /** * Porter Stemmer */ @@ -199,7 +200,6 @@ var Stemmer = function() { - var splitChars = (function() { var result = {}; var singles = [96, 180, 187, 191, 215, 247, 749, 885, 903, 907, 909, 930, 1014, 1648, diff --git a/deepsparse/_static/pygments.css b/deepsparse/_static/pygments.css index de7af262ffb..691aeb82d00 100644 --- a/deepsparse/_static/pygments.css +++ b/deepsparse/_static/pygments.css @@ -1,7 +1,7 @@ pre { line-height: 125%; } -td.linenos pre { color: #000000; background-color: #f0f0f0; padding-left: 5px; padding-right: 5px; } -span.linenos { color: #000000; background-color: #f0f0f0; padding-left: 5px; padding-right: 5px; } -td.linenos pre.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } +td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } +span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } +td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } .highlight .hll { background-color: #ffffcc } .highlight { background: #eeffcc; } diff --git a/deepsparse/_static/searchtools.js b/deepsparse/_static/searchtools.js index 6fc9e7f3338..1a90152eb0e 100644 --- a/deepsparse/_static/searchtools.js +++ b/deepsparse/_static/searchtools.js @@ -248,7 +248,7 @@ var Search = { // results left, load the summary and display it if (results.length) { var item = results.pop(); - var listItem = $('
  • '); + var listItem = $('
  • '); var requestUrl = ""; var linkUrl = ""; if (DOCUMENTATION_OPTIONS.BUILDER === 'dirhtml') { @@ -273,9 +273,9 @@ var Search = { if (item[3]) { listItem.append($(' (' + item[3] + ')')); Search.output.append(listItem); - listItem.slideDown(5, function() { + setTimeout(function() { displayNextItem(); - }); + }, 5); } else if (DOCUMENTATION_OPTIONS.HAS_SOURCE) { $.ajax({url: requestUrl, dataType: "text", @@ -285,16 +285,16 @@ var Search = { listItem.append(Search.makeSearchSummary(data, searchterms, hlterms)); } Search.output.append(listItem); - listItem.slideDown(5, function() { + setTimeout(function() { displayNextItem(); - }); + }, 5); }}); } else { // no source available, just display title Search.output.append(listItem); - listItem.slideDown(5, function() { + setTimeout(function() { displayNextItem(); - }); + }, 5); } } // search finished, update title and status message @@ -379,6 +379,13 @@ var Search = { return results; }, + /** + * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions + */ + escapeRegExp : function(string) { + return string.replace(/[.*+\-?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string + }, + /** * search for full-text terms in the index */ @@ -402,13 +409,14 @@ var Search = { ]; // add support for partial matches if (word.length > 2) { + var word_regex = this.escapeRegExp(word); for (var w in terms) { - if (w.match(word) && !terms[word]) { + if (w.match(word_regex) && !terms[word]) { _o.push({files: terms[w], score: Scorer.partialTerm}) } } for (var w in titleterms) { - if (w.match(word) && !titleterms[word]) { + if (w.match(word_regex) && !titleterms[word]) { _o.push({files: titleterms[w], score: Scorer.partialTitle}) } } diff --git a/deepsparse/_static/underscore-1.12.0.js b/deepsparse/_static/underscore-1.12.0.js new file mode 100644 index 00000000000..3af6352e613 --- /dev/null +++ b/deepsparse/_static/underscore-1.12.0.js @@ -0,0 +1,2027 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : + typeof define === 'function' && define.amd ? define('underscore', factory) : + (global = global || self, (function () { + var current = global._; + var exports = global._ = factory(); + exports.noConflict = function () { global._ = current; return exports; }; + }())); +}(this, (function () { + // Underscore.js 1.12.0 + // https://underscorejs.org + // (c) 2009-2020 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors + // Underscore may be freely distributed under the MIT license. + + // Current version. + var VERSION = '1.12.0'; + + // Establish the root object, `window` (`self`) in the browser, `global` + // on the server, or `this` in some virtual machines. We use `self` + // instead of `window` for `WebWorker` support. + var root = typeof self == 'object' && self.self === self && self || + typeof global == 'object' && global.global === global && global || + Function('return this')() || + {}; + + // Save bytes in the minified (but not gzipped) version: + var ArrayProto = Array.prototype, ObjProto = Object.prototype; + var SymbolProto = typeof Symbol !== 'undefined' ? Symbol.prototype : null; + + // Create quick reference variables for speed access to core prototypes. + var push = ArrayProto.push, + slice = ArrayProto.slice, + toString = ObjProto.toString, + hasOwnProperty = ObjProto.hasOwnProperty; + + // Modern feature detection. + var supportsArrayBuffer = typeof ArrayBuffer !== 'undefined', + supportsDataView = typeof DataView !== 'undefined'; + + // All **ECMAScript 5+** native function implementations that we hope to use + // are declared here. + var nativeIsArray = Array.isArray, + nativeKeys = Object.keys, + nativeCreate = Object.create, + nativeIsView = supportsArrayBuffer && ArrayBuffer.isView; + + // Create references to these builtin functions because we override them. + var _isNaN = isNaN, + _isFinite = isFinite; + + // Keys in IE < 9 that won't be iterated by `for key in ...` and thus missed. + var hasEnumBug = !{toString: null}.propertyIsEnumerable('toString'); + var nonEnumerableProps = ['valueOf', 'isPrototypeOf', 'toString', + 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString']; + + // The largest integer that can be represented exactly. + var MAX_ARRAY_INDEX = Math.pow(2, 53) - 1; + + // Some functions take a variable number of arguments, or a few expected + // arguments at the beginning and then a variable number of values to operate + // on. This helper accumulates all remaining arguments past the function’s + // argument length (or an explicit `startIndex`), into an array that becomes + // the last argument. Similar to ES6’s "rest parameter". + function restArguments(func, startIndex) { + startIndex = startIndex == null ? func.length - 1 : +startIndex; + return function() { + var length = Math.max(arguments.length - startIndex, 0), + rest = Array(length), + index = 0; + for (; index < length; index++) { + rest[index] = arguments[index + startIndex]; + } + switch (startIndex) { + case 0: return func.call(this, rest); + case 1: return func.call(this, arguments[0], rest); + case 2: return func.call(this, arguments[0], arguments[1], rest); + } + var args = Array(startIndex + 1); + for (index = 0; index < startIndex; index++) { + args[index] = arguments[index]; + } + args[startIndex] = rest; + return func.apply(this, args); + }; + } + + // Is a given variable an object? + function isObject(obj) { + var type = typeof obj; + return type === 'function' || type === 'object' && !!obj; + } + + // Is a given value equal to null? + function isNull(obj) { + return obj === null; + } + + // Is a given variable undefined? + function isUndefined(obj) { + return obj === void 0; + } + + // Is a given value a boolean? + function isBoolean(obj) { + return obj === true || obj === false || toString.call(obj) === '[object Boolean]'; + } + + // Is a given value a DOM element? + function isElement(obj) { + return !!(obj && obj.nodeType === 1); + } + + // Internal function for creating a `toString`-based type tester. + function tagTester(name) { + var tag = '[object ' + name + ']'; + return function(obj) { + return toString.call(obj) === tag; + }; + } + + var isString = tagTester('String'); + + var isNumber = tagTester('Number'); + + var isDate = tagTester('Date'); + + var isRegExp = tagTester('RegExp'); + + var isError = tagTester('Error'); + + var isSymbol = tagTester('Symbol'); + + var isArrayBuffer = tagTester('ArrayBuffer'); + + var isFunction = tagTester('Function'); + + // Optimize `isFunction` if appropriate. Work around some `typeof` bugs in old + // v8, IE 11 (#1621), Safari 8 (#1929), and PhantomJS (#2236). + var nodelist = root.document && root.document.childNodes; + if (typeof /./ != 'function' && typeof Int8Array != 'object' && typeof nodelist != 'function') { + isFunction = function(obj) { + return typeof obj == 'function' || false; + }; + } + + var isFunction$1 = isFunction; + + var hasObjectTag = tagTester('Object'); + + // In IE 10 - Edge 13, `DataView` has string tag `'[object Object]'`. + // In IE 11, the most common among them, this problem also applies to + // `Map`, `WeakMap` and `Set`. + var hasStringTagBug = ( + supportsDataView && hasObjectTag(new DataView(new ArrayBuffer(8))) + ), + isIE11 = (typeof Map !== 'undefined' && hasObjectTag(new Map)); + + var isDataView = tagTester('DataView'); + + // In IE 10 - Edge 13, we need a different heuristic + // to determine whether an object is a `DataView`. + function ie10IsDataView(obj) { + return obj != null && isFunction$1(obj.getInt8) && isArrayBuffer(obj.buffer); + } + + var isDataView$1 = (hasStringTagBug ? ie10IsDataView : isDataView); + + // Is a given value an array? + // Delegates to ECMA5's native `Array.isArray`. + var isArray = nativeIsArray || tagTester('Array'); + + // Internal function to check whether `key` is an own property name of `obj`. + function has(obj, key) { + return obj != null && hasOwnProperty.call(obj, key); + } + + var isArguments = tagTester('Arguments'); + + // Define a fallback version of the method in browsers (ahem, IE < 9), where + // there isn't any inspectable "Arguments" type. + (function() { + if (!isArguments(arguments)) { + isArguments = function(obj) { + return has(obj, 'callee'); + }; + } + }()); + + var isArguments$1 = isArguments; + + // Is a given object a finite number? + function isFinite$1(obj) { + return !isSymbol(obj) && _isFinite(obj) && !isNaN(parseFloat(obj)); + } + + // Is the given value `NaN`? + function isNaN$1(obj) { + return isNumber(obj) && _isNaN(obj); + } + + // Predicate-generating function. Often useful outside of Underscore. + function constant(value) { + return function() { + return value; + }; + } + + // Common internal logic for `isArrayLike` and `isBufferLike`. + function createSizePropertyCheck(getSizeProperty) { + return function(collection) { + var sizeProperty = getSizeProperty(collection); + return typeof sizeProperty == 'number' && sizeProperty >= 0 && sizeProperty <= MAX_ARRAY_INDEX; + } + } + + // Internal helper to generate a function to obtain property `key` from `obj`. + function shallowProperty(key) { + return function(obj) { + return obj == null ? void 0 : obj[key]; + }; + } + + // Internal helper to obtain the `byteLength` property of an object. + var getByteLength = shallowProperty('byteLength'); + + // Internal helper to determine whether we should spend extensive checks against + // `ArrayBuffer` et al. + var isBufferLike = createSizePropertyCheck(getByteLength); + + // Is a given value a typed array? + var typedArrayPattern = /\[object ((I|Ui)nt(8|16|32)|Float(32|64)|Uint8Clamped|Big(I|Ui)nt64)Array\]/; + function isTypedArray(obj) { + // `ArrayBuffer.isView` is the most future-proof, so use it when available. + // Otherwise, fall back on the above regular expression. + return nativeIsView ? (nativeIsView(obj) && !isDataView$1(obj)) : + isBufferLike(obj) && typedArrayPattern.test(toString.call(obj)); + } + + var isTypedArray$1 = supportsArrayBuffer ? isTypedArray : constant(false); + + // Internal helper to obtain the `length` property of an object. + var getLength = shallowProperty('length'); + + // Internal helper to create a simple lookup structure. + // `collectNonEnumProps` used to depend on `_.contains`, but this led to + // circular imports. `emulatedSet` is a one-off solution that only works for + // arrays of strings. + function emulatedSet(keys) { + var hash = {}; + for (var l = keys.length, i = 0; i < l; ++i) hash[keys[i]] = true; + return { + contains: function(key) { return hash[key]; }, + push: function(key) { + hash[key] = true; + return keys.push(key); + } + }; + } + + // Internal helper. Checks `keys` for the presence of keys in IE < 9 that won't + // be iterated by `for key in ...` and thus missed. Extends `keys` in place if + // needed. + function collectNonEnumProps(obj, keys) { + keys = emulatedSet(keys); + var nonEnumIdx = nonEnumerableProps.length; + var constructor = obj.constructor; + var proto = isFunction$1(constructor) && constructor.prototype || ObjProto; + + // Constructor is a special case. + var prop = 'constructor'; + if (has(obj, prop) && !keys.contains(prop)) keys.push(prop); + + while (nonEnumIdx--) { + prop = nonEnumerableProps[nonEnumIdx]; + if (prop in obj && obj[prop] !== proto[prop] && !keys.contains(prop)) { + keys.push(prop); + } + } + } + + // Retrieve the names of an object's own properties. + // Delegates to **ECMAScript 5**'s native `Object.keys`. + function keys(obj) { + if (!isObject(obj)) return []; + if (nativeKeys) return nativeKeys(obj); + var keys = []; + for (var key in obj) if (has(obj, key)) keys.push(key); + // Ahem, IE < 9. + if (hasEnumBug) collectNonEnumProps(obj, keys); + return keys; + } + + // Is a given array, string, or object empty? + // An "empty" object has no enumerable own-properties. + function isEmpty(obj) { + if (obj == null) return true; + // Skip the more expensive `toString`-based type checks if `obj` has no + // `.length`. + var length = getLength(obj); + if (typeof length == 'number' && ( + isArray(obj) || isString(obj) || isArguments$1(obj) + )) return length === 0; + return getLength(keys(obj)) === 0; + } + + // Returns whether an object has a given set of `key:value` pairs. + function isMatch(object, attrs) { + var _keys = keys(attrs), length = _keys.length; + if (object == null) return !length; + var obj = Object(object); + for (var i = 0; i < length; i++) { + var key = _keys[i]; + if (attrs[key] !== obj[key] || !(key in obj)) return false; + } + return true; + } + + // If Underscore is called as a function, it returns a wrapped object that can + // be used OO-style. This wrapper holds altered versions of all functions added + // through `_.mixin`. Wrapped objects may be chained. + function _(obj) { + if (obj instanceof _) return obj; + if (!(this instanceof _)) return new _(obj); + this._wrapped = obj; + } + + _.VERSION = VERSION; + + // Extracts the result from a wrapped and chained object. + _.prototype.value = function() { + return this._wrapped; + }; + + // Provide unwrapping proxies for some methods used in engine operations + // such as arithmetic and JSON stringification. + _.prototype.valueOf = _.prototype.toJSON = _.prototype.value; + + _.prototype.toString = function() { + return String(this._wrapped); + }; + + // Internal function to wrap or shallow-copy an ArrayBuffer, + // typed array or DataView to a new view, reusing the buffer. + function toBufferView(bufferSource) { + return new Uint8Array( + bufferSource.buffer || bufferSource, + bufferSource.byteOffset || 0, + getByteLength(bufferSource) + ); + } + + // We use this string twice, so give it a name for minification. + var tagDataView = '[object DataView]'; + + // Internal recursive comparison function for `_.isEqual`. + function eq(a, b, aStack, bStack) { + // Identical objects are equal. `0 === -0`, but they aren't identical. + // See the [Harmony `egal` proposal](https://wiki.ecmascript.org/doku.php?id=harmony:egal). + if (a === b) return a !== 0 || 1 / a === 1 / b; + // `null` or `undefined` only equal to itself (strict comparison). + if (a == null || b == null) return false; + // `NaN`s are equivalent, but non-reflexive. + if (a !== a) return b !== b; + // Exhaust primitive checks + var type = typeof a; + if (type !== 'function' && type !== 'object' && typeof b != 'object') return false; + return deepEq(a, b, aStack, bStack); + } + + // Internal recursive comparison function for `_.isEqual`. + function deepEq(a, b, aStack, bStack) { + // Unwrap any wrapped objects. + if (a instanceof _) a = a._wrapped; + if (b instanceof _) b = b._wrapped; + // Compare `[[Class]]` names. + var className = toString.call(a); + if (className !== toString.call(b)) return false; + // Work around a bug in IE 10 - Edge 13. + if (hasStringTagBug && className == '[object Object]' && isDataView$1(a)) { + if (!isDataView$1(b)) return false; + className = tagDataView; + } + switch (className) { + // These types are compared by value. + case '[object RegExp]': + // RegExps are coerced to strings for comparison (Note: '' + /a/i === '/a/i') + case '[object String]': + // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is + // equivalent to `new String("5")`. + return '' + a === '' + b; + case '[object Number]': + // `NaN`s are equivalent, but non-reflexive. + // Object(NaN) is equivalent to NaN. + if (+a !== +a) return +b !== +b; + // An `egal` comparison is performed for other numeric values. + return +a === 0 ? 1 / +a === 1 / b : +a === +b; + case '[object Date]': + case '[object Boolean]': + // Coerce dates and booleans to numeric primitive values. Dates are compared by their + // millisecond representations. Note that invalid dates with millisecond representations + // of `NaN` are not equivalent. + return +a === +b; + case '[object Symbol]': + return SymbolProto.valueOf.call(a) === SymbolProto.valueOf.call(b); + case '[object ArrayBuffer]': + case tagDataView: + // Coerce to typed array so we can fall through. + return deepEq(toBufferView(a), toBufferView(b), aStack, bStack); + } + + var areArrays = className === '[object Array]'; + if (!areArrays && isTypedArray$1(a)) { + var byteLength = getByteLength(a); + if (byteLength !== getByteLength(b)) return false; + if (a.buffer === b.buffer && a.byteOffset === b.byteOffset) return true; + areArrays = true; + } + if (!areArrays) { + if (typeof a != 'object' || typeof b != 'object') return false; + + // Objects with different constructors are not equivalent, but `Object`s or `Array`s + // from different frames are. + var aCtor = a.constructor, bCtor = b.constructor; + if (aCtor !== bCtor && !(isFunction$1(aCtor) && aCtor instanceof aCtor && + isFunction$1(bCtor) && bCtor instanceof bCtor) + && ('constructor' in a && 'constructor' in b)) { + return false; + } + } + // Assume equality for cyclic structures. The algorithm for detecting cyclic + // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`. + + // Initializing stack of traversed objects. + // It's done here since we only need them for objects and arrays comparison. + aStack = aStack || []; + bStack = bStack || []; + var length = aStack.length; + while (length--) { + // Linear search. Performance is inversely proportional to the number of + // unique nested structures. + if (aStack[length] === a) return bStack[length] === b; + } + + // Add the first object to the stack of traversed objects. + aStack.push(a); + bStack.push(b); + + // Recursively compare objects and arrays. + if (areArrays) { + // Compare array lengths to determine if a deep comparison is necessary. + length = a.length; + if (length !== b.length) return false; + // Deep compare the contents, ignoring non-numeric properties. + while (length--) { + if (!eq(a[length], b[length], aStack, bStack)) return false; + } + } else { + // Deep compare objects. + var _keys = keys(a), key; + length = _keys.length; + // Ensure that both objects contain the same number of properties before comparing deep equality. + if (keys(b).length !== length) return false; + while (length--) { + // Deep compare each member + key = _keys[length]; + if (!(has(b, key) && eq(a[key], b[key], aStack, bStack))) return false; + } + } + // Remove the first object from the stack of traversed objects. + aStack.pop(); + bStack.pop(); + return true; + } + + // Perform a deep comparison to check if two objects are equal. + function isEqual(a, b) { + return eq(a, b); + } + + // Retrieve all the enumerable property names of an object. + function allKeys(obj) { + if (!isObject(obj)) return []; + var keys = []; + for (var key in obj) keys.push(key); + // Ahem, IE < 9. + if (hasEnumBug) collectNonEnumProps(obj, keys); + return keys; + } + + // Since the regular `Object.prototype.toString` type tests don't work for + // some types in IE 11, we use a fingerprinting heuristic instead, based + // on the methods. It's not great, but it's the best we got. + // The fingerprint method lists are defined below. + function ie11fingerprint(methods) { + var length = getLength(methods); + return function(obj) { + if (obj == null) return false; + // `Map`, `WeakMap` and `Set` have no enumerable keys. + var keys = allKeys(obj); + if (getLength(keys)) return false; + for (var i = 0; i < length; i++) { + if (!isFunction$1(obj[methods[i]])) return false; + } + // If we are testing against `WeakMap`, we need to ensure that + // `obj` doesn't have a `forEach` method in order to distinguish + // it from a regular `Map`. + return methods !== weakMapMethods || !isFunction$1(obj[forEachName]); + }; + } + + // In the interest of compact minification, we write + // each string in the fingerprints only once. + var forEachName = 'forEach', + hasName = 'has', + commonInit = ['clear', 'delete'], + mapTail = ['get', hasName, 'set']; + + // `Map`, `WeakMap` and `Set` each have slightly different + // combinations of the above sublists. + var mapMethods = commonInit.concat(forEachName, mapTail), + weakMapMethods = commonInit.concat(mapTail), + setMethods = ['add'].concat(commonInit, forEachName, hasName); + + var isMap = isIE11 ? ie11fingerprint(mapMethods) : tagTester('Map'); + + var isWeakMap = isIE11 ? ie11fingerprint(weakMapMethods) : tagTester('WeakMap'); + + var isSet = isIE11 ? ie11fingerprint(setMethods) : tagTester('Set'); + + var isWeakSet = tagTester('WeakSet'); + + // Retrieve the values of an object's properties. + function values(obj) { + var _keys = keys(obj); + var length = _keys.length; + var values = Array(length); + for (var i = 0; i < length; i++) { + values[i] = obj[_keys[i]]; + } + return values; + } + + // Convert an object into a list of `[key, value]` pairs. + // The opposite of `_.object` with one argument. + function pairs(obj) { + var _keys = keys(obj); + var length = _keys.length; + var pairs = Array(length); + for (var i = 0; i < length; i++) { + pairs[i] = [_keys[i], obj[_keys[i]]]; + } + return pairs; + } + + // Invert the keys and values of an object. The values must be serializable. + function invert(obj) { + var result = {}; + var _keys = keys(obj); + for (var i = 0, length = _keys.length; i < length; i++) { + result[obj[_keys[i]]] = _keys[i]; + } + return result; + } + + // Return a sorted list of the function names available on the object. + function functions(obj) { + var names = []; + for (var key in obj) { + if (isFunction$1(obj[key])) names.push(key); + } + return names.sort(); + } + + // An internal function for creating assigner functions. + function createAssigner(keysFunc, defaults) { + return function(obj) { + var length = arguments.length; + if (defaults) obj = Object(obj); + if (length < 2 || obj == null) return obj; + for (var index = 1; index < length; index++) { + var source = arguments[index], + keys = keysFunc(source), + l = keys.length; + for (var i = 0; i < l; i++) { + var key = keys[i]; + if (!defaults || obj[key] === void 0) obj[key] = source[key]; + } + } + return obj; + }; + } + + // Extend a given object with all the properties in passed-in object(s). + var extend = createAssigner(allKeys); + + // Assigns a given object with all the own properties in the passed-in + // object(s). + // (https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) + var extendOwn = createAssigner(keys); + + // Fill in a given object with default properties. + var defaults = createAssigner(allKeys, true); + + // Create a naked function reference for surrogate-prototype-swapping. + function ctor() { + return function(){}; + } + + // An internal function for creating a new object that inherits from another. + function baseCreate(prototype) { + if (!isObject(prototype)) return {}; + if (nativeCreate) return nativeCreate(prototype); + var Ctor = ctor(); + Ctor.prototype = prototype; + var result = new Ctor; + Ctor.prototype = null; + return result; + } + + // Creates an object that inherits from the given prototype object. + // If additional properties are provided then they will be added to the + // created object. + function create(prototype, props) { + var result = baseCreate(prototype); + if (props) extendOwn(result, props); + return result; + } + + // Create a (shallow-cloned) duplicate of an object. + function clone(obj) { + if (!isObject(obj)) return obj; + return isArray(obj) ? obj.slice() : extend({}, obj); + } + + // Invokes `interceptor` with the `obj` and then returns `obj`. + // The primary purpose of this method is to "tap into" a method chain, in + // order to perform operations on intermediate results within the chain. + function tap(obj, interceptor) { + interceptor(obj); + return obj; + } + + // Normalize a (deep) property `path` to array. + // Like `_.iteratee`, this function can be customized. + function toPath(path) { + return isArray(path) ? path : [path]; + } + _.toPath = toPath; + + // Internal wrapper for `_.toPath` to enable minification. + // Similar to `cb` for `_.iteratee`. + function toPath$1(path) { + return _.toPath(path); + } + + // Internal function to obtain a nested property in `obj` along `path`. + function deepGet(obj, path) { + var length = path.length; + for (var i = 0; i < length; i++) { + if (obj == null) return void 0; + obj = obj[path[i]]; + } + return length ? obj : void 0; + } + + // Get the value of the (deep) property on `path` from `object`. + // If any property in `path` does not exist or if the value is + // `undefined`, return `defaultValue` instead. + // The `path` is normalized through `_.toPath`. + function get(object, path, defaultValue) { + var value = deepGet(object, toPath$1(path)); + return isUndefined(value) ? defaultValue : value; + } + + // Shortcut function for checking if an object has a given property directly on + // itself (in other words, not on a prototype). Unlike the internal `has` + // function, this public version can also traverse nested properties. + function has$1(obj, path) { + path = toPath$1(path); + var length = path.length; + for (var i = 0; i < length; i++) { + var key = path[i]; + if (!has(obj, key)) return false; + obj = obj[key]; + } + return !!length; + } + + // Keep the identity function around for default iteratees. + function identity(value) { + return value; + } + + // Returns a predicate for checking whether an object has a given set of + // `key:value` pairs. + function matcher(attrs) { + attrs = extendOwn({}, attrs); + return function(obj) { + return isMatch(obj, attrs); + }; + } + + // Creates a function that, when passed an object, will traverse that object’s + // properties down the given `path`, specified as an array of keys or indices. + function property(path) { + path = toPath$1(path); + return function(obj) { + return deepGet(obj, path); + }; + } + + // Internal function that returns an efficient (for current engines) version + // of the passed-in callback, to be repeatedly applied in other Underscore + // functions. + function optimizeCb(func, context, argCount) { + if (context === void 0) return func; + switch (argCount == null ? 3 : argCount) { + case 1: return function(value) { + return func.call(context, value); + }; + // The 2-argument case is omitted because we’re not using it. + case 3: return function(value, index, collection) { + return func.call(context, value, index, collection); + }; + case 4: return function(accumulator, value, index, collection) { + return func.call(context, accumulator, value, index, collection); + }; + } + return function() { + return func.apply(context, arguments); + }; + } + + // An internal function to generate callbacks that can be applied to each + // element in a collection, returning the desired result — either `_.identity`, + // an arbitrary callback, a property matcher, or a property accessor. + function baseIteratee(value, context, argCount) { + if (value == null) return identity; + if (isFunction$1(value)) return optimizeCb(value, context, argCount); + if (isObject(value) && !isArray(value)) return matcher(value); + return property(value); + } + + // External wrapper for our callback generator. Users may customize + // `_.iteratee` if they want additional predicate/iteratee shorthand styles. + // This abstraction hides the internal-only `argCount` argument. + function iteratee(value, context) { + return baseIteratee(value, context, Infinity); + } + _.iteratee = iteratee; + + // The function we call internally to generate a callback. It invokes + // `_.iteratee` if overridden, otherwise `baseIteratee`. + function cb(value, context, argCount) { + if (_.iteratee !== iteratee) return _.iteratee(value, context); + return baseIteratee(value, context, argCount); + } + + // Returns the results of applying the `iteratee` to each element of `obj`. + // In contrast to `_.map` it returns an object. + function mapObject(obj, iteratee, context) { + iteratee = cb(iteratee, context); + var _keys = keys(obj), + length = _keys.length, + results = {}; + for (var index = 0; index < length; index++) { + var currentKey = _keys[index]; + results[currentKey] = iteratee(obj[currentKey], currentKey, obj); + } + return results; + } + + // Predicate-generating function. Often useful outside of Underscore. + function noop(){} + + // Generates a function for a given object that returns a given property. + function propertyOf(obj) { + if (obj == null) return noop; + return function(path) { + return get(obj, path); + }; + } + + // Run a function **n** times. + function times(n, iteratee, context) { + var accum = Array(Math.max(0, n)); + iteratee = optimizeCb(iteratee, context, 1); + for (var i = 0; i < n; i++) accum[i] = iteratee(i); + return accum; + } + + // Return a random integer between `min` and `max` (inclusive). + function random(min, max) { + if (max == null) { + max = min; + min = 0; + } + return min + Math.floor(Math.random() * (max - min + 1)); + } + + // A (possibly faster) way to get the current timestamp as an integer. + var now = Date.now || function() { + return new Date().getTime(); + }; + + // Internal helper to generate functions for escaping and unescaping strings + // to/from HTML interpolation. + function createEscaper(map) { + var escaper = function(match) { + return map[match]; + }; + // Regexes for identifying a key that needs to be escaped. + var source = '(?:' + keys(map).join('|') + ')'; + var testRegexp = RegExp(source); + var replaceRegexp = RegExp(source, 'g'); + return function(string) { + string = string == null ? '' : '' + string; + return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string; + }; + } + + // Internal list of HTML entities for escaping. + var escapeMap = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + "'": ''', + '`': '`' + }; + + // Function for escaping strings to HTML interpolation. + var _escape = createEscaper(escapeMap); + + // Internal list of HTML entities for unescaping. + var unescapeMap = invert(escapeMap); + + // Function for unescaping strings from HTML interpolation. + var _unescape = createEscaper(unescapeMap); + + // By default, Underscore uses ERB-style template delimiters. Change the + // following template settings to use alternative delimiters. + var templateSettings = _.templateSettings = { + evaluate: /<%([\s\S]+?)%>/g, + interpolate: /<%=([\s\S]+?)%>/g, + escape: /<%-([\s\S]+?)%>/g + }; + + // When customizing `_.templateSettings`, if you don't want to define an + // interpolation, evaluation or escaping regex, we need one that is + // guaranteed not to match. + var noMatch = /(.)^/; + + // Certain characters need to be escaped so that they can be put into a + // string literal. + var escapes = { + "'": "'", + '\\': '\\', + '\r': 'r', + '\n': 'n', + '\u2028': 'u2028', + '\u2029': 'u2029' + }; + + var escapeRegExp = /\\|'|\r|\n|\u2028|\u2029/g; + + function escapeChar(match) { + return '\\' + escapes[match]; + } + + // JavaScript micro-templating, similar to John Resig's implementation. + // Underscore templating handles arbitrary delimiters, preserves whitespace, + // and correctly escapes quotes within interpolated code. + // NB: `oldSettings` only exists for backwards compatibility. + function template(text, settings, oldSettings) { + if (!settings && oldSettings) settings = oldSettings; + settings = defaults({}, settings, _.templateSettings); + + // Combine delimiters into one regular expression via alternation. + var matcher = RegExp([ + (settings.escape || noMatch).source, + (settings.interpolate || noMatch).source, + (settings.evaluate || noMatch).source + ].join('|') + '|$', 'g'); + + // Compile the template source, escaping string literals appropriately. + var index = 0; + var source = "__p+='"; + text.replace(matcher, function(match, escape, interpolate, evaluate, offset) { + source += text.slice(index, offset).replace(escapeRegExp, escapeChar); + index = offset + match.length; + + if (escape) { + source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'"; + } else if (interpolate) { + source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'"; + } else if (evaluate) { + source += "';\n" + evaluate + "\n__p+='"; + } + + // Adobe VMs need the match returned to produce the correct offset. + return match; + }); + source += "';\n"; + + // If a variable is not specified, place data values in local scope. + if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n'; + + source = "var __t,__p='',__j=Array.prototype.join," + + "print=function(){__p+=__j.call(arguments,'');};\n" + + source + 'return __p;\n'; + + var render; + try { + render = new Function(settings.variable || 'obj', '_', source); + } catch (e) { + e.source = source; + throw e; + } + + var template = function(data) { + return render.call(this, data, _); + }; + + // Provide the compiled source as a convenience for precompilation. + var argument = settings.variable || 'obj'; + template.source = 'function(' + argument + '){\n' + source + '}'; + + return template; + } + + // Traverses the children of `obj` along `path`. If a child is a function, it + // is invoked with its parent as context. Returns the value of the final + // child, or `fallback` if any child is undefined. + function result(obj, path, fallback) { + path = toPath$1(path); + var length = path.length; + if (!length) { + return isFunction$1(fallback) ? fallback.call(obj) : fallback; + } + for (var i = 0; i < length; i++) { + var prop = obj == null ? void 0 : obj[path[i]]; + if (prop === void 0) { + prop = fallback; + i = length; // Ensure we don't continue iterating. + } + obj = isFunction$1(prop) ? prop.call(obj) : prop; + } + return obj; + } + + // Generate a unique integer id (unique within the entire client session). + // Useful for temporary DOM ids. + var idCounter = 0; + function uniqueId(prefix) { + var id = ++idCounter + ''; + return prefix ? prefix + id : id; + } + + // Start chaining a wrapped Underscore object. + function chain(obj) { + var instance = _(obj); + instance._chain = true; + return instance; + } + + // Internal function to execute `sourceFunc` bound to `context` with optional + // `args`. Determines whether to execute a function as a constructor or as a + // normal function. + function executeBound(sourceFunc, boundFunc, context, callingContext, args) { + if (!(callingContext instanceof boundFunc)) return sourceFunc.apply(context, args); + var self = baseCreate(sourceFunc.prototype); + var result = sourceFunc.apply(self, args); + if (isObject(result)) return result; + return self; + } + + // Partially apply a function by creating a version that has had some of its + // arguments pre-filled, without changing its dynamic `this` context. `_` acts + // as a placeholder by default, allowing any combination of arguments to be + // pre-filled. Set `_.partial.placeholder` for a custom placeholder argument. + var partial = restArguments(function(func, boundArgs) { + var placeholder = partial.placeholder; + var bound = function() { + var position = 0, length = boundArgs.length; + var args = Array(length); + for (var i = 0; i < length; i++) { + args[i] = boundArgs[i] === placeholder ? arguments[position++] : boundArgs[i]; + } + while (position < arguments.length) args.push(arguments[position++]); + return executeBound(func, bound, this, this, args); + }; + return bound; + }); + + partial.placeholder = _; + + // Create a function bound to a given object (assigning `this`, and arguments, + // optionally). + var bind = restArguments(function(func, context, args) { + if (!isFunction$1(func)) throw new TypeError('Bind must be called on a function'); + var bound = restArguments(function(callArgs) { + return executeBound(func, bound, context, this, args.concat(callArgs)); + }); + return bound; + }); + + // Internal helper for collection methods to determine whether a collection + // should be iterated as an array or as an object. + // Related: https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength + // Avoids a very nasty iOS 8 JIT bug on ARM-64. #2094 + var isArrayLike = createSizePropertyCheck(getLength); + + // Internal implementation of a recursive `flatten` function. + function flatten(input, depth, strict, output) { + output = output || []; + if (!depth && depth !== 0) { + depth = Infinity; + } else if (depth <= 0) { + return output.concat(input); + } + var idx = output.length; + for (var i = 0, length = getLength(input); i < length; i++) { + var value = input[i]; + if (isArrayLike(value) && (isArray(value) || isArguments$1(value))) { + // Flatten current level of array or arguments object. + if (depth > 1) { + flatten(value, depth - 1, strict, output); + idx = output.length; + } else { + var j = 0, len = value.length; + while (j < len) output[idx++] = value[j++]; + } + } else if (!strict) { + output[idx++] = value; + } + } + return output; + } + + // Bind a number of an object's methods to that object. Remaining arguments + // are the method names to be bound. Useful for ensuring that all callbacks + // defined on an object belong to it. + var bindAll = restArguments(function(obj, keys) { + keys = flatten(keys, false, false); + var index = keys.length; + if (index < 1) throw new Error('bindAll must be passed function names'); + while (index--) { + var key = keys[index]; + obj[key] = bind(obj[key], obj); + } + return obj; + }); + + // Memoize an expensive function by storing its results. + function memoize(func, hasher) { + var memoize = function(key) { + var cache = memoize.cache; + var address = '' + (hasher ? hasher.apply(this, arguments) : key); + if (!has(cache, address)) cache[address] = func.apply(this, arguments); + return cache[address]; + }; + memoize.cache = {}; + return memoize; + } + + // Delays a function for the given number of milliseconds, and then calls + // it with the arguments supplied. + var delay = restArguments(function(func, wait, args) { + return setTimeout(function() { + return func.apply(null, args); + }, wait); + }); + + // Defers a function, scheduling it to run after the current call stack has + // cleared. + var defer = partial(delay, _, 1); + + // Returns a function, that, when invoked, will only be triggered at most once + // during a given window of time. Normally, the throttled function will run + // as much as it can, without ever going more than once per `wait` duration; + // but if you'd like to disable the execution on the leading edge, pass + // `{leading: false}`. To disable execution on the trailing edge, ditto. + function throttle(func, wait, options) { + var timeout, context, args, result; + var previous = 0; + if (!options) options = {}; + + var later = function() { + previous = options.leading === false ? 0 : now(); + timeout = null; + result = func.apply(context, args); + if (!timeout) context = args = null; + }; + + var throttled = function() { + var _now = now(); + if (!previous && options.leading === false) previous = _now; + var remaining = wait - (_now - previous); + context = this; + args = arguments; + if (remaining <= 0 || remaining > wait) { + if (timeout) { + clearTimeout(timeout); + timeout = null; + } + previous = _now; + result = func.apply(context, args); + if (!timeout) context = args = null; + } else if (!timeout && options.trailing !== false) { + timeout = setTimeout(later, remaining); + } + return result; + }; + + throttled.cancel = function() { + clearTimeout(timeout); + previous = 0; + timeout = context = args = null; + }; + + return throttled; + } + + // When a sequence of calls of the returned function ends, the argument + // function is triggered. The end of a sequence is defined by the `wait` + // parameter. If `immediate` is passed, the argument function will be + // triggered at the beginning of the sequence instead of at the end. + function debounce(func, wait, immediate) { + var timeout, previous, args, result, context; + + var later = function() { + var passed = now() - previous; + if (wait > passed) { + timeout = setTimeout(later, wait - passed); + } else { + timeout = null; + if (!immediate) result = func.apply(context, args); + // This check is needed because `func` can recursively invoke `debounced`. + if (!timeout) args = context = null; + } + }; + + var debounced = restArguments(function(_args) { + context = this; + args = _args; + previous = now(); + if (!timeout) { + timeout = setTimeout(later, wait); + if (immediate) result = func.apply(context, args); + } + return result; + }); + + debounced.cancel = function() { + clearTimeout(timeout); + timeout = args = context = null; + }; + + return debounced; + } + + // Returns the first function passed as an argument to the second, + // allowing you to adjust arguments, run code before and after, and + // conditionally execute the original function. + function wrap(func, wrapper) { + return partial(wrapper, func); + } + + // Returns a negated version of the passed-in predicate. + function negate(predicate) { + return function() { + return !predicate.apply(this, arguments); + }; + } + + // Returns a function that is the composition of a list of functions, each + // consuming the return value of the function that follows. + function compose() { + var args = arguments; + var start = args.length - 1; + return function() { + var i = start; + var result = args[start].apply(this, arguments); + while (i--) result = args[i].call(this, result); + return result; + }; + } + + // Returns a function that will only be executed on and after the Nth call. + function after(times, func) { + return function() { + if (--times < 1) { + return func.apply(this, arguments); + } + }; + } + + // Returns a function that will only be executed up to (but not including) the + // Nth call. + function before(times, func) { + var memo; + return function() { + if (--times > 0) { + memo = func.apply(this, arguments); + } + if (times <= 1) func = null; + return memo; + }; + } + + // Returns a function that will be executed at most one time, no matter how + // often you call it. Useful for lazy initialization. + var once = partial(before, 2); + + // Returns the first key on an object that passes a truth test. + function findKey(obj, predicate, context) { + predicate = cb(predicate, context); + var _keys = keys(obj), key; + for (var i = 0, length = _keys.length; i < length; i++) { + key = _keys[i]; + if (predicate(obj[key], key, obj)) return key; + } + } + + // Internal function to generate `_.findIndex` and `_.findLastIndex`. + function createPredicateIndexFinder(dir) { + return function(array, predicate, context) { + predicate = cb(predicate, context); + var length = getLength(array); + var index = dir > 0 ? 0 : length - 1; + for (; index >= 0 && index < length; index += dir) { + if (predicate(array[index], index, array)) return index; + } + return -1; + }; + } + + // Returns the first index on an array-like that passes a truth test. + var findIndex = createPredicateIndexFinder(1); + + // Returns the last index on an array-like that passes a truth test. + var findLastIndex = createPredicateIndexFinder(-1); + + // Use a comparator function to figure out the smallest index at which + // an object should be inserted so as to maintain order. Uses binary search. + function sortedIndex(array, obj, iteratee, context) { + iteratee = cb(iteratee, context, 1); + var value = iteratee(obj); + var low = 0, high = getLength(array); + while (low < high) { + var mid = Math.floor((low + high) / 2); + if (iteratee(array[mid]) < value) low = mid + 1; else high = mid; + } + return low; + } + + // Internal function to generate the `_.indexOf` and `_.lastIndexOf` functions. + function createIndexFinder(dir, predicateFind, sortedIndex) { + return function(array, item, idx) { + var i = 0, length = getLength(array); + if (typeof idx == 'number') { + if (dir > 0) { + i = idx >= 0 ? idx : Math.max(idx + length, i); + } else { + length = idx >= 0 ? Math.min(idx + 1, length) : idx + length + 1; + } + } else if (sortedIndex && idx && length) { + idx = sortedIndex(array, item); + return array[idx] === item ? idx : -1; + } + if (item !== item) { + idx = predicateFind(slice.call(array, i, length), isNaN$1); + return idx >= 0 ? idx + i : -1; + } + for (idx = dir > 0 ? i : length - 1; idx >= 0 && idx < length; idx += dir) { + if (array[idx] === item) return idx; + } + return -1; + }; + } + + // Return the position of the first occurrence of an item in an array, + // or -1 if the item is not included in the array. + // If the array is large and already in sort order, pass `true` + // for **isSorted** to use binary search. + var indexOf = createIndexFinder(1, findIndex, sortedIndex); + + // Return the position of the last occurrence of an item in an array, + // or -1 if the item is not included in the array. + var lastIndexOf = createIndexFinder(-1, findLastIndex); + + // Return the first value which passes a truth test. + function find(obj, predicate, context) { + var keyFinder = isArrayLike(obj) ? findIndex : findKey; + var key = keyFinder(obj, predicate, context); + if (key !== void 0 && key !== -1) return obj[key]; + } + + // Convenience version of a common use case of `_.find`: getting the first + // object containing specific `key:value` pairs. + function findWhere(obj, attrs) { + return find(obj, matcher(attrs)); + } + + // The cornerstone for collection functions, an `each` + // implementation, aka `forEach`. + // Handles raw objects in addition to array-likes. Treats all + // sparse array-likes as if they were dense. + function each(obj, iteratee, context) { + iteratee = optimizeCb(iteratee, context); + var i, length; + if (isArrayLike(obj)) { + for (i = 0, length = obj.length; i < length; i++) { + iteratee(obj[i], i, obj); + } + } else { + var _keys = keys(obj); + for (i = 0, length = _keys.length; i < length; i++) { + iteratee(obj[_keys[i]], _keys[i], obj); + } + } + return obj; + } + + // Return the results of applying the iteratee to each element. + function map(obj, iteratee, context) { + iteratee = cb(iteratee, context); + var _keys = !isArrayLike(obj) && keys(obj), + length = (_keys || obj).length, + results = Array(length); + for (var index = 0; index < length; index++) { + var currentKey = _keys ? _keys[index] : index; + results[index] = iteratee(obj[currentKey], currentKey, obj); + } + return results; + } + + // Internal helper to create a reducing function, iterating left or right. + function createReduce(dir) { + // Wrap code that reassigns argument variables in a separate function than + // the one that accesses `arguments.length` to avoid a perf hit. (#1991) + var reducer = function(obj, iteratee, memo, initial) { + var _keys = !isArrayLike(obj) && keys(obj), + length = (_keys || obj).length, + index = dir > 0 ? 0 : length - 1; + if (!initial) { + memo = obj[_keys ? _keys[index] : index]; + index += dir; + } + for (; index >= 0 && index < length; index += dir) { + var currentKey = _keys ? _keys[index] : index; + memo = iteratee(memo, obj[currentKey], currentKey, obj); + } + return memo; + }; + + return function(obj, iteratee, memo, context) { + var initial = arguments.length >= 3; + return reducer(obj, optimizeCb(iteratee, context, 4), memo, initial); + }; + } + + // **Reduce** builds up a single result from a list of values, aka `inject`, + // or `foldl`. + var reduce = createReduce(1); + + // The right-associative version of reduce, also known as `foldr`. + var reduceRight = createReduce(-1); + + // Return all the elements that pass a truth test. + function filter(obj, predicate, context) { + var results = []; + predicate = cb(predicate, context); + each(obj, function(value, index, list) { + if (predicate(value, index, list)) results.push(value); + }); + return results; + } + + // Return all the elements for which a truth test fails. + function reject(obj, predicate, context) { + return filter(obj, negate(cb(predicate)), context); + } + + // Determine whether all of the elements pass a truth test. + function every(obj, predicate, context) { + predicate = cb(predicate, context); + var _keys = !isArrayLike(obj) && keys(obj), + length = (_keys || obj).length; + for (var index = 0; index < length; index++) { + var currentKey = _keys ? _keys[index] : index; + if (!predicate(obj[currentKey], currentKey, obj)) return false; + } + return true; + } + + // Determine if at least one element in the object passes a truth test. + function some(obj, predicate, context) { + predicate = cb(predicate, context); + var _keys = !isArrayLike(obj) && keys(obj), + length = (_keys || obj).length; + for (var index = 0; index < length; index++) { + var currentKey = _keys ? _keys[index] : index; + if (predicate(obj[currentKey], currentKey, obj)) return true; + } + return false; + } + + // Determine if the array or object contains a given item (using `===`). + function contains(obj, item, fromIndex, guard) { + if (!isArrayLike(obj)) obj = values(obj); + if (typeof fromIndex != 'number' || guard) fromIndex = 0; + return indexOf(obj, item, fromIndex) >= 0; + } + + // Invoke a method (with arguments) on every item in a collection. + var invoke = restArguments(function(obj, path, args) { + var contextPath, func; + if (isFunction$1(path)) { + func = path; + } else { + path = toPath$1(path); + contextPath = path.slice(0, -1); + path = path[path.length - 1]; + } + return map(obj, function(context) { + var method = func; + if (!method) { + if (contextPath && contextPath.length) { + context = deepGet(context, contextPath); + } + if (context == null) return void 0; + method = context[path]; + } + return method == null ? method : method.apply(context, args); + }); + }); + + // Convenience version of a common use case of `_.map`: fetching a property. + function pluck(obj, key) { + return map(obj, property(key)); + } + + // Convenience version of a common use case of `_.filter`: selecting only + // objects containing specific `key:value` pairs. + function where(obj, attrs) { + return filter(obj, matcher(attrs)); + } + + // Return the maximum element (or element-based computation). + function max(obj, iteratee, context) { + var result = -Infinity, lastComputed = -Infinity, + value, computed; + if (iteratee == null || typeof iteratee == 'number' && typeof obj[0] != 'object' && obj != null) { + obj = isArrayLike(obj) ? obj : values(obj); + for (var i = 0, length = obj.length; i < length; i++) { + value = obj[i]; + if (value != null && value > result) { + result = value; + } + } + } else { + iteratee = cb(iteratee, context); + each(obj, function(v, index, list) { + computed = iteratee(v, index, list); + if (computed > lastComputed || computed === -Infinity && result === -Infinity) { + result = v; + lastComputed = computed; + } + }); + } + return result; + } + + // Return the minimum element (or element-based computation). + function min(obj, iteratee, context) { + var result = Infinity, lastComputed = Infinity, + value, computed; + if (iteratee == null || typeof iteratee == 'number' && typeof obj[0] != 'object' && obj != null) { + obj = isArrayLike(obj) ? obj : values(obj); + for (var i = 0, length = obj.length; i < length; i++) { + value = obj[i]; + if (value != null && value < result) { + result = value; + } + } + } else { + iteratee = cb(iteratee, context); + each(obj, function(v, index, list) { + computed = iteratee(v, index, list); + if (computed < lastComputed || computed === Infinity && result === Infinity) { + result = v; + lastComputed = computed; + } + }); + } + return result; + } + + // Sample **n** random values from a collection using the modern version of the + // [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher–Yates_shuffle). + // If **n** is not specified, returns a single random element. + // The internal `guard` argument allows it to work with `_.map`. + function sample(obj, n, guard) { + if (n == null || guard) { + if (!isArrayLike(obj)) obj = values(obj); + return obj[random(obj.length - 1)]; + } + var sample = isArrayLike(obj) ? clone(obj) : values(obj); + var length = getLength(sample); + n = Math.max(Math.min(n, length), 0); + var last = length - 1; + for (var index = 0; index < n; index++) { + var rand = random(index, last); + var temp = sample[index]; + sample[index] = sample[rand]; + sample[rand] = temp; + } + return sample.slice(0, n); + } + + // Shuffle a collection. + function shuffle(obj) { + return sample(obj, Infinity); + } + + // Sort the object's values by a criterion produced by an iteratee. + function sortBy(obj, iteratee, context) { + var index = 0; + iteratee = cb(iteratee, context); + return pluck(map(obj, function(value, key, list) { + return { + value: value, + index: index++, + criteria: iteratee(value, key, list) + }; + }).sort(function(left, right) { + var a = left.criteria; + var b = right.criteria; + if (a !== b) { + if (a > b || a === void 0) return 1; + if (a < b || b === void 0) return -1; + } + return left.index - right.index; + }), 'value'); + } + + // An internal function used for aggregate "group by" operations. + function group(behavior, partition) { + return function(obj, iteratee, context) { + var result = partition ? [[], []] : {}; + iteratee = cb(iteratee, context); + each(obj, function(value, index) { + var key = iteratee(value, index, obj); + behavior(result, value, key); + }); + return result; + }; + } + + // Groups the object's values by a criterion. Pass either a string attribute + // to group by, or a function that returns the criterion. + var groupBy = group(function(result, value, key) { + if (has(result, key)) result[key].push(value); else result[key] = [value]; + }); + + // Indexes the object's values by a criterion, similar to `_.groupBy`, but for + // when you know that your index values will be unique. + var indexBy = group(function(result, value, key) { + result[key] = value; + }); + + // Counts instances of an object that group by a certain criterion. Pass + // either a string attribute to count by, or a function that returns the + // criterion. + var countBy = group(function(result, value, key) { + if (has(result, key)) result[key]++; else result[key] = 1; + }); + + // Split a collection into two arrays: one whose elements all pass the given + // truth test, and one whose elements all do not pass the truth test. + var partition = group(function(result, value, pass) { + result[pass ? 0 : 1].push(value); + }, true); + + // Safely create a real, live array from anything iterable. + var reStrSymbol = /[^\ud800-\udfff]|[\ud800-\udbff][\udc00-\udfff]|[\ud800-\udfff]/g; + function toArray(obj) { + if (!obj) return []; + if (isArray(obj)) return slice.call(obj); + if (isString(obj)) { + // Keep surrogate pair characters together. + return obj.match(reStrSymbol); + } + if (isArrayLike(obj)) return map(obj, identity); + return values(obj); + } + + // Return the number of elements in a collection. + function size(obj) { + if (obj == null) return 0; + return isArrayLike(obj) ? obj.length : keys(obj).length; + } + + // Internal `_.pick` helper function to determine whether `key` is an enumerable + // property name of `obj`. + function keyInObj(value, key, obj) { + return key in obj; + } + + // Return a copy of the object only containing the allowed properties. + var pick = restArguments(function(obj, keys) { + var result = {}, iteratee = keys[0]; + if (obj == null) return result; + if (isFunction$1(iteratee)) { + if (keys.length > 1) iteratee = optimizeCb(iteratee, keys[1]); + keys = allKeys(obj); + } else { + iteratee = keyInObj; + keys = flatten(keys, false, false); + obj = Object(obj); + } + for (var i = 0, length = keys.length; i < length; i++) { + var key = keys[i]; + var value = obj[key]; + if (iteratee(value, key, obj)) result[key] = value; + } + return result; + }); + + // Return a copy of the object without the disallowed properties. + var omit = restArguments(function(obj, keys) { + var iteratee = keys[0], context; + if (isFunction$1(iteratee)) { + iteratee = negate(iteratee); + if (keys.length > 1) context = keys[1]; + } else { + keys = map(flatten(keys, false, false), String); + iteratee = function(value, key) { + return !contains(keys, key); + }; + } + return pick(obj, iteratee, context); + }); + + // Returns everything but the last entry of the array. Especially useful on + // the arguments object. Passing **n** will return all the values in + // the array, excluding the last N. + function initial(array, n, guard) { + return slice.call(array, 0, Math.max(0, array.length - (n == null || guard ? 1 : n))); + } + + // Get the first element of an array. Passing **n** will return the first N + // values in the array. The **guard** check allows it to work with `_.map`. + function first(array, n, guard) { + if (array == null || array.length < 1) return n == null || guard ? void 0 : []; + if (n == null || guard) return array[0]; + return initial(array, array.length - n); + } + + // Returns everything but the first entry of the `array`. Especially useful on + // the `arguments` object. Passing an **n** will return the rest N values in the + // `array`. + function rest(array, n, guard) { + return slice.call(array, n == null || guard ? 1 : n); + } + + // Get the last element of an array. Passing **n** will return the last N + // values in the array. + function last(array, n, guard) { + if (array == null || array.length < 1) return n == null || guard ? void 0 : []; + if (n == null || guard) return array[array.length - 1]; + return rest(array, Math.max(0, array.length - n)); + } + + // Trim out all falsy values from an array. + function compact(array) { + return filter(array, Boolean); + } + + // Flatten out an array, either recursively (by default), or up to `depth`. + // Passing `true` or `false` as `depth` means `1` or `Infinity`, respectively. + function flatten$1(array, depth) { + return flatten(array, depth, false); + } + + // Take the difference between one array and a number of other arrays. + // Only the elements present in just the first array will remain. + var difference = restArguments(function(array, rest) { + rest = flatten(rest, true, true); + return filter(array, function(value){ + return !contains(rest, value); + }); + }); + + // Return a version of the array that does not contain the specified value(s). + var without = restArguments(function(array, otherArrays) { + return difference(array, otherArrays); + }); + + // Produce a duplicate-free version of the array. If the array has already + // been sorted, you have the option of using a faster algorithm. + // The faster algorithm will not work with an iteratee if the iteratee + // is not a one-to-one function, so providing an iteratee will disable + // the faster algorithm. + function uniq(array, isSorted, iteratee, context) { + if (!isBoolean(isSorted)) { + context = iteratee; + iteratee = isSorted; + isSorted = false; + } + if (iteratee != null) iteratee = cb(iteratee, context); + var result = []; + var seen = []; + for (var i = 0, length = getLength(array); i < length; i++) { + var value = array[i], + computed = iteratee ? iteratee(value, i, array) : value; + if (isSorted && !iteratee) { + if (!i || seen !== computed) result.push(value); + seen = computed; + } else if (iteratee) { + if (!contains(seen, computed)) { + seen.push(computed); + result.push(value); + } + } else if (!contains(result, value)) { + result.push(value); + } + } + return result; + } + + // Produce an array that contains the union: each distinct element from all of + // the passed-in arrays. + var union = restArguments(function(arrays) { + return uniq(flatten(arrays, true, true)); + }); + + // Produce an array that contains every item shared between all the + // passed-in arrays. + function intersection(array) { + var result = []; + var argsLength = arguments.length; + for (var i = 0, length = getLength(array); i < length; i++) { + var item = array[i]; + if (contains(result, item)) continue; + var j; + for (j = 1; j < argsLength; j++) { + if (!contains(arguments[j], item)) break; + } + if (j === argsLength) result.push(item); + } + return result; + } + + // Complement of zip. Unzip accepts an array of arrays and groups + // each array's elements on shared indices. + function unzip(array) { + var length = array && max(array, getLength).length || 0; + var result = Array(length); + + for (var index = 0; index < length; index++) { + result[index] = pluck(array, index); + } + return result; + } + + // Zip together multiple lists into a single array -- elements that share + // an index go together. + var zip = restArguments(unzip); + + // Converts lists into objects. Pass either a single array of `[key, value]` + // pairs, or two parallel arrays of the same length -- one of keys, and one of + // the corresponding values. Passing by pairs is the reverse of `_.pairs`. + function object(list, values) { + var result = {}; + for (var i = 0, length = getLength(list); i < length; i++) { + if (values) { + result[list[i]] = values[i]; + } else { + result[list[i][0]] = list[i][1]; + } + } + return result; + } + + // Generate an integer Array containing an arithmetic progression. A port of + // the native Python `range()` function. See + // [the Python documentation](https://docs.python.org/library/functions.html#range). + function range(start, stop, step) { + if (stop == null) { + stop = start || 0; + start = 0; + } + if (!step) { + step = stop < start ? -1 : 1; + } + + var length = Math.max(Math.ceil((stop - start) / step), 0); + var range = Array(length); + + for (var idx = 0; idx < length; idx++, start += step) { + range[idx] = start; + } + + return range; + } + + // Chunk a single array into multiple arrays, each containing `count` or fewer + // items. + function chunk(array, count) { + if (count == null || count < 1) return []; + var result = []; + var i = 0, length = array.length; + while (i < length) { + result.push(slice.call(array, i, i += count)); + } + return result; + } + + // Helper function to continue chaining intermediate results. + function chainResult(instance, obj) { + return instance._chain ? _(obj).chain() : obj; + } + + // Add your own custom functions to the Underscore object. + function mixin(obj) { + each(functions(obj), function(name) { + var func = _[name] = obj[name]; + _.prototype[name] = function() { + var args = [this._wrapped]; + push.apply(args, arguments); + return chainResult(this, func.apply(_, args)); + }; + }); + return _; + } + + // Add all mutator `Array` functions to the wrapper. + each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) { + var method = ArrayProto[name]; + _.prototype[name] = function() { + var obj = this._wrapped; + if (obj != null) { + method.apply(obj, arguments); + if ((name === 'shift' || name === 'splice') && obj.length === 0) { + delete obj[0]; + } + } + return chainResult(this, obj); + }; + }); + + // Add all accessor `Array` functions to the wrapper. + each(['concat', 'join', 'slice'], function(name) { + var method = ArrayProto[name]; + _.prototype[name] = function() { + var obj = this._wrapped; + if (obj != null) obj = method.apply(obj, arguments); + return chainResult(this, obj); + }; + }); + + // Named Exports + + var allExports = { + __proto__: null, + VERSION: VERSION, + restArguments: restArguments, + isObject: isObject, + isNull: isNull, + isUndefined: isUndefined, + isBoolean: isBoolean, + isElement: isElement, + isString: isString, + isNumber: isNumber, + isDate: isDate, + isRegExp: isRegExp, + isError: isError, + isSymbol: isSymbol, + isArrayBuffer: isArrayBuffer, + isDataView: isDataView$1, + isArray: isArray, + isFunction: isFunction$1, + isArguments: isArguments$1, + isFinite: isFinite$1, + isNaN: isNaN$1, + isTypedArray: isTypedArray$1, + isEmpty: isEmpty, + isMatch: isMatch, + isEqual: isEqual, + isMap: isMap, + isWeakMap: isWeakMap, + isSet: isSet, + isWeakSet: isWeakSet, + keys: keys, + allKeys: allKeys, + values: values, + pairs: pairs, + invert: invert, + functions: functions, + methods: functions, + extend: extend, + extendOwn: extendOwn, + assign: extendOwn, + defaults: defaults, + create: create, + clone: clone, + tap: tap, + get: get, + has: has$1, + mapObject: mapObject, + identity: identity, + constant: constant, + noop: noop, + toPath: toPath, + property: property, + propertyOf: propertyOf, + matcher: matcher, + matches: matcher, + times: times, + random: random, + now: now, + escape: _escape, + unescape: _unescape, + templateSettings: templateSettings, + template: template, + result: result, + uniqueId: uniqueId, + chain: chain, + iteratee: iteratee, + partial: partial, + bind: bind, + bindAll: bindAll, + memoize: memoize, + delay: delay, + defer: defer, + throttle: throttle, + debounce: debounce, + wrap: wrap, + negate: negate, + compose: compose, + after: after, + before: before, + once: once, + findKey: findKey, + findIndex: findIndex, + findLastIndex: findLastIndex, + sortedIndex: sortedIndex, + indexOf: indexOf, + lastIndexOf: lastIndexOf, + find: find, + detect: find, + findWhere: findWhere, + each: each, + forEach: each, + map: map, + collect: map, + reduce: reduce, + foldl: reduce, + inject: reduce, + reduceRight: reduceRight, + foldr: reduceRight, + filter: filter, + select: filter, + reject: reject, + every: every, + all: every, + some: some, + any: some, + contains: contains, + includes: contains, + include: contains, + invoke: invoke, + pluck: pluck, + where: where, + max: max, + min: min, + shuffle: shuffle, + sample: sample, + sortBy: sortBy, + groupBy: groupBy, + indexBy: indexBy, + countBy: countBy, + partition: partition, + toArray: toArray, + size: size, + pick: pick, + omit: omit, + first: first, + head: first, + take: first, + initial: initial, + last: last, + rest: rest, + tail: rest, + drop: rest, + compact: compact, + flatten: flatten$1, + without: without, + uniq: uniq, + unique: uniq, + union: union, + intersection: intersection, + difference: difference, + unzip: unzip, + transpose: unzip, + zip: zip, + object: object, + range: range, + chunk: chunk, + mixin: mixin, + 'default': _ + }; + + // Default Export + + // Add all of the Underscore functions to the wrapper object. + var _$1 = mixin(allExports); + // Legacy Node.js API. + _$1._ = _$1; + + return _$1; + +}))); +//# sourceMappingURL=underscore.js.map diff --git a/deepsparse/_static/underscore.js b/deepsparse/_static/underscore.js index 5b55f32beac..166240ef2dd 100644 --- a/deepsparse/_static/underscore.js +++ b/deepsparse/_static/underscore.js @@ -1,31 +1,6 @@ -// Underscore.js 1.3.1 -// (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc. -// Underscore is freely distributable under the MIT license. -// Portions of Underscore are inspired or borrowed from Prototype, -// Oliver Steele's Functional, and John Resig's Micro-Templating. -// For all details and documentation: -// http://documentcloud.github.com/underscore -(function(){function q(a,c,d){if(a===c)return a!==0||1/a==1/c;if(a==null||c==null)return a===c;if(a._chain)a=a._wrapped;if(c._chain)c=c._wrapped;if(a.isEqual&&b.isFunction(a.isEqual))return a.isEqual(c);if(c.isEqual&&b.isFunction(c.isEqual))return c.isEqual(a);var e=l.call(a);if(e!=l.call(c))return false;switch(e){case "[object String]":return a==String(c);case "[object Number]":return a!=+a?c!=+c:a==0?1/a==1/c:a==+c;case "[object Date]":case "[object Boolean]":return+a==+c;case "[object RegExp]":return a.source== -c.source&&a.global==c.global&&a.multiline==c.multiline&&a.ignoreCase==c.ignoreCase}if(typeof a!="object"||typeof c!="object")return false;for(var f=d.length;f--;)if(d[f]==a)return true;d.push(a);var f=0,g=true;if(e=="[object Array]"){if(f=a.length,g=f==c.length)for(;f--;)if(!(g=f in a==f in c&&q(a[f],c[f],d)))break}else{if("constructor"in a!="constructor"in c||a.constructor!=c.constructor)return false;for(var h in a)if(b.has(a,h)&&(f++,!(g=b.has(c,h)&&q(a[h],c[h],d))))break;if(g){for(h in c)if(b.has(c, -h)&&!f--)break;g=!f}}d.pop();return g}var r=this,G=r._,n={},k=Array.prototype,o=Object.prototype,i=k.slice,H=k.unshift,l=o.toString,I=o.hasOwnProperty,w=k.forEach,x=k.map,y=k.reduce,z=k.reduceRight,A=k.filter,B=k.every,C=k.some,p=k.indexOf,D=k.lastIndexOf,o=Array.isArray,J=Object.keys,s=Function.prototype.bind,b=function(a){return new m(a)};if(typeof exports!=="undefined"){if(typeof module!=="undefined"&&module.exports)exports=module.exports=b;exports._=b}else r._=b;b.VERSION="1.3.1";var j=b.each= -b.forEach=function(a,c,d){if(a!=null)if(w&&a.forEach===w)a.forEach(c,d);else if(a.length===+a.length)for(var e=0,f=a.length;e2;a== -null&&(a=[]);if(y&&a.reduce===y)return e&&(c=b.bind(c,e)),f?a.reduce(c,d):a.reduce(c);j(a,function(a,b,i){f?d=c.call(e,d,a,b,i):(d=a,f=true)});if(!f)throw new TypeError("Reduce of empty array with no initial value");return d};b.reduceRight=b.foldr=function(a,c,d,e){var f=arguments.length>2;a==null&&(a=[]);if(z&&a.reduceRight===z)return e&&(c=b.bind(c,e)),f?a.reduceRight(c,d):a.reduceRight(c);var g=b.toArray(a).reverse();e&&!f&&(c=b.bind(c,e));return f?b.reduce(g,c,d,e):b.reduce(g,c)};b.find=b.detect= -function(a,c,b){var e;E(a,function(a,g,h){if(c.call(b,a,g,h))return e=a,true});return e};b.filter=b.select=function(a,c,b){var e=[];if(a==null)return e;if(A&&a.filter===A)return a.filter(c,b);j(a,function(a,g,h){c.call(b,a,g,h)&&(e[e.length]=a)});return e};b.reject=function(a,c,b){var e=[];if(a==null)return e;j(a,function(a,g,h){c.call(b,a,g,h)||(e[e.length]=a)});return e};b.every=b.all=function(a,c,b){var e=true;if(a==null)return e;if(B&&a.every===B)return a.every(c,b);j(a,function(a,g,h){if(!(e= -e&&c.call(b,a,g,h)))return n});return e};var E=b.some=b.any=function(a,c,d){c||(c=b.identity);var e=false;if(a==null)return e;if(C&&a.some===C)return a.some(c,d);j(a,function(a,b,h){if(e||(e=c.call(d,a,b,h)))return n});return!!e};b.include=b.contains=function(a,c){var b=false;if(a==null)return b;return p&&a.indexOf===p?a.indexOf(c)!=-1:b=E(a,function(a){return a===c})};b.invoke=function(a,c){var d=i.call(arguments,2);return b.map(a,function(a){return(b.isFunction(c)?c||a:a[c]).apply(a,d)})};b.pluck= -function(a,c){return b.map(a,function(a){return a[c]})};b.max=function(a,c,d){if(!c&&b.isArray(a))return Math.max.apply(Math,a);if(!c&&b.isEmpty(a))return-Infinity;var e={computed:-Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b>=e.computed&&(e={value:a,computed:b})});return e.value};b.min=function(a,c,d){if(!c&&b.isArray(a))return Math.min.apply(Math,a);if(!c&&b.isEmpty(a))return Infinity;var e={computed:Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;bd?1:0}),"value")};b.groupBy=function(a,c){var d={},e=b.isFunction(c)?c:function(a){return a[c]};j(a,function(a,b){var c=e(a,b);(d[c]||(d[c]=[])).push(a)});return d};b.sortedIndex=function(a, -c,d){d||(d=b.identity);for(var e=0,f=a.length;e>1;d(a[g])=0})})};b.difference=function(a){var c=b.flatten(i.call(arguments,1));return b.filter(a,function(a){return!b.include(c,a)})};b.zip=function(){for(var a=i.call(arguments),c=b.max(b.pluck(a,"length")),d=Array(c),e=0;e=0;d--)b=[a[d].apply(this,b)];return b[0]}}; -b.after=function(a,b){return a<=0?b():function(){if(--a<1)return b.apply(this,arguments)}};b.keys=J||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var c=[],d;for(d in a)b.has(a,d)&&(c[c.length]=d);return c};b.values=function(a){return b.map(a,b.identity)};b.functions=b.methods=function(a){var c=[],d;for(d in a)b.isFunction(a[d])&&c.push(d);return c.sort()};b.extend=function(a){j(i.call(arguments,1),function(b){for(var d in b)a[d]=b[d]});return a};b.defaults=function(a){j(i.call(arguments, -1),function(b){for(var d in b)a[d]==null&&(a[d]=b[d])});return a};b.clone=function(a){return!b.isObject(a)?a:b.isArray(a)?a.slice():b.extend({},a)};b.tap=function(a,b){b(a);return a};b.isEqual=function(a,b){return q(a,b,[])};b.isEmpty=function(a){if(b.isArray(a)||b.isString(a))return a.length===0;for(var c in a)if(b.has(a,c))return false;return true};b.isElement=function(a){return!!(a&&a.nodeType==1)};b.isArray=o||function(a){return l.call(a)=="[object Array]"};b.isObject=function(a){return a===Object(a)}; -b.isArguments=function(a){return l.call(a)=="[object Arguments]"};if(!b.isArguments(arguments))b.isArguments=function(a){return!(!a||!b.has(a,"callee"))};b.isFunction=function(a){return l.call(a)=="[object Function]"};b.isString=function(a){return l.call(a)=="[object String]"};b.isNumber=function(a){return l.call(a)=="[object Number]"};b.isNaN=function(a){return a!==a};b.isBoolean=function(a){return a===true||a===false||l.call(a)=="[object Boolean]"};b.isDate=function(a){return l.call(a)=="[object Date]"}; -b.isRegExp=function(a){return l.call(a)=="[object RegExp]"};b.isNull=function(a){return a===null};b.isUndefined=function(a){return a===void 0};b.has=function(a,b){return I.call(a,b)};b.noConflict=function(){r._=G;return this};b.identity=function(a){return a};b.times=function(a,b,d){for(var e=0;e/g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")};b.mixin=function(a){j(b.functions(a), -function(c){K(c,b[c]=a[c])})};var L=0;b.uniqueId=function(a){var b=L++;return a?a+b:b};b.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var t=/.^/,u=function(a){return a.replace(/\\\\/g,"\\").replace(/\\'/g,"'")};b.template=function(a,c){var d=b.templateSettings,d="var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('"+a.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(d.escape||t,function(a,b){return"',_.escape("+ -u(b)+"),'"}).replace(d.interpolate||t,function(a,b){return"',"+u(b)+",'"}).replace(d.evaluate||t,function(a,b){return"');"+u(b).replace(/[\r\n\t]/g," ")+";__p.push('"}).replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t")+"');}return __p.join('');",e=new Function("obj","_",d);return c?e(c,b):function(a){return e.call(this,a,b)}};b.chain=function(a){return b(a).chain()};var m=function(a){this._wrapped=a};b.prototype=m.prototype;var v=function(a,c){return c?b(a).chain():a},K=function(a,c){m.prototype[a]= -function(){var a=i.call(arguments);H.call(a,this._wrapped);return v(c.apply(b,a),this._chain)}};b.mixin(b);j("pop,push,reverse,shift,sort,splice,unshift".split(","),function(a){var b=k[a];m.prototype[a]=function(){var d=this._wrapped;b.apply(d,arguments);var e=d.length;(a=="shift"||a=="splice")&&e===0&&delete d[0];return v(d,this._chain)}});j(["concat","join","slice"],function(a){var b=k[a];m.prototype[a]=function(){return v(b.apply(this._wrapped,arguments),this._chain)}});m.prototype.chain=function(){this._chain= -true;return this};m.prototype.value=function(){return this._wrapped}}).call(this); +!function(n,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define("underscore",r):(n=n||self,function(){var t=n._,e=n._=r();e.noConflict=function(){return n._=t,e}}())}(this,(function(){ +// Underscore.js 1.12.0 +// https://underscorejs.org +// (c) 2009-2020 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors +// Underscore may be freely distributed under the MIT license. +var n="1.12.0",r="object"==typeof self&&self.self===self&&self||"object"==typeof global&&global.global===global&&global||Function("return this")()||{},t=Array.prototype,e=Object.prototype,u="undefined"!=typeof Symbol?Symbol.prototype:null,o=t.push,i=t.slice,a=e.toString,f=e.hasOwnProperty,c="undefined"!=typeof ArrayBuffer,l="undefined"!=typeof DataView,s=Array.isArray,p=Object.keys,v=Object.create,h=c&&ArrayBuffer.isView,y=isNaN,g=isFinite,d=!{toString:null}.propertyIsEnumerable("toString"),b=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],m=Math.pow(2,53)-1;function j(n,r){return r=null==r?n.length-1:+r,function(){for(var t=Math.max(arguments.length-r,0),e=Array(t),u=0;u=0&&t<=m}}function $(n){return function(r){return null==r?void 0:r[n]}}var G=$("byteLength"),H=J(G),Q=/\[object ((I|Ui)nt(8|16|32)|Float(32|64)|Uint8Clamped|Big(I|Ui)nt64)Array\]/;var X=c?function(n){return h?h(n)&&!q(n):H(n)&&Q.test(a.call(n))}:K(!1),Y=$("length");function Z(n,r){r=function(n){for(var r={},t=n.length,e=0;e":">",'"':""","'":"'","`":"`"},Kn=Ln(Cn),Jn=Ln(_n(Cn)),$n=tn.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g},Gn=/(.)^/,Hn={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},Qn=/\\|'|\r|\n|\u2028|\u2029/g;function Xn(n){return"\\"+Hn[n]}var Yn=0;function Zn(n,r,t,e,u){if(!(e instanceof r))return n.apply(t,u);var o=Mn(n.prototype),i=n.apply(o,u);return _(i)?i:o}var nr=j((function(n,r){var t=nr.placeholder,e=function(){for(var u=0,o=r.length,i=Array(o),a=0;a1)er(a,r-1,t,e),u=e.length;else for(var f=0,c=a.length;f0&&(t=r.apply(this,arguments)),n<=1&&(r=null),t}}var cr=nr(fr,2);function lr(n,r,t){r=qn(r,t);for(var e,u=nn(n),o=0,i=u.length;o0?0:u-1;o>=0&&o0?a=o>=0?o:Math.max(o+f,a):f=o>=0?Math.min(o+1,f):o+f+1;else if(t&&o&&f)return e[o=t(e,u)]===u?o:-1;if(u!=u)return(o=r(i.call(e,a,f),C))>=0?o+a:-1;for(o=n>0?a:f-1;o>=0&&o0?0:i-1;for(u||(e=r[o?o[a]:a],a+=n);a>=0&&a=3;return r(n,Fn(t,u,4),e,o)}}var wr=_r(1),Ar=_r(-1);function xr(n,r,t){var e=[];return r=qn(r,t),mr(n,(function(n,t,u){r(n,t,u)&&e.push(n)})),e}function Sr(n,r,t){r=qn(r,t);for(var e=!tr(n)&&nn(n),u=(e||n).length,o=0;o=0}var Er=j((function(n,r,t){var e,u;return D(r)?u=r:(r=Nn(r),e=r.slice(0,-1),r=r[r.length-1]),jr(n,(function(n){var o=u;if(!o){if(e&&e.length&&(n=In(n,e)),null==n)return;o=n[r]}return null==o?o:o.apply(n,t)}))}));function Br(n,r){return jr(n,Rn(r))}function Nr(n,r,t){var e,u,o=-1/0,i=-1/0;if(null==r||"number"==typeof r&&"object"!=typeof n[0]&&null!=n)for(var a=0,f=(n=tr(n)?n:jn(n)).length;ao&&(o=e);else r=qn(r,t),mr(n,(function(n,t,e){((u=r(n,t,e))>i||u===-1/0&&o===-1/0)&&(o=n,i=u)}));return o}function Ir(n,r,t){if(null==r||t)return tr(n)||(n=jn(n)),n[Wn(n.length-1)];var e=tr(n)?En(n):jn(n),u=Y(e);r=Math.max(Math.min(r,u),0);for(var o=u-1,i=0;i1&&(e=Fn(e,r[1])),r=an(n)):(e=Pr,r=er(r,!1,!1),n=Object(n));for(var u=0,o=r.length;u1&&(t=r[1])):(r=jr(er(r,!1,!1),String),e=function(n,t){return!Mr(r,t)}),qr(n,e,t)}));function Wr(n,r,t){return i.call(n,0,Math.max(0,n.length-(null==r||t?1:r)))}function zr(n,r,t){return null==n||n.length<1?null==r||t?void 0:[]:null==r||t?n[0]:Wr(n,n.length-r)}function Lr(n,r,t){return i.call(n,null==r||t?1:r)}var Cr=j((function(n,r){return r=er(r,!0,!0),xr(n,(function(n){return!Mr(r,n)}))})),Kr=j((function(n,r){return Cr(n,r)}));function Jr(n,r,t,e){A(r)||(e=t,t=r,r=!1),null!=t&&(t=qn(t,e));for(var u=[],o=[],i=0,a=Y(n);ir?(e&&(clearTimeout(e),e=null),a=c,i=n.apply(u,o),e||(u=o=null)):e||!1===t.trailing||(e=setTimeout(f,l)),i};return c.cancel=function(){clearTimeout(e),a=0,e=u=o=null},c},debounce:function(n,r,t){var e,u,o=function(r,t){e=null,t&&(u=n.apply(r,t))},i=j((function(i){if(e&&clearTimeout(e),t){var a=!e;e=setTimeout(o,r),a&&(u=n.apply(this,i))}else e=or(o,r,this,i);return u}));return i.cancel=function(){clearTimeout(e),e=null},i},wrap:function(n,r){return nr(r,n)},negate:ar,compose:function(){var n=arguments,r=n.length-1;return function(){for(var t=r,e=n[r].apply(this,arguments);t--;)e=n[t].call(this,e);return e}},after:function(n,r){return function(){if(--n<1)return r.apply(this,arguments)}},before:fr,once:cr,findKey:lr,findIndex:pr,findLastIndex:vr,sortedIndex:hr,indexOf:gr,lastIndexOf:dr,find:br,detect:br,findWhere:function(n,r){return br(n,Dn(r))},each:mr,forEach:mr,map:jr,collect:jr,reduce:wr,foldl:wr,inject:wr,reduceRight:Ar,foldr:Ar,filter:xr,select:xr,reject:function(n,r,t){return xr(n,ar(qn(r)),t)},every:Sr,all:Sr,some:Or,any:Or,contains:Mr,includes:Mr,include:Mr,invoke:Er,pluck:Br,where:function(n,r){return xr(n,Dn(r))},max:Nr,min:function(n,r,t){var e,u,o=1/0,i=1/0;if(null==r||"number"==typeof r&&"object"!=typeof n[0]&&null!=n)for(var a=0,f=(n=tr(n)?n:jn(n)).length;ae||void 0===t)return 1;if(tSubmodules
    -class deepsparse.benchmark.BatchBenchmarkResult(time_start: float, time_end: float, batch_size: int, inputs: Union[None, List[numpy.ndarray]] = None, outputs: Union[None, List[numpy.ndarray], Dict[str, numpy.ndarray]] = None, extras: Optional[Any] = None)[source]
    +class deepsparse.benchmark.BatchBenchmarkResult(time_start: float, time_end: float, batch_size: int, inputs: Union[None, List[numpy.ndarray]] = None, outputs: Union[None, List[numpy.ndarray], Dict[str, numpy.ndarray]] = None, extras: Optional[Any] = None)[source]

    Bases: object

    A benchmark result for a batched inference run

    @@ -237,7 +237,7 @@

    Submodules
    -property batch_size
    +property batch_size

    The size of the batch that was benchmarked

    Type
    @@ -248,7 +248,7 @@

    Submodules
    -property batches_per_second
    +property batches_per_second

    The number of batches that could be run in one second based on this result

    @@ -260,7 +260,7 @@

    Submodules
    -property extras
    +property extras

    Batch extras to store any other data for the run

    Type
    @@ -271,7 +271,7 @@

    Submodules
    -property inputs
    +property inputs

    Batch inputs that were given for the run, if any

    Type
    @@ -282,7 +282,7 @@

    Submodules
    -property items_per_second
    +property items_per_second

    The number of items that could be run in one second based on this result

    @@ -294,7 +294,7 @@

    Submodules
    -property ms_per_batch
    +property ms_per_batch

    The number of milliseconds it took to run the batch

    Type
    @@ -305,7 +305,7 @@

    Submodules
    -property ms_per_item
    +property ms_per_item

    The averaged number of milliseconds it took to run each item in the batch

    @@ -317,7 +317,7 @@

    Submodules
    -property outputs
    +property outputs

    Batch outputs that were given for the run, if any

    Type
    @@ -328,7 +328,7 @@

    Submodules
    -property time_elapsed
    +property time_elapsed

    The time elapsed for the entire run (end - start)

    Type
    @@ -339,7 +339,7 @@

    Submodules
    -property time_end
    +property time_end

    The system time when the run for the batch ended

    Type
    @@ -350,7 +350,7 @@

    Submodules
    -property time_start
    +property time_start

    The system time when the run for the batch was started

    Type
    @@ -363,12 +363,12 @@

    Submodules
    -class deepsparse.benchmark.BenchmarkResults[source]
    +class deepsparse.benchmark.BenchmarkResults[source]

    Bases: Iterable

    The benchmark results for a list of batched inference runs

    -append_batch(time_start: float, time_end: float, batch_size: int, inputs: Union[None, List[numpy.ndarray]] = None, outputs: Union[None, List[numpy.ndarray], Dict[str, numpy.ndarray]] = None, extras: Optional[Any] = None)[source]
    +append_batch(time_start: float, time_end: float, batch_size: int, inputs: Union[None, List[numpy.ndarray]] = None, outputs: Union[None, List[numpy.ndarray], Dict[str, numpy.ndarray]] = None, extras: Optional[Any] = None)[source]

    Add a recorded batch to the current results

    Parameters
    @@ -386,7 +386,7 @@

    Submodules
    -property batch_sizes
    +property batch_sizes

    the list of all batch run sizes that have been added

    Type
    @@ -397,7 +397,7 @@

    Submodules
    -property batch_times
    +property batch_times

    the list of all batch run times that have been added

    Type
    @@ -408,7 +408,7 @@

    Submodules
    -property batch_times_mean
    +property batch_times_mean

    the mean of all the batch run times that have been added

    Type
    @@ -419,7 +419,7 @@

    Submodules
    -property batch_times_median
    +property batch_times_median

    the median of all the batch run times that have been added

    Type
    @@ -430,7 +430,7 @@

    Submodules
    -property batch_times_std
    +property batch_times_std

    the standard deviation of all the batch run times that have been added

    Type
    @@ -441,7 +441,7 @@

    Submodules
    -property batches_per_second
    +property batches_per_second

    The number of batches that could be run in one second based on this result

    @@ -453,7 +453,7 @@

    Submodules
    -property inputs
    +property inputs

    Batch inputs that were given for the run, if any

    Type
    @@ -464,7 +464,7 @@

    Submodules
    -property items_per_second
    +property items_per_second

    The number of items that could be run in one second based on this result

    @@ -476,7 +476,7 @@

    Submodules
    -property ms_per_batch
    +property ms_per_batch

    The number of milliseconds it took to run the batch

    Type
    @@ -487,7 +487,7 @@

    Submodules
    -property ms_per_item
    +property ms_per_item

    The averaged number of milliseconds it took to run each item in the batch

    @@ -499,7 +499,7 @@

    Submodules
    -property num_batches
    +property num_batches

    the number of batches that have been added

    Type
    @@ -510,7 +510,7 @@

    Submodules
    -property num_items
    +property num_items

    the number of items across all batches that have been added

    Type
    @@ -521,7 +521,7 @@

    Submodules
    -property outputs
    +property outputs

    Batch outputs that were given for the run, if any

    Type
    @@ -532,7 +532,7 @@

    Submodules
    -property results
    +property results

    the list of recorded batch results

    Type
    @@ -549,7 +549,7 @@

    Submodules
    -deepsparse.cpu.cpu_details() → Tuple[int, str, bool][source]
    +deepsparse.cpu.cpu_details()Tuple[int, str, bool][source]

    Detect the CPU details on linux systems If any other OS is used, will raise an exception

    @@ -575,7 +575,7 @@

    Submodules
    -class deepsparse.engine.Engine(model: Union[str, sparsezoo.objects.model.Model, sparsezoo.objects.file.File], batch_size: int, num_cores: int, num_sockets: Optional[int] = None)[source]
    +class deepsparse.engine.Engine(model: Union[str, sparsezoo.objects.model.Model, sparsezoo.objects.file.File], batch_size: int, num_cores: int, num_sockets: Optional[int] = None)[source]

    Bases: object

    Create a new DeepSparse Engine that compiles the given onnx file for GPU class performance on commodity CPUs.

    @@ -608,7 +608,7 @@

    Submodules
    -property batch_size
    +property batch_size

    The batch size of the inputs to be used with the model

    Type
    @@ -619,7 +619,7 @@

    Submodules
    -benchmark(inp: List[numpy.ndarray], num_iterations: int = 20, num_warmup_iterations: int = 5, include_inputs: bool = False, include_outputs: bool = False, show_progress: bool = False)deepsparse.benchmark.BenchmarkResults[source]
    +benchmark(inp: List[numpy.ndarray], num_iterations: int = 20, num_warmup_iterations: int = 5, include_inputs: bool = False, include_outputs: bool = False, show_progress: bool = False)deepsparse.benchmark.BenchmarkResults[source]

    A convenience function for quickly benchmarking the instantiated model on a given input in the DeepSparse Engine. After executing, will return the summary statistics for benchmarking.

    @@ -649,7 +649,7 @@

    Submodules
    -benchmark_loader(loader: Iterable[List[numpy.ndarray]], num_iterations: int = 20, num_warmup_iterations: int = 5, include_inputs: bool = False, include_outputs: bool = False, show_progress: bool = False)deepsparse.benchmark.BenchmarkResults[source]
    +benchmark_loader(loader: Iterable[List[numpy.ndarray]], num_iterations: int = 20, num_warmup_iterations: int = 5, include_inputs: bool = False, include_outputs: bool = False, show_progress: bool = False)deepsparse.benchmark.BenchmarkResults[source]

    A convenience function for quickly benchmarking the instantiated model on a give DataLoader in the DeepSparse Engine. After executing, will return the summary statistics for benchmarking.

    @@ -679,7 +679,7 @@

    Submodules
    -property cpu_avx_type
    +property cpu_avx_type

    The detected cpu avx type that neural magic is running with. One of {avx2, avx512}. AVX instructions give significant execution speedup with avx512 > avx2.

    @@ -692,7 +692,7 @@

    Submodules
    -property cpu_vnni
    +property cpu_vnni

    True if vnni support was detected on the cpu, False otherwise. VNNI gives performance benefits for quantized networks.

    @@ -704,7 +704,7 @@

    Submodules
    -mapped_run(inp: List[numpy.ndarray], val_inp: bool = True) → Dict[str, numpy.ndarray][source]
    +mapped_run(inp: List[numpy.ndarray], val_inp: bool = True)Dict[str, numpy.ndarray][source]

    Run given inputs through the model for inference. Returns the result as a dictionary of numpy arrays corresponding to the output names of the model as defined in the ONNX graph.

    @@ -739,7 +739,7 @@

    Submodules
    -property model_path
    +property model_path

    The local path to the model file the current instance was compiled from

    Type
    @@ -750,7 +750,7 @@

    Submodules
    -property num_cores
    +property num_cores

    The number of physical cores the current instance is running on

    Type
    @@ -761,7 +761,7 @@

    Submodules
    -property num_sockets
    +property num_sockets

    The number of sockets the engine is compiled to run on; only current support is 1

    @@ -773,7 +773,7 @@

    Submodules
    -run(inp: List[numpy.ndarray], val_inp: bool = True) → List[numpy.ndarray][source]
    +run(inp: List[numpy.ndarray], val_inp: bool = True)List[numpy.ndarray][source]

    Run given inputs through the model for inference. Returns the result as a list of numpy arrays corresponding to the outputs of the model as defined in the ONNX graph.

    @@ -814,7 +814,7 @@

    Submodules
    -timed_run(inp: List[numpy.ndarray], val_inp: bool = True) → Tuple[List[numpy.ndarray], float][source]
    +timed_run(inp: List[numpy.ndarray], val_inp: bool = True)Tuple[List[numpy.ndarray], float][source]

    Convenience method for timing a model inference run. Returns the result as a tuple containing (the outputs from @run, time take)

    See @run for more details.

    @@ -847,7 +847,7 @@

    Submodules
    -deepsparse.engine.analyze_model(model: Union[str, sparsezoo.objects.model.Model, sparsezoo.objects.file.File], inp: List[numpy.ndarray], batch_size: int = 1, num_cores: Optional[int] = None, num_iterations: int = 20, num_warmup_iterations: int = 5, optimization_level: int = 1, imposed_as: Optional[float] = None, imposed_ks: Optional[float] = None, num_sockets: Optional[int] = None) → dict[source]
    +deepsparse.engine.analyze_model(model: Union[str, sparsezoo.objects.model.Model, sparsezoo.objects.file.File], inp: List[numpy.ndarray], batch_size: int = 1, num_cores: Optional[int] = None, num_iterations: int = 20, num_warmup_iterations: int = 5, optimization_level: int = 1, imposed_as: Optional[float] = None, imposed_ks: Optional[float] = None, num_sockets: Optional[int] = None)dict[source]

    Function to analyze a model’s performance in the DeepSparse Engine. The model must be defined in an ONNX graph and stored in a local file. Gives defaults of batch_size == 1 and num_cores == None @@ -891,7 +891,7 @@

    Submodules
    -deepsparse.engine.benchmark_model(model: Union[str, sparsezoo.objects.model.Model, sparsezoo.objects.file.File], inp: List[numpy.ndarray], batch_size: int = 1, num_cores: Optional[int] = None, num_iterations: int = 20, num_warmup_iterations: int = 5, include_inputs: bool = False, include_outputs: bool = False, show_progress: bool = False, num_sockets: Optional[int] = None)deepsparse.benchmark.BenchmarkResults[source]
    +deepsparse.engine.benchmark_model(model: Union[str, sparsezoo.objects.model.Model, sparsezoo.objects.file.File], inp: List[numpy.ndarray], batch_size: int = 1, num_cores: Optional[int] = None, num_iterations: int = 20, num_warmup_iterations: int = 5, include_inputs: bool = False, include_outputs: bool = False, show_progress: bool = False, num_sockets: Optional[int] = None)deepsparse.benchmark.BenchmarkResults[source]

    Convenience function to benchmark a model in the DeepSparse Engine from an ONNX file for inference. Gives defaults of batch_size == 1 and num_cores == None @@ -932,7 +932,7 @@

    Submodules
    -deepsparse.engine.compile_model(model: Union[str, sparsezoo.objects.model.Model, sparsezoo.objects.file.File], batch_size: int = 1, num_cores: Optional[int] = None, num_sockets: Optional[int] = None)deepsparse.engine.Engine[source]
    +deepsparse.engine.compile_model(model: Union[str, sparsezoo.objects.model.Model, sparsezoo.objects.file.File], batch_size: int = 1, num_cores: Optional[int] = None, num_sockets: Optional[int] = None)deepsparse.engine.Engine[source]

    Convenience function to compile a model in the DeepSparse Engine from an ONNX file for inference. Gives defaults of batch_size == 1 and num_cores == None @@ -963,7 +963,7 @@

    Submodules

    deepsparse.lib module

    -deepsparse.lib.init_deepsparse_lib()[source]
    +deepsparse.lib.init_deepsparse_lib()[source]
    diff --git a/deepsparse/api/deepsparse.utils.html b/deepsparse/api/deepsparse.utils.html index 9bc63bfc8cd..c4abdd470a0 100644 --- a/deepsparse/api/deepsparse.utils.html +++ b/deepsparse/api/deepsparse.utils.html @@ -212,7 +212,7 @@

    Submodules

    deepsparse.utils.data module

    -deepsparse.utils.data.verify_outputs(outputs: List[numpy.array], gt_outputs: List[numpy.array], atol: float = 0.0008, rtol: float = 0.0) → List[float][source]
    +deepsparse.utils.data.verify_outputs(outputs: List[numpy.array], gt_outputs: List[numpy.array], atol: float = 0.0008, rtol: float = 0.0)List[float][source]

    Compares two lists of output tensors, checking that they are sufficiently similar :param outputs: List of numpy arrays, usually model outputs :param gt_outputs: List of numpy arrays, usually reference outputs @@ -226,7 +226,7 @@

    Submodules

    deepsparse.utils.log module

    -deepsparse.utils.log.log_init(name)[source]
    +deepsparse.utils.log.log_init(name)[source]
    @@ -234,7 +234,7 @@

    Submodules

    deepsparse.utils.onnx module

    -deepsparse.utils.onnx.generate_random_inputs(onnx_filepath: str, batch_size: Optional[int] = None) → List[numpy.array][source]
    +deepsparse.utils.onnx.generate_random_inputs(onnx_filepath: str, batch_size: Optional[int] = None)List[numpy.array][source]

    Generate random data that matches the type and shape of ONNX model, with a batch size override :param onnx_filepath: File path to ONNX model @@ -244,7 +244,7 @@

    Submodules
    -deepsparse.utils.onnx.get_external_inputs(onnx_filepath: str) → List[source]
    +deepsparse.utils.onnx.get_external_inputs(onnx_filepath: str)List[source]

    Gather external inputs of ONNX model :param onnx_filepath: File path to ONNX model :return: List of input objects

    @@ -252,7 +252,7 @@

    Submodules
    -deepsparse.utils.onnx.get_external_outputs(onnx_filepath: str) → List[source]
    +deepsparse.utils.onnx.get_external_outputs(onnx_filepath: str)List[source]

    Gather external outputs of ONNX model :param onnx_filepath: File path to ONNX model :return: List of output objects

    @@ -260,7 +260,7 @@

    Submodules
    -deepsparse.utils.onnx.get_input_names(onnx_filepath: str) → List[str][source]
    +deepsparse.utils.onnx.get_input_names(onnx_filepath: str)List[str][source]

    Gather names of all external inputs of ONNX model :param onnx_filepath: File path to ONNX model :return: List of string names

    @@ -268,7 +268,7 @@

    Submodules
    -deepsparse.utils.onnx.get_output_names(onnx_filepath: str) → List[str][source]
    +deepsparse.utils.onnx.get_output_names(onnx_filepath: str)List[str][source]

    Gather names of all external outputs of ONNX model :param onnx_filepath: File path to ONNX model :return: List of string names

    @@ -276,7 +276,7 @@

    Submodules
    -deepsparse.utils.onnx.override_onnx_batch_size(onnx_filepath: str, batch_size: int)[source]
    +deepsparse.utils.onnx.override_onnx_batch_size(onnx_filepath: str, batch_size: int)[source]

    Rewrite batch sizes of ONNX model, saving the modified model and returning its path :param onnx_filepath: File path to ONNX model :param batch_size: Override for the batch size dimension diff --git a/deepsparse/searchindex.js b/deepsparse/searchindex.js index f6df4f690a1..cb63ab698b3 100644 --- a/deepsparse/searchindex.js +++ b/deepsparse/searchindex.js @@ -1 +1 @@ -Search.setIndex({docnames:["api/deepsparse","api/deepsparse.utils","api/modules","debugging-optimizing/diagnostics-debugging","debugging-optimizing/example-log","debugging-optimizing/index","debugging-optimizing/numactl-utility","hardware","index","installation","quicktour"],envversion:{"sphinx.domains.c":2,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":3,"sphinx.domains.index":1,"sphinx.domains.javascript":2,"sphinx.domains.math":2,"sphinx.domains.python":2,"sphinx.domains.rst":2,"sphinx.domains.std":1,"sphinx.ext.intersphinx":1,"sphinx.ext.viewcode":1,sphinx:56},filenames:["api/deepsparse.rst","api/deepsparse.utils.rst","api/modules.rst","debugging-optimizing/diagnostics-debugging.md","debugging-optimizing/example-log.md","debugging-optimizing/index.rst","debugging-optimizing/numactl-utility.md","hardware.md","index.rst","installation.md","quicktour.md"],objects:{"":{deepsparse:[0,0,0,"-"]},"deepsparse.benchmark":{BatchBenchmarkResult:[0,1,1,""],BenchmarkResults:[0,1,1,""]},"deepsparse.benchmark.BatchBenchmarkResult":{batch_size:[0,2,1,""],batches_per_second:[0,2,1,""],extras:[0,2,1,""],inputs:[0,2,1,""],items_per_second:[0,2,1,""],ms_per_batch:[0,2,1,""],ms_per_item:[0,2,1,""],outputs:[0,2,1,""],time_elapsed:[0,2,1,""],time_end:[0,2,1,""],time_start:[0,2,1,""]},"deepsparse.benchmark.BenchmarkResults":{append_batch:[0,2,1,""],batch_sizes:[0,2,1,""],batch_times:[0,2,1,""],batch_times_mean:[0,2,1,""],batch_times_median:[0,2,1,""],batch_times_std:[0,2,1,""],batches_per_second:[0,2,1,""],inputs:[0,2,1,""],items_per_second:[0,2,1,""],ms_per_batch:[0,2,1,""],ms_per_item:[0,2,1,""],num_batches:[0,2,1,""],num_items:[0,2,1,""],outputs:[0,2,1,""],results:[0,2,1,""]},"deepsparse.cpu":{cpu_details:[0,3,1,""]},"deepsparse.engine":{Engine:[0,1,1,""],analyze_model:[0,3,1,""],benchmark_model:[0,3,1,""],compile_model:[0,3,1,""]},"deepsparse.engine.Engine":{batch_size:[0,2,1,""],benchmark:[0,2,1,""],benchmark_loader:[0,2,1,""],cpu_avx_type:[0,2,1,""],cpu_vnni:[0,2,1,""],mapped_run:[0,2,1,""],model_path:[0,2,1,""],num_cores:[0,2,1,""],num_sockets:[0,2,1,""],run:[0,2,1,""],timed_run:[0,2,1,""]},"deepsparse.lib":{init_deepsparse_lib:[0,3,1,""]},"deepsparse.utils":{data:[1,0,0,"-"],log:[1,0,0,"-"],onnx:[1,0,0,"-"]},"deepsparse.utils.data":{verify_outputs:[1,3,1,""]},"deepsparse.utils.log":{log_init:[1,3,1,""]},"deepsparse.utils.onnx":{generate_random_inputs:[1,3,1,""],get_external_inputs:[1,3,1,""],get_external_outputs:[1,3,1,""],get_input_names:[1,3,1,""],get_output_names:[1,3,1,""],override_onnx_batch_size:[1,3,1,""]},deepsparse:{benchmark:[0,0,0,"-"],cpu:[0,0,0,"-"],engine:[0,0,0,"-"],lib:[0,0,0,"-"],utils:[1,0,0,"-"],version:[0,0,0,"-"]}},objnames:{"0":["py","module","Python module"],"1":["py","class","Python class"],"2":["py","method","Python method"],"3":["py","function","Python function"]},objtypes:{"0":"py:module","1":"py:class","2":"py:method","3":"py:function"},terms:{"0008":1,"100":10,"104":4,"112":4,"121":4,"122":[3,4],"124":4,"126":4,"129":4,"130":4,"132":4,"140":4,"157":4,"224":[0,3,4,10],"242":4,"25690112":4,"265":[3,4],"276":4,"321":[3,4],"33918976":4,"478":[3,4],"512":7,"595":4,"604":4,"644":4,"652":4,"667":4,"672":4,"679":4,"684":4,"706":[3,4],"715":[3,4],"723":[3,4],"757396":4,"7f4fbbd3f740":[3,4],"96ce2f6cb23b8ab377012ed9ef38d3da3b9f5313":4,"case":[0,6],"class":[0,8],"const":[3,4],"default":[0,3,4],"export":[3,4,6,8],"final":8,"float":[0,1,3,4],"function":0,"import":10,"int":[0,1],"new":[0,3,4],"return":[0,1],"super":[3,4],"true":0,"try":[6,10],"while":[0,8],For:[3,6,8,10],Ice:7,Its:3,One:[0,6],The:[0,1,3,4,6,7,8,10],Then:[3,9],There:3,These:0,Useful:0,Using:[5,8],Will:0,about:6,abov:6,absolut:1,acceler:8,accept:10,accuraci:[8,10],achiev:[0,6],across:0,activ:[0,7,8],add:[0,3],added:0,addit:[5,8,9],addition:8,advantag:8,advis:6,affect:0,after:[0,3,6],against:3,aggress:10,agreement:3,algorithm:7,all:[0,1,3,6,8],allclos:1,alloc:[3,6],allocate_buffers_pass:4,allow:[3,6,8],along:8,also:6,altern:[3,8],amd:[6,7],amount:[0,5,6,8],analysi:0,analyz:[0,3],analyze_model:0,ani:[0,6,9],anoth:6,api:8,append:6,append_batch:0,appli:8,applic:3,approach:8,architectur:[3,6],arrai:[0,1],art:10,ascontiguousarrai:0,assert:0,assign:3,associ:3,assum:0,astyp:[0,10],atol:1,augment:10,avail:[0,3,6,7,10],averag:0,avoid:0,avx2:[0,7],avx512:[0,4],avx:[0,7],backend:8,bar:0,base:[0,10],baselin:[8,10],basi:3,batch:[0,1,4,5,6],batch_siz:[0,1,10],batch_tim:0,batch_times_mean:0,batch_times_median:0,batch_times_std:0,batchbenchmarkresult:0,batches_per_second:0,been:[0,6],befor:[0,3],begin:[3,4],behavior:3,being:6,below:3,benchmark:[2,8,10],benchmark_load:0,benchmark_model:0,benchmarkresult:0,benchmarks_bas:10,benchmarks_spars:10,benefici:0,benefit:[0,3],best:[0,6],better:6,between:[3,6],bia:[3,4],binari:4,bind:[3,6],block:3,blog:8,bool:0,boost:7,both:0,bound:[6,8],bring:0,broadwel:7,bsd300:4,buffer:4,bug:8,build:[3,8],built:0,calc:[3,4],can:[0,3,6,8,10],cannon:7,cannot:4,captur:3,care:6,cascad:7,certain:[0,3],channel:0,check:1,choic:0,choos:10,classif:10,clone:9,close:10,code:[0,3,4,8],com:[3,10],command:3,commod:0,common:[0,3],commun:3,compar:[0,1,10],compat:10,compil:[0,4,5,10],compile_model:[0,10],complex:3,complic:3,comput:[6,8],compute_func:[3,4],conflict:3,connect:3,consecut:6,consent:3,conserv:10,consider:6,constant:[3,4],construct:4,construct_subgraph:4,consult:3,contain:[0,3],content:[2,3,8],contigu:0,control:[5,8],conv1:[3,4],conv2:[3,4],conv3:[3,4],conv4:[3,4],conv:[3,4],conveni:0,convolut:3,cooper:7,core:[0,4,5,6],correctli:[0,8],correspond:0,could:[0,6],count:0,cours:6,cpu:[2,6,7,8,10],cpu_avx_typ:0,cpu_detail:0,cpu_vnni:[0,10],cpunodebind:6,creat:[0,3,4,8],current:[0,6],custom:8,data:[0,2,3],data_input:10,dataload:0,dataset:[3,8],debian:9,debug:8,decid:3,decis:3,deep:8,deepspars:[5,7,9,10],deepsparseengin:[3,6],defens:3,defin:0,definit:0,degrad:[3,6],deliv:8,dens:10,depend:9,deploi:8,deploy:[3,8],describ:[3,6],design:3,desir:[0,6],detail:[0,3,6,7],detect:[0,10],determin:5,dev:8,deviat:0,diagnos:[3,5,8],diagnost:[5,8],dict:0,dictionari:0,differ:[1,3,4,6,7],dimens:[0,1],direct:8,disabl:[3,6],displai:[0,3,6],divis:6,doc:8,document:8,doe:6,doing:6,download:[8,10],driven:8,due:3,dure:[0,6],dynam:3,each:[0,1,5,6],easili:8,ecosystem:3,edit:8,effect:8,either:0,elaps:0,elementwis:[3,4],empti:4,emul:7,enabl:[5,6,7,8,10],encod:8,encompass:8,end:[0,3,4,6],engin:[2,4,5,7,8,10],engine_bas:10,engine_spars:10,ensur:0,entir:[0,3],environ:[0,3,6,9],error:3,evenli:6,everyth:8,exampl:[0,5,6,8,9],except:0,execut:[0,4,5,6,10],exist:8,expect:0,expedit:10,explain:[3,4],explor:[9,10],extens:7,extern:1,extra:[0,8],fals:0,faster:[8,10],fatal:3,featur:8,fetch:10,few:8,fft:8,file:[0,1,3,10],filter:4,find:[5,10],fine:6,finish:4,first:[0,3,6],fit:8,fix:0,float32:[0,10],flow:8,focus:8,follow:[3,4,6],forc:[0,6],format:[0,8],forward:0,found:8,four:6,fp32:10,framework:8,from:[0,3,4,6,8,10],full:8,func:0,further:6,gather:1,gener:[0,1,3,4,8,10],generate_random_input:[1,10],get:[3,8],get_external_input:1,get_external_output:1,get_input_nam:1,get_output_nam:1,getcap:4,github:[8,10],give:[0,8],given:[0,6],gpu:[0,8],grain:6,graph:[0,4,5],graph_util:[3,4],graphview:[3,4],greater:[3,4],gt_output:1,guid:3,guidanc:[5,8],hardwar:[6,8,10],has:6,haswel:7,have:[0,6],height:0,help:8,here:[6,7,10],highli:7,hit:[0,3],home:[3,4],host:[8,10],how:[0,3,8,10],howev:6,hpp:4,http:[3,10],hurt:3,hyper:6,hyperthread:6,ideal:[3,6],idl:6,ignor:4,imagenet:10,implement:8,impos:0,imposed_a:0,imposed_k:0,improv:[6,8],includ:[3,4,8,10],include_input:0,include_output:0,increas:3,incur:0,indic:3,induc:8,infer:[0,3,8,10],inferenc:8,inference_tim:10,info:4,inform:[0,3,8],ingest:8,init_deepsparse_lib:0,initi:3,inp:0,input:[0,1,3,4,10],input_data:4,instal:8,instanc:[0,3],instanti:0,instruct:[0,7,10],int16:0,int8:[0,10],intak:[3,4],intel:[6,7],intend:6,interfac:0,inventori:6,isinst:0,issu:3,item:0,items_per_second:[0,10],iter:0,its:1,jdoe:[3,4],jit:[3,4],just:8,keep:9,kera:8,kernel:[0,3,4,7],lake:7,larger:6,layer:0,learn:3,legal:3,level:[0,3,5,8],lib:[2,8],like:[3,6,9],limit:8,line:[3,8],linux:[0,7,9],list:[0,1,3],load:3,loader:0,local:0,locat:[3,6],log:[0,2,5,8],log_init:1,logic:6,look:3,machin:[0,3,8,10],macro:3,made:3,magic:[0,3,8],mai:[3,6],main:3,major:[3,6],make:3,man:6,manag:3,mani:[3,8],manual:3,map:6,mapped_run:0,master:10,match:[0,1,4],max:[0,1],maxim:3,maximum:6,mean:0,median:0,membind:6,memori:[0,6,8],method:0,metric:8,microarchitectur:7,migrat:[3,6],millisecond:0,minim:0,mobilenet:10,mobilenetv2:10,model:[0,1,3,4,6,8],model_path:0,moder:10,modifi:1,modul:[2,8],monitor:3,monopol:3,more:[0,6],most:0,ms_per_batch:0,ms_per_item:0,multi:[0,6],multipl:6,must:0,name:[0,1],name_of_log:3,natur:8,ndarrai:0,nearli:[8,10],need:6,network:[0,3,4,8],neural:[0,3,8],neuralmag:[3,4],neuralmagic_cr:4,neuralmagic_execut:4,newer:7,nightli:8,nm_arch:0,nm_bind_threads_to_cor:[3,6],nm_exec_test_it:4,nm_execution_provid:[3,4],nm_logging_level:[3,4],nm_ogging_level:3,nm_ort:[3,4],nm_subgraph:3,nm_subgraph_1:[3,4],nmexecutionprovid:4,node:[4,5],non:4,none:[0,1,4,10],normal:3,notabl:3,note:[0,3,5,8],notebook:9,notic:8,num_batch:0,num_cor:0,num_item:0,num_iter:0,num_socket:0,num_warmup_iter:0,numactl:[5,8],number:[0,5,6],numpi:[0,1,10],nyann:[3,4],object:[0,1],obtain:5,occur:8,offer:6,offici:8,onc:3,one:[0,3,6,8],onli:[0,3,4,6,8],onnx:[0,2,4,8],onnx_filenam:4,onnx_filepath:[1,10],onnxruntime_neuralmag:[3,4],openmp:3,oper:[3,4,7],ops:[3,4],optim:[0,4,6,7,8,10],optimization_level:0,option:[0,1,6],order:[0,3,9],ort:[3,4],other:[0,3,6,8,10],otherwis:0,our:5,out:[0,3,6],output:[0,1,3,4,10],output_data:4,outsid:6,over:[0,6,7,8],overprecis:8,overrid:[0,1],override_onnx_batch_s:1,own:6,packag:[2,8,10],pad:[3,4],page:6,pair:1,param:1,paramet:[0,3,6],parameter:8,pars:[4,5,8],part:3,particular:6,pass:0,path:[0,1],pattern:4,per:[0,3,6],percentag:[0,3],perform:[0,5,6,8,10],physcpubind:6,physic:[0,6],pin:[3,5,8],pinpoint:3,pip:9,pipelin:[3,8],planner:4,pleas:0,plu:8,plug:10,point:3,polici:3,pool:3,portion:[3,4],possibl:3,practic:3,pre:10,predict:10,prefer:6,prefix:0,prepar:8,prevent:[3,6],print:[3,4,10],privaci:3,process:[3,6,8],produc:[5,8],product:8,progress:0,properti:0,provid:[1,3,4],prunabl:0,prune:[0,8,10],pruned_qu:10,pypi:8,python:[0,3,9],pytorch:[8,10],quant:10,quantiz:[0,7,8,10],quick:8,quickli:[0,8,10],quickstart:8,rais:0,rand:0,randn:10,random:[0,1,4,10],rang:6,ratio:4,raw:10,real:[3,10],recip:[8,10],recommend:[0,3,7,9],record:0,recov:[8,10],reduc:8,redund:8,refer:1,regular:0,rel:1,relat:0,relu:[0,3,4],remov:8,repeat:[0,10],repo:4,report:3,repositori:[8,9],request:8,requir:[4,6,8,9],reshap:[3,4],resnet:10,resnet_50:10,resnet_v1:10,resolut:[3,4],resourc:[3,5],respect:10,restrict:6,result:[0,3,6,8],reveal:3,review:3,rewrit:1,rtol:1,run:[0,3,4,6,7,10],run_model:3,runtim:[4,5,8],same:[6,8],sampl:[3,10],sample_batch:10,sample_input:10,save:[1,10],scale:8,scarc:3,scenario:6,scienc:3,script:3,seamlessli:8,search_optimized_model:10,second:[0,6],section:10,see:[0,3,6,10],seek:3,select:6,self:3,separ:6,serv:3,set:[0,3,6,10],setup:[0,6],sever:3,shape:[1,3,4],share:[3,6,10],shell:3,ship:3,should:6,show:[3,6],show_progress:0,shuffl:0,signific:0,significantli:8,similar:1,similarli:6,simpl:8,simpli:10,simplif:3,sinc:6,singl:[0,6],size:[0,1,4,5,6],skylak:7,smaller:8,smt:6,socket:[0,6],softwar:3,solut:10,some:[0,3,7],sourc:[0,1],spars:[7,8,10],sparseml:[8,10],sparsezoo:[0,8],sparsif:10,sparsifi:[8,10],sparsiti:[0,7,8],specif:[0,6,7],specifi:[3,6],speedup:[0,10],split:3,src:[3,4],stabl:8,standard:[0,6],start:[0,3,4,6,8],startup:6,state:[0,3,10],statement:3,statist:[0,5],stderr:3,steadi:0,step:8,store:0,str:[0,1],straightforward:6,stride:[3,4],string:1,structur:0,stub:[0,10],subgraph:[4,5],submodul:[2,8],subpackag:[2,8],suffici:1,suit:8,summari:0,super_resolut:4,support:[0,4,5,8,10],supported_subgraph:[3,4],system:[0,3,4,6,7,9],tabl:7,tag:10,take:[0,8],target:10,tbb:3,technic:3,techniqu:[8,10],tensor:[0,1,3],tensorflow:8,test:[4,9],test_1:4,than:[3,4,6,10],thei:[1,3],them:3,thi:[0,3,6,8,9,10],thread:[3,5,8],through:[0,6],tiger:7,time:[0,5],time_elaps:0,time_end:0,time_start:0,timed_run:[0,10],toler:1,too:10,took:0,top:8,torch:[3,4],total:4,tour:8,tradit:3,train:[3,8,10],translat:[3,4],transpos:[3,4],troubleshoot:3,truncat:3,tune:[5,8],tupl:0,two:[1,6,10],txt:3,type:[0,1,3],union:0,uniqu:3,unit:4,unlik:3,unoptim:3,unsupport:[3,4],use:[0,3,6,10],used:[0,6],using:[0,3,4,6,8,9,10],usual:[1,6],util:[0,2,3,4,5,8,10],val_inp:0,valid:[0,7],validate_minimum_supported_fract:[3,4],valu:[3,4],variabl:[0,3,6],variou:3,vector:0,verbos:[3,5,8],veri:[3,10],verify_output:1,version:[2,4,8,10],via:8,view:5,virtual:9,vision:10,vnni:[0,7,10],wai:6,wand:4,want:3,warm:0,warn:[3,4,10],websit:8,weight:[0,3,4],well:[6,8,10],were:0,wget:10,what:[0,3,10],when:[0,6,8,10],where:[3,4,6],whether:3,which:[3,6],whole:5,width:0,winograd:8,within:[3,8],work:[6,7,8],workload:8,would:[3,6,9],x86:7,yet:0,you:[0,3,6,8,9,10],your:[3,6,8,9,10],zen:7,zoo:[0,10]},titles:["deepsparse package","deepsparse.utils package","deepsparse","Logging Guidance for Diagnostics and Debugging","Example Log, Verbose Level = diagnose","Debugging and Optimizing","Using the numactl Utility to Control Resource Utilization with the DeepSparse Engine","Hardware Support","DeepSparse 0.1","Installation","Quick Tour"],titleterms:{Using:6,addit:6,amount:3,batch:3,benchmark:0,compat:8,compil:3,content:[0,1],control:[3,6],core:3,cpu:0,custom:10,data:1,debug:[3,5],deepspars:[0,1,2,3,6,8],determin:3,diagnos:4,diagnost:3,each:3,enabl:3,engin:[0,3,6],exampl:[3,4],execut:3,find:3,graph:3,guidanc:3,hardwar:7,histori:8,instal:9,learn:8,level:4,lib:0,log:[1,3,4],model:10,modul:[0,1],more:8,node:3,note:6,numactl:6,number:3,obtain:3,onnx:[1,10],optim:[3,5],our:3,overview:8,packag:[0,1],pars:3,perform:3,pin:6,produc:3,quick:10,quickstart:10,releas:8,resourc:[6,8],runtim:3,size:3,sparsezoo:10,sparsif:8,statist:3,subgraph:3,submodul:[0,1],subpackag:0,support:[3,7],thread:6,time:3,tour:10,tune:3,util:[1,6],verbos:4,version:0,view:3,whole:3}}) \ No newline at end of file +Search.setIndex({docnames:["api/deepsparse","api/deepsparse.utils","api/modules","debugging-optimizing/diagnostics-debugging","debugging-optimizing/example-log","debugging-optimizing/index","debugging-optimizing/numactl-utility","hardware","index","installation","quicktour"],envversion:{"sphinx.domains.c":2,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":3,"sphinx.domains.index":1,"sphinx.domains.javascript":2,"sphinx.domains.math":2,"sphinx.domains.python":2,"sphinx.domains.rst":2,"sphinx.domains.std":2,"sphinx.ext.intersphinx":1,"sphinx.ext.viewcode":1,sphinx:56},filenames:["api/deepsparse.rst","api/deepsparse.utils.rst","api/modules.rst","debugging-optimizing/diagnostics-debugging.md","debugging-optimizing/example-log.md","debugging-optimizing/index.rst","debugging-optimizing/numactl-utility.md","hardware.md","index.rst","installation.md","quicktour.md"],objects:{"":{deepsparse:[0,0,0,"-"]},"deepsparse.benchmark":{BatchBenchmarkResult:[0,1,1,""],BenchmarkResults:[0,1,1,""]},"deepsparse.benchmark.BatchBenchmarkResult":{batch_size:[0,2,1,""],batches_per_second:[0,2,1,""],extras:[0,2,1,""],inputs:[0,2,1,""],items_per_second:[0,2,1,""],ms_per_batch:[0,2,1,""],ms_per_item:[0,2,1,""],outputs:[0,2,1,""],time_elapsed:[0,2,1,""],time_end:[0,2,1,""],time_start:[0,2,1,""]},"deepsparse.benchmark.BenchmarkResults":{append_batch:[0,2,1,""],batch_sizes:[0,2,1,""],batch_times:[0,2,1,""],batch_times_mean:[0,2,1,""],batch_times_median:[0,2,1,""],batch_times_std:[0,2,1,""],batches_per_second:[0,2,1,""],inputs:[0,2,1,""],items_per_second:[0,2,1,""],ms_per_batch:[0,2,1,""],ms_per_item:[0,2,1,""],num_batches:[0,2,1,""],num_items:[0,2,1,""],outputs:[0,2,1,""],results:[0,2,1,""]},"deepsparse.cpu":{cpu_details:[0,3,1,""]},"deepsparse.engine":{Engine:[0,1,1,""],analyze_model:[0,3,1,""],benchmark_model:[0,3,1,""],compile_model:[0,3,1,""]},"deepsparse.engine.Engine":{batch_size:[0,2,1,""],benchmark:[0,2,1,""],benchmark_loader:[0,2,1,""],cpu_avx_type:[0,2,1,""],cpu_vnni:[0,2,1,""],mapped_run:[0,2,1,""],model_path:[0,2,1,""],num_cores:[0,2,1,""],num_sockets:[0,2,1,""],run:[0,2,1,""],timed_run:[0,2,1,""]},"deepsparse.lib":{init_deepsparse_lib:[0,3,1,""]},"deepsparse.utils":{data:[1,0,0,"-"],log:[1,0,0,"-"],onnx:[1,0,0,"-"]},"deepsparse.utils.data":{verify_outputs:[1,3,1,""]},"deepsparse.utils.log":{log_init:[1,3,1,""]},"deepsparse.utils.onnx":{generate_random_inputs:[1,3,1,""],get_external_inputs:[1,3,1,""],get_external_outputs:[1,3,1,""],get_input_names:[1,3,1,""],get_output_names:[1,3,1,""],override_onnx_batch_size:[1,3,1,""]},deepsparse:{benchmark:[0,0,0,"-"],cpu:[0,0,0,"-"],engine:[0,0,0,"-"],lib:[0,0,0,"-"],utils:[1,0,0,"-"],version:[0,0,0,"-"]}},objnames:{"0":["py","module","Python module"],"1":["py","class","Python class"],"2":["py","method","Python method"],"3":["py","function","Python function"]},objtypes:{"0":"py:module","1":"py:class","2":"py:method","3":"py:function"},terms:{"0008":1,"100":10,"104":4,"112":4,"121":4,"122":[3,4],"124":4,"126":4,"129":4,"130":4,"132":4,"140":4,"157":4,"224":[0,3,4,10],"242":4,"25690112":4,"265":[3,4],"276":4,"321":[3,4],"33918976":4,"478":[3,4],"512":7,"595":4,"604":4,"644":4,"652":4,"667":4,"672":4,"679":4,"684":4,"706":[3,4],"715":[3,4],"723":[3,4],"757396":4,"7f4fbbd3f740":[3,4],"96ce2f6cb23b8ab377012ed9ef38d3da3b9f5313":4,"case":[0,6],"class":[0,8],"const":[3,4],"default":[0,3,4],"export":[3,4,6,8],"final":8,"float":[0,1,3,4],"function":0,"import":10,"int":[0,1],"new":[0,3,4],"return":[0,1],"super":[3,4],"true":0,"try":[6,10],"while":[0,8],For:[3,6,8,10],Ice:7,Its:3,One:[0,6],The:[0,1,3,4,6,7,8,10],Then:[3,9],There:3,These:0,Useful:0,Using:[5,8],Will:0,about:6,abov:6,absolut:1,acceler:8,accept:10,accuraci:[8,10],achiev:[0,6],across:0,activ:[0,7,8],add:[0,3],added:0,addit:[5,8,9],addition:8,advantag:8,advis:6,affect:0,after:[0,3,6],against:3,aggress:10,agreement:3,algorithm:7,all:[0,1,3,6,8],allclos:1,alloc:[3,6],allocate_buffers_pass:4,allow:[3,6,8],along:8,also:6,altern:[3,8],amd:[6,7],amount:[0,5,6,8],analysi:0,analyz:[0,3],analyze_model:0,ani:[0,6,9],anoth:6,api:8,append:6,append_batch:0,appli:8,applic:3,approach:8,architectur:[3,6],arrai:[0,1],art:10,ascontiguousarrai:0,assert:0,assign:3,associ:3,assum:0,astyp:[0,10],atol:1,augment:10,avail:[0,3,6,7,10],averag:0,avoid:0,avx2:[0,7],avx512:[0,4],avx:[0,7],backend:8,bar:0,base:[0,10],baselin:[8,10],basi:3,batch:[0,1,4,5,6],batch_siz:[0,1,10],batch_tim:0,batch_times_mean:0,batch_times_median:0,batch_times_std:0,batchbenchmarkresult:0,batches_per_second:0,been:[0,6],befor:[0,3],begin:[3,4],behavior:3,being:6,below:3,benchmark:[2,8,10],benchmark_load:0,benchmark_model:0,benchmarkresult:0,benchmarks_bas:10,benchmarks_spars:10,benefici:0,benefit:[0,3],best:[0,6],better:6,between:[3,6],bia:[3,4],binari:4,bind:[3,6],block:3,blog:8,bool:0,boost:7,both:0,bound:[6,8],bring:0,broadwel:7,bsd300:4,buffer:4,bug:8,build:[3,8],built:0,calc:[3,4],can:[0,3,6,8,10],cannon:7,cannot:4,captur:3,care:6,cascad:7,certain:[0,3],channel:0,check:1,choic:0,choos:10,classif:10,clone:9,close:10,code:[0,3,4,8],com:[3,10],command:3,commod:0,common:[0,3],commun:3,compar:[0,1,10],compat:10,compil:[0,4,5,10],compile_model:[0,10],complex:3,complic:3,comput:[6,8],compute_func:[3,4],conflict:3,connect:3,consecut:6,consent:3,conserv:10,consider:6,constant:[3,4],construct:4,construct_subgraph:4,consult:3,contain:[0,3],content:[2,3,8],contigu:0,control:[5,8],conv1:[3,4],conv2:[3,4],conv3:[3,4],conv4:[3,4],conv:[3,4],conveni:0,convolut:3,cooper:7,core:[0,4,5,6],correctli:[0,8],correspond:0,could:[0,6],count:0,cours:6,cpu:[2,6,7,8,10],cpu_avx_typ:0,cpu_detail:0,cpu_vnni:[0,10],cpunodebind:6,creat:[0,3,4,8],current:[0,6],custom:8,data:[0,2,3],data_input:10,dataload:0,dataset:[3,8],debian:9,debug:8,decid:3,decis:3,deep:8,deepspars:[5,7,9,10],deepsparseengin:[3,6],defens:3,defin:0,definit:0,degrad:[3,6],deliv:8,dens:10,depend:9,deploi:8,deploy:[3,8],describ:[3,6],design:3,desir:[0,6],detail:[0,3,6,7],detect:[0,10],determin:5,dev:8,deviat:0,diagnos:[3,5,8],diagnost:[5,8],dict:0,dictionari:0,differ:[1,3,4,6,7],dimens:[0,1],direct:8,disabl:[3,6],displai:[0,3,6],divis:6,doc:8,document:8,doe:6,doing:6,download:[8,10],driven:8,due:3,dure:[0,6],dynam:3,each:[0,1,5,6],easili:8,ecosystem:3,edit:8,effect:8,either:0,elaps:0,elementwis:[3,4],empti:4,emul:7,enabl:[5,6,7,8,10],encod:8,encompass:8,end:[0,3,4,6],engin:[2,4,5,7,8,10],engine_bas:10,engine_spars:10,ensur:0,entir:[0,3],environ:[0,3,6,9],error:3,evenli:6,everyth:8,exampl:[0,5,6,8,9],except:0,execut:[0,4,5,6,10],exist:8,expect:0,expedit:10,explain:[3,4],explor:[9,10],extens:7,extern:1,extra:[0,8],fals:0,faster:[8,10],fatal:3,featur:8,fetch:10,few:8,fft:8,file:[0,1,3,10],filter:4,find:[5,10],fine:6,finish:4,first:[0,3,6],fit:8,fix:0,float32:[0,10],flow:8,focus:8,follow:[3,4,6],forc:[0,6],format:[0,8],forward:0,found:8,four:6,fp32:10,framework:8,from:[0,3,4,6,8,10],full:8,func:0,further:6,gather:1,gener:[0,1,3,4,8,10],generate_random_input:[1,10],get:[3,8],get_external_input:1,get_external_output:1,get_input_nam:1,get_output_nam:1,getcap:4,github:[8,10],give:[0,8],given:[0,6],gpu:[0,8],grain:6,graph:[0,4,5],graph_util:[3,4],graphview:[3,4],greater:[3,4],gt_output:1,guid:3,guidanc:[5,8],hardwar:[6,8,10],has:6,haswel:7,have:[0,6],height:0,help:8,here:[6,7,10],highli:7,hit:[0,3],home:[3,4],host:[8,10],how:[0,3,8,10],howev:6,hpp:4,http:[3,10],hurt:3,hyper:6,hyperthread:6,ideal:[3,6],idl:6,ignor:4,imagenet:10,implement:8,impos:0,imposed_a:0,imposed_k:0,improv:[6,8],includ:[3,4,8,10],include_input:0,include_output:0,increas:3,incur:0,indic:3,induc:8,infer:[0,3,8,10],inferenc:8,inference_tim:10,info:4,inform:[0,3,8],ingest:8,init_deepsparse_lib:0,initi:3,inp:0,input:[0,1,3,4,10],input_data:4,instal:8,instanc:[0,3],instanti:0,instruct:[0,7,10],int16:0,int8:[0,10],intak:[3,4],intel:[6,7],intend:6,interfac:0,inventori:6,isinst:0,issu:3,item:0,items_per_second:[0,10],iter:0,its:1,jdoe:[3,4],jit:[3,4],just:8,keep:9,kera:8,kernel:[0,3,4,7],lake:7,larger:6,layer:0,learn:3,legal:3,level:[0,3,5,8],lib:[2,8],like:[3,6,9],limit:8,line:[3,8],linux:[0,7,9],list:[0,1,3],load:3,loader:0,local:0,locat:[3,6],log:[0,2,5,8],log_init:1,logic:6,look:3,machin:[0,3,8,10],macro:3,made:3,magic:[0,3,8],mai:[3,6],main:3,major:[3,6],make:3,man:6,manag:3,mani:[3,8],manual:3,map:6,mapped_run:0,master:10,match:[0,1,4],max:[0,1],maxim:3,maximum:6,mean:0,median:0,membind:6,memori:[0,6,8],method:0,metric:8,microarchitectur:7,migrat:[3,6],millisecond:0,minim:0,mobilenet:10,mobilenetv2:10,model:[0,1,3,4,6,8],model_path:0,moder:10,modifi:1,modul:[2,8],monitor:3,monopol:3,more:[0,6],most:0,ms_per_batch:0,ms_per_item:0,multi:[0,6],multipl:6,must:0,name:[0,1],name_of_log:3,natur:8,ndarrai:0,nearli:[8,10],need:6,network:[0,3,4,8],neural:[0,3,8],neuralmag:[3,4],neuralmagic_cr:4,neuralmagic_execut:4,newer:7,nightli:8,nm_arch:0,nm_bind_threads_to_cor:[3,6],nm_exec_test_it:4,nm_execution_provid:[3,4],nm_logging_level:[3,4],nm_ogging_level:3,nm_ort:[3,4],nm_subgraph:3,nm_subgraph_1:[3,4],nmexecutionprovid:4,node:[4,5],non:4,none:[0,1,4,10],normal:3,notabl:3,note:[0,3,5,8],notebook:9,notic:8,num_batch:0,num_cor:0,num_item:0,num_iter:0,num_socket:0,num_warmup_iter:0,numactl:[5,8],number:[0,5,6],numpi:[0,1,10],nyann:[3,4],object:[0,1],obtain:5,occur:8,offer:6,offici:8,onc:3,one:[0,3,6,8],onli:[0,3,4,6,8],onnx:[0,2,4,8],onnx_filenam:4,onnx_filepath:[1,10],onnxruntime_neuralmag:[3,4],openmp:3,oper:[3,4,7],ops:[3,4],optim:[0,4,6,7,8,10],optimization_level:0,option:[0,1,6],order:[0,3,9],ort:[3,4],other:[0,3,6,8,10],otherwis:0,our:5,out:[0,3,6],output:[0,1,3,4,10],output_data:4,outsid:6,over:[0,6,7,8],overprecis:8,overrid:[0,1],override_onnx_batch_s:1,own:6,packag:[2,8,10],pad:[3,4],page:6,pair:1,param:1,paramet:[0,3,6],parameter:8,pars:[4,5,8],part:3,particular:6,pass:0,path:[0,1],pattern:4,per:[0,3,6],percentag:[0,3],perform:[0,5,6,8,10],physcpubind:6,physic:[0,6],pin:[3,5,8],pinpoint:3,pip:9,pipelin:[3,8],planner:4,pleas:0,plu:8,plug:10,point:3,polici:3,pool:3,portion:[3,4],possibl:3,practic:3,pre:10,predict:10,prefer:6,prefix:0,prepar:8,prevent:[3,6],print:[3,4,10],privaci:3,process:[3,6,8],produc:[5,8],product:8,progress:0,properti:0,provid:[1,3,4],prunabl:0,prune:[0,8,10],pruned_qu:10,pypi:8,python:[0,3,9],pytorch:[8,10],quant:10,quantiz:[0,7,8,10],quick:8,quickli:[0,8,10],quickstart:8,rais:0,rand:0,randn:10,random:[0,1,4,10],rang:6,ratio:4,raw:10,real:[3,10],recip:[8,10],recommend:[0,3,7,9],record:0,recov:[8,10],reduc:8,redund:8,refer:1,regular:0,rel:1,relat:0,relu:[0,3,4],remov:8,repeat:[0,10],repo:4,report:3,repositori:[8,9],request:8,requir:[4,6,8,9],reshap:[3,4],resnet:10,resnet_50:10,resnet_v1:10,resolut:[3,4],resourc:[3,5],respect:10,restrict:6,result:[0,3,6,8],reveal:3,review:3,rewrit:1,rtol:1,run:[0,3,4,6,7,10],run_model:3,runtim:[4,5,8],same:[6,8],sampl:[3,10],sample_batch:10,sample_input:10,save:[1,10],scale:8,scarc:3,scenario:6,scienc:3,script:3,seamlessli:8,search_optimized_model:10,second:[0,6],section:10,see:[0,3,6,10],seek:3,select:6,self:3,separ:6,serv:3,set:[0,3,6,10],setup:[0,6],sever:3,shape:[1,3,4],share:[3,6,10],shell:3,ship:3,should:6,show:[3,6],show_progress:0,shuffl:0,signific:0,significantli:8,similar:1,similarli:6,simpl:8,simpli:10,simplif:3,sinc:6,singl:[0,6],size:[0,1,4,5,6],skylak:7,smaller:8,smt:6,socket:[0,6],softwar:3,solut:10,some:[0,3,7],sourc:[0,1],spars:[7,8,10],sparseml:[8,10],sparsezoo:[0,8],sparsif:10,sparsifi:[8,10],sparsiti:[0,7,8],specif:[0,6,7],specifi:[3,6],speedup:[0,10],split:3,src:[3,4],stabl:8,standard:[0,6],start:[0,3,4,6,8],startup:6,state:[0,3,10],statement:3,statist:[0,5],stderr:3,steadi:0,step:8,store:0,str:[0,1],straightforward:6,stride:[3,4],string:1,structur:0,stub:[0,10],subgraph:[4,5],submodul:[2,8],subpackag:[2,8],suffici:1,suit:8,summari:0,super_resolut:4,support:[0,4,5,8,10],supported_subgraph:[3,4],system:[0,3,4,6,7,9],tabl:7,tag:10,take:[0,8],target:10,tbb:3,technic:3,techniqu:[8,10],tensor:[0,1,3],tensorflow:8,test:[4,9],test_1:4,than:[3,4,6,10],thei:[1,3],them:3,thi:[0,3,6,8,9,10],thread:[3,5,8],through:[0,6],tiger:7,time:[0,5],time_elaps:0,time_end:0,time_start:0,timed_run:[0,10],toler:1,too:10,took:0,top:8,torch:[3,4],total:4,tour:8,tradit:3,train:[3,8,10],translat:[3,4],transpos:[3,4],troubleshoot:3,truncat:3,tune:[5,8],tupl:0,two:[1,6,10],txt:3,type:[0,1,3],union:0,uniqu:3,unit:4,unlik:3,unoptim:3,unsupport:[3,4],use:[0,3,6,10],used:[0,6],using:[0,3,4,6,8,9,10],usual:[1,6],util:[0,2,3,4,5,8,10],val_inp:0,valid:[0,7],validate_minimum_supported_fract:[3,4],valu:[3,4],variabl:[0,3,6],variou:3,vector:0,verbos:[3,5,8],veri:[3,10],verify_output:1,version:[2,4,8,10],via:8,view:5,virtual:9,vision:10,vnni:[0,7,10],wai:6,wand:4,want:3,warm:0,warn:[3,4,10],websit:8,weight:[0,3,4],well:[6,8,10],were:0,wget:10,what:[0,3,10],when:[0,6,8,10],where:[3,4,6],whether:3,which:[3,6],whole:5,width:0,winograd:8,within:[3,8],work:[6,7,8],workload:8,would:[3,6,9],x86:7,yet:0,you:[0,3,6,8,9,10],your:[3,6,8,9,10],zen:7,zoo:[0,10]},titles:["deepsparse package","deepsparse.utils package","deepsparse","Logging Guidance for Diagnostics and Debugging","Example Log, Verbose Level = diagnose","Debugging and Optimizing","Using the numactl Utility to Control Resource Utilization with the DeepSparse Engine","Hardware Support","DeepSparse 0.1","Installation","Quick Tour"],titleterms:{Using:6,addit:6,amount:3,batch:3,benchmark:0,compat:8,compil:3,content:[0,1],control:[3,6],core:3,cpu:0,custom:10,data:1,debug:[3,5],deepspars:[0,1,2,3,6,8],determin:3,diagnos:4,diagnost:3,each:3,enabl:3,engin:[0,3,6],exampl:[3,4],execut:3,find:3,graph:3,guidanc:3,hardwar:7,histori:8,instal:9,learn:8,level:4,lib:0,log:[1,3,4],model:10,modul:[0,1],more:8,node:3,note:6,numactl:6,number:3,obtain:3,onnx:[1,10],optim:[3,5],our:3,overview:8,packag:[0,1],pars:3,perform:3,pin:6,produc:3,quick:10,quickstart:10,releas:8,resourc:[6,8],runtim:3,size:3,sparsezoo:10,sparsif:8,statist:3,subgraph:3,submodul:[0,1],subpackag:0,support:[3,7],thread:6,time:3,tour:10,tune:3,util:[1,6],verbos:4,version:0,view:3,whole:3}}) \ No newline at end of file diff --git a/sparseml/.buildinfo b/sparseml/.buildinfo index 2b6cd377ec9..91e7ee54e31 100644 --- a/sparseml/.buildinfo +++ b/sparseml/.buildinfo @@ -1,4 +1,4 @@ # Sphinx build info version 1 # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. -config: c63c6ded94ac1c7e5c66b2826a50b394 +config: a86ffcb0c88a33c5305858fcafe2189c tags: 645f666f9bcd5a90fca523b33c5a78b7 diff --git a/sparseml/_modules/index.html b/sparseml/_modules/index.html index 234feb41f55..ef30f3ad87b 100644 --- a/sparseml/_modules/index.html +++ b/sparseml/_modules/index.html @@ -297,7 +297,6 @@

    All modules for which code is available

  • sparseml.utils.singleton
  • sparseml.utils.worker
  • sparseml.utils.wrapper
  • -
  • tensorflow.python.ops.math_ops
  • diff --git a/sparseml/_modules/sparseml/pytorch/optim/mask_creator_pruning.html b/sparseml/_modules/sparseml/pytorch/optim/mask_creator_pruning.html index 0dd39ac1c04..2904d63a9ca 100644 --- a/sparseml/_modules/sparseml/pytorch/optim/mask_creator_pruning.html +++ b/sparseml/_modules/sparseml/pytorch/optim/mask_creator_pruning.html @@ -337,26 +337,35 @@

    Source code for sparseml.pytorch.optim.mask_creator_pruning

    _map_mask_to_tensor """ - _GROUPING_FUNCTIONS = { - "mean": lambda args: torch.mean(**args), - "max": lambda args: torch.max(**args)[0], - "min": lambda args: torch.min(**args)[0], - } - -
    [docs] @staticmethod - def get_grouping_fn(grouping_fn_name: str) -> Callable[[Tensor, List[int]], Tensor]: + _VALID_GROUPING_FN_NAMES = ["mean", "max", "min"] + +
    [docs] @staticmethod + def reduce_tensor( + tensor: Tensor, + dim: Union[int, List[int]], + reduce_fn_name: str, + keepdim: bool = True, + ) -> Tensor: """ - :param grouping_fn_name: name of grouping function to get torch function for - :return: torch function for grouping_fn_name if available, - raises error otherwise + + :param tensor: the tensor to reduce + :param dim: dimension or list of dimension to reduce along + :param reduce_fn_name: function name to reduce tensor with. valid options + are 'mean', 'max', 'min' + :param keepdim: preserves the reduced dimension(s) in returned tensor shape + as shape 1. default is True + :return: Tensor reduced along the given dimension(s) """ - if grouping_fn_name not in GroupedPruningMaskCreator._GROUPING_FUNCTIONS: - raise ValueError( - "Invalid grouping fn {}, valid grouping fns: {}".format( - grouping_fn_name, GroupedPruningMaskCreator._GROUPING_FUNCTIONS - ) - ) - return GroupedPruningMaskCreator._GROUPING_FUNCTIONS[grouping_fn_name]
    + if reduce_fn_name == "mean": + return torch.mean(input=tensor, dim=dim, keepdim=keepdim) + if reduce_fn_name == "max": + return torch.max(input=tensor, dim=dim, keepdim=keepdim)[0] + if reduce_fn_name == "min": + return torch.min(input=tensor, dim=dim, keepdim=keepdim)[0] + raise ValueError( + f"Invalid grouping fn {reduce_fn_name}, valid grouping fns: " + f"{GroupedPruningMaskCreator._VALID_GROUPING_FN_NAMES}" + )
    [docs] @abstractmethod def group_tensor(self, tensor: Tensor) -> Tensor: @@ -440,7 +449,7 @@

    Source code for sparseml.pytorch.optim.mask_creator_pruning

    if isinstance(dim, int): dim = [dim] self._dim_name = None - self._grouping_fn = GroupedPruningMaskCreator.get_grouping_fn(grouping_fn_name) + self._grouping_fn_name = grouping_fn_name if isinstance(dim, str): valid_dim_names = ["channel", "filter"] if dim in valid_dim_names: @@ -467,8 +476,8 @@

    Source code for sparseml.pytorch.optim.mask_creator_pruning

    " Received tensor with shape {}".format(tensor.shape) ) reduced_dims = [idx for idx in range(n_dims) if idx not in self._dim] - reduced_tensor = self._grouping_fn( - {"input": torch.abs(tensor), "dim": reduced_dims, "keepdim": True} + reduced_tensor = GroupedPruningMaskCreator.reduce_tensor( + torch.abs(tensor), reduced_dims, self._grouping_fn_name ) return reduced_tensor.type(tensor.type())
    @@ -520,7 +529,7 @@

    Source code for sparseml.pytorch.optim.mask_creator_pruning

    ).format(block_shape) ) self._block_shape = block_shape - self._grouping_fn = GroupedPruningMaskCreator.get_grouping_fn(grouping_fn_name) + self._grouping_fn_name = grouping_fn_name
    [docs] def group_tensor(self, tensor: Tensor) -> Tensor: """ @@ -530,8 +539,8 @@

    Source code for sparseml.pytorch.optim.mask_creator_pruning

    """ blocked_tens_shape = self._get_blocked_tens_shape_and_validate(tensor.shape) blocked_tensor = tensor.reshape(blocked_tens_shape) - reduced_blocks = self._grouping_fn( - {"input": torch.abs(blocked_tensor), "dim": 1, "keepdim": True} + reduced_blocks = GroupedPruningMaskCreator.reduce_tensor( + torch.abs(blocked_tensor), 1, self._grouping_fn_name ) return reduced_blocks.type(tensor.type())
    diff --git a/sparseml/_modules/tensorflow/python/ops/math_ops.html b/sparseml/_modules/tensorflow/python/ops/math_ops.html deleted file mode 100644 index 119591176b7..00000000000 --- a/sparseml/_modules/tensorflow/python/ops/math_ops.html +++ /dev/null @@ -1,4930 +0,0 @@ - - - - - - - - - - tensorflow.python.ops.math_ops — SparseML 0.1.0 documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - -
    - - - - - -
    - -
    - - - - - - - - - - - - - - - - - - - -
    - -
      - -
    • »
    • - -
    • Module code »
    • - -
    • tensorflow.python.ops.math_ops
    • - - -
    • - -
    • - -
    - - -
    -
    -
    -
    - -

    Source code for tensorflow.python.ops.math_ops

    -# Copyright 2015 The TensorFlow Authors. All Rights Reserved.
    -#
    -# Licensed under the Apache License, Version 2.0 (the "License");
    -# you may not use this file except in compliance with the License.
    -# You may obtain a copy of the License at
    -#
    -#     http://www.apache.org/licenses/LICENSE-2.0
    -#
    -# Unless required by applicable law or agreed to in writing, software
    -# distributed under the License is distributed on an "AS IS" BASIS,
    -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    -# See the License for the specific language governing permissions and
    -# limitations under the License.
    -# ==============================================================================
    -"""Math Operations.
    -
    -Note: Functions taking `Tensor` arguments can also take anything accepted by
    -`tf.convert_to_tensor`.
    -
    -Note: Elementwise binary operations in TensorFlow follow [numpy-style
    -broadcasting](http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html).
    -
    -TensorFlow provides a variety of math functions including:
    -
    -* Basic arithmetic operators and trigonometric functions.
    -* Special math functions (like: `tf.math.igamma` and `tf.math.zeta`)
    -* Complex number functions (like: `tf.math.imag` and `tf.math.angle`)
    -* Reductions and scans (like: `tf.math.reduce_mean` and `tf.math.cumsum`)
    -* Segment functions (like: `tf.math.segment_sum`)
    -
    -See: `tf.linalg` for matrix and tensor functions.
    -
    -<a id=Segmentation></a>
    -
    -## About Segmentation
    -
    -TensorFlow provides several operations that you can use to perform common
    -math computations on tensor segments.
    -Here a segmentation is a partitioning of a tensor along
    -the first dimension, i.e. it  defines a mapping from the first dimension onto
    -`segment_ids`. The `segment_ids` tensor should be the size of
    -the first dimension, `d0`, with consecutive IDs in the range `0` to `k`,
    -where `k<d0`.
    -In particular, a segmentation of a matrix tensor is a mapping of rows to
    -segments.
    -
    -For example:
    -
    -```python
    -c = tf.constant([[1,2,3,4], [-1,-2,-3,-4], [5,6,7,8]])
    -tf.math.segment_sum(c, tf.constant([0, 0, 1]))
    -#  ==>  [[0 0 0 0]
    -#        [5 6 7 8]]
    -```
    -
    -The standard `segment_*` functions assert that the segment indices are sorted.
    -If you have unsorted indices use the equivalent `unsorted_segment_` function.
    -These functions take an additional argument `num_segments` so that the output
    -tensor can be efficiently allocated.
    -
    -``` python
    -c = tf.constant([[1,2,3,4], [-1,-2,-3,-4], [5,6,7,8]])
    -tf.math.unsorted_segment_sum(c, tf.constant([0, 1, 0]), num_segments=2)
    -# ==> [[ 6,  8, 10, 12],
    -#       [-1, -2, -3, -4]]
    -```
    -
    -"""
    -from __future__ import absolute_import
    -from __future__ import division
    -from __future__ import print_function
    -
    -import numpy as np
    -import six
    -from six.moves import builtins
    -from six.moves import xrange  # pylint: disable=redefined-builtin
    -
    -from tensorflow.python.eager import context
    -from tensorflow.python.framework import constant_op
    -from tensorflow.python.framework import dtypes
    -from tensorflow.python.framework import graph_util
    -from tensorflow.python.framework import ops
    -from tensorflow.python.framework import sparse_tensor
    -from tensorflow.python.framework import tensor_shape
    -from tensorflow.python.ops import array_ops
    -from tensorflow.python.ops import gen_array_ops
    -from tensorflow.python.ops import gen_data_flow_ops
    -from tensorflow.python.ops import gen_math_ops
    -from tensorflow.python.ops import gen_nn_ops
    -from tensorflow.python.ops import gen_sparse_ops
    -# go/tf-wildcard-import
    -# pylint: disable=wildcard-import
    -from tensorflow.python.ops.gen_math_ops import *
    -# pylint: enable=wildcard-import
    -from tensorflow.python.platform import tf_logging as logging
    -from tensorflow.python.util import compat
    -from tensorflow.python.util import deprecation
    -from tensorflow.python.util import dispatch
    -from tensorflow.python.util import nest
    -from tensorflow.python.util.tf_export import tf_export
    -
    -# Aliases for some automatically-generated names.
    -linspace = gen_math_ops.lin_space
    -nextafter = gen_math_ops.next_after
    -
    -arg_max = deprecation.deprecated(None, "Use `tf.math.argmax` instead")(arg_max)  # pylint: disable=used-before-assignment
    -arg_min = deprecation.deprecated(None, "Use `tf.math.argmin` instead")(arg_min)  # pylint: disable=used-before-assignment
    -tf_export(v1=["arg_max"])(arg_max)
    -tf_export(v1=["arg_min"])(arg_min)
    -
    -
    -# This is set by resource_variable_ops.py. It is included in this way since
    -# there is a circular dependency between math_ops and resource_variable_ops
    -_resource_variable_type = None
    -
    -
    -def _set_doc(doc):
    -
    -  def _decorator(func):
    -    func.__doc__ = doc
    -    return func
    -
    -  return _decorator
    -
    -
    -# pylint: disable=redefined-builtin
    -@tf_export(v1=["math.argmax", "argmax"])
    -@deprecation.deprecated_args(None, "Use the `axis` argument instead",
    -                             "dimension")
    -@_set_doc(
    -    gen_math_ops.arg_max.__doc__.replace("dimensions",
    -                                         "axes").replace("dimension", "axis"))
    -def argmax(input,
    -           axis=None,
    -           name=None,
    -           dimension=None,
    -           output_type=dtypes.int64):
    -  axis = deprecation.deprecated_argument_lookup("axis", axis, "dimension",
    -                                                dimension)
    -  return argmax_v2(input, axis, output_type, name)
    -
    -
    -@tf_export("math.argmax", "argmax", v1=[])
    -def argmax_v2(input, axis=None, output_type=dtypes.int64, name=None):
    -  """Returns the index with the largest value across axes of a tensor.
    -
    -  Note that in case of ties the identity of the return value is not guaranteed.
    -
    -  For example:
    -
    -  >>> A = tf.constant([2, 20, 30, 3, 6])
    -  >>> tf.math.argmax(A)  # A[2] is maximum in tensor A
    -  <tf.Tensor: shape=(), dtype=int64, numpy=2>
    -  >>> B = tf.constant([[2, 20, 30, 3, 6], [3, 11, 16, 1, 8],
    -  ...                  [14, 45, 23, 5, 27]])
    -  >>> tf.math.argmax(B, 0)
    -  <tf.Tensor: shape=(5,), dtype=int64, numpy=array([2, 2, 0, 2, 2])>
    -  >>> tf.math.argmax(B, 1)
    -  <tf.Tensor: shape=(3,), dtype=int64, numpy=array([2, 2, 1])>
    -
    -  Args:
    -    input: A `Tensor`.
    -    axis: An integer, the axis to reduce across. Default to 0.
    -    output_type: An optional output dtype (`tf.int32` or `tf.int64`). Defaults
    -      to `tf.int64`.
    -    name: An optional name for the operation.
    -
    -  Returns:
    -    A `Tensor` of type `output_type`.
    -  """
    -  if axis is None:
    -    axis = 0
    -  return gen_math_ops.arg_max(input, axis, name=name, output_type=output_type)
    -
    -
    -@tf_export(v1=["math.argmin", "argmin"])
    -@deprecation.deprecated_args(None, "Use the `axis` argument instead",
    -                             "dimension")
    -@_set_doc(
    -    gen_math_ops.arg_min.__doc__.replace("dimensions",
    -                                         "axes").replace("dimension", "axis"))
    -def argmin(input,
    -           axis=None,
    -           name=None,
    -           dimension=None,
    -           output_type=dtypes.int64):
    -  axis = deprecation.deprecated_argument_lookup("axis", axis, "dimension",
    -                                                dimension)
    -  return argmin_v2(input, axis, output_type, name)
    -
    -
    -@tf_export("math.argmin", "argmin", v1=[])
    -def argmin_v2(input, axis=None, output_type=dtypes.int64, name=None):
    -  """Returns the index with the smallest value across axes of a tensor.
    -
    -  Note that in case of ties the identity of the return value is not guaranteed.
    -
    -  Args:
    -    input: A `Tensor`. Must be one of the following types: `float32`, `float64`,
    -      `int32`, `uint8`, `int16`, `int8`, `complex64`, `int64`, `qint8`,
    -      `quint8`, `qint32`, `bfloat16`, `uint16`, `complex128`, `half`, `uint32`,
    -      `uint64`.
    -    axis: A `Tensor`. Must be one of the following types: `int32`, `int64`.
    -      int32 or int64, must be in the range `-rank(input), rank(input))`.
    -      Describes which axis of the input Tensor to reduce across. For vectors,
    -      use axis = 0.
    -    output_type: An optional `tf.DType` from: `tf.int32, tf.int64`. Defaults to
    -      `tf.int64`.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    A `Tensor` of type `output_type`.
    -
    -  Usage:
    -  ```python
    -  import tensorflow as tf
    -  a = [1, 10, 26.9, 2.8, 166.32, 62.3]
    -  b = tf.math.argmin(input = a)
    -  c = tf.keras.backend.eval(b)
    -  # c = 0
    -  # here a[0] = 1 which is the smallest element of a across axis 0
    -  ```
    -  """
    -  if axis is None:
    -    axis = 0
    -  return gen_math_ops.arg_min(input, axis, name=name, output_type=output_type)
    -
    -
    -# pylint: enable=redefined-builtin
    -
    -
    -# pylint: disable=anomalous-backslash-in-string,protected-access
    -# pylint: disable=g-docstring-has-escape
    -@tf_export("math.abs", "abs")
    -@dispatch.add_dispatch_support
    -def abs(x, name=None):  # pylint: disable=redefined-builtin
    -  r"""Computes the absolute value of a tensor.
    -
    -  Given a tensor of integer or floating-point values, this operation returns a
    -  tensor of the same type, where each element contains the absolute value of the
    -  corresponding element in the input.
    -
    -  Given a tensor `x` of complex numbers, this operation returns a tensor of type
    -  `float32` or `float64` that is the absolute value of each element in `x`. For
    -  a complex number \\(a + bj\\), its absolute value is computed as \\(\sqrt{a^2
    -  + b^2}\\).  For example:
    -
    -  >>> x = tf.constant([[-2.25 + 4.75j], [-3.25 + 5.75j]])
    -  >>> tf.abs(x)
    -  <tf.Tensor: shape=(2, 1), dtype=float64, numpy=
    -  array([[5.25594901],
    -         [6.60492241]])>
    -
    -  Args:
    -    x: A `Tensor` or `SparseTensor` of type `float16`, `float32`, `float64`,
    -      `int32`, `int64`, `complex64` or `complex128`.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    A `Tensor` or `SparseTensor` of the same size, type and sparsity as `x`,
    -      with absolute values. Note, for `complex64` or `complex128` input, the
    -      returned `Tensor` will be of type `float32` or `float64`, respectively.
    -  """
    -  with ops.name_scope(name, "Abs", [x]) as name:
    -    x = ops.convert_to_tensor(x, name="x")
    -    if x.dtype.is_complex:
    -      return gen_math_ops.complex_abs(x, Tout=x.dtype.real_dtype, name=name)
    -    return gen_math_ops._abs(x, name=name)
    -
    -
    -# pylint: enable=g-docstring-has-escape
    -
    -
    -# pylint: disable=redefined-builtin
    -def _bucketize(input, boundaries, name=None):
    -  return gen_math_ops.bucketize(input=input, boundaries=boundaries, name=name)
    -
    -
    -# pylint: enable=redefined-builtin
    -
    -
    -class DivideDelegateWithName(object):
    -  """Use Python2/Python3 division delegation to implement divide for tensors."""
    -
    -  def __init__(self, x, name):
    -    """Construct DivideDelegateWithName.
    -
    -    Args:
    -      x: Tensor to use as left operand in operator overloads
    -      name: The name that is preferred for the op created.
    -    """
    -    self.x = x
    -    self.name = name
    -
    -  def __truediv__(self, y):
    -    return _truediv_python3(self.x, y, self.name)
    -
    -  def __floordiv__(self, y):
    -    return floordiv(self.x, y, self.name)
    -
    -  def __div__(self, y):
    -    return _div_python2(self.x, y, self.name)
    -
    -
    -@tf_export("math.divide", "divide")
    -@dispatch.add_dispatch_support
    -def divide(x, y, name=None):
    -  """Computes Python style division of `x` by `y`.
    -
    -  For example:
    -
    -  >>> x = tf.constant([16, 12, 11])
    -  >>> y = tf.constant([4, 6, 2])
    -  >>> tf.divide(x,y)
    -  <tf.Tensor: shape=(3,), dtype=float64,
    -  numpy=array([4. , 2. , 5.5])>
    -
    -  Args:
    -    x: A `Tensor`
    -    y: A `Tensor`
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    A `Tensor` with same shape as input
    -  """
    -
    -  if name is not None:
    -    # Cannot use tensors operator overload, because it has no way to track
    -    # override names. Use a dummy class to track the runtime division behavior
    -    return DivideDelegateWithName(x, name) / y
    -  else:
    -    return x / y
    -
    -
    -@tf_export("math.multiply", "multiply")
    -@dispatch.add_dispatch_support
    -def multiply(x, y, name=None):
    -  """Returns an element-wise x * y.
    -
    -  For example:
    -
    -  >>> x = tf.constant(([1, 2, 3, 4]))
    -  >>> tf.math.multiply(x, x)
    -  <tf.Tensor: shape=(4,), dtype=..., numpy=array([ 1,  4,  9, 16], dtype=int32)>
    -
    -  Since `tf.math.multiply` will convert its arguments to `Tensor`s, you can also
    -  pass in non-`Tensor` arguments:
    -
    -  >>> tf.math.multiply(7,6)
    -  <tf.Tensor: shape=(), dtype=int32, numpy=42>
    -
    -  If `x.shape` is not thes same as `y.shape`, they will be broadcast to a
    -  compatible shape. (More about broadcasting
    -  [here](https://docs.scipy.org/doc/numpy/user/basics.broadcasting.html).)
    -
    -  For example:
    -
    -  >>> x = tf.ones([1, 2]);
    -  >>> y = tf.ones([2, 1]);
    -  >>> x * y  # Taking advantage of operator overriding
    -  <tf.Tensor: shape=(2, 2), dtype=float32, numpy=
    -  array([[1., 1.],
    -       [1., 1.]], dtype=float32)>
    -
    -  Args:
    -    x: A Tensor. Must be one of the following types: `bfloat16`,
    -      `half`, `float32`, `float64`, `uint8`, `int8`, `uint16`,
    -      `int16`, `int32`, `int64`, `complex64`, `complex128`.
    -    y: A `Tensor`. Must have the same type as `x`.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -
    -  A `Tensor`.  Has the same type as `x`.
    -
    -  Raises:
    -
    -   * InvalidArgumentError: When `x` and `y` have incomptatible shapes or types.
    -  """
    -
    -  return gen_math_ops.mul(x, y, name)
    -
    -
    -# TODO(aselle): put deprecation in after another round of global code changes
    -@deprecation.deprecated(
    -    "2016-12-30",
    -    "`tf.mul(x, y)` is deprecated; use `tf.math.multiply(x, y)` or `x * y`")
    -def _mul(x, y, name=None):
    -  return gen_math_ops.mul(x, y, name)
    -
    -
    -_mul.__doc__ = (
    -    gen_math_ops.mul.__doc__ + ("" if _mul.__doc__ is None else _mul.__doc__))
    -
    -
    -@tf_export("math.subtract", "subtract")
    -@dispatch.add_dispatch_support
    -def subtract(x, y, name=None):
    -  return gen_math_ops.sub(x, y, name)
    -
    -
    -subtract.__doc__ = gen_math_ops.sub.__doc__.replace("`Sub`", "`tf.subtract`")
    -
    -
    -# TODO(aselle): put deprecation in after another round of global code changes
    -@deprecation.deprecated(
    -    "2016-12-30",
    -    "`tf.sub(x, y)` is deprecated, please use `tf.subtract(x, y)` or `x - y`")
    -def _sub(x, y, name=None):
    -  return gen_math_ops.sub(x, y, name)
    -
    -
    -_sub.__doc__ = (
    -    gen_math_ops.sub.__doc__ + ("" if _sub.__doc__ is None else _sub.__doc__))
    -
    -negative = gen_math_ops.neg
    -
    -
    -# pylint: disable=g-docstring-has-escape
    -@deprecation.deprecated(
    -    "2016-12-30",
    -    "`tf.neg(x)` is deprecated, please use `tf.negative(x)` or `-x`")
    -def _neg(x, name=None):
    -  """Computes numerical negative value element-wise.
    -
    -  I.e., \\(y = -x\\).
    -
    -  Args:
    -    x: A `Tensor` or `SparseTensor`. Must be one of the following types: `half`,
    -      `float32`, `float64`, `int32`, `int64`, `complex64`, `complex128`.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    A `Tensor` or `SparseTensor`, respectively. Has the same type as `x`.
    -  """
    -  return negative(x, name)
    -
    -
    -# pylint: enable=g-docstring-has-escape
    -
    -
    -@tf_export(v1=["math.scalar_mul", "scalar_mul"])
    -def scalar_mul(scalar, x, name=None):
    -  """Multiplies a scalar times a `Tensor` or `IndexedSlices` object.
    -
    -  Intended for use in gradient code which might deal with `IndexedSlices`
    -  objects, which are easy to multiply by a scalar but more expensive to
    -  multiply with arbitrary tensors.
    -
    -  Args:
    -    scalar: A 0-D scalar `Tensor`. Must have known shape.
    -    x: A `Tensor` or `IndexedSlices` to be scaled.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    `scalar * x` of the same type (`Tensor` or `IndexedSlices`) as `x`.
    -
    -  Raises:
    -    ValueError: if scalar is not a 0-D `scalar`.
    -  """
    -  scalar = ops.convert_to_tensor(
    -      scalar, dtype=x.dtype.base_dtype, name="scalar")
    -  shape = scalar.get_shape()
    -  if shape.ndims == 0:
    -    if isinstance(x, ops.IndexedSlices):
    -      return ops.IndexedSlices(
    -          gen_math_ops.mul(scalar, x.values, name), x.indices, x.dense_shape)
    -    else:
    -      return gen_math_ops.mul(scalar, x, name)
    -  else:
    -    raise ValueError("Only scalar multiply works, got shape %s" % shape)
    -
    -
    -@tf_export("math.scalar_mul", "scalar_mul", v1=[])
    -@_set_doc(scalar_mul.__doc__)
    -def scalar_mul_v2(scalar, x, name=None):
    -  with ops.name_scope(name, "scalar_mul", [x]) as name:
    -    return scalar_mul(scalar, x, name)
    -
    -
    -@tf_export("math.pow", "pow")
    -@dispatch.add_dispatch_support
    -def pow(x, y, name=None):  # pylint: disable=redefined-builtin
    -  r"""Computes the power of one value to another.
    -
    -  Given a tensor `x` and a tensor `y`, this operation computes \\(x^y\\) for
    -  corresponding elements in `x` and `y`. For example:
    -
    -  ```python
    -  x = tf.constant([[2, 2], [3, 3]])
    -  y = tf.constant([[8, 16], [2, 3]])
    -  tf.pow(x, y)  # [[256, 65536], [9, 27]]
    -  ```
    -
    -  Args:
    -    x: A `Tensor` of type `float16`, `float32`, `float64`, `int32`, `int64`,
    -      `complex64`, or `complex128`.
    -    y: A `Tensor` of type `float16`, `float32`, `float64`, `int32`, `int64`,
    -      `complex64`, or `complex128`.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    A `Tensor`.
    -  """
    -  with ops.name_scope(name, "Pow", [x]) as name:
    -    return gen_math_ops._pow(x, y, name=name)
    -
    -
    -# pylint: disable=redefined-builtin,redefined-outer-name
    -@tf_export("dtypes.complex", "complex")
    -@dispatch.add_dispatch_support
    -def complex(real, imag, name=None):
    -  r"""Converts two real numbers to a complex number.
    -
    -  Given a tensor `real` representing the real part of a complex number, and a
    -  tensor `imag` representing the imaginary part of a complex number, this
    -  operation returns complex numbers elementwise of the form \\(a + bj\\), where
    -  *a* represents the `real` part and *b* represents the `imag` part.
    -
    -  The input tensors `real` and `imag` must have the same shape.
    -
    -  For example:
    -
    -  ```python
    -  real = tf.constant([2.25, 3.25])
    -  imag = tf.constant([4.75, 5.75])
    -  tf.complex(real, imag)  # [[2.25 + 4.75j], [3.25 + 5.75j]]
    -  ```
    -
    -  Args:
    -    real: A `Tensor`. Must be one of the following types: `float32`, `float64`.
    -    imag: A `Tensor`. Must have the same type as `real`.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    A `Tensor` of type `complex64` or `complex128`.
    -
    -  Raises:
    -    TypeError: Real and imag must be correct types
    -  """
    -  real = ops.convert_to_tensor(real, name="real")
    -  imag = ops.convert_to_tensor(imag, name="imag")
    -  with ops.name_scope(name, "Complex", [real, imag]) as name:
    -    input_types = (real.dtype, imag.dtype)
    -    if input_types == (dtypes.float64, dtypes.float64):
    -      Tout = dtypes.complex128
    -    elif input_types == (dtypes.float32, dtypes.float32):
    -      Tout = dtypes.complex64
    -    else:
    -      raise TypeError("real and imag have incorrect types: "
    -                      "{} {}".format(real.dtype.name, imag.dtype.name))
    -    return gen_math_ops._complex(real, imag, Tout=Tout, name=name)
    -
    -
    -@tf_export("math.sign", "sign")
    -@dispatch.add_dispatch_support
    -def sign(x, name=None):
    -  """Returns an element-wise indication of the sign of a number.
    -
    -  y = sign(x) = -1 if x < 0; 0 if x == 0; 1 if x > 0.
    -
    -  For complex numbers, y = sign(x) = x / |x| if x != 0, otherwise y = 0.
    -
    -  Example usage:
    -
    -  >>> tf.math.sign([0., 2., -3.])
    -  <tf.Tensor: ... numpy=array([ 0.,  1., -1.], dtype=float32)>
    -
    -  Args:
    -   x: A Tensor. Must be one of the following types: bfloat16, half, float32,
    -      float64, int32, int64, complex64, complex128.
    -   name: A name for the operation (optional).
    -
    -  Returns:
    -   A Tensor. Has the same type as x.
    -
    -   If x is a SparseTensor, returns SparseTensor(x.indices,
    -     tf.math.sign(x.values, ...), x.dense_shape).
    -  """
    -  x = ops.convert_to_tensor(x)
    -  if x.dtype in (dtypes.complex64, dtypes.complex128):
    -    return gen_math_ops.div_no_nan(
    -        x,
    -        cast(
    -            gen_math_ops.complex_abs(
    -                x,
    -                Tout=dtypes.float32
    -                if x.dtype == dtypes.complex64 else dtypes.float64),
    -            dtype=x.dtype),
    -        name=name)
    -  return gen_math_ops.sign(x, name=name)
    -
    -
    -@tf_export("math.real", v1=["math.real", "real"])
    -@deprecation.deprecated_endpoints("real")
    -@dispatch.add_dispatch_support
    -def real(input, name=None):
    -  r"""Returns the real part of a complex (or real) tensor.
    -
    -  Given a tensor `input`, this operation returns a tensor of type `float` that
    -  is the real part of each element in `input` considered as a complex number.
    -
    -  For example:
    -
    -  ```python
    -  x = tf.constant([-2.25 + 4.75j, 3.25 + 5.75j])
    -  tf.math.real(x)  # [-2.25, 3.25]
    -  ```
    -
    -  If `input` is already real, it is returned unchanged.
    -
    -  Args:
    -    input: A `Tensor`. Must have numeric type.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    A `Tensor` of type `float32` or `float64`.
    -  """
    -  with ops.name_scope(name, "Real", [input]) as name:
    -    input = ops.convert_to_tensor(input, name="input")
    -    if input.dtype.is_complex:
    -      real_dtype = input.dtype.real_dtype
    -      return gen_math_ops.real(input, Tout=real_dtype, name=name)
    -    else:
    -      return input
    -
    -
    -@tf_export("math.imag", v1=["math.imag", "imag"])
    -@deprecation.deprecated_endpoints("imag")
    -@dispatch.add_dispatch_support
    -def imag(input, name=None):
    -  r"""Returns the imaginary part of a complex (or real) tensor.
    -
    -  Given a tensor `input`, this operation returns a tensor of type `float` that
    -  is the imaginary part of each element in `input` considered as a complex
    -  number. If `input` is real, a tensor of all zeros is returned.
    -
    -  For example:
    -
    -  ```python
    -  x = tf.constant([-2.25 + 4.75j, 3.25 + 5.75j])
    -  tf.math.imag(x)  # [4.75, 5.75]
    -  ```
    -
    -  Args:
    -    input: A `Tensor`. Must be one of the following types: `float`, `double`,
    -      `complex64`, `complex128`.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    A `Tensor` of type `float32` or `float64`.
    -  """
    -  with ops.name_scope(name, "Imag", [input]) as name:
    -    input = ops.convert_to_tensor(input, name="input")
    -    if input.dtype.is_complex:
    -      return gen_math_ops.imag(input, Tout=input.dtype.real_dtype, name=name)
    -    else:
    -      return array_ops.zeros_like(input)
    -
    -
    -@tf_export("math.angle", v1=["math.angle", "angle"])
    -@deprecation.deprecated_endpoints("angle")
    -@dispatch.add_dispatch_support
    -def angle(input, name=None):
    -  r"""Returns the element-wise argument of a complex (or real) tensor.
    -
    -  Given a tensor `input`, this operation returns a tensor of type `float` that
    -  is the argument of each element in `input` considered as a complex number.
    -
    -  The elements in `input` are considered to be complex numbers of the form
    -  \\(a + bj\\), where *a* is the real part and *b* is the imaginary part.
    -  If `input` is real then *b* is zero by definition.
    -
    -  The argument returned by this function is of the form \\(atan2(b, a)\\).
    -  If `input` is real, a tensor of all zeros is returned.
    -
    -  For example:
    -
    -  ```
    -  input = tf.constant([-2.25 + 4.75j, 3.25 + 5.75j], dtype=tf.complex64)
    -  tf.math.angle(input).numpy()
    -  # ==> array([2.0131705, 1.056345 ], dtype=float32)
    -  ```
    -
    -  Args:
    -    input: A `Tensor`. Must be one of the following types: `float`, `double`,
    -      `complex64`, `complex128`.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    A `Tensor` of type `float32` or `float64`.
    -  """
    -  with ops.name_scope(name, "Angle", [input]) as name:
    -    input = ops.convert_to_tensor(input, name="input")
    -    if input.dtype.is_complex:
    -      return gen_math_ops.angle(input, Tout=input.dtype.real_dtype, name=name)
    -    else:
    -      return array_ops.zeros_like(input)
    -
    -
    -# pylint: enable=redefined-outer-name,redefined-builtin
    -
    -
    -@tf_export("math.round", "round")
    -@dispatch.add_dispatch_support
    -def round(x, name=None):  # pylint: disable=redefined-builtin
    -  """Rounds the values of a tensor to the nearest integer, element-wise.
    -
    -  Rounds half to even.  Also known as bankers rounding. If you want to round
    -  according to the current system rounding mode use tf::cint.
    -  For example:
    -
    -  ```python
    -  x = tf.constant([0.9, 2.5, 2.3, 1.5, -4.5])
    -  tf.round(x)  # [ 1.0, 2.0, 2.0, 2.0, -4.0 ]
    -  ```
    -
    -  Args:
    -    x: A `Tensor` of type `float16`, `float32`, `float64`, `int32`, or `int64`.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    A `Tensor` of same shape and type as `x`.
    -  """
    -  x = ops.convert_to_tensor(x, name="x")
    -  if x.dtype.is_integer:
    -    return x
    -  else:
    -    return gen_math_ops.round(x, name=name)
    -
    -
    -@tf_export("cast", "dtypes.cast")
    -@dispatch.add_dispatch_support
    -def cast(x, dtype, name=None):
    -  """Casts a tensor to a new type.
    -
    -  The operation casts `x` (in case of `Tensor`) or `x.values`
    -  (in case of `SparseTensor` or `IndexedSlices`) to `dtype`.
    -
    -  For example:
    -
    -  >>> x = tf.constant([1.8, 2.2], dtype=tf.float32)
    -  >>> tf.dtypes.cast(x, tf.int32)
    -  <tf.Tensor: shape=(2,), dtype=int32, numpy=array([1, 2], dtype=int32)>
    -
    -  The operation supports data types (for `x` and `dtype`) of
    -  `uint8`, `uint16`, `uint32`, `uint64`, `int8`, `int16`, `int32`, `int64`,
    -  `float16`, `float32`, `float64`, `complex64`, `complex128`, `bfloat16`.
    -  In case of casting from complex types (`complex64`, `complex128`) to real
    -  types, only the real part of `x` is returned. In case of casting from real
    -  types to complex types (`complex64`, `complex128`), the imaginary part of the
    -  returned value is set to `0`. The handling of complex types here matches the
    -  behavior of numpy.
    -
    -  Args:
    -    x: A `Tensor` or `SparseTensor` or `IndexedSlices` of numeric type. It could
    -      be `uint8`, `uint16`, `uint32`, `uint64`, `int8`, `int16`, `int32`,
    -      `int64`, `float16`, `float32`, `float64`, `complex64`, `complex128`,
    -      `bfloat16`.
    -    dtype: The destination type. The list of supported dtypes is the same as
    -      `x`.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    A `Tensor` or `SparseTensor` or `IndexedSlices` with same shape as `x` and
    -      same type as `dtype`.
    -
    -  Raises:
    -    TypeError: If `x` cannot be cast to the `dtype`.
    -  """
    -  base_type = dtypes.as_dtype(dtype).base_dtype
    -  if isinstance(x,
    -                (ops.Tensor, _resource_variable_type)) and base_type == x.dtype:
    -    return x
    -  with ops.name_scope(name, "Cast", [x]) as name:
    -    if isinstance(x, sparse_tensor.SparseTensor):
    -      values_cast = cast(x.values, base_type, name=name)
    -      x = sparse_tensor.SparseTensor(x.indices, values_cast, x.dense_shape)
    -    elif isinstance(x, ops.IndexedSlices):
    -      values_cast = cast(x.values, base_type, name=name)
    -      x = ops.IndexedSlices(values_cast, x.indices, x.dense_shape)
    -    else:
    -      # TODO(josh11b): If x is not already a Tensor, we could return
    -      # ops.convert_to_tensor(x, dtype=dtype, ...)  here, but that
    -      # allows some conversions that cast() can't do, e.g. casting numbers to
    -      # strings.
    -      x = ops.convert_to_tensor(x, name="x")
    -      if x.dtype.base_dtype != base_type:
    -        x = gen_math_ops.cast(x, base_type, name=name)
    -    if x.dtype.is_complex and base_type.is_floating:
    -      logging.warn("Casting complex to real discards imaginary part.")
    -    return x
    -
    -
    -@tf_export("dtypes.saturate_cast", "saturate_cast")
    -@dispatch.add_dispatch_support
    -def saturate_cast(value, dtype, name=None):
    -  """Performs a safe saturating cast of `value` to `dtype`.
    -
    -  This function casts the input to `dtype` without applying any scaling.  If
    -  there is a danger that values would over or underflow in the cast, this op
    -  applies the appropriate clamping before the cast.
    -
    -  Args:
    -    value: A `Tensor`.
    -    dtype: The desired output `DType`.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    `value` safely cast to `dtype`.
    -  """
    -  # When casting to a type with smaller representable range, clamp.
    -  # Note that this covers casting to unsigned types as well.
    -  with ops.name_scope(name, "saturate_cast", [value]) as name:
    -    value = ops.convert_to_tensor(value, name="value")
    -    dtype = dtypes.as_dtype(dtype).base_dtype
    -    if value.dtype.min < dtype.min:
    -      value = gen_math_ops.maximum(
    -          value,
    -          ops.convert_to_tensor(dtype.min, dtype=value.dtype, name="min"))
    -    if value.dtype.max > dtype.max:
    -      value = gen_math_ops.minimum(
    -          value,
    -          ops.convert_to_tensor(dtype.max, dtype=value.dtype, name="max"))
    -    return cast(value, dtype, name=name)
    -
    -
    -@deprecation.deprecated(date=None, instructions="Use `tf.cast` instead.")
    -@tf_export(v1=["to_float"])
    -def to_float(x, name="ToFloat"):
    -  """Casts a tensor to type `float32`.
    -
    -  Args:
    -    x: A `Tensor` or `SparseTensor` or `IndexedSlices`.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    A `Tensor` or `SparseTensor` or `IndexedSlices` with same shape as `x` with
    -    type `float32`.
    -
    -  Raises:
    -    TypeError: If `x` cannot be cast to the `float32`.
    -  """
    -  return cast(x, dtypes.float32, name=name)
    -
    -
    -@deprecation.deprecated(date=None, instructions="Use `tf.cast` instead.")
    -@tf_export(v1=["to_double"])
    -def to_double(x, name="ToDouble"):
    -  """Casts a tensor to type `float64`.
    -
    -  Args:
    -    x: A `Tensor` or `SparseTensor` or `IndexedSlices`.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    A `Tensor` or `SparseTensor` or `IndexedSlices` with same shape as `x` with
    -    type `float64`.
    -
    -  Raises:
    -    TypeError: If `x` cannot be cast to the `float64`.
    -  """
    -  return cast(x, dtypes.float64, name=name)
    -
    -
    -@deprecation.deprecated(date=None, instructions="Use `tf.cast` instead.")
    -@tf_export(v1=["to_int32"])
    -def to_int32(x, name="ToInt32"):
    -  """Casts a tensor to type `int32`.
    -
    -  Args:
    -    x: A `Tensor` or `SparseTensor` or `IndexedSlices`.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    A `Tensor` or `SparseTensor` or `IndexedSlices` with same shape as `x` with
    -    type `int32`.
    -
    -  Raises:
    -    TypeError: If `x` cannot be cast to the `int32`.
    -  """
    -  return cast(x, dtypes.int32, name=name)
    -
    -
    -@deprecation.deprecated(date=None, instructions="Use `tf.cast` instead.")
    -@tf_export(v1=["to_int64"])
    -def to_int64(x, name="ToInt64"):
    -  """Casts a tensor to type `int64`.
    -
    -  Args:
    -    x: A `Tensor` or `SparseTensor` or `IndexedSlices`.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    A `Tensor` or `SparseTensor` or `IndexedSlices` with same shape as `x` with
    -    type `int64`.
    -
    -  Raises:
    -    TypeError: If `x` cannot be cast to the `int64`.
    -  """
    -  return cast(x, dtypes.int64, name=name)
    -
    -
    -@deprecation.deprecated(date=None, instructions="Use `tf.cast` instead.")
    -@tf_export(v1=["to_bfloat16"])
    -def to_bfloat16(x, name="ToBFloat16"):
    -  """Casts a tensor to type `bfloat16`.
    -
    -  Args:
    -    x: A `Tensor` or `SparseTensor` or `IndexedSlices`.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    A `Tensor` or `SparseTensor` or `IndexedSlices` with same shape as `x` with
    -    type `bfloat16`.
    -
    -  Raises:
    -    TypeError: If `x` cannot be cast to the `bfloat16`.
    -  """
    -  return cast(x, dtypes.bfloat16, name=name)
    -
    -
    -@deprecation.deprecated(date=None, instructions="Use `tf.cast` instead.")
    -@tf_export(v1=["to_complex64"])
    -def to_complex64(x, name="ToComplex64"):
    -  """Casts a tensor to type `complex64`.
    -
    -  Args:
    -    x: A `Tensor` or `SparseTensor` or `IndexedSlices`.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    A `Tensor` or `SparseTensor` or `IndexedSlices` with same shape as `x` with
    -    type `complex64`.
    -
    -  Raises:
    -    TypeError: If `x` cannot be cast to the `complex64`.
    -  """
    -  return cast(x, dtypes.complex64, name=name)
    -
    -
    -@deprecation.deprecated(date=None, instructions="Use `tf.cast` instead.")
    -@tf_export(v1=["to_complex128"])
    -def to_complex128(x, name="ToComplex128"):
    -  """Casts a tensor to type `complex128`.
    -
    -  Args:
    -    x: A `Tensor` or `SparseTensor` or `IndexedSlices`.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    A `Tensor` or `SparseTensor` or `IndexedSlices` with same shape as `x` with
    -    type `complex128`.
    -
    -  Raises:
    -    TypeError: If `x` cannot be cast to the `complex128`.
    -  """
    -  return cast(x, dtypes.complex128, name=name)
    -
    -
    -ops.Tensor._override_operator("__neg__", gen_math_ops.neg)
    -ops.Tensor._override_operator("__abs__", abs)
    -# __invert__ corresponds to the ~ operator.  Here we follow the numpy convention
    -# ~ marks an elementwise bit-wise inverse.  This is only implemented for boolean
    -# tensors and will throw a TypeError if used on nonboolean arrays
    -ops.Tensor._override_operator("__invert__", gen_math_ops.logical_not)
    -
    -
    -def _OverrideBinaryOperatorHelper(func, op_name, clazz_object=ops.Tensor):
    -  """Register operators with different tensor and scalar versions.
    -
    -  If `clazz_object` is `SparseTensor`, assumes `func` takes `(sp_indices,
    -  sp_values, sp_shape, dense)` and outputs `(new_sp_values)`.
    -
    -  Args:
    -    func: the operator
    -    op_name: name of the operator being overridden
    -    clazz_object: class to override for.  Either `Tensor` or `SparseTensor`.
    -  """
    -
    -  def binary_op_wrapper(x, y):
    -    with ops.name_scope(None, op_name, [x, y]) as name:
    -      if isinstance(x, ops.Tensor) and isinstance(y, ops.Tensor):
    -        return func(x, y, name=name)
    -      elif not isinstance(y, sparse_tensor.SparseTensor):
    -        try:
    -          y = ops.convert_to_tensor_v2(
    -              y, dtype_hint=x.dtype.base_dtype, name="y")
    -        except TypeError:
    -          # If the RHS is not a tensor, it might be a tensor aware object
    -          # that can implement the operator with knowledge of itself
    -          # and the tensor.
    -          if hasattr(type(y), "__r%s__" % op_name):
    -            return NotImplemented
    -          else:
    -            raise
    -      return func(x, y, name=name)
    -
    -  def binary_op_wrapper_sparse(sp_x, y):
    -    with ops.name_scope(None, op_name, [sp_x, y]) as name:
    -      y = ops.convert_to_tensor(y, dtype=sp_x.dtype.base_dtype, name="y")
    -      return sparse_tensor.SparseTensor(
    -          sp_x.indices,
    -          func(sp_x.indices, sp_x.values, sp_x.dense_shape, y, name=name),
    -          sp_x.dense_shape)
    -
    -  def r_binary_op_wrapper(y, x):
    -    with ops.name_scope(None, op_name, [x, y]) as name:
    -      x = ops.convert_to_tensor(x, dtype=y.dtype.base_dtype, name="x")
    -      return func(x, y, name=name)
    -
    -  # Propagate func.__doc__ to the wrappers
    -  try:
    -    doc = func.__doc__
    -  except AttributeError:
    -    doc = None
    -  binary_op_wrapper.__doc__ = doc
    -  r_binary_op_wrapper.__doc__ = doc
    -  binary_op_wrapper_sparse.__doc__ = doc
    -
    -  if clazz_object is ops.Tensor:
    -    clazz_object._override_operator("__%s__" % op_name, binary_op_wrapper)
    -    del binary_op_wrapper
    -    clazz_object._override_operator("__r%s__" % op_name, r_binary_op_wrapper)
    -    del r_binary_op_wrapper
    -  else:
    -    clazz_object._override_operator("__%s__" % op_name,
    -                                    binary_op_wrapper_sparse)
    -    del binary_op_wrapper_sparse
    -
    -
    -# Conversion table for __truediv__.  None entries mean no conversion required.
    -_TRUEDIV_TABLE = {
    -    dtypes.uint8: dtypes.float32,
    -    dtypes.int8: dtypes.float32,
    -    dtypes.uint16: dtypes.float32,
    -    dtypes.int16: dtypes.float32,
    -    dtypes.int32: dtypes.float64,
    -    dtypes.int64: dtypes.float64,
    -    dtypes.bfloat16: None,
    -    dtypes.float16: None,
    -    dtypes.float32: None,
    -    dtypes.float64: None,
    -    dtypes.complex64: None,
    -    dtypes.complex128: None,
    -}
    -
    -
    -# NOTE: the support of "sparse (true)div dense" is currently not baked in into
    -# "tf.(true_)div()".  Until such an API decision is made, the supported usage is
    -# to explicitly use the "/" operator to invoke either truediv or div.
    -def _sparse_dense_truediv(sp_indices, sp_values, sp_shape, y, name=None):
    -  """Internal helper function for 'sp_t / dense_t'."""
    -  with ops.name_scope(name, "truediv",
    -                      [sp_indices, sp_values, sp_shape, y]) as name:
    -    sp_values = ops.convert_to_tensor(sp_values, name="sp_values")
    -    y = ops.convert_to_tensor(y, name="y")
    -    x_dtype = sp_values.dtype.base_dtype
    -    y_dtype = y.dtype.base_dtype
    -    if x_dtype != y_dtype:
    -      raise TypeError("x and y must have the same dtype, got %r != %r" %
    -                      (x_dtype, y_dtype))
    -    try:
    -      dtype = _TRUEDIV_TABLE[x_dtype]
    -    except KeyError:
    -      raise TypeError("Invalid dtype %r in __truediv__" % x_dtype)
    -    if dtype is not None:
    -      sp_values = cast(sp_values, dtype)
    -      y = cast(y, dtype)
    -    return gen_sparse_ops.sparse_dense_cwise_div(
    -        sp_indices, sp_values, sp_shape, y, name=name)
    -
    -
    -def _truediv_python3(x, y, name=None):
    -  with ops.name_scope(name, "truediv", [x, y]) as name:
    -    x = ops.convert_to_tensor(x, name="x")
    -    y = ops.convert_to_tensor(y, name="y")
    -    x_dtype = x.dtype.base_dtype
    -    y_dtype = y.dtype.base_dtype
    -    if x_dtype != y_dtype:
    -      raise TypeError("x and y must have the same dtype, got %r != %r" %
    -                      (x_dtype, y_dtype))
    -    try:
    -      dtype = _TRUEDIV_TABLE[x_dtype]
    -    except KeyError:
    -      raise TypeError("Invalid dtype %r in __truediv__" % x_dtype)
    -    if dtype is not None:
    -      x = cast(x, dtype)
    -      y = cast(y, dtype)
    -    return gen_math_ops.real_div(x, y, name=name)
    -
    -
    -def _div_python2(x, y, name=None):
    -  """Divide two values using Python 2 semantics.
    -
    -  Used for Tensor.__div__.
    -
    -  Args:
    -    x: `Tensor` numerator of real numeric type.
    -    y: `Tensor` denominator of real numeric type.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    `x / y` returns the quotient of x and y.
    -  """
    -
    -  with ops.name_scope(name, "div", [x, y]) as name:
    -    x = ops.convert_to_tensor(x, name="x")
    -    y = ops.convert_to_tensor(y, name="y", dtype=x.dtype.base_dtype)
    -    x_dtype = x.dtype.base_dtype
    -    y_dtype = y.dtype.base_dtype
    -    if x_dtype != y_dtype:
    -      raise TypeError("x and y must have the same dtype, got %r != %r" %
    -                      (x_dtype, y_dtype))
    -    if x_dtype.is_floating or x_dtype.is_complex:
    -      return gen_math_ops.real_div(x, y, name=name)
    -    else:
    -      return gen_math_ops.floor_div(x, y, name=name)
    -
    -
    -@tf_export("math.truediv", "truediv")
    -@dispatch.add_dispatch_support
    -def truediv(x, y, name=None):
    -  """Divides x / y elementwise (using Python 3 division operator semantics).
    -
    -  NOTE: Prefer using the Tensor operator or tf.divide which obey Python
    -  division operator semantics.
    -
    -  This function forces Python 3 division operator semantics where all integer
    -  arguments are cast to floating types first.   This op is generated by normal
    -  `x / y` division in Python 3 and in Python 2.7 with
    -  `from __future__ import division`.  If you want integer division that rounds
    -  down, use `x // y` or `tf.math.floordiv`.
    -
    -  `x` and `y` must have the same numeric type.  If the inputs are floating
    -  point, the output will have the same type.  If the inputs are integral, the
    -  inputs are cast to `float32` for `int8` and `int16` and `float64` for `int32`
    -  and `int64` (matching the behavior of Numpy).
    -
    -  Args:
    -    x: `Tensor` numerator of numeric type.
    -    y: `Tensor` denominator of numeric type.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    `x / y` evaluated in floating point.
    -
    -  Raises:
    -    TypeError: If `x` and `y` have different dtypes.
    -  """
    -  return _truediv_python3(x, y, name)
    -
    -
    -@deprecation.deprecated(
    -    date=None,
    -    instructions="Deprecated in favor of operator or tf.math.divide.")
    -@tf_export(v1=["div"])
    -def div(x, y, name=None):
    -  """Divides x / y elementwise (using Python 2 division operator semantics).
    -
    -  NOTE: Prefer using the Tensor division operator or tf.divide which obey Python
    -  3 division operator semantics.
    -
    -  This function divides `x` and `y`, forcing Python 2 semantics. That is, if `x`
    -  and `y` are both integers then the result will be an integer. This is in
    -  contrast to Python 3, where division with `/` is always a float while division
    -  with `//` is always an integer.
    -
    -  Args:
    -    x: `Tensor` numerator of real numeric type.
    -    y: `Tensor` denominator of real numeric type.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    `x / y` returns the quotient of x and y.
    -  """
    -  return _div_python2(x, y, name)
    -
    -
    -@tf_export("math.divide_no_nan", v1=["math.divide_no_nan", "div_no_nan"])
    -@deprecation.deprecated_endpoints("div_no_nan")
    -@dispatch.add_dispatch_support
    -def div_no_nan(x, y, name=None):
    -  """Computes a safe divide which returns 0 if the y is zero.
    -
    -  Args:
    -    x: A `Tensor`. Must be one of the following types: `float32`, `float64`.
    -    y: A `Tensor` whose dtype is compatible with `x`.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    The element-wise value of the x divided by y.
    -  """
    -
    -  with ops.name_scope(name, "div_no_nan", [x, y]) as name:
    -    x = ops.convert_to_tensor(x, name="x")
    -    y = ops.convert_to_tensor(y, name="y", dtype=x.dtype.base_dtype)
    -    return gen_math_ops.div_no_nan(x, y, name=name)
    -
    -
    -@tf_export("math.multiply_no_nan")
    -@dispatch.add_dispatch_support
    -def multiply_no_nan(x, y, name=None):
    -  """Computes the product of x and y and returns 0 if the y is zero, even if x is NaN or infinite.
    -
    -  Args:
    -    x: A `Tensor`. Must be one of the following types: `float32`, `float64`.
    -    y: A `Tensor` whose dtype is compatible with `x`.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    The element-wise value of the x times y.
    -  """
    -
    -  with ops.name_scope(name, "multiply_no_nan", [x, y]) as name:
    -    x = ops.convert_to_tensor(x, name="x")
    -    y = ops.convert_to_tensor(y, name="y", dtype=x.dtype.base_dtype)
    -    x_dtype = x.dtype.base_dtype
    -    y_dtype = y.dtype.base_dtype
    -    if x_dtype != y_dtype:
    -      raise TypeError("x and y must have the same dtype, got %r != %r" %
    -                      (x_dtype, y_dtype))
    -    return gen_math_ops.mul_no_nan(x, y, name=name)
    -
    -
    -# TODO(aselle): This should be removed
    -mod = gen_math_ops.floor_mod
    -
    -
    -# TODO(aselle): Deprecate this once all internal functionality uses
    -# tf.truncatediv
    -@tf_export("math.floordiv", v1=["math.floordiv", "floordiv"])
    -@dispatch.add_dispatch_support
    -@deprecation.deprecated_endpoints("floordiv")
    -def floordiv(x, y, name=None):
    -  """Divides `x / y` elementwise, rounding toward the most negative integer.
    -
    -  The same as `tf.compat.v1.div(x,y)` for integers, but uses
    -  `tf.floor(tf.compat.v1.div(x,y))` for
    -  floating point arguments so that the result is always an integer (though
    -  possibly an integer represented as floating point).  This op is generated by
    -  `x // y` floor division in Python 3 and in Python 2.7 with
    -  `from __future__ import division`.
    -
    -  `x` and `y` must have the same type, and the result will have the same type
    -  as well.
    -
    -  Args:
    -    x: `Tensor` numerator of real numeric type.
    -    y: `Tensor` denominator of real numeric type.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    `x / y` rounded down.
    -
    -  Raises:
    -    TypeError: If the inputs are complex.
    -  """
    -  with ops.name_scope(name, "floordiv", [x, y]) as name:
    -    return gen_math_ops.floor_div(x, y, name=name)
    -
    -
    -realdiv = gen_math_ops.real_div
    -truncatediv = gen_math_ops.truncate_div
    -# TODO(aselle): Rename this to floordiv when we can.
    -floor_div = gen_math_ops.floor_div
    -truncatemod = gen_math_ops.truncate_mod
    -floormod = gen_math_ops.floor_mod
    -
    -
    -def _add_dispatch(x, y, name=None):
    -  """Dispatches to add for strings and add_v2 for all other types."""
    -  if x.dtype == dtypes.string:
    -    return gen_math_ops.add(x, y, name=name)
    -  else:
    -    return gen_math_ops.add_v2(x, y, name=name)
    -
    -
    -def _mul_dispatch(x, y, name=None):
    -  """Dispatches cwise mul for "Dense*Dense" and "Dense*Sparse"."""
    -  is_tensor_y = isinstance(y, ops.Tensor)
    -  if is_tensor_y:
    -    return gen_math_ops.mul(x, y, name=name)
    -  else:
    -    assert isinstance(y, sparse_tensor.SparseTensor)  # Case: Dense * Sparse.
    -    new_vals = gen_sparse_ops.sparse_dense_cwise_mul(y.indices, y.values,
    -                                                     y.dense_shape, x, name)
    -    return sparse_tensor.SparseTensor(y.indices, new_vals, y.dense_shape)
    -
    -
    -# NOTE(aselle): When integer division is added for sparse_dense_cwise,
    -# div, truediv, and floordiv should be delegated appropriately for
    -# Python semantics, analogous to dense cwise tensor operations.
    -_OverrideBinaryOperatorHelper(gen_sparse_ops.sparse_dense_cwise_div, "div",
    -                              sparse_tensor.SparseTensor)
    -_OverrideBinaryOperatorHelper(_sparse_dense_truediv, "truediv",
    -                              sparse_tensor.SparseTensor)
    -_OverrideBinaryOperatorHelper(gen_sparse_ops.sparse_dense_cwise_mul, "mul",
    -                              sparse_tensor.SparseTensor)
    -
    -_OverrideBinaryOperatorHelper(_add_dispatch, "add")
    -_OverrideBinaryOperatorHelper(gen_math_ops.sub, "sub")
    -_OverrideBinaryOperatorHelper(_mul_dispatch, "mul")
    -_OverrideBinaryOperatorHelper(_div_python2, "div")
    -_OverrideBinaryOperatorHelper(_truediv_python3, "truediv")
    -_OverrideBinaryOperatorHelper(floordiv, "floordiv")
    -_OverrideBinaryOperatorHelper(gen_math_ops.floor_mod, "mod")
    -_OverrideBinaryOperatorHelper(pow, "pow")
    -
    -
    -@tf_export("math.logical_xor", v1=["math.logical_xor", "logical_xor"])
    -@dispatch.add_dispatch_support
    -@deprecation.deprecated_endpoints("logical_xor")
    -def logical_xor(x, y, name="LogicalXor"):
    -  """Logical XOR function.
    -
    -  x ^ y = (x | y) & ~(x & y)
    -
    -  The operation works for the following input types:
    -
    -  - Two single elements of type `bool`
    -  - One `tf.Tensor` of type `bool` and one single `bool`, where the result will
    -    be calculated by applying logical XOR with the single element to each
    -    element in the larger Tensor.
    -  - Two `tf.Tensor` objects of type `bool` of the same shape. In this case,
    -    the result will be the element-wise logical XOR of the two input tensors.
    -
    -  Usage:
    -
    -  >>> a = tf.constant([True])
    -  >>> b = tf.constant([False])
    -  >>> tf.math.logical_xor(a, b)
    -  <tf.Tensor: shape=(1,), dtype=bool, numpy=array([ True])>
    -
    -  >>> c = tf.constant([True])
    -  >>> x = tf.constant([False, True, True, False])
    -  >>> tf.math.logical_xor(c, x)
    -  <tf.Tensor: shape=(4,), dtype=bool, numpy=array([ True, False, False,  True])>
    -
    -  >>> y = tf.constant([False, False, True, True])
    -  >>> z = tf.constant([False, True, False, True])
    -  >>> tf.math.logical_xor(y, z)
    -  <tf.Tensor: shape=(4,), dtype=bool, numpy=array([False,  True,  True, False])>
    -
    -  Args:
    -      x: A `tf.Tensor` type bool.
    -      y: A `tf.Tensor` of type bool.
    -      name: A name for the operation (optional).
    -
    -  Returns:
    -    A `tf.Tensor` of type bool with the same size as that of x or y.
    -  """
    -  # TODO(alemi) Make this a cwise op if people end up relying on it.
    -  return gen_math_ops.logical_and(
    -      gen_math_ops.logical_or(x, y),
    -      gen_math_ops.logical_not(gen_math_ops.logical_and(x, y)),
    -      name=name)
    -
    -
    -@tf_export("math.logical_and", "logical_and")
    -@dispatch.add_dispatch_support
    -def logical_and(x, y, name=None):
    -  """Logical AND function.
    -
    -  The operation works for the following input types:
    -
    -  - Two single elements of type `bool`
    -  - One `tf.Tensor` of type `bool` and one single `bool`, where the result will
    -    be calculated by applying logical AND with the single element to each
    -    element in the larger Tensor.
    -  - Two `tf.Tensor` objects of type `bool` of the same shape. In this case,
    -    the result will be the element-wise logical AND of the two input tensors.
    -
    -  Usage:
    -
    -  >>> a = tf.constant([True])
    -  >>> b = tf.constant([False])
    -  >>> tf.math.logical_and(a, b)
    -  <tf.Tensor: shape=(1,), dtype=bool, numpy=array([False])>
    -
    -  >>> c = tf.constant([True])
    -  >>> x = tf.constant([False, True, True, False])
    -  >>> tf.math.logical_and(c, x)
    -  <tf.Tensor: shape=(4,), dtype=bool, numpy=array([False,  True,  True, False])>
    -
    -  >>> y = tf.constant([False, False, True, True])
    -  >>> z = tf.constant([False, True, False, True])
    -  >>> tf.math.logical_and(y, z)
    -  <tf.Tensor: shape=(4,), dtype=bool, numpy=array([False, False, False,  True])>
    -
    -  Args:
    -      x: A `tf.Tensor` type bool.
    -      y: A `tf.Tensor` of type bool.
    -      name: A name for the operation (optional).
    -
    -  Returns:
    -    A `tf.Tensor` of type bool with the same size as that of x or y.
    -  """
    -  return gen_math_ops.logical_and(x, y, name)
    -
    -
    -_OverrideBinaryOperatorHelper(gen_math_ops.logical_and, "and")
    -_OverrideBinaryOperatorHelper(gen_math_ops.logical_or, "or")
    -_OverrideBinaryOperatorHelper(logical_xor, "xor")
    -
    -ops.Tensor._override_operator("__lt__", gen_math_ops.less)
    -ops.Tensor._override_operator("__le__", gen_math_ops.less_equal)
    -ops.Tensor._override_operator("__gt__", gen_math_ops.greater)
    -ops.Tensor._override_operator("__ge__", gen_math_ops.greater_equal)
    -
    -
    -@tf_export("math.equal", "equal")
    -@dispatch.add_dispatch_support
    -def equal(x, y, name=None):
    -  """Returns the truth value of (x == y) element-wise.
    -
    -  Performs a [broadcast](
    -  https://docs.scipy.org/doc/numpy/user/basics.broadcasting.html) with the
    -  arguments and then an element-wise equality comparison, returning a Tensor of
    -  boolean values.
    -
    -  For example:
    -
    -  >>> x = tf.constant([2, 4])
    -  >>> y = tf.constant(2)
    -  >>> tf.math.equal(x, y)
    -  <tf.Tensor: shape=(2,), dtype=bool, numpy=array([ True,  False])>
    -
    -  >>> x = tf.constant([2, 4])
    -  >>> y = tf.constant([2, 4])
    -  >>> tf.math.equal(x, y)
    -  <tf.Tensor: shape=(2,), dtype=bool, numpy=array([ True,  True])>
    -
    -  Args:
    -    x: A `tf.Tensor` or `tf.SparseTensor` or `tf.IndexedSlices`.
    -    y: A `tf.Tensor` or `tf.SparseTensor` or `tf.IndexedSlices`.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    A `tf.Tensor` of type bool with the same size as that of x or y.
    -
    -  Raises:
    -    `tf.errors.InvalidArgumentError`: If shapes of arguments are incompatible
    -  """
    -  return gen_math_ops.equal(x, y, name=name)
    -
    -
    -@tf_export("math.not_equal", "not_equal")
    -@dispatch.add_dispatch_support
    -def not_equal(x, y, name=None):
    -  """Returns the truth value of (x != y) element-wise.
    -
    -  Performs a [broadcast](
    -  https://docs.scipy.org/doc/numpy/user/basics.broadcasting.html) with the
    -  arguments and then an element-wise inequality comparison, returning a Tensor
    -  of boolean values.
    -
    -  For example:
    -
    -  >>> x = tf.constant([2, 4])
    -  >>> y = tf.constant(2)
    -  >>> tf.math.not_equal(x, y)
    -  <tf.Tensor: shape=(2,), dtype=bool, numpy=array([False,  True])>
    -
    -  >>> x = tf.constant([2, 4])
    -  >>> y = tf.constant([2, 4])
    -  >>> tf.math.not_equal(x, y)
    -  <tf.Tensor: shape=(2,), dtype=bool, numpy=array([False,  False])>
    -
    -  Args:
    -    x: A `tf.Tensor` or `tf.SparseTensor` or `tf.IndexedSlices`.
    -    y: A `tf.Tensor` or `tf.SparseTensor` or `tf.IndexedSlices`.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    A `tf.Tensor` of type bool with the same size as that of x or y.
    -
    -  Raises:
    -    `tf.errors.InvalidArgumentError`: If shapes of arguments are incompatible
    -  """
    -  return gen_math_ops.not_equal(x, y, name=name)
    -
    -
    -def tensor_equals(self, other):
    -  """Compares two tensors element-wise for equality."""
    -  if other is None:
    -    return False
    -  g = getattr(self, "graph", None)
    -  if (ops.Tensor._USE_EQUALITY and ops.executing_eagerly_outside_functions() and
    -      (g is None or g.building_function)):
    -    return gen_math_ops.equal(self, other, incompatible_shape_error=False)
    -  else:
    -    # In legacy graph mode, tensor equality is object equality
    -    return self is other
    -
    -
    -def tensor_not_equals(self, other):
    -  """Compares two tensors element-wise for equality."""
    -  if other is None:
    -    return True
    -  if ops.Tensor._USE_EQUALITY and ops.executing_eagerly_outside_functions():
    -    return gen_math_ops.not_equal(self, other, incompatible_shape_error=False)
    -  else:
    -    # In legacy graph mode, tensor equality is object equality
    -    return self is not other
    -
    -
    -ops.Tensor._override_operator("__eq__", tensor_equals)
    -ops.Tensor._override_operator("__ne__", tensor_not_equals)
    -
    -
    -@tf_export("range")
    -def range(start, limit=None, delta=1, dtype=None, name="range"):  # pylint: disable=redefined-builtin
    -  """Creates a sequence of numbers.
    -
    -  Creates a sequence of numbers that begins at `start` and extends by
    -  increments of `delta` up to but not including `limit`.
    -
    -  The dtype of the resulting tensor is inferred from the inputs unless
    -  it is provided explicitly.
    -
    -  Like the Python builtin `range`, `start` defaults to 0, so that
    -  `range(n) = range(0, n)`.
    -
    -  For example:
    -
    -  >>> start = 3
    -  >>> limit = 18
    -  >>> delta = 3
    -  >>> tf.range(start, limit, delta)
    -  <tf.Tensor: shape=(5,), dtype=int32,
    -  numpy=array([ 3,  6,  9, 12, 15], dtype=int32)>
    -
    -  >>> start = 3
    -  >>> limit = 1
    -  >>> delta = -0.5
    -  >>> tf.range(start, limit, delta)
    -  <tf.Tensor: shape=(4,), dtype=float32,
    -  numpy=array([3. , 2.5, 2. , 1.5], dtype=float32)>
    -
    -  >>> limit = 5
    -  >>> tf.range(limit)
    -  <tf.Tensor: shape=(5,), dtype=int32,
    -  numpy=array([0, 1, 2, 3, 4], dtype=int32)>
    -
    -  Args:
    -    start: A 0-D `Tensor` (scalar). Acts as first entry in the range if `limit`
    -      is not None; otherwise, acts as range limit and first entry defaults to 0.
    -    limit: A 0-D `Tensor` (scalar). Upper limit of sequence, exclusive. If None,
    -      defaults to the value of `start` while the first entry of the range
    -      defaults to 0.
    -    delta: A 0-D `Tensor` (scalar). Number that increments `start`. Defaults to
    -      1.
    -    dtype: The type of the elements of the resulting tensor.
    -    name: A name for the operation. Defaults to "range".
    -
    -  Returns:
    -    An 1-D `Tensor` of type `dtype`.
    -
    -  @compatibility(numpy)
    -  Equivalent to np.arange
    -  @end_compatibility
    -  """
    -  if limit is None:
    -    start, limit = 0, start
    -
    -  with ops.name_scope(name, "Range", [start, limit, delta]) as name:
    -    if not isinstance(start, ops.Tensor):
    -      start = ops.convert_to_tensor(start, dtype=dtype, name="start")
    -    if not isinstance(limit, ops.Tensor):
    -      limit = ops.convert_to_tensor(limit, dtype=dtype, name="limit")
    -    if not isinstance(delta, ops.Tensor):
    -      delta = ops.convert_to_tensor(delta, dtype=dtype, name="delta")
    -
    -    # infer dtype if not explicitly provided
    -    if dtype is None:
    -      dtype_hierarchy = [
    -          dtypes.int32, dtypes.int64, dtypes.float32, dtypes.float64
    -      ]
    -      assert all(arg.dtype in dtype_hierarchy for arg in [start, limit, delta])
    -      inferred_dtype = max([arg.dtype for arg in [start, limit, delta]],
    -                           key=dtype_hierarchy.index)
    -    else:
    -      inferred_dtype = dtype
    -    # Always try perform a cast even start/limit/delta are already tensors.
    -    # This will revole the case where start/limit/delta's original's dtype
    -    # is different from provided dtype.
    -    start = cast(start, inferred_dtype)
    -    limit = cast(limit, inferred_dtype)
    -    delta = cast(delta, inferred_dtype)
    -
    -    return gen_math_ops._range(start, limit, delta, name=name)
    -
    -
    -def _range_tensor_conversion_function(value, dtype=None, name=None,
    -                                      as_ref=False):
    -  del as_ref
    -  return range(value.start, value.stop, value.step, dtype=dtype, name=name)
    -
    -
    -if not six.PY2:
    -  ops.register_tensor_conversion_function(builtins.range,
    -                                          _range_tensor_conversion_function)
    -
    -# Reduction operations
    -def _ReductionDims(x, axis, reduction_indices=None):  # pylint: disable=invalid-name
    -  """Returns range(0, rank(x)) if reduction_indices is None."""
    -  # TODO(aselle): Remove this after deprecation
    -  if reduction_indices is not None:
    -    if axis is not None:
    -      raise ValueError("Can't specify both axis' and 'reduction_indices'.")
    -    axis = reduction_indices
    -  if axis is not None:
    -    return axis
    -  else:
    -    # Fast path: avoid creating Rank and Range ops if ndims is known.
    -    if isinstance(x, ops.Tensor):
    -      rank = x.shape.rank
    -      if rank is not None:
    -        return constant_op.constant(np.arange(rank, dtype=np.int32))
    -    elif (isinstance(x, sparse_tensor.SparseTensor) and
    -          x.dense_shape.shape.is_fully_defined()):
    -      rank = x.dense_shape.shape.dims[0].value  # sparse.dense_shape is 1-D.
    -      return constant_op.constant(np.arange(rank, dtype=np.int32))
    -
    -    # Otherwise, we rely on Range and Rank to do the right thing at run-time.
    -    return range(0, array_ops.rank(x))
    -
    -
    -def _has_fully_defined_shape(tensor):
    -  """Returns true if tensor has a fully defined shape."""
    -  return isinstance(tensor, ops.EagerTensor) or tensor.shape.is_fully_defined()
    -
    -
    -def _may_reduce_to_scalar(keepdims, axis, output):
    -  """Set a reduction's output shape to be a scalar if we are certain."""
    -  if not _has_fully_defined_shape(output) and (not keepdims) and (
    -      axis is None):
    -    output.set_shape(())
    -  return output
    -
    -
    -@tf_export(v1=["math.reduce_sum", "reduce_sum"])
    -@deprecation.deprecated_args(None,
    -                             "keep_dims is deprecated, use keepdims instead",
    -                             "keep_dims")
    -def reduce_sum_v1(input_tensor,
    -                  axis=None,
    -                  keepdims=None,
    -                  name=None,
    -                  reduction_indices=None,
    -                  keep_dims=None):
    -  """Computes the sum of elements across dimensions of a tensor.
    -
    -  Reduces `input_tensor` along the dimensions given in `axis`.
    -  Unless `keepdims` is true, the rank of the tensor is reduced by 1 for each
    -  entry in `axis`. If `keepdims` is true, the reduced dimensions
    -  are retained with length 1.
    -
    -  If `axis` is None, all dimensions are reduced, and a
    -  tensor with a single element is returned.
    -
    -  For example:
    -
    -  ```python
    -  x = tf.constant([[1, 1, 1], [1, 1, 1]])
    -  tf.reduce_sum(x)  # 6
    -  tf.reduce_sum(x, 0)  # [2, 2, 2]
    -  tf.reduce_sum(x, 1)  # [3, 3]
    -  tf.reduce_sum(x, 1, keepdims=True)  # [[3], [3]]
    -  tf.reduce_sum(x, [0, 1])  # 6
    -  ```
    -
    -  Args:
    -    input_tensor: The tensor to reduce. Should have numeric type.
    -    axis: The dimensions to reduce. If `None` (the default), reduces all
    -      dimensions. Must be in the range `[-rank(input_tensor),
    -      rank(input_tensor))`.
    -    keepdims: If true, retains reduced dimensions with length 1.
    -    name: A name for the operation (optional).
    -    reduction_indices: The old (deprecated) name for axis.
    -    keep_dims: Deprecated alias for `keepdims`.
    -
    -  Returns:
    -    The reduced tensor, of the same dtype as the input_tensor.
    -
    -  @compatibility(numpy)
    -  Equivalent to np.sum apart the fact that numpy upcast uint8 and int32 to
    -  int64 while tensorflow returns the same dtype as the input.
    -  @end_compatibility
    -  """
    -  axis = deprecation.deprecated_argument_lookup("axis", axis,
    -                                                "reduction_indices",
    -                                                reduction_indices)
    -  keepdims = deprecation.deprecated_argument_lookup("keepdims", keepdims,
    -                                                    "keep_dims", keep_dims)
    -  return reduce_sum(input_tensor, axis, keepdims, name)
    -
    -
    -@tf_export("math.reduce_sum", "reduce_sum", v1=[])
    -@dispatch.add_dispatch_support
    -def reduce_sum(input_tensor, axis=None, keepdims=False, name=None):
    -  """Computes the sum of elements across dimensions of a tensor.
    -
    -  Reduces `input_tensor` along the dimensions given in `axis`.
    -  Unless `keepdims` is true, the rank of the tensor is reduced by 1 for each
    -  entry in `axis`. If `keepdims` is true, the reduced dimensions
    -  are retained with length 1.
    -
    -  If `axis` is None, all dimensions are reduced, and a
    -  tensor with a single element is returned.
    -
    -  For example:
    -
    -  ```python
    -  x = tf.constant([[1, 1, 1], [1, 1, 1]])
    -  tf.reduce_sum(x)  # 6
    -  tf.reduce_sum(x, 0)  # [2, 2, 2]
    -  tf.reduce_sum(x, 1)  # [3, 3]
    -  tf.reduce_sum(x, 1, keepdims=True)  # [[3], [3]]
    -  tf.reduce_sum(x, [0, 1])  # 6
    -  ```
    -
    -  Args:
    -    input_tensor: The tensor to reduce. Should have numeric type.
    -    axis: The dimensions to reduce. If `None` (the default), reduces all
    -      dimensions. Must be in the range `[-rank(input_tensor),
    -      rank(input_tensor))`.
    -    keepdims: If true, retains reduced dimensions with length 1.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    The reduced tensor, of the same dtype as the input_tensor.
    -
    -  @compatibility(numpy)
    -  Equivalent to np.sum apart the fact that numpy upcast uint8 and int32 to
    -  int64 while tensorflow returns the same dtype as the input.
    -  @end_compatibility
    -  """
    -
    -  return reduce_sum_with_dims(input_tensor, axis, keepdims, name,
    -                              _ReductionDims(input_tensor, axis))
    -
    -
    -def reduce_sum_with_dims(input_tensor,
    -                         axis=None,
    -                         keepdims=False,
    -                         name=None,
    -                         dims=None):
    -  keepdims = False if keepdims is None else keepdims
    -  return _may_reduce_to_scalar(
    -      keepdims, axis,
    -      gen_math_ops._sum(input_tensor, dims, keepdims, name=name))
    -
    -
    -@tf_export("math.reduce_euclidean_norm")
    -def reduce_euclidean_norm(input_tensor, axis=None, keepdims=False, name=None):
    -  """Computes the Euclidean norm of elements across dimensions of a tensor.
    -
    -  Reduces `input_tensor` along the dimensions given in `axis`.
    -  Unless `keepdims` is true, the rank of the tensor is reduced by 1 for each
    -  entry in `axis`. If `keepdims` is true, the reduced dimensions
    -  are retained with length 1.
    -
    -  If `axis` is None, all dimensions are reduced, and a
    -  tensor with a single element is returned.
    -
    -  For example:
    -
    -  ```python
    -  x = tf.constant([[1, 2, 3], [1, 1, 1]]) # x.dtype is tf.int32
    -  tf.math.reduce_euclidean_norm(x)  # returns 4 as dtype is tf.int32
    -  y = tf.constant([[1, 2, 3], [1, 1, 1]], dtype = tf.float32)
    -  tf.math.reduce_euclidean_norm(y)  # returns 4.1231055 which is sqrt(17)
    -  tf.math.reduce_euclidean_norm(y, 0)  # [sqrt(2), sqrt(5), sqrt(10)]
    -  tf.math.reduce_euclidean_norm(y, 1)  # [sqrt(14), sqrt(3)]
    -  tf.math.reduce_euclidean_norm(y, 1, keepdims=True)  # [[sqrt(14)], [sqrt(3)]]
    -  tf.math.reduce_euclidean_norm(y, [0, 1])  # sqrt(17)
    -  ```
    -
    -  Args:
    -    input_tensor: The tensor to reduce. Should have numeric type.
    -    axis: The dimensions to reduce. If `None` (the default), reduces all
    -      dimensions. Must be in the range `[-rank(input_tensor),
    -      rank(input_tensor))`.
    -    keepdims: If true, retains reduced dimensions with length 1.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    The reduced tensor, of the same dtype as the input_tensor.
    -  """
    -  return _may_reduce_to_scalar(
    -      keepdims, axis,
    -      gen_math_ops.euclidean_norm(
    -          input_tensor, _ReductionDims(input_tensor, axis), keepdims,
    -          name=name))
    -
    -
    -@tf_export(v1=["math.count_nonzero", "count_nonzero"])
    -@deprecation.deprecated_args(None,
    -                             "keep_dims is deprecated, use keepdims instead",
    -                             "keep_dims")
    -@deprecation.deprecated_args(
    -    None, "reduction_indices is deprecated, use axis instead",
    -    "reduction_indices")
    -def count_nonzero(input_tensor=None,
    -                  axis=None,
    -                  keepdims=None,
    -                  dtype=dtypes.int64,
    -                  name=None,
    -                  reduction_indices=None,
    -                  keep_dims=None,
    -                  input=None):  # pylint: disable=redefined-builtin
    -  """Computes number of nonzero elements across dimensions of a tensor.
    -
    -  Reduces `input_tensor` along the dimensions given in `axis`.
    -  Unless `keepdims` is true, the rank of the tensor is reduced by 1 for each
    -  entry in `axis`. If `keepdims` is true, the reduced dimensions
    -  are retained with length 1.
    -
    -  If `axis` has no entries, all dimensions are reduced, and a
    -  tensor with a single element is returned.
    -
    -  **NOTE** Floating point comparison to zero is done by exact floating point
    -  equality check.  Small values are **not** rounded to zero for purposes of
    -  the nonzero check.
    -
    -  For example:
    -
    -  ```python
    -  x = tf.constant([[0, 1, 0], [1, 1, 0]])
    -  tf.math.count_nonzero(x)  # 3
    -  tf.math.count_nonzero(x, 0)  # [1, 2, 0]
    -  tf.math.count_nonzero(x, 1)  # [1, 2]
    -  tf.math.count_nonzero(x, 1, keepdims=True)  # [[1], [2]]
    -  tf.math.count_nonzero(x, [0, 1])  # 3
    -  ```
    -
    -  **NOTE** Strings are compared against zero-length empty string `""`. Any
    -  string with a size greater than zero is already considered as nonzero.
    -
    -  For example:
    -  ```python
    -  x = tf.constant(["", "a", "  ", "b", ""])
    -  tf.math.count_nonzero(x) # 3, with "a", "  ", and "b" as nonzero strings.
    -  ```
    -
    -  Args:
    -    input_tensor: The tensor to reduce. Should be of numeric type, `bool`, or
    -      `string`.
    -    axis: The dimensions to reduce. If `None` (the default), reduces all
    -      dimensions. Must be in the range `[-rank(input_tensor),
    -      rank(input_tensor))`.
    -    keepdims: If true, retains reduced dimensions with length 1.
    -    dtype: The output dtype; defaults to `tf.int64`.
    -    name: A name for the operation (optional).
    -    reduction_indices: The old (deprecated) name for axis.
    -    keep_dims: Deprecated alias for `keepdims`.
    -    input: Overrides input_tensor. For compatibility.
    -
    -  Returns:
    -    The reduced tensor (number of nonzero values).
    -  """
    -  keepdims = deprecation.deprecated_argument_lookup("keepdims", keepdims,
    -                                                    "keep_dims", keep_dims)
    -  input_tensor = deprecation.deprecated_argument_lookup("input", input,
    -                                                        "input_tensor",
    -                                                        input_tensor)
    -  axis = deprecation.deprecated_argument_lookup("axis", axis,
    -                                                "reduction_indices",
    -                                                reduction_indices)
    -
    -  return count_nonzero_v2(input_tensor, axis, keepdims, dtype, name)
    -
    -
    -@tf_export("math.count_nonzero", v1=[])
    -def count_nonzero_v2(
    -    input,  # pylint: disable=redefined-builtin
    -    axis=None,
    -    keepdims=None,
    -    dtype=dtypes.int64,
    -    name=None):
    -  """Computes number of nonzero elements across dimensions of a tensor.
    -
    -  Reduces `input` along the dimensions given in `axis`.
    -  Unless `keepdims` is true, the rank of the tensor is reduced by 1 for each
    -  entry in `axis`. If `keepdims` is true, the reduced dimensions
    -  are retained with length 1.
    -
    -  If `axis` has no entries, all dimensions are reduced, and a
    -  tensor with a single element is returned.
    -
    -  **NOTE** Floating point comparison to zero is done by exact floating point
    -  equality check.  Small values are **not** rounded to zero for purposes of
    -  the nonzero check.
    -
    -  For example:
    -
    -  ```python
    -  x = tf.constant([[0, 1, 0], [1, 1, 0]])
    -  tf.math.count_nonzero(x)  # 3
    -  tf.math.count_nonzero(x, 0)  # [1, 2, 0]
    -  tf.math.count_nonzero(x, 1)  # [1, 2]
    -  tf.math.count_nonzero(x, 1, keepdims=True)  # [[1], [2]]
    -  tf.math.count_nonzero(x, [0, 1])  # 3
    -  ```
    -
    -  **NOTE** Strings are compared against zero-length empty string `""`. Any
    -  string with a size greater than zero is already considered as nonzero.
    -
    -  For example:
    -  ```python
    -  x = tf.constant(["", "a", "  ", "b", ""])
    -  tf.math.count_nonzero(x) # 3, with "a", "  ", and "b" as nonzero strings.
    -  ```
    -
    -  Args:
    -    input: The tensor to reduce. Should be of numeric type, `bool`, or `string`.
    -    axis: The dimensions to reduce. If `None` (the default), reduces all
    -      dimensions. Must be in the range `[-rank(input), rank(input))`.
    -    keepdims: If true, retains reduced dimensions with length 1.
    -    dtype: The output dtype; defaults to `tf.int64`.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    The reduced tensor (number of nonzero values).
    -  """
    -  if keepdims is None:
    -    keepdims = False
    -  with ops.name_scope(name, "count_nonzero", [input]):
    -    input = ops.convert_to_tensor(input, name="input")
    -    # A scalar of 'zero' is enough as `not_equal` will broadcast.
    -    zero = array_ops.zeros([], dtype=input.dtype)
    -    return cast(
    -        reduce_sum(
    -            # int64 reduction happens on GPU
    -            cast(gen_math_ops.not_equal(input, zero), dtypes.int64),
    -            axis=axis,
    -            keepdims=keepdims),
    -        dtype=dtype)
    -
    -
    -@tf_export(v1=["math.reduce_mean", "reduce_mean"])
    -def reduce_mean_v1(input_tensor,
    -                   axis=None,
    -                   keepdims=None,
    -                   name=None,
    -                   reduction_indices=None,
    -                   keep_dims=None):
    -  """Computes the mean of elements across dimensions of a tensor.
    -
    -  Reduces `input_tensor` along the dimensions given in `axis` by computing the
    -  mean of elements across the dimensions in `axis`.
    -  Unless `keepdims` is true, the rank of the tensor is reduced by 1 for each
    -  entry in `axis`. If `keepdims` is true, the reduced dimensions
    -  are retained with length 1.
    -
    -  If `axis` is None, all dimensions are reduced, and a tensor with a single
    -  element is returned.
    -
    -  For example:
    -
    -  >>> x = tf.constant([[1., 1.], [2., 2.]])
    -  >>> tf.reduce_mean(x)
    -  <tf.Tensor: shape=(), dtype=float32, numpy=1.5>
    -  >>> tf.reduce_mean(x, 0)
    -  <tf.Tensor: shape=(2,), dtype=float32, numpy=array([1.5, 1.5], dtype=float32)>
    -  >>> tf.reduce_mean(x, 1)
    -  <tf.Tensor: shape=(2,), dtype=float32, numpy=array([1., 2.], dtype=float32)>
    -
    -  Args:
    -    input_tensor: The tensor to reduce. Should have numeric type.
    -    axis: The dimensions to reduce. If `None` (the default), reduces all
    -      dimensions. Must be in the range `[-rank(input_tensor),
    -      rank(input_tensor))`.
    -    keepdims: If true, retains reduced dimensions with length 1.
    -    name: A name for the operation (optional).
    -    reduction_indices: The old (deprecated) name for axis.
    -    keep_dims: Deprecated alias for `keepdims`.
    -
    -  Returns:
    -    The reduced tensor.
    -
    -  @compatibility(numpy)
    -  Equivalent to np.mean
    -
    -  Please note that `np.mean` has a `dtype` parameter that could be used to
    -  specify the output type. By default this is `dtype=float64`. On the other
    -  hand, `tf.reduce_mean` has an aggressive type inference from `input_tensor`,
    -  for example:
    -
    -  >>> x = tf.constant([1, 0, 1, 0])
    -  >>> tf.reduce_mean(x)
    -  <tf.Tensor: shape=(), dtype=int32, numpy=0>
    -  >>> y = tf.constant([1., 0., 1., 0.])
    -  >>> tf.reduce_mean(y)
    -  <tf.Tensor: shape=(), dtype=float32, numpy=0.5>
    -
    -  @end_compatibility
    -  """
    -  axis = deprecation.deprecated_argument_lookup("axis", axis,
    -                                                "reduction_indices",
    -                                                reduction_indices)
    -  keepdims = deprecation.deprecated_argument_lookup("keepdims", keepdims,
    -                                                    "keep_dims", keep_dims)
    -  return reduce_mean(input_tensor, axis, keepdims, name)
    -
    -
    -@tf_export("math.reduce_mean", "reduce_mean", v1=[])
    -@dispatch.add_dispatch_support
    -def reduce_mean(input_tensor, axis=None, keepdims=False, name=None):
    -  """Computes the mean of elements across dimensions of a tensor.
    -
    -  Reduces `input_tensor` along the dimensions given in `axis` by computing the
    -  mean of elements across the dimensions in `axis`.
    -  Unless `keepdims` is true, the rank of the tensor is reduced by 1 for each
    -  entry in `axis`. If `keepdims` is true, the reduced dimensions are retained
    -  with length 1.
    -
    -  If `axis` is None, all dimensions are reduced, and a tensor with a single
    -  element is returned.
    -
    -  For example:
    -
    -  >>> x = tf.constant([[1., 1.], [2., 2.]])
    -  >>> tf.reduce_mean(x)
    -  <tf.Tensor: shape=(), dtype=float32, numpy=1.5>
    -  >>> tf.reduce_mean(x, 0)
    -  <tf.Tensor: shape=(2,), dtype=float32, numpy=array([1.5, 1.5], dtype=float32)>
    -  >>> tf.reduce_mean(x, 1)
    -  <tf.Tensor: shape=(2,), dtype=float32, numpy=array([1., 2.], dtype=float32)>
    -
    -  Args:
    -    input_tensor: The tensor to reduce. Should have numeric type.
    -    axis: The dimensions to reduce. If `None` (the default), reduces all
    -      dimensions. Must be in the range `[-rank(input_tensor),
    -      rank(input_tensor))`.
    -    keepdims: If true, retains reduced dimensions with length 1.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    The reduced tensor.
    -
    -  @compatibility(numpy)
    -  Equivalent to np.mean
    -
    -  Please note that `np.mean` has a `dtype` parameter that could be used to
    -  specify the output type. By default this is `dtype=float64`. On the other
    -  hand, `tf.reduce_mean` has an aggressive type inference from `input_tensor`,
    -  for example:
    -
    -  >>> x = tf.constant([1, 0, 1, 0])
    -  >>> tf.reduce_mean(x)
    -  <tf.Tensor: shape=(), dtype=int32, numpy=0>
    -  >>> y = tf.constant([1., 0., 1., 0.])
    -  >>> tf.reduce_mean(y)
    -  <tf.Tensor: shape=(), dtype=float32, numpy=0.5>
    -
    -  @end_compatibility
    -  """
    -  keepdims = False if keepdims is None else keepdims
    -  return _may_reduce_to_scalar(
    -      keepdims, axis,
    -      gen_math_ops.mean(
    -          input_tensor, _ReductionDims(input_tensor, axis), keepdims,
    -          name=name))
    -
    -
    -@tf_export("math.reduce_variance")
    -def reduce_variance(input_tensor, axis=None, keepdims=False, name=None):
    -  """Computes the variance of elements across dimensions of a tensor.
    -
    -  Reduces `input_tensor` along the dimensions given in `axis`.
    -  Unless `keepdims` is true, the rank of the tensor is reduced by 1 for each
    -  entry in `axis`. If `keepdims` is true, the reduced dimensions
    -  are retained with length 1.
    -
    -  If `axis` is None, all dimensions are reduced, and a
    -  tensor with a single element is returned.
    -
    -  For example:
    -
    -  ```python
    -  x = tf.constant([[1., 2.], [3., 4.]])
    -  tf.reduce_variance(x)  # 1.25
    -  tf.reduce_variance(x, 0)  # [1., 1.]
    -  tf.reduce_variance(x, 1)  # [0.25,  0.25]
    -  ```
    -
    -  Args:
    -    input_tensor: The tensor to reduce. Should have numeric type.
    -    axis: The dimensions to reduce. If `None` (the default), reduces all
    -      dimensions. Must be in the range `[-rank(input_tensor),
    -      rank(input_tensor))`.
    -    keepdims: If true, retains reduced dimensions with length 1.
    -    name: A name scope for the associated operations (optional).
    -
    -  Returns:
    -    The reduced tensor, of the same dtype as the input_tensor.
    -
    -  @compatibility(numpy)
    -  Equivalent to np.var
    -
    -  Please note that `np.var` has a `dtype` parameter that could be used to
    -  specify the output type. By default this is `dtype=float64`. On the other
    -  hand, `tf.reduce_variance` has an aggressive type inference from
    -  `input_tensor`,
    -  @end_compatibility
    -  """
    -  name = name if name else "reduce_variance"
    -  with ops.name_scope(name):
    -    means = reduce_mean(input_tensor, axis=axis, keepdims=True)
    -    squared_deviations = gen_math_ops.square(input_tensor - means)
    -    return reduce_mean(squared_deviations, axis=axis, keepdims=keepdims)
    -
    -
    -@tf_export("math.reduce_std")
    -def reduce_std(input_tensor, axis=None, keepdims=False, name=None):
    -  """Computes the standard deviation of elements across dimensions of a tensor.
    -
    -  Reduces `input_tensor` along the dimensions given in `axis`.
    -  Unless `keepdims` is true, the rank of the tensor is reduced by 1 for each
    -  entry in `axis`. If `keepdims` is true, the reduced dimensions
    -  are retained with length 1.
    -
    -  If `axis` is None, all dimensions are reduced, and a
    -  tensor with a single element is returned.
    -
    -  For example:
    -
    -  ```python
    -  x = tf.constant([[1., 2.], [3., 4.]])
    -  tf.reduce_std(x)  # 1.1180339887498949
    -  tf.reduce_std(x, 0)  # [1., 1.]
    -  tf.reduce_std(x, 1)  # [0.5,  0.5]
    -  ```
    -
    -  Args:
    -    input_tensor: The tensor to reduce. Should have numeric type.
    -    axis: The dimensions to reduce. If `None` (the default), reduces all
    -      dimensions. Must be in the range `[-rank(input_tensor),
    -      rank(input_tensor))`.
    -    keepdims: If true, retains reduced dimensions with length 1.
    -    name: A name scope for the associated operations (optional).
    -
    -  Returns:
    -    The reduced tensor, of the same dtype as the input_tensor.
    -
    -  @compatibility(numpy)
    -  Equivalent to np.std
    -
    -  Please note that `np.std` has a `dtype` parameter that could be used to
    -  specify the output type. By default this is `dtype=float64`. On the other
    -  hand, `tf.reduce_std` has an aggressive type inference from `input_tensor`,
    -  @end_compatibility
    -  """
    -  name = name if name else "reduce_std"
    -  with ops.name_scope(name):
    -    variance = reduce_variance(input_tensor, axis=axis, keepdims=keepdims)
    -    return gen_math_ops.sqrt(variance)
    -
    -
    -@tf_export("math.reduce_prod", "reduce_prod", v1=[])
    -@dispatch.add_dispatch_support
    -def reduce_prod(input_tensor, axis=None, keepdims=False, name=None):
    -  """Computes the product of elements across dimensions of a tensor.
    -
    -  Reduces `input_tensor` along the dimensions given in `axis`.
    -  Unless `keepdims` is true, the rank of the tensor is reduced by 1 for each
    -  entry in `axis`. If `keepdims` is true, the reduced dimensions
    -  are retained with length 1.
    -
    -  If `axis` is None, all dimensions are reduced, and a
    -  tensor with a single element is returned.
    -
    -  Args:
    -    input_tensor: The tensor to reduce. Should have numeric type.
    -    axis: The dimensions to reduce. If `None` (the default), reduces all
    -      dimensions. Must be in the range `[-rank(input_tensor),
    -      rank(input_tensor))`.
    -    keepdims: If true, retains reduced dimensions with length 1.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    The reduced tensor.
    -
    -  @compatibility(numpy)
    -  Equivalent to np.prod
    -  @end_compatibility
    -  """
    -  keepdims = False if keepdims is None else keepdims
    -  return _may_reduce_to_scalar(
    -      keepdims, axis,
    -      gen_math_ops.prod(
    -          input_tensor, _ReductionDims(input_tensor, axis), keepdims,
    -          name=name))
    -
    -
    -@tf_export(v1=["math.reduce_prod", "reduce_prod"])
    -@deprecation.deprecated_args(None,
    -                             "keep_dims is deprecated, use keepdims instead",
    -                             "keep_dims")
    -def reduce_prod_v1(input_tensor,
    -                   axis=None,
    -                   keepdims=None,
    -                   name=None,
    -                   reduction_indices=None,
    -                   keep_dims=None):
    -  """Computes the product of elements across dimensions of a tensor.
    -
    -  Reduces `input_tensor` along the dimensions given in `axis`.
    -  Unless `keepdims` is true, the rank of the tensor is reduced by 1 for each
    -  entry in `axis`. If `keepdims` is true, the reduced dimensions
    -  are retained with length 1.
    -
    -  If `axis` is None, all dimensions are reduced, and a
    -  tensor with a single element is returned.
    -
    -  Args:
    -    input_tensor: The tensor to reduce. Should have numeric type.
    -    axis: The dimensions to reduce. If `None` (the default), reduces all
    -      dimensions. Must be in the range `[-rank(input_tensor),
    -      rank(input_tensor))`.
    -    keepdims: If true, retains reduced dimensions with length 1.
    -    name: A name for the operation (optional).
    -    reduction_indices: The old (deprecated) name for axis.
    -    keep_dims: Deprecated alias for `keepdims`.
    -
    -  Returns:
    -    The reduced tensor.
    -
    -  @compatibility(numpy)
    -  Equivalent to np.prod
    -  @end_compatibility
    -  """
    -  axis = deprecation.deprecated_argument_lookup("axis", axis,
    -                                                "reduction_indices",
    -                                                reduction_indices)
    -  keepdims = deprecation.deprecated_argument_lookup("keepdims", keepdims,
    -                                                    "keep_dims", keep_dims)
    -  return reduce_prod(input_tensor, axis, keepdims, name)
    -
    -
    -@tf_export(v1=["math.reduce_min", "reduce_min"])
    -@deprecation.deprecated_args(None,
    -                             "keep_dims is deprecated, use keepdims instead",
    -                             "keep_dims")
    -def reduce_min_v1(input_tensor,
    -                  axis=None,
    -                  keepdims=None,
    -                  name=None,
    -                  reduction_indices=None,
    -                  keep_dims=None):
    -  """Computes the minimum of elements across dimensions of a tensor.
    -
    -  Reduces `input_tensor` along the dimensions given in `axis`.
    -  Unless `keepdims` is true, the rank of the tensor is reduced by 1 for each
    -  entry in `axis`. If `keepdims` is true, the reduced dimensions
    -  are retained with length 1.
    -
    -  If `axis` is None, all dimensions are reduced, and a
    -  tensor with a single element is returned.
    -
    -  Args:
    -    input_tensor: The tensor to reduce. Should have real numeric type.
    -    axis: The dimensions to reduce. If `None` (the default), reduces all
    -      dimensions. Must be in the range `[-rank(input_tensor),
    -      rank(input_tensor))`.
    -    keepdims: If true, retains reduced dimensions with length 1.
    -    name: A name for the operation (optional).
    -    reduction_indices: The old (deprecated) name for axis.
    -    keep_dims: Deprecated alias for `keepdims`.
    -
    -  Returns:
    -    The reduced tensor.
    -
    -  @compatibility(numpy)
    -  Equivalent to np.min
    -  @end_compatibility
    -  """
    -  axis = deprecation.deprecated_argument_lookup("axis", axis,
    -                                                "reduction_indices",
    -                                                reduction_indices)
    -  keepdims = deprecation.deprecated_argument_lookup("keepdims", keepdims,
    -                                                    "keep_dims", keep_dims)
    -  return reduce_min(input_tensor, axis, keepdims, name)
    -
    -
    -@tf_export("math.reduce_min", "reduce_min", v1=[])
    -@dispatch.add_dispatch_support
    -def reduce_min(input_tensor, axis=None, keepdims=False, name=None):
    -  """Computes the minimum of elements across dimensions of a tensor.
    -
    -  Reduces `input_tensor` along the dimensions given in `axis`.
    -  Unless `keepdims` is true, the rank of the tensor is reduced by 1 for each
    -  entry in `axis`. If `keepdims` is true, the reduced dimensions
    -  are retained with length 1.
    -
    -  If `axis` is None, all dimensions are reduced, and a
    -  tensor with a single element is returned.
    -
    -  Args:
    -    input_tensor: The tensor to reduce. Should have real numeric type.
    -    axis: The dimensions to reduce. If `None` (the default), reduces all
    -      dimensions. Must be in the range `[-rank(input_tensor),
    -      rank(input_tensor))`.
    -    keepdims: If true, retains reduced dimensions with length 1.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    The reduced tensor.
    -
    -  For example:
    -    >>> a = tf.constant([[1, 2], [3, 4]])
    -    >>> tf.reduce_min(a)
    -    <tf.Tensor: shape=(), dtype=int32, numpy=1>
    -
    -  @compatibility(numpy)
    -  Equivalent to np.min
    -  @end_compatibility
    -  """
    -  keepdims = False if keepdims is None else keepdims
    -  return _may_reduce_to_scalar(
    -      keepdims, axis,
    -      gen_math_ops._min(
    -          input_tensor, _ReductionDims(input_tensor, axis), keepdims,
    -          name=name))
    -
    -
    -@tf_export(v1=["math.reduce_max", "reduce_max"])
    -@deprecation.deprecated_args(None,
    -                             "keep_dims is deprecated, use keepdims instead",
    -                             "keep_dims")
    -def reduce_max_v1(input_tensor,
    -                  axis=None,
    -                  keepdims=None,
    -                  name=None,
    -                  reduction_indices=None,
    -                  keep_dims=None):
    -  """Computes the maximum of elements across dimensions of a tensor.
    -
    -  Reduces `input_tensor` along the dimensions given in `axis`.
    -  Unless `keepdims` is true, the rank of the tensor is reduced by 1 for each
    -  entry in `axis`. If `keepdims` is true, the reduced dimensions
    -  are retained with length 1.
    -
    -  If `axis` is None, all dimensions are reduced, and a
    -  tensor with a single element is returned.
    -
    -  Args:
    -    input_tensor: The tensor to reduce. Should have real numeric type.
    -    axis: The dimensions to reduce. If `None` (the default), reduces all
    -      dimensions. Must be in the range `[-rank(input_tensor),
    -      rank(input_tensor))`.
    -    keepdims: If true, retains reduced dimensions with length 1.
    -    name: A name for the operation (optional).
    -    reduction_indices: The old (deprecated) name for axis.
    -    keep_dims: Deprecated alias for `keepdims`.
    -
    -  Returns:
    -    The reduced tensor.
    -
    -  @compatibility(numpy)
    -  Equivalent to np.max
    -  @end_compatibility
    -  """
    -  axis = deprecation.deprecated_argument_lookup("axis", axis,
    -                                                "reduction_indices",
    -                                                reduction_indices)
    -  keepdims = deprecation.deprecated_argument_lookup("keepdims", keepdims,
    -                                                    "keep_dims", keep_dims)
    -  return reduce_max(input_tensor, axis, keepdims, name)
    -
    -
    -@tf_export("math.reduce_max", "reduce_max", v1=[])
    -@dispatch.add_dispatch_support
    -def reduce_max(input_tensor, axis=None, keepdims=False, name=None):
    -  """Computes the maximum of elements across dimensions of a tensor.
    -
    -  Reduces `input_tensor` along the dimensions given in `axis`.
    -  Unless `keepdims` is true, the rank of the tensor is reduced by 1 for each
    -  entry in `axis`. If `keepdims` is true, the reduced dimensions
    -  are retained with length 1.
    -
    -  If `axis` is None, all dimensions are reduced, and a
    -  tensor with a single element is returned.
    -
    -  Usage example:
    -
    -  >>> x = tf.constant([5, 1, 2, 4])
    -  >>> print(tf.reduce_max(x))
    -  tf.Tensor(5, shape=(), dtype=int32)
    -  >>> x = tf.constant([-5, -1, -2, -4])
    -  >>> print(tf.reduce_max(x))
    -  tf.Tensor(-1, shape=(), dtype=int32)
    -  >>> x = tf.constant([4, float('nan')])
    -  >>> print(tf.reduce_max(x))
    -  tf.Tensor(4.0, shape=(), dtype=float32)
    -  >>> x = tf.constant([float('nan'), float('nan')])
    -  >>> print(tf.reduce_max(x))
    -  tf.Tensor(-inf, shape=(), dtype=float32)
    -  >>> x = tf.constant([float('-inf'), float('inf')])
    -  >>> print(tf.reduce_max(x))
    -  tf.Tensor(inf, shape=(), dtype=float32)
    -
    -  See the numpy docs for `np.amax` and `np.nanmax` behavior.
    -
    -  Args:
    -    input_tensor: The tensor to reduce. Should have real numeric type.
    -    axis: The dimensions to reduce. If `None` (the default), reduces all
    -      dimensions. Must be in the range `[-rank(input_tensor),
    -      rank(input_tensor))`.
    -    keepdims: If true, retains reduced dimensions with length 1.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    The reduced tensor.
    -  """
    -  return reduce_max_with_dims(input_tensor, axis, keepdims, name,
    -                              _ReductionDims(input_tensor, axis))
    -
    -
    -def reduce_max_with_dims(input_tensor,
    -                         axis=None,
    -                         keepdims=False,
    -                         name=None,
    -                         dims=None):
    -  keepdims = False if keepdims is None else keepdims
    -  return _may_reduce_to_scalar(
    -      keepdims, axis,
    -      gen_math_ops._max(input_tensor, dims, keepdims, name=name))
    -
    -
    -@tf_export(v1=["math.reduce_all", "reduce_all"])
    -@deprecation.deprecated_args(None,
    -                             "keep_dims is deprecated, use keepdims instead",
    -                             "keep_dims")
    -def reduce_all_v1(input_tensor,
    -                  axis=None,
    -                  keepdims=None,
    -                  name=None,
    -                  reduction_indices=None,
    -                  keep_dims=None):
    -  """Computes the "logical and" of elements across dimensions of a tensor.
    -
    -  Reduces `input_tensor` along the dimensions given in `axis`.
    -  Unless `keepdims` is true, the rank of the tensor is reduced by 1 for each
    -  entry in `axis`. If `keepdims` is true, the reduced dimensions
    -  are retained with length 1.
    -
    -  If `axis` is None, all dimensions are reduced, and a
    -  tensor with a single element is returned.
    -
    -  For example:
    -
    -  ```python
    -  x = tf.constant([[True,  True], [False, False]])
    -  tf.reduce_all(x)  # False
    -  tf.reduce_all(x, 0)  # [False, False]
    -  tf.reduce_all(x, 1)  # [True, False]
    -  ```
    -
    -  Args:
    -    input_tensor: The boolean tensor to reduce.
    -    axis: The dimensions to reduce. If `None` (the default), reduces all
    -      dimensions. Must be in the range `[-rank(input_tensor),
    -      rank(input_tensor))`.
    -    keepdims: If true, retains reduced dimensions with length 1.
    -    name: A name for the operation (optional).
    -    reduction_indices: The old (deprecated) name for axis.
    -    keep_dims: Deprecated alias for `keepdims`.
    -
    -  Returns:
    -    The reduced tensor.
    -
    -  @compatibility(numpy)
    -  Equivalent to np.all
    -  @end_compatibility
    -  """
    -  axis = deprecation.deprecated_argument_lookup("axis", axis,
    -                                                "reduction_indices",
    -                                                reduction_indices)
    -  keepdims = deprecation.deprecated_argument_lookup("keepdims", keepdims,
    -                                                    "keep_dims", keep_dims)
    -  return reduce_all(input_tensor, axis, keepdims, name)
    -
    -
    -@tf_export("reduce_all", "math.reduce_all", v1=[])
    -@dispatch.add_dispatch_support
    -def reduce_all(input_tensor, axis=None, keepdims=False, name=None):
    -  """Computes the "logical and" of elements across dimensions of a tensor.
    -
    -  Reduces `input_tensor` along the dimensions given in `axis`.
    -  Unless `keepdims` is true, the rank of the tensor is reduced by 1 for each
    -  entry in `axis`. If `keepdims` is true, the reduced dimensions
    -  are retained with length 1.
    -
    -  If `axis` is None, all dimensions are reduced, and a
    -  tensor with a single element is returned.
    -
    -  For example:
    -
    -  ```python
    -  x = tf.constant([[True,  True], [False, False]])
    -  tf.reduce_all(x)  # False
    -  tf.reduce_all(x, 0)  # [False, False]
    -  tf.reduce_all(x, 1)  # [True, False]
    -  ```
    -
    -  Args:
    -    input_tensor: The boolean tensor to reduce.
    -    axis: The dimensions to reduce. If `None` (the default), reduces all
    -      dimensions. Must be in the range `[-rank(input_tensor),
    -      rank(input_tensor))`.
    -    keepdims: If true, retains reduced dimensions with length 1.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    The reduced tensor.
    -
    -  @compatibility(numpy)
    -  Equivalent to np.all
    -  @end_compatibility
    -  """
    -  keepdims = False if keepdims is None else keepdims
    -  return _may_reduce_to_scalar(
    -      keepdims, axis,
    -      gen_math_ops._all(
    -          input_tensor, _ReductionDims(input_tensor, axis), keepdims,
    -          name=name))
    -
    -
    -@tf_export(v1=["math.reduce_any", "reduce_any"])
    -@deprecation.deprecated_args(None,
    -                             "keep_dims is deprecated, use keepdims instead",
    -                             "keep_dims")
    -def reduce_any_v1(input_tensor,
    -                  axis=None,
    -                  keepdims=None,
    -                  name=None,
    -                  reduction_indices=None,
    -                  keep_dims=None):
    -  """Computes the "logical or" of elements across dimensions of a tensor.
    -
    -  Reduces `input_tensor` along the dimensions given in `axis`.
    -  Unless `keepdims` is true, the rank of the tensor is reduced by 1 for each
    -  entry in `axis`. If `keepdims` is true, the reduced dimensions
    -  are retained with length 1.
    -
    -  If `axis` is None, all dimensions are reduced, and a
    -  tensor with a single element is returned.
    -
    -  For example:
    -
    -  ```python
    -  x = tf.constant([[True,  True], [False, False]])
    -  tf.reduce_any(x)  # True
    -  tf.reduce_any(x, 0)  # [True, True]
    -  tf.reduce_any(x, 1)  # [True, False]
    -  ```
    -
    -  Args:
    -    input_tensor: The boolean tensor to reduce.
    -    axis: The dimensions to reduce. If `None` (the default), reduces all
    -      dimensions. Must be in the range `[-rank(input_tensor),
    -      rank(input_tensor))`.
    -    keepdims: If true, retains reduced dimensions with length 1.
    -    name: A name for the operation (optional).
    -    reduction_indices: The old (deprecated) name for axis.
    -    keep_dims: Deprecated alias for `keepdims`.
    -
    -  Returns:
    -    The reduced tensor.
    -
    -  @compatibility(numpy)
    -  Equivalent to np.any
    -  @end_compatibility
    -  """
    -  axis = deprecation.deprecated_argument_lookup("axis", axis,
    -                                                "reduction_indices",
    -                                                reduction_indices)
    -  keepdims = deprecation.deprecated_argument_lookup("keepdims", keepdims,
    -                                                    "keep_dims", keep_dims)
    -  return reduce_any(input_tensor, axis, keepdims, name)
    -
    -
    -@tf_export("math.reduce_any", "reduce_any", v1=[])
    -@dispatch.add_dispatch_support
    -def reduce_any(input_tensor, axis=None, keepdims=False, name=None):
    -  """Computes the "logical or" of elements across dimensions of a tensor.
    -
    -  Reduces `input_tensor` along the dimensions given in `axis`.
    -  Unless `keepdims` is true, the rank of the tensor is reduced by 1 for each
    -  entry in `axis`. If `keepdims` is true, the reduced dimensions
    -  are retained with length 1.
    -
    -  If `axis` is None, all dimensions are reduced, and a
    -  tensor with a single element is returned.
    -
    -  For example:
    -
    -  ```python
    -  x = tf.constant([[True,  True], [False, False]])
    -  tf.reduce_any(x)  # True
    -  tf.reduce_any(x, 0)  # [True, True]
    -  tf.reduce_any(x, 1)  # [True, False]
    -  ```
    -
    -  Args:
    -    input_tensor: The boolean tensor to reduce.
    -    axis: The dimensions to reduce. If `None` (the default), reduces all
    -      dimensions. Must be in the range `[-rank(input_tensor),
    -      rank(input_tensor))`.
    -    keepdims: If true, retains reduced dimensions with length 1.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    The reduced tensor.
    -
    -  @compatibility(numpy)
    -  Equivalent to np.any
    -  @end_compatibility
    -  """
    -  keepdims = False if keepdims is None else keepdims
    -  return _may_reduce_to_scalar(
    -      keepdims, axis,
    -      gen_math_ops._any(
    -          input_tensor, _ReductionDims(input_tensor, axis), keepdims,
    -          name=name))
    -
    -
    -@tf_export(v1=["math.reduce_logsumexp", "reduce_logsumexp"])
    -@deprecation.deprecated_args(None,
    -                             "keep_dims is deprecated, use keepdims instead",
    -                             "keep_dims")
    -def reduce_logsumexp_v1(input_tensor,
    -                        axis=None,
    -                        keepdims=None,
    -                        name=None,
    -                        reduction_indices=None,
    -                        keep_dims=None):
    -  """Computes log(sum(exp(elements across dimensions of a tensor))).
    -
    -  Reduces `input_tensor` along the dimensions given in `axis`.
    -  Unless `keepdims` is true, the rank of the tensor is reduced by 1 for each
    -  entry in `axis`. If `keepdims` is true, the reduced dimensions
    -  are retained with length 1.
    -
    -  If `axis` has no entries, all dimensions are reduced, and a
    -  tensor with a single element is returned.
    -
    -  This function is more numerically stable than log(sum(exp(input))). It avoids
    -  overflows caused by taking the exp of large inputs and underflows caused by
    -  taking the log of small inputs.
    -
    -  For example:
    -
    -  ```python
    -  x = tf.constant([[0., 0., 0.], [0., 0., 0.]])
    -  tf.reduce_logsumexp(x)  # log(6)
    -  tf.reduce_logsumexp(x, 0)  # [log(2), log(2), log(2)]
    -  tf.reduce_logsumexp(x, 1)  # [log(3), log(3)]
    -  tf.reduce_logsumexp(x, 1, keepdims=True)  # [[log(3)], [log(3)]]
    -  tf.reduce_logsumexp(x, [0, 1])  # log(6)
    -  ```
    -
    -  Args:
    -    input_tensor: The tensor to reduce. Should have numeric type.
    -    axis: The dimensions to reduce. If `None` (the default), reduces all
    -      dimensions. Must be in the range `[-rank(input_tensor),
    -      rank(input_tensor))`.
    -    keepdims: If true, retains reduced dimensions with length 1.
    -    name: A name for the operation (optional).
    -    reduction_indices: The old (deprecated) name for axis.
    -    keep_dims: Deprecated alias for `keepdims`.
    -
    -  Returns:
    -    The reduced tensor.
    -  """
    -  axis = deprecation.deprecated_argument_lookup("axis", axis,
    -                                                "reduction_indices",
    -                                                reduction_indices)
    -  keepdims = deprecation.deprecated_argument_lookup("keepdims", keepdims,
    -                                                    "keep_dims", keep_dims)
    -  return reduce_logsumexp(input_tensor, axis, keepdims, name)
    -
    -
    -@tf_export("math.reduce_logsumexp", "reduce_logsumexp", v1=[])
    -def reduce_logsumexp(input_tensor, axis=None, keepdims=False, name=None):
    -  """Computes log(sum(exp(elements across dimensions of a tensor))).
    -
    -  Reduces `input_tensor` along the dimensions given in `axis`.
    -  Unless `keepdims` is true, the rank of the tensor is reduced by 1 for each
    -  entry in `axis`. If `keepdims` is true, the reduced dimensions
    -  are retained with length 1.
    -
    -  If `axis` has no entries, all dimensions are reduced, and a
    -  tensor with a single element is returned.
    -
    -  This function is more numerically stable than log(sum(exp(input))). It avoids
    -  overflows caused by taking the exp of large inputs and underflows caused by
    -  taking the log of small inputs.
    -
    -  For example:
    -
    -  ```python
    -  x = tf.constant([[0., 0., 0.], [0., 0., 0.]])
    -  tf.reduce_logsumexp(x)  # log(6)
    -  tf.reduce_logsumexp(x, 0)  # [log(2), log(2), log(2)]
    -  tf.reduce_logsumexp(x, 1)  # [log(3), log(3)]
    -  tf.reduce_logsumexp(x, 1, keepdims=True)  # [[log(3)], [log(3)]]
    -  tf.reduce_logsumexp(x, [0, 1])  # log(6)
    -  ```
    -
    -  Args:
    -    input_tensor: The tensor to reduce. Should have numeric type.
    -    axis: The dimensions to reduce. If `None` (the default), reduces all
    -      dimensions. Must be in the range `[-rank(input_tensor),
    -      rank(input_tensor))`.
    -    keepdims: If true, retains reduced dimensions with length 1.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    The reduced tensor.
    -  """
    -  keepdims = False if keepdims is None else keepdims
    -  input_tensor = ops.convert_to_tensor(input_tensor)
    -  with ops.name_scope(name, "ReduceLogSumExp", [input_tensor]) as name:
    -    reduce_dim = _ReductionDims(input_tensor, axis)
    -    raw_max = reduce_max_with_dims(
    -        input_tensor, axis=axis, keepdims=True, dims=reduce_dim)
    -    my_max = array_ops.stop_gradient(
    -        gen_math_ops.select(
    -            gen_math_ops.is_finite(raw_max), raw_max,
    -            gen_array_ops.zeros_like(raw_max)))
    -    result = gen_math_ops.log(
    -        reduce_sum_with_dims(
    -            gen_math_ops.exp(gen_math_ops.sub(input_tensor, my_max)),
    -            axis=axis,
    -            keepdims=keepdims,
    -            dims=reduce_dim))
    -    if not keepdims:
    -      my_max = array_ops.reshape(my_max, gen_array_ops.shape(result))
    -    result = gen_math_ops.add(result, my_max)
    -    return _may_reduce_to_scalar(keepdims, axis, result)
    -
    -
    -@tf_export("linalg.trace", v1=["linalg.trace", "trace"])
    -@deprecation.deprecated_endpoints("trace")
    -@dispatch.add_dispatch_support
    -def trace(x, name=None):
    -  """Compute the trace of a tensor `x`.
    -
    -  `trace(x)` returns the sum along the main diagonal of each inner-most matrix
    -  in x. If x is of rank `k` with shape `[I, J, K, ..., L, M, N]`, then output
    -  is a tensor of rank `k-2` with dimensions `[I, J, K, ..., L]` where
    -
    -  `output[i, j, k, ..., l] = trace(x[i, j, i, ..., l, :, :])`
    -
    -  For example:
    -
    -  ```python
    -  x = tf.constant([[1, 2], [3, 4]])
    -  tf.linalg.trace(x)  # 5
    -
    -  x = tf.constant([[1, 2, 3],
    -                   [4, 5, 6],
    -                   [7, 8, 9]])
    -  tf.linalg.trace(x)  # 15
    -
    -  x = tf.constant([[[1, 2, 3],
    -                    [4, 5, 6],
    -                    [7, 8, 9]],
    -                   [[-1, -2, -3],
    -                    [-4, -5, -6],
    -                    [-7, -8, -9]]])
    -  tf.linalg.trace(x)  # [15, -15]
    -  ```
    -
    -  Args:
    -    x: tensor.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    The trace of input tensor.
    -  """
    -  with ops.name_scope(name, "Trace", [x]) as name:
    -    x = ops.convert_to_tensor(x, name="x")
    -    return reduce_sum(array_ops.matrix_diag_part(x), [-1], name=name)
    -
    -
    -@tf_export("linalg.matmul", "matmul")
    -@dispatch.add_dispatch_support
    -def matmul(a,
    -           b,
    -           transpose_a=False,
    -           transpose_b=False,
    -           adjoint_a=False,
    -           adjoint_b=False,
    -           a_is_sparse=False,
    -           b_is_sparse=False,
    -           name=None):
    -  """Multiplies matrix `a` by matrix `b`, producing `a` * `b`.
    -
    -  The inputs must, following any transpositions, be tensors of rank >= 2
    -  where the inner 2 dimensions specify valid matrix multiplication dimensions,
    -  and any further outer dimensions specify matching batch size.
    -
    -  Both matrices must be of the same type. The supported types are:
    -  `float16`, `float32`, `float64`, `int32`, `complex64`, `complex128`.
    -
    -  Either matrix can be transposed or adjointed (conjugated and transposed) on
    -  the fly by setting one of the corresponding flag to `True`. These are `False`
    -  by default.
    -
    -  If one or both of the matrices contain a lot of zeros, a more efficient
    -  multiplication algorithm can be used by setting the corresponding
    -  `a_is_sparse` or `b_is_sparse` flag to `True`. These are `False` by default.
    -  This optimization is only available for plain matrices (rank-2 tensors) with
    -  datatypes `bfloat16` or `float32`.
    -
    -  A simple 2-D tensor matrix multiplication:
    -
    -  >>> a = tf.constant([1, 2, 3, 4, 5, 6], shape=[2, 3])
    -  >>> a  # 2-D tensor
    -  <tf.Tensor: shape=(2, 3), dtype=int32, numpy=
    -  array([[1, 2, 3],
    -         [4, 5, 6]], dtype=int32)>
    -  >>> b = tf.constant([7, 8, 9, 10, 11, 12], shape=[3, 2])
    -  >>> b  # 2-D tensor
    -  <tf.Tensor: shape=(3, 2), dtype=int32, numpy=
    -  array([[ 7,  8],
    -         [ 9, 10],
    -         [11, 12]], dtype=int32)>
    -  >>> c = tf.matmul(a, b)
    -  >>> c  # `a` * `b`
    -  <tf.Tensor: shape=(2, 2), dtype=int32, numpy=
    -  array([[ 58,  64],
    -         [139, 154]], dtype=int32)>
    -
    -  A batch matrix multiplication with batch shape [2]:
    -
    -  >>> a = tf.constant(np.arange(1, 13, dtype=np.int32), shape=[2, 2, 3])
    -  >>> a  # 3-D tensor
    -  <tf.Tensor: shape=(2, 2, 3), dtype=int32, numpy=
    -  array([[[ 1,  2,  3],
    -          [ 4,  5,  6]],
    -         [[ 7,  8,  9],
    -          [10, 11, 12]]], dtype=int32)>
    -  >>> b = tf.constant(np.arange(13, 25, dtype=np.int32), shape=[2, 3, 2])
    -  >>> b  # 3-D tensor
    -  <tf.Tensor: shape=(2, 3, 2), dtype=int32, numpy=
    -  array([[[13, 14],
    -          [15, 16],
    -          [17, 18]],
    -         [[19, 20],
    -          [21, 22],
    -          [23, 24]]], dtype=int32)>
    -  >>> c = tf.matmul(a, b)
    -  >>> c  # `a` * `b`
    -  <tf.Tensor: shape=(2, 2, 2), dtype=int32, numpy=
    -  array([[[ 94, 100],
    -          [229, 244]],
    -         [[508, 532],
    -          [697, 730]]], dtype=int32)>
    -
    -  Since python >= 3.5 the @ operator is supported
    -  (see [PEP 465](https://www.python.org/dev/peps/pep-0465/)). In TensorFlow,
    -  it simply calls the `tf.matmul()` function, so the following lines are
    -  equivalent:
    -
    -  >>> d = a @ b @ [[10], [11]]
    -  >>> d = tf.matmul(tf.matmul(a, b), [[10], [11]])
    -
    -  Args:
    -    a: `tf.Tensor` of type `float16`, `float32`, `float64`, `int32`,
    -      `complex64`, `complex128` and rank > 1.
    -    b: `tf.Tensor` with same type and rank as `a`.
    -    transpose_a: If `True`, `a` is transposed before multiplication.
    -    transpose_b: If `True`, `b` is transposed before multiplication.
    -    adjoint_a: If `True`, `a` is conjugated and transposed before
    -      multiplication.
    -    adjoint_b: If `True`, `b` is conjugated and transposed before
    -      multiplication.
    -    a_is_sparse: If `True`, `a` is treated as a sparse matrix. Notice, this
    -      **does not support `tf.sparse.SparseTensor`**, it just makes optimizations
    -      that assume most values in `a` are zero.
    -      See `tf.sparse.sparse_dense_matmul`
    -      for some support for `tf.SparseTensor` multiplication.
    -    b_is_sparse: If `True`, `b` is treated as a sparse matrix. Notice, this
    -      **does not support `tf.sparse.SparseTensor`**, it just makes optimizations
    -      that assume most values in `a` are zero.
    -      See `tf.sparse.sparse_dense_matmul`
    -      for some support for `tf.SparseTensor` multiplication.
    -    name: Name for the operation (optional).
    -
    -  Returns:
    -    A `tf.Tensor` of the same type as `a` and `b` where each inner-most matrix
    -    is the product of the corresponding matrices in `a` and `b`, e.g. if all
    -    transpose or adjoint attributes are `False`:
    -
    -    `output[..., i, j] = sum_k (a[..., i, k] * b[..., k, j])`,
    -    for all indices `i`, `j`.
    -
    -    Note: This is matrix product, not element-wise product.
    -
    -
    -  Raises:
    -    ValueError: If `transpose_a` and `adjoint_a`, or `transpose_b` and
    -      `adjoint_b` are both set to `True`.
    -  """
    -  with ops.name_scope(name, "MatMul", [a, b]) as name:
    -    if transpose_a and adjoint_a:
    -      raise ValueError("Only one of transpose_a and adjoint_a can be True.")
    -    if transpose_b and adjoint_b:
    -      raise ValueError("Only one of transpose_b and adjoint_b can be True.")
    -
    -    if context.executing_eagerly():
    -      if not isinstance(a, (ops.EagerTensor, _resource_variable_type)):
    -        a = ops.convert_to_tensor(a, name="a")
    -      if not isinstance(b, (ops.EagerTensor, _resource_variable_type)):
    -        b = ops.convert_to_tensor(b, name="b")
    -    else:
    -      a = ops.convert_to_tensor(a, name="a")
    -      b = ops.convert_to_tensor(b, name="b")
    -
    -    # TODO(apassos) remove _shape_tuple here when it is not needed.
    -    a_shape = a._shape_tuple()  # pylint: disable=protected-access
    -    b_shape = b._shape_tuple()  # pylint: disable=protected-access
    -
    -    output_may_have_non_empty_batch_shape = (
    -        (a_shape is None or len(a_shape) > 2) or
    -        (b_shape is None or len(b_shape) > 2))
    -
    -    if (not a_is_sparse and
    -        not b_is_sparse) and output_may_have_non_empty_batch_shape:
    -      # BatchMatmul does not support transpose, so we conjugate the matrix and
    -      # use adjoint instead. Conj() is a noop for real matrices.
    -      if transpose_a:
    -        a = conj(a)
    -        adjoint_a = True
    -      if transpose_b:
    -        b = conj(b)
    -        adjoint_b = True
    -      return gen_math_ops.batch_mat_mul_v2(
    -          a, b, adj_x=adjoint_a, adj_y=adjoint_b, name=name)
    -
    -    # Neither matmul nor sparse_matmul support adjoint, so we conjugate
    -    # the matrix and use transpose instead. Conj() is a noop for real
    -    # matrices.
    -    if adjoint_a:
    -      a = conj(a)
    -      transpose_a = True
    -    if adjoint_b:
    -      b = conj(b)
    -      transpose_b = True
    -
    -    use_sparse_matmul = False
    -    if a_is_sparse or b_is_sparse:
    -      sparse_matmul_types = [dtypes.bfloat16, dtypes.float32]
    -      use_sparse_matmul = (
    -          a.dtype in sparse_matmul_types and b.dtype in sparse_matmul_types)
    -    if ((a.dtype == dtypes.bfloat16 or b.dtype == dtypes.bfloat16) and
    -        a.dtype != b.dtype):
    -      # matmul currently doesn't handle mixed-precision inputs.
    -      use_sparse_matmul = True
    -    if use_sparse_matmul:
    -      ret = sparse_matmul(
    -          a,
    -          b,
    -          transpose_a=transpose_a,
    -          transpose_b=transpose_b,
    -          a_is_sparse=a_is_sparse,
    -          b_is_sparse=b_is_sparse,
    -          name=name)
    -      # sparse_matmul always returns float32, even with
    -      # bfloat16 inputs. This prevents us from configuring bfloat16 training.
    -      # casting to bfloat16 also matches non-sparse matmul behavior better.
    -      if a.dtype == dtypes.bfloat16 and b.dtype == dtypes.bfloat16:
    -        ret = cast(ret, dtypes.bfloat16)
    -      return ret
    -    else:
    -      return gen_math_ops.mat_mul(
    -          a, b, transpose_a=transpose_a, transpose_b=transpose_b, name=name)
    -
    -
    -@tf_export("linalg.matvec")
    -def matvec(a,
    -           b,
    -           transpose_a=False,
    -           adjoint_a=False,
    -           a_is_sparse=False,
    -           b_is_sparse=False,
    -           name=None):
    -  """Multiplies matrix `a` by vector `b`, producing `a` * `b`.
    -
    -  The matrix `a` must, following any transpositions, be a tensor of rank >= 2,
    -  with `shape(a)[-1] == shape(b)[-1]`, and `shape(a)[:-2]` able to broadcast
    -  with `shape(b)[:-1]`.
    -
    -  Both `a` and `b` must be of the same type. The supported types are:
    -  `float16`, `float32`, `float64`, `int32`, `complex64`, `complex128`.
    -
    -  Matrix `a` can be transposed or adjointed (conjugated and transposed) on
    -  the fly by setting one of the corresponding flag to `True`. These are `False`
    -  by default.
    -
    -  If one or both of the inputs contain a lot of zeros, a more efficient
    -  multiplication algorithm can be used by setting the corresponding
    -  `a_is_sparse` or `b_is_sparse` flag to `True`. These are `False` by default.
    -  This optimization is only available for plain matrices/vectors (rank-2/1
    -  tensors) with datatypes `bfloat16` or `float32`.
    -
    -  For example:
    -
    -  ```python
    -  # 2-D tensor `a`
    -  # [[1, 2, 3],
    -  #  [4, 5, 6]]
    -  a = tf.constant([1, 2, 3, 4, 5, 6], shape=[2, 3])
    -
    -  # 1-D tensor `b`
    -  # [7, 9, 11]
    -  b = tf.constant([7, 9, 11], shape=[3])
    -
    -  # `a` * `b`
    -  # [ 58,  64]
    -  c = tf.linalg.matvec(a, b)
    -
    -
    -  # 3-D tensor `a`
    -  # [[[ 1,  2,  3],
    -  #   [ 4,  5,  6]],
    -  #  [[ 7,  8,  9],
    -  #   [10, 11, 12]]]
    -  a = tf.constant(np.arange(1, 13, dtype=np.int32),
    -                  shape=[2, 2, 3])
    -
    -  # 2-D tensor `b`
    -  # [[13, 14, 15],
    -  #  [16, 17, 18]]
    -  b = tf.constant(np.arange(13, 19, dtype=np.int32),
    -                  shape=[2, 3])
    -
    -  # `a` * `b`
    -  # [[ 86, 212],
    -  #  [410, 563]]
    -  c = tf.linalg.matvec(a, b)
    -  ```
    -
    -  Args:
    -    a: `Tensor` of type `float16`, `float32`, `float64`, `int32`, `complex64`,
    -      `complex128` and rank > 1.
    -    b: `Tensor` with same type as `a` and compatible dimensions.
    -    transpose_a: If `True`, `a` is transposed before multiplication.
    -    adjoint_a: If `True`, `a` is conjugated and transposed before
    -      multiplication.
    -    a_is_sparse: If `True`, `a` is treated as a sparse matrix.
    -    b_is_sparse: If `True`, `b` is treated as a sparse matrix.
    -    name: Name for the operation (optional).
    -
    -  Returns:
    -    A `Tensor` of the same type as `a` and `b` where each inner-most vector is
    -    the product of the corresponding matrices in `a` and vectors in `b`, e.g. if
    -    all transpose or adjoint attributes are `False`:
    -
    -    `output`[..., i] = sum_k (`a`[..., i, k] * `b`[..., k]), for all indices i.
    -
    -    Note: This is matrix-vector product, not element-wise product.
    -
    -
    -  Raises:
    -    ValueError: If transpose_a and adjoint_a are both set to True.
    -  """
    -  with ops.name_scope(name, "MatVec", [a, b]) as name:
    -    output = matmul(
    -        a,
    -        array_ops.expand_dims(b, axis=-1),
    -        transpose_a=transpose_a,
    -        adjoint_a=adjoint_a,
    -        a_is_sparse=a_is_sparse,
    -        b_is_sparse=b_is_sparse)
    -    return array_ops.squeeze(output, axis=-1)
    -
    -
    -_OverrideBinaryOperatorHelper(matmul, "matmul")
    -
    -sparse_matmul = deprecation.deprecated(None, "Use `tf.linalg.matmul` instead")(
    -    gen_math_ops.sparse_mat_mul)
    -tf_export(v1=["sparse_matmul"])(sparse_matmul)
    -
    -
    -@ops.RegisterStatistics("MatMul", "flops")
    -def _calc_mat_mul_flops(graph, node):
    -  """Calculates the compute resources needed for MatMul."""
    -  transpose_a = node.attr["transpose_a"].b
    -  a_shape = graph_util.tensor_shape_from_node_def_name(graph, node.input[0])
    -  a_shape.assert_is_fully_defined()
    -  if transpose_a:
    -    k = int(a_shape[0])
    -  else:
    -    k = int(a_shape[1])
    -  output_shape = graph_util.tensor_shape_from_node_def_name(graph, node.name)
    -  output_shape.assert_is_fully_defined()
    -  output_count = np.prod(output_shape.as_list())
    -  return ops.OpStats("flops", (k * output_count * 2))
    -
    -
    -@ops.RegisterStatistics("BatchMatMul", "flops")
    -@ops.RegisterStatistics("BatchMatMulV2", "flops")
    -def _calc_batch_mat_mul_flops(graph, node):
    -  """Calculates the compute resources needed for BatchMatMul."""
    -  transpose_a = node.attr["transpose_a"].b
    -  a_shape = graph_util.tensor_shape_from_node_def_name(graph, node.input[0])
    -  a_shape.assert_is_fully_defined()
    -  if transpose_a:
    -    k = int(a_shape[-2])
    -  else:
    -    k = int(a_shape[-1])
    -  output_shape = graph_util.tensor_shape_from_node_def_name(graph, node.name)
    -  output_shape.assert_is_fully_defined()
    -  output_count = np.prod(output_shape.as_list())
    -  return ops.OpStats("flops", (k * output_count * 2))
    -
    -
    -def _as_indexed_slices(x, optimize=True):
    -  """Convert 'x' to IndexedSlices.
    -
    -  Convert a dense Tensor to a block-sparse IndexedSlices.
    -
    -  Args:
    -    x: Either a Tensor object, or an IndexedSlices object.
    -    optimize: if true, attempt to optimize the conversion of 'x'.
    -
    -  Returns:
    -    An IndexedSlices object.
    -
    -  Raises:
    -    TypeError: If 'x' is not a Tensor or an IndexedSlices object.
    -  """
    -  # TODO(touts): op_scope
    -  if not isinstance(x, (ops.Tensor, ops.IndexedSlices)):
    -    raise TypeError("Not a Tensor or IndexedSlices: %s" % type(x))
    -  if isinstance(x, ops.IndexedSlices):
    -    return x
    -  x_shape = array_ops.shape_internal(x, optimize=optimize)
    -  return ops.IndexedSlices(x, range(0, x_shape[0]), x_shape)
    -
    -
    -def _as_indexed_slices_list(inputs, optimize=True):
    -  """Convert all elements of 'inputs' to IndexedSlices.
    -
    -  Additionally, homogenize the types of all the indices to
    -  either int32 or int64.
    -
    -  Args:
    -    inputs: List containing either Tensor or IndexedSlices objects.
    -    optimize: if true, attempt to optimize the conversion of each input.
    -
    -  Returns:
    -    A list of IndexedSlices objects.
    -
    -  Raises:
    -    TypeError: If 'inputs' is not a list or a tuple.
    -  """
    -  if not isinstance(inputs, (list, tuple)):
    -    raise TypeError("Expected a list or tuple, not a %s" % type(inputs))
    -  outputs = [_as_indexed_slices(i, optimize=optimize) for i in inputs]
    -  with_int32_index = [
    -      o.indices for o in outputs if o.indices.dtype == dtypes.int32
    -  ]
    -  if not with_int32_index or len(with_int32_index) == len(outputs):
    -    return outputs
    -  casted_outputs = []
    -  for o in outputs:
    -    if o.indices.dtype == dtypes.int32:
    -      casted_outputs.append(
    -          ops.IndexedSlices(o.values, cast(o.indices, dtypes.int64),
    -                            o.dense_shape))
    -    else:
    -      casted_outputs.append(o)
    -  return casted_outputs
    -
    -
    -@tf_export("math.add_n", "add_n")
    -@dispatch.add_dispatch_support
    -def add_n(inputs, name=None):
    -  """Adds all input tensors element-wise.
    -
    -  `tf.math.add_n` performs the same operation as `tf.math.accumulate_n`, but it
    -  waits for all of its inputs to be ready before beginning to sum.
    -  This buffering can result in higher memory consumption when inputs are ready
    -  at different times, since the minimum temporary storage required is
    -  proportional to the input size rather than the output size.
    -
    -  This op does not [broadcast](
    -  https://docs.scipy.org/doc/numpy-1.13.0/user/basics.broadcasting.html)
    -  its inputs. If you need broadcasting, use `tf.math.add` (or the `+` operator)
    -  instead.
    -
    -  For example:
    -
    -  >>> a = tf.constant([[3, 5], [4, 8]])
    -  >>> b = tf.constant([[1, 6], [2, 9]])
    -  >>> tf.math.add_n([a, b, a])
    -  <tf.Tensor: shape=(2, 2), dtype=int32, numpy=
    -  array([[ 7, 16],
    -         [10, 25]], dtype=int32)>
    -
    -  Args:
    -    inputs: A list of `tf.Tensor` or `tf.IndexedSlices` objects, each with the
    -      same shape and type. `tf.IndexedSlices` objects will be converted into
    -      dense tensors prior to adding.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    A `tf.Tensor` of the same shape and type as the elements of `inputs`.
    -
    -  Raises:
    -    ValueError: If `inputs` don't all have same shape and dtype or the shape
    -    cannot be inferred.
    -  """
    -  if not inputs or not isinstance(inputs, (list, tuple)):
    -    raise ValueError("inputs must be a list of at least one "
    -                     "Tensor/IndexedSlices with the same dtype and shape")
    -  inputs = ops.convert_n_to_tensor_or_indexed_slices(inputs)
    -  if not all(isinstance(x, (ops.Tensor, ops.IndexedSlices)) for x in inputs):
    -    raise ValueError("inputs must be a list of at least one "
    -                     "Tensor/IndexedSlices with the same dtype and shape")
    -
    -  if len(inputs) == 1:
    -    if isinstance(inputs[0], ops.IndexedSlices):
    -      values = ops.convert_to_tensor(inputs[0])
    -    else:
    -      values = inputs[0]
    -    if name:
    -      return array_ops.identity(values, name=name)
    -    return values
    -  return gen_math_ops.add_n(inputs, name=name)
    -
    -
    -@tf_export("math.accumulate_n", v1=["math.accumulate_n", "accumulate_n"])
    -@deprecation.deprecated_endpoints("accumulate_n")
    -def accumulate_n(inputs, shape=None, tensor_dtype=None, name=None):
    -  """Returns the element-wise sum of a list of tensors.
    -
    -  Optionally, pass `shape` and `tensor_dtype` for shape and type checking,
    -  otherwise, these are inferred.
    -
    -  `accumulate_n` performs the same operation as `tf.math.add_n`.
    -
    -  For example:
    -
    -  ```python
    -  a = tf.constant([[1, 2], [3, 4]])
    -  b = tf.constant([[5, 0], [0, 6]])
    -  tf.math.accumulate_n([a, b, a])  # [[7, 4], [6, 14]]
    -
    -  # Explicitly pass shape and type
    -  tf.math.accumulate_n([a, b, a], shape=[2, 2], tensor_dtype=tf.int32)
    -                                                                 # [[7,  4],
    -                                                                 #  [6, 14]]
    -  ```
    -
    -  Args:
    -    inputs: A list of `Tensor` objects, each with same shape and type.
    -    shape: Expected shape of elements of `inputs` (optional). Also controls the
    -      output shape of this op, which may affect type inference in other ops. A
    -      value of `None` means "infer the input shape from the shapes in `inputs`".
    -    tensor_dtype: Expected data type of `inputs` (optional). A value of `None`
    -      means "infer the input dtype from `inputs[0]`".
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    A `Tensor` of same shape and type as the elements of `inputs`.
    -
    -  Raises:
    -    ValueError: If `inputs` don't all have same shape and dtype or the shape
    -    cannot be inferred.
    -  """
    -
    -  def _input_error():
    -    return ValueError("inputs must be a list of at least one Tensor with the "
    -                      "same dtype and shape")
    -
    -  if not inputs or not isinstance(inputs, (list, tuple)):
    -    raise _input_error()
    -  inputs = ops.convert_n_to_tensor_or_indexed_slices(inputs)
    -  if not all(isinstance(x, ops.Tensor) for x in inputs):
    -    raise _input_error()
    -  if not all(x.dtype == inputs[0].dtype for x in inputs):
    -    raise _input_error()
    -  if shape is not None:
    -    shape = tensor_shape.as_shape(shape)
    -  else:
    -    shape = tensor_shape.unknown_shape()
    -  for input_tensor in inputs:
    -    if isinstance(input_tensor, ops.Tensor):
    -      shape = shape.merge_with(input_tensor.get_shape())
    -
    -  # tensor_dtype is for safety only; operator's output type computed in C++
    -  if tensor_dtype is not None and tensor_dtype != inputs[0].dtype:
    -    raise TypeError("tensor_dtype is {}, but input is of type {}".format(
    -        tensor_dtype, inputs[0].dtype))
    -
    -  if len(inputs) == 1 and name is None:
    -    return inputs[0]
    -  elif len(inputs) == 1 and name is not None:
    -    return array_ops.identity(inputs[0], name=name)
    -  return add_n(inputs, name=name)
    -
    -
    -@ops.RegisterGradient("AccumulateNV2")
    -def _accumulate_n_grad(op, grad):
    -  """Same as gradient for AddN. Copies the gradient to all inputs."""
    -  # Not broadcasting.
    -  return [grad] * len(op.inputs)
    -
    -
    -@tf_export("math.sigmoid", "nn.sigmoid", "sigmoid")
    -def sigmoid(x, name=None):
    -  r"""Computes sigmoid of `x` element-wise.
    -
    -  Formula for calculating sigmoid(x): `y = 1 / (1 + exp(-x))`.
    -
    -  For x \in (-inf, inf) => sigmoid(x) \in (0, 1)
    -
    -  Example Usage:
    -
    -  If a positive number is large, then its sigmoid will approach to 1 since the
    -  formula will be `y = <large_num> / (1 + <large_num>)`
    -
    -  >>> x = tf.constant([0.0, 1.0, 50.0, 100.0])
    -  >>> tf.math.sigmoid(x)
    -  <tf.Tensor: shape=(4,), dtype=float32,
    -  numpy=array([0.5      , 0.7310586, 1.       , 1.       ], dtype=float32)>
    -
    -  If a negative number is large, its sigmoid will approach to 0 since the
    -  formula will be `y = 1 / (1 + <large_num>)`
    -
    -  >>> x = tf.constant([-100.0, -50.0, -1.0, 0.0])
    -  >>> tf.math.sigmoid(x)
    -  <tf.Tensor: shape=(4,), dtype=float32, numpy=
    -  array([0.0000000e+00, 1.9287499e-22, 2.6894143e-01, 0.5],
    -        dtype=float32)>
    -
    -  Args:
    -    x: A Tensor with type `float16`, `float32`, `float64`, `complex64`, or
    -      `complex128`.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    A Tensor with the same type as `x`.
    -  
    -  Usage Example:
    -  
    -  >>> x = tf.constant([-128.0, 0.0, 128.0], dtype=tf.float32)
    -  >>> tf.sigmoid(x)
    -  <tf.Tensor: shape=(3,), dtype=float32,
    -  numpy=array([0. , 0.5, 1. ], dtype=float32)>
    -
    -  @compatibility(scipy)
    -  Equivalent to scipy.special.expit
    -  @end_compatibility
    -  """
    -  with ops.name_scope(name, "Sigmoid", [x]) as name:
    -    x = ops.convert_to_tensor(x, name="x")
    -    return gen_math_ops.sigmoid(x, name=name)
    -
    -
    -@tf_export("math.log_sigmoid", v1=["math.log_sigmoid", "log_sigmoid"])
    -@dispatch.add_dispatch_support
    -@deprecation.deprecated_endpoints("log_sigmoid")
    -def log_sigmoid(x, name=None):
    -  """Computes log sigmoid of `x` element-wise.
    -
    -  Specifically, `y = log(1 / (1 + exp(-x)))`.  For numerical stability,
    -  we use `y = -tf.nn.softplus(-x)`.
    -
    -  Args:
    -    x: A Tensor with type `float32` or `float64`.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    A Tensor with the same type as `x`.
    -  """
    -  with ops.name_scope(name, "LogSigmoid", [x]) as name:
    -    x = ops.convert_to_tensor(x, name="x")
    -    return gen_math_ops.neg(gen_nn_ops.softplus(-x), name=name)
    -
    -
    -@tf_export("math.bincount", v1=[])
    -def bincount(arr,
    -             weights=None,
    -             minlength=None,
    -             maxlength=None,
    -             dtype=dtypes.int32,
    -             name=None):
    -  """Counts the number of occurrences of each value in an integer array.
    -
    -  If `minlength` and `maxlength` are not given, returns a vector with length
    -  `tf.reduce_max(arr) + 1` if `arr` is non-empty, and length 0 otherwise.
    -  If `weights` are non-None, then index `i` of the output stores the sum of the
    -  value in `weights` at each index where the corresponding value in `arr` is
    -  `i`.
    -
    -  ```python
    -  values = tf.constant([1,1,2,3,2,4,4,5])
    -  tf.math.bincount(values) #[0 2 2 1 2 1]
    -  ```
    -  Vector length = Maximum element in vector `values` is 5. Adding 1, which is 6
    -                  will be the vector length.
    -
    -  Each bin value in the output indicates number of occurrences of the particular
    -  index. Here, index 1 in output has a value 2. This indicates value 1 occurs
    -  two times in `values`.
    -
    -  ```python
    -  values = tf.constant([1,1,2,3,2,4,4,5])
    -  weights = tf.constant([1,5,0,1,0,5,4,5])
    -  tf.math.bincount(values, weights=weights) #[0 6 0 1 9 5]
    -  ```
    -  Bin will be incremented by the corresponding weight instead of 1.
    -  Here, index 1 in output has a value 6. This is the summation of weights
    -  corresponding to the value in `values`.
    -
    -  Args:
    -    arr: An int32 tensor of non-negative values.
    -    weights: If non-None, must be the same shape as arr. For each value in
    -      `arr`, the bin will be incremented by the corresponding weight instead of
    -      1.
    -    minlength: If given, ensures the output has length at least `minlength`,
    -      padding with zeros at the end if necessary.
    -    maxlength: If given, skips values in `arr` that are equal or greater than
    -      `maxlength`, ensuring that the output has length at most `maxlength`.
    -    dtype: If `weights` is None, determines the type of the output bins.
    -    name: A name scope for the associated operations (optional).
    -
    -  Returns:
    -    A vector with the same dtype as `weights` or the given `dtype`. The bin
    -    values.
    -
    -  Raises:
    -    `InvalidArgumentError` if negative values are provided as an input.
    -
    -  """
    -  name = "bincount" if name is None else name
    -  with ops.name_scope(name):
    -    arr = ops.convert_to_tensor(arr, name="arr", dtype=dtypes.int32)
    -    array_is_nonempty = reduce_prod(array_ops.shape(arr)) > 0
    -    output_size = cast(array_is_nonempty, dtypes.int32) * (reduce_max(arr) + 1)
    -    if minlength is not None:
    -      minlength = ops.convert_to_tensor(
    -          minlength, name="minlength", dtype=dtypes.int32)
    -      output_size = gen_math_ops.maximum(minlength, output_size)
    -    if maxlength is not None:
    -      maxlength = ops.convert_to_tensor(
    -          maxlength, name="maxlength", dtype=dtypes.int32)
    -      output_size = gen_math_ops.minimum(maxlength, output_size)
    -    if weights is not None:
    -      weights = ops.convert_to_tensor(weights, name="weights")
    -      return gen_math_ops.unsorted_segment_sum(weights, arr, output_size)
    -    weights = constant_op.constant([], dtype)
    -    return gen_math_ops.bincount(arr, output_size, weights)
    -
    -
    -@tf_export(v1=["math.bincount", "bincount"])
    -@deprecation.deprecated_endpoints("bincount")
    -def bincount_v1(arr,
    -                weights=None,
    -                minlength=None,
    -                maxlength=None,
    -                dtype=dtypes.int32):
    -  """Counts the number of occurrences of each value in an integer array.
    -
    -  If `minlength` and `maxlength` are not given, returns a vector with length
    -  `tf.reduce_max(arr) + 1` if `arr` is non-empty, and length 0 otherwise.
    -  If `weights` are non-None, then index `i` of the output stores the sum of the
    -  value in `weights` at each index where the corresponding value in `arr` is
    -  `i`.
    -
    -  Args:
    -    arr: An int32 tensor of non-negative values.
    -    weights: If non-None, must be the same shape as arr. For each value in
    -      `arr`, the bin will be incremented by the corresponding weight instead of
    -      1.
    -    minlength: If given, ensures the output has length at least `minlength`,
    -      padding with zeros at the end if necessary.
    -    maxlength: If given, skips values in `arr` that are equal or greater than
    -      `maxlength`, ensuring that the output has length at most `maxlength`.
    -    dtype: If `weights` is None, determines the type of the output bins.
    -
    -  Returns:
    -    A vector with the same dtype as `weights` or the given `dtype`. The bin
    -    values.
    -  """
    -  return bincount(arr, weights, minlength, maxlength, dtype)
    -
    -
    -@tf_export("math.cumsum", "cumsum")
    -def cumsum(x, axis=0, exclusive=False, reverse=False, name=None):
    -  """Compute the cumulative sum of the tensor `x` along `axis`.
    -
    -  By default, this op performs an inclusive cumsum, which means that the first
    -  element of the input is identical to the first element of the output:
    -  For example:
    -
    -  >>> # tf.cumsum([a, b, c])   # [a, a + b, a + b + c]
    -  >>> x = tf.constant([2, 4, 6, 8])
    -  >>> tf.cumsum(x)
    -  <tf.Tensor: shape=(4,), dtype=int32,
    -  numpy=array([ 2,  6, 12, 20], dtype=int32)>
    -
    -  >>> # using varying `axis` values
    -  >>> y = tf.constant([[2, 4, 6, 8], [1,3,5,7]])
    -  >>> tf.cumsum(y, axis=0)
    -  <tf.Tensor: shape=(2, 4), dtype=int32, numpy=
    -  array([[ 2,  4,  6,  8],
    -         [ 3,  7, 11, 15]], dtype=int32)>
    -  >>> tf.cumsum(y, axis=1)
    -  <tf.Tensor: shape=(2, 4), dtype=int32, numpy=
    -  array([[ 2,  6, 12, 20],
    -         [ 1,  4,  9, 16]], dtype=int32)>
    -
    -  By setting the `exclusive` kwarg to `True`, an exclusive cumsum is performed
    -  instead:
    -
    -  >>> # tf.cumsum([a, b, c], exclusive=True)  => [0, a, a + b]
    -  >>> x = tf.constant([2, 4, 6, 8])
    -  >>> tf.cumsum(x, exclusive=True)
    -  <tf.Tensor: shape=(4,), dtype=int32,
    -  numpy=array([ 0,  2,  6, 12], dtype=int32)>
    -
    -  By setting the `reverse` kwarg to `True`, the cumsum is performed in the
    -  opposite direction:
    -
    -  >>> # tf.cumsum([a, b, c], reverse=True)  # [a + b + c, b + c, c]
    -  >>> x = tf.constant([2, 4, 6, 8])
    -  >>> tf.cumsum(x, reverse=True)
    -  <tf.Tensor: shape=(4,), dtype=int32,
    -  numpy=array([20, 18, 14,  8], dtype=int32)>
    -
    -  This is more efficient than using separate `tf.reverse` ops.
    -  The `reverse` and `exclusive` kwargs can also be combined:
    -
    -  >>> # tf.cumsum([a, b, c], exclusive=True, reverse=True)  # [b + c, c, 0]
    -  >>> x = tf.constant([2, 4, 6, 8])
    -  >>> tf.cumsum(x, exclusive=True, reverse=True)
    -  <tf.Tensor: shape=(4,), dtype=int32,
    -  numpy=array([18, 14,  8,  0], dtype=int32)>
    -
    -  Args:
    -    x: A `Tensor`. Must be one of the following types: `float32`, `float64`,
    -      `int64`, `int32`, `uint8`, `uint16`, `int16`, `int8`, `complex64`,
    -      `complex128`, `qint8`, `quint8`, `qint32`, `half`.
    -    axis: A `Tensor` of type `int32` (default: 0). Must be in the range
    -      `[-rank(x), rank(x))`.
    -    exclusive: If `True`, perform exclusive cumsum.
    -    reverse: A `bool` (default: False).
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    A `Tensor`. Has the same type as `x`.
    -  """
    -  with ops.name_scope(name, "Cumsum", [x]) as name:
    -    x = ops.convert_to_tensor(x, name="x")
    -    return gen_math_ops.cumsum(
    -        x, axis, exclusive=exclusive, reverse=reverse, name=name)
    -
    -
    -@tf_export("math.cumprod", v1=["math.cumprod", "cumprod"])
    -@deprecation.deprecated_endpoints("cumprod")
    -def cumprod(x, axis=0, exclusive=False, reverse=False, name=None):
    -  """Compute the cumulative product of the tensor `x` along `axis`.
    -
    -  By default, this op performs an inclusive cumprod, which means that the
    -  first element of the input is identical to the first element of the output:
    -
    -  ```python
    -  tf.math.cumprod([a, b, c])  # [a, a * b, a * b * c]
    -  ```
    -
    -  By setting the `exclusive` kwarg to `True`, an exclusive cumprod is
    -  performed
    -  instead:
    -
    -  ```python
    -  tf.math.cumprod([a, b, c], exclusive=True)  # [1, a, a * b]
    -  ```
    -
    -  By setting the `reverse` kwarg to `True`, the cumprod is performed in the
    -  opposite direction:
    -
    -  ```python
    -  tf.math.cumprod([a, b, c], reverse=True)  # [a * b * c, b * c, c]
    -  ```
    -
    -  This is more efficient than using separate `tf.reverse` ops.
    -  The `reverse` and `exclusive` kwargs can also be combined:
    -
    -  ```python
    -  tf.math.cumprod([a, b, c], exclusive=True, reverse=True)  # [b * c, c, 1]
    -  ```
    -
    -  Args:
    -    x: A `Tensor`. Must be one of the following types: `float32`, `float64`,
    -      `int64`, `int32`, `uint8`, `uint16`, `int16`, `int8`, `complex64`,
    -      `complex128`, `qint8`, `quint8`, `qint32`, `half`.
    -    axis: A `Tensor` of type `int32` (default: 0). Must be in the range
    -      `[-rank(x), rank(x))`.
    -    exclusive: If `True`, perform exclusive cumprod.
    -    reverse: A `bool` (default: False).
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    A `Tensor`. Has the same type as `x`.
    -  """
    -  with ops.name_scope(name, "Cumprod", [x]) as name:
    -    x = ops.convert_to_tensor(x, name="x")
    -    return gen_math_ops.cumprod(
    -        x, axis, exclusive=exclusive, reverse=reverse, name=name)
    -
    -
    -@tf_export("math.cumulative_logsumexp", v1=["math.cumulative_logsumexp"])
    -def cumulative_logsumexp(x, axis=0, exclusive=False, reverse=False, name=None):
    -  """Compute the cumulative log-sum-exp of the tensor `x` along `axis`.
    -
    -  By default, this op performs an inclusive cumulative log-sum-exp, which means
    -  that the first element of the input is identical to the first element of
    -  the output.
    -
    -  This operation is significantly more numerically stable than the equivalent
    -  tensorflow operation `tf.math.log(tf.math.cumsum(tf.math.exp(x)))`, although
    -  computes the same result given infinite numerical precision. However, note
    -  that in some cases, it may be less stable than `tf.math.reduce_logsumexp`
    -  for a given element, as it applies the "log-sum-exp trick" in a different
    -  way.
    -
    -  More precisely, where `tf.math.reduce_logsumexp` uses the following trick:
    -
    -  ```
    -  log(sum(exp(x))) == log(sum(exp(x - max(x)))) + max(x)
    -  ```
    -
    -  it cannot be directly used here as there is no fast way of applying it
    -  to each prefix `x[:i]`. Instead, this function implements a prefix
    -  scan using pairwise log-add-exp, which is a commutative and associative
    -  (up to floating point precision) operator:
    -
    -  ```
    -  log_add_exp(x, y) = log(exp(x) + exp(y))
    -                    = log(1 + exp(min(x, y) - max(x, y))) + max(x, y)
    -  ```
    -
    -  However, reducing using the above operator leads to a different computation
    -  tree (logs are taken repeatedly instead of only at the end), and the maximum
    -  is only computed pairwise instead of over the entire prefix. In general, this
    -  leads to a different and slightly less precise computation.
    -
    -  Args:
    -    x: A `Tensor`. Must be one of the following types: `float16`, `float32`,
    -      `float64`.
    -    axis: A `Tensor` of type `int32` or `int64` (default: 0). Must be in the
    -      range `[-rank(x), rank(x))`.
    -    exclusive: If `True`, perform exclusive cumulative log-sum-exp.
    -    reverse: If `True`, performs the cumulative log-sum-exp in the reverse
    -      direction.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    A `Tensor`. Has the same shape and type as `x`.
    -  """
    -  with ops.name_scope(name, "CumulativeLogsumexp", [x]) as name:
    -    x = ops.convert_to_tensor(x, name="x")
    -    return gen_math_ops.cumulative_logsumexp(
    -        x, axis, exclusive=exclusive, reverse=reverse, name=name)
    -
    -
    -@tf_export("math.conj", v1=["math.conj", "conj"])
    -@dispatch.add_dispatch_support
    -@deprecation.deprecated_endpoints("conj")
    -def conj(x, name=None):
    -  r"""Returns the complex conjugate of a complex number.
    -
    -  Given a tensor `input` of complex numbers, this operation returns a tensor of
    -  complex numbers that are the complex conjugate of each element in `input`. The
    -  complex numbers in `input` must be of the form \\(a + bj\\), where *a* is the
    -  real part and *b* is the imaginary part.
    -
    -  The complex conjugate returned by this operation is of the form \\(a - bj\\).
    -
    -  For example:
    -
    -      # tensor 'input' is [-2.25 + 4.75j, 3.25 + 5.75j]
    -      tf.math.conj(input) ==> [-2.25 - 4.75j, 3.25 - 5.75j]
    -
    -  If `x` is real, it is returned unchanged.
    -
    -  Args:
    -    x: `Tensor` to conjugate.  Must have numeric or variant type.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    A `Tensor` that is the conjugate of `x` (with the same type).
    -
    -  Raises:
    -    TypeError: If `x` is not a numeric tensor.
    -  """
    -  if isinstance(x, ops.Tensor):
    -    dt = x.dtype
    -    if dt.is_floating or dt.is_integer:
    -      return x
    -  with ops.name_scope(name, "Conj", [x]) as name:
    -    x = ops.convert_to_tensor(x, name="x")
    -    if x.dtype.is_complex or x.dtype == dtypes.variant:
    -      return gen_math_ops.conj(x, name=name)
    -    elif x.dtype.is_floating or x.dtype.is_integer:
    -      return x
    -    else:
    -      raise TypeError("Expected numeric or variant tensor, got dtype %r" %
    -                      x.dtype)
    -
    -
    -def reduced_shape(input_shape, axes):
    -  """Helper function for reduction ops.
    -
    -  Args:
    -    input_shape: 1-D Tensor, the shape of the Tensor being reduced.
    -    axes: 1-D Tensor, the reduction axes.
    -
    -  Returns:
    -    A 1-D Tensor, the output shape as if keepdims were set to True.
    -  """
    -  if context.executing_eagerly():
    -    input_shape = input_shape.numpy()
    -    axes = axes.numpy()
    -    input_shape[axes] = 1
    -    return input_shape
    -
    -  # Example:
    -  # cast needed for SparseTensor reductions
    -  input_shape = cast(input_shape, dtypes.int32)  # [2, 3, 5, 7]
    -  axes = cast(axes, dtypes.int32)  # [1, 2]
    -
    -  input_rank = array_ops.size(input_shape)  # 4
    -  axes = (axes + input_rank) % input_rank
    -  axes_shape = array_ops.shape(axes)  # [2]
    -  return gen_data_flow_ops.dynamic_stitch(  # [2, 1, 1, 7]
    -      [
    -          range(input_rank),  # [0, 1, 2, 3]
    -          axes
    -      ],  # [1, 2]
    -      [
    -          input_shape,  # [2, 3, 5, 7]
    -          array_ops.fill(axes_shape, 1)
    -      ])  # [1, 1]
    -
    -
    -def _unsorted_segment_N(data, segment_ids, num_segments):
    -  """ Helper function for unsorted_segment_mean/_sqrtN.
    -
    -  Computes the number
    -      of segment entries with 0-entries set to 1 to allow division by N.
    -  """
    -  num_segments = ops.convert_to_tensor(num_segments)
    -  # bincount doesn't support negative indices so we use unsorted_segment_sum
    -  segment_ids_shape = array_ops.shape_internal(segment_ids)
    -  ones_tensor = array_ops.ones(segment_ids_shape, dtype=data.dtype)
    -  n = gen_math_ops.unsorted_segment_sum(ones_tensor, segment_ids, num_segments)
    -  # add dimensions for all non-reduced axes
    -  broadcastable_shape = array_ops.concat(
    -      [num_segments[array_ops.newaxis],
    -       array_ops.ones([array_ops.rank(data)
    -                       - array_ops.rank(segment_ids)],
    -                      dtype=num_segments.dtype)],
    -      axis=0)
    -  n = array_ops.reshape(n, broadcastable_shape)
    -  return gen_math_ops.maximum(n, 1)
    -
    -
    -@tf_export(
    -    "math.unsorted_segment_mean",
    -    v1=["math.unsorted_segment_mean", "unsorted_segment_mean"])
    -@deprecation.deprecated_endpoints("unsorted_segment_mean")
    -@dispatch.add_dispatch_support
    -def unsorted_segment_mean(data, segment_ids, num_segments, name=None):
    -  r"""Computes the mean along segments of a tensor.
    -
    -  Read [the section on
    -  segmentation](https://www.tensorflow.org/versions/r2.0/api_docs/python/tf/math#about_segmentation)
    -  for an explanation of segments.
    -
    -  This operator is similar to the unsorted segment sum operator found
    -  [here](../../../api_docs/python/math_ops.md#UnsortedSegmentSum).
    -  Instead of computing the sum over segments, it computes the mean of all
    -  entries belonging to a segment such that:
    -
    -  \\(output_i = 1/N_i \sum_{j...} data[j...]\\) where the sum is over tuples
    -  `j...` such that `segment_ids[j...] == i` with \\N_i\\ being the number of
    -  occurrences of id \\i\\.
    -
    -  If there is no entry for a given segment ID `i`, it outputs 0.
    -
    -  If the given segment ID `i` is negative, the value is dropped and will not
    -  be added to the sum of the segment.
    -
    -  Args:
    -    data: A `Tensor` with floating point or complex dtype.
    -    segment_ids: An integer tensor whose shape is a prefix of `data.shape`.
    -    num_segments: An integer scalar `Tensor`.  The number of distinct segment
    -      IDs.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    A `Tensor`.  Has same shape as data, except for the first `segment_ids.rank`
    -    dimensions, which are replaced with a single dimension which has size
    -   `num_segments`.
    -  """
    -  with ops.name_scope(name, "UnsortedSegmentMean"):
    -    data = ops.convert_to_tensor(data)
    -    segment_ids = ops.convert_to_tensor(segment_ids)
    -    N = _unsorted_segment_N(data, segment_ids, num_segments)
    -    summed = gen_math_ops.unsorted_segment_sum(data, segment_ids, num_segments)
    -    return summed / N
    -
    -
    -@tf_export(
    -    "math.unsorted_segment_sqrt_n",
    -    v1=["math.unsorted_segment_sqrt_n", "unsorted_segment_sqrt_n"])
    -@deprecation.deprecated_endpoints("unsorted_segment_sqrt_n")
    -@dispatch.add_dispatch_support
    -def unsorted_segment_sqrt_n(data, segment_ids, num_segments, name=None):
    -  r"""Computes the sum along segments of a tensor divided by the sqrt(N).
    -
    -  Read [the section on
    -  segmentation](https://www.tensorflow.org/versions/r2.0/api_docs/python/tf/math#about_segmentation)
    -  for an explanation of segments.
    -
    -  This operator is similar to the unsorted segment sum operator found
    -  [here](../../../api_docs/python/math_ops.md#UnsortedSegmentSum).
    -  Additionally to computing the sum over segments, it divides the results by
    -  sqrt(N).
    -
    -  \\(output_i = 1/sqrt(N_i) \sum_{j...} data[j...]\\) where the sum is over
    -  tuples `j...` such that `segment_ids[j...] == i` with \\N_i\\ being the
    -  number of occurrences of id \\i\\.
    -
    -  If there is no entry for a given segment ID `i`, it outputs 0.
    -
    -  Note that this op only supports floating point and complex dtypes,
    -  due to tf.sqrt only supporting these types.
    -
    -  If the given segment ID `i` is negative, the value is dropped and will not
    -  be added to the sum of the segment.
    -
    -  Args:
    -    data: A `Tensor` with floating point or complex dtype.
    -    segment_ids: An integer tensor whose shape is a prefix of `data.shape`.
    -    num_segments: An integer scalar `Tensor`.  The number of distinct segment
    -      IDs.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    A `Tensor`.  Has same shape as data, except for the first `segment_ids.rank`
    -    dimensions, which are replaced with a single dimension which has size
    -   `num_segments`.
    -  """
    -  with ops.name_scope(name, "UnsortedSegmentSqrtN"):
    -    data = ops.convert_to_tensor(data)
    -    segment_ids = ops.convert_to_tensor(segment_ids)
    -    N = _unsorted_segment_N(data, segment_ids, num_segments)
    -    summed = gen_math_ops.unsorted_segment_sum(data, segment_ids, num_segments)
    -    return summed / gen_math_ops.sqrt(N)
    -
    -
    -@tf_export(v1=["sparse.segment_sum", "sparse_segment_sum"])
    -@deprecation.deprecated_endpoints("sparse_segment_sum")
    -def sparse_segment_sum(data,
    -                       indices,
    -                       segment_ids,
    -                       name=None,
    -                       num_segments=None):
    -  r"""Computes the sum along sparse segments of a tensor.
    -
    -  Read [the section on
    -  segmentation](https://www.tensorflow.org/versions/r2.0/api_docs/python/tf/math#about_segmentation)
    -  for an explanation of segments.
    -
    -  Like `tf.math.segment_sum`, but `segment_ids` can have rank less than `data`'s
    -  first dimension, selecting a subset of dimension 0, specified by `indices`.
    -  `segment_ids` is allowed to have missing ids, in which case the output will
    -  be zeros at those indices. In those cases `num_segments` is used to determine
    -  the size of the output.
    -
    -  For example:
    -
    -  ```python
    -  c = tf.constant([[1,2,3,4], [-1,-2,-3,-4], [5,6,7,8]])
    -
    -  # Select two rows, one segment.
    -  tf.sparse.segment_sum(c, tf.constant([0, 1]), tf.constant([0, 0]))
    -  # => [[0 0 0 0]]
    -
    -  # Select two rows, two segment.
    -  tf.sparse.segment_sum(c, tf.constant([0, 1]), tf.constant([0, 1]))
    -  # => [[ 1  2  3  4]
    -  #     [-1 -2 -3 -4]]
    -
    -  # With missing segment ids.
    -  tf.sparse.segment_sum(c, tf.constant([0, 1]), tf.constant([0, 2]),
    -                        num_segments=4)
    -  # => [[ 1  2  3  4]
    -  #     [ 0  0  0  0]
    -  #     [-1 -2 -3 -4]
    -  #     [ 0  0  0  0]]
    -
    -  # Select all rows, two segments.
    -  tf.sparse.segment_sum(c, tf.constant([0, 1, 2]), tf.constant([0, 0, 1]))
    -  # => [[0 0 0 0]
    -  #     [5 6 7 8]]
    -
    -  # Which is equivalent to:
    -  tf.math.segment_sum(c, tf.constant([0, 0, 1]))
    -  ```
    -
    -  Args:
    -    data: A `Tensor` with data that will be assembled in the output.
    -    indices: A 1-D `Tensor` with indices into `data`. Has same rank as
    -      `segment_ids`.
    -    segment_ids: A 1-D `Tensor` with indices into the output `Tensor`. Values
    -      should be sorted and can be repeated.
    -    name: A name for the operation (optional).
    -    num_segments: An optional int32 scalar. Indicates the size of the output
    -      `Tensor`.
    -
    -  Returns:
    -    A `tensor` of the shape as data, except for dimension 0 which
    -    has size `k`, the number of segments specified via `num_segments` or
    -    inferred for the last element in `segments_ids`.
    -  """
    -  if num_segments is not None:
    -    return gen_math_ops.sparse_segment_sum_with_num_segments(
    -        data=data,
    -        indices=indices,
    -        segment_ids=segment_ids,
    -        num_segments=num_segments,
    -        name=name)
    -  else:
    -    return gen_math_ops.sparse_segment_sum(
    -        data=data, indices=indices, segment_ids=segment_ids, name=name)
    -
    -
    -@tf_export("sparse.segment_sum", v1=[])
    -def sparse_segment_sum_v2(data,
    -                          indices,
    -                          segment_ids,
    -                          num_segments=None,
    -                          name=None):
    -  r"""Computes the sum along sparse segments of a tensor.
    -
    -  Read [the section on
    -  segmentation](https://www.tensorflow.org/versions/r2.0/api_docs/python/tf/math#about_segmentation)
    -  for an explanation of segments.
    -
    -  Like `tf.math.segment_sum`, but `segment_ids` can have rank less than `data`'s
    -  first dimension, selecting a subset of dimension 0, specified by `indices`.
    -  `segment_ids` is allowed to have missing ids, in which case the output will
    -  be zeros at those indices. In those cases `num_segments` is used to determine
    -  the size of the output.
    -
    -  For example:
    -
    -  ```python
    -  c = tf.constant([[1,2,3,4], [-1,-2,-3,-4], [5,6,7,8]])
    -
    -  # Select two rows, one segment.
    -  tf.sparse.segment_sum(c, tf.constant([0, 1]), tf.constant([0, 0]))
    -  # => [[0 0 0 0]]
    -
    -  # Select two rows, two segment.
    -  tf.sparse.segment_sum(c, tf.constant([0, 1]), tf.constant([0, 1]))
    -  # => [[ 1  2  3  4]
    -  #     [-1 -2 -3 -4]]
    -
    -  # With missing segment ids.
    -  tf.sparse.segment_sum(c, tf.constant([0, 1]), tf.constant([0, 2]),
    -                        num_segments=4)
    -  # => [[ 1  2  3  4]
    -  #     [ 0  0  0  0]
    -  #     [-1 -2 -3 -4]
    -  #     [ 0  0  0  0]]
    -
    -  # Select all rows, two segments.
    -  tf.sparse.segment_sum(c, tf.constant([0, 1, 2]), tf.constant([0, 0, 1]))
    -  # => [[0 0 0 0]
    -  #     [5 6 7 8]]
    -
    -  # Which is equivalent to:
    -  tf.math.segment_sum(c, tf.constant([0, 0, 1]))
    -  ```
    -
    -  Args:
    -    data: A `Tensor` with data that will be assembled in the output.
    -    indices: A 1-D `Tensor` with indices into `data`. Has same rank as
    -      `segment_ids`.
    -    segment_ids: A 1-D `Tensor` with indices into the output `Tensor`. Values
    -      should be sorted and can be repeated.
    -    num_segments: An optional int32 scalar. Indicates the size of the output
    -      `Tensor`.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    A `tensor` of the shape as data, except for dimension 0 which
    -    has size `k`, the number of segments specified via `num_segments` or
    -    inferred for the last element in `segments_ids`.
    -  """
    -  return sparse_segment_sum(
    -      data, indices, segment_ids, name=name, num_segments=num_segments)
    -
    -
    -@tf_export(v1=["sparse.segment_mean", "sparse_segment_mean"])
    -@deprecation.deprecated_endpoints("sparse_segment_mean")
    -def sparse_segment_mean(data,
    -                        indices,
    -                        segment_ids,
    -                        name=None,
    -                        num_segments=None):
    -  r"""Computes the mean along sparse segments of a tensor.
    -
    -  Read [the section on
    -  segmentation](https://www.tensorflow.org/versions/r2.0/api_docs/python/tf/math#about_segmentation)
    -  for an explanation of segments.
    -
    -  Like `tf.math.segment_mean`, but `segment_ids` can have rank less than
    -  `data`'s first dimension, selecting a subset of dimension 0, specified by
    -  `indices`.
    -  `segment_ids` is allowed to have missing ids, in which case the output will
    -  be zeros at those indices. In those cases `num_segments` is used to determine
    -  the size of the output.
    -
    -  Args:
    -    data: A `Tensor` with data that will be assembled in the output.
    -    indices: A 1-D `Tensor` with indices into `data`. Has same rank as
    -      `segment_ids`.
    -    segment_ids: A 1-D `Tensor` with indices into the output `Tensor`. Values
    -      should be sorted and can be repeated.
    -    name: A name for the operation (optional).
    -    num_segments: An optional int32 scalar. Indicates the size of the output
    -      `Tensor`.
    -
    -  Returns:
    -    A `tensor` of the shape as data, except for dimension 0 which
    -    has size `k`, the number of segments specified via `num_segments` or
    -    inferred for the last element in `segments_ids`.
    -  """
    -  if num_segments is not None:
    -    return gen_math_ops.sparse_segment_mean_with_num_segments(
    -        data=data,
    -        indices=indices,
    -        segment_ids=segment_ids,
    -        num_segments=num_segments,
    -        name=name)
    -  else:
    -    return gen_math_ops.sparse_segment_mean(
    -        data=data, indices=indices, segment_ids=segment_ids, name=name)
    -
    -
    -@tf_export("sparse.segment_mean", v1=[])
    -def sparse_segment_mean_v2(data,
    -                           indices,
    -                           segment_ids,
    -                           num_segments=None,
    -                           name=None):
    -  r"""Computes the mean along sparse segments of a tensor.
    -
    -  Read [the section on
    -  segmentation](https://www.tensorflow.org/versions/r2.0/api_docs/python/tf/math#about_segmentation)
    -  for an explanation of segments.
    -
    -  Like `tf.math.segment_mean`, but `segment_ids` can have rank less than
    -  `data`'s first dimension, selecting a subset of dimension 0, specified by
    -  `indices`.
    -  `segment_ids` is allowed to have missing ids, in which case the output will
    -  be zeros at those indices. In those cases `num_segments` is used to determine
    -  the size of the output.
    -
    -  Args:
    -    data: A `Tensor` with data that will be assembled in the output.
    -    indices: A 1-D `Tensor` with indices into `data`. Has same rank as
    -      `segment_ids`.
    -    segment_ids: A 1-D `Tensor` with indices into the output `Tensor`. Values
    -      should be sorted and can be repeated.
    -    num_segments: An optional int32 scalar. Indicates the size of the output
    -      `Tensor`.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    A `tensor` of the shape as data, except for dimension 0 which
    -    has size `k`, the number of segments specified via `num_segments` or
    -    inferred for the last element in `segments_ids`.
    -  """
    -  return sparse_segment_mean(
    -      data, indices, segment_ids, name=name, num_segments=num_segments)
    -
    -
    -@tf_export(v1=["sparse.segment_sqrt_n", "sparse_segment_sqrt_n"])
    -@deprecation.deprecated_endpoints("sparse_segment_sqrt_n")
    -def sparse_segment_sqrt_n(data,
    -                          indices,
    -                          segment_ids,
    -                          name=None,
    -                          num_segments=None):
    -  r"""Computes the sum along sparse segments of a tensor divided by the sqrt(N).
    -
    -  `N` is the size of the segment being reduced.
    -
    -  Args:
    -    data: A `Tensor` with data that will be assembled in the output.
    -    indices: A 1-D `Tensor` with indices into `data`. Has same rank as
    -      `segment_ids`.
    -    segment_ids: A 1-D `Tensor` with indices into the output `Tensor`. Values
    -      should be sorted and can be repeated.
    -    name: A name for the operation (optional).
    -    num_segments: An optional int32 scalar. Indicates the size of the output
    -      `Tensor`.
    -
    -  Returns:
    -    A `tensor` of the shape as data, except for dimension 0 which
    -    has size `k`, the number of segments specified via `num_segments` or
    -    inferred for the last element in `segments_ids`.
    -  """
    -  if num_segments is not None:
    -    return gen_math_ops.sparse_segment_sqrt_n_with_num_segments(
    -        data=data,
    -        indices=indices,
    -        segment_ids=segment_ids,
    -        num_segments=num_segments,
    -        name=name)
    -  else:
    -    return gen_math_ops.sparse_segment_sqrt_n(
    -        data=data, indices=indices, segment_ids=segment_ids, name=name)
    -
    -
    -@tf_export("sparse.segment_sqrt_n", v1=[])
    -def sparse_segment_sqrt_n_v2(data,
    -                             indices,
    -                             segment_ids,
    -                             num_segments=None,
    -                             name=None):
    -  r"""Computes the sum along sparse segments of a tensor divided by the sqrt(N).
    -
    -  Read [the section on
    -  segmentation](https://www.tensorflow.org/versions/r2.0/api_docs/python/tf/math#about_segmentation)
    -  for an explanation of segments.
    -
    -  Like `tf.sparse.segment_mean`, but instead of dividing by the size of the
    -  segment, `N`, divide by `sqrt(N)` instead.
    -
    -  Args:
    -    data: A `Tensor` with data that will be assembled in the output.
    -    indices: A 1-D `Tensor` with indices into `data`. Has same rank as
    -      `segment_ids`.
    -    segment_ids: A 1-D `Tensor` with indices into the output `Tensor`. Values
    -      should be sorted and can be repeated.
    -    num_segments: An optional int32 scalar. Indicates the size of the output
    -      `Tensor`.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    A `tensor` of the shape as data, except for dimension 0 which
    -    has size `k`, the number of segments specified via `num_segments` or
    -    inferred for the last element in `segments_ids`.
    -  """
    -  return sparse_segment_sqrt_n(
    -      data, indices, segment_ids, name=name, num_segments=num_segments)
    -
    -
    -@tf_export("tensordot", "linalg.tensordot")
    -def tensordot(a, b, axes, name=None):
    -  r"""Tensor contraction of a and b along specified axes and outer product.
    -
    -  Tensordot (also known as tensor contraction) sums the product of elements
    -  from `a` and `b` over the indices specified by `a_axes` and `b_axes`.
    -  The lists `a_axes` and `b_axes` specify those pairs of axes along which to
    -  contract the tensors. The axis `a_axes[i]` of `a` must have the same dimension
    -  as axis `b_axes[i]` of `b` for all `i` in `range(0, len(a_axes))`. The lists
    -  `a_axes` and `b_axes` must have identical length and consist of unique
    -  integers that specify valid axes for each of the tensors. Additionally
    -  outer product is supported by passing `axes=0`.
    -
    -  This operation corresponds to `numpy.tensordot(a, b, axes)`.
    -
    -  Example 1: When `a` and `b` are matrices (order 2), the case `axes = 1`
    -  is equivalent to matrix multiplication.
    -
    -  Example 2: When `a` and `b` are matrices (order 2), the case
    -  `axes = [[1], [0]]` is equivalent to matrix multiplication.
    -
    -  Example 3: When `a` and `b` are matrices (order 2), the case `axes=0` gives
    -  the outer product, a tensor of order 4.
    -
    -  Example 4: Suppose that \\(a_{ijk}\\) and \\(b_{lmn}\\) represent two
    -  tensors of order 3. Then, `contract(a, b, [[0], [2]])` is the order 4 tensor
    -  \\(c_{jklm}\\) whose entry
    -  corresponding to the indices \\((j,k,l,m)\\) is given by:
    -
    -  \\( c_{jklm} = \sum_i a_{ijk} b_{lmi} \\).
    -
    -  In general, `order(c) = order(a) + order(b) - 2*len(axes[0])`.
    -
    -  Args:
    -    a: `Tensor` of type `float32` or `float64`.
    -    b: `Tensor` with the same type as `a`.
    -    axes: Either a scalar `N`, or a list or an `int32` `Tensor` of shape [2, k].
    -      If axes is a scalar, sum over the last N axes of a and the first N axes of
    -      b in order. If axes is a list or `Tensor` the first and second row contain
    -      the set of unique integers specifying axes along which the contraction is
    -      computed, for `a` and `b`, respectively. The number of axes for `a` and
    -      `b` must be equal. If `axes=0`, computes the outer product between `a` and
    -      `b`.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    A `Tensor` with the same type as `a`.
    -
    -  Raises:
    -    ValueError: If the shapes of `a`, `b`, and `axes` are incompatible.
    -    IndexError: If the values in axes exceed the rank of the corresponding
    -      tensor.
    -  """
    -
    -  def _tensordot_reshape(a, axes, flipped=False):
    -    """Helper method to perform transpose and reshape for contraction op.
    -
    -    This method is helpful in reducing `math_ops.tensordot` to `math_ops.matmul`
    -    using `array_ops.transpose` and `array_ops.reshape`. The method takes a
    -    tensor and performs the correct transpose and reshape operation for a given
    -    set of indices. It returns the reshaped tensor as well as a list of indices
    -    necessary to reshape the tensor again after matrix multiplication.
    -
    -    Args:
    -      a: `Tensor`.
    -      axes: List or `int32` `Tensor` of unique indices specifying valid axes of
    -        `a`.
    -      flipped: An optional `bool`. Defaults to `False`. If `True`, the method
    -        assumes that `a` is the second argument in the contraction operation.
    -
    -    Returns:
    -      A tuple `(reshaped_a, free_dims, free_dims_static)` where `reshaped_a` is
    -      the tensor `a` reshaped to allow contraction via `matmul`, `free_dims` is
    -      either a list of integers or an `int32` `Tensor`, depending on whether
    -      the shape of a is fully specified, and free_dims_static is either a list
    -      of integers and None values, or None, representing the inferred
    -      static shape of the free dimensions
    -    """
    -    if a.get_shape().is_fully_defined() and isinstance(axes, (list, tuple)):
    -      shape_a = a.get_shape().as_list()
    -      axes = [i if i >= 0 else i + len(shape_a) for i in axes]
    -      free = [i for i in xrange(len(shape_a)) if i not in axes]
    -      free_dims = [shape_a[i] for i in free]
    -      prod_free = int(np.prod([shape_a[i] for i in free]))
    -      prod_axes = int(np.prod([shape_a[i] for i in axes]))
    -      perm = list(axes) + free if flipped else free + list(axes)
    -      new_shape = [prod_axes, prod_free] if flipped else [prod_free, prod_axes]
    -      if (perm != np.arange(len(shape_a))).any():
    -        a_trans = array_ops.transpose(a, perm)
    -      else:
    -        a_trans = a
    -      if a_trans.get_shape().as_list() != new_shape:
    -        reshaped_a = array_ops.reshape(a_trans, new_shape)
    -      else:
    -        reshaped_a = a_trans
    -      return reshaped_a, free_dims, free_dims
    -    else:
    -      if a.get_shape().ndims is not None and isinstance(axes, (list, tuple)):
    -        shape_a = a.get_shape().as_list()
    -        axes = [i if i >= 0 else i + len(shape_a) for i in axes]
    -        free = [i for i in xrange(len(shape_a)) if i not in axes]
    -        axes_dims = [shape_a[i] for i in axes]
    -        free_dims = [shape_a[i] for i in free]
    -        free_dims_static = free_dims
    -        axes = ops.convert_to_tensor(axes, dtype=dtypes.int32, name="axes")
    -        free = ops.convert_to_tensor(free, dtype=dtypes.int32, name="free")
    -        shape_a = array_ops.shape(a)
    -      else:
    -        free_dims_static = None
    -        shape_a = array_ops.shape(a)
    -        rank_a = array_ops.rank(a)
    -        axes = ops.convert_to_tensor(axes, dtype=dtypes.int32, name="axes")
    -        axes = array_ops.where(axes >= 0, axes, axes + rank_a)
    -        free, _ = array_ops.setdiff1d(range(rank_a), axes)
    -      free_dims = array_ops.gather(shape_a, free)
    -      axes_dims = array_ops.gather(shape_a, axes)
    -      prod_free_dims = reduce_prod(free_dims)
    -      prod_axes_dims = reduce_prod(axes_dims)
    -      if flipped:
    -        perm = array_ops.concat([axes, free], 0)
    -        new_shape = array_ops.stack([prod_axes_dims, prod_free_dims])
    -      else:
    -        perm = array_ops.concat([free, axes], 0)
    -        new_shape = array_ops.stack([prod_free_dims, prod_axes_dims])
    -      reshaped_a = array_ops.reshape(array_ops.transpose(a, perm), new_shape)
    -      return reshaped_a, free_dims, free_dims_static
    -
    -  def _tensordot_axes(a, axes):
    -    """Generates two sets of contraction axes for the two tensor arguments."""
    -    a_shape = a.get_shape()
    -    if isinstance(axes, compat.integral_types):
    -      if axes < 0:
    -        raise ValueError("'axes' must be at least 0.")
    -      if a_shape.ndims is not None:
    -        if axes > a_shape.ndims:
    -          raise ValueError("'axes' must not be larger than the number of "
    -                           "dimensions of tensor %s." % a)
    -        return (list(xrange(a_shape.ndims - axes,
    -                            a_shape.ndims)), list(xrange(axes)))
    -      else:
    -        rank = array_ops.rank(a)
    -        return (range(rank - axes, rank,
    -                      dtype=dtypes.int32), range(axes, dtype=dtypes.int32))
    -    elif isinstance(axes, (list, tuple)):
    -      if len(axes) != 2:
    -        raise ValueError("'axes' must be an integer or have length 2.")
    -      a_axes = axes[0]
    -      b_axes = axes[1]
    -      if isinstance(a_axes, compat.integral_types) and \
    -          isinstance(b_axes, compat.integral_types):
    -        a_axes = [a_axes]
    -        b_axes = [b_axes]
    -      if len(a_axes) != len(b_axes):
    -        raise ValueError(
    -            "Different number of contraction axes 'a' and 'b', %s != %s." %
    -            (len(a_axes), len(b_axes)))
    -      return a_axes, b_axes
    -    else:
    -      axes = ops.convert_to_tensor(axes, name="axes", dtype=dtypes.int32)
    -      return axes[0], axes[1]
    -
    -  with ops.name_scope(name, "Tensordot", [a, b, axes]) as name:
    -    a = ops.convert_to_tensor(a, name="a")
    -    b = ops.convert_to_tensor(b, name="b")
    -    a_axes, b_axes = _tensordot_axes(a, axes)
    -    a_reshape, a_free_dims, a_free_dims_static = _tensordot_reshape(a, a_axes)
    -    b_reshape, b_free_dims, b_free_dims_static = _tensordot_reshape(
    -        b, b_axes, True)
    -    ab_matmul = matmul(a_reshape, b_reshape)
    -    if isinstance(a_free_dims, list) and isinstance(b_free_dims, list):
    -      if (ab_matmul.get_shape().is_fully_defined() and
    -          ab_matmul.get_shape().as_list() == a_free_dims + b_free_dims):
    -        return ab_matmul
    -      else:
    -        return array_ops.reshape(
    -            ab_matmul, a_free_dims + b_free_dims, name=name)
    -    else:
    -      a_free_dims = ops.convert_to_tensor(a_free_dims, dtype=dtypes.int32)
    -      b_free_dims = ops.convert_to_tensor(b_free_dims, dtype=dtypes.int32)
    -      product = array_ops.reshape(
    -          ab_matmul, array_ops.concat([a_free_dims, b_free_dims], 0), name=name)
    -      if a_free_dims_static is not None and b_free_dims_static is not None:
    -        product.set_shape(a_free_dims_static + b_free_dims_static)
    -      return product
    -
    -
    -@tf_export("math.polyval")
    -def polyval(coeffs, x, name=None):
    -  r"""Computes the elementwise value of a polynomial.
    -
    -  If `x` is a tensor and `coeffs` is a list n + 1 tensors,
    -  this function returns the value of the n-th order polynomial
    -
    -     p(x) = coeffs[n-1] + coeffs[n-2] * x + ...  + coeffs[0] * x**(n-1)
    -
    -  evaluated using Horner's method, i.e.
    -
    -     p(x) = coeffs[n-1] + x * (coeffs[n-2] + ... + x * (coeffs[1] +
    -            x * coeffs[0]))
    -            
    -  Usage Example:
    -  
    -  >>> coefficients = [1.0, 2.5, -4.2]
    -  >>> x = 5.0
    -  >>> y = tf.math.polyval(coefficients, x)
    -  >>> y
    -  <tf.Tensor: shape=(), dtype=float32, numpy=33.3>
    -
    -  Usage Example:
    -
    -  >>> tf.math.polyval([2, 1, 0], 3) # evaluates 2 * (3**2) + 1 * (3**1) + 0 * (3**0)
    -  <tf.Tensor: shape=(), dtype=int32, numpy=21>
    -
    -  `tf.math.polyval` can also be used in polynomial regression. Taking
    -  advantage of this function can facilitate writing a polynomial equation
    -  as compared to explicitly writing it out, especially for higher degree
    -  polynomials.
    -
    -  >>> x = tf.constant(3)
    -  >>> theta1 = tf.Variable(2)
    -  >>> theta2 = tf.Variable(1)
    -  >>> theta3 = tf.Variable(0)
    -  >>> tf.math.polyval([theta1, theta2, theta3], x)
    -  <tf.Tensor: shape=(), dtype=int32, numpy=21>
    -
    -  Args:
    -    coeffs: A list of `Tensor` representing the coefficients of the polynomial.
    -    x: A `Tensor` representing the variable of the polynomial.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    A `tensor` of the shape as the expression p(x) with usual broadcasting
    -    rules for element-wise addition and multiplication applied.
    -
    -  @compatibility(numpy)
    -  Equivalent to numpy.polyval.
    -  @end_compatibility
    -  """
    -  if not isinstance(coeffs, list):
    -    raise ValueError("Argument coeffs must be list type "
    -                     "found {}.".format(type(coeffs)))
    -
    -  with ops.name_scope(name, "polyval", nest.flatten(coeffs) + [x]) as name:
    -    x = ops.convert_to_tensor(x, name="x")
    -    if len(coeffs) < 1:
    -      return array_ops.zeros_like(x, name=name)
    -    coeffs = [
    -        ops.convert_to_tensor(coeff, name=("coeff_%d" % index))
    -        for index, coeff in enumerate(coeffs)
    -    ]
    -    p = coeffs[0]
    -    for c in coeffs[1:]:
    -      p = c + p * x
    -    return p
    -
    -
    -@tf_export("math.reciprocal_no_nan")
    -def reciprocal_no_nan(x, name=None):
    -  """Performs a safe reciprocal operation, element wise.
    -
    -  If a particular element is zero, the reciprocal for that element is
    -  also set to zero.
    -
    -  For example:
    -  ```python
    -  x = tf.constant([2.0, 0.5, 0, 1], dtype=tf.float32)
    -  tf.math.reciprocal_no_nan(x)  # [ 0.5, 2, 0.0, 1.0 ]
    -  ```
    -
    -  Args:
    -    x: A `Tensor` of type `float16`, `float32`, `float64` `complex64` or
    -      `complex128`.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    A `Tensor` of same shape and type as `x`.
    -
    -  Raises:
    -    TypeError: x must be of a valid dtype.
    -
    -  """
    -
    -  with ops.name_scope(name, "reciprocal_no_nan", [x]) as scope:
    -    x = ops.convert_to_tensor(x, name="x")
    -    one = constant_op.constant(1, dtype=x.dtype.base_dtype, name="one")
    -    return gen_math_ops.div_no_nan(one, x, name=scope)
    -
    -
    -@tf_export("math.xlog1py")
    -@dispatch.add_dispatch_support
    -def xlog1py(x, y, name=None):
    -  r"""Compute x * log1p(y).
    -
    -  Given `x` and `y`, compute `x * log1p(y)`. This function safely returns
    -  zero when `x = 0`, no matter what the value of `y` is.
    -
    -  Example:
    -
    -  >>> tf.math.xlog1py(0., 1.)
    -  <tf.Tensor: shape=(), dtype=float32, numpy=0.>
    -  >>> tf.math.xlog1py(1., 1.)
    -  <tf.Tensor: shape=(), dtype=float32, numpy=0.6931472>
    -  >>> tf.math.xlog1py(2., 2.)
    -  <tf.Tensor: shape=(), dtype=float32, numpy=2.1972246>
    -  >>> tf.math.xlog1py(0., -1.)
    -  <tf.Tensor: shape=(), dtype=float32, numpy=0.>
    -
    -  Args:
    -    x: A `tf.Tensor` of type `bfloat16`, `half`, `float32`, `float64`,
    -      `complex64`, `complex128`
    -    y: A `tf.Tensor` of type `bfloat16`, `half`, `float32`, `float64`,
    -      `complex64`, `complex128`
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    `x * log1p(y)`.
    -
    -  @compatibility(scipy)
    -  Equivalent to scipy.special.xlog1py
    -  @end_compatibility
    -  """
    -  with ops.name_scope(name, "xlog1py", [x]):
    -    return gen_math_ops.xlog1py(x, y)
    -
    -
    -@tf_export("math.erfinv")
    -@dispatch.add_dispatch_support
    -def erfinv(x, name=None):
    -  """Compute inverse error function.
    -
    -  Given `x`, compute the inverse error function of `x`. This function
    -  is the inverse of `tf.math.erf`.
    -
    -  Args:
    -    x: `Tensor` with type `float` or `double`.
    -    name: A name for the operation (optional).
    -  Returns:
    -    Inverse error function of `x`.
    -  """
    -  with ops.name_scope(name, "erfinv", [x]):
    -    return gen_math_ops.erfinv(x)
    -
    -
    -@tf_export("math.ndtri")
    -@dispatch.add_dispatch_support
    -def ndtri(x, name=None):
    -  """Compute quantile of Standard Normal.
    -
    -  Args:
    -    x: `Tensor` with type `float` or `double`.
    -    name: A name for the operation (optional).
    -  Returns:
    -    Inverse error function of `x`.
    -  """
    -  with ops.name_scope(name, "ndtri", [x]):
    -    return gen_math_ops.ndtri(x)
    -
    -
    -@tf_export("math.ceil", v1=["math.ceil", "ceil"])
    -@deprecation.deprecated_endpoints("ceil")
    -@dispatch.add_dispatch_support
    -def ceil(x, name=None):
    -  """Return the ceiling of the input, element-wise.
    -
    -  For example:
    -
    -  >>> tf.math.ceil([-1.7, -1.5, -0.2, 0.2, 1.5, 1.7, 2.0])
    -  <tf.Tensor: shape=(7,), dtype=float32,
    -  numpy=array([-1., -1., -0.,  1.,  2.,  2.,  2.], dtype=float32)>
    -
    -  Args:
    -    x: A `tf.Tensor`. Must be one of the following types: `bfloat16`, `half`,
    -      `float32`, `float64`. `int32`
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    A `tf.Tensor`. Has the same type as `x`.
    -
    -  @compatibility(numpy)
    -  Equivalent to np.ceil
    -  @end_compatibility
    -  """
    -  return gen_math_ops.ceil(x, name)
    -
    -
    -@tf_export("math.sqrt", "sqrt")
    -@dispatch.add_dispatch_support
    -def sqrt(x, name=None):  # pylint: disable=redefined-builtin
    -  r"""Computes element-wise square root of the input tensor.
    -
    -  Note: This operation does not support integer types.
    -
    -  >>> x = tf.constant([[4.0], [16.0]])
    -  >>> tf.sqrt(x)
    -  <tf.Tensor: shape=(2, 1), dtype=float32, numpy=
    -    array([[2.],
    -           [4.]], dtype=float32)>
    -  >>> y = tf.constant([[-4.0], [16.0]])
    -  >>> tf.sqrt(y)
    -  <tf.Tensor: shape=(2, 1), dtype=float32, numpy=
    -    array([[nan],
    -           [ 4.]], dtype=float32)>
    -  >>> z = tf.constant([[-1.0], [16.0]], dtype=tf.complex128)
    -  >>> tf.sqrt(z)
    -  <tf.Tensor: shape=(2, 1), dtype=complex128, numpy=
    -    array([[0.0+1.j],
    -           [4.0+0.j]])>
    -
    -  Note: In order to support complex complex, please provide an input tensor
    -  of `complex64` or `complex128`.
    -
    -  Args:
    -    x: A `tf.Tensor` of type `bfloat16`, `half`, `float32`, `float64`,
    -      `complex64`, `complex128`
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    A `tf.Tensor` of same size, type and sparsity as `x`.
    -  """
    -  return gen_math_ops.sqrt(x, name)
    -
    -
    -# pylint: disable=g-docstring-has-escape
    -@tf_export("math.exp", "exp")
    -@dispatch.add_dispatch_support
    -def exp(x, name=None):
    -  r"""Computes exponential of x element-wise.  \\(y = e^x\\).
    -
    -  This function computes the exponential of the input tensor element-wise.
    -  i.e. `math.exp(x)` or \\(e^x\\), where `x` is the input tensor.
    -  \\(e\\) denotes Euler's number and is approximately equal to 2.718281.
    -  Output is positive for any real input.
    -
    -  >>> x = tf.constant(2.0)
    -  >>> tf.math.exp(x)
    -  <tf.Tensor: shape=(), dtype=float32, numpy=7.389056>
    -
    -  >>> x = tf.constant([2.0, 8.0])
    -  >>> tf.math.exp(x)
    -  <tf.Tensor: shape=(2,), dtype=float32,
    -  numpy=array([   7.389056, 2980.958   ], dtype=float32)>
    -
    -  For complex numbers, the exponential value is calculated as
    -  \\(e^{x+iy}={e^x}{e^{iy}}={e^x}{\\cos(y)+i\\sin(y)}\\)
    -
    -  For `1+1j` the value would be computed as:
    -  \\(e^1{\\cos(1)+i\\sin(1)} = 2.7182817 \\times (0.5403023+0.84147096j)\\)
    -
    -  >>> x = tf.constant(1 + 1j)
    -  >>> tf.math.exp(x)
    -  <tf.Tensor: shape=(), dtype=complex128,
    -  numpy=(1.4686939399158851+2.2873552871788423j)>
    -
    -  Args:
    -    x: A `tf.Tensor`. Must be one of the following types: `bfloat16`, `half`,
    -      `float32`, `float64`, `complex64`, `complex128`.
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    A `tf.Tensor`. Has the same type as `x`.
    -
    -  @compatibility(numpy)
    -  Equivalent to np.exp
    -  @end_compatibility
    -  """
    -  return gen_math_ops.exp(x, name)
    -
    -
    -# pylint: enable=g-docstring-has-escape
    -
    -
    -@tf_export("math.sobol_sample")
    -def sobol_sample(dim, num_results, skip=0, dtype=dtypes.float32, name=None):
    -  """Generates points from the Sobol sequence.
    -
    -  Creates a Sobol sequence with `num_results` samples. Each sample has dimension
    -  `dim`. Skips the first `skip` samples.
    -
    -  Args:
    -    dim: Positive scalar `Tensor` representing each sample's dimension.
    -    num_results: Positive scalar `Tensor` of dtype int32. The number of Sobol
    -        points to return in the output.
    -    skip: (Optional) Positive scalar `Tensor` of dtype int32. The number of
    -        initial points of the Sobol sequence to skip. Default value is 0.
    -    dtype: (Optional) The `tf.Dtype` of the sample. One of: `tf.float32` or
    -        `tf.float64`. Defaults to `tf.float32`.
    -    name: (Optional) Python `str` name prefixed to ops created by this function.
    -
    -  Returns:
    -    `Tensor` of samples from Sobol sequence with `shape` [num_results, dim].
    -  """
    -  with ops.name_scope(name, "sobol", [dim, num_results, skip]):
    -    return gen_math_ops.sobol_sample(dim, num_results, skip, dtype=dtype)
    -
    -
    -@tf_export("math.rsqrt", v1=["math.rsqrt", "rsqrt"])
    -@deprecation.deprecated_endpoints("rsqrt")
    -@dispatch.add_dispatch_support
    -def rsqrt(x, name=None):
    -  """Computes reciprocal of square root of x element-wise.
    -
    -  For example:
    -
    -  >>> x = tf.constant([2., 0., -2.])
    -  >>> tf.math.rsqrt(x)
    -  <tf.Tensor: shape=(3,), dtype=float32,
    -  numpy=array([0.707, inf, nan], dtype=float32)>
    -
    -  Args:
    -    x: A `tf.Tensor`. Must be one of the following types: `bfloat16`, `half`,
    -      `float32`, `float64`. `int32`
    -    name: A name for the operation (optional).
    -
    -  Returns:
    -    A `tf.Tensor`. Has the same type as `x`.
    -  """
    -  return gen_math_ops.rsqrt(x, name)
    -
    - -
    - -
    -
    - -
    - -
    -

    - © Copyright 2021 - present / Neuralmagic, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"). - -

    -
    - - - - Built with Sphinx using a - - theme - - provided by Read the Docs. - -
    -
    -
    - -
    - -
    - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sparseml/_static/doctools.js b/sparseml/_static/doctools.js index 144884ea651..61ac9d266f9 100644 --- a/sparseml/_static/doctools.js +++ b/sparseml/_static/doctools.js @@ -29,9 +29,14 @@ if (!window.console || !console.firebug) { /** * small helper function to urldecode strings + * + * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent#Decoding_query_parameters_from_a_URL */ jQuery.urldecode = function(x) { - return decodeURIComponent(x).replace(/\+/g, ' '); + if (!x) { + return x + } + return decodeURIComponent(x.replace(/\+/g, ' ')); }; /** diff --git a/sparseml/_static/language_data.js b/sparseml/_static/language_data.js index 0e7dc7e9ef0..863704b310d 100644 --- a/sparseml/_static/language_data.js +++ b/sparseml/_static/language_data.js @@ -13,7 +13,8 @@ var stopwords = ["a","and","are","as","at","be","but","by","for","if","in","into","is","it","near","no","not","of","on","or","such","that","the","their","then","there","these","they","this","to","was","will","with"]; -/* Non-minified version JS is _stemmer.js if file is provided */ +/* Non-minified version is copied as a separate JS file, is available */ + /** * Porter Stemmer */ @@ -199,7 +200,6 @@ var Stemmer = function() { - var splitChars = (function() { var result = {}; var singles = [96, 180, 187, 191, 215, 247, 749, 885, 903, 907, 909, 930, 1014, 1648, diff --git a/sparseml/_static/pygments.css b/sparseml/_static/pygments.css index de7af262ffb..691aeb82d00 100644 --- a/sparseml/_static/pygments.css +++ b/sparseml/_static/pygments.css @@ -1,7 +1,7 @@ pre { line-height: 125%; } -td.linenos pre { color: #000000; background-color: #f0f0f0; padding-left: 5px; padding-right: 5px; } -span.linenos { color: #000000; background-color: #f0f0f0; padding-left: 5px; padding-right: 5px; } -td.linenos pre.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } +td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } +span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } +td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } .highlight .hll { background-color: #ffffcc } .highlight { background: #eeffcc; } diff --git a/sparseml/_static/searchtools.js b/sparseml/_static/searchtools.js index 6fc9e7f3338..1a90152eb0e 100644 --- a/sparseml/_static/searchtools.js +++ b/sparseml/_static/searchtools.js @@ -248,7 +248,7 @@ var Search = { // results left, load the summary and display it if (results.length) { var item = results.pop(); - var listItem = $('
  • '); + var listItem = $('
  • '); var requestUrl = ""; var linkUrl = ""; if (DOCUMENTATION_OPTIONS.BUILDER === 'dirhtml') { @@ -273,9 +273,9 @@ var Search = { if (item[3]) { listItem.append($(' (' + item[3] + ')')); Search.output.append(listItem); - listItem.slideDown(5, function() { + setTimeout(function() { displayNextItem(); - }); + }, 5); } else if (DOCUMENTATION_OPTIONS.HAS_SOURCE) { $.ajax({url: requestUrl, dataType: "text", @@ -285,16 +285,16 @@ var Search = { listItem.append(Search.makeSearchSummary(data, searchterms, hlterms)); } Search.output.append(listItem); - listItem.slideDown(5, function() { + setTimeout(function() { displayNextItem(); - }); + }, 5); }}); } else { // no source available, just display title Search.output.append(listItem); - listItem.slideDown(5, function() { + setTimeout(function() { displayNextItem(); - }); + }, 5); } } // search finished, update title and status message @@ -379,6 +379,13 @@ var Search = { return results; }, + /** + * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions + */ + escapeRegExp : function(string) { + return string.replace(/[.*+\-?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string + }, + /** * search for full-text terms in the index */ @@ -402,13 +409,14 @@ var Search = { ]; // add support for partial matches if (word.length > 2) { + var word_regex = this.escapeRegExp(word); for (var w in terms) { - if (w.match(word) && !terms[word]) { + if (w.match(word_regex) && !terms[word]) { _o.push({files: terms[w], score: Scorer.partialTerm}) } } for (var w in titleterms) { - if (w.match(word) && !titleterms[word]) { + if (w.match(word_regex) && !titleterms[word]) { _o.push({files: titleterms[w], score: Scorer.partialTitle}) } } diff --git a/sparseml/_static/underscore-1.12.0.js b/sparseml/_static/underscore-1.12.0.js new file mode 100644 index 00000000000..3af6352e613 --- /dev/null +++ b/sparseml/_static/underscore-1.12.0.js @@ -0,0 +1,2027 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : + typeof define === 'function' && define.amd ? define('underscore', factory) : + (global = global || self, (function () { + var current = global._; + var exports = global._ = factory(); + exports.noConflict = function () { global._ = current; return exports; }; + }())); +}(this, (function () { + // Underscore.js 1.12.0 + // https://underscorejs.org + // (c) 2009-2020 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors + // Underscore may be freely distributed under the MIT license. + + // Current version. + var VERSION = '1.12.0'; + + // Establish the root object, `window` (`self`) in the browser, `global` + // on the server, or `this` in some virtual machines. We use `self` + // instead of `window` for `WebWorker` support. + var root = typeof self == 'object' && self.self === self && self || + typeof global == 'object' && global.global === global && global || + Function('return this')() || + {}; + + // Save bytes in the minified (but not gzipped) version: + var ArrayProto = Array.prototype, ObjProto = Object.prototype; + var SymbolProto = typeof Symbol !== 'undefined' ? Symbol.prototype : null; + + // Create quick reference variables for speed access to core prototypes. + var push = ArrayProto.push, + slice = ArrayProto.slice, + toString = ObjProto.toString, + hasOwnProperty = ObjProto.hasOwnProperty; + + // Modern feature detection. + var supportsArrayBuffer = typeof ArrayBuffer !== 'undefined', + supportsDataView = typeof DataView !== 'undefined'; + + // All **ECMAScript 5+** native function implementations that we hope to use + // are declared here. + var nativeIsArray = Array.isArray, + nativeKeys = Object.keys, + nativeCreate = Object.create, + nativeIsView = supportsArrayBuffer && ArrayBuffer.isView; + + // Create references to these builtin functions because we override them. + var _isNaN = isNaN, + _isFinite = isFinite; + + // Keys in IE < 9 that won't be iterated by `for key in ...` and thus missed. + var hasEnumBug = !{toString: null}.propertyIsEnumerable('toString'); + var nonEnumerableProps = ['valueOf', 'isPrototypeOf', 'toString', + 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString']; + + // The largest integer that can be represented exactly. + var MAX_ARRAY_INDEX = Math.pow(2, 53) - 1; + + // Some functions take a variable number of arguments, or a few expected + // arguments at the beginning and then a variable number of values to operate + // on. This helper accumulates all remaining arguments past the function’s + // argument length (or an explicit `startIndex`), into an array that becomes + // the last argument. Similar to ES6’s "rest parameter". + function restArguments(func, startIndex) { + startIndex = startIndex == null ? func.length - 1 : +startIndex; + return function() { + var length = Math.max(arguments.length - startIndex, 0), + rest = Array(length), + index = 0; + for (; index < length; index++) { + rest[index] = arguments[index + startIndex]; + } + switch (startIndex) { + case 0: return func.call(this, rest); + case 1: return func.call(this, arguments[0], rest); + case 2: return func.call(this, arguments[0], arguments[1], rest); + } + var args = Array(startIndex + 1); + for (index = 0; index < startIndex; index++) { + args[index] = arguments[index]; + } + args[startIndex] = rest; + return func.apply(this, args); + }; + } + + // Is a given variable an object? + function isObject(obj) { + var type = typeof obj; + return type === 'function' || type === 'object' && !!obj; + } + + // Is a given value equal to null? + function isNull(obj) { + return obj === null; + } + + // Is a given variable undefined? + function isUndefined(obj) { + return obj === void 0; + } + + // Is a given value a boolean? + function isBoolean(obj) { + return obj === true || obj === false || toString.call(obj) === '[object Boolean]'; + } + + // Is a given value a DOM element? + function isElement(obj) { + return !!(obj && obj.nodeType === 1); + } + + // Internal function for creating a `toString`-based type tester. + function tagTester(name) { + var tag = '[object ' + name + ']'; + return function(obj) { + return toString.call(obj) === tag; + }; + } + + var isString = tagTester('String'); + + var isNumber = tagTester('Number'); + + var isDate = tagTester('Date'); + + var isRegExp = tagTester('RegExp'); + + var isError = tagTester('Error'); + + var isSymbol = tagTester('Symbol'); + + var isArrayBuffer = tagTester('ArrayBuffer'); + + var isFunction = tagTester('Function'); + + // Optimize `isFunction` if appropriate. Work around some `typeof` bugs in old + // v8, IE 11 (#1621), Safari 8 (#1929), and PhantomJS (#2236). + var nodelist = root.document && root.document.childNodes; + if (typeof /./ != 'function' && typeof Int8Array != 'object' && typeof nodelist != 'function') { + isFunction = function(obj) { + return typeof obj == 'function' || false; + }; + } + + var isFunction$1 = isFunction; + + var hasObjectTag = tagTester('Object'); + + // In IE 10 - Edge 13, `DataView` has string tag `'[object Object]'`. + // In IE 11, the most common among them, this problem also applies to + // `Map`, `WeakMap` and `Set`. + var hasStringTagBug = ( + supportsDataView && hasObjectTag(new DataView(new ArrayBuffer(8))) + ), + isIE11 = (typeof Map !== 'undefined' && hasObjectTag(new Map)); + + var isDataView = tagTester('DataView'); + + // In IE 10 - Edge 13, we need a different heuristic + // to determine whether an object is a `DataView`. + function ie10IsDataView(obj) { + return obj != null && isFunction$1(obj.getInt8) && isArrayBuffer(obj.buffer); + } + + var isDataView$1 = (hasStringTagBug ? ie10IsDataView : isDataView); + + // Is a given value an array? + // Delegates to ECMA5's native `Array.isArray`. + var isArray = nativeIsArray || tagTester('Array'); + + // Internal function to check whether `key` is an own property name of `obj`. + function has(obj, key) { + return obj != null && hasOwnProperty.call(obj, key); + } + + var isArguments = tagTester('Arguments'); + + // Define a fallback version of the method in browsers (ahem, IE < 9), where + // there isn't any inspectable "Arguments" type. + (function() { + if (!isArguments(arguments)) { + isArguments = function(obj) { + return has(obj, 'callee'); + }; + } + }()); + + var isArguments$1 = isArguments; + + // Is a given object a finite number? + function isFinite$1(obj) { + return !isSymbol(obj) && _isFinite(obj) && !isNaN(parseFloat(obj)); + } + + // Is the given value `NaN`? + function isNaN$1(obj) { + return isNumber(obj) && _isNaN(obj); + } + + // Predicate-generating function. Often useful outside of Underscore. + function constant(value) { + return function() { + return value; + }; + } + + // Common internal logic for `isArrayLike` and `isBufferLike`. + function createSizePropertyCheck(getSizeProperty) { + return function(collection) { + var sizeProperty = getSizeProperty(collection); + return typeof sizeProperty == 'number' && sizeProperty >= 0 && sizeProperty <= MAX_ARRAY_INDEX; + } + } + + // Internal helper to generate a function to obtain property `key` from `obj`. + function shallowProperty(key) { + return function(obj) { + return obj == null ? void 0 : obj[key]; + }; + } + + // Internal helper to obtain the `byteLength` property of an object. + var getByteLength = shallowProperty('byteLength'); + + // Internal helper to determine whether we should spend extensive checks against + // `ArrayBuffer` et al. + var isBufferLike = createSizePropertyCheck(getByteLength); + + // Is a given value a typed array? + var typedArrayPattern = /\[object ((I|Ui)nt(8|16|32)|Float(32|64)|Uint8Clamped|Big(I|Ui)nt64)Array\]/; + function isTypedArray(obj) { + // `ArrayBuffer.isView` is the most future-proof, so use it when available. + // Otherwise, fall back on the above regular expression. + return nativeIsView ? (nativeIsView(obj) && !isDataView$1(obj)) : + isBufferLike(obj) && typedArrayPattern.test(toString.call(obj)); + } + + var isTypedArray$1 = supportsArrayBuffer ? isTypedArray : constant(false); + + // Internal helper to obtain the `length` property of an object. + var getLength = shallowProperty('length'); + + // Internal helper to create a simple lookup structure. + // `collectNonEnumProps` used to depend on `_.contains`, but this led to + // circular imports. `emulatedSet` is a one-off solution that only works for + // arrays of strings. + function emulatedSet(keys) { + var hash = {}; + for (var l = keys.length, i = 0; i < l; ++i) hash[keys[i]] = true; + return { + contains: function(key) { return hash[key]; }, + push: function(key) { + hash[key] = true; + return keys.push(key); + } + }; + } + + // Internal helper. Checks `keys` for the presence of keys in IE < 9 that won't + // be iterated by `for key in ...` and thus missed. Extends `keys` in place if + // needed. + function collectNonEnumProps(obj, keys) { + keys = emulatedSet(keys); + var nonEnumIdx = nonEnumerableProps.length; + var constructor = obj.constructor; + var proto = isFunction$1(constructor) && constructor.prototype || ObjProto; + + // Constructor is a special case. + var prop = 'constructor'; + if (has(obj, prop) && !keys.contains(prop)) keys.push(prop); + + while (nonEnumIdx--) { + prop = nonEnumerableProps[nonEnumIdx]; + if (prop in obj && obj[prop] !== proto[prop] && !keys.contains(prop)) { + keys.push(prop); + } + } + } + + // Retrieve the names of an object's own properties. + // Delegates to **ECMAScript 5**'s native `Object.keys`. + function keys(obj) { + if (!isObject(obj)) return []; + if (nativeKeys) return nativeKeys(obj); + var keys = []; + for (var key in obj) if (has(obj, key)) keys.push(key); + // Ahem, IE < 9. + if (hasEnumBug) collectNonEnumProps(obj, keys); + return keys; + } + + // Is a given array, string, or object empty? + // An "empty" object has no enumerable own-properties. + function isEmpty(obj) { + if (obj == null) return true; + // Skip the more expensive `toString`-based type checks if `obj` has no + // `.length`. + var length = getLength(obj); + if (typeof length == 'number' && ( + isArray(obj) || isString(obj) || isArguments$1(obj) + )) return length === 0; + return getLength(keys(obj)) === 0; + } + + // Returns whether an object has a given set of `key:value` pairs. + function isMatch(object, attrs) { + var _keys = keys(attrs), length = _keys.length; + if (object == null) return !length; + var obj = Object(object); + for (var i = 0; i < length; i++) { + var key = _keys[i]; + if (attrs[key] !== obj[key] || !(key in obj)) return false; + } + return true; + } + + // If Underscore is called as a function, it returns a wrapped object that can + // be used OO-style. This wrapper holds altered versions of all functions added + // through `_.mixin`. Wrapped objects may be chained. + function _(obj) { + if (obj instanceof _) return obj; + if (!(this instanceof _)) return new _(obj); + this._wrapped = obj; + } + + _.VERSION = VERSION; + + // Extracts the result from a wrapped and chained object. + _.prototype.value = function() { + return this._wrapped; + }; + + // Provide unwrapping proxies for some methods used in engine operations + // such as arithmetic and JSON stringification. + _.prototype.valueOf = _.prototype.toJSON = _.prototype.value; + + _.prototype.toString = function() { + return String(this._wrapped); + }; + + // Internal function to wrap or shallow-copy an ArrayBuffer, + // typed array or DataView to a new view, reusing the buffer. + function toBufferView(bufferSource) { + return new Uint8Array( + bufferSource.buffer || bufferSource, + bufferSource.byteOffset || 0, + getByteLength(bufferSource) + ); + } + + // We use this string twice, so give it a name for minification. + var tagDataView = '[object DataView]'; + + // Internal recursive comparison function for `_.isEqual`. + function eq(a, b, aStack, bStack) { + // Identical objects are equal. `0 === -0`, but they aren't identical. + // See the [Harmony `egal` proposal](https://wiki.ecmascript.org/doku.php?id=harmony:egal). + if (a === b) return a !== 0 || 1 / a === 1 / b; + // `null` or `undefined` only equal to itself (strict comparison). + if (a == null || b == null) return false; + // `NaN`s are equivalent, but non-reflexive. + if (a !== a) return b !== b; + // Exhaust primitive checks + var type = typeof a; + if (type !== 'function' && type !== 'object' && typeof b != 'object') return false; + return deepEq(a, b, aStack, bStack); + } + + // Internal recursive comparison function for `_.isEqual`. + function deepEq(a, b, aStack, bStack) { + // Unwrap any wrapped objects. + if (a instanceof _) a = a._wrapped; + if (b instanceof _) b = b._wrapped; + // Compare `[[Class]]` names. + var className = toString.call(a); + if (className !== toString.call(b)) return false; + // Work around a bug in IE 10 - Edge 13. + if (hasStringTagBug && className == '[object Object]' && isDataView$1(a)) { + if (!isDataView$1(b)) return false; + className = tagDataView; + } + switch (className) { + // These types are compared by value. + case '[object RegExp]': + // RegExps are coerced to strings for comparison (Note: '' + /a/i === '/a/i') + case '[object String]': + // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is + // equivalent to `new String("5")`. + return '' + a === '' + b; + case '[object Number]': + // `NaN`s are equivalent, but non-reflexive. + // Object(NaN) is equivalent to NaN. + if (+a !== +a) return +b !== +b; + // An `egal` comparison is performed for other numeric values. + return +a === 0 ? 1 / +a === 1 / b : +a === +b; + case '[object Date]': + case '[object Boolean]': + // Coerce dates and booleans to numeric primitive values. Dates are compared by their + // millisecond representations. Note that invalid dates with millisecond representations + // of `NaN` are not equivalent. + return +a === +b; + case '[object Symbol]': + return SymbolProto.valueOf.call(a) === SymbolProto.valueOf.call(b); + case '[object ArrayBuffer]': + case tagDataView: + // Coerce to typed array so we can fall through. + return deepEq(toBufferView(a), toBufferView(b), aStack, bStack); + } + + var areArrays = className === '[object Array]'; + if (!areArrays && isTypedArray$1(a)) { + var byteLength = getByteLength(a); + if (byteLength !== getByteLength(b)) return false; + if (a.buffer === b.buffer && a.byteOffset === b.byteOffset) return true; + areArrays = true; + } + if (!areArrays) { + if (typeof a != 'object' || typeof b != 'object') return false; + + // Objects with different constructors are not equivalent, but `Object`s or `Array`s + // from different frames are. + var aCtor = a.constructor, bCtor = b.constructor; + if (aCtor !== bCtor && !(isFunction$1(aCtor) && aCtor instanceof aCtor && + isFunction$1(bCtor) && bCtor instanceof bCtor) + && ('constructor' in a && 'constructor' in b)) { + return false; + } + } + // Assume equality for cyclic structures. The algorithm for detecting cyclic + // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`. + + // Initializing stack of traversed objects. + // It's done here since we only need them for objects and arrays comparison. + aStack = aStack || []; + bStack = bStack || []; + var length = aStack.length; + while (length--) { + // Linear search. Performance is inversely proportional to the number of + // unique nested structures. + if (aStack[length] === a) return bStack[length] === b; + } + + // Add the first object to the stack of traversed objects. + aStack.push(a); + bStack.push(b); + + // Recursively compare objects and arrays. + if (areArrays) { + // Compare array lengths to determine if a deep comparison is necessary. + length = a.length; + if (length !== b.length) return false; + // Deep compare the contents, ignoring non-numeric properties. + while (length--) { + if (!eq(a[length], b[length], aStack, bStack)) return false; + } + } else { + // Deep compare objects. + var _keys = keys(a), key; + length = _keys.length; + // Ensure that both objects contain the same number of properties before comparing deep equality. + if (keys(b).length !== length) return false; + while (length--) { + // Deep compare each member + key = _keys[length]; + if (!(has(b, key) && eq(a[key], b[key], aStack, bStack))) return false; + } + } + // Remove the first object from the stack of traversed objects. + aStack.pop(); + bStack.pop(); + return true; + } + + // Perform a deep comparison to check if two objects are equal. + function isEqual(a, b) { + return eq(a, b); + } + + // Retrieve all the enumerable property names of an object. + function allKeys(obj) { + if (!isObject(obj)) return []; + var keys = []; + for (var key in obj) keys.push(key); + // Ahem, IE < 9. + if (hasEnumBug) collectNonEnumProps(obj, keys); + return keys; + } + + // Since the regular `Object.prototype.toString` type tests don't work for + // some types in IE 11, we use a fingerprinting heuristic instead, based + // on the methods. It's not great, but it's the best we got. + // The fingerprint method lists are defined below. + function ie11fingerprint(methods) { + var length = getLength(methods); + return function(obj) { + if (obj == null) return false; + // `Map`, `WeakMap` and `Set` have no enumerable keys. + var keys = allKeys(obj); + if (getLength(keys)) return false; + for (var i = 0; i < length; i++) { + if (!isFunction$1(obj[methods[i]])) return false; + } + // If we are testing against `WeakMap`, we need to ensure that + // `obj` doesn't have a `forEach` method in order to distinguish + // it from a regular `Map`. + return methods !== weakMapMethods || !isFunction$1(obj[forEachName]); + }; + } + + // In the interest of compact minification, we write + // each string in the fingerprints only once. + var forEachName = 'forEach', + hasName = 'has', + commonInit = ['clear', 'delete'], + mapTail = ['get', hasName, 'set']; + + // `Map`, `WeakMap` and `Set` each have slightly different + // combinations of the above sublists. + var mapMethods = commonInit.concat(forEachName, mapTail), + weakMapMethods = commonInit.concat(mapTail), + setMethods = ['add'].concat(commonInit, forEachName, hasName); + + var isMap = isIE11 ? ie11fingerprint(mapMethods) : tagTester('Map'); + + var isWeakMap = isIE11 ? ie11fingerprint(weakMapMethods) : tagTester('WeakMap'); + + var isSet = isIE11 ? ie11fingerprint(setMethods) : tagTester('Set'); + + var isWeakSet = tagTester('WeakSet'); + + // Retrieve the values of an object's properties. + function values(obj) { + var _keys = keys(obj); + var length = _keys.length; + var values = Array(length); + for (var i = 0; i < length; i++) { + values[i] = obj[_keys[i]]; + } + return values; + } + + // Convert an object into a list of `[key, value]` pairs. + // The opposite of `_.object` with one argument. + function pairs(obj) { + var _keys = keys(obj); + var length = _keys.length; + var pairs = Array(length); + for (var i = 0; i < length; i++) { + pairs[i] = [_keys[i], obj[_keys[i]]]; + } + return pairs; + } + + // Invert the keys and values of an object. The values must be serializable. + function invert(obj) { + var result = {}; + var _keys = keys(obj); + for (var i = 0, length = _keys.length; i < length; i++) { + result[obj[_keys[i]]] = _keys[i]; + } + return result; + } + + // Return a sorted list of the function names available on the object. + function functions(obj) { + var names = []; + for (var key in obj) { + if (isFunction$1(obj[key])) names.push(key); + } + return names.sort(); + } + + // An internal function for creating assigner functions. + function createAssigner(keysFunc, defaults) { + return function(obj) { + var length = arguments.length; + if (defaults) obj = Object(obj); + if (length < 2 || obj == null) return obj; + for (var index = 1; index < length; index++) { + var source = arguments[index], + keys = keysFunc(source), + l = keys.length; + for (var i = 0; i < l; i++) { + var key = keys[i]; + if (!defaults || obj[key] === void 0) obj[key] = source[key]; + } + } + return obj; + }; + } + + // Extend a given object with all the properties in passed-in object(s). + var extend = createAssigner(allKeys); + + // Assigns a given object with all the own properties in the passed-in + // object(s). + // (https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) + var extendOwn = createAssigner(keys); + + // Fill in a given object with default properties. + var defaults = createAssigner(allKeys, true); + + // Create a naked function reference for surrogate-prototype-swapping. + function ctor() { + return function(){}; + } + + // An internal function for creating a new object that inherits from another. + function baseCreate(prototype) { + if (!isObject(prototype)) return {}; + if (nativeCreate) return nativeCreate(prototype); + var Ctor = ctor(); + Ctor.prototype = prototype; + var result = new Ctor; + Ctor.prototype = null; + return result; + } + + // Creates an object that inherits from the given prototype object. + // If additional properties are provided then they will be added to the + // created object. + function create(prototype, props) { + var result = baseCreate(prototype); + if (props) extendOwn(result, props); + return result; + } + + // Create a (shallow-cloned) duplicate of an object. + function clone(obj) { + if (!isObject(obj)) return obj; + return isArray(obj) ? obj.slice() : extend({}, obj); + } + + // Invokes `interceptor` with the `obj` and then returns `obj`. + // The primary purpose of this method is to "tap into" a method chain, in + // order to perform operations on intermediate results within the chain. + function tap(obj, interceptor) { + interceptor(obj); + return obj; + } + + // Normalize a (deep) property `path` to array. + // Like `_.iteratee`, this function can be customized. + function toPath(path) { + return isArray(path) ? path : [path]; + } + _.toPath = toPath; + + // Internal wrapper for `_.toPath` to enable minification. + // Similar to `cb` for `_.iteratee`. + function toPath$1(path) { + return _.toPath(path); + } + + // Internal function to obtain a nested property in `obj` along `path`. + function deepGet(obj, path) { + var length = path.length; + for (var i = 0; i < length; i++) { + if (obj == null) return void 0; + obj = obj[path[i]]; + } + return length ? obj : void 0; + } + + // Get the value of the (deep) property on `path` from `object`. + // If any property in `path` does not exist or if the value is + // `undefined`, return `defaultValue` instead. + // The `path` is normalized through `_.toPath`. + function get(object, path, defaultValue) { + var value = deepGet(object, toPath$1(path)); + return isUndefined(value) ? defaultValue : value; + } + + // Shortcut function for checking if an object has a given property directly on + // itself (in other words, not on a prototype). Unlike the internal `has` + // function, this public version can also traverse nested properties. + function has$1(obj, path) { + path = toPath$1(path); + var length = path.length; + for (var i = 0; i < length; i++) { + var key = path[i]; + if (!has(obj, key)) return false; + obj = obj[key]; + } + return !!length; + } + + // Keep the identity function around for default iteratees. + function identity(value) { + return value; + } + + // Returns a predicate for checking whether an object has a given set of + // `key:value` pairs. + function matcher(attrs) { + attrs = extendOwn({}, attrs); + return function(obj) { + return isMatch(obj, attrs); + }; + } + + // Creates a function that, when passed an object, will traverse that object’s + // properties down the given `path`, specified as an array of keys or indices. + function property(path) { + path = toPath$1(path); + return function(obj) { + return deepGet(obj, path); + }; + } + + // Internal function that returns an efficient (for current engines) version + // of the passed-in callback, to be repeatedly applied in other Underscore + // functions. + function optimizeCb(func, context, argCount) { + if (context === void 0) return func; + switch (argCount == null ? 3 : argCount) { + case 1: return function(value) { + return func.call(context, value); + }; + // The 2-argument case is omitted because we’re not using it. + case 3: return function(value, index, collection) { + return func.call(context, value, index, collection); + }; + case 4: return function(accumulator, value, index, collection) { + return func.call(context, accumulator, value, index, collection); + }; + } + return function() { + return func.apply(context, arguments); + }; + } + + // An internal function to generate callbacks that can be applied to each + // element in a collection, returning the desired result — either `_.identity`, + // an arbitrary callback, a property matcher, or a property accessor. + function baseIteratee(value, context, argCount) { + if (value == null) return identity; + if (isFunction$1(value)) return optimizeCb(value, context, argCount); + if (isObject(value) && !isArray(value)) return matcher(value); + return property(value); + } + + // External wrapper for our callback generator. Users may customize + // `_.iteratee` if they want additional predicate/iteratee shorthand styles. + // This abstraction hides the internal-only `argCount` argument. + function iteratee(value, context) { + return baseIteratee(value, context, Infinity); + } + _.iteratee = iteratee; + + // The function we call internally to generate a callback. It invokes + // `_.iteratee` if overridden, otherwise `baseIteratee`. + function cb(value, context, argCount) { + if (_.iteratee !== iteratee) return _.iteratee(value, context); + return baseIteratee(value, context, argCount); + } + + // Returns the results of applying the `iteratee` to each element of `obj`. + // In contrast to `_.map` it returns an object. + function mapObject(obj, iteratee, context) { + iteratee = cb(iteratee, context); + var _keys = keys(obj), + length = _keys.length, + results = {}; + for (var index = 0; index < length; index++) { + var currentKey = _keys[index]; + results[currentKey] = iteratee(obj[currentKey], currentKey, obj); + } + return results; + } + + // Predicate-generating function. Often useful outside of Underscore. + function noop(){} + + // Generates a function for a given object that returns a given property. + function propertyOf(obj) { + if (obj == null) return noop; + return function(path) { + return get(obj, path); + }; + } + + // Run a function **n** times. + function times(n, iteratee, context) { + var accum = Array(Math.max(0, n)); + iteratee = optimizeCb(iteratee, context, 1); + for (var i = 0; i < n; i++) accum[i] = iteratee(i); + return accum; + } + + // Return a random integer between `min` and `max` (inclusive). + function random(min, max) { + if (max == null) { + max = min; + min = 0; + } + return min + Math.floor(Math.random() * (max - min + 1)); + } + + // A (possibly faster) way to get the current timestamp as an integer. + var now = Date.now || function() { + return new Date().getTime(); + }; + + // Internal helper to generate functions for escaping and unescaping strings + // to/from HTML interpolation. + function createEscaper(map) { + var escaper = function(match) { + return map[match]; + }; + // Regexes for identifying a key that needs to be escaped. + var source = '(?:' + keys(map).join('|') + ')'; + var testRegexp = RegExp(source); + var replaceRegexp = RegExp(source, 'g'); + return function(string) { + string = string == null ? '' : '' + string; + return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string; + }; + } + + // Internal list of HTML entities for escaping. + var escapeMap = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + "'": ''', + '`': '`' + }; + + // Function for escaping strings to HTML interpolation. + var _escape = createEscaper(escapeMap); + + // Internal list of HTML entities for unescaping. + var unescapeMap = invert(escapeMap); + + // Function for unescaping strings from HTML interpolation. + var _unescape = createEscaper(unescapeMap); + + // By default, Underscore uses ERB-style template delimiters. Change the + // following template settings to use alternative delimiters. + var templateSettings = _.templateSettings = { + evaluate: /<%([\s\S]+?)%>/g, + interpolate: /<%=([\s\S]+?)%>/g, + escape: /<%-([\s\S]+?)%>/g + }; + + // When customizing `_.templateSettings`, if you don't want to define an + // interpolation, evaluation or escaping regex, we need one that is + // guaranteed not to match. + var noMatch = /(.)^/; + + // Certain characters need to be escaped so that they can be put into a + // string literal. + var escapes = { + "'": "'", + '\\': '\\', + '\r': 'r', + '\n': 'n', + '\u2028': 'u2028', + '\u2029': 'u2029' + }; + + var escapeRegExp = /\\|'|\r|\n|\u2028|\u2029/g; + + function escapeChar(match) { + return '\\' + escapes[match]; + } + + // JavaScript micro-templating, similar to John Resig's implementation. + // Underscore templating handles arbitrary delimiters, preserves whitespace, + // and correctly escapes quotes within interpolated code. + // NB: `oldSettings` only exists for backwards compatibility. + function template(text, settings, oldSettings) { + if (!settings && oldSettings) settings = oldSettings; + settings = defaults({}, settings, _.templateSettings); + + // Combine delimiters into one regular expression via alternation. + var matcher = RegExp([ + (settings.escape || noMatch).source, + (settings.interpolate || noMatch).source, + (settings.evaluate || noMatch).source + ].join('|') + '|$', 'g'); + + // Compile the template source, escaping string literals appropriately. + var index = 0; + var source = "__p+='"; + text.replace(matcher, function(match, escape, interpolate, evaluate, offset) { + source += text.slice(index, offset).replace(escapeRegExp, escapeChar); + index = offset + match.length; + + if (escape) { + source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'"; + } else if (interpolate) { + source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'"; + } else if (evaluate) { + source += "';\n" + evaluate + "\n__p+='"; + } + + // Adobe VMs need the match returned to produce the correct offset. + return match; + }); + source += "';\n"; + + // If a variable is not specified, place data values in local scope. + if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n'; + + source = "var __t,__p='',__j=Array.prototype.join," + + "print=function(){__p+=__j.call(arguments,'');};\n" + + source + 'return __p;\n'; + + var render; + try { + render = new Function(settings.variable || 'obj', '_', source); + } catch (e) { + e.source = source; + throw e; + } + + var template = function(data) { + return render.call(this, data, _); + }; + + // Provide the compiled source as a convenience for precompilation. + var argument = settings.variable || 'obj'; + template.source = 'function(' + argument + '){\n' + source + '}'; + + return template; + } + + // Traverses the children of `obj` along `path`. If a child is a function, it + // is invoked with its parent as context. Returns the value of the final + // child, or `fallback` if any child is undefined. + function result(obj, path, fallback) { + path = toPath$1(path); + var length = path.length; + if (!length) { + return isFunction$1(fallback) ? fallback.call(obj) : fallback; + } + for (var i = 0; i < length; i++) { + var prop = obj == null ? void 0 : obj[path[i]]; + if (prop === void 0) { + prop = fallback; + i = length; // Ensure we don't continue iterating. + } + obj = isFunction$1(prop) ? prop.call(obj) : prop; + } + return obj; + } + + // Generate a unique integer id (unique within the entire client session). + // Useful for temporary DOM ids. + var idCounter = 0; + function uniqueId(prefix) { + var id = ++idCounter + ''; + return prefix ? prefix + id : id; + } + + // Start chaining a wrapped Underscore object. + function chain(obj) { + var instance = _(obj); + instance._chain = true; + return instance; + } + + // Internal function to execute `sourceFunc` bound to `context` with optional + // `args`. Determines whether to execute a function as a constructor or as a + // normal function. + function executeBound(sourceFunc, boundFunc, context, callingContext, args) { + if (!(callingContext instanceof boundFunc)) return sourceFunc.apply(context, args); + var self = baseCreate(sourceFunc.prototype); + var result = sourceFunc.apply(self, args); + if (isObject(result)) return result; + return self; + } + + // Partially apply a function by creating a version that has had some of its + // arguments pre-filled, without changing its dynamic `this` context. `_` acts + // as a placeholder by default, allowing any combination of arguments to be + // pre-filled. Set `_.partial.placeholder` for a custom placeholder argument. + var partial = restArguments(function(func, boundArgs) { + var placeholder = partial.placeholder; + var bound = function() { + var position = 0, length = boundArgs.length; + var args = Array(length); + for (var i = 0; i < length; i++) { + args[i] = boundArgs[i] === placeholder ? arguments[position++] : boundArgs[i]; + } + while (position < arguments.length) args.push(arguments[position++]); + return executeBound(func, bound, this, this, args); + }; + return bound; + }); + + partial.placeholder = _; + + // Create a function bound to a given object (assigning `this`, and arguments, + // optionally). + var bind = restArguments(function(func, context, args) { + if (!isFunction$1(func)) throw new TypeError('Bind must be called on a function'); + var bound = restArguments(function(callArgs) { + return executeBound(func, bound, context, this, args.concat(callArgs)); + }); + return bound; + }); + + // Internal helper for collection methods to determine whether a collection + // should be iterated as an array or as an object. + // Related: https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength + // Avoids a very nasty iOS 8 JIT bug on ARM-64. #2094 + var isArrayLike = createSizePropertyCheck(getLength); + + // Internal implementation of a recursive `flatten` function. + function flatten(input, depth, strict, output) { + output = output || []; + if (!depth && depth !== 0) { + depth = Infinity; + } else if (depth <= 0) { + return output.concat(input); + } + var idx = output.length; + for (var i = 0, length = getLength(input); i < length; i++) { + var value = input[i]; + if (isArrayLike(value) && (isArray(value) || isArguments$1(value))) { + // Flatten current level of array or arguments object. + if (depth > 1) { + flatten(value, depth - 1, strict, output); + idx = output.length; + } else { + var j = 0, len = value.length; + while (j < len) output[idx++] = value[j++]; + } + } else if (!strict) { + output[idx++] = value; + } + } + return output; + } + + // Bind a number of an object's methods to that object. Remaining arguments + // are the method names to be bound. Useful for ensuring that all callbacks + // defined on an object belong to it. + var bindAll = restArguments(function(obj, keys) { + keys = flatten(keys, false, false); + var index = keys.length; + if (index < 1) throw new Error('bindAll must be passed function names'); + while (index--) { + var key = keys[index]; + obj[key] = bind(obj[key], obj); + } + return obj; + }); + + // Memoize an expensive function by storing its results. + function memoize(func, hasher) { + var memoize = function(key) { + var cache = memoize.cache; + var address = '' + (hasher ? hasher.apply(this, arguments) : key); + if (!has(cache, address)) cache[address] = func.apply(this, arguments); + return cache[address]; + }; + memoize.cache = {}; + return memoize; + } + + // Delays a function for the given number of milliseconds, and then calls + // it with the arguments supplied. + var delay = restArguments(function(func, wait, args) { + return setTimeout(function() { + return func.apply(null, args); + }, wait); + }); + + // Defers a function, scheduling it to run after the current call stack has + // cleared. + var defer = partial(delay, _, 1); + + // Returns a function, that, when invoked, will only be triggered at most once + // during a given window of time. Normally, the throttled function will run + // as much as it can, without ever going more than once per `wait` duration; + // but if you'd like to disable the execution on the leading edge, pass + // `{leading: false}`. To disable execution on the trailing edge, ditto. + function throttle(func, wait, options) { + var timeout, context, args, result; + var previous = 0; + if (!options) options = {}; + + var later = function() { + previous = options.leading === false ? 0 : now(); + timeout = null; + result = func.apply(context, args); + if (!timeout) context = args = null; + }; + + var throttled = function() { + var _now = now(); + if (!previous && options.leading === false) previous = _now; + var remaining = wait - (_now - previous); + context = this; + args = arguments; + if (remaining <= 0 || remaining > wait) { + if (timeout) { + clearTimeout(timeout); + timeout = null; + } + previous = _now; + result = func.apply(context, args); + if (!timeout) context = args = null; + } else if (!timeout && options.trailing !== false) { + timeout = setTimeout(later, remaining); + } + return result; + }; + + throttled.cancel = function() { + clearTimeout(timeout); + previous = 0; + timeout = context = args = null; + }; + + return throttled; + } + + // When a sequence of calls of the returned function ends, the argument + // function is triggered. The end of a sequence is defined by the `wait` + // parameter. If `immediate` is passed, the argument function will be + // triggered at the beginning of the sequence instead of at the end. + function debounce(func, wait, immediate) { + var timeout, previous, args, result, context; + + var later = function() { + var passed = now() - previous; + if (wait > passed) { + timeout = setTimeout(later, wait - passed); + } else { + timeout = null; + if (!immediate) result = func.apply(context, args); + // This check is needed because `func` can recursively invoke `debounced`. + if (!timeout) args = context = null; + } + }; + + var debounced = restArguments(function(_args) { + context = this; + args = _args; + previous = now(); + if (!timeout) { + timeout = setTimeout(later, wait); + if (immediate) result = func.apply(context, args); + } + return result; + }); + + debounced.cancel = function() { + clearTimeout(timeout); + timeout = args = context = null; + }; + + return debounced; + } + + // Returns the first function passed as an argument to the second, + // allowing you to adjust arguments, run code before and after, and + // conditionally execute the original function. + function wrap(func, wrapper) { + return partial(wrapper, func); + } + + // Returns a negated version of the passed-in predicate. + function negate(predicate) { + return function() { + return !predicate.apply(this, arguments); + }; + } + + // Returns a function that is the composition of a list of functions, each + // consuming the return value of the function that follows. + function compose() { + var args = arguments; + var start = args.length - 1; + return function() { + var i = start; + var result = args[start].apply(this, arguments); + while (i--) result = args[i].call(this, result); + return result; + }; + } + + // Returns a function that will only be executed on and after the Nth call. + function after(times, func) { + return function() { + if (--times < 1) { + return func.apply(this, arguments); + } + }; + } + + // Returns a function that will only be executed up to (but not including) the + // Nth call. + function before(times, func) { + var memo; + return function() { + if (--times > 0) { + memo = func.apply(this, arguments); + } + if (times <= 1) func = null; + return memo; + }; + } + + // Returns a function that will be executed at most one time, no matter how + // often you call it. Useful for lazy initialization. + var once = partial(before, 2); + + // Returns the first key on an object that passes a truth test. + function findKey(obj, predicate, context) { + predicate = cb(predicate, context); + var _keys = keys(obj), key; + for (var i = 0, length = _keys.length; i < length; i++) { + key = _keys[i]; + if (predicate(obj[key], key, obj)) return key; + } + } + + // Internal function to generate `_.findIndex` and `_.findLastIndex`. + function createPredicateIndexFinder(dir) { + return function(array, predicate, context) { + predicate = cb(predicate, context); + var length = getLength(array); + var index = dir > 0 ? 0 : length - 1; + for (; index >= 0 && index < length; index += dir) { + if (predicate(array[index], index, array)) return index; + } + return -1; + }; + } + + // Returns the first index on an array-like that passes a truth test. + var findIndex = createPredicateIndexFinder(1); + + // Returns the last index on an array-like that passes a truth test. + var findLastIndex = createPredicateIndexFinder(-1); + + // Use a comparator function to figure out the smallest index at which + // an object should be inserted so as to maintain order. Uses binary search. + function sortedIndex(array, obj, iteratee, context) { + iteratee = cb(iteratee, context, 1); + var value = iteratee(obj); + var low = 0, high = getLength(array); + while (low < high) { + var mid = Math.floor((low + high) / 2); + if (iteratee(array[mid]) < value) low = mid + 1; else high = mid; + } + return low; + } + + // Internal function to generate the `_.indexOf` and `_.lastIndexOf` functions. + function createIndexFinder(dir, predicateFind, sortedIndex) { + return function(array, item, idx) { + var i = 0, length = getLength(array); + if (typeof idx == 'number') { + if (dir > 0) { + i = idx >= 0 ? idx : Math.max(idx + length, i); + } else { + length = idx >= 0 ? Math.min(idx + 1, length) : idx + length + 1; + } + } else if (sortedIndex && idx && length) { + idx = sortedIndex(array, item); + return array[idx] === item ? idx : -1; + } + if (item !== item) { + idx = predicateFind(slice.call(array, i, length), isNaN$1); + return idx >= 0 ? idx + i : -1; + } + for (idx = dir > 0 ? i : length - 1; idx >= 0 && idx < length; idx += dir) { + if (array[idx] === item) return idx; + } + return -1; + }; + } + + // Return the position of the first occurrence of an item in an array, + // or -1 if the item is not included in the array. + // If the array is large and already in sort order, pass `true` + // for **isSorted** to use binary search. + var indexOf = createIndexFinder(1, findIndex, sortedIndex); + + // Return the position of the last occurrence of an item in an array, + // or -1 if the item is not included in the array. + var lastIndexOf = createIndexFinder(-1, findLastIndex); + + // Return the first value which passes a truth test. + function find(obj, predicate, context) { + var keyFinder = isArrayLike(obj) ? findIndex : findKey; + var key = keyFinder(obj, predicate, context); + if (key !== void 0 && key !== -1) return obj[key]; + } + + // Convenience version of a common use case of `_.find`: getting the first + // object containing specific `key:value` pairs. + function findWhere(obj, attrs) { + return find(obj, matcher(attrs)); + } + + // The cornerstone for collection functions, an `each` + // implementation, aka `forEach`. + // Handles raw objects in addition to array-likes. Treats all + // sparse array-likes as if they were dense. + function each(obj, iteratee, context) { + iteratee = optimizeCb(iteratee, context); + var i, length; + if (isArrayLike(obj)) { + for (i = 0, length = obj.length; i < length; i++) { + iteratee(obj[i], i, obj); + } + } else { + var _keys = keys(obj); + for (i = 0, length = _keys.length; i < length; i++) { + iteratee(obj[_keys[i]], _keys[i], obj); + } + } + return obj; + } + + // Return the results of applying the iteratee to each element. + function map(obj, iteratee, context) { + iteratee = cb(iteratee, context); + var _keys = !isArrayLike(obj) && keys(obj), + length = (_keys || obj).length, + results = Array(length); + for (var index = 0; index < length; index++) { + var currentKey = _keys ? _keys[index] : index; + results[index] = iteratee(obj[currentKey], currentKey, obj); + } + return results; + } + + // Internal helper to create a reducing function, iterating left or right. + function createReduce(dir) { + // Wrap code that reassigns argument variables in a separate function than + // the one that accesses `arguments.length` to avoid a perf hit. (#1991) + var reducer = function(obj, iteratee, memo, initial) { + var _keys = !isArrayLike(obj) && keys(obj), + length = (_keys || obj).length, + index = dir > 0 ? 0 : length - 1; + if (!initial) { + memo = obj[_keys ? _keys[index] : index]; + index += dir; + } + for (; index >= 0 && index < length; index += dir) { + var currentKey = _keys ? _keys[index] : index; + memo = iteratee(memo, obj[currentKey], currentKey, obj); + } + return memo; + }; + + return function(obj, iteratee, memo, context) { + var initial = arguments.length >= 3; + return reducer(obj, optimizeCb(iteratee, context, 4), memo, initial); + }; + } + + // **Reduce** builds up a single result from a list of values, aka `inject`, + // or `foldl`. + var reduce = createReduce(1); + + // The right-associative version of reduce, also known as `foldr`. + var reduceRight = createReduce(-1); + + // Return all the elements that pass a truth test. + function filter(obj, predicate, context) { + var results = []; + predicate = cb(predicate, context); + each(obj, function(value, index, list) { + if (predicate(value, index, list)) results.push(value); + }); + return results; + } + + // Return all the elements for which a truth test fails. + function reject(obj, predicate, context) { + return filter(obj, negate(cb(predicate)), context); + } + + // Determine whether all of the elements pass a truth test. + function every(obj, predicate, context) { + predicate = cb(predicate, context); + var _keys = !isArrayLike(obj) && keys(obj), + length = (_keys || obj).length; + for (var index = 0; index < length; index++) { + var currentKey = _keys ? _keys[index] : index; + if (!predicate(obj[currentKey], currentKey, obj)) return false; + } + return true; + } + + // Determine if at least one element in the object passes a truth test. + function some(obj, predicate, context) { + predicate = cb(predicate, context); + var _keys = !isArrayLike(obj) && keys(obj), + length = (_keys || obj).length; + for (var index = 0; index < length; index++) { + var currentKey = _keys ? _keys[index] : index; + if (predicate(obj[currentKey], currentKey, obj)) return true; + } + return false; + } + + // Determine if the array or object contains a given item (using `===`). + function contains(obj, item, fromIndex, guard) { + if (!isArrayLike(obj)) obj = values(obj); + if (typeof fromIndex != 'number' || guard) fromIndex = 0; + return indexOf(obj, item, fromIndex) >= 0; + } + + // Invoke a method (with arguments) on every item in a collection. + var invoke = restArguments(function(obj, path, args) { + var contextPath, func; + if (isFunction$1(path)) { + func = path; + } else { + path = toPath$1(path); + contextPath = path.slice(0, -1); + path = path[path.length - 1]; + } + return map(obj, function(context) { + var method = func; + if (!method) { + if (contextPath && contextPath.length) { + context = deepGet(context, contextPath); + } + if (context == null) return void 0; + method = context[path]; + } + return method == null ? method : method.apply(context, args); + }); + }); + + // Convenience version of a common use case of `_.map`: fetching a property. + function pluck(obj, key) { + return map(obj, property(key)); + } + + // Convenience version of a common use case of `_.filter`: selecting only + // objects containing specific `key:value` pairs. + function where(obj, attrs) { + return filter(obj, matcher(attrs)); + } + + // Return the maximum element (or element-based computation). + function max(obj, iteratee, context) { + var result = -Infinity, lastComputed = -Infinity, + value, computed; + if (iteratee == null || typeof iteratee == 'number' && typeof obj[0] != 'object' && obj != null) { + obj = isArrayLike(obj) ? obj : values(obj); + for (var i = 0, length = obj.length; i < length; i++) { + value = obj[i]; + if (value != null && value > result) { + result = value; + } + } + } else { + iteratee = cb(iteratee, context); + each(obj, function(v, index, list) { + computed = iteratee(v, index, list); + if (computed > lastComputed || computed === -Infinity && result === -Infinity) { + result = v; + lastComputed = computed; + } + }); + } + return result; + } + + // Return the minimum element (or element-based computation). + function min(obj, iteratee, context) { + var result = Infinity, lastComputed = Infinity, + value, computed; + if (iteratee == null || typeof iteratee == 'number' && typeof obj[0] != 'object' && obj != null) { + obj = isArrayLike(obj) ? obj : values(obj); + for (var i = 0, length = obj.length; i < length; i++) { + value = obj[i]; + if (value != null && value < result) { + result = value; + } + } + } else { + iteratee = cb(iteratee, context); + each(obj, function(v, index, list) { + computed = iteratee(v, index, list); + if (computed < lastComputed || computed === Infinity && result === Infinity) { + result = v; + lastComputed = computed; + } + }); + } + return result; + } + + // Sample **n** random values from a collection using the modern version of the + // [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher–Yates_shuffle). + // If **n** is not specified, returns a single random element. + // The internal `guard` argument allows it to work with `_.map`. + function sample(obj, n, guard) { + if (n == null || guard) { + if (!isArrayLike(obj)) obj = values(obj); + return obj[random(obj.length - 1)]; + } + var sample = isArrayLike(obj) ? clone(obj) : values(obj); + var length = getLength(sample); + n = Math.max(Math.min(n, length), 0); + var last = length - 1; + for (var index = 0; index < n; index++) { + var rand = random(index, last); + var temp = sample[index]; + sample[index] = sample[rand]; + sample[rand] = temp; + } + return sample.slice(0, n); + } + + // Shuffle a collection. + function shuffle(obj) { + return sample(obj, Infinity); + } + + // Sort the object's values by a criterion produced by an iteratee. + function sortBy(obj, iteratee, context) { + var index = 0; + iteratee = cb(iteratee, context); + return pluck(map(obj, function(value, key, list) { + return { + value: value, + index: index++, + criteria: iteratee(value, key, list) + }; + }).sort(function(left, right) { + var a = left.criteria; + var b = right.criteria; + if (a !== b) { + if (a > b || a === void 0) return 1; + if (a < b || b === void 0) return -1; + } + return left.index - right.index; + }), 'value'); + } + + // An internal function used for aggregate "group by" operations. + function group(behavior, partition) { + return function(obj, iteratee, context) { + var result = partition ? [[], []] : {}; + iteratee = cb(iteratee, context); + each(obj, function(value, index) { + var key = iteratee(value, index, obj); + behavior(result, value, key); + }); + return result; + }; + } + + // Groups the object's values by a criterion. Pass either a string attribute + // to group by, or a function that returns the criterion. + var groupBy = group(function(result, value, key) { + if (has(result, key)) result[key].push(value); else result[key] = [value]; + }); + + // Indexes the object's values by a criterion, similar to `_.groupBy`, but for + // when you know that your index values will be unique. + var indexBy = group(function(result, value, key) { + result[key] = value; + }); + + // Counts instances of an object that group by a certain criterion. Pass + // either a string attribute to count by, or a function that returns the + // criterion. + var countBy = group(function(result, value, key) { + if (has(result, key)) result[key]++; else result[key] = 1; + }); + + // Split a collection into two arrays: one whose elements all pass the given + // truth test, and one whose elements all do not pass the truth test. + var partition = group(function(result, value, pass) { + result[pass ? 0 : 1].push(value); + }, true); + + // Safely create a real, live array from anything iterable. + var reStrSymbol = /[^\ud800-\udfff]|[\ud800-\udbff][\udc00-\udfff]|[\ud800-\udfff]/g; + function toArray(obj) { + if (!obj) return []; + if (isArray(obj)) return slice.call(obj); + if (isString(obj)) { + // Keep surrogate pair characters together. + return obj.match(reStrSymbol); + } + if (isArrayLike(obj)) return map(obj, identity); + return values(obj); + } + + // Return the number of elements in a collection. + function size(obj) { + if (obj == null) return 0; + return isArrayLike(obj) ? obj.length : keys(obj).length; + } + + // Internal `_.pick` helper function to determine whether `key` is an enumerable + // property name of `obj`. + function keyInObj(value, key, obj) { + return key in obj; + } + + // Return a copy of the object only containing the allowed properties. + var pick = restArguments(function(obj, keys) { + var result = {}, iteratee = keys[0]; + if (obj == null) return result; + if (isFunction$1(iteratee)) { + if (keys.length > 1) iteratee = optimizeCb(iteratee, keys[1]); + keys = allKeys(obj); + } else { + iteratee = keyInObj; + keys = flatten(keys, false, false); + obj = Object(obj); + } + for (var i = 0, length = keys.length; i < length; i++) { + var key = keys[i]; + var value = obj[key]; + if (iteratee(value, key, obj)) result[key] = value; + } + return result; + }); + + // Return a copy of the object without the disallowed properties. + var omit = restArguments(function(obj, keys) { + var iteratee = keys[0], context; + if (isFunction$1(iteratee)) { + iteratee = negate(iteratee); + if (keys.length > 1) context = keys[1]; + } else { + keys = map(flatten(keys, false, false), String); + iteratee = function(value, key) { + return !contains(keys, key); + }; + } + return pick(obj, iteratee, context); + }); + + // Returns everything but the last entry of the array. Especially useful on + // the arguments object. Passing **n** will return all the values in + // the array, excluding the last N. + function initial(array, n, guard) { + return slice.call(array, 0, Math.max(0, array.length - (n == null || guard ? 1 : n))); + } + + // Get the first element of an array. Passing **n** will return the first N + // values in the array. The **guard** check allows it to work with `_.map`. + function first(array, n, guard) { + if (array == null || array.length < 1) return n == null || guard ? void 0 : []; + if (n == null || guard) return array[0]; + return initial(array, array.length - n); + } + + // Returns everything but the first entry of the `array`. Especially useful on + // the `arguments` object. Passing an **n** will return the rest N values in the + // `array`. + function rest(array, n, guard) { + return slice.call(array, n == null || guard ? 1 : n); + } + + // Get the last element of an array. Passing **n** will return the last N + // values in the array. + function last(array, n, guard) { + if (array == null || array.length < 1) return n == null || guard ? void 0 : []; + if (n == null || guard) return array[array.length - 1]; + return rest(array, Math.max(0, array.length - n)); + } + + // Trim out all falsy values from an array. + function compact(array) { + return filter(array, Boolean); + } + + // Flatten out an array, either recursively (by default), or up to `depth`. + // Passing `true` or `false` as `depth` means `1` or `Infinity`, respectively. + function flatten$1(array, depth) { + return flatten(array, depth, false); + } + + // Take the difference between one array and a number of other arrays. + // Only the elements present in just the first array will remain. + var difference = restArguments(function(array, rest) { + rest = flatten(rest, true, true); + return filter(array, function(value){ + return !contains(rest, value); + }); + }); + + // Return a version of the array that does not contain the specified value(s). + var without = restArguments(function(array, otherArrays) { + return difference(array, otherArrays); + }); + + // Produce a duplicate-free version of the array. If the array has already + // been sorted, you have the option of using a faster algorithm. + // The faster algorithm will not work with an iteratee if the iteratee + // is not a one-to-one function, so providing an iteratee will disable + // the faster algorithm. + function uniq(array, isSorted, iteratee, context) { + if (!isBoolean(isSorted)) { + context = iteratee; + iteratee = isSorted; + isSorted = false; + } + if (iteratee != null) iteratee = cb(iteratee, context); + var result = []; + var seen = []; + for (var i = 0, length = getLength(array); i < length; i++) { + var value = array[i], + computed = iteratee ? iteratee(value, i, array) : value; + if (isSorted && !iteratee) { + if (!i || seen !== computed) result.push(value); + seen = computed; + } else if (iteratee) { + if (!contains(seen, computed)) { + seen.push(computed); + result.push(value); + } + } else if (!contains(result, value)) { + result.push(value); + } + } + return result; + } + + // Produce an array that contains the union: each distinct element from all of + // the passed-in arrays. + var union = restArguments(function(arrays) { + return uniq(flatten(arrays, true, true)); + }); + + // Produce an array that contains every item shared between all the + // passed-in arrays. + function intersection(array) { + var result = []; + var argsLength = arguments.length; + for (var i = 0, length = getLength(array); i < length; i++) { + var item = array[i]; + if (contains(result, item)) continue; + var j; + for (j = 1; j < argsLength; j++) { + if (!contains(arguments[j], item)) break; + } + if (j === argsLength) result.push(item); + } + return result; + } + + // Complement of zip. Unzip accepts an array of arrays and groups + // each array's elements on shared indices. + function unzip(array) { + var length = array && max(array, getLength).length || 0; + var result = Array(length); + + for (var index = 0; index < length; index++) { + result[index] = pluck(array, index); + } + return result; + } + + // Zip together multiple lists into a single array -- elements that share + // an index go together. + var zip = restArguments(unzip); + + // Converts lists into objects. Pass either a single array of `[key, value]` + // pairs, or two parallel arrays of the same length -- one of keys, and one of + // the corresponding values. Passing by pairs is the reverse of `_.pairs`. + function object(list, values) { + var result = {}; + for (var i = 0, length = getLength(list); i < length; i++) { + if (values) { + result[list[i]] = values[i]; + } else { + result[list[i][0]] = list[i][1]; + } + } + return result; + } + + // Generate an integer Array containing an arithmetic progression. A port of + // the native Python `range()` function. See + // [the Python documentation](https://docs.python.org/library/functions.html#range). + function range(start, stop, step) { + if (stop == null) { + stop = start || 0; + start = 0; + } + if (!step) { + step = stop < start ? -1 : 1; + } + + var length = Math.max(Math.ceil((stop - start) / step), 0); + var range = Array(length); + + for (var idx = 0; idx < length; idx++, start += step) { + range[idx] = start; + } + + return range; + } + + // Chunk a single array into multiple arrays, each containing `count` or fewer + // items. + function chunk(array, count) { + if (count == null || count < 1) return []; + var result = []; + var i = 0, length = array.length; + while (i < length) { + result.push(slice.call(array, i, i += count)); + } + return result; + } + + // Helper function to continue chaining intermediate results. + function chainResult(instance, obj) { + return instance._chain ? _(obj).chain() : obj; + } + + // Add your own custom functions to the Underscore object. + function mixin(obj) { + each(functions(obj), function(name) { + var func = _[name] = obj[name]; + _.prototype[name] = function() { + var args = [this._wrapped]; + push.apply(args, arguments); + return chainResult(this, func.apply(_, args)); + }; + }); + return _; + } + + // Add all mutator `Array` functions to the wrapper. + each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) { + var method = ArrayProto[name]; + _.prototype[name] = function() { + var obj = this._wrapped; + if (obj != null) { + method.apply(obj, arguments); + if ((name === 'shift' || name === 'splice') && obj.length === 0) { + delete obj[0]; + } + } + return chainResult(this, obj); + }; + }); + + // Add all accessor `Array` functions to the wrapper. + each(['concat', 'join', 'slice'], function(name) { + var method = ArrayProto[name]; + _.prototype[name] = function() { + var obj = this._wrapped; + if (obj != null) obj = method.apply(obj, arguments); + return chainResult(this, obj); + }; + }); + + // Named Exports + + var allExports = { + __proto__: null, + VERSION: VERSION, + restArguments: restArguments, + isObject: isObject, + isNull: isNull, + isUndefined: isUndefined, + isBoolean: isBoolean, + isElement: isElement, + isString: isString, + isNumber: isNumber, + isDate: isDate, + isRegExp: isRegExp, + isError: isError, + isSymbol: isSymbol, + isArrayBuffer: isArrayBuffer, + isDataView: isDataView$1, + isArray: isArray, + isFunction: isFunction$1, + isArguments: isArguments$1, + isFinite: isFinite$1, + isNaN: isNaN$1, + isTypedArray: isTypedArray$1, + isEmpty: isEmpty, + isMatch: isMatch, + isEqual: isEqual, + isMap: isMap, + isWeakMap: isWeakMap, + isSet: isSet, + isWeakSet: isWeakSet, + keys: keys, + allKeys: allKeys, + values: values, + pairs: pairs, + invert: invert, + functions: functions, + methods: functions, + extend: extend, + extendOwn: extendOwn, + assign: extendOwn, + defaults: defaults, + create: create, + clone: clone, + tap: tap, + get: get, + has: has$1, + mapObject: mapObject, + identity: identity, + constant: constant, + noop: noop, + toPath: toPath, + property: property, + propertyOf: propertyOf, + matcher: matcher, + matches: matcher, + times: times, + random: random, + now: now, + escape: _escape, + unescape: _unescape, + templateSettings: templateSettings, + template: template, + result: result, + uniqueId: uniqueId, + chain: chain, + iteratee: iteratee, + partial: partial, + bind: bind, + bindAll: bindAll, + memoize: memoize, + delay: delay, + defer: defer, + throttle: throttle, + debounce: debounce, + wrap: wrap, + negate: negate, + compose: compose, + after: after, + before: before, + once: once, + findKey: findKey, + findIndex: findIndex, + findLastIndex: findLastIndex, + sortedIndex: sortedIndex, + indexOf: indexOf, + lastIndexOf: lastIndexOf, + find: find, + detect: find, + findWhere: findWhere, + each: each, + forEach: each, + map: map, + collect: map, + reduce: reduce, + foldl: reduce, + inject: reduce, + reduceRight: reduceRight, + foldr: reduceRight, + filter: filter, + select: filter, + reject: reject, + every: every, + all: every, + some: some, + any: some, + contains: contains, + includes: contains, + include: contains, + invoke: invoke, + pluck: pluck, + where: where, + max: max, + min: min, + shuffle: shuffle, + sample: sample, + sortBy: sortBy, + groupBy: groupBy, + indexBy: indexBy, + countBy: countBy, + partition: partition, + toArray: toArray, + size: size, + pick: pick, + omit: omit, + first: first, + head: first, + take: first, + initial: initial, + last: last, + rest: rest, + tail: rest, + drop: rest, + compact: compact, + flatten: flatten$1, + without: without, + uniq: uniq, + unique: uniq, + union: union, + intersection: intersection, + difference: difference, + unzip: unzip, + transpose: unzip, + zip: zip, + object: object, + range: range, + chunk: chunk, + mixin: mixin, + 'default': _ + }; + + // Default Export + + // Add all of the Underscore functions to the wrapper object. + var _$1 = mixin(allExports); + // Legacy Node.js API. + _$1._ = _$1; + + return _$1; + +}))); +//# sourceMappingURL=underscore.js.map diff --git a/sparseml/_static/underscore-1.3.1.js b/sparseml/_static/underscore-1.3.1.js deleted file mode 100644 index 208d4cd890c..00000000000 --- a/sparseml/_static/underscore-1.3.1.js +++ /dev/null @@ -1,999 +0,0 @@ -// Underscore.js 1.3.1 -// (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc. -// Underscore is freely distributable under the MIT license. -// Portions of Underscore are inspired or borrowed from Prototype, -// Oliver Steele's Functional, and John Resig's Micro-Templating. -// For all details and documentation: -// http://documentcloud.github.com/underscore - -(function() { - - // Baseline setup - // -------------- - - // Establish the root object, `window` in the browser, or `global` on the server. - var root = this; - - // Save the previous value of the `_` variable. - var previousUnderscore = root._; - - // Establish the object that gets returned to break out of a loop iteration. - var breaker = {}; - - // Save bytes in the minified (but not gzipped) version: - var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype; - - // Create quick reference variables for speed access to core prototypes. - var slice = ArrayProto.slice, - unshift = ArrayProto.unshift, - toString = ObjProto.toString, - hasOwnProperty = ObjProto.hasOwnProperty; - - // All **ECMAScript 5** native function implementations that we hope to use - // are declared here. - var - nativeForEach = ArrayProto.forEach, - nativeMap = ArrayProto.map, - nativeReduce = ArrayProto.reduce, - nativeReduceRight = ArrayProto.reduceRight, - nativeFilter = ArrayProto.filter, - nativeEvery = ArrayProto.every, - nativeSome = ArrayProto.some, - nativeIndexOf = ArrayProto.indexOf, - nativeLastIndexOf = ArrayProto.lastIndexOf, - nativeIsArray = Array.isArray, - nativeKeys = Object.keys, - nativeBind = FuncProto.bind; - - // Create a safe reference to the Underscore object for use below. - var _ = function(obj) { return new wrapper(obj); }; - - // Export the Underscore object for **Node.js**, with - // backwards-compatibility for the old `require()` API. If we're in - // the browser, add `_` as a global object via a string identifier, - // for Closure Compiler "advanced" mode. - if (typeof exports !== 'undefined') { - if (typeof module !== 'undefined' && module.exports) { - exports = module.exports = _; - } - exports._ = _; - } else { - root['_'] = _; - } - - // Current version. - _.VERSION = '1.3.1'; - - // Collection Functions - // -------------------- - - // The cornerstone, an `each` implementation, aka `forEach`. - // Handles objects with the built-in `forEach`, arrays, and raw objects. - // Delegates to **ECMAScript 5**'s native `forEach` if available. - var each = _.each = _.forEach = function(obj, iterator, context) { - if (obj == null) return; - if (nativeForEach && obj.forEach === nativeForEach) { - obj.forEach(iterator, context); - } else if (obj.length === +obj.length) { - for (var i = 0, l = obj.length; i < l; i++) { - if (i in obj && iterator.call(context, obj[i], i, obj) === breaker) return; - } - } else { - for (var key in obj) { - if (_.has(obj, key)) { - if (iterator.call(context, obj[key], key, obj) === breaker) return; - } - } - } - }; - - // Return the results of applying the iterator to each element. - // Delegates to **ECMAScript 5**'s native `map` if available. - _.map = _.collect = function(obj, iterator, context) { - var results = []; - if (obj == null) return results; - if (nativeMap && obj.map === nativeMap) return obj.map(iterator, context); - each(obj, function(value, index, list) { - results[results.length] = iterator.call(context, value, index, list); - }); - if (obj.length === +obj.length) results.length = obj.length; - return results; - }; - - // **Reduce** builds up a single result from a list of values, aka `inject`, - // or `foldl`. Delegates to **ECMAScript 5**'s native `reduce` if available. - _.reduce = _.foldl = _.inject = function(obj, iterator, memo, context) { - var initial = arguments.length > 2; - if (obj == null) obj = []; - if (nativeReduce && obj.reduce === nativeReduce) { - if (context) iterator = _.bind(iterator, context); - return initial ? obj.reduce(iterator, memo) : obj.reduce(iterator); - } - each(obj, function(value, index, list) { - if (!initial) { - memo = value; - initial = true; - } else { - memo = iterator.call(context, memo, value, index, list); - } - }); - if (!initial) throw new TypeError('Reduce of empty array with no initial value'); - return memo; - }; - - // The right-associative version of reduce, also known as `foldr`. - // Delegates to **ECMAScript 5**'s native `reduceRight` if available. - _.reduceRight = _.foldr = function(obj, iterator, memo, context) { - var initial = arguments.length > 2; - if (obj == null) obj = []; - if (nativeReduceRight && obj.reduceRight === nativeReduceRight) { - if (context) iterator = _.bind(iterator, context); - return initial ? obj.reduceRight(iterator, memo) : obj.reduceRight(iterator); - } - var reversed = _.toArray(obj).reverse(); - if (context && !initial) iterator = _.bind(iterator, context); - return initial ? _.reduce(reversed, iterator, memo, context) : _.reduce(reversed, iterator); - }; - - // Return the first value which passes a truth test. Aliased as `detect`. - _.find = _.detect = function(obj, iterator, context) { - var result; - any(obj, function(value, index, list) { - if (iterator.call(context, value, index, list)) { - result = value; - return true; - } - }); - return result; - }; - - // Return all the elements that pass a truth test. - // Delegates to **ECMAScript 5**'s native `filter` if available. - // Aliased as `select`. - _.filter = _.select = function(obj, iterator, context) { - var results = []; - if (obj == null) return results; - if (nativeFilter && obj.filter === nativeFilter) return obj.filter(iterator, context); - each(obj, function(value, index, list) { - if (iterator.call(context, value, index, list)) results[results.length] = value; - }); - return results; - }; - - // Return all the elements for which a truth test fails. - _.reject = function(obj, iterator, context) { - var results = []; - if (obj == null) return results; - each(obj, function(value, index, list) { - if (!iterator.call(context, value, index, list)) results[results.length] = value; - }); - return results; - }; - - // Determine whether all of the elements match a truth test. - // Delegates to **ECMAScript 5**'s native `every` if available. - // Aliased as `all`. - _.every = _.all = function(obj, iterator, context) { - var result = true; - if (obj == null) return result; - if (nativeEvery && obj.every === nativeEvery) return obj.every(iterator, context); - each(obj, function(value, index, list) { - if (!(result = result && iterator.call(context, value, index, list))) return breaker; - }); - return result; - }; - - // Determine if at least one element in the object matches a truth test. - // Delegates to **ECMAScript 5**'s native `some` if available. - // Aliased as `any`. - var any = _.some = _.any = function(obj, iterator, context) { - iterator || (iterator = _.identity); - var result = false; - if (obj == null) return result; - if (nativeSome && obj.some === nativeSome) return obj.some(iterator, context); - each(obj, function(value, index, list) { - if (result || (result = iterator.call(context, value, index, list))) return breaker; - }); - return !!result; - }; - - // Determine if a given value is included in the array or object using `===`. - // Aliased as `contains`. - _.include = _.contains = function(obj, target) { - var found = false; - if (obj == null) return found; - if (nativeIndexOf && obj.indexOf === nativeIndexOf) return obj.indexOf(target) != -1; - found = any(obj, function(value) { - return value === target; - }); - return found; - }; - - // Invoke a method (with arguments) on every item in a collection. - _.invoke = function(obj, method) { - var args = slice.call(arguments, 2); - return _.map(obj, function(value) { - return (_.isFunction(method) ? method || value : value[method]).apply(value, args); - }); - }; - - // Convenience version of a common use case of `map`: fetching a property. - _.pluck = function(obj, key) { - return _.map(obj, function(value){ return value[key]; }); - }; - - // Return the maximum element or (element-based computation). - _.max = function(obj, iterator, context) { - if (!iterator && _.isArray(obj)) return Math.max.apply(Math, obj); - if (!iterator && _.isEmpty(obj)) return -Infinity; - var result = {computed : -Infinity}; - each(obj, function(value, index, list) { - var computed = iterator ? iterator.call(context, value, index, list) : value; - computed >= result.computed && (result = {value : value, computed : computed}); - }); - return result.value; - }; - - // Return the minimum element (or element-based computation). - _.min = function(obj, iterator, context) { - if (!iterator && _.isArray(obj)) return Math.min.apply(Math, obj); - if (!iterator && _.isEmpty(obj)) return Infinity; - var result = {computed : Infinity}; - each(obj, function(value, index, list) { - var computed = iterator ? iterator.call(context, value, index, list) : value; - computed < result.computed && (result = {value : value, computed : computed}); - }); - return result.value; - }; - - // Shuffle an array. - _.shuffle = function(obj) { - var shuffled = [], rand; - each(obj, function(value, index, list) { - if (index == 0) { - shuffled[0] = value; - } else { - rand = Math.floor(Math.random() * (index + 1)); - shuffled[index] = shuffled[rand]; - shuffled[rand] = value; - } - }); - return shuffled; - }; - - // Sort the object's values by a criterion produced by an iterator. - _.sortBy = function(obj, iterator, context) { - return _.pluck(_.map(obj, function(value, index, list) { - return { - value : value, - criteria : iterator.call(context, value, index, list) - }; - }).sort(function(left, right) { - var a = left.criteria, b = right.criteria; - return a < b ? -1 : a > b ? 1 : 0; - }), 'value'); - }; - - // Groups the object's values by a criterion. Pass either a string attribute - // to group by, or a function that returns the criterion. - _.groupBy = function(obj, val) { - var result = {}; - var iterator = _.isFunction(val) ? val : function(obj) { return obj[val]; }; - each(obj, function(value, index) { - var key = iterator(value, index); - (result[key] || (result[key] = [])).push(value); - }); - return result; - }; - - // Use a comparator function to figure out at what index an object should - // be inserted so as to maintain order. Uses binary search. - _.sortedIndex = function(array, obj, iterator) { - iterator || (iterator = _.identity); - var low = 0, high = array.length; - while (low < high) { - var mid = (low + high) >> 1; - iterator(array[mid]) < iterator(obj) ? low = mid + 1 : high = mid; - } - return low; - }; - - // Safely convert anything iterable into a real, live array. - _.toArray = function(iterable) { - if (!iterable) return []; - if (iterable.toArray) return iterable.toArray(); - if (_.isArray(iterable)) return slice.call(iterable); - if (_.isArguments(iterable)) return slice.call(iterable); - return _.values(iterable); - }; - - // Return the number of elements in an object. - _.size = function(obj) { - return _.toArray(obj).length; - }; - - // Array Functions - // --------------- - - // Get the first element of an array. Passing **n** will return the first N - // values in the array. Aliased as `head`. The **guard** check allows it to work - // with `_.map`. - _.first = _.head = function(array, n, guard) { - return (n != null) && !guard ? slice.call(array, 0, n) : array[0]; - }; - - // Returns everything but the last entry of the array. Especcialy useful on - // the arguments object. Passing **n** will return all the values in - // the array, excluding the last N. The **guard** check allows it to work with - // `_.map`. - _.initial = function(array, n, guard) { - return slice.call(array, 0, array.length - ((n == null) || guard ? 1 : n)); - }; - - // Get the last element of an array. Passing **n** will return the last N - // values in the array. The **guard** check allows it to work with `_.map`. - _.last = function(array, n, guard) { - if ((n != null) && !guard) { - return slice.call(array, Math.max(array.length - n, 0)); - } else { - return array[array.length - 1]; - } - }; - - // Returns everything but the first entry of the array. Aliased as `tail`. - // Especially useful on the arguments object. Passing an **index** will return - // the rest of the values in the array from that index onward. The **guard** - // check allows it to work with `_.map`. - _.rest = _.tail = function(array, index, guard) { - return slice.call(array, (index == null) || guard ? 1 : index); - }; - - // Trim out all falsy values from an array. - _.compact = function(array) { - return _.filter(array, function(value){ return !!value; }); - }; - - // Return a completely flattened version of an array. - _.flatten = function(array, shallow) { - return _.reduce(array, function(memo, value) { - if (_.isArray(value)) return memo.concat(shallow ? value : _.flatten(value)); - memo[memo.length] = value; - return memo; - }, []); - }; - - // Return a version of the array that does not contain the specified value(s). - _.without = function(array) { - return _.difference(array, slice.call(arguments, 1)); - }; - - // Produce a duplicate-free version of the array. If the array has already - // been sorted, you have the option of using a faster algorithm. - // Aliased as `unique`. - _.uniq = _.unique = function(array, isSorted, iterator) { - var initial = iterator ? _.map(array, iterator) : array; - var result = []; - _.reduce(initial, function(memo, el, i) { - if (0 == i || (isSorted === true ? _.last(memo) != el : !_.include(memo, el))) { - memo[memo.length] = el; - result[result.length] = array[i]; - } - return memo; - }, []); - return result; - }; - - // Produce an array that contains the union: each distinct element from all of - // the passed-in arrays. - _.union = function() { - return _.uniq(_.flatten(arguments, true)); - }; - - // Produce an array that contains every item shared between all the - // passed-in arrays. (Aliased as "intersect" for back-compat.) - _.intersection = _.intersect = function(array) { - var rest = slice.call(arguments, 1); - return _.filter(_.uniq(array), function(item) { - return _.every(rest, function(other) { - return _.indexOf(other, item) >= 0; - }); - }); - }; - - // Take the difference between one array and a number of other arrays. - // Only the elements present in just the first array will remain. - _.difference = function(array) { - var rest = _.flatten(slice.call(arguments, 1)); - return _.filter(array, function(value){ return !_.include(rest, value); }); - }; - - // Zip together multiple lists into a single array -- elements that share - // an index go together. - _.zip = function() { - var args = slice.call(arguments); - var length = _.max(_.pluck(args, 'length')); - var results = new Array(length); - for (var i = 0; i < length; i++) results[i] = _.pluck(args, "" + i); - return results; - }; - - // If the browser doesn't supply us with indexOf (I'm looking at you, **MSIE**), - // we need this function. Return the position of the first occurrence of an - // item in an array, or -1 if the item is not included in the array. - // Delegates to **ECMAScript 5**'s native `indexOf` if available. - // If the array is large and already in sort order, pass `true` - // for **isSorted** to use binary search. - _.indexOf = function(array, item, isSorted) { - if (array == null) return -1; - var i, l; - if (isSorted) { - i = _.sortedIndex(array, item); - return array[i] === item ? i : -1; - } - if (nativeIndexOf && array.indexOf === nativeIndexOf) return array.indexOf(item); - for (i = 0, l = array.length; i < l; i++) if (i in array && array[i] === item) return i; - return -1; - }; - - // Delegates to **ECMAScript 5**'s native `lastIndexOf` if available. - _.lastIndexOf = function(array, item) { - if (array == null) return -1; - if (nativeLastIndexOf && array.lastIndexOf === nativeLastIndexOf) return array.lastIndexOf(item); - var i = array.length; - while (i--) if (i in array && array[i] === item) return i; - return -1; - }; - - // Generate an integer Array containing an arithmetic progression. A port of - // the native Python `range()` function. See - // [the Python documentation](http://docs.python.org/library/functions.html#range). - _.range = function(start, stop, step) { - if (arguments.length <= 1) { - stop = start || 0; - start = 0; - } - step = arguments[2] || 1; - - var len = Math.max(Math.ceil((stop - start) / step), 0); - var idx = 0; - var range = new Array(len); - - while(idx < len) { - range[idx++] = start; - start += step; - } - - return range; - }; - - // Function (ahem) Functions - // ------------------ - - // Reusable constructor function for prototype setting. - var ctor = function(){}; - - // Create a function bound to a given object (assigning `this`, and arguments, - // optionally). Binding with arguments is also known as `curry`. - // Delegates to **ECMAScript 5**'s native `Function.bind` if available. - // We check for `func.bind` first, to fail fast when `func` is undefined. - _.bind = function bind(func, context) { - var bound, args; - if (func.bind === nativeBind && nativeBind) return nativeBind.apply(func, slice.call(arguments, 1)); - if (!_.isFunction(func)) throw new TypeError; - args = slice.call(arguments, 2); - return bound = function() { - if (!(this instanceof bound)) return func.apply(context, args.concat(slice.call(arguments))); - ctor.prototype = func.prototype; - var self = new ctor; - var result = func.apply(self, args.concat(slice.call(arguments))); - if (Object(result) === result) return result; - return self; - }; - }; - - // Bind all of an object's methods to that object. Useful for ensuring that - // all callbacks defined on an object belong to it. - _.bindAll = function(obj) { - var funcs = slice.call(arguments, 1); - if (funcs.length == 0) funcs = _.functions(obj); - each(funcs, function(f) { obj[f] = _.bind(obj[f], obj); }); - return obj; - }; - - // Memoize an expensive function by storing its results. - _.memoize = function(func, hasher) { - var memo = {}; - hasher || (hasher = _.identity); - return function() { - var key = hasher.apply(this, arguments); - return _.has(memo, key) ? memo[key] : (memo[key] = func.apply(this, arguments)); - }; - }; - - // Delays a function for the given number of milliseconds, and then calls - // it with the arguments supplied. - _.delay = function(func, wait) { - var args = slice.call(arguments, 2); - return setTimeout(function(){ return func.apply(func, args); }, wait); - }; - - // Defers a function, scheduling it to run after the current call stack has - // cleared. - _.defer = function(func) { - return _.delay.apply(_, [func, 1].concat(slice.call(arguments, 1))); - }; - - // Returns a function, that, when invoked, will only be triggered at most once - // during a given window of time. - _.throttle = function(func, wait) { - var context, args, timeout, throttling, more; - var whenDone = _.debounce(function(){ more = throttling = false; }, wait); - return function() { - context = this; args = arguments; - var later = function() { - timeout = null; - if (more) func.apply(context, args); - whenDone(); - }; - if (!timeout) timeout = setTimeout(later, wait); - if (throttling) { - more = true; - } else { - func.apply(context, args); - } - whenDone(); - throttling = true; - }; - }; - - // Returns a function, that, as long as it continues to be invoked, will not - // be triggered. The function will be called after it stops being called for - // N milliseconds. - _.debounce = function(func, wait) { - var timeout; - return function() { - var context = this, args = arguments; - var later = function() { - timeout = null; - func.apply(context, args); - }; - clearTimeout(timeout); - timeout = setTimeout(later, wait); - }; - }; - - // Returns a function that will be executed at most one time, no matter how - // often you call it. Useful for lazy initialization. - _.once = function(func) { - var ran = false, memo; - return function() { - if (ran) return memo; - ran = true; - return memo = func.apply(this, arguments); - }; - }; - - // Returns the first function passed as an argument to the second, - // allowing you to adjust arguments, run code before and after, and - // conditionally execute the original function. - _.wrap = function(func, wrapper) { - return function() { - var args = [func].concat(slice.call(arguments, 0)); - return wrapper.apply(this, args); - }; - }; - - // Returns a function that is the composition of a list of functions, each - // consuming the return value of the function that follows. - _.compose = function() { - var funcs = arguments; - return function() { - var args = arguments; - for (var i = funcs.length - 1; i >= 0; i--) { - args = [funcs[i].apply(this, args)]; - } - return args[0]; - }; - }; - - // Returns a function that will only be executed after being called N times. - _.after = function(times, func) { - if (times <= 0) return func(); - return function() { - if (--times < 1) { return func.apply(this, arguments); } - }; - }; - - // Object Functions - // ---------------- - - // Retrieve the names of an object's properties. - // Delegates to **ECMAScript 5**'s native `Object.keys` - _.keys = nativeKeys || function(obj) { - if (obj !== Object(obj)) throw new TypeError('Invalid object'); - var keys = []; - for (var key in obj) if (_.has(obj, key)) keys[keys.length] = key; - return keys; - }; - - // Retrieve the values of an object's properties. - _.values = function(obj) { - return _.map(obj, _.identity); - }; - - // Return a sorted list of the function names available on the object. - // Aliased as `methods` - _.functions = _.methods = function(obj) { - var names = []; - for (var key in obj) { - if (_.isFunction(obj[key])) names.push(key); - } - return names.sort(); - }; - - // Extend a given object with all the properties in passed-in object(s). - _.extend = function(obj) { - each(slice.call(arguments, 1), function(source) { - for (var prop in source) { - obj[prop] = source[prop]; - } - }); - return obj; - }; - - // Fill in a given object with default properties. - _.defaults = function(obj) { - each(slice.call(arguments, 1), function(source) { - for (var prop in source) { - if (obj[prop] == null) obj[prop] = source[prop]; - } - }); - return obj; - }; - - // Create a (shallow-cloned) duplicate of an object. - _.clone = function(obj) { - if (!_.isObject(obj)) return obj; - return _.isArray(obj) ? obj.slice() : _.extend({}, obj); - }; - - // Invokes interceptor with the obj, and then returns obj. - // The primary purpose of this method is to "tap into" a method chain, in - // order to perform operations on intermediate results within the chain. - _.tap = function(obj, interceptor) { - interceptor(obj); - return obj; - }; - - // Internal recursive comparison function. - function eq(a, b, stack) { - // Identical objects are equal. `0 === -0`, but they aren't identical. - // See the Harmony `egal` proposal: http://wiki.ecmascript.org/doku.php?id=harmony:egal. - if (a === b) return a !== 0 || 1 / a == 1 / b; - // A strict comparison is necessary because `null == undefined`. - if (a == null || b == null) return a === b; - // Unwrap any wrapped objects. - if (a._chain) a = a._wrapped; - if (b._chain) b = b._wrapped; - // Invoke a custom `isEqual` method if one is provided. - if (a.isEqual && _.isFunction(a.isEqual)) return a.isEqual(b); - if (b.isEqual && _.isFunction(b.isEqual)) return b.isEqual(a); - // Compare `[[Class]]` names. - var className = toString.call(a); - if (className != toString.call(b)) return false; - switch (className) { - // Strings, numbers, dates, and booleans are compared by value. - case '[object String]': - // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is - // equivalent to `new String("5")`. - return a == String(b); - case '[object Number]': - // `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for - // other numeric values. - return a != +a ? b != +b : (a == 0 ? 1 / a == 1 / b : a == +b); - case '[object Date]': - case '[object Boolean]': - // Coerce dates and booleans to numeric primitive values. Dates are compared by their - // millisecond representations. Note that invalid dates with millisecond representations - // of `NaN` are not equivalent. - return +a == +b; - // RegExps are compared by their source patterns and flags. - case '[object RegExp]': - return a.source == b.source && - a.global == b.global && - a.multiline == b.multiline && - a.ignoreCase == b.ignoreCase; - } - if (typeof a != 'object' || typeof b != 'object') return false; - // Assume equality for cyclic structures. The algorithm for detecting cyclic - // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`. - var length = stack.length; - while (length--) { - // Linear search. Performance is inversely proportional to the number of - // unique nested structures. - if (stack[length] == a) return true; - } - // Add the first object to the stack of traversed objects. - stack.push(a); - var size = 0, result = true; - // Recursively compare objects and arrays. - if (className == '[object Array]') { - // Compare array lengths to determine if a deep comparison is necessary. - size = a.length; - result = size == b.length; - if (result) { - // Deep compare the contents, ignoring non-numeric properties. - while (size--) { - // Ensure commutative equality for sparse arrays. - if (!(result = size in a == size in b && eq(a[size], b[size], stack))) break; - } - } - } else { - // Objects with different constructors are not equivalent. - if ('constructor' in a != 'constructor' in b || a.constructor != b.constructor) return false; - // Deep compare objects. - for (var key in a) { - if (_.has(a, key)) { - // Count the expected number of properties. - size++; - // Deep compare each member. - if (!(result = _.has(b, key) && eq(a[key], b[key], stack))) break; - } - } - // Ensure that both objects contain the same number of properties. - if (result) { - for (key in b) { - if (_.has(b, key) && !(size--)) break; - } - result = !size; - } - } - // Remove the first object from the stack of traversed objects. - stack.pop(); - return result; - } - - // Perform a deep comparison to check if two objects are equal. - _.isEqual = function(a, b) { - return eq(a, b, []); - }; - - // Is a given array, string, or object empty? - // An "empty" object has no enumerable own-properties. - _.isEmpty = function(obj) { - if (_.isArray(obj) || _.isString(obj)) return obj.length === 0; - for (var key in obj) if (_.has(obj, key)) return false; - return true; - }; - - // Is a given value a DOM element? - _.isElement = function(obj) { - return !!(obj && obj.nodeType == 1); - }; - - // Is a given value an array? - // Delegates to ECMA5's native Array.isArray - _.isArray = nativeIsArray || function(obj) { - return toString.call(obj) == '[object Array]'; - }; - - // Is a given variable an object? - _.isObject = function(obj) { - return obj === Object(obj); - }; - - // Is a given variable an arguments object? - _.isArguments = function(obj) { - return toString.call(obj) == '[object Arguments]'; - }; - if (!_.isArguments(arguments)) { - _.isArguments = function(obj) { - return !!(obj && _.has(obj, 'callee')); - }; - } - - // Is a given value a function? - _.isFunction = function(obj) { - return toString.call(obj) == '[object Function]'; - }; - - // Is a given value a string? - _.isString = function(obj) { - return toString.call(obj) == '[object String]'; - }; - - // Is a given value a number? - _.isNumber = function(obj) { - return toString.call(obj) == '[object Number]'; - }; - - // Is the given value `NaN`? - _.isNaN = function(obj) { - // `NaN` is the only value for which `===` is not reflexive. - return obj !== obj; - }; - - // Is a given value a boolean? - _.isBoolean = function(obj) { - return obj === true || obj === false || toString.call(obj) == '[object Boolean]'; - }; - - // Is a given value a date? - _.isDate = function(obj) { - return toString.call(obj) == '[object Date]'; - }; - - // Is the given value a regular expression? - _.isRegExp = function(obj) { - return toString.call(obj) == '[object RegExp]'; - }; - - // Is a given value equal to null? - _.isNull = function(obj) { - return obj === null; - }; - - // Is a given variable undefined? - _.isUndefined = function(obj) { - return obj === void 0; - }; - - // Has own property? - _.has = function(obj, key) { - return hasOwnProperty.call(obj, key); - }; - - // Utility Functions - // ----------------- - - // Run Underscore.js in *noConflict* mode, returning the `_` variable to its - // previous owner. Returns a reference to the Underscore object. - _.noConflict = function() { - root._ = previousUnderscore; - return this; - }; - - // Keep the identity function around for default iterators. - _.identity = function(value) { - return value; - }; - - // Run a function **n** times. - _.times = function (n, iterator, context) { - for (var i = 0; i < n; i++) iterator.call(context, i); - }; - - // Escape a string for HTML interpolation. - _.escape = function(string) { - return (''+string).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, ''').replace(/\//g,'/'); - }; - - // Add your own custom functions to the Underscore object, ensuring that - // they're correctly added to the OOP wrapper as well. - _.mixin = function(obj) { - each(_.functions(obj), function(name){ - addToWrapper(name, _[name] = obj[name]); - }); - }; - - // Generate a unique integer id (unique within the entire client session). - // Useful for temporary DOM ids. - var idCounter = 0; - _.uniqueId = function(prefix) { - var id = idCounter++; - return prefix ? prefix + id : id; - }; - - // By default, Underscore uses ERB-style template delimiters, change the - // following template settings to use alternative delimiters. - _.templateSettings = { - evaluate : /<%([\s\S]+?)%>/g, - interpolate : /<%=([\s\S]+?)%>/g, - escape : /<%-([\s\S]+?)%>/g - }; - - // When customizing `templateSettings`, if you don't want to define an - // interpolation, evaluation or escaping regex, we need one that is - // guaranteed not to match. - var noMatch = /.^/; - - // Within an interpolation, evaluation, or escaping, remove HTML escaping - // that had been previously added. - var unescape = function(code) { - return code.replace(/\\\\/g, '\\').replace(/\\'/g, "'"); - }; - - // JavaScript micro-templating, similar to John Resig's implementation. - // Underscore templating handles arbitrary delimiters, preserves whitespace, - // and correctly escapes quotes within interpolated code. - _.template = function(str, data) { - var c = _.templateSettings; - var tmpl = 'var __p=[],print=function(){__p.push.apply(__p,arguments);};' + - 'with(obj||{}){__p.push(\'' + - str.replace(/\\/g, '\\\\') - .replace(/'/g, "\\'") - .replace(c.escape || noMatch, function(match, code) { - return "',_.escape(" + unescape(code) + "),'"; - }) - .replace(c.interpolate || noMatch, function(match, code) { - return "'," + unescape(code) + ",'"; - }) - .replace(c.evaluate || noMatch, function(match, code) { - return "');" + unescape(code).replace(/[\r\n\t]/g, ' ') + ";__p.push('"; - }) - .replace(/\r/g, '\\r') - .replace(/\n/g, '\\n') - .replace(/\t/g, '\\t') - + "');}return __p.join('');"; - var func = new Function('obj', '_', tmpl); - if (data) return func(data, _); - return function(data) { - return func.call(this, data, _); - }; - }; - - // Add a "chain" function, which will delegate to the wrapper. - _.chain = function(obj) { - return _(obj).chain(); - }; - - // The OOP Wrapper - // --------------- - - // If Underscore is called as a function, it returns a wrapped object that - // can be used OO-style. This wrapper holds altered versions of all the - // underscore functions. Wrapped objects may be chained. - var wrapper = function(obj) { this._wrapped = obj; }; - - // Expose `wrapper.prototype` as `_.prototype` - _.prototype = wrapper.prototype; - - // Helper function to continue chaining intermediate results. - var result = function(obj, chain) { - return chain ? _(obj).chain() : obj; - }; - - // A method to easily add functions to the OOP wrapper. - var addToWrapper = function(name, func) { - wrapper.prototype[name] = function() { - var args = slice.call(arguments); - unshift.call(args, this._wrapped); - return result(func.apply(_, args), this._chain); - }; - }; - - // Add all of the Underscore functions to the wrapper object. - _.mixin(_); - - // Add all mutator Array functions to the wrapper. - each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) { - var method = ArrayProto[name]; - wrapper.prototype[name] = function() { - var wrapped = this._wrapped; - method.apply(wrapped, arguments); - var length = wrapped.length; - if ((name == 'shift' || name == 'splice') && length === 0) delete wrapped[0]; - return result(wrapped, this._chain); - }; - }); - - // Add all accessor Array functions to the wrapper. - each(['concat', 'join', 'slice'], function(name) { - var method = ArrayProto[name]; - wrapper.prototype[name] = function() { - return result(method.apply(this._wrapped, arguments), this._chain); - }; - }); - - // Start chaining a wrapped Underscore object. - wrapper.prototype.chain = function() { - this._chain = true; - return this; - }; - - // Extracts the result from a wrapped and chained object. - wrapper.prototype.value = function() { - return this._wrapped; - }; - -}).call(this); diff --git a/sparseml/_static/underscore.js b/sparseml/_static/underscore.js index 5b55f32beac..166240ef2dd 100644 --- a/sparseml/_static/underscore.js +++ b/sparseml/_static/underscore.js @@ -1,31 +1,6 @@ -// Underscore.js 1.3.1 -// (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc. -// Underscore is freely distributable under the MIT license. -// Portions of Underscore are inspired or borrowed from Prototype, -// Oliver Steele's Functional, and John Resig's Micro-Templating. -// For all details and documentation: -// http://documentcloud.github.com/underscore -(function(){function q(a,c,d){if(a===c)return a!==0||1/a==1/c;if(a==null||c==null)return a===c;if(a._chain)a=a._wrapped;if(c._chain)c=c._wrapped;if(a.isEqual&&b.isFunction(a.isEqual))return a.isEqual(c);if(c.isEqual&&b.isFunction(c.isEqual))return c.isEqual(a);var e=l.call(a);if(e!=l.call(c))return false;switch(e){case "[object String]":return a==String(c);case "[object Number]":return a!=+a?c!=+c:a==0?1/a==1/c:a==+c;case "[object Date]":case "[object Boolean]":return+a==+c;case "[object RegExp]":return a.source== -c.source&&a.global==c.global&&a.multiline==c.multiline&&a.ignoreCase==c.ignoreCase}if(typeof a!="object"||typeof c!="object")return false;for(var f=d.length;f--;)if(d[f]==a)return true;d.push(a);var f=0,g=true;if(e=="[object Array]"){if(f=a.length,g=f==c.length)for(;f--;)if(!(g=f in a==f in c&&q(a[f],c[f],d)))break}else{if("constructor"in a!="constructor"in c||a.constructor!=c.constructor)return false;for(var h in a)if(b.has(a,h)&&(f++,!(g=b.has(c,h)&&q(a[h],c[h],d))))break;if(g){for(h in c)if(b.has(c, -h)&&!f--)break;g=!f}}d.pop();return g}var r=this,G=r._,n={},k=Array.prototype,o=Object.prototype,i=k.slice,H=k.unshift,l=o.toString,I=o.hasOwnProperty,w=k.forEach,x=k.map,y=k.reduce,z=k.reduceRight,A=k.filter,B=k.every,C=k.some,p=k.indexOf,D=k.lastIndexOf,o=Array.isArray,J=Object.keys,s=Function.prototype.bind,b=function(a){return new m(a)};if(typeof exports!=="undefined"){if(typeof module!=="undefined"&&module.exports)exports=module.exports=b;exports._=b}else r._=b;b.VERSION="1.3.1";var j=b.each= -b.forEach=function(a,c,d){if(a!=null)if(w&&a.forEach===w)a.forEach(c,d);else if(a.length===+a.length)for(var e=0,f=a.length;e2;a== -null&&(a=[]);if(y&&a.reduce===y)return e&&(c=b.bind(c,e)),f?a.reduce(c,d):a.reduce(c);j(a,function(a,b,i){f?d=c.call(e,d,a,b,i):(d=a,f=true)});if(!f)throw new TypeError("Reduce of empty array with no initial value");return d};b.reduceRight=b.foldr=function(a,c,d,e){var f=arguments.length>2;a==null&&(a=[]);if(z&&a.reduceRight===z)return e&&(c=b.bind(c,e)),f?a.reduceRight(c,d):a.reduceRight(c);var g=b.toArray(a).reverse();e&&!f&&(c=b.bind(c,e));return f?b.reduce(g,c,d,e):b.reduce(g,c)};b.find=b.detect= -function(a,c,b){var e;E(a,function(a,g,h){if(c.call(b,a,g,h))return e=a,true});return e};b.filter=b.select=function(a,c,b){var e=[];if(a==null)return e;if(A&&a.filter===A)return a.filter(c,b);j(a,function(a,g,h){c.call(b,a,g,h)&&(e[e.length]=a)});return e};b.reject=function(a,c,b){var e=[];if(a==null)return e;j(a,function(a,g,h){c.call(b,a,g,h)||(e[e.length]=a)});return e};b.every=b.all=function(a,c,b){var e=true;if(a==null)return e;if(B&&a.every===B)return a.every(c,b);j(a,function(a,g,h){if(!(e= -e&&c.call(b,a,g,h)))return n});return e};var E=b.some=b.any=function(a,c,d){c||(c=b.identity);var e=false;if(a==null)return e;if(C&&a.some===C)return a.some(c,d);j(a,function(a,b,h){if(e||(e=c.call(d,a,b,h)))return n});return!!e};b.include=b.contains=function(a,c){var b=false;if(a==null)return b;return p&&a.indexOf===p?a.indexOf(c)!=-1:b=E(a,function(a){return a===c})};b.invoke=function(a,c){var d=i.call(arguments,2);return b.map(a,function(a){return(b.isFunction(c)?c||a:a[c]).apply(a,d)})};b.pluck= -function(a,c){return b.map(a,function(a){return a[c]})};b.max=function(a,c,d){if(!c&&b.isArray(a))return Math.max.apply(Math,a);if(!c&&b.isEmpty(a))return-Infinity;var e={computed:-Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b>=e.computed&&(e={value:a,computed:b})});return e.value};b.min=function(a,c,d){if(!c&&b.isArray(a))return Math.min.apply(Math,a);if(!c&&b.isEmpty(a))return Infinity;var e={computed:Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;bd?1:0}),"value")};b.groupBy=function(a,c){var d={},e=b.isFunction(c)?c:function(a){return a[c]};j(a,function(a,b){var c=e(a,b);(d[c]||(d[c]=[])).push(a)});return d};b.sortedIndex=function(a, -c,d){d||(d=b.identity);for(var e=0,f=a.length;e>1;d(a[g])=0})})};b.difference=function(a){var c=b.flatten(i.call(arguments,1));return b.filter(a,function(a){return!b.include(c,a)})};b.zip=function(){for(var a=i.call(arguments),c=b.max(b.pluck(a,"length")),d=Array(c),e=0;e=0;d--)b=[a[d].apply(this,b)];return b[0]}}; -b.after=function(a,b){return a<=0?b():function(){if(--a<1)return b.apply(this,arguments)}};b.keys=J||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var c=[],d;for(d in a)b.has(a,d)&&(c[c.length]=d);return c};b.values=function(a){return b.map(a,b.identity)};b.functions=b.methods=function(a){var c=[],d;for(d in a)b.isFunction(a[d])&&c.push(d);return c.sort()};b.extend=function(a){j(i.call(arguments,1),function(b){for(var d in b)a[d]=b[d]});return a};b.defaults=function(a){j(i.call(arguments, -1),function(b){for(var d in b)a[d]==null&&(a[d]=b[d])});return a};b.clone=function(a){return!b.isObject(a)?a:b.isArray(a)?a.slice():b.extend({},a)};b.tap=function(a,b){b(a);return a};b.isEqual=function(a,b){return q(a,b,[])};b.isEmpty=function(a){if(b.isArray(a)||b.isString(a))return a.length===0;for(var c in a)if(b.has(a,c))return false;return true};b.isElement=function(a){return!!(a&&a.nodeType==1)};b.isArray=o||function(a){return l.call(a)=="[object Array]"};b.isObject=function(a){return a===Object(a)}; -b.isArguments=function(a){return l.call(a)=="[object Arguments]"};if(!b.isArguments(arguments))b.isArguments=function(a){return!(!a||!b.has(a,"callee"))};b.isFunction=function(a){return l.call(a)=="[object Function]"};b.isString=function(a){return l.call(a)=="[object String]"};b.isNumber=function(a){return l.call(a)=="[object Number]"};b.isNaN=function(a){return a!==a};b.isBoolean=function(a){return a===true||a===false||l.call(a)=="[object Boolean]"};b.isDate=function(a){return l.call(a)=="[object Date]"}; -b.isRegExp=function(a){return l.call(a)=="[object RegExp]"};b.isNull=function(a){return a===null};b.isUndefined=function(a){return a===void 0};b.has=function(a,b){return I.call(a,b)};b.noConflict=function(){r._=G;return this};b.identity=function(a){return a};b.times=function(a,b,d){for(var e=0;e/g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")};b.mixin=function(a){j(b.functions(a), -function(c){K(c,b[c]=a[c])})};var L=0;b.uniqueId=function(a){var b=L++;return a?a+b:b};b.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var t=/.^/,u=function(a){return a.replace(/\\\\/g,"\\").replace(/\\'/g,"'")};b.template=function(a,c){var d=b.templateSettings,d="var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('"+a.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(d.escape||t,function(a,b){return"',_.escape("+ -u(b)+"),'"}).replace(d.interpolate||t,function(a,b){return"',"+u(b)+",'"}).replace(d.evaluate||t,function(a,b){return"');"+u(b).replace(/[\r\n\t]/g," ")+";__p.push('"}).replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t")+"');}return __p.join('');",e=new Function("obj","_",d);return c?e(c,b):function(a){return e.call(this,a,b)}};b.chain=function(a){return b(a).chain()};var m=function(a){this._wrapped=a};b.prototype=m.prototype;var v=function(a,c){return c?b(a).chain():a},K=function(a,c){m.prototype[a]= -function(){var a=i.call(arguments);H.call(a,this._wrapped);return v(c.apply(b,a),this._chain)}};b.mixin(b);j("pop,push,reverse,shift,sort,splice,unshift".split(","),function(a){var b=k[a];m.prototype[a]=function(){var d=this._wrapped;b.apply(d,arguments);var e=d.length;(a=="shift"||a=="splice")&&e===0&&delete d[0];return v(d,this._chain)}});j(["concat","join","slice"],function(a){var b=k[a];m.prototype[a]=function(){return v(b.apply(this._wrapped,arguments),this._chain)}});m.prototype.chain=function(){this._chain= -true;return this};m.prototype.value=function(){return this._wrapped}}).call(this); +!function(n,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define("underscore",r):(n=n||self,function(){var t=n._,e=n._=r();e.noConflict=function(){return n._=t,e}}())}(this,(function(){ +// Underscore.js 1.12.0 +// https://underscorejs.org +// (c) 2009-2020 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors +// Underscore may be freely distributed under the MIT license. +var n="1.12.0",r="object"==typeof self&&self.self===self&&self||"object"==typeof global&&global.global===global&&global||Function("return this")()||{},t=Array.prototype,e=Object.prototype,u="undefined"!=typeof Symbol?Symbol.prototype:null,o=t.push,i=t.slice,a=e.toString,f=e.hasOwnProperty,c="undefined"!=typeof ArrayBuffer,l="undefined"!=typeof DataView,s=Array.isArray,p=Object.keys,v=Object.create,h=c&&ArrayBuffer.isView,y=isNaN,g=isFinite,d=!{toString:null}.propertyIsEnumerable("toString"),b=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],m=Math.pow(2,53)-1;function j(n,r){return r=null==r?n.length-1:+r,function(){for(var t=Math.max(arguments.length-r,0),e=Array(t),u=0;u=0&&t<=m}}function $(n){return function(r){return null==r?void 0:r[n]}}var G=$("byteLength"),H=J(G),Q=/\[object ((I|Ui)nt(8|16|32)|Float(32|64)|Uint8Clamped|Big(I|Ui)nt64)Array\]/;var X=c?function(n){return h?h(n)&&!q(n):H(n)&&Q.test(a.call(n))}:K(!1),Y=$("length");function Z(n,r){r=function(n){for(var r={},t=n.length,e=0;e":">",'"':""","'":"'","`":"`"},Kn=Ln(Cn),Jn=Ln(_n(Cn)),$n=tn.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g},Gn=/(.)^/,Hn={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},Qn=/\\|'|\r|\n|\u2028|\u2029/g;function Xn(n){return"\\"+Hn[n]}var Yn=0;function Zn(n,r,t,e,u){if(!(e instanceof r))return n.apply(t,u);var o=Mn(n.prototype),i=n.apply(o,u);return _(i)?i:o}var nr=j((function(n,r){var t=nr.placeholder,e=function(){for(var u=0,o=r.length,i=Array(o),a=0;a1)er(a,r-1,t,e),u=e.length;else for(var f=0,c=a.length;f0&&(t=r.apply(this,arguments)),n<=1&&(r=null),t}}var cr=nr(fr,2);function lr(n,r,t){r=qn(r,t);for(var e,u=nn(n),o=0,i=u.length;o0?0:u-1;o>=0&&o0?a=o>=0?o:Math.max(o+f,a):f=o>=0?Math.min(o+1,f):o+f+1;else if(t&&o&&f)return e[o=t(e,u)]===u?o:-1;if(u!=u)return(o=r(i.call(e,a,f),C))>=0?o+a:-1;for(o=n>0?a:f-1;o>=0&&o0?0:i-1;for(u||(e=r[o?o[a]:a],a+=n);a>=0&&a=3;return r(n,Fn(t,u,4),e,o)}}var wr=_r(1),Ar=_r(-1);function xr(n,r,t){var e=[];return r=qn(r,t),mr(n,(function(n,t,u){r(n,t,u)&&e.push(n)})),e}function Sr(n,r,t){r=qn(r,t);for(var e=!tr(n)&&nn(n),u=(e||n).length,o=0;o=0}var Er=j((function(n,r,t){var e,u;return D(r)?u=r:(r=Nn(r),e=r.slice(0,-1),r=r[r.length-1]),jr(n,(function(n){var o=u;if(!o){if(e&&e.length&&(n=In(n,e)),null==n)return;o=n[r]}return null==o?o:o.apply(n,t)}))}));function Br(n,r){return jr(n,Rn(r))}function Nr(n,r,t){var e,u,o=-1/0,i=-1/0;if(null==r||"number"==typeof r&&"object"!=typeof n[0]&&null!=n)for(var a=0,f=(n=tr(n)?n:jn(n)).length;ao&&(o=e);else r=qn(r,t),mr(n,(function(n,t,e){((u=r(n,t,e))>i||u===-1/0&&o===-1/0)&&(o=n,i=u)}));return o}function Ir(n,r,t){if(null==r||t)return tr(n)||(n=jn(n)),n[Wn(n.length-1)];var e=tr(n)?En(n):jn(n),u=Y(e);r=Math.max(Math.min(r,u),0);for(var o=u-1,i=0;i1&&(e=Fn(e,r[1])),r=an(n)):(e=Pr,r=er(r,!1,!1),n=Object(n));for(var u=0,o=r.length;u1&&(t=r[1])):(r=jr(er(r,!1,!1),String),e=function(n,t){return!Mr(r,t)}),qr(n,e,t)}));function Wr(n,r,t){return i.call(n,0,Math.max(0,n.length-(null==r||t?1:r)))}function zr(n,r,t){return null==n||n.length<1?null==r||t?void 0:[]:null==r||t?n[0]:Wr(n,n.length-r)}function Lr(n,r,t){return i.call(n,null==r||t?1:r)}var Cr=j((function(n,r){return r=er(r,!0,!0),xr(n,(function(n){return!Mr(r,n)}))})),Kr=j((function(n,r){return Cr(n,r)}));function Jr(n,r,t,e){A(r)||(e=t,t=r,r=!1),null!=t&&(t=qn(t,e));for(var u=[],o=[],i=0,a=Y(n);ir?(e&&(clearTimeout(e),e=null),a=c,i=n.apply(u,o),e||(u=o=null)):e||!1===t.trailing||(e=setTimeout(f,l)),i};return c.cancel=function(){clearTimeout(e),a=0,e=u=o=null},c},debounce:function(n,r,t){var e,u,o=function(r,t){e=null,t&&(u=n.apply(r,t))},i=j((function(i){if(e&&clearTimeout(e),t){var a=!e;e=setTimeout(o,r),a&&(u=n.apply(this,i))}else e=or(o,r,this,i);return u}));return i.cancel=function(){clearTimeout(e),e=null},i},wrap:function(n,r){return nr(r,n)},negate:ar,compose:function(){var n=arguments,r=n.length-1;return function(){for(var t=r,e=n[r].apply(this,arguments);t--;)e=n[t].call(this,e);return e}},after:function(n,r){return function(){if(--n<1)return r.apply(this,arguments)}},before:fr,once:cr,findKey:lr,findIndex:pr,findLastIndex:vr,sortedIndex:hr,indexOf:gr,lastIndexOf:dr,find:br,detect:br,findWhere:function(n,r){return br(n,Dn(r))},each:mr,forEach:mr,map:jr,collect:jr,reduce:wr,foldl:wr,inject:wr,reduceRight:Ar,foldr:Ar,filter:xr,select:xr,reject:function(n,r,t){return xr(n,ar(qn(r)),t)},every:Sr,all:Sr,some:Or,any:Or,contains:Mr,includes:Mr,include:Mr,invoke:Er,pluck:Br,where:function(n,r){return xr(n,Dn(r))},max:Nr,min:function(n,r,t){var e,u,o=1/0,i=1/0;if(null==r||"number"==typeof r&&"object"!=typeof n[0]&&null!=n)for(var a=0,f=(n=tr(n)?n:jn(n)).length;ae||void 0===t)return 1;if(tSubmodules
    -sparseml.log.get_main_logger() → logging.Logger[source]
    +sparseml.log.get_main_logger()logging.Logger[source]
    Returns

    a main logger that can be used in external scripts for logging @@ -433,7 +433,7 @@

    Submodules
    -sparseml.log.get_nm_root_logger() → logging.Logger[source]
    +sparseml.log.get_nm_root_logger()logging.Logger[source]
    Returns

    the logger used for the sparseml root package that all @@ -444,7 +444,7 @@

    Submodules
    -sparseml.log.set_logging_level(level: int)[source]
    +sparseml.log.set_logging_level(level: int)[source]

    Set the logging level for the MAIN and NM_ROOT loggers along with all loggers created in the sparseml namespace

    diff --git a/sparseml/api/sparseml.keras.optim.html b/sparseml/api/sparseml.keras.optim.html index c454ff1741b..74110e0a154 100644 --- a/sparseml/api/sparseml.keras.optim.html +++ b/sparseml/api/sparseml.keras.optim.html @@ -212,12 +212,12 @@

    Submodules
    -class sparseml.keras.optim.manager.ScheduledModifierManager(modifiers: List[sparseml.keras.optim.modifier.ScheduledModifier])[source]
    +class sparseml.keras.optim.manager.ScheduledModifierManager(modifiers: List[sparseml.keras.optim.modifier.ScheduledModifier])[source]

    Bases: sparseml.optim.manager.BaseManager, sparseml.keras.optim.modifier.Modifier

    The base modifier manager, handles managing multiple ScheduledModifier.

    -finalize(model: tensorflow.python.keras.engine.training.Model)[source]
    +finalize(model: tensorflow.python.keras.engine.training.Model)[source]

    Remove extra information related to the modifier from the model that is not necessary for exporting

    @@ -232,7 +232,7 @@

    Submodules
    -static from_yaml(file_path: Union[str, sparsezoo.objects.optimization_recipe.OptimizationRecipe], add_modifiers: Optional[List[sparseml.keras.optim.modifier.Modifier]] = None)[source]
    +static from_yaml(file_path: Union[str, sparsezoo.objects.optimization_recipe.OptimizationRecipe], add_modifiers: Optional[List[sparseml.keras.optim.modifier.Modifier]] = None)[source]

    Convenience function used to create the manager of multiple modifiers from a recipe file.

    @@ -256,7 +256,7 @@

    Submodules
    -modify(model: tensorflow.python.keras.engine.training.Model, optimizer: tensorflow.python.keras.optimizer_v2.optimizer_v2.OptimizerV2, steps_per_epoch: int, loggers: Optional[Union[sparseml.keras.utils.logger.KerasLogger, List[sparseml.keras.utils.logger.KerasLogger]]] = None, input_tensors: Optional[tensorflow.python.framework.ops.Tensor] = None)[source]
    +modify(model: tensorflow.python.keras.engine.training.Model, optimizer: tensorflow.python.keras.optimizer_v2.optimizer_v2.OptimizerV2, steps_per_epoch: int, loggers: Optional[Union[sparseml.keras.utils.logger.KerasLogger, List[sparseml.keras.utils.logger.KerasLogger]]] = None, input_tensors: Optional[tensorflow.python.framework.ops.Tensor] = None)[source]

    Modify the model and optimizer based on the requirements of modifiers

    Parameters
    @@ -281,7 +281,7 @@

    Submodules

    sparseml.keras.optim.mask_pruning module

    -class sparseml.keras.optim.mask_pruning.MaskedLayer(*args, **kwargs)[source]
    +class sparseml.keras.optim.mask_pruning.MaskedLayer(*args, **kwargs)[source]

    Bases: tensorflow.python.keras.layers.wrappers.Wrapper

    Masked layer is a layer wrapping around another layer with a mask; the mask however is shared if the enclosed layer is again of MaskedLayer type

    @@ -297,7 +297,7 @@

    Submodules
    -build(input_shape)[source]
    +build(input_shape)[source]

    Creates the variables of the layer (optional, for subclass implementers).

    This is a method that implementers of subclasses of Layer or Model can override if they need a state-creation step in-between @@ -314,13 +314,13 @@

    Submodules
    -call(inputs: tensorflow.python.framework.ops.Tensor, training=None)[source]
    +call(inputs: tensorflow.python.framework.ops.Tensor, training=None)[source]

    Forward function for calling layer instance as function

    -compute_output_shape(input_shape)[source]
    +compute_output_shape(input_shape)[source]

    Computes the output shape of the layer.

    If the layer has not been built, this method will call build on the layer. This assumes that the layer will later be used with inputs that @@ -340,7 +340,7 @@

    Submodules
    -classmethod from_config(config)[source]
    +classmethod from_config(config)[source]

    Creates a layer from its config.

    This method is the reverse of get_config, capable of instantiating the same layer from the config @@ -359,7 +359,7 @@

    Submodules
    -get_config()[source]
    +get_config()[source]

    Get layer config Serialization and deserialization should be done using tf.keras.serialize/deserialize, which create and retrieve the “class_name” @@ -369,44 +369,44 @@

    Submodules
    -property global_step
    +property global_step

    -property mask_updater
    +property mask_updater
    -property masked_layer
    +property masked_layer
    -property masks
    +property masks
    -property pruned_layer
    +property pruned_layer
    -property pruning_vars
    +property pruning_vars

    -class sparseml.keras.optim.mask_pruning.PruningScheduler[source]
    +class sparseml.keras.optim.mask_pruning.PruningScheduler[source]

    Bases: abc.ABC

    Abstract pruning scheduler

    -classmethod deserialize(config)[source]
    +classmethod deserialize(config)[source]

    Deserialize a pruning scheduler from config returned by scheduler’s get_config method

    @@ -421,12 +421,12 @@

    Submodules
    -abstract get_config()[source]
    +abstract get_config()[source]

    -abstract should_prune(step: int) → bool[source]
    +abstract should_prune(step: int)bool[source]

    Check if the given step is a right time for pruning

    Parameters
    @@ -440,7 +440,7 @@

    Submodules
    -abstract target_sparsity(step: int, **kwargs) → float[source]
    +abstract target_sparsity(step: int, **kwargs)float[source]

    Compute the target sparsity at the given step

    Parameters
    @@ -459,7 +459,7 @@

    Submodules
    -sparseml.keras.optim.mask_pruning.remove_pruning_masks(model: tensorflow.python.keras.engine.training.Model)[source]
    +sparseml.keras.optim.mask_pruning.remove_pruning_masks(model: tensorflow.python.keras.engine.training.Model)[source]

    Remove pruning masks from a model that was pruned using the MaskedLayer logic :param model: a model that was pruned using MaskedLayer :return: the original model with pruned weights

    @@ -471,7 +471,7 @@

    Submodules
    -class sparseml.keras.optim.mask_pruning_creator.BlockPruningMaskCreator(block_shape: List[int], grouping_op_name: str = 'mean')[source]
    +class sparseml.keras.optim.mask_pruning_creator.BlockPruningMaskCreator(block_shape: List[int], grouping_op_name: str = 'mean')[source]

    Bases: sparseml.keras.optim.mask_pruning_creator.GroupedPruningMaskCreator

    Structured sparsity mask creator that groups the input tensor into blocks of shape block_shape. @@ -485,7 +485,7 @@

    Submodules
    -group_tensor(tensor: tensorflow.python.framework.ops.Tensor) → tensorflow.python.framework.ops.Tensor[source]
    +group_tensor(tensor: tensorflow.python.framework.ops.Tensor)tensorflow.python.framework.ops.Tensor[source]
    Parameters

    tensor – The tensor to transform

    @@ -501,7 +501,7 @@

    Submodules
    -class sparseml.keras.optim.mask_pruning_creator.DimensionPruningMaskCreator(dim: Union[str, int, List[int]], grouping_op_name: str = 'mean')[source]
    +class sparseml.keras.optim.mask_pruning_creator.DimensionPruningMaskCreator(dim: Union[str, int, List[int]], grouping_op_name: str = 'mean')[source]

    Bases: sparseml.keras.optim.mask_pruning_creator.GroupedPruningMaskCreator

    Structured sparsity mask creator that groups sparsity blocks by the given dimension(s)

    @@ -513,7 +513,7 @@

    Submodules
    -group_tensor(tensor: tensorflow.python.framework.ops.Tensor) → tensorflow.python.framework.ops.Tensor[source]
    +group_tensor(tensor: tensorflow.python.framework.ops.Tensor)tensorflow.python.framework.ops.Tensor[source]
    Parameters

    tensor – The tensor to transform

    @@ -529,14 +529,14 @@

    Submodules
    -class sparseml.keras.optim.mask_pruning_creator.GroupedPruningMaskCreator[source]
    +class sparseml.keras.optim.mask_pruning_creator.GroupedPruningMaskCreator[source]

    Bases: sparseml.keras.optim.mask_pruning_creator.UnstructuredPruningMaskCreator

    Abstract class for a sparsity mask creator that structures masks according to grouping functions. Subclasses should implement group_tensor and _map_mask_to_tensor

    -create_sparsity_mask(tensor: tensorflow.python.framework.ops.Tensor, sparsity: tensorflow.python.framework.ops.Tensor) → tensorflow.python.framework.ops.Tensor[source]
    +create_sparsity_mask(tensor: tensorflow.python.framework.ops.Tensor, sparsity: tensorflow.python.framework.ops.Tensor)tensorflow.python.framework.ops.Tensor[source]
    Parameters
      @@ -553,7 +553,7 @@

      Submodules
      -static get_grouping_op(grouping_op_name: str) → tensorflow.python.framework.ops.Operation[source]
      +static get_grouping_op(grouping_op_name: str)tensorflow.python.framework.ops.Operation[source]
      Parameters

      grouping_op_name – name of grouping operation to get tf operation for

      @@ -566,7 +566,7 @@

      Submodules
      -get_mask_initializer(tensor: tensorflow.python.framework.ops.Tensor) → Callable[tensorflow.python.framework.ops.Tensor][source]
      +get_mask_initializer(tensor: tensorflow.python.framework.ops.Tensor)Callable[tensorflow.python.framework.ops.Tensor][source]
      Parameters

      tensor – A tensor of a model layer’s weights

      @@ -579,7 +579,7 @@

      Submodules
      -abstract group_tensor(tensor: tensorflow.python.framework.ops.Tensor) → tensorflow.python.framework.ops.Tensor[source]
      +abstract group_tensor(tensor: tensorflow.python.framework.ops.Tensor)tensorflow.python.framework.ops.Tensor[source]
      Parameters

      tensor – The tensor to reduce in groups

      @@ -594,13 +594,13 @@

      Submodules
      -class sparseml.keras.optim.mask_pruning_creator.PruningMaskCreator[source]
      +class sparseml.keras.optim.mask_pruning_creator.PruningMaskCreator[source]

      Bases: abc.ABC

      Base abstract class for a sparsity mask creator. Subclasses should define all methods for creating masks and their initializers

      -abstract create_sparsity_mask(tensor: tensorflow.python.framework.ops.Tensor, sparsity: tensorflow.python.framework.ops.Tensor) → tensorflow.python.framework.ops.Tensor[source]
      +abstract create_sparsity_mask(tensor: tensorflow.python.framework.ops.Tensor, sparsity: tensorflow.python.framework.ops.Tensor)tensorflow.python.framework.ops.Tensor[source]
      Parameters
        @@ -617,7 +617,7 @@

        Submodules
        -abstract get_mask_initializer(tensor: tensorflow.python.framework.ops.Tensor) → Callable[tensorflow.python.framework.ops.Tensor][source]
        +abstract get_mask_initializer(tensor: tensorflow.python.framework.ops.Tensor)Callable[tensorflow.python.framework.ops.Tensor][source]
        Parameters

        tensor – A tensor of a model layer’s weights

        @@ -632,14 +632,14 @@

        Submodules
        -class sparseml.keras.optim.mask_pruning_creator.UnstructuredPruningMaskCreator[source]
        +class sparseml.keras.optim.mask_pruning_creator.UnstructuredPruningMaskCreator[source]

        Bases: sparseml.keras.optim.mask_pruning_creator.PruningMaskCreator

        Class for creating unstructured sparsity masks. Masks will be created using unstructured sparsity by pruning weights ranked by their magnitude.

        -create_sparsity_mask(tensor: tensorflow.python.framework.ops.Tensor, sparsity: tensorflow.python.framework.ops.Tensor) → tensorflow.python.framework.ops.Tensor[source]
        +create_sparsity_mask(tensor: tensorflow.python.framework.ops.Tensor, sparsity: tensorflow.python.framework.ops.Tensor)tensorflow.python.framework.ops.Tensor[source]
        Parameters
          @@ -656,7 +656,7 @@

          Submodules
          -get_mask_initializer(tensor: tensorflow.python.framework.ops.Tensor) → Callable[tensorflow.python.framework.ops.Tensor][source]
          +get_mask_initializer(tensor: tensorflow.python.framework.ops.Tensor)Callable[tensorflow.python.framework.ops.Tensor][source]
          Parameters

          tensor – A tensor of a model layer’s weights

          @@ -675,7 +675,7 @@

          Submodules
          -sparseml.keras.optim.mask_pruning_creator.load_mask_creator(obj: Union[str, Iterable[int]])sparseml.keras.optim.mask_pruning_creator.PruningMaskCreator[source]
          +sparseml.keras.optim.mask_pruning_creator.load_mask_creator(obj: Union[str, Iterable[int]])sparseml.keras.optim.mask_pruning_creator.PruningMaskCreator[source]
          Parameters

          obj – Formatted string or iterable of block_shape specifying @@ -696,7 +696,7 @@

          Submodules
          -class sparseml.keras.optim.modifier.KerasModifierYAML[source]
          +class sparseml.keras.optim.modifier.KerasModifierYAML[source]

          Bases: sparseml.optim.modifier.ModifierYAML

          A decorator to handle making a Keras modifier class YAML ready. IE it can be loaded in through the yaml plugin easily.

          @@ -704,7 +704,7 @@

          Submodules
          -class sparseml.keras.optim.modifier.Modifier(log_types: Optional[Union[str, List[str]]] = None, **kwargs)[source]
          +class sparseml.keras.optim.modifier.Modifier(log_types: Optional[Union[str, List[str]]] = None, **kwargs)[source]

          Bases: sparseml.optim.modifier.BaseModifier

          Base modifier class that all Keras modifiers should derive themselves from. Handles setting up the expected contracts for modifying model and optimizer

          @@ -724,7 +724,7 @@

          Submodules
          -finalize(model: tensorflow.python.keras.engine.training.Model)[source]
          +finalize(model: tensorflow.python.keras.engine.training.Model)[source]

          Remove extra information related to the modifier from the model that is not necessary for exporting

          @@ -739,7 +739,7 @@

          Submodules
          -static load_list(yaml_str: str)[source]
          +static load_list(yaml_str: str)[source]
          Parameters

          yaml_str – a string representation of the yaml syntax to @@ -753,7 +753,7 @@

          Submodules
          -static load_obj(yaml_str: str)[source]
          +static load_obj(yaml_str: str)[source]
          Parameters

          yaml_str – a string representation of the yaml syntax to @@ -767,7 +767,7 @@

          Submodules
          -modify(model, optimizer, steps_per_epoch: int, loggers: Optional[Union[sparseml.keras.utils.logger.KerasLogger, List[sparseml.keras.utils.logger.KerasLogger]]] = None, input_tensors: Optional[tensorflow.python.framework.ops.Tensor] = None)[source]
          +modify(model, optimizer, steps_per_epoch: int, loggers: Optional[Union[sparseml.keras.utils.logger.KerasLogger, List[sparseml.keras.utils.logger.KerasLogger]]] = None, input_tensors: Optional[tensorflow.python.framework.ops.Tensor] = None)[source]

          Modify model, optimizer based on the logic of the modifier. Return the modified model, optimizer and a list of callbacks (e.g., to enhance training process)

          @@ -789,7 +789,7 @@

          Submodules
          -class sparseml.keras.optim.modifier.ModifierProp(serializable: bool = True, restrict_initialized: bool = True, restrict_enabled: bool = False, restrict_extras: Optional[List[str]] = None, no_serialize_val: Optional[Any] = None, func_get: Optional[Callable] = None, func_set: Optional[Callable] = None, doc: Optional[Callable] = None)[source]
          +class sparseml.keras.optim.modifier.ModifierProp(serializable: bool = True, restrict_initialized: bool = True, restrict_enabled: bool = False, restrict_extras: Optional[List[str]] = None, no_serialize_val: Optional[Any] = None, func_get: Optional[Callable] = None, func_set: Optional[Callable] = None, doc: Optional[Callable] = None)[source]

          Bases: sparseml.optim.modifier.BaseProp

          Property used to decorate a modifier. Use for creating getters and setters in a modifier. @@ -816,7 +816,7 @@

          Submodules
          -getter(func_get: Callable)sparseml.optim.modifier.BaseProp[source]
          +getter(func_get: Callable)sparseml.optim.modifier.BaseProp[source]

          Create a ModifierProp based off the current instance with the getter function

          Parameters
          @@ -830,7 +830,7 @@

          Submodules
          -property no_serialize_val
          +property no_serialize_val

          a value that if the prop is equal to, will not serialize the prop

          Type
          @@ -841,7 +841,7 @@

          Submodules
          -property restrictions
          +property restrictions

          The attributes to check for restricting when the attribute can be set

          Type
          @@ -852,7 +852,7 @@

          Submodules
          -property serializable
          +property serializable

          True if the property should be serialized (ex in yaml), False otherwise

          Type
          @@ -863,7 +863,7 @@

          Submodules
          -setter(func_set: Callable)sparseml.optim.modifier.BaseProp[source]
          +setter(func_set: Callable)sparseml.optim.modifier.BaseProp[source]

          Create a ModifierProp based off the current instance with the setter function

          Parameters
          @@ -879,7 +879,7 @@

          Submodules
          -class sparseml.keras.optim.modifier.ScheduledModifier(log_types: Optional[Union[str, List[str]]] = None, start_epoch: float = - 1.0, end_epoch: float = - 1.0, min_start: float = - 1.0, min_end: float = - 1.0, end_comparator: Optional[int] = 0, **kwargs)[source]
          +class sparseml.keras.optim.modifier.ScheduledModifier(log_types: Optional[Union[str, List[str]]] = None, start_epoch: float = - 1.0, end_epoch: float = - 1.0, min_start: float = - 1.0, min_end: float = - 1.0, end_comparator: Optional[int] = 0, **kwargs)[source]

          Bases: sparseml.keras.optim.modifier.Modifier, sparseml.optim.modifier.BaseScheduled

          The base scheduled update modifier implementation, all scheduled modifiers should inherit from this class. @@ -911,7 +911,7 @@

          Submodules
          -property end_epoch
          +property end_epoch

          The epoch to end the modifier at (set to -1.0 so it never ends)

          @@ -923,7 +923,7 @@

          Submodules
          -start_end_steps(steps_per_epoch, after_optim: bool) → Tuple[int, int][source]
          +start_end_steps(steps_per_epoch, after_optim: bool)Tuple[int, int][source]

          Calculate the start and end steps for this modifier given a certain amount of steps per epoch

          @@ -943,7 +943,7 @@

          Submodules
          -property start_epoch
          +property start_epoch

          The epoch to start the modifier at (set to -1.0 so it starts immediately)

          @@ -957,7 +957,7 @@

          Submodules
          -class sparseml.keras.optim.modifier.ScheduledUpdateModifier(log_types: Optional[Union[str, List[str]]] = None, start_epoch: float = - 1.0, end_epoch: float = - 1.0, min_start: float = - 1.0, min_end: float = - 1.0, end_comparator: int = 0, update_frequency: float = - 1.0, min_frequency: float = - 1.0, **kwargs)[source]
          +class sparseml.keras.optim.modifier.ScheduledUpdateModifier(log_types: Optional[Union[str, List[str]]] = None, start_epoch: float = - 1.0, end_epoch: float = - 1.0, min_start: float = - 1.0, min_end: float = - 1.0, end_comparator: int = 0, update_frequency: float = - 1.0, min_frequency: float = - 1.0, **kwargs)[source]

          Bases: sparseml.keras.optim.modifier.ScheduledModifier, sparseml.optim.modifier.BaseUpdate

          The base scheduled update modifier implementation, all scheduled update modifiers should inherit from this class. @@ -990,7 +990,7 @@

          Submodules
          -update_frequency_steps(steps_per_epoch: int) → int[source]
          +update_frequency_steps(steps_per_epoch: int)int[source]

          Calculate the update frequency steps for this modifier given a certain amount of steps per epoch

          @@ -1012,7 +1012,7 @@

          Submodules
          -class sparseml.keras.optim.modifier_epoch.EpochRangeModifier(start_epoch: float, end_epoch: float)[source]
          +class sparseml.keras.optim.modifier_epoch.EpochRangeModifier(start_epoch: float, end_epoch: float)[source]

          Bases: sparseml.keras.optim.modifier.ScheduledModifier

          Simple modifier to set the range of epochs to train over for the recalibration process. @@ -1036,7 +1036,7 @@

          Submodules
          -class sparseml.keras.optim.modifier_lr.LearningRateModifier(lr_class: str, lr_kwargs: Dict, init_lr: float, start_epoch: float, end_epoch: float = - 1.0, update_frequency: float = - 1.0, log_types: Union[str, List[str]] = '__ALL__')[source]
          +class sparseml.keras.optim.modifier_lr.LearningRateModifier(lr_class: str, lr_kwargs: Dict, init_lr: float, start_epoch: float, end_epoch: float = - 1.0, update_frequency: float = - 1.0, log_types: Union[str, List[str]] = '__ALL__')[source]

          Bases: sparseml.keras.optim.modifier.ScheduledUpdateModifier, sparseml.optim.learning_rate.LearningRate

          Modifier to set the learning rate to follow specific schedulers within a period of epochs. @@ -1080,7 +1080,7 @@

          Submodules
          -modify(model, optimizer, steps_per_epoch: int, loggers: Optional[Union[sparseml.keras.utils.logger.KerasLogger, List[sparseml.keras.utils.logger.KerasLogger]]] = None, input_tensors: Optional[tensorflow.python.framework.ops.Tensor] = None)[source]
          +modify(model, optimizer, steps_per_epoch: int, loggers: Optional[Union[sparseml.keras.utils.logger.KerasLogger, List[sparseml.keras.utils.logger.KerasLogger]]] = None, input_tensors: Optional[tensorflow.python.framework.ops.Tensor] = None)[source]

          Modify model and optimizer, and provide callbacks to process the model

          Parameters
          @@ -1102,7 +1102,7 @@

          Submodules
          -class sparseml.keras.optim.modifier_lr.SetLearningRateModifier(learning_rate: float, start_epoch: float = - 1, end_epoch: float = - 1, log_types: Union[str, List[str]] = '__ALL__')[source]
          +class sparseml.keras.optim.modifier_lr.SetLearningRateModifier(learning_rate: float, start_epoch: float = - 1, end_epoch: float = - 1, log_types: Union[str, List[str]] = '__ALL__')[source]

          Bases: sparseml.keras.optim.modifier.ScheduledModifier, sparseml.optim.learning_rate.SetLearningRate

          Modifier to set the learning rate to a specific value at a certain point in the training process. Once that point is reached, will update the optimizer’s @@ -1131,7 +1131,7 @@

          Submodules
          -modify(model, optimizer, steps_per_epoch: int, loggers: Optional[Union[sparseml.keras.utils.logger.KerasLogger, List[sparseml.keras.utils.logger.KerasLogger]]] = None, input_tensors: Optional[tensorflow.python.framework.ops.Tensor] = None)[source]
          +modify(model, optimizer, steps_per_epoch: int, loggers: Optional[Union[sparseml.keras.utils.logger.KerasLogger, List[sparseml.keras.utils.logger.KerasLogger]]] = None, input_tensors: Optional[tensorflow.python.framework.ops.Tensor] = None)[source]

          Modify model and optimizer, and provide callbacks to process the model

          Parameters
          @@ -1158,7 +1158,7 @@

          Submodules
          -class sparseml.keras.optim.modifier_params.TrainableParamsModifier(params: Union[str, List[str]], trainable: bool, params_strict: bool = True, start_epoch: float = - 1.0, end_epoch: float = - 1.0)[source]
          +class sparseml.keras.optim.modifier_params.TrainableParamsModifier(params: Union[str, List[str]], trainable: bool, params_strict: bool = True, start_epoch: float = - 1.0, end_epoch: float = - 1.0)[source]

          Bases: sparseml.keras.optim.modifier.ScheduledModifier

          Modifier to control the params for a given list of parameters. Applies the trainability over all epochs. @@ -1190,12 +1190,12 @@

          Submodules
          -property layer_names
          +property layer_names

          -modify(model, optimizer, steps_per_epoch: int, input_tensors: Optional[tensorflow.python.framework.ops.Tensor] = None)[source]
          +modify(model, optimizer, steps_per_epoch: int, input_tensors: Optional[tensorflow.python.framework.ops.Tensor] = None)[source]

          Modify model, optimizer based on the logic of the modifier. Return the modified model, optimizer and a list of callbacks (e.g., to enhance training process)

          @@ -1215,7 +1215,7 @@

          Submodules
          -params
          +params

          A list of full parameter names or regex patterns of names to apply pruning to. Regex patterns must be specified with the prefix ‘re:’. __ALL__ will match to all parameters. Can also use the token __ALL__ to specify all @@ -1229,7 +1229,7 @@

          Submodules
          -params_strict
          +params_strict

          True if the given param(s) must be found in each layer and will raise an err if not found, False if missing params are ok and will not raise an err

          @@ -1242,7 +1242,7 @@

          Submodules
          -trainable
          +trainable

          True if the param(s) should be made trainable, False to make them non-trainable

          @@ -1254,7 +1254,7 @@

          Submodules
          -validate()[source]
          +validate()[source]

          Validate the values of the params for the current instance are valid

          @@ -1267,7 +1267,7 @@

          Submodules
          -class sparseml.keras.optim.modifier_pruning.ConstantPruningModifier(params: Union[str, List[str]], start_epoch: float = - 1, end_epoch: float = - 1, log_types: Union[str, List[str]] = '__ALL__')[source]
          +class sparseml.keras.optim.modifier_pruning.ConstantPruningModifier(params: Union[str, List[str]], start_epoch: float = - 1, end_epoch: float = - 1, log_types: Union[str, List[str]] = '__ALL__')[source]

          Bases: sparseml.keras.optim.modifier.ScheduledModifier

          Holds the sparsity level and shape for a given param constant while training. Useful for transfer learning use cases.

          @@ -1299,7 +1299,7 @@

          Submodules
          -finalize(model: tensorflow.python.keras.engine.training.Model)[source]
          +finalize(model: tensorflow.python.keras.engine.training.Model)[source]

          Remove extra information related to the modifier from the model that is not necessary for exporting

          @@ -1314,17 +1314,17 @@

          Submodules
          -is_pruning_step(step: int, steps_per_epoch, tensor=None)[source]
          +is_pruning_step(step: int, steps_per_epoch, tensor=None)[source]

          -property layer_names
          +property layer_names
          -modify(model, optimizer, steps_per_epoch: int, loggers: Optional[Union[sparseml.keras.utils.logger.KerasLogger, List[sparseml.keras.utils.logger.KerasLogger]]] = None, input_tensors: Optional[tensorflow.python.framework.ops.Tensor] = None)[source]
          +modify(model, optimizer, steps_per_epoch: int, loggers: Optional[Union[sparseml.keras.utils.logger.KerasLogger, List[sparseml.keras.utils.logger.KerasLogger]]] = None, input_tensors: Optional[tensorflow.python.framework.ops.Tensor] = None)[source]

          Modify model and optimizer

          Parameters
          @@ -1344,7 +1344,7 @@

          Submodules
          -params
          +params

          List of str for the variable names or regex patterns of names to apply the KS modifier to. Regex patterns must be specified with the prefix ‘re:’.

          @@ -1357,7 +1357,7 @@

          Submodules
          -property sparsity
          +property sparsity

          the created sparsity tensor for setting the pruning ops if create_ops has been called, else None

          @@ -1369,7 +1369,7 @@

          Submodules
          -property update_ready
          +property update_ready

          the created update_ready tensor for setting the pruning ops if create_ops has been called, else None

          @@ -1383,7 +1383,7 @@

          Submodules
          -class sparseml.keras.optim.modifier_pruning.GMPruningModifier(params: Union[str, List[str]], init_sparsity: float, final_sparsity: float, start_epoch: float, end_epoch: float, update_frequency: float, inter_func: str = 'cubic', log_types: Union[str, List[str]] = '__ALL__', mask_type: Union[str, List[int]] = 'unstructured', leave_enabled: bool = True)[source]
          +class sparseml.keras.optim.modifier_pruning.GMPruningModifier(params: Union[str, List[str]], init_sparsity: float, final_sparsity: float, start_epoch: float, end_epoch: float, update_frequency: float, inter_func: str = 'cubic', log_types: Union[str, List[str]] = '__ALL__', mask_type: Union[str, List[int]] = 'unstructured', leave_enabled: bool = True)[source]

          Bases: sparseml.keras.optim.modifier.ScheduledUpdateModifier

          Gradually applies kernel sparsity to a given variable or variables from init_sparsity until final_sparsity is reached over a given amount of time and @@ -1438,12 +1438,12 @@

          Submodules
          -exponent
          +exponent

          -final_sparsity
          +final_sparsity

          The final sparsity for the variable to end with at end_epoch

          Type
          @@ -1454,7 +1454,7 @@

          Submodules
          -finalize(model: tensorflow.python.keras.engine.training.Model)[source]
          +finalize(model: tensorflow.python.keras.engine.training.Model)[source]

          Remove extra information related to the modifier from the model that is not necessary for exporting

          @@ -1469,7 +1469,7 @@

          Submodules
          -init_sparsity
          +init_sparsity

          The initial sparsity for the variable to start with at start_epoch

          Type
          @@ -1480,7 +1480,7 @@

          Submodules
          -inter_func
          +inter_func

          The type of interpolation function to use: [linear, cubic, inverse_cubic]

          @@ -1492,12 +1492,12 @@

          Submodules
          -property layer_names
          +property layer_names

          -leave_enabled
          +leave_enabled

          True to continue masking the weights after end_epoch, False to stop masking. Note, if set as False, sparsity will not be enforced and the model will likely deviate from the sparse solution

          @@ -1510,7 +1510,7 @@

          Submodules
          -mask_type
          +mask_type

          the mask type used

          Type
          @@ -1521,7 +1521,7 @@

          Submodules
          -modify(model, optimizer, steps_per_epoch: int, loggers: Optional[Union[sparseml.keras.utils.logger.KerasLogger, List[sparseml.keras.utils.logger.KerasLogger]]] = None, input_tensors: Optional[tensorflow.python.framework.ops.Tensor] = None)[source]
          +modify(model, optimizer, steps_per_epoch: int, loggers: Optional[Union[sparseml.keras.utils.logger.KerasLogger, List[sparseml.keras.utils.logger.KerasLogger]]] = None, input_tensors: Optional[tensorflow.python.framework.ops.Tensor] = None)[source]

          Modify model and optimizer, and provide callbacks to process the model

          Parameters
          @@ -1541,7 +1541,7 @@

          Submodules
          -params
          +params

          List of str for the variable names or regex patterns of names to apply the KS modifier to. Regex patterns must be specified with the prefix ‘re:’.

          @@ -1554,12 +1554,12 @@

          Submodules
          -property prunable_layers
          +property prunable_layers

          -property sparsity
          +property sparsity

          the created sparsity tensor for setting the pruning ops if create_ops has been called, else None

          @@ -1571,7 +1571,7 @@

          Submodules
          -property update_ready
          +property update_ready

          the created update_ready tensor for setting the pruning ops if create_ops has been called, else None

          @@ -1583,7 +1583,7 @@

          Submodules
          -validate()[source]
          +validate()[source]

          Validate the values of the params for the current instance are valid

          @@ -1594,7 +1594,7 @@

          Submodules

          sparseml.keras.optim.utils module

          -sparseml.keras.optim.utils.get_layer_name_from_param(param: str)[source]
          +sparseml.keras.optim.utils.get_layer_name_from_param(param: str)[source]
          diff --git a/sparseml/api/sparseml.keras.utils.html b/sparseml/api/sparseml.keras.utils.html index 73318a24f58..081d68ad9c2 100644 --- a/sparseml/api/sparseml.keras.utils.html +++ b/sparseml/api/sparseml.keras.utils.html @@ -210,7 +210,7 @@

          Submodules
          -class sparseml.keras.utils.callbacks.LoggerSettingCallback(loggers: Union[sparseml.keras.utils.logger.KerasLogger, List[sparseml.keras.utils.logger.KerasLogger]])[source]
          +class sparseml.keras.utils.callbacks.LoggerSettingCallback(loggers: Union[sparseml.keras.utils.logger.KerasLogger, List[sparseml.keras.utils.logger.KerasLogger]])[source]

          Bases: tensorflow.python.keras.callbacks.Callback

          Class to help correctly set logging modes for callbacks that rely on KerasLogger. All callbacks using KerasLogger should derive from this class.

          @@ -221,7 +221,7 @@

          Submodules
          -on_epoch_begin(epoch, logs=None)[source]
          +on_epoch_begin(epoch, logs=None)[source]

          Called at the begin of a training epoch

          Parameters
          @@ -235,7 +235,7 @@

          Submodules
          -on_epoch_end(epoch, logs=None)[source]
          +on_epoch_end(epoch, logs=None)[source]

          Called at the end of a training epoch

          Parameters
          @@ -249,7 +249,7 @@

          Submodules
          -on_predict_batch_begin(batch, logs=None)[source]
          +on_predict_batch_begin(batch, logs=None)[source]

          Called at the begin of a batch in prediction

          Parameters
          @@ -263,7 +263,7 @@

          Submodules
          -on_predict_batch_end(batch, logs=None)[source]
          +on_predict_batch_end(batch, logs=None)[source]

          Called at the end of a batch in prediction

          Parameters
          @@ -277,7 +277,7 @@

          Submodules
          -on_predict_begin(logs=None)[source]
          +on_predict_begin(logs=None)[source]

          Called at the begin of prediction

          Parameters
          @@ -288,7 +288,7 @@

          Submodules
          -on_predict_end(logs=None)[source]
          +on_predict_end(logs=None)[source]

          Called at the end of prediction

          Parameters
          @@ -299,7 +299,7 @@

          Submodules
          -on_test_batch_begin(batch, logs=None)[source]
          +on_test_batch_begin(batch, logs=None)[source]

          Called at the begin of a batch in evaluation

          Parameters
          @@ -313,7 +313,7 @@

          Submodules
          -on_test_batch_end(batch, logs=None)[source]
          +on_test_batch_end(batch, logs=None)[source]

          Called at the end of a batch in evaluation

          Parameters
          @@ -327,7 +327,7 @@

          Submodules
          -on_test_begin(logs=None)[source]
          +on_test_begin(logs=None)[source]

          Called at the begin of evaluation

          Parameters
          @@ -338,7 +338,7 @@

          Submodules
          -on_test_end(logs=None)[source]
          +on_test_end(logs=None)[source]

          Called at the end of evaluation

          Parameters
          @@ -349,7 +349,7 @@

          Submodules
          -on_train_batch_begin(batch, logs=None)[source]
          +on_train_batch_begin(batch, logs=None)[source]

          Called at the begin of a batch in training

          Parameters
          @@ -363,7 +363,7 @@

          Submodules
          -on_train_batch_end(batch, logs=None)[source]
          +on_train_batch_end(batch, logs=None)[source]

          Called at the end of a batch in training

          Parameters
          @@ -377,7 +377,7 @@

          Submodules
          -on_train_begin(logs=None)[source]
          +on_train_begin(logs=None)[source]

          Called at the begin of training

          Parameters
          @@ -388,7 +388,7 @@

          Submodules
          -on_train_end(logs=None)[source]
          +on_train_end(logs=None)[source]

          Called at the end of training

          Parameters
          @@ -401,7 +401,7 @@

          Submodules
          -class sparseml.keras.utils.callbacks.LossesAndMetricsLoggingCallback(loggers: Union[sparseml.keras.utils.logger.KerasLogger, List[sparseml.keras.utils.logger.KerasLogger]], start_step: Union[tensorflow.python.framework.ops.Tensor, int] = 0)[source]
          +class sparseml.keras.utils.callbacks.LossesAndMetricsLoggingCallback(loggers: Union[sparseml.keras.utils.logger.KerasLogger, List[sparseml.keras.utils.logger.KerasLogger]], start_step: Union[tensorflow.python.framework.ops.Tensor, int] = 0)[source]

          Bases: sparseml.keras.utils.callbacks.LoggerSettingCallback

          Callback to log all losses and metrics

          @@ -414,7 +414,7 @@

          Submodules
          -on_epoch_end(epoch, logs=None)[source]
          +on_epoch_end(epoch, logs=None)[source]

          Called at the end of a training epoch

          Parameters
          @@ -428,7 +428,7 @@

          Submodules
          -on_test_end(logs=None)[source]
          +on_test_end(logs=None)[source]

          Called at the end of evaluation

          Parameters
          @@ -439,7 +439,7 @@

          Submodules
          -on_train_batch_end(batch, logs=None)[source]
          +on_train_batch_end(batch, logs=None)[source]

          Called at the end of a batch in training

          Parameters
          @@ -453,7 +453,7 @@

          Submodules
          -on_train_begin(logs=None)[source]
          +on_train_begin(logs=None)[source]

          Called at the begin of training

          Parameters
          @@ -470,7 +470,7 @@

          Submodules
          -class sparseml.keras.utils.exporter.ModelExporter(model: tensorflow.python.keras.engine.training.Model, output_dir: str)[source]
          +class sparseml.keras.utils.exporter.ModelExporter(model: tensorflow.python.keras.engine.training.Model, output_dir: str)[source]

          Bases: object

          An exporter for exporting Keras models into ONNX format as well as numpy arrays for the input and output tensors.

          @@ -484,7 +484,7 @@

          Submodules
          -export_h5(name: str = 'model.h5')[source]
          +export_h5(name: str = 'model.h5')[source]

          Export the Keras model as a single HDF5 file in the output_dir/keras directory

          @@ -496,13 +496,13 @@

          Submodules
          -export_keras()[source]
          +export_keras()[source]

          Export the model Keras files to the output_dir/keras directory

          -export_onnx(name: str = 'model.onnx', opset: int = 11, doc_string: str = '', debug_mode: bool = True, **kwargs)[source]
          +export_onnx(name: str = 'model.onnx', opset: int = 11, doc_string: str = '', debug_mode: bool = True, **kwargs)[source]

          Export an ONNX file for the current model.

          Parameters
          @@ -519,7 +519,7 @@

          Submodules
          -export_samples(sample_batches: List[Any], sample_labels: Optional[List[Any]] = None, exp_counter: int = 0)[source]
          +export_samples(sample_batches: List[Any], sample_labels: Optional[List[Any]] = None, exp_counter: int = 0)[source]

          Export a set list of sample batches as inputs and outputs through the model.

          Parameters
          @@ -542,7 +542,7 @@

          Submodules
          -class sparseml.keras.utils.logger.KerasLogger(name: str, update_freq: Union[str, int] = 'epoch', **kwargs)[source]
          +class sparseml.keras.utils.logger.KerasLogger(name: str, update_freq: Union[str, int] = 'epoch', **kwargs)[source]

          Bases: abc.ABC

          Base class that all modifier loggers shall implement.

          @@ -558,7 +558,7 @@

          Submodules
          -abstract log_scalar(tag: str, value: float, step: Union[None, int] = None, **kwargs)[source]
          +abstract log_scalar(tag: str, value: float, step: Union[None, int] = None, **kwargs)[source]
          Parameters
            @@ -572,7 +572,7 @@

            Submodules
            -property mode
            +property mode

            Mode the current logger is at a current time

            Returns
            @@ -583,7 +583,7 @@

            Submodules
            -property name
            +property name

            name given to the logger, used for identification

            Type
            @@ -594,38 +594,38 @@

            Submodules
            -property update_freq
            +property update_freq

            -class sparseml.keras.utils.logger.LoggingMode(value)[source]
            +class sparseml.keras.utils.logger.LoggingMode(value)[source]

            Bases: enum.Enum

            Some logger changes its logging behavior (e.g. the destination it logs to) based on whether it’s running in train, validation or predict mode

            This enum defines the mode a logger could be in during its lifetime

            -PREDICT = 'predict'
            +PREDICT = 'predict'
            -TEST = 'validation'
            +TEST = 'validation'
            -TRAIN = 'train'
            +TRAIN = 'train'
            -class sparseml.keras.utils.logger.PythonLogger(name: str = 'python', update_freq: Union[str, int] = 'epoch', logger: Optional[logging.Logger] = None)[source]
            +class sparseml.keras.utils.logger.PythonLogger(name: str = 'python', update_freq: Union[str, int] = 'epoch', logger: Optional[logging.Logger] = None)[source]

            Bases: sparseml.keras.utils.logger.KerasLogger

            Modifier logger that handles printing values into a python logger instance.

            @@ -640,7 +640,7 @@

            Submodules
            -log_scalar(tag: str, value: float, step: Union[None, int] = None, **kwargs)[source]
            +log_scalar(tag: str, value: float, step: Union[None, int] = None, **kwargs)[source]
            Parameters
              @@ -658,7 +658,7 @@

              Submodules
              -class sparseml.keras.utils.logger.TensorBoardLogger(name: str = 'tensorboard', update_freq: Union[str, int] = 'epoch', log_dir: str = 'logs')[source]
              +class sparseml.keras.utils.logger.TensorBoardLogger(name: str = 'tensorboard', update_freq: Union[str, int] = 'epoch', log_dir: str = 'logs')[source]

              Bases: sparseml.keras.utils.logger.KerasLogger

              Modifier logger that handles outputting values into a TensorBoard log directory for viewing in TensorBoard.

              @@ -676,7 +676,7 @@

              Submodules
              -log_scalar(tag: str, value: float, step: Union[None, int] = None, **kwargs)[source]
              +log_scalar(tag: str, value: float, step: Union[None, int] = None, **kwargs)[source]
              Parameters
                @@ -696,7 +696,7 @@

                Submodules
                -sparseml.keras.utils.model.sparsity(model: tensorflow.python.keras.engine.training.Model)[source]
                +sparseml.keras.utils.model.sparsity(model: tensorflow.python.keras.engine.training.Model)[source]

                Retrieve sparsity of a Keras model

                Parameters
                diff --git a/sparseml/api/sparseml.onnx.optim.html b/sparseml/api/sparseml.onnx.optim.html index 0475121d042..b94e87128fa 100644 --- a/sparseml/api/sparseml.onnx.optim.html +++ b/sparseml/api/sparseml.onnx.optim.html @@ -226,7 +226,7 @@

                Submodules
                -class sparseml.onnx.optim.analyzer_model.ModelAnalyzer(model: Optional[Union[onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto, str]], nodes: Optional[List[sparseml.onnx.optim.analyzer_model.NodeAnalyzer]] = None)[source]
                +class sparseml.onnx.optim.analyzer_model.ModelAnalyzer(model: Optional[Union[onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto, str]], nodes: Optional[List[sparseml.onnx.optim.analyzer_model.NodeAnalyzer]] = None)[source]

                Bases: object

                Analyze a model to get the information for every node in the model including params, prunable, flops, etc

                @@ -242,7 +242,7 @@

                Submodules
                -dict() → Dict[str, Any][source]
                +dict()Dict[str, Any][source]
                Returns

                dictionary representation of the current instance

                @@ -252,7 +252,7 @@

                Submodules
                -static from_dict(dictionary: Dict[str, Any])[source]
                +static from_dict(dictionary: Dict[str, Any])[source]
                Parameters

                dictionary – the dictionary to create an analysis object from

                @@ -265,7 +265,7 @@

                Submodules
                -get_node(id_: str) → Union[None, sparseml.onnx.optim.analyzer_model.NodeAnalyzer][source]
                +get_node(id_: str)Union[None, sparseml.onnx.optim.analyzer_model.NodeAnalyzer][source]

                Get the NodeAnalyzer or the node matching the given id

                Parameters
                @@ -279,7 +279,7 @@

                Submodules
                -static load_json(path: str)[source]
                +static load_json(path: str)[source]
                Parameters

                path – the path to load a previous analysis from

                @@ -292,7 +292,7 @@

                Submodules
                -property nodes
                +property nodes

                list of analyzers for each node in the model graph

                Type
                @@ -303,7 +303,7 @@

                Submodules
                -save_json(path: str)[source]
                +save_json(path: str)[source]
                Parameters

                path – the path to save the json file at representing the analyzed @@ -316,7 +316,7 @@

                Submodules
                -class sparseml.onnx.optim.analyzer_model.NodeAnalyzer(model: Optional[onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto], node: Optional[Any], node_shape: Optional[sparseml.onnx.utils.helpers.NodeShape] = None, **kwargs)[source]
                +class sparseml.onnx.optim.analyzer_model.NodeAnalyzer(model: Optional[onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto], node: Optional[Any], node_shape: Optional[sparseml.onnx.utils.helpers.NodeShape] = None, **kwargs)[source]

                Bases: object

                Analyzer instance for an individual node in a model

                @@ -333,7 +333,7 @@

                Submodules
                -property attributes
                +property attributes

                any extra attributes for the node such as padding, stride, etc

                Type
                @@ -344,7 +344,7 @@

                Submodules
                -property bias_name
                +property bias_name

                name of the bias for the node if applicable

                Type
                @@ -355,7 +355,7 @@

                Submodules
                -property bias_shape
                +property bias_shape

                the shape of the bias for the node if applicable

                Type
                @@ -366,7 +366,7 @@

                Submodules
                -dict() → Dict[str, Any][source]
                +dict()Dict[str, Any][source]
                Returns

                dictionary representation of the current instance

                @@ -376,7 +376,7 @@

                Submodules
                -property flops
                +property flops

                number of flops to run the node

                Type
                @@ -387,7 +387,7 @@

                Submodules
                -property id_
                +property id_

                id of the onnx node (first output id)

                Type
                @@ -398,7 +398,7 @@

                Submodules
                -property input_names
                +property input_names

                the names of the inputs to the node

                Type
                @@ -409,7 +409,7 @@

                Submodules
                -property input_shapes
                +property input_shapes

                shapes for the inputs to the node

                Type
                @@ -420,7 +420,7 @@

                Submodules
                -property op_type
                +property op_type

                the operator type for the onnx node

                Type
                @@ -431,7 +431,7 @@

                Submodules
                -property output_names
                +property output_names

                the names of the outputs to the node

                Type
                @@ -442,7 +442,7 @@

                Submodules
                -property output_shapes
                +property output_shapes

                shapes for the outputs to the node

                Type
                @@ -453,7 +453,7 @@

                Submodules
                -property params
                +property params

                number of params in the node

                Type
                @@ -464,7 +464,7 @@

                Submodules
                -property prunable
                +property prunable

                True if the node is prunable (conv, gemm, etc), False otherwise

                Type
                @@ -475,7 +475,7 @@

                Submodules
                -property prunable_equation_sensitivity
                +property prunable_equation_sensitivity

                approximated sensitivity for the layer towards pruning based on the layer structure and params

                @@ -487,7 +487,7 @@

                Submodules
                -property prunable_params
                +property prunable_params

                number of prunable params in the node

                Type
                @@ -498,7 +498,7 @@

                Submodules
                -property prunable_params_zeroed
                +property prunable_params_zeroed

                number of prunable params set to zero in the node

                Type
                @@ -509,7 +509,7 @@

                Submodules
                -property weight_name
                +property weight_name

                the name of the weight for the node if applicable

                Type
                @@ -520,7 +520,7 @@

                Submodules
                -property weight_shape
                +property weight_shape

                the shape of the weight for the node if applicable

                Type
                @@ -537,13 +537,13 @@

                Submodules
                -class sparseml.onnx.optim.sensitivity_pruning.PruningLossSensitivityAnalysis[source]
                +class sparseml.onnx.optim.sensitivity_pruning.PruningLossSensitivityAnalysis[source]

                Bases: object

                Analysis result for how kernel sparsity (pruning) affects the loss of a given model. Contains layer by layer results.

                -add_result(id_: Optional[str], name: str, index: int, sparsity: float, measurement: float, baseline: bool)[source]
                +add_result(id_: Optional[str], name: str, index: int, sparsity: float, measurement: float, baseline: bool)[source]

                Add a result to the sensitivity analysis for a specific param

                Parameters
                @@ -561,7 +561,7 @@

                Submodules
                -dict() → Dict[str, Any][source]
                +dict()Dict[str, Any][source]
                Returns

                dictionary representation of the current instance

                @@ -571,7 +571,7 @@

                Submodules
                -static from_dict(dictionary: Dict[str, Any])[source]
                +static from_dict(dictionary: Dict[str, Any])[source]
                Parameters

                dictionary – the dictionary to create an analysis object from

                @@ -584,7 +584,7 @@

                Submodules
                -get_result(id_or_name: str)sparseml.optim.sensitivity.PruningSensitivityResult[source]
                +get_result(id_or_name: str)sparseml.optim.sensitivity.PruningSensitivityResult[source]

                get a result from the sensitivity analysis for a specific param

                Parameters
                @@ -598,7 +598,7 @@

                Submodules
                -static load_json(path: str)[source]
                +static load_json(path: str)[source]
                Parameters

                path – the path to load a previous analysis from

                @@ -611,7 +611,7 @@

                Submodules
                -plot(path: Optional[str], plot_integral: bool, normalize: bool = True, title: Optional[str] = None) → Union[Tuple[matplotlib.figure.Figure, matplotlib.axes._axes.Axes], Tuple[None, None]][source]
                +plot(path: Optional[str], plot_integral: bool, normalize: bool = True, title: Optional[str] = None)Union[Tuple[matplotlib.figure.Figure, matplotlib.axes._axes.Axes], Tuple[None, None]][source]
                Parameters
                -property results
                +property results

                the individual results for the analysis

                Type
                @@ -648,7 +648,7 @@

                Submodules
                -property results_model
                +property results_model

                the overall results for the model

                Type
                @@ -659,7 +659,7 @@

                Submodules
                -save_json(path: str)[source]
                +save_json(path: str)[source]
                Parameters

                path – the path to save the json file at representing the layer @@ -672,7 +672,7 @@

                Submodules
                -class sparseml.onnx.optim.sensitivity_pruning.PruningPerfSensitivityAnalysis(num_cores: int, batch_size: int)[source]
                +class sparseml.onnx.optim.sensitivity_pruning.PruningPerfSensitivityAnalysis(num_cores: int, batch_size: int)[source]

                Bases: object

                Analysis result for how kernel sparsity (pruning) affects the loss of a given model. Contains layer by layer results.

                @@ -686,7 +686,7 @@

                Submodules
                -add_model_result(sparsity: float, measurement: float, baseline: bool)[source]
                +add_model_result(sparsity: float, measurement: float, baseline: bool)[source]

                Add a result to the sensitivity analysis for the overall model

                Parameters
                @@ -702,7 +702,7 @@

                Submodules
                -add_result(id_: Optional[str], name: str, index: int, sparsity: float, measurement: float, baseline: bool)[source]
                +add_result(id_: Optional[str], name: str, index: int, sparsity: float, measurement: float, baseline: bool)[source]

                Add a result to the sensitivity analysis for a specific param

                Parameters
                @@ -721,7 +721,7 @@

                Submodules
                -property batch_size
                +property batch_size

                the input batch size the analysis was run for

                Type
                @@ -732,7 +732,7 @@

                Submodules
                -dict() → Dict[str, Any][source]
                +dict()Dict[str, Any][source]
                Returns

                dictionary representation of the current instance

                @@ -742,7 +742,7 @@

                Submodules
                -static from_dict(dictionary: Dict[str, Any])[source]
                +static from_dict(dictionary: Dict[str, Any])[source]
                Parameters

                dictionary – the dictionary to create an analysis object from

                @@ -755,7 +755,7 @@

                Submodules
                -get_result(id_or_name: str)sparseml.optim.sensitivity.PruningSensitivityResult[source]
                +get_result(id_or_name: str)sparseml.optim.sensitivity.PruningSensitivityResult[source]

                get a result from the sensitivity analysis for a specific param

                Parameters
                @@ -769,7 +769,7 @@

                Submodules
                -static load_json(path: str)[source]
                +static load_json(path: str)[source]
                Parameters

                path – the path to load a previous analysis from

                @@ -782,7 +782,7 @@

                Submodules
                -property num_cores
                +property num_cores

                number of physical cpu cores the analysis was run on

                Type
                @@ -793,7 +793,7 @@

                Submodules
                -plot(path: Optional[str], title: Optional[str] = None) → Union[Tuple[matplotlib.figure.Figure, matplotlib.axes._axes.Axes], Tuple[None, None]][source]
                +plot(path: Optional[str], title: Optional[str] = None)Union[Tuple[matplotlib.figure.Figure, matplotlib.axes._axes.Axes], Tuple[None, None]][source]
                Parameters
                -property results
                +property results

                the individual results for the analysis

                Type
                @@ -827,7 +827,7 @@

                Submodules
                -property results_model
                +property results_model

                the overall results for the model

                Type
                @@ -838,7 +838,7 @@

                Submodules
                -save_json(path: str)[source]
                +save_json(path: str)[source]
                Parameters

                path – the path to save the json file at representing the layer @@ -851,7 +851,7 @@

                Submodules
                -class sparseml.onnx.optim.sensitivity_pruning.PruningSensitivityResult(id_: str, name: str, index: int, baseline_measurement_index: int = - 1, baseline_measurement_key: Optional[str] = None, sparse_measurements: Optional[Dict[float, List[float]]] = None)[source]
                +class sparseml.onnx.optim.sensitivity_pruning.PruningSensitivityResult(id_: str, name: str, index: int, baseline_measurement_index: int = - 1, baseline_measurement_key: Optional[str] = None, sparse_measurements: Optional[Dict[float, List[float]]] = None)[source]

                Bases: object

                A sensitivity result for a given node/param in a model. Ex: loss sensitivity or perf sensitivity

                @@ -869,7 +869,7 @@

                Submodules
                -add_measurement(sparsity: float, loss: float, baseline: bool)[source]
                +add_measurement(sparsity: float, loss: float, baseline: bool)[source]

                add a sparse measurement to the result

                Parameters
                @@ -884,7 +884,7 @@

                Submodules
                -property averages
                +property averages

                average values of loss for each level recorded

                Type
                @@ -895,7 +895,7 @@

                Submodules
                -property baseline_average
                +property baseline_average

                the baseline average time to compare to for the result

                Type
                @@ -906,7 +906,7 @@

                Submodules
                -property baseline_measurement_index
                +property baseline_measurement_index

                index for where the baseline measurement is stored in the sparse_measurements, if any

                @@ -918,7 +918,7 @@

                Submodules
                -property baseline_measurement_key
                +property baseline_measurement_key

                key for where the baseline measurement is stored in the sparse_measurements, if any

                @@ -930,7 +930,7 @@

                Submodules
                -dict() → Dict[str, Any][source]
                +dict()Dict[str, Any][source]
                Returns

                dictionary representation of the current instance

                @@ -940,7 +940,7 @@

                Submodules
                -static from_dict(dictionary: Dict[str, Any])[source]
                +static from_dict(dictionary: Dict[str, Any])[source]

                Create a new loss sensitivity result from a dictionary of values. Expected to match the format as given in the dict() call.

                @@ -955,7 +955,7 @@

                Submodules
                -property has_baseline
                +property has_baseline

                True if the result has a baseline measurement in the sparse_measurements, False otherwise

                @@ -967,7 +967,7 @@

                Submodules
                -property id_
                +property id_

                id for the node / param

                Type
                @@ -978,7 +978,7 @@

                Submodules
                -property index
                +property index

                index order for when the node / param is used in the model

                Type
                @@ -989,7 +989,7 @@

                Submodules
                -property name
                +property name

                human readable name for the node / param

                Type
                @@ -1000,7 +1000,7 @@

                Submodules
                -property sparse_average
                +property sparse_average

                average loss across all levels recorded

                Type
                @@ -1011,7 +1011,7 @@

                Submodules
                -sparse_comparison(compare_index: int = - 1)[source]
                +sparse_comparison(compare_index: int = - 1)[source]

                Compare the baseline average to a sparse average value through the difference: sparse - baseline

                If compare_index is not given then will compare @@ -1033,7 +1033,7 @@

                Submodules
                -property sparse_integral
                +property sparse_integral

                integrated loss across all levels recorded

                Type
                @@ -1044,7 +1044,7 @@

                Submodules
                -property sparse_measurements
                +property sparse_measurements

                the sparse measurements

                Type
                @@ -1057,7 +1057,7 @@

                Submodules
                -sparseml.onnx.optim.sensitivity_pruning.pruning_loss_sens_approx(input_shape: Union[None, List[int], List[List[int]]], output_shape: Union[None, List[int]], params: int, apply_shape_change_mult: bool = True) → float[source]
                +sparseml.onnx.optim.sensitivity_pruning.pruning_loss_sens_approx(input_shape: Union[None, List[int], List[List[int]]], output_shape: Union[None, List[int]], params: int, apply_shape_change_mult: bool = True)float[source]

                Approximate the pruning sensitivity of a Neural Network’s layer based on the params and metadata for a given layer

                @@ -1079,7 +1079,7 @@

                Submodules
                -sparseml.onnx.optim.sensitivity_pruning.pruning_loss_sens_magnitude(model: Union[str, onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto], sparsity_levels: Union[List[float], Tuple[float, ]] = (0.0, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.2, 0.21, 0.22, 0.23, 0.24, 0.25, 0.26, 0.27, 0.28, 0.29, 0.3, 0.31, 0.32, 0.33, 0.34, 0.35, 0.36, 0.37, 0.38, 0.39, 0.4, 0.41, 0.42, 0.43, 0.44, 0.45, 0.46, 0.47, 0.48, 0.49, 0.5, 0.51, 0.52, 0.53, 0.54, 0.55, 0.56, 0.57, 0.58, 0.59, 0.6, 0.61, 0.62, 0.63, 0.64, 0.65, 0.66, 0.67, 0.68, 0.69, 0.7, 0.71, 0.72, 0.73, 0.74, 0.75, 0.76, 0.77, 0.78, 0.79, 0.8, 0.81, 0.82, 0.83, 0.84, 0.85, 0.86, 0.87, 0.88, 0.89, 0.9, 0.91, 0.92, 0.93, 0.94, 0.95, 0.96, 0.97, 0.98, 0.99), show_progress: bool = True)sparseml.optim.sensitivity.PruningLossSensitivityAnalysis[source]
                +sparseml.onnx.optim.sensitivity_pruning.pruning_loss_sens_magnitude(model: Union[str, onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto], sparsity_levels: Union[List[float], Tuple[float, ]] = (0.0, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.2, 0.21, 0.22, 0.23, 0.24, 0.25, 0.26, 0.27, 0.28, 0.29, 0.3, 0.31, 0.32, 0.33, 0.34, 0.35, 0.36, 0.37, 0.38, 0.39, 0.4, 0.41, 0.42, 0.43, 0.44, 0.45, 0.46, 0.47, 0.48, 0.49, 0.5, 0.51, 0.52, 0.53, 0.54, 0.55, 0.56, 0.57, 0.58, 0.59, 0.6, 0.61, 0.62, 0.63, 0.64, 0.65, 0.66, 0.67, 0.68, 0.69, 0.7, 0.71, 0.72, 0.73, 0.74, 0.75, 0.76, 0.77, 0.78, 0.79, 0.8, 0.81, 0.82, 0.83, 0.84, 0.85, 0.86, 0.87, 0.88, 0.89, 0.9, 0.91, 0.92, 0.93, 0.94, 0.95, 0.96, 0.97, 0.98, 0.99), show_progress: bool = True)sparseml.optim.sensitivity.PruningLossSensitivityAnalysis[source]

                Approximated kernel sparsity (pruning) loss analysis for a given model. Returns the results for each prunable param (conv, linear) in the model.

                @@ -1099,7 +1099,7 @@

                Submodules
                -sparseml.onnx.optim.sensitivity_pruning.pruning_loss_sens_magnitude_iter(model: Union[str, onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto], sparsity_levels: Union[List[float], Tuple[float, ]] = (0.0, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.2, 0.21, 0.22, 0.23, 0.24, 0.25, 0.26, 0.27, 0.28, 0.29, 0.3, 0.31, 0.32, 0.33, 0.34, 0.35, 0.36, 0.37, 0.38, 0.39, 0.4, 0.41, 0.42, 0.43, 0.44, 0.45, 0.46, 0.47, 0.48, 0.49, 0.5, 0.51, 0.52, 0.53, 0.54, 0.55, 0.56, 0.57, 0.58, 0.59, 0.6, 0.61, 0.62, 0.63, 0.64, 0.65, 0.66, 0.67, 0.68, 0.69, 0.7, 0.71, 0.72, 0.73, 0.74, 0.75, 0.76, 0.77, 0.78, 0.79, 0.8, 0.81, 0.82, 0.83, 0.84, 0.85, 0.86, 0.87, 0.88, 0.89, 0.9, 0.91, 0.92, 0.93, 0.94, 0.95, 0.96, 0.97, 0.98, 0.99)) → Generator[Tuple[sparseml.optim.sensitivity.PruningLossSensitivityAnalysis, sparseml.onnx.optim.sensitivity_pruning.KSSensitivityProgress], None, None][source]
                +sparseml.onnx.optim.sensitivity_pruning.pruning_loss_sens_magnitude_iter(model: Union[str, onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto], sparsity_levels: Union[List[float], Tuple[float, ]] = (0.0, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.2, 0.21, 0.22, 0.23, 0.24, 0.25, 0.26, 0.27, 0.28, 0.29, 0.3, 0.31, 0.32, 0.33, 0.34, 0.35, 0.36, 0.37, 0.38, 0.39, 0.4, 0.41, 0.42, 0.43, 0.44, 0.45, 0.46, 0.47, 0.48, 0.49, 0.5, 0.51, 0.52, 0.53, 0.54, 0.55, 0.56, 0.57, 0.58, 0.59, 0.6, 0.61, 0.62, 0.63, 0.64, 0.65, 0.66, 0.67, 0.68, 0.69, 0.7, 0.71, 0.72, 0.73, 0.74, 0.75, 0.76, 0.77, 0.78, 0.79, 0.8, 0.81, 0.82, 0.83, 0.84, 0.85, 0.86, 0.87, 0.88, 0.89, 0.9, 0.91, 0.92, 0.93, 0.94, 0.95, 0.96, 0.97, 0.98, 0.99))Generator[Tuple[sparseml.optim.sensitivity.PruningLossSensitivityAnalysis, sparseml.onnx.optim.sensitivity_pruning.KSSensitivityProgress], None, None][source]

                Approximated kernel sparsity (pruning) loss analysis for a given model. Iteratively builds a KSLossSensitivityAnalysis object and yields an updated version after each layer is run. The final result is the complete @@ -1121,7 +1121,7 @@

                Submodules
                -sparseml.onnx.optim.sensitivity_pruning.pruning_loss_sens_one_shot(model: Union[str, onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto], data: sparseml.onnx.utils.data.DataLoader, batch_size: int, steps_per_measurement: int, sparsity_levels: List[float] = (0.0, 0.2, 0.4, 0.6, 0.7, 0.8, 0.85, 0.9, 0.95, 0.99), show_progress: bool = True, use_deepsparse_inference: bool = False)sparseml.optim.sensitivity.PruningLossSensitivityAnalysis[source]
                +sparseml.onnx.optim.sensitivity_pruning.pruning_loss_sens_one_shot(model: Union[str, onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto], data: sparseml.onnx.utils.data.DataLoader, batch_size: int, steps_per_measurement: int, sparsity_levels: List[float] = (0.0, 0.2, 0.4, 0.6, 0.7, 0.8, 0.85, 0.9, 0.95, 0.99), show_progress: bool = True, use_deepsparse_inference: bool = False)sparseml.optim.sensitivity.PruningLossSensitivityAnalysis[source]

                Run a one shot sensitivity analysis for kernel sparsity. It does not retrain,. Moves layer by layer to calculate the sensitivity analysis for each and @@ -1151,7 +1151,7 @@

                Submodules
                -sparseml.onnx.optim.sensitivity_pruning.pruning_loss_sens_one_shot_iter(model: Union[str, onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto], data: sparseml.onnx.utils.data.DataLoader, batch_size: int, steps_per_measurement: int, sparsity_levels: List[float] = (0.0, 0.2, 0.4, 0.6, 0.7, 0.8, 0.85, 0.9, 0.95, 0.99), use_deepsparse_inference: bool = False) → Generator[Tuple[sparseml.optim.sensitivity.PruningLossSensitivityAnalysis, sparseml.onnx.optim.sensitivity_pruning.KSSensitivityProgress], None, None][source]
                +sparseml.onnx.optim.sensitivity_pruning.pruning_loss_sens_one_shot_iter(model: Union[str, onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto], data: sparseml.onnx.utils.data.DataLoader, batch_size: int, steps_per_measurement: int, sparsity_levels: List[float] = (0.0, 0.2, 0.4, 0.6, 0.7, 0.8, 0.85, 0.9, 0.95, 0.99), use_deepsparse_inference: bool = False)Generator[Tuple[sparseml.optim.sensitivity.PruningLossSensitivityAnalysis, sparseml.onnx.optim.sensitivity_pruning.KSSensitivityProgress], None, None][source]

                Run a one shot sensitivity analysis for kernel sparsity. It does not retrain. Moves layer by layer to calculate the sensitivity analysis for each and @@ -1182,7 +1182,7 @@

                Submodules
                -sparseml.onnx.optim.sensitivity_pruning.pruning_perf_sens_one_shot(model: Union[str, onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto], data: sparseml.onnx.utils.data.DataLoader, batch_size: int, num_cores: Optional[int] = None, iterations_per_check: int = 10, warmup_iterations_per_check: int = 5, sparsity_levels: List[float] = (0.0, 0.4, 0.6, 0.7, 0.8, 0.85, 0.9, 0.95, 0.975, 0.99), show_progress: bool = True, wait_between_iters: bool = False)sparseml.optim.sensitivity.PruningPerfSensitivityAnalysis[source]
                +sparseml.onnx.optim.sensitivity_pruning.pruning_perf_sens_one_shot(model: Union[str, onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto], data: sparseml.onnx.utils.data.DataLoader, batch_size: int, num_cores: Optional[int] = None, iterations_per_check: int = 10, warmup_iterations_per_check: int = 5, sparsity_levels: List[float] = (0.0, 0.4, 0.6, 0.7, 0.8, 0.85, 0.9, 0.95, 0.975, 0.99), show_progress: bool = True, wait_between_iters: bool = False)sparseml.optim.sensitivity.PruningPerfSensitivityAnalysis[source]

                Run a one shot sensitivity analysis for kernel sparsity. Runs a baseline and then sets the sparsity for each layer to a given range of values as defined in sparsity_levels to measure their performance for pruning.

                @@ -1211,7 +1211,7 @@

                Submodules
                -sparseml.onnx.optim.sensitivity_pruning.pruning_perf_sens_one_shot_iter(model: Union[str, onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto], data: sparseml.onnx.utils.data.DataLoader, batch_size: int, num_cores: Optional[int] = None, iterations_per_check: int = 10, warmup_iterations_per_check: int = 5, sparsity_levels: List[float] = (0.0, 0.4, 0.6, 0.7, 0.8, 0.85, 0.9, 0.95, 0.975, 0.99), optimization_level: int = 0, iters_sleep_time: float = - 1) → Generator[Tuple[sparseml.optim.sensitivity.PruningPerfSensitivityAnalysis, sparseml.onnx.optim.sensitivity_pruning.KSSensitivityProgress], None, None][source]
                +sparseml.onnx.optim.sensitivity_pruning.pruning_perf_sens_one_shot_iter(model: Union[str, onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto], data: sparseml.onnx.utils.data.DataLoader, batch_size: int, num_cores: Optional[int] = None, iterations_per_check: int = 10, warmup_iterations_per_check: int = 5, sparsity_levels: List[float] = (0.0, 0.4, 0.6, 0.7, 0.8, 0.85, 0.9, 0.95, 0.975, 0.99), optimization_level: int = 0, iters_sleep_time: float = - 1)Generator[Tuple[sparseml.optim.sensitivity.PruningPerfSensitivityAnalysis, sparseml.onnx.optim.sensitivity_pruning.KSSensitivityProgress], None, None][source]

                Run a one shot sensitivity analysis for kernel sparsity. Runs a baseline and then sets the sparsity for each layer to a given range of values as defined in sparsity_levels to measure their performance for pruning. diff --git a/sparseml/api/sparseml.onnx.optim.quantization.html b/sparseml/api/sparseml.onnx.optim.quantization.html index 560f13e9f95..a142abc6709 100644 --- a/sparseml/api/sparseml.onnx.optim.quantization.html +++ b/sparseml/api/sparseml.onnx.optim.quantization.html @@ -212,7 +212,7 @@

                Submodules
                -class sparseml.onnx.optim.quantization.calibration.CalibrationSession(onnx_file: str, calibrate_op_types: Iterable[str] = ('Conv', 'MatMul', 'Gemm'), exclude_nodes: Optional[List[str]] = None, include_nodes: Optional[List[str]] = None, augmented_model_path: Optional[str] = None, static: bool = True)[source]
                +class sparseml.onnx.optim.quantization.calibration.CalibrationSession(onnx_file: str, calibrate_op_types: Iterable[str] = ('Conv', 'MatMul', 'Gemm'), exclude_nodes: Optional[List[str]] = None, include_nodes: Optional[List[str]] = None, augmented_model_path: Optional[str] = None, static: bool = True)[source]

                Bases: object

                Class for performing quantization calibration on an Onnx model.

                @@ -230,7 +230,7 @@

                Submodules
                -add_reduce_to_node_output(node: onnx.onnx_ONNX_REL_1_6_ml_pb2.NodeProto, output_edge: str, op_type: str) → Tuple[onnx.onnx_ONNX_REL_1_6_ml_pb2.NodeProto, onnx.onnx_ONNX_REL_1_6_ml_pb2.ValueInfoProto][source]
                +add_reduce_to_node_output(node: onnx.onnx_ONNX_REL_1_7_ml_pb2.NodeProto, output_edge: str, op_type: str)Tuple[onnx.onnx_ONNX_REL_1_7_ml_pb2.NodeProto, onnx.onnx_ONNX_REL_1_7_ml_pb2.ValueInfoProto][source]
                Parameters
                  @@ -247,7 +247,7 @@

                  Submodules
                  -generate_augmented_model() → onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto[source]
                  +generate_augmented_model()onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto[source]
                  return: A new Onnx model with ReduceMin and ReduceMax nodes added to all

                  quantizable nodes in the original model and ensures their outputs are stored as part of the graph output.

                  @@ -257,7 +257,7 @@

                  Submodules
                  -get_model_input_names() → List[str][source]
                  +get_model_input_names()List[str][source]
                  Returns

                  List of input names to the model

                  @@ -267,7 +267,7 @@

                  Submodules
                  -get_quantization_params_dict() → Dict[str, List[Union[int, float]]][source]
                  +get_quantization_params_dict()Dict[str, List[Union[int, float]]][source]
                  Returns

                  A dictionary of quantization parameters based on the original @@ -280,7 +280,7 @@

                  Submodules
                  -property model
                  +property model

                  The loaded model, if optimization has run, will be the optimized version

                  @@ -292,7 +292,7 @@

                  Submodules
                  -property model_augmented
                  +property model_augmented

                  The augmented model, if optimization has run, will be the optimized version

                  @@ -304,7 +304,7 @@

                  Submodules
                  -process_batch(input_batch: Dict[str, numpy.ndarray]) → None[source]
                  +process_batch(input_batch: Dict[str, numpy.ndarray])None[source]

                  Updates the model’s calibration thresholds based on a run of the input batch

                  Parameters
                  @@ -321,11 +321,11 @@

                  Submodules

                  sparseml.onnx.optim.quantization.quantize module

                  -class sparseml.onnx.optim.quantization.quantize.ONNXQuantizer(model, per_channel, mode, static, fuse_dynamic_quant, weight_qType, input_qType, quantization_params, nodes_to_quantize, nodes_to_exclude)[source]
                  +class sparseml.onnx.optim.quantization.quantize.ONNXQuantizer(model, per_channel, mode, static, fuse_dynamic_quant, weight_qType, input_qType, quantization_params, nodes_to_quantize, nodes_to_exclude)[source]

                  Bases: object

                  -find_weight_data(initializer)[source]
                  +find_weight_data(initializer)[source]
                  Parameters

                  initializer – TensorProto initializer object from a graph

                  @@ -338,60 +338,60 @@

                  Submodules
                  -quantize_model()[source]
                  +quantize_model()[source]

                  -class sparseml.onnx.optim.quantization.quantize.QuantizationMode[source]
                  +class sparseml.onnx.optim.quantization.quantize.QuantizationMode[source]

                  Bases: object

                  -IntegerOps = 0
                  +IntegerOps = 0
                  -QLinearOps = 1
                  +QLinearOps = 1
                  -class sparseml.onnx.optim.quantization.quantize.QuantizedInitializer(name, initializer, rmins, rmaxs, zero_points, scales, data=[], quantized_data=[], axis=None, qType=2)[source]
                  +class sparseml.onnx.optim.quantization.quantize.QuantizedInitializer(name, initializer, rmins, rmaxs, zero_points, scales, data=[], quantized_data=[], axis=None, qType=2)[source]

                  Bases: object

                  Represents a linearly quantized weight input from ONNX operators

                  -class sparseml.onnx.optim.quantization.quantize.QuantizedValue(name, new_quantized_name, scale_name, zero_point_name, quantized_value_type, axis=None, qType=2)[source]
                  +class sparseml.onnx.optim.quantization.quantize.QuantizedValue(name, new_quantized_name, scale_name, zero_point_name, quantized_value_type, axis=None, qType=2)[source]

                  Bases: object

                  Represents a linearly quantized value (input/output/intializer)

                  -class sparseml.onnx.optim.quantization.quantize.QuantizedValueType[source]
                  +class sparseml.onnx.optim.quantization.quantize.QuantizedValueType[source]

                  Bases: object

                  -Initializer = 1
                  +Initializer = 1
                  -Input = 0
                  +Input = 0
                  -sparseml.onnx.optim.quantization.quantize.check_opset_version(org_model, force_fusions)[source]
                  +sparseml.onnx.optim.quantization.quantize.check_opset_version(org_model, force_fusions)[source]

                  Check opset version of original model and set opset version and fuse_dynamic_quant accordingly. If opset version < 10, set quantized model opset version to 10. If opset version == 10, do quantization without using dynamicQuantizeLinear operator. @@ -401,7 +401,7 @@

                  Submodules
                  -sparseml.onnx.optim.quantization.quantize.quantize(model, per_channel=False, nbits=8, quantization_mode=0, static=False, force_fusions=False, symmetric_activation=False, symmetric_weight=False, quantization_params=None, nodes_to_quantize=None, nodes_to_exclude=None)[source]
                  +sparseml.onnx.optim.quantization.quantize.quantize(model, per_channel=False, nbits=8, quantization_mode=0, static=False, force_fusions=False, symmetric_activation=False, symmetric_weight=False, quantization_params=None, nodes_to_quantize=None, nodes_to_exclude=None)[source]

                  Given an onnx model, create a quantized onnx model and save it into a file

                  @@ -478,7 +478,7 @@

                  Submodules
                  -sparseml.onnx.optim.quantization.quantize.quantize_data(data, quantize_range, qType)[source]
                  +sparseml.onnx.optim.quantization.quantize.quantize_data(data, quantize_range, qType)[source]
                  Parameters
                    @@ -518,7 +518,7 @@

                    Submodules
                    -sparseml.onnx.optim.quantization.quantize_model_post_training.quantize_model_post_training(onnx_file: str, data_loader: sparseml.onnx.utils.data.DataLoader, output_model_path: Optional[str] = None, calibrate_op_types: Iterable[str] = ('Conv', 'MatMul', 'Gemm'), exclude_nodes: Optional[List[str]] = None, include_nodes: Optional[List[str]] = None, augmented_model_path: Optional[str] = None, static: bool = True, symmetric_weight: bool = False, force_fusions: bool = False, show_progress: bool = True, run_extra_opt: bool = True) → Union[None, onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto][source]
                    +sparseml.onnx.optim.quantization.quantize_model_post_training.quantize_model_post_training(onnx_file: str, data_loader: sparseml.onnx.utils.data.DataLoader, output_model_path: Optional[str] = None, calibrate_op_types: Iterable[str] = ('Conv', 'MatMul', 'Gemm'), exclude_nodes: Optional[List[str]] = None, include_nodes: Optional[List[str]] = None, augmented_model_path: Optional[str] = None, static: bool = True, symmetric_weight: bool = False, force_fusions: bool = False, show_progress: bool = True, run_extra_opt: bool = True)Union[None, onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto][source]

                    Wrapper function for calibrating and quantizing an Onnx model

                    Parameters
                    diff --git a/sparseml/api/sparseml.onnx.utils.html b/sparseml/api/sparseml.onnx.utils.html index 857f35517e8..7fcd6399f06 100644 --- a/sparseml/api/sparseml.onnx.utils.html +++ b/sparseml/api/sparseml.onnx.utils.html @@ -210,7 +210,7 @@

                    Submodules
                    -class sparseml.onnx.utils.data.DataLoader(data: Union[str, List[Dict[str, numpy.ndarray]]], labels: Union[None, str, List[Union[numpy.ndarray, Dict[str, numpy.ndarray]]]], batch_size: int, iter_steps: int = 0)[source]
                    +class sparseml.onnx.utils.data.DataLoader(data: Union[str, List[Dict[str, numpy.ndarray]]], labels: Union[None, str, List[Union[numpy.ndarray, Dict[str, numpy.ndarray]]]], batch_size: int, iter_steps: int = 0)[source]

                    Bases: object

                    Data loader instance that supports loading numpy arrays from file or memory and creating an iterator to go through batches of that data.

                    @@ -232,7 +232,7 @@

                    Submodules
                    -property batch_size
                    +property batch_size

                    the size of batches to create for the iterator

                    Type
                    @@ -243,7 +243,7 @@

                    Submodules
                    -static from_model_random(model: Union[str, onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto], batch_size: int, iter_steps: int = 0, num_samples: int = 100, create_labels: bool = False, strip_first_dim: bool = True)[source]
                    +static from_model_random(model: Union[str, onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto], batch_size: int, iter_steps: int = 0, num_samples: int = 100, create_labels: bool = False, strip_first_dim: bool = True)[source]

                    Create a DataLoader from random data for a model’s input and output sizes

                    Parameters
                    @@ -268,7 +268,7 @@

                    Submodules
                    -static from_random(data_shapes: Dict[str, Tuple[int, ]], label_shapes: Union[None, Dict[str, Tuple[int, ]]], batch_size: int, iter_steps: int = 0, num_samples: int = 100, data_types: Optional[Dict[str, numpy.dtype]] = None)[source]
                    +static from_random(data_shapes: Dict[str, Tuple[int, ]], label_shapes: Union[None, Dict[str, Tuple[int, ]]], batch_size: int, iter_steps: int = 0, num_samples: int = 100, data_types: Optional[Dict[str, numpy.dtype]] = None)[source]

                    Create a DataLoader from random data

                    Parameters
                    @@ -291,7 +291,7 @@

                    Submodules
                    -property infinite
                    +property infinite

                    True if the loader instance is setup to continually create batches, False otherwise

                    @@ -303,7 +303,7 @@

                    Submodules
                    -property iter_steps
                    +property iter_steps

                    the number of steps (batches) to create. Set to -1 for infinite, 0 for running through the loaded data once, or a positive integer for the desired number of steps

                    @@ -316,7 +316,7 @@

                    Submodules
                    -property labeled_data
                    +property labeled_data

                    the loaded data and labels

                    Type
                    @@ -333,7 +333,7 @@

                    Submodules
                    -sparseml.onnx.utils.graph_editor.override_model_batch_size(model: onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto, batch_size: int) → onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto[source]
                    +sparseml.onnx.utils.graph_editor.override_model_batch_size(model: onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto, batch_size: int)onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto[source]

                    Rewrites any positive batch dimensions in the model inputs or outputs to the given batch_size

                    @@ -352,7 +352,7 @@

                    Submodules
                    -sparseml.onnx.utils.graph_editor.prune_model_one_shot(model: onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto, nodes: List[onnx.onnx_ONNX_REL_1_6_ml_pb2.NodeProto], sparsity: Union[float, List[float]])[source]
                    +sparseml.onnx.utils.graph_editor.prune_model_one_shot(model: onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto, nodes: List[onnx.onnx_ONNX_REL_1_7_ml_pb2.NodeProto], sparsity: Union[float, List[float]])[source]

                    Prune a model in-place with one shot pruning (no retraining) according to magnitude pruning. Does so in an unstructured way currently

                    @@ -372,7 +372,7 @@

                    Submodules
                    -sparseml.onnx.utils.graph_editor.prune_model_one_shot_iter(model: onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto, nodes: List[onnx.onnx_ONNX_REL_1_6_ml_pb2.NodeProto], sparsity: Union[float, List[float]])[source]
                    +sparseml.onnx.utils.graph_editor.prune_model_one_shot_iter(model: onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto, nodes: List[onnx.onnx_ONNX_REL_1_7_ml_pb2.NodeProto], sparsity: Union[float, List[float]])[source]

                    Iteratively prune a model in-place with one shot pruning (no retraining) according to magnitude pruning. Does so in an unstructured way currently

                    @@ -389,7 +389,7 @@

                    Submodules
                    -sparseml.onnx.utils.graph_editor.prune_unstructured(array: numpy.ndarray, sparsity: float) → numpy.ndarray[source]
                    +sparseml.onnx.utils.graph_editor.prune_unstructured(array: numpy.ndarray, sparsity: float)numpy.ndarray[source]

                    Prune a numpy array with unstructured sparsity according to magnitude pruning

                    Parameters
                    @@ -407,7 +407,7 @@

                    Submodules
                    -sparseml.onnx.utils.graph_editor.remove_node_and_params_from_graph(model: onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto, node: onnx.onnx_ONNX_REL_1_6_ml_pb2.NodeProto, keep_params: Optional[Iterable[str]] = None) → None[source]
                    +sparseml.onnx.utils.graph_editor.remove_node_and_params_from_graph(model: onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto, node: onnx.onnx_ONNX_REL_1_7_ml_pb2.NodeProto, keep_params: Optional[Iterable[str]] = None)None[source]

                    Deletes a node from the mdoel graph as well as its parameters listed in node.input

                    Parameters
                    @@ -423,7 +423,7 @@

                    Submodules
                    -sparseml.onnx.utils.graph_editor.swap_node_output(node: onnx.onnx_ONNX_REL_1_6_ml_pb2.NodeProto, output: str) → None[source]
                    +sparseml.onnx.utils.graph_editor.swap_node_output(node: onnx.onnx_ONNX_REL_1_7_ml_pb2.NodeProto, output: str)None[source]

                    Deletes the current output of the node and replaces it with the provided value Assumes that the node only has one output

                    @@ -438,7 +438,7 @@

                    Submodules
                    -sparseml.onnx.utils.graph_editor.update_model_param(model: onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto, param_name: str, val: numpy.ndarray) → None[source]
                    +sparseml.onnx.utils.graph_editor.update_model_param(model: onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto, param_name: str, val: numpy.ndarray)None[source]

                    Removes the parameter with name param_name from the model Creates a new parameter using val Adds val to the model with name param_name as an update

                    @@ -459,7 +459,7 @@

                    Submodules
                    -sparseml.onnx.utils.graph_optimizer.fold_conv_bns(onnx_file: str) → onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto[source]
                    +sparseml.onnx.utils.graph_optimizer.fold_conv_bns(onnx_file: str)onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto[source]

                    When a batch norm op is the only child operator of a conv op, this function will fold the batch norm into the conv and return the processed graph

                    @@ -475,7 +475,7 @@

                    Submodules
                    -sparseml.onnx.utils.graph_optimizer.quantize_resnet_identity_add_inputs(quantized_model: onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto) → bool[source]
                    +sparseml.onnx.utils.graph_optimizer.quantize_resnet_identity_add_inputs(quantized_model: onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto)bool[source]

                    To avoid storing the identity value of a ResNet block in fp32, this optimization will pass the identity value through the same quantize operation as the ResNet block and add a de-quantize operation for the identity before the add.

                    @@ -498,41 +498,41 @@

                    Submodules
                    -class sparseml.onnx.utils.helpers.BatchNormParams(epsilon, momentum, scale, bias, mean, var)
                    +class sparseml.onnx.utils.helpers.BatchNormParams(epsilon, momentum, scale, bias, mean, var)

                    Bases: tuple

                    -property bias
                    +property bias

                    Alias for field number 3

                    -property epsilon
                    +property epsilon

                    Alias for field number 0

                    -property mean
                    +property mean

                    Alias for field number 4

                    -property momentum
                    +property momentum

                    Alias for field number 1

                    -property scale
                    +property scale

                    Alias for field number 2

                    -property var
                    +property var

                    Alias for field number 5

                    @@ -540,17 +540,17 @@

                    Submodules
                    -class sparseml.onnx.utils.helpers.NodeParam(name, val)
                    +class sparseml.onnx.utils.helpers.NodeParam(name, val)

                    Bases: tuple

                    -property name
                    +property name

                    Alias for field number 0

                    -property val
                    +property val

                    Alias for field number 1

                    @@ -558,23 +558,23 @@

                    Submodules
                    -class sparseml.onnx.utils.helpers.NodeShape(id, input_shapes, output_shapes)
                    +class sparseml.onnx.utils.helpers.NodeShape(id, input_shapes, output_shapes)

                    Bases: tuple

                    -property id
                    +property id

                    Alias for field number 0

                    -property input_shapes
                    +property input_shapes

                    Alias for field number 1

                    -property output_shapes
                    +property output_shapes

                    Alias for field number 2

                    @@ -582,35 +582,35 @@

                    Submodules
                    -class sparseml.onnx.utils.helpers.SparsityMeasurement(node_id, params_count, params_zero_count, sparsity, density)
                    +class sparseml.onnx.utils.helpers.SparsityMeasurement(node_id, params_count, params_zero_count, sparsity, density)

                    Bases: tuple

                    -property density
                    +property density

                    Alias for field number 4

                    -property node_id
                    +property node_id

                    Alias for field number 0

                    -property params_count
                    +property params_count

                    Alias for field number 1

                    -property params_zero_count
                    +property params_zero_count

                    Alias for field number 2

                    -property sparsity
                    +property sparsity

                    Alias for field number 3

                    @@ -618,7 +618,7 @@

                    Submodules
                    -sparseml.onnx.utils.helpers.calculate_flops(op_type: str, input_shape: Optional[List[List]] = None, output_shape: Optional[List[List]] = None, weight_shape: Optional[List] = None, kernel_shape: Optional[List] = None, bias_shape: Optional[List] = None, attributes: Union[None, Dict[str, Any]] = None) → Optional[float][source]
                    +sparseml.onnx.utils.helpers.calculate_flops(op_type: str, input_shape: Optional[List[List]] = None, output_shape: Optional[List[List]] = None, weight_shape: Optional[List] = None, kernel_shape: Optional[List] = None, bias_shape: Optional[List] = None, attributes: Union[None, Dict[str, Any]] = None)Optional[float][source]

                    Calculate flops based on operation type and shape of certain attributes. If any fields necessary in operation are set to None, will return None

                    @@ -641,7 +641,7 @@

                    Submodules
                    -sparseml.onnx.utils.helpers.check_load_model(model: Union[str, onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto]) → onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto[source]
                    +sparseml.onnx.utils.helpers.check_load_model(model: Union[str, onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto])onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto[source]

                    Load an ONNX model from a given file path if supplied. If already a model proto, then returns.

                    @@ -656,7 +656,7 @@

                    Submodules
                    -sparseml.onnx.utils.helpers.conv_node_params(model: onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto, node: onnx.onnx_ONNX_REL_1_6_ml_pb2.NodeProto, include_values: bool = True) → Tuple[sparseml.onnx.utils.helpers.NodeParam, Optional[sparseml.onnx.utils.helpers.NodeParam]][source]
                    +sparseml.onnx.utils.helpers.conv_node_params(model: onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto, node: onnx.onnx_ONNX_REL_1_7_ml_pb2.NodeProto, include_values: bool = True)Tuple[sparseml.onnx.utils.helpers.NodeParam, Optional[sparseml.onnx.utils.helpers.NodeParam]][source]

                    Get the params (weight and bias) for a conv node in an onnx ModelProto

                    Parameters
                    @@ -676,7 +676,7 @@

                    Submodules
                    -sparseml.onnx.utils.helpers.extract_node_id(node: onnx.onnx_ONNX_REL_1_6_ml_pb2.NodeProto) → str[source]
                    +sparseml.onnx.utils.helpers.extract_node_id(node: onnx.onnx_ONNX_REL_1_7_ml_pb2.NodeProto)str[source]

                    Get the node id for a given node from an onnx model. Grabs the first ouput id as the node id. This is because is guaranteed to be unique for this node by the onnx spec.

                    @@ -692,7 +692,7 @@

                    Submodules
                    -sparseml.onnx.utils.helpers.extract_node_shapes(model: onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto) → Dict[str, sparseml.onnx.utils.helpers.NodeShape][source]
                    +sparseml.onnx.utils.helpers.extract_node_shapes(model: onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto)Dict[str, sparseml.onnx.utils.helpers.NodeShape][source]

                    Extracts the shape information for each node as a NodeShape object.

                    Parameters
                    @@ -706,7 +706,7 @@

                    Submodules
                    -sparseml.onnx.utils.helpers.extract_nodes_shapes_ort(model: onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto) → Dict[str, List[List[int]]][source]
                    +sparseml.onnx.utils.helpers.extract_nodes_shapes_ort(model: onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto)Dict[str, List[List[int]]][source]

                    Creates a modified model to expose intermediate outputs and runs an onnxruntime InferenceSession to obtain the output shape of each node.

                    @@ -721,7 +721,7 @@

                    Submodules
                    -sparseml.onnx.utils.helpers.extract_nodes_shapes_shape_inference(model: onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto) → Dict[str, List[Union[None, List[int]]]][source]
                    +sparseml.onnx.utils.helpers.extract_nodes_shapes_shape_inference(model: onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto)Dict[str, List[Union[None, List[int]]]][source]

                    Creates a modified model to expose intermediate outputs and runs an onnx shape inference to obtain the output shape of each node.

                    NOTE: The Onnx docs on shape inference have the following @@ -742,7 +742,7 @@

                    Submodules
                    -sparseml.onnx.utils.helpers.extract_shape(proto: Any) → Union[None, Tuple[Optional[int], ]][source]
                    +sparseml.onnx.utils.helpers.extract_shape(proto: Any)Union[None, Tuple[Optional[int], ]][source]

                    Extract the shape info from a proto. Convenient for inputs into a model for example to get the tensor dimension.

                    @@ -757,7 +757,7 @@

                    Submodules
                    -sparseml.onnx.utils.helpers.gemm_node_params(model: onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto, node: onnx.onnx_ONNX_REL_1_6_ml_pb2.NodeProto, include_values: bool = True) → Tuple[sparseml.onnx.utils.helpers.NodeParam, Optional[sparseml.onnx.utils.helpers.NodeParam]][source]
                    +sparseml.onnx.utils.helpers.gemm_node_params(model: onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto, node: onnx.onnx_ONNX_REL_1_7_ml_pb2.NodeProto, include_values: bool = True)Tuple[sparseml.onnx.utils.helpers.NodeParam, Optional[sparseml.onnx.utils.helpers.NodeParam]][source]

                    Get the params (weight and bias) for a gemm node in an onnx ModelProto

                    Parameters
                    @@ -777,7 +777,7 @@

                    Submodules
                    -sparseml.onnx.utils.helpers.get_attr_float_val_for_node(node: onnx.onnx_ONNX_REL_1_6_ml_pb2.NodeProto, attr: str) → Optional[float][source]
                    +sparseml.onnx.utils.helpers.get_attr_float_val_for_node(node: onnx.onnx_ONNX_REL_1_7_ml_pb2.NodeProto, attr: str)Optional[float][source]
                    Parameters
                      @@ -794,7 +794,7 @@

                      Submodules
                      -sparseml.onnx.utils.helpers.get_batch_norm_params(model: onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto, bn_node: onnx.onnx_ONNX_REL_1_6_ml_pb2.NodeProto)sparseml.onnx.utils.helpers.BatchNormParams[source]
                      +sparseml.onnx.utils.helpers.get_batch_norm_params(model: onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto, bn_node: onnx.onnx_ONNX_REL_1_7_ml_pb2.NodeProto)sparseml.onnx.utils.helpers.BatchNormParams[source]

                      Get the params and relevant attributes of a batch normalization operator. Following the onnx operators spec, will default epsilon and momentum to 1e-5 and 0.9 respectively when not defined.

                      @@ -813,7 +813,7 @@

                      Submodules
                      -sparseml.onnx.utils.helpers.get_init_by_name(model: onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto, init_name: str) → Optional[Any][source]
                      +sparseml.onnx.utils.helpers.get_init_by_name(model: onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto, init_name: str)Optional[Any][source]

                      Get an initializer by name from the onnx model proto graph

                      Parameters
                      @@ -830,7 +830,7 @@

                      Submodules
                      -sparseml.onnx.utils.helpers.get_kernel_shape(attributes: Dict[str, Any]) → Optional[List[float]][source]
                      +sparseml.onnx.utils.helpers.get_kernel_shape(attributes: Dict[str, Any])Optional[List[float]][source]

                      Get the kernel shape from a dictionary of a model’s attributes

                      Parameters
                      @@ -845,7 +845,7 @@

                      Submodules
                      -sparseml.onnx.utils.helpers.get_node_attributes(node: onnx.onnx_ONNX_REL_1_6_ml_pb2.NodeProto) → Dict[str, Any][source]
                      +sparseml.onnx.utils.helpers.get_node_attributes(node: onnx.onnx_ONNX_REL_1_7_ml_pb2.NodeProto)Dict[str, Any][source]
                      Parameters

                      node – the ONNX node to get the attibutes for

                      @@ -858,7 +858,7 @@

                      Submodules
                      -sparseml.onnx.utils.helpers.get_node_by_id(model: onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto, node_id: str) → Optional[onnx.onnx_ONNX_REL_1_6_ml_pb2.NodeProto][source]
                      +sparseml.onnx.utils.helpers.get_node_by_id(model: onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto, node_id: str)Optional[onnx.onnx_ONNX_REL_1_7_ml_pb2.NodeProto][source]

                      Get a node from a model by the node_id generated from extract_node_id

                      Parameters
                      @@ -875,7 +875,7 @@

                      Submodules
                      -sparseml.onnx.utils.helpers.get_node_input_nodes(model: onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto, node: onnx.onnx_ONNX_REL_1_6_ml_pb2.NodeProto) → List[onnx.onnx_ONNX_REL_1_6_ml_pb2.NodeProto][source]
                      +sparseml.onnx.utils.helpers.get_node_input_nodes(model: onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto, node: onnx.onnx_ONNX_REL_1_7_ml_pb2.NodeProto)List[onnx.onnx_ONNX_REL_1_7_ml_pb2.NodeProto][source]

                      Get all of the nodes that share an output edge for the inputs to a given node

                      Parameters
                      @@ -893,7 +893,7 @@

                      Submodules
                      -sparseml.onnx.utils.helpers.get_node_inputs(model: onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto, node: onnx.onnx_ONNX_REL_1_6_ml_pb2.NodeProto) → List[str][source]
                      +sparseml.onnx.utils.helpers.get_node_inputs(model: onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto, node: onnx.onnx_ONNX_REL_1_7_ml_pb2.NodeProto)List[str][source]
                      Parameters
                        @@ -909,7 +909,7 @@

                        Submodules
                        -sparseml.onnx.utils.helpers.get_node_output_nodes(model: onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto, node: onnx.onnx_ONNX_REL_1_6_ml_pb2.NodeProto) → List[onnx.onnx_ONNX_REL_1_6_ml_pb2.NodeProto][source]
                        +sparseml.onnx.utils.helpers.get_node_output_nodes(model: onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto, node: onnx.onnx_ONNX_REL_1_7_ml_pb2.NodeProto)List[onnx.onnx_ONNX_REL_1_7_ml_pb2.NodeProto][source]

                        Get all of the nodes that share an input edge for the outputs from a given node

                        Parameters
                        @@ -927,7 +927,7 @@

                        Submodules
                        -sparseml.onnx.utils.helpers.get_node_outputs(model: onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto, node: onnx.onnx_ONNX_REL_1_6_ml_pb2.NodeProto) → List[str][source]
                        +sparseml.onnx.utils.helpers.get_node_outputs(model: onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto, node: onnx.onnx_ONNX_REL_1_7_ml_pb2.NodeProto)List[str][source]
                        Parameters
                          @@ -943,7 +943,7 @@

                          Submodules
                          -sparseml.onnx.utils.helpers.get_node_params(model: onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto, node: onnx.onnx_ONNX_REL_1_6_ml_pb2.NodeProto, include_values: bool = True) → Tuple[sparseml.onnx.utils.helpers.NodeParam, Optional[sparseml.onnx.utils.helpers.NodeParam]][source]
                          +sparseml.onnx.utils.helpers.get_node_params(model: onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto, node: onnx.onnx_ONNX_REL_1_7_ml_pb2.NodeProto, include_values: bool = True)Tuple[sparseml.onnx.utils.helpers.NodeParam, Optional[sparseml.onnx.utils.helpers.NodeParam]][source]

                          Get the params (weight and bias) for a node in an onnx ModelProto. Must be an op type of one of [conv, gemm, matmul]

                          @@ -964,7 +964,7 @@

                          Submodules
                          -sparseml.onnx.utils.helpers.get_nodes_by_input_id(model: onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto, input_id: str) → List[onnx.onnx_ONNX_REL_1_6_ml_pb2.NodeProto][source]
                          +sparseml.onnx.utils.helpers.get_nodes_by_input_id(model: onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto, input_id: str)List[onnx.onnx_ONNX_REL_1_7_ml_pb2.NodeProto][source]

                          Get all the nodes in a model that have a given id as one of the inputs

                          Parameters
                          @@ -981,7 +981,7 @@

                          Submodules
                          -sparseml.onnx.utils.helpers.get_nodes_by_output_id(model: onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto, output_id: str) → List[onnx.onnx_ONNX_REL_1_6_ml_pb2.NodeProto][source]
                          +sparseml.onnx.utils.helpers.get_nodes_by_output_id(model: onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto, output_id: str)List[onnx.onnx_ONNX_REL_1_7_ml_pb2.NodeProto][source]

                          Get all the nodes in a model that have a given id as one of the outputs

                          Parameters
                          @@ -998,7 +998,7 @@

                          Submodules
                          -sparseml.onnx.utils.helpers.get_numpy_dtype(tensor: onnx.onnx_ONNX_REL_1_6_ml_pb2.TensorProto) → Union[None, numpy.dtype][source]
                          +sparseml.onnx.utils.helpers.get_numpy_dtype(tensor: onnx.onnx_ONNX_REL_1_7_ml_pb2.TensorProto)Union[None, numpy.dtype][source]

                          Extract the numpy dtype of an ONNX tensor. Returns None if there is not a direct mapping from the ONNX data type to a numpy dtype.

                          @@ -1014,7 +1014,7 @@

                          Submodules
                          -sparseml.onnx.utils.helpers.get_prunable_node_from_foldable(model: onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto, foldable_node: Union[str, onnx.onnx_ONNX_REL_1_6_ml_pb2.NodeProto], traverse_previous: bool = True, max_node_distance: int = 3) → Union[None, onnx.onnx_ONNX_REL_1_6_ml_pb2.NodeProto][source]
                          +sparseml.onnx.utils.helpers.get_prunable_node_from_foldable(model: onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto, foldable_node: Union[str, onnx.onnx_ONNX_REL_1_7_ml_pb2.NodeProto], traverse_previous: bool = True, max_node_distance: int = 3)Union[None, onnx.onnx_ONNX_REL_1_7_ml_pb2.NodeProto][source]

                          Get a prunable node that is attached by foldable nodes to a given foldable node. Returns None if nothing could be found. Ex: get the convolution that would be folded for an attached BatchNormalization

                          @@ -1041,7 +1041,7 @@

                          Submodules
                          -sparseml.onnx.utils.helpers.get_prunable_nodes(model: Union[str, onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto]) → List[Any][source]
                          +sparseml.onnx.utils.helpers.get_prunable_nodes(model: Union[str, onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto])List[Any][source]

                          Get the prunable nodes in an onnx model proto. Prunable nodes are defined as any conv, gemm, or matmul

                          @@ -1056,7 +1056,7 @@

                          Submodules
                          -sparseml.onnx.utils.helpers.get_quantize_parent_for_dequantize_node(quantized_model: onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto, dequantize_node: onnx.onnx_ONNX_REL_1_6_ml_pb2.NodeProto) → Optional[onnx.onnx_ONNX_REL_1_6_ml_pb2.NodeProto][source]
                          +sparseml.onnx.utils.helpers.get_quantize_parent_for_dequantize_node(quantized_model: onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto, dequantize_node: onnx.onnx_ONNX_REL_1_7_ml_pb2.NodeProto)Optional[onnx.onnx_ONNX_REL_1_7_ml_pb2.NodeProto][source]

                          Returns the first quantize node found by traversing the first node input of the given de-quantize node’s ancestors. All inputs to de-quantize nodes should have a quantize node ancestor.

                          @@ -1076,7 +1076,7 @@

                          Submodules
                          -sparseml.onnx.utils.helpers.is_foldable_node(node: Union[str, onnx.onnx_ONNX_REL_1_6_ml_pb2.NodeProto]) → bool[source]
                          +sparseml.onnx.utils.helpers.is_foldable_node(node: Union[str, onnx.onnx_ONNX_REL_1_7_ml_pb2.NodeProto])bool[source]

                          Foldable nodes as defined by ONNXRuntime and what it supports layerwise folding in the ONNX graphs. More info can be fined in their docs: https://github.com/microsoft/onnxruntime/blob/master/docs/ONNX_Runtime_Graph_Optimizations.md

                          @@ -1094,7 +1094,7 @@

                          Submodules
                          -sparseml.onnx.utils.helpers.is_prunable_node(model: onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto, node: onnx.onnx_ONNX_REL_1_6_ml_pb2.NodeProto) → bool[source]
                          +sparseml.onnx.utils.helpers.is_prunable_node(model: onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto, node: onnx.onnx_ONNX_REL_1_7_ml_pb2.NodeProto)bool[source]
                          Parameters
                            @@ -1110,7 +1110,7 @@

                            Submodules
                            -sparseml.onnx.utils.helpers.matmul_node_params(model: onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto, node: onnx.onnx_ONNX_REL_1_6_ml_pb2.NodeProto, include_values: bool = True) → Tuple[sparseml.onnx.utils.helpers.NodeParam, Optional[sparseml.onnx.utils.helpers.NodeParam]][source]
                            +sparseml.onnx.utils.helpers.matmul_node_params(model: onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto, node: onnx.onnx_ONNX_REL_1_7_ml_pb2.NodeProto, include_values: bool = True)Tuple[sparseml.onnx.utils.helpers.NodeParam, Optional[sparseml.onnx.utils.helpers.NodeParam]][source]

                            Get the params (weight) for a matmul node in an onnx ModelProto. In the future will retrieve a following bias addition as the bias for the matmul.

                            @@ -1131,7 +1131,7 @@

                            Submodules
                            -sparseml.onnx.utils.helpers.model_inputs(model: Union[str, onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto]) → List[source]
                            +sparseml.onnx.utils.helpers.model_inputs(model: Union[str, onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto])List[source]

                            Get the input to the model from an ONNX model

                            Parameters
                            @@ -1146,7 +1146,7 @@

                            Submodules
                            -sparseml.onnx.utils.helpers.model_outputs(model: Union[str, onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto]) → List[source]
                            +sparseml.onnx.utils.helpers.model_outputs(model: Union[str, onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto])List[source]

                            Get the output from an ONNX model

                            Parameters
                            @@ -1161,7 +1161,7 @@

                            Submodules
                            -sparseml.onnx.utils.helpers.onnx_nodes_sparsities(model: Union[str, onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto]) → Tuple[sparseml.onnx.utils.helpers.SparsityMeasurement, Dict[str, sparseml.onnx.utils.helpers.SparsityMeasurement]][source]
                            +sparseml.onnx.utils.helpers.onnx_nodes_sparsities(model: Union[str, onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto])Tuple[sparseml.onnx.utils.helpers.SparsityMeasurement, Dict[str, sparseml.onnx.utils.helpers.SparsityMeasurement]][source]

                            Retrieve the sparsities for each Conv or Gemm op in an onnx graph for the associated weight inputs.

                            @@ -1177,7 +1177,7 @@

                            Submodules
                            -sparseml.onnx.utils.helpers.validate_onnx_file(path: str)[source]
                            +sparseml.onnx.utils.helpers.validate_onnx_file(path: str)[source]

                            Validate that a file at a given path is a valid onnx model

                            Parameters
                            @@ -1194,7 +1194,7 @@

                            Submodules

                            sparseml.onnx.utils.loss module

                            -sparseml.onnx.utils.loss.kl_divergence(predicted: numpy.ndarray, expected: numpy.ndarray, zero_point: float = 0.0, min_value: float = 1.0) → float[source]
                            +sparseml.onnx.utils.loss.kl_divergence(predicted: numpy.ndarray, expected: numpy.ndarray, zero_point: float = 0.0, min_value: float = 1.0)float[source]

                            Calculate the kl_divergence (entropy) between two input arrays.

                            Shifts all values such that the zero_point is at one. If a value is lower, then sets it equal to 1.

                            @@ -1220,7 +1220,7 @@

                            Submodules
                            -class sparseml.onnx.utils.model.DeepSparseAnalyzeModelRunner(model: Union[str, onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto], batch_size: int, num_cores: Optional[int] = None)[source]
                            +class sparseml.onnx.utils.model.DeepSparseAnalyzeModelRunner(model: Union[str, onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto], batch_size: int, num_cores: Optional[int] = None)[source]

                            Bases: sparseml.onnx.utils.model._DeepSparseBaseModelRunner

                            Class for handling running inference for an ONNX model through Neural Magic’s analyze_model api

                            @@ -1236,7 +1236,7 @@

                            Submodules
                            -batch_forward(batch: Dict[str, numpy.ndarray], num_iterations: int = 1, num_warmup_iterations: int = 0, optimization_level: int = 1, imposed_ks: Union[None, float] = None, *args, **kwargs) → Tuple[Dict[str, numpy.ndarray], float][source]
                            +batch_forward(batch: Dict[str, numpy.ndarray], num_iterations: int = 1, num_warmup_iterations: int = 0, optimization_level: int = 1, imposed_ks: Union[None, float] = None, *args, **kwargs)Tuple[Dict[str, numpy.ndarray], float][source]
                            Parameters
                              @@ -1260,7 +1260,7 @@

                              Submodules
                              -run(data_loader: sparseml.onnx.utils.data.DataLoader, desc: str = '', show_progress: bool = True, max_steps: int = 1, num_iterations: int = 20, num_warmup_iterations: int = 5, optimization_level: int = 1, imposed_ks: Union[None, float] = None, *args, **kwargs) → Tuple[List[Dict], List[float]][source]
                              +run(data_loader: sparseml.onnx.utils.data.DataLoader, desc: str = '', show_progress: bool = True, max_steps: int = 1, num_iterations: int = 20, num_warmup_iterations: int = 5, optimization_level: int = 1, imposed_ks: Union[None, float] = None, *args, **kwargs)Tuple[List[Dict], List[float]][source]

                              Run inference for a model for the data given in the data_loader iterator through neural magic inference engine model analysis function. The analysis function allows more granular control over how the @@ -1295,7 +1295,7 @@

                              Submodules
                              -class sparseml.onnx.utils.model.DeepSparseModelRunner(model: Union[str, onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto], batch_size: int, num_cores: Optional[int] = None, loss: Optional[Callable[[Dict[str, numpy.ndarray], Dict[str, numpy.ndarray]], Any]] = None)[source]
                              +class sparseml.onnx.utils.model.DeepSparseModelRunner(model: Union[str, onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto], batch_size: int, num_cores: Optional[int] = None, loss: Optional[Callable[[Dict[str, numpy.ndarray], Dict[str, numpy.ndarray]], Any]] = None)[source]

                              Bases: sparseml.onnx.utils.model._DeepSparseBaseModelRunner

                              Class for handling running inference for an ONNX model through Neural Magic

                              @@ -1311,7 +1311,7 @@

                              Submodules
                              -batch_forward(batch: Dict[str, numpy.ndarray], *args, **kwargs) → Tuple[Dict[str, numpy.ndarray], float][source]
                              +batch_forward(batch: Dict[str, numpy.ndarray], *args, **kwargs)Tuple[Dict[str, numpy.ndarray], float][source]
                              Parameters

                              batch – the batch to run through the ONNX model for inference @@ -1326,7 +1326,7 @@

                              Submodules
                              -run(data_loader: sparseml.onnx.utils.data.DataLoader, desc: str = '', show_progress: bool = True, max_steps: int = - 1, *args, **kwargs) → Tuple[List[Any], List[float]][source]
                              +run(data_loader: sparseml.onnx.utils.data.DataLoader, desc: str = '', show_progress: bool = True, max_steps: int = - 1, *args, **kwargs)Tuple[List[Any], List[float]][source]

                              Run inference for a model for the data given in the data_loader iterator through neural magic inference engine.

                              @@ -1351,7 +1351,7 @@

                              Submodules
                              -class sparseml.onnx.utils.model.ModelRunner(loss: Optional[Callable[[Dict[str, numpy.ndarray], Dict[str, numpy.ndarray]], Any]] = None)[source]
                              +class sparseml.onnx.utils.model.ModelRunner(loss: Optional[Callable[[Dict[str, numpy.ndarray], Dict[str, numpy.ndarray]], Any]] = None)[source]

                              Bases: abc.ABC

                              Abstract class for handling running inference for a model

                              @@ -1361,7 +1361,7 @@

                              Submodules
                              -abstract batch_forward(batch: Dict[str, numpy.ndarray], *args, **kwargs) → Tuple[Any, float][source]
                              +abstract batch_forward(batch: Dict[str, numpy.ndarray], *args, **kwargs)Tuple[Any, float][source]

                              Abstract method for subclasses to override to run a batch through the inference engine for the ONNX model it was constructed with

                              @@ -1377,7 +1377,7 @@

                              Submodules
                              -run(data_loader: sparseml.onnx.utils.data.DataLoader, desc: str = '', show_progress: bool = True, max_steps: int = - 1, *args, **kwargs) → Tuple[List[Any], List[float]][source]
                              +run(data_loader: sparseml.onnx.utils.data.DataLoader, desc: str = '', show_progress: bool = True, max_steps: int = - 1, *args, **kwargs)Tuple[List[Any], List[float]][source]

                              Run inference for a model for the data given in the data_loader iterator

                              Parameters
                              @@ -1399,7 +1399,7 @@

                              Submodules
                              -run_iter(data_loader: sparseml.onnx.utils.data.DataLoader, desc: str = '', show_progress: bool = True, max_steps: int = - 1, *args, **kwargs)[source]
                              +run_iter(data_loader: sparseml.onnx.utils.data.DataLoader, desc: str = '', show_progress: bool = True, max_steps: int = - 1, *args, **kwargs)[source]

                              Iteratively runs inference for a model for the data given in the data_loader iterator

                              @@ -1424,7 +1424,7 @@

                              Submodules
                              -class sparseml.onnx.utils.model.ORTModelRunner(model: Union[str, onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto], loss: Optional[Callable[[Dict[str, numpy.ndarray], Dict[str, numpy.ndarray]], Any]] = None, overwrite_input_names: bool = True, nthreads: int = 0, batch_size: Optional[int] = None, providers: Optional[List[str]] = None)[source]
                              +class sparseml.onnx.utils.model.ORTModelRunner(model: Union[str, onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto], loss: Optional[Callable[[Dict[str, numpy.ndarray], Dict[str, numpy.ndarray]], Any]] = None, overwrite_input_names: bool = True, nthreads: int = 0, batch_size: Optional[int] = None, providers: Optional[List[str]] = None)[source]

                              Bases: sparseml.onnx.utils.model.ModelRunner

                              Class for handling running inference for an ONNX model through onnxruntime

                              @@ -1445,7 +1445,7 @@

                              Submodules
                              -batch_forward(batch: Dict[str, numpy.ndarray], *args, **kwargs) → Tuple[Dict[str, numpy.ndarray], float][source]
                              +batch_forward(batch: Dict[str, numpy.ndarray], *args, **kwargs)Tuple[Dict[str, numpy.ndarray], float][source]
                              Parameters

                              batch – the batch to run through the ONNX model for inference @@ -1460,7 +1460,7 @@

                              Submodules
                              -run(data_loader: sparseml.onnx.utils.data.DataLoader, desc: str = '', show_progress: bool = True, max_steps: int = - 1, *args, **kwargs) → Tuple[List[Any], List[float]][source]
                              +run(data_loader: sparseml.onnx.utils.data.DataLoader, desc: str = '', show_progress: bool = True, max_steps: int = - 1, *args, **kwargs)Tuple[List[Any], List[float]][source]

                              Run inference for a model for the data given in the data_loader iterator through ONNX Runtime.

                              @@ -1485,7 +1485,7 @@

                              Submodules
                              -class sparseml.onnx.utils.model.OpenVINOModelRunner(model: str, loss: Optional[Callable[[Dict[str, numpy.ndarray], Dict[str, numpy.ndarray]], Any]] = None, nthreads: int = 1, batch_size: int = 0, shape: str = '')[source]
                              +class sparseml.onnx.utils.model.OpenVINOModelRunner(model: str, loss: Optional[Callable[[Dict[str, numpy.ndarray], Dict[str, numpy.ndarray]], Any]] = None, nthreads: int = 1, batch_size: int = 0, shape: str = '')[source]

                              Bases: sparseml.onnx.utils.model.ModelRunner

                              OpenVINO model runner class

                              @@ -1504,12 +1504,12 @@

                              Submodules
                              -static available() → bool[source]
                              +static available()bool[source]

                              -batch_forward(batch: Dict[str, numpy.ndarray], *args, **kwargs) → Tuple[Any, float][source]
                              +batch_forward(batch: Dict[str, numpy.ndarray], *args, **kwargs)Tuple[Any, float][source]

                              Run a batch through the model

                              Parameters
                              @@ -1523,7 +1523,7 @@

                              Submodules
                              -network_input_shapes()[source]
                              +network_input_shapes()[source]

                              Get network input shapes :return: dictionary of shapes for each input key

                              @@ -1532,7 +1532,7 @@

                              Submodules
                              -sparseml.onnx.utils.model.correct_nm_analyze_model_node_ids(nm_result: Dict, model: Union[str, onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto])[source]
                              +sparseml.onnx.utils.model.correct_nm_analyze_model_node_ids(nm_result: Dict, model: Union[str, onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto])[source]

                              Correct the node ids returned from the deepsparse.analyze_model api. In some cases, it will return the ids for folded nodes due to ONNXRuntime folding. This finds the corrected node ids from those folded nodes. @@ -1551,7 +1551,7 @@

                              Submodules
                              -sparseml.onnx.utils.model.max_available_cores() → int[source]
                              +sparseml.onnx.utils.model.max_available_cores()int[source]
                              Returns

                              the maximum number of physical cores detected on the system

                              @@ -1561,7 +1561,7 @@

                              Submodules
                              -sparseml.onnx.utils.model.split_canonical_names(nm_result: Dict)[source]
                              +sparseml.onnx.utils.model.split_canonical_names(nm_result: Dict)[source]

                              Splits analysis layer results from grouped canonical names by individual nodes. Stores the original grouped canonical name in the ‘meta_canonical_name’ field.

                              Will split on any canonical_name that includes ‘,’.

                              @@ -1579,7 +1579,7 @@

                              Submodules
                              -sparseml.onnx.utils.sparse_tensor.convert_model_initializers_to_sparse(model: onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto, sparsity_threshold: float = 0.6, inplace: bool = True) → onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto[source]
                              +sparseml.onnx.utils.sparse_tensor.convert_model_initializers_to_sparse(model: onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto, sparsity_threshold: float = 0.6, inplace: bool = True)onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto[source]
                              Parameters
                                @@ -1598,7 +1598,7 @@

                                Submodules
                                -sparseml.onnx.utils.sparse_tensor.convert_sparse_initializers_to_dense(model: onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto, inplace: bool = True) → onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto[source]
                                +sparseml.onnx.utils.sparse_tensor.convert_sparse_initializers_to_dense(model: onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto, inplace: bool = True)onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto[source]
                                Parameters
                                  @@ -1615,7 +1615,7 @@

                                  Submodules
                                  -sparseml.onnx.utils.sparse_tensor.create_sparse_tensor(array: Union[numpy.ndarray, onnx.onnx_ONNX_REL_1_6_ml_pb2.TensorProto], name: Optional[str] = None) → Optional[onnx.onnx_ONNX_REL_1_6_ml_pb2.SparseTensorProto][source]
                                  +sparseml.onnx.utils.sparse_tensor.create_sparse_tensor(array: Union[numpy.ndarray, onnx.onnx_ONNX_REL_1_7_ml_pb2.TensorProto], name: Optional[str] = None)Optional[onnx.onnx_ONNX_REL_1_7_ml_pb2.SparseTensorProto][source]
                                  Parameters
                                    @@ -1634,7 +1634,7 @@

                                    Submodules
                                    -sparseml.onnx.utils.sparse_tensor.sparse_tensor_to_dense(sparse_tensor: onnx.onnx_ONNX_REL_1_6_ml_pb2.SparseTensorProto) → onnx.onnx_ONNX_REL_1_6_ml_pb2.TensorProto[source]
                                    +sparseml.onnx.utils.sparse_tensor.sparse_tensor_to_dense(sparse_tensor: onnx.onnx_ONNX_REL_1_7_ml_pb2.SparseTensorProto)onnx.onnx_ONNX_REL_1_7_ml_pb2.TensorProto[source]
                                    Parameters

                                    sparse_tensor – SparseTensorProto object

                                    diff --git a/sparseml/api/sparseml.optim.html b/sparseml/api/sparseml.optim.html index e9d3d3e46bf..41588392718 100644 --- a/sparseml/api/sparseml.optim.html +++ b/sparseml/api/sparseml.optim.html @@ -213,7 +213,7 @@

                                    Submodules
                                    -class sparseml.optim.analyzer.AnalyzedLayerDesc(name: str, type_: str, params: int = 0, zeroed_params: int = 0, prunable_params: int = 0, params_dims: Optional[Dict[str, Tuple[int, ]]] = None, prunable_params_dims: Optional[Dict[str, Tuple[int, ]]] = None, execution_order: int = - 1, input_shape: Optional[Tuple[Tuple[int, ], ]] = None, output_shape: Optional[Tuple[Tuple[int, ], ]] = None, flops: int = 0, total_flops: int = 0, stride: Optional[Tuple[int, ]] = None)[source]
                                    +class sparseml.optim.analyzer.AnalyzedLayerDesc(name: str, type_: str, params: int = 0, zeroed_params: int = 0, prunable_params: int = 0, params_dims: Optional[Dict[str, Tuple[int, ]]] = None, prunable_params_dims: Optional[Dict[str, Tuple[int, ]]] = None, execution_order: int = - 1, input_shape: Optional[Tuple[Tuple[int, ], ]] = None, output_shape: Optional[Tuple[Tuple[int, ], ]] = None, flops: int = 0, total_flops: int = 0, stride: Optional[Tuple[int, ]] = None)[source]

                                    Bases: object

                                    Description of an executed neural network layer. Contains information about the number of flops, shapes, params, etc.

                                    @@ -237,7 +237,7 @@

                                    Submodules
                                    -dict() → Dict[str, Any][source]
                                    +dict()Dict[str, Any][source]
                                    Returns

                                    A serializable dictionary representation of the current instance

                                    @@ -247,7 +247,7 @@

                                    Submodules
                                    -static load_descs(path: str) → List[source]
                                    +static load_descs(path: str)List[source]

                                    Load a list of AnalyzedLayerDesc from a json file

                                    Parameters
                                    @@ -261,7 +261,7 @@

                                    Submodules
                                    -static merge_descs(orig, descs: List)[source]
                                    +static merge_descs(orig, descs: List)[source]

                                    Merge a layer description with a list of others

                                    Parameters
                                    @@ -278,7 +278,7 @@

                                    Submodules
                                    -property prunable
                                    +property prunable

                                    True if the layer supports kernel sparsity (is prunable), False otherwise

                                    @@ -290,7 +290,7 @@

                                    Submodules
                                    -static save_descs(descs: List, path: str)[source]
                                    +static save_descs(descs: List, path: str)[source]

                                    Save a list of AnalyzedLayerDesc to a json file

                                    Parameters
                                    @@ -304,7 +304,7 @@

                                    Submodules
                                    -property terminal
                                    +property terminal

                                    True if this is a terminal op, ie it is doing compute and is not a container, False otherwise

                                    @@ -322,7 +322,7 @@

                                    Submodules
                                    -class sparseml.optim.learning_rate.LearningRate(lr_class: str, lr_kwargs: Dict, init_lr: float, **kwargs)[source]
                                    +class sparseml.optim.learning_rate.LearningRate(lr_class: str, lr_kwargs: Dict, init_lr: float, **kwargs)[source]

                                    Bases: sparseml.optim.modifier.BaseObject

                                    Generic implementation for LearningRate shared across framework implementations.

                                    @@ -338,7 +338,7 @@

                                    Submodules
                                    -corrected_lr_info(steps_per_epoch: int, start_epoch: float, end_epoch: float) → Tuple[str, Dict][source]
                                    +corrected_lr_info(steps_per_epoch: int, start_epoch: float, end_epoch: float)Tuple[str, Dict][source]

                                    Get the corrected learning rate info for use with modifiers. Normalizes any epoch values to steps.

                                    @@ -357,7 +357,7 @@

                                    Submodules
                                    -init_lr
                                    +init_lr

                                    The initial learning rate to use once this modifier starts

                                    Type
                                    @@ -368,7 +368,7 @@

                                    Submodules
                                    -lr_class
                                    +lr_class

                                    The name of the lr scheduler class to use: [StepLR, MultiStepLR, ExponentialLR]

                                    @@ -380,7 +380,7 @@

                                    Submodules
                                    -lr_kwargs
                                    +lr_kwargs

                                    The dictionary of keyword arguments to pass to the constructor for the lr_class

                                    @@ -392,7 +392,7 @@

                                    Submodules
                                    -validate_lr_info()[source]
                                    +validate_lr_info()[source]

                                    Validate the values of the params for the current instance are valid

                                    @@ -400,7 +400,7 @@

                                    Submodules
                                    -class sparseml.optim.learning_rate.SetLearningRate(learning_rate: float, **kwargs)[source]
                                    +class sparseml.optim.learning_rate.SetLearningRate(learning_rate: float, **kwargs)[source]

                                    Bases: sparseml.optim.modifier.BaseObject

                                    Generic implementation for SetLearningRate shared across framework implementations.

                                    @@ -410,7 +410,7 @@

                                    Submodules
                                    -learning_rate
                                    +learning_rate

                                    The learning rate to use once this modifier starts

                                    Type
                                    @@ -421,7 +421,7 @@

                                    Submodules
                                    -validate_learning_rate()[source]
                                    +validate_learning_rate()[source]

                                    @@ -434,7 +434,7 @@

                                    Submodules
                                    -class sparseml.optim.manager.BaseManager(modifiers: List[sparseml.optim.modifier.BaseScheduled], **kwargs)[source]
                                    +class sparseml.optim.manager.BaseManager(modifiers: List[sparseml.optim.modifier.BaseScheduled], **kwargs)[source]

                                    Bases: sparseml.optim.modifier.BaseObject

                                    Parent class meant to be used for all managers. Handles base implementations for properties and methods.

                                    @@ -445,22 +445,22 @@

                                    Submodules
                                    -max_epochs
                                    +max_epochs

                                    -min_epochs
                                    +min_epochs
                                    -modifiers
                                    +modifiers
                                    -modifiers_to_string_lines(modifiers: List[sparseml.optim.modifier.BaseScheduled]) → List[str][source]
                                    +modifiers_to_string_lines(modifiers: List[sparseml.optim.modifier.BaseScheduled])List[str][source]
                                    Parameters

                                    modifiers – the modifiers to convert into string / yaml representation @@ -475,7 +475,7 @@

                                    Submodules
                                    -save(file_path: str)[source]
                                    +save(file_path: str)[source]
                                    Parameters

                                    file_path – the file path to save the yaml config representation to

                                    @@ -485,7 +485,7 @@

                                    Submodules
                                    -to_string_lines() → List[str][source]
                                    +to_string_lines()List[str][source]
                                    Returns

                                    a list of lines for a string / yaml representation of this instance

                                    @@ -502,7 +502,7 @@

                                    Submodules
                                    -class sparseml.optim.modifier.BaseModifier(log_types: Union[str, List[str]], **kwargs)[source]
                                    +class sparseml.optim.modifier.BaseModifier(log_types: Union[str, List[str]], **kwargs)[source]

                                    Bases: sparseml.optim.modifier.BaseObject

                                    Parent class meant to be used for all modifiers. Handles base implementations for properties and methods.

                                    @@ -516,7 +516,7 @@

                                    Submodules
                                    -enabled[source]
                                    +enabled[source]

                                    True if the modifier is currently enabled and making updates, False otherwise

                                    @@ -528,12 +528,12 @@

                                    Submodules
                                    -initialized[source]
                                    +initialized[source]

                                    -static load_framework_list(yaml_str: str, framework: str)[source]
                                    +static load_framework_list(yaml_str: str, framework: str)[source]
                                    Parameters
                                      @@ -549,7 +549,7 @@

                                      Submodules
                                      -static load_framework_obj(yaml_str: str, framework: str)[source]
                                      +static load_framework_obj(yaml_str: str, framework: str)[source]
                                      Parameters
                                      -props(only_serializable: bool, format_str: bool = False, format_repr: bool = False) → Dict[str, Any][source]
                                      +props(only_serializable: bool, format_str: bool = False, format_repr: bool = False)Dict[str, Any][source]

                                      Gather all the ModifierProps for the current instance into a dictionary collection.

                                      @@ -591,7 +591,7 @@

                                      Submodules
                                      -static yaml_key(clazz, framework: Optional[str] = None)[source]
                                      +static yaml_key(clazz, framework: Optional[str] = None)[source]

                                      create a key for loading in yaml from the class and the framework

                                      Parameters
                                      @@ -611,7 +611,7 @@

                                      Submodules
                                      -class sparseml.optim.modifier.BaseObject(**kwargs)[source]
                                      +class sparseml.optim.modifier.BaseObject(**kwargs)[source]

                                      Bases: object

                                      BaseObject to accept kwargs so multiple inheritance will work with the modifier classes. @@ -625,12 +625,12 @@

                                      Submodules
                                      -class sparseml.optim.modifier.BaseProp[source]
                                      +class sparseml.optim.modifier.BaseProp[source]

                                      Bases: abc.ABC

                                      BaseProp class meant to be implemented by any property decorators

                                      -abstract getter(func_get: Callable)[source]
                                      +abstract getter(func_get: Callable)[source]
                                      Parameters

                                      func_get – the getter function

                                      @@ -643,7 +643,7 @@

                                      Submodules
                                      -abstract setter(func_set: Callable)[source]
                                      +abstract setter(func_set: Callable)[source]
                                      Parameters

                                      func_set – the setter function

                                      @@ -658,7 +658,7 @@

                                      Submodules
                                      -class sparseml.optim.modifier.BaseScheduled(start_epoch: float, min_start: float, end_epoch: float, min_end: float, end_comparator: Optional[int], **kwargs)[source]
                                      +class sparseml.optim.modifier.BaseScheduled(start_epoch: float, min_start: float, end_epoch: float, min_end: float, end_comparator: Optional[int], **kwargs)[source]

                                      Bases: sparseml.optim.modifier.BaseObject

                                      Abstract class meant to be used for all scheduled modifiers. :py:func ~Modifier is also meant to be inherited alongside this class. @@ -685,7 +685,7 @@

                                      Submodules
                                      -end_epoch[source]
                                      +end_epoch[source]

                                      The epoch to end the modifier at (set to -1.0 so it never ends)

                                      @@ -697,7 +697,7 @@

                                      Submodules
                                      -start_epoch[source]
                                      +start_epoch[source]

                                      The epoch to start the modifier at (set to -1.0 so it starts immediately)

                                      @@ -709,7 +709,7 @@

                                      Submodules
                                      -validate_schedule()[source]
                                      +validate_schedule()[source]

                                      Validate the schedule values of the params for the current instance are valid

                                      @@ -717,7 +717,7 @@

                                      Submodules
                                      -class sparseml.optim.modifier.BaseUpdate(update_frequency: float, min_frequency: float, **kwargs)[source]
                                      +class sparseml.optim.modifier.BaseUpdate(update_frequency: float, min_frequency: float, **kwargs)[source]

                                      Bases: sparseml.optim.modifier.BaseObject

                                      Abstract class meant to be used for all update modifiers. :py:func ~Modifier and :py:func ~ScheduledModifier are also meant @@ -737,7 +737,7 @@

                                      Submodules
                                      -update_frequency[source]
                                      +update_frequency[source]

                                      The number of epochs or fraction of epochs to update at between start and end

                                      @@ -749,7 +749,7 @@

                                      Submodules
                                      -validate_update()[source]
                                      +validate_update()[source]

                                      Validate the update schedule values of the params for the current instance are valid

                                      @@ -758,7 +758,7 @@

                                      Submodules
                                      -class sparseml.optim.modifier.ModifierProp(serializable: bool = True, restrict_initialized: bool = True, restrict_enabled: bool = False, restrict_extras: Optional[List[str]] = None, no_serialize_val: Optional[Any] = None, func_get: Optional[Callable] = None, func_set: Optional[Callable] = None, doc: Optional[Callable] = None)[source]
                                      +class sparseml.optim.modifier.ModifierProp(serializable: bool = True, restrict_initialized: bool = True, restrict_enabled: bool = False, restrict_extras: Optional[List[str]] = None, no_serialize_val: Optional[Any] = None, func_get: Optional[Callable] = None, func_set: Optional[Callable] = None, doc: Optional[Callable] = None)[source]

                                      Bases: sparseml.optim.modifier.BaseProp

                                      Property used to decorate a modifier. Use for creating getters and setters in a modifier. @@ -785,7 +785,7 @@

                                      Submodules
                                      -getter(func_get: Callable)sparseml.optim.modifier.BaseProp[source]
                                      +getter(func_get: Callable)sparseml.optim.modifier.BaseProp[source]

                                      Create a ModifierProp based off the current instance with the getter function

                                      Parameters
                                      @@ -799,7 +799,7 @@

                                      Submodules
                                      -property no_serialize_val
                                      +property no_serialize_val

                                      a value that if the prop is equal to, will not serialize the prop

                                      Type
                                      @@ -810,7 +810,7 @@

                                      Submodules
                                      -property restrictions
                                      +property restrictions

                                      The attributes to check for restricting when the attribute can be set

                                      Type
                                      @@ -821,7 +821,7 @@

                                      Submodules
                                      -property serializable
                                      +property serializable

                                      True if the property should be serialized (ex in yaml), False otherwise

                                      Type
                                      @@ -832,7 +832,7 @@

                                      Submodules
                                      -setter(func_set: Callable)sparseml.optim.modifier.BaseProp[source]
                                      +setter(func_set: Callable)sparseml.optim.modifier.BaseProp[source]

                                      Create a ModifierProp based off the current instance with the setter function

                                      Parameters
                                      @@ -848,7 +848,7 @@

                                      Submodules
                                      -class sparseml.optim.modifier.ModifierYAML(framework: str)[source]
                                      +class sparseml.optim.modifier.ModifierYAML(framework: str)[source]

                                      Bases: object

                                      A decorator to handle making a modifier class YAML ready. IE it can be loaded in through the yaml plugin easily.

                                      @@ -866,17 +866,17 @@

                                      Submodules
                                      -class sparseml.optim.sensitivity.LRLossSensitivityAnalysis[source]
                                      +class sparseml.optim.sensitivity.LRLossSensitivityAnalysis[source]

                                      Bases: object

                                      Basic class for tracking the results from a learning rate sensitivity analysis

                                      -add_result(lr: float, loss_measurements: List[float])[source]
                                      +add_result(lr: float, loss_measurements: List[float])[source]
                                      -dict() → Dict[str, Any][source]
                                      +dict()Dict[str, Any][source]
                                      Returns

                                      dictionary representation of the current instance

                                      @@ -886,7 +886,7 @@

                                      Submodules
                                      -static load_json(path: str)[source]
                                      +static load_json(path: str)[source]
                                      Parameters

                                      path – the path to load a previous analysis from

                                      @@ -899,7 +899,7 @@

                                      Submodules
                                      -plot(path: Optional[str], title: Optional[str] = None) → Union[Tuple[matplotlib.figure.Figure, matplotlib.axes._axes.Axes], Tuple[None, None]][source]
                                      +plot(path: Optional[str], title: Optional[str] = None)Union[Tuple[matplotlib.figure.Figure, matplotlib.axes._axes.Axes], Tuple[None, None]][source]

                                      Plot the recorded sensitivity values

                                      Parameters
                                      @@ -918,18 +918,18 @@

                                      Submodules
                                      -print_res()[source]
                                      +print_res()[source]

                                      Print the recorded sensitivity values CSV results

                                      -property results
                                      +property results
                                      -save_json(path: str)[source]
                                      +save_json(path: str)[source]
                                      Parameters

                                      path – the path to save the json file at representing the layer @@ -942,13 +942,13 @@

                                      Submodules
                                      -class sparseml.optim.sensitivity.PruningLossSensitivityAnalysis[source]
                                      +class sparseml.optim.sensitivity.PruningLossSensitivityAnalysis[source]

                                      Bases: object

                                      Analysis result for how kernel sparsity (pruning) affects the loss of a given model. Contains layer by layer results.

                                      -add_result(id_: Optional[str], name: str, index: int, sparsity: float, measurement: float, baseline: bool)[source]
                                      +add_result(id_: Optional[str], name: str, index: int, sparsity: float, measurement: float, baseline: bool)[source]

                                      Add a result to the sensitivity analysis for a specific param

                                      Parameters
                                      @@ -966,7 +966,7 @@

                                      Submodules
                                      -dict() → Dict[str, Any][source]
                                      +dict()Dict[str, Any][source]
                                      Returns

                                      dictionary representation of the current instance

                                      @@ -976,7 +976,7 @@

                                      Submodules
                                      -static from_dict(dictionary: Dict[str, Any])[source]
                                      +static from_dict(dictionary: Dict[str, Any])[source]
                                      Parameters

                                      dictionary – the dictionary to create an analysis object from

                                      @@ -989,7 +989,7 @@

                                      Submodules
                                      -get_result(id_or_name: str)sparseml.optim.sensitivity.PruningSensitivityResult[source]
                                      +get_result(id_or_name: str)sparseml.optim.sensitivity.PruningSensitivityResult[source]

                                      get a result from the sensitivity analysis for a specific param

                                      Parameters
                                      @@ -1003,7 +1003,7 @@

                                      Submodules
                                      -static load_json(path: str)[source]
                                      +static load_json(path: str)[source]
                                      Parameters

                                      path – the path to load a previous analysis from

                                      @@ -1016,7 +1016,7 @@

                                      Submodules
                                      -plot(path: Optional[str], plot_integral: bool, normalize: bool = True, title: Optional[str] = None) → Union[Tuple[matplotlib.figure.Figure, matplotlib.axes._axes.Axes], Tuple[None, None]][source]
                                      +plot(path: Optional[str], plot_integral: bool, normalize: bool = True, title: Optional[str] = None)Union[Tuple[matplotlib.figure.Figure, matplotlib.axes._axes.Axes], Tuple[None, None]][source]
                                      Parameters
                                      -property results
                                      +property results

                                      the individual results for the analysis

                                      Type
                                      @@ -1053,7 +1053,7 @@

                                      Submodules
                                      -property results_model
                                      +property results_model

                                      the overall results for the model

                                      Type
                                      @@ -1064,7 +1064,7 @@

                                      Submodules
                                      -save_json(path: str)[source]
                                      +save_json(path: str)[source]
                                      Parameters

                                      path – the path to save the json file at representing the layer @@ -1077,7 +1077,7 @@

                                      Submodules
                                      -class sparseml.optim.sensitivity.PruningPerfSensitivityAnalysis(num_cores: int, batch_size: int)[source]
                                      +class sparseml.optim.sensitivity.PruningPerfSensitivityAnalysis(num_cores: int, batch_size: int)[source]

                                      Bases: object

                                      Analysis result for how kernel sparsity (pruning) affects the loss of a given model. Contains layer by layer results.

                                      @@ -1091,7 +1091,7 @@

                                      Submodules
                                      -add_model_result(sparsity: float, measurement: float, baseline: bool)[source]
                                      +add_model_result(sparsity: float, measurement: float, baseline: bool)[source]

                                      Add a result to the sensitivity analysis for the overall model

                                      Parameters
                                      @@ -1107,7 +1107,7 @@

                                      Submodules
                                      -add_result(id_: Optional[str], name: str, index: int, sparsity: float, measurement: float, baseline: bool)[source]
                                      +add_result(id_: Optional[str], name: str, index: int, sparsity: float, measurement: float, baseline: bool)[source]

                                      Add a result to the sensitivity analysis for a specific param

                                      Parameters
                                      @@ -1126,7 +1126,7 @@

                                      Submodules
                                      -property batch_size
                                      +property batch_size

                                      the input batch size the analysis was run for

                                      Type
                                      @@ -1137,7 +1137,7 @@

                                      Submodules
                                      -dict() → Dict[str, Any][source]
                                      +dict()Dict[str, Any][source]
                                      Returns

                                      dictionary representation of the current instance

                                      @@ -1147,7 +1147,7 @@

                                      Submodules
                                      -static from_dict(dictionary: Dict[str, Any])[source]
                                      +static from_dict(dictionary: Dict[str, Any])[source]
                                      Parameters

                                      dictionary – the dictionary to create an analysis object from

                                      @@ -1160,7 +1160,7 @@

                                      Submodules
                                      -get_result(id_or_name: str)sparseml.optim.sensitivity.PruningSensitivityResult[source]
                                      +get_result(id_or_name: str)sparseml.optim.sensitivity.PruningSensitivityResult[source]

                                      get a result from the sensitivity analysis for a specific param

                                      Parameters
                                      @@ -1174,7 +1174,7 @@

                                      Submodules
                                      -static load_json(path: str)[source]
                                      +static load_json(path: str)[source]
                                      Parameters

                                      path – the path to load a previous analysis from

                                      @@ -1187,7 +1187,7 @@

                                      Submodules
                                      -property num_cores
                                      +property num_cores

                                      number of physical cpu cores the analysis was run on

                                      Type
                                      @@ -1198,7 +1198,7 @@

                                      Submodules
                                      -plot(path: Optional[str], title: Optional[str] = None) → Union[Tuple[matplotlib.figure.Figure, matplotlib.axes._axes.Axes], Tuple[None, None]][source]
                                      +plot(path: Optional[str], title: Optional[str] = None)Union[Tuple[matplotlib.figure.Figure, matplotlib.axes._axes.Axes], Tuple[None, None]][source]
                                      Parameters
                                      -property results
                                      +property results

                                      the individual results for the analysis

                                      Type
                                      @@ -1232,7 +1232,7 @@

                                      Submodules
                                      -property results_model
                                      +property results_model

                                      the overall results for the model

                                      Type
                                      @@ -1243,7 +1243,7 @@

                                      Submodules
                                      -save_json(path: str)[source]
                                      +save_json(path: str)[source]
                                      Parameters

                                      path – the path to save the json file at representing the layer @@ -1256,7 +1256,7 @@

                                      Submodules
                                      -class sparseml.optim.sensitivity.PruningSensitivityResult(id_: str, name: str, index: int, baseline_measurement_index: int = - 1, baseline_measurement_key: Optional[str] = None, sparse_measurements: Optional[Dict[float, List[float]]] = None)[source]
                                      +class sparseml.optim.sensitivity.PruningSensitivityResult(id_: str, name: str, index: int, baseline_measurement_index: int = - 1, baseline_measurement_key: Optional[str] = None, sparse_measurements: Optional[Dict[float, List[float]]] = None)[source]

                                      Bases: object

                                      A sensitivity result for a given node/param in a model. Ex: loss sensitivity or perf sensitivity

                                      @@ -1274,7 +1274,7 @@

                                      Submodules
                                      -add_measurement(sparsity: float, loss: float, baseline: bool)[source]
                                      +add_measurement(sparsity: float, loss: float, baseline: bool)[source]

                                      add a sparse measurement to the result

                                      Parameters
                                      @@ -1289,7 +1289,7 @@

                                      Submodules
                                      -property averages
                                      +property averages

                                      average values of loss for each level recorded

                                      Type
                                      @@ -1300,7 +1300,7 @@

                                      Submodules
                                      -property baseline_average
                                      +property baseline_average

                                      the baseline average time to compare to for the result

                                      Type
                                      @@ -1311,7 +1311,7 @@

                                      Submodules
                                      -property baseline_measurement_index
                                      +property baseline_measurement_index

                                      index for where the baseline measurement is stored in the sparse_measurements, if any

                                      @@ -1323,7 +1323,7 @@

                                      Submodules
                                      -property baseline_measurement_key
                                      +property baseline_measurement_key

                                      key for where the baseline measurement is stored in the sparse_measurements, if any

                                      @@ -1335,7 +1335,7 @@

                                      Submodules
                                      -dict() → Dict[str, Any][source]
                                      +dict()Dict[str, Any][source]
                                      Returns

                                      dictionary representation of the current instance

                                      @@ -1345,7 +1345,7 @@

                                      Submodules
                                      -static from_dict(dictionary: Dict[str, Any])[source]
                                      +static from_dict(dictionary: Dict[str, Any])[source]

                                      Create a new loss sensitivity result from a dictionary of values. Expected to match the format as given in the dict() call.

                                      @@ -1360,7 +1360,7 @@

                                      Submodules
                                      -property has_baseline
                                      +property has_baseline

                                      True if the result has a baseline measurement in the sparse_measurements, False otherwise

                                      @@ -1372,7 +1372,7 @@

                                      Submodules
                                      -property id_
                                      +property id_

                                      id for the node / param

                                      Type
                                      @@ -1383,7 +1383,7 @@

                                      Submodules
                                      -property index
                                      +property index

                                      index order for when the node / param is used in the model

                                      Type
                                      @@ -1394,7 +1394,7 @@

                                      Submodules
                                      -property name
                                      +property name

                                      human readable name for the node / param

                                      Type
                                      @@ -1405,7 +1405,7 @@

                                      Submodules
                                      -property sparse_average
                                      +property sparse_average

                                      average loss across all levels recorded

                                      Type
                                      @@ -1416,7 +1416,7 @@

                                      Submodules
                                      -sparse_comparison(compare_index: int = - 1)[source]
                                      +sparse_comparison(compare_index: int = - 1)[source]

                                      Compare the baseline average to a sparse average value through the difference: sparse - baseline

                                      If compare_index is not given then will compare @@ -1438,7 +1438,7 @@

                                      Submodules
                                      -property sparse_integral
                                      +property sparse_integral

                                      integrated loss across all levels recorded

                                      Type
                                      @@ -1449,7 +1449,7 @@

                                      Submodules
                                      -property sparse_measurements
                                      +property sparse_measurements

                                      the sparse measurements

                                      Type
                                      @@ -1462,7 +1462,7 @@

                                      Submodules
                                      -sparseml.optim.sensitivity.default_pruning_sparsities_loss(extended: bool) → Tuple[float, ][source]
                                      +sparseml.optim.sensitivity.default_pruning_sparsities_loss(extended: bool)Tuple[float, ][source]

                                      The default sparsities to use for checking pruning effects on the loss

                                      Parameters
                                      @@ -1477,7 +1477,7 @@

                                      Submodules
                                      -sparseml.optim.sensitivity.default_pruning_sparsities_perf() → Tuple[float, ][source]
                                      +sparseml.optim.sensitivity.default_pruning_sparsities_perf()Tuple[float, ][source]
                                      Returns

                                      the sparsities to check for effects on the loss

                                      diff --git a/sparseml/api/sparseml.pytorch.datasets.classification.html b/sparseml/api/sparseml.pytorch.datasets.classification.html index b89e94aacc7..5a4d6872ee4 100644 --- a/sparseml/api/sparseml.pytorch.datasets.classification.html +++ b/sparseml/api/sparseml.pytorch.datasets.classification.html @@ -214,7 +214,7 @@

                                      Submoduleshere.

                                      -class sparseml.pytorch.datasets.classification.cifar.CIFAR100Dataset(root: str = '~/.cache/nm_datasets/cifar100', train: bool = True, rand_trans: bool = False)[source]
                                      +class sparseml.pytorch.datasets.classification.cifar.CIFAR100Dataset(root: str = '~/.cache/nm_datasets/cifar100', train: bool = True, rand_trans: bool = False)[source]

                                      Bases: torchvision.datasets.cifar.CIFAR100

                                      Wrapper for the CIFAR100 dataset to apply standard transforms.

                                      @@ -232,7 +232,7 @@

                                      Submodules
                                      -class sparseml.pytorch.datasets.classification.cifar.CIFAR10Dataset(root: str = '~/.cache/nm_datasets/cifar10', train: bool = True, rand_trans: bool = False)[source]
                                      +class sparseml.pytorch.datasets.classification.cifar.CIFAR10Dataset(root: str = '~/.cache/nm_datasets/cifar10', train: bool = True, rand_trans: bool = False)[source]

                                      Bases: torchvision.datasets.cifar.CIFAR10

                                      Wrapper for the CIFAR10 dataset to apply standard transforms.

                                      @@ -255,7 +255,7 @@

                                      Submoduleshere.

                                      -class sparseml.pytorch.datasets.classification.imagefolder.ImageFolderDataset(root: str = '~/.cache/nm_datasets/imagenet', train: bool = True, rand_trans: bool = False, image_size: int = 224)[source]
                                      +class sparseml.pytorch.datasets.classification.imagefolder.ImageFolderDataset(root: str = '~/.cache/nm_datasets/imagenet', train: bool = True, rand_trans: bool = False, image_size: int = 224)[source]

                                      Bases: torchvision.datasets.folder.ImageFolder

                                      Wrapper for the ImageFolder dataset to apply standard transforms. Additionally scales the inputs based off of the imagenet means and stds.

                                      @@ -284,7 +284,7 @@

                                      Submodules
                                      -property num_classes
                                      +property num_classes

                                      @@ -296,7 +296,7 @@

                                      Submoduleshere.

                                      -class sparseml.pytorch.datasets.classification.imagenet.ImageNetDataset(root: str = '~/.cache/nm_datasets/imagenet', train: bool = True, rand_trans: bool = False, image_size: int = 224)[source]
                                      +class sparseml.pytorch.datasets.classification.imagenet.ImageNetDataset(root: str = '~/.cache/nm_datasets/imagenet', train: bool = True, rand_trans: bool = False, image_size: int = 224)[source]

                                      Bases: torchvision.datasets.folder.ImageFolder

                                      Wrapper for the ImageNet dataset to apply standard transforms.

                                      @@ -321,7 +321,7 @@

                                      Submoduleshere.

                                      -class sparseml.pytorch.datasets.classification.imagenette.ImagenetteDataset(root: str = '~/.cache/nm_datasets/imagenette', train: bool = True, rand_trans: bool = False, dataset_size: sparseml.utils.datasets.imagenette.ImagenetteSize = <ImagenetteSize.s160: 's160'>, image_size: Union[None, int] = None, download: bool = True)[source]
                                      +class sparseml.pytorch.datasets.classification.imagenette.ImagenetteDataset(root: str = '~/.cache/nm_datasets/imagenette', train: bool = True, rand_trans: bool = False, dataset_size: sparseml.utils.datasets.imagenette.ImagenetteSize = <ImagenetteSize.s160: 's160'>, image_size: Union[None, int] = None, download: bool = True)[source]

                                      Bases: sparseml.utils.datasets.imagenette.ImagenetteDownloader, torchvision.datasets.folder.ImageFolder

                                      Wrapper for the imagenette (10 class) dataset that fastai created. Handles downloading and applying standard transforms.

                                      @@ -345,7 +345,7 @@

                                      Submodules
                                      -class sparseml.pytorch.datasets.classification.imagenette.ImagenetteSize(value)[source]
                                      +class sparseml.pytorch.datasets.classification.imagenette.ImagenetteSize(value)[source]

                                      Bases: enum.Enum

                                      Dataset size for Imagenette / Imagewoof. full does not resize the original dataset at all. @@ -353,24 +353,24 @@

                                      Submodules
                                      -full = 'full'
                                      +full = 'full'

                                      -s160 = 's160'
                                      +s160 = 's160'
                                      -s320 = 's320'
                                      +s320 = 's320'

                                      -class sparseml.pytorch.datasets.classification.imagenette.ImagewoofDataset(root: str = '~/.cache/nm_datasets/imagewoof', train: bool = True, rand_trans: bool = False, dataset_size: sparseml.utils.datasets.imagenette.ImagenetteSize = <ImagenetteSize.s160: 's160'>, image_size: Union[None, int] = None, download: bool = True)[source]
                                      +class sparseml.pytorch.datasets.classification.imagenette.ImagewoofDataset(root: str = '~/.cache/nm_datasets/imagewoof', train: bool = True, rand_trans: bool = False, dataset_size: sparseml.utils.datasets.imagenette.ImagenetteSize = <ImagenetteSize.s160: 's160'>, image_size: Union[None, int] = None, download: bool = True)[source]

                                      Bases: sparseml.utils.datasets.imagenette.ImagewoofDownloader, torchvision.datasets.folder.ImageFolder

                                      Wrapper for the imagewoof (10 class) dataset that fastai created. Handles downloading and applying standard transforms. @@ -400,7 +400,7 @@

                                      Submoduleshere.

                                      -class sparseml.pytorch.datasets.classification.mnist.MNISTDataset(root: str = '~/.cache/nm_datasets/mnist', train: bool = True, flatten: bool = False)[source]
                                      +class sparseml.pytorch.datasets.classification.mnist.MNISTDataset(root: str = '~/.cache/nm_datasets/mnist', train: bool = True, flatten: bool = False)[source]

                                      Bases: torchvision.datasets.mnist.MNIST

                                      Wrapper for MNIST dataset to apply standard transforms.

                                      diff --git a/sparseml/api/sparseml.pytorch.datasets.detection.html b/sparseml/api/sparseml.pytorch.datasets.detection.html index a2d50fad52f..cb2ec3e72d6 100644 --- a/sparseml/api/sparseml.pytorch.datasets.detection.html +++ b/sparseml/api/sparseml.pytorch.datasets.detection.html @@ -211,7 +211,7 @@

                                      Submodules

                                      sparseml.pytorch.datasets.detection.coco module

                                      -class sparseml.pytorch.datasets.detection.coco.CocoDetectionDataset(root: str = '~/.cache/nm_datasets/coco-detection', train: bool = False, rand_trans: bool = False, download: bool = True, year: str = '2017', image_size: int = 300, preprocessing_type: Optional[str] = None, default_boxes: Optional[sparseml.pytorch.utils.ssd_helpers.DefaultBoxes] = None)[source]
                                      +class sparseml.pytorch.datasets.detection.coco.CocoDetectionDataset(root: str = '~/.cache/nm_datasets/coco-detection', train: bool = False, rand_trans: bool = False, download: bool = True, year: str = '2017', image_size: int = 300, preprocessing_type: Optional[str] = None, default_boxes: Optional[sparseml.pytorch.utils.ssd_helpers.DefaultBoxes] = None)[source]

                                      Bases: object

                                      Wrapper for the Coco Detection dataset to apply standard transforms for input to detection models. Will return the processed image along @@ -244,7 +244,7 @@

                                      Submodules
                                      -property default_boxes
                                      +property default_boxes

                                      The DefaultBoxes object used to encode this datasets bounding boxes

                                      Type
                                      @@ -257,7 +257,7 @@

                                      Submodules
                                      -sparseml.pytorch.datasets.detection.coco.coco_2017_yolo(root: str = '~/.cache/nm_datasets/coco-detection', train: bool = False, rand_trans: bool = False, download: bool = True, year: str = '2017', image_size: int = 640, preprocessing_type: str = 'yolo')[source]
                                      +sparseml.pytorch.datasets.detection.coco.coco_2017_yolo(root: str = '~/.cache/nm_datasets/coco-detection', train: bool = False, rand_trans: bool = False, download: bool = True, year: str = '2017', image_size: int = 640, preprocessing_type: str = 'yolo')[source]

                                      Wrapper for COCO detection dataset with Dataset Registry values properly created for a Yolo model trained on 80 classes.

                                      @@ -285,7 +285,7 @@

                                      Submodules
                                      -class sparseml.pytorch.datasets.detection.helpers.AnnotatedImageTransforms(transforms: List)[source]
                                      +class sparseml.pytorch.datasets.detection.helpers.AnnotatedImageTransforms(transforms: List)[source]

                                      Bases: object

                                      Class for chaining transforms that take two parameters (images and annotations for object detection).

                                      @@ -297,7 +297,7 @@

                                      Submodules
                                      -property transforms
                                      +property transforms

                                      a list of the transforms performed by this object

                                      Type
                                      @@ -310,12 +310,12 @@

                                      Submodules
                                      -sparseml.pytorch.datasets.detection.helpers.bounding_box_and_labels_to_yolo_fmt(annotations)[source]
                                      +sparseml.pytorch.datasets.detection.helpers.bounding_box_and_labels_to_yolo_fmt(annotations)[source]

                                      -sparseml.pytorch.datasets.detection.helpers.random_horizontal_flip_image_and_annotations(image: PIL.Image.Image, annotations: Tuple[torch.Tensor, torch.Tensor], p: float = 0.5) → Tuple[PIL.Image.Image, Tuple[torch.Tensor, torch.Tensor]][source]
                                      +sparseml.pytorch.datasets.detection.helpers.random_horizontal_flip_image_and_annotations(image: PIL.Image.Image, annotations: Tuple[torch.Tensor, torch.Tensor], p: float = 0.5)Tuple[PIL.Image.Image, Tuple[torch.Tensor, torch.Tensor]][source]

                                      Performs a horizontal flip on given image and bounding boxes with probability p.

                                      Parameters
                                      @@ -333,7 +333,7 @@

                                      Submodules
                                      -sparseml.pytorch.datasets.detection.helpers.ssd_collate_fn(batch: List[Any]) → Tuple[torch.Tensor, Tuple[torch.Tensor, torch.Tensor, List[Tuple[torch.Tensor, torch.Tensor]]]][source]
                                      +sparseml.pytorch.datasets.detection.helpers.ssd_collate_fn(batch: List[Any])Tuple[torch.Tensor, Tuple[torch.Tensor, torch.Tensor, List[Tuple[torch.Tensor, torch.Tensor]]]][source]

                                      Collate function to be used for creating a DataLoader with values transformed by encode_annotation_bounding_boxes.

                                      @@ -349,7 +349,7 @@

                                      Submodules
                                      -sparseml.pytorch.datasets.detection.helpers.ssd_random_crop_image_and_annotations(image: PIL.Image.Image, annotations: Tuple[torch.Tensor, torch.Tensor]) → Tuple[PIL.Image.Image, Tuple[torch.Tensor, torch.Tensor]][source]
                                      +sparseml.pytorch.datasets.detection.helpers.ssd_random_crop_image_and_annotations(image: PIL.Image.Image, annotations: Tuple[torch.Tensor, torch.Tensor])Tuple[PIL.Image.Image, Tuple[torch.Tensor, torch.Tensor]][source]

                                      Wraps sparseml.pytorch.utils.ssd_random_crop to work in the AnnotatedImageTransforms pipeline.

                                      @@ -367,7 +367,7 @@

                                      Submodules
                                      -sparseml.pytorch.datasets.detection.helpers.yolo_collate_fn(batch: List[Any]) → Tuple[torch.Tensor, Tuple[torch.Tensor, torch.Tensor, List[Tuple[torch.Tensor, torch.Tensor]]]][source]
                                      +sparseml.pytorch.datasets.detection.helpers.yolo_collate_fn(batch: List[Any])Tuple[torch.Tensor, Tuple[torch.Tensor, torch.Tensor, List[Tuple[torch.Tensor, torch.Tensor]]]][source]

                                      Collate function to be used for creating a DataLoader with values for Yolo model input.

                                      @@ -390,7 +390,7 @@

                                      Submoduleshere.

                                      -class sparseml.pytorch.datasets.detection.voc.VOCDetectionDataset(root: str = '~/.cache/nm_datasets/voc-detection', train: bool = True, rand_trans: bool = False, download: bool = True, year: str = '2012', image_size: int = 300, preprocessing_type: Optional[str] = None, default_boxes: Optional[sparseml.pytorch.utils.ssd_helpers.DefaultBoxes] = None)[source]
                                      +class sparseml.pytorch.datasets.detection.voc.VOCDetectionDataset(root: str = '~/.cache/nm_datasets/voc-detection', train: bool = True, rand_trans: bool = False, download: bool = True, year: str = '2012', image_size: int = 300, preprocessing_type: Optional[str] = None, default_boxes: Optional[sparseml.pytorch.utils.ssd_helpers.DefaultBoxes] = None)[source]

                                      Bases: torchvision.datasets.voc.VOCDetection

                                      Wrapper for the VOC Detection dataset to apply standard transforms for input to detection models. Will return the processed image along @@ -423,7 +423,7 @@

                                      Submodules
                                      -property default_boxes
                                      +property default_boxes

                                      The DefaultBoxes object used to encode this datasets bounding boxes

                                      Type
                                      @@ -436,7 +436,7 @@

                                      Submodules
                                      -class sparseml.pytorch.datasets.detection.voc.VOCSegmentationDataset(root: str = '~/.cache/nm_datasets/voc-segmentation', train: bool = True, rand_trans: bool = False, download: bool = True, year: str = '2012', image_size: int = 300)[source]
                                      +class sparseml.pytorch.datasets.detection.voc.VOCSegmentationDataset(root: str = '~/.cache/nm_datasets/voc-segmentation', train: bool = True, rand_trans: bool = False, download: bool = True, year: str = '2012', image_size: int = 300)[source]

                                      Bases: torchvision.datasets.voc.VOCSegmentation

                                      Wrapper for the VOC Segmentation dataset to apply standard transforms.

                                      diff --git a/sparseml/api/sparseml.pytorch.datasets.html b/sparseml/api/sparseml.pytorch.datasets.html index 4502c44ee55..bd824bfa40c 100644 --- a/sparseml/api/sparseml.pytorch.datasets.html +++ b/sparseml/api/sparseml.pytorch.datasets.html @@ -242,7 +242,7 @@

                                      Submodules

                                      sparseml.pytorch.datasets.generic module

                                      -class sparseml.pytorch.datasets.generic.CacheableDataset(original: torch.utils.data.dataset.Dataset)[source]
                                      +class sparseml.pytorch.datasets.generic.CacheableDataset(original: torch.utils.data.dataset.Dataset)[source]

                                      Bases: torch.utils.data.dataset.Dataset

                                      Generates a cacheable dataset, ie stores the data in a cache in cpu memory so it doesn’t have to be loaded from disk every time.

                                      @@ -256,7 +256,7 @@

                                      Submodules
                                      -class sparseml.pytorch.datasets.generic.EarlyStopDataset(original: torch.utils.data.dataset.Dataset, early_stop: int)[source]
                                      +class sparseml.pytorch.datasets.generic.EarlyStopDataset(original: torch.utils.data.dataset.Dataset, early_stop: int)[source]

                                      Bases: torch.utils.data.dataset.Dataset

                                      Dataset that handles applying an early stop when iterating through the dataset IE will allow indexing between [0, early_stop)

                                      @@ -273,7 +273,7 @@

                                      Submodules
                                      -class sparseml.pytorch.datasets.generic.NoisyDataset(original: torch.utils.data.dataset.Dataset, intensity: float)[source]
                                      +class sparseml.pytorch.datasets.generic.NoisyDataset(original: torch.utils.data.dataset.Dataset, intensity: float)[source]

                                      Bases: torch.utils.data.dataset.Dataset

                                      Add random noise from a standard distribution mean(0) and stdev(intensity) on top of a dataset

                                      @@ -290,7 +290,7 @@

                                      Submodules
                                      -class sparseml.pytorch.datasets.generic.RandNDataset(length: int, shape: Union[int, Tuple[int, ]], normalize: bool)[source]
                                      +class sparseml.pytorch.datasets.generic.RandNDataset(length: int, shape: Union[int, Tuple[int, ]], normalize: bool)[source]

                                      Bases: torch.utils.data.dataset.Dataset

                                      Generates a random dataset

                                      @@ -311,12 +311,12 @@

                                      Submodules
                                      -class sparseml.pytorch.datasets.registry.DatasetRegistry[source]
                                      +class sparseml.pytorch.datasets.registry.DatasetRegistry[source]

                                      Bases: object

                                      Registry class for creating datasets

                                      -static attributes(key: str) → Dict[str, Any][source]
                                      +static attributes(key: str)Dict[str, Any][source]
                                      Parameters

                                      key – the dataset key (name) to create

                                      @@ -329,7 +329,7 @@

                                      Submodules
                                      -static create(key: str, *args, **kwargs) → torch.utils.data.dataset.Dataset[source]
                                      +static create(key: str, *args, **kwargs)torch.utils.data.dataset.Dataset[source]

                                      Create a new dataset for the given key

                                      Parameters
                                      @@ -343,7 +343,7 @@

                                      Submodules
                                      -static register(key: Union[str, List[str]], attributes: Dict[str, Any])[source]
                                      +static register(key: Union[str, List[str]], attributes: Dict[str, Any])[source]

                                      Register a dataset with the registry. Should be used as a decorator

                                      Parameters
                                      diff --git a/sparseml/api/sparseml.pytorch.models.classification.html b/sparseml/api/sparseml.pytorch.models.classification.html index 251fddbdbe2..fdf85b48c09 100644 --- a/sparseml/api/sparseml.pytorch.models.classification.html +++ b/sparseml/api/sparseml.pytorch.models.classification.html @@ -212,7 +212,7 @@

                                      Submodules
                                      -class sparseml.pytorch.models.classification.darknet.DarkNet(sec_settings: List[sparseml.pytorch.models.classification.darknet.DarkNetSectionSettings], num_classes: int, class_type: str)[source]
                                      +class sparseml.pytorch.models.classification.darknet.DarkNet(sec_settings: List[sparseml.pytorch.models.classification.darknet.DarkNetSectionSettings], num_classes: int, class_type: str)[source]

                                      Bases: torch.nn.modules.module.Module

                                      DarkNet implementation

                                      @@ -227,13 +227,13 @@

                                      Submodules
                                      -as_classifier()[source]
                                      +as_classifier()[source]

                                      Sets this model to return output as an image classifier through a final FC layer

                                      -as_yolo_backbone(output_blocks: Optional[List[int]] = None)[source]
                                      +as_yolo_backbone(output_blocks: Optional[List[int]] = None)[source]

                                      Sets this model to output the given residual block indices as a backbone feature extractor for a detection model such as Yolo.

                                      @@ -246,12 +246,12 @@

                                      Submodules
                                      -static create_section(settings: sparseml.pytorch.models.classification.darknet.DarkNetSectionSettings) → torch.nn.modules.container.Sequential[source]
                                      +static create_section(settings: sparseml.pytorch.models.classification.darknet.DarkNetSectionSettings)torch.nn.modules.container.Sequential[source]

                                      -forward(inp: torch.Tensor) → Union[torch.Tensor, List[torch.Tensor]][source]
                                      +forward(inp: torch.Tensor)Union[torch.Tensor, List[torch.Tensor]][source]

                                      Defines the computation performed at every call.

                                      Should be overridden by all subclasses.

                                      @@ -265,14 +265,14 @@

                                      Submodules
                                      -training: bool
                                      +training: bool

                                      -class sparseml.pytorch.models.classification.darknet.DarkNetSectionSettings(num_blocks: int, in_channels: int, hidden_channels: int, out_channels: int, downsample_out_channels: Union[None, int] = None)[source]
                                      +class sparseml.pytorch.models.classification.darknet.DarkNetSectionSettings(num_blocks: int, in_channels: int, hidden_channels: int, out_channels: int, downsample_out_channels: Union[None, int] = None)[source]

                                      Bases: object

                                      Settings to describe how to put together a DarkNet based architecture using user supplied configurations.

                                      @@ -293,7 +293,7 @@

                                      Submodules
                                      -sparseml.pytorch.models.classification.darknet.darknet53(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.darknet.DarkNet[source]
                                      +sparseml.pytorch.models.classification.darknet.darknet53(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.darknet.DarkNet[source]

                                      DarkNet-53 implementation as described in the Yolo v3 paper; expected input shape is (B, 3, 256, 256)

                                      @@ -333,7 +333,7 @@

                                      Submoduleshere.

                                      -class sparseml.pytorch.models.classification.efficientnet.EfficientNet(sec_settings: List[sparseml.pytorch.models.classification.efficientnet.EfficientNetSectionSettings], out_channels: int, num_classes: int, class_type: str, dropout: float)[source]
                                      +class sparseml.pytorch.models.classification.efficientnet.EfficientNet(sec_settings: List[sparseml.pytorch.models.classification.efficientnet.EfficientNetSectionSettings], out_channels: int, num_classes: int, class_type: str, dropout: float)[source]

                                      Bases: torch.nn.modules.module.Module

                                      EfficientNet implementation

                                      @@ -350,12 +350,12 @@

                                      Submodules
                                      -static create_section(settings: sparseml.pytorch.models.classification.efficientnet.EfficientNetSectionSettings) → torch.nn.modules.container.Sequential[source]
                                      +static create_section(settings: sparseml.pytorch.models.classification.efficientnet.EfficientNetSectionSettings)torch.nn.modules.container.Sequential[source]

                                      -forward(inp: torch.Tensor) → Tuple[torch.Tensor, torch.Tensor][source]
                                      +forward(inp: torch.Tensor)Tuple[torch.Tensor, torch.Tensor][source]

                                      Defines the computation performed at every call.

                                      Should be overridden by all subclasses.

                                      @@ -369,14 +369,14 @@

                                      Submodules
                                      -training: bool
                                      +training: bool

                                      -class sparseml.pytorch.models.classification.efficientnet.EfficientNetSectionSettings(num_blocks: int, in_channels: int, out_channels: int, kernel_size: int, expansion_ratio: int, stride: int, se_ratio: Optional[float], se_mod: bool)[source]
                                      +class sparseml.pytorch.models.classification.efficientnet.EfficientNetSectionSettings(num_blocks: int, in_channels: int, out_channels: int, kernel_size: int, expansion_ratio: int, stride: int, se_ratio: Optional[float], se_mod: bool)[source]

                                      Bases: object

                                      Settings to describe how to put together an EfficientNet architecture using user supplied configurations.

                                      @@ -401,7 +401,7 @@

                                      Submodules
                                      -sparseml.pytorch.models.classification.efficientnet.efficientnet_b0(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single', dropout: float = 0.2, se_mod: bool = False)sparseml.pytorch.models.classification.efficientnet.EfficientNet[source]
                                      +sparseml.pytorch.models.classification.efficientnet.efficientnet_b0(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single', dropout: float = 0.2, se_mod: bool = False)sparseml.pytorch.models.classification.efficientnet.EfficientNet[source]

                                      EfficientNet B0 implementation; expected input shape is (B, 3, 224, 224)

                                      Parameters
                                      @@ -438,7 +438,7 @@

                                      Submodules
                                      -sparseml.pytorch.models.classification.efficientnet.efficientnet_b1(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single', dropout: float = 0.2, se_mod: bool = False)sparseml.pytorch.models.classification.efficientnet.EfficientNet[source]
                                      +sparseml.pytorch.models.classification.efficientnet.efficientnet_b1(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single', dropout: float = 0.2, se_mod: bool = False)sparseml.pytorch.models.classification.efficientnet.EfficientNet[source]

                                      EfficientNet B1 implementation; expected input shape is (B, 3, 240, 240)

                                      Parameters
                                      @@ -475,7 +475,7 @@

                                      Submodules
                                      -sparseml.pytorch.models.classification.efficientnet.efficientnet_b2(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single', dropout: float = 0.3, se_mod: bool = False)sparseml.pytorch.models.classification.efficientnet.EfficientNet[source]
                                      +sparseml.pytorch.models.classification.efficientnet.efficientnet_b2(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single', dropout: float = 0.3, se_mod: bool = False)sparseml.pytorch.models.classification.efficientnet.EfficientNet[source]

                                      EfficientNet B2 implementation; expected input shape is (B, 3, 260, 260)

                                      Parameters
                                      @@ -512,7 +512,7 @@

                                      Submodules
                                      -sparseml.pytorch.models.classification.efficientnet.efficientnet_b3(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single', dropout: float = 0.3, se_mod: bool = False)sparseml.pytorch.models.classification.efficientnet.EfficientNet[source]
                                      +sparseml.pytorch.models.classification.efficientnet.efficientnet_b3(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single', dropout: float = 0.3, se_mod: bool = False)sparseml.pytorch.models.classification.efficientnet.EfficientNet[source]

                                      EfficientNet B3 implementation; expected input shape is (B, 3, 300, 300)

                                      Parameters
                                      @@ -549,7 +549,7 @@

                                      Submodules
                                      -sparseml.pytorch.models.classification.efficientnet.efficientnet_b4(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single', dropout: float = 0.4, se_mod: bool = False)sparseml.pytorch.models.classification.efficientnet.EfficientNet[source]
                                      +sparseml.pytorch.models.classification.efficientnet.efficientnet_b4(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single', dropout: float = 0.4, se_mod: bool = False)sparseml.pytorch.models.classification.efficientnet.EfficientNet[source]

                                      EfficientNet B4 implementation; expected input shape is (B, 3, 380, 380)

                                      Parameters
                                      @@ -586,7 +586,7 @@

                                      Submodules
                                      -sparseml.pytorch.models.classification.efficientnet.efficientnet_b5(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single', dropout: float = 0.4, se_mod: bool = False)sparseml.pytorch.models.classification.efficientnet.EfficientNet[source]
                                      +sparseml.pytorch.models.classification.efficientnet.efficientnet_b5(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single', dropout: float = 0.4, se_mod: bool = False)sparseml.pytorch.models.classification.efficientnet.EfficientNet[source]

                                      EfficientNet B5 implementation; expected input shape is (B, 3, 456, 456)

                                      Parameters
                                      @@ -623,7 +623,7 @@

                                      Submodules
                                      -sparseml.pytorch.models.classification.efficientnet.efficientnet_b6(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single', dropout: float = 0.5, se_mod: bool = False)sparseml.pytorch.models.classification.efficientnet.EfficientNet[source]
                                      +sparseml.pytorch.models.classification.efficientnet.efficientnet_b6(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single', dropout: float = 0.5, se_mod: bool = False)sparseml.pytorch.models.classification.efficientnet.EfficientNet[source]

                                      EfficientNet B6 implementation; expected input shape is (B, 3, 528, 528)

                                      Parameters
                                      @@ -660,7 +660,7 @@

                                      Submodules
                                      -sparseml.pytorch.models.classification.efficientnet.efficientnet_b7(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single', dropout: float = 0.5, se_mod: bool = False)sparseml.pytorch.models.classification.efficientnet.EfficientNet[source]
                                      +sparseml.pytorch.models.classification.efficientnet.efficientnet_b7(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single', dropout: float = 0.5, se_mod: bool = False)sparseml.pytorch.models.classification.efficientnet.EfficientNet[source]

                                      EfficientNet B0 implementation; expected input shape is (B, 3, 600, 600)

                                      Parameters
                                      @@ -702,7 +702,7 @@

                                      Submoduleshere.

                                      -class sparseml.pytorch.models.classification.inception_v3.InceptionV3(num_classes: int, class_type: str, enable_aux: bool)[source]
                                      +class sparseml.pytorch.models.classification.inception_v3.InceptionV3(num_classes: int, class_type: str, enable_aux: bool)[source]

                                      Bases: torch.nn.modules.module.Module

                                      InceptionV3 implementation

                                      @@ -719,7 +719,7 @@

                                      Submodules
                                      -forward(x_tens: torch.Tensor) → Tuple[torch.Tensor, ][source]
                                      +forward(x_tens: torch.Tensor)Tuple[torch.Tensor, ][source]

                                      Defines the computation performed at every call.

                                      Should be overridden by all subclasses.

                                      @@ -733,14 +733,14 @@

                                      Submodules
                                      -training: bool
                                      +training: bool

                                      -sparseml.pytorch.models.classification.inception_v3.inception_v3(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single', enable_aux: bool = True)sparseml.pytorch.models.classification.inception_v3.InceptionV3[source]
                                      +sparseml.pytorch.models.classification.inception_v3.inception_v3(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single', enable_aux: bool = True)sparseml.pytorch.models.classification.inception_v3.InceptionV3[source]

                                      Standard InceptionV3 implementation; expected input shape is (B, 3, 299, 299)

                                      @@ -782,7 +782,7 @@

                                      Submodules
                                      -class sparseml.pytorch.models.classification.mnist.MnistNet(num_classes: int = 10, class_type: str = 'single')[source]
                                      +class sparseml.pytorch.models.classification.mnist.MnistNet(num_classes: int = 10, class_type: str = 'single')[source]

                                      Bases: torch.nn.modules.module.Module

                                      A simple convolutional model created for the MNIST dataset

                                      @@ -796,7 +796,7 @@

                                      Submodules
                                      -forward(inp: torch.Tensor)[source]
                                      +forward(inp: torch.Tensor)[source]

                                      Defines the computation performed at every call.

                                      Should be overridden by all subclasses.

                                      @@ -810,14 +810,14 @@

                                      Submodules
                                      -training: bool
                                      +training: bool

                                      -sparseml.pytorch.models.classification.mnist.mnist_net(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 10, class_type: str = 'single')sparseml.pytorch.models.classification.mnist.MnistNet[source]
                                      +sparseml.pytorch.models.classification.mnist.mnist_net(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 10, class_type: str = 'single')sparseml.pytorch.models.classification.mnist.MnistNet[source]

                                      MnistNet implementation; expected input shape is (B, 1, 28, 28)

                                      Parameters
                                      @@ -856,7 +856,7 @@

                                      Submoduleshere.

                                      -class sparseml.pytorch.models.classification.mobilenet.MobileNet(sec_settings: List[sparseml.pytorch.models.classification.mobilenet.MobileNetSectionSettings], num_classes: int, class_type: str, dropout: Union[None, float] = None)[source]
                                      +class sparseml.pytorch.models.classification.mobilenet.MobileNet(sec_settings: List[sparseml.pytorch.models.classification.mobilenet.MobileNetSectionSettings], num_classes: int, class_type: str, dropout: Union[None, float] = None)[source]

                                      Bases: torch.nn.modules.module.Module

                                      MobileNet implementation

                                      @@ -873,12 +873,12 @@

                                      Submodules
                                      -static create_section(settings: sparseml.pytorch.models.classification.mobilenet.MobileNetSectionSettings) → torch.nn.modules.container.Sequential[source]
                                      +static create_section(settings: sparseml.pytorch.models.classification.mobilenet.MobileNetSectionSettings)torch.nn.modules.container.Sequential[source]

                                      -forward(inp: torch.Tensor)[source]
                                      +forward(inp: torch.Tensor)[source]

                                      Defines the computation performed at every call.

                                      Should be overridden by all subclasses.

                                      @@ -892,14 +892,14 @@

                                      Submodules
                                      -training: bool
                                      +training: bool

                                      -class sparseml.pytorch.models.classification.mobilenet.MobileNetSectionSettings(num_blocks: int, in_channels: int, out_channels: int, downsample: bool)[source]
                                      +class sparseml.pytorch.models.classification.mobilenet.MobileNetSectionSettings(num_blocks: int, in_channels: int, out_channels: int, downsample: bool)[source]

                                      Bases: object

                                      Settings to describe how to put together a MobileNet architecture using user supplied configurations.

                                      @@ -918,7 +918,7 @@

                                      Submodules
                                      -sparseml.pytorch.models.classification.mobilenet.han_mobilenet(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.mobilenet.MobileNet[source]
                                      +sparseml.pytorch.models.classification.mobilenet.han_mobilenet(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.mobilenet.MobileNet[source]

                                      Standard MobileNet implementation with width=1.0; expected input shape is (B, 3, 224, 224)

                                      @@ -953,7 +953,7 @@

                                      Submodules
                                      -sparseml.pytorch.models.classification.mobilenet.mobilenet(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.mobilenet.MobileNet[source]
                                      +sparseml.pytorch.models.classification.mobilenet.mobilenet(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.mobilenet.MobileNet[source]

                                      Standard MobileNet implementation with width=1.0; expected input shape is (B, 3, 224, 224)

                                      @@ -993,17 +993,17 @@

                                      Submoduleshere.

                                      -class sparseml.pytorch.models.classification.mobilenet_v2.MobilenetV2(sec_settings: List[sparseml.pytorch.models.classification.mobilenet_v2.MobilenetV2SectionSettings], num_classes: int, class_type: str)[source]
                                      +class sparseml.pytorch.models.classification.mobilenet_v2.MobilenetV2(sec_settings: List[sparseml.pytorch.models.classification.mobilenet_v2.MobilenetV2SectionSettings], num_classes: int, class_type: str)[source]

                                      Bases: torch.nn.modules.module.Module

                                      Standard MobileNetV2 model https://arxiv.org/abs/1801.04381

                                      -static create_section(settings: sparseml.pytorch.models.classification.mobilenet_v2.MobilenetV2SectionSettings) → torch.nn.modules.container.Sequential[source]
                                      +static create_section(settings: sparseml.pytorch.models.classification.mobilenet_v2.MobilenetV2SectionSettings)torch.nn.modules.container.Sequential[source]
                                      -forward(inp: torch.Tensor)[source]
                                      +forward(inp: torch.Tensor)[source]

                                      Defines the computation performed at every call.

                                      Should be overridden by all subclasses.

                                      @@ -1017,14 +1017,14 @@

                                      Submodules
                                      -training: bool
                                      +training: bool

                                      -class sparseml.pytorch.models.classification.mobilenet_v2.MobilenetV2SectionSettings(num_blocks: int, in_channels: int, out_channels: int, downsample: bool, exp_channels: Union[None, int] = None, exp_ratio: float = 1.0, init_section: bool = False, width_mult: float = 1.0)[source]
                                      +class sparseml.pytorch.models.classification.mobilenet_v2.MobilenetV2SectionSettings(num_blocks: int, in_channels: int, out_channels: int, downsample: bool, exp_channels: Union[None, int] = None, exp_ratio: float = 1.0, init_section: bool = False, width_mult: float = 1.0)[source]

                                      Bases: object

                                      Settings to describe how to put together MobileNet V2 architecture using user supplied configurations.

                                      @@ -1048,7 +1048,7 @@

                                      Submodules
                                      -sparseml.pytorch.models.classification.mobilenet_v2.mobilenet_v2(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.mobilenet_v2.MobilenetV2[source]
                                      +sparseml.pytorch.models.classification.mobilenet_v2.mobilenet_v2(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.mobilenet_v2.MobilenetV2[source]

                                      Standard MobileNet V2 implementation for a width multiplier; expected input shape is (B, 3, 224, 224)

                                      @@ -1083,7 +1083,7 @@

                                      Submodules
                                      -sparseml.pytorch.models.classification.mobilenet_v2.mobilenet_v2_width(width_mult: float, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.mobilenet_v2.MobilenetV2[source]
                                      +sparseml.pytorch.models.classification.mobilenet_v2.mobilenet_v2_width(width_mult: float, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.mobilenet_v2.MobilenetV2[source]

                                      Standard MobileNet V2 implementation for a width multiplier; expected input shape is (B, 3, 224, 224)

                                      @@ -1113,7 +1113,7 @@

                                      Submoduleshere.

                                      -class sparseml.pytorch.models.classification.resnet.ResNet(sec_settings: List[sparseml.pytorch.models.classification.resnet.ResNetSectionSettings], num_classes: int, class_type: str)[source]
                                      +class sparseml.pytorch.models.classification.resnet.ResNet(sec_settings: List[sparseml.pytorch.models.classification.resnet.ResNetSectionSettings], num_classes: int, class_type: str)[source]

                                      Bases: torch.nn.modules.module.Module

                                      ResNet, ResNet V2, ResNext implementations.

                                      @@ -1128,12 +1128,12 @@

                                      Submodules
                                      -static create_section(settings: sparseml.pytorch.models.classification.resnet.ResNetSectionSettings) → torch.nn.modules.container.Sequential[source]
                                      +static create_section(settings: sparseml.pytorch.models.classification.resnet.ResNetSectionSettings)torch.nn.modules.container.Sequential[source]

                                      -forward(inp: torch.Tensor)[source]
                                      +forward(inp: torch.Tensor)[source]

                                      Defines the computation performed at every call.

                                      Should be overridden by all subclasses.

                                      @@ -1147,14 +1147,14 @@

                                      Submodules
                                      -training: bool
                                      +training: bool

                                      -class sparseml.pytorch.models.classification.resnet.ResNetSectionSettings(num_blocks: int, in_channels: int, out_channels: int, downsample: bool, proj_channels: int = - 1, groups: int = 1, use_se: bool = False, version: int = 1)[source]
                                      +class sparseml.pytorch.models.classification.resnet.ResNetSectionSettings(num_blocks: int, in_channels: int, out_channels: int, downsample: bool, proj_channels: int = - 1, groups: int = 1, use_se: bool = False, version: int = 1)[source]

                                      Bases: object

                                      Settings to describe how to put together a ResNet based architecture using user supplied configurations.

                                      @@ -1179,7 +1179,7 @@

                                      Submodules
                                      -sparseml.pytorch.models.classification.resnet.resnet101(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.resnet.ResNet[source]
                                      +sparseml.pytorch.models.classification.resnet.resnet101(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.resnet.ResNet[source]

                                      Standard ResNet 101 implementation; expected input shape is (B, 3, 224, 224)

                                      @@ -1214,7 +1214,7 @@

                                      Submodules
                                      -sparseml.pytorch.models.classification.resnet.resnet101_2xwidth(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.resnet.ResNet[source]
                                      +sparseml.pytorch.models.classification.resnet.resnet101_2xwidth(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.resnet.ResNet[source]

                                      ResNet 101 implementation where channel sizes for 3x3 convolutions are doubled; expected input shape is (B, 3, 224, 224)

                                      @@ -1249,7 +1249,7 @@

                                      Submodules
                                      -sparseml.pytorch.models.classification.resnet.resnet152(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.resnet.ResNet[source]
                                      +sparseml.pytorch.models.classification.resnet.resnet152(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.resnet.ResNet[source]

                                      Standard ResNet 152 implementation; expected input shape is (B, 3, 224, 224)

                                      @@ -1284,7 +1284,7 @@

                                      Submodules
                                      -sparseml.pytorch.models.classification.resnet.resnet18(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.resnet.ResNet[source]
                                      +sparseml.pytorch.models.classification.resnet.resnet18(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.resnet.ResNet[source]

                                      Standard ResNet 18 implementation; expected input shape is (B, 3, 224, 224)

                                      @@ -1319,7 +1319,7 @@

                                      Submodules
                                      -sparseml.pytorch.models.classification.resnet.resnet34(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.resnet.ResNet[source]
                                      +sparseml.pytorch.models.classification.resnet.resnet34(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.resnet.ResNet[source]

                                      Standard ResNet 34 implementation; expected input shape is (B, 3, 224, 224)

                                      @@ -1354,7 +1354,7 @@

                                      Submodules
                                      -sparseml.pytorch.models.classification.resnet.resnet50(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.resnet.ResNet[source]
                                      +sparseml.pytorch.models.classification.resnet.resnet50(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.resnet.ResNet[source]

                                      Standard ResNet 50 implementation; expected input shape is (B, 3, 224, 224)

                                      @@ -1389,7 +1389,7 @@

                                      Submodules
                                      -sparseml.pytorch.models.classification.resnet.resnet50_2xwidth(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.resnet.ResNet[source]
                                      +sparseml.pytorch.models.classification.resnet.resnet50_2xwidth(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.resnet.ResNet[source]

                                      ResNet 50 implementation where channel sizes for 3x3 convolutions are doubled; expected input shape is (B, 3, 224, 224)

                                      @@ -1424,7 +1424,7 @@

                                      Submodules
                                      -sparseml.pytorch.models.classification.resnet.resnetv2_101(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.resnet.ResNet[source]
                                      +sparseml.pytorch.models.classification.resnet.resnetv2_101(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.resnet.ResNet[source]

                                      Standard ResNet V2 101 implementation; expected input shape is (B, 3, 224, 224)

                                      @@ -1459,7 +1459,7 @@

                                      Submodules
                                      -sparseml.pytorch.models.classification.resnet.resnetv2_152(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.resnet.ResNet[source]
                                      +sparseml.pytorch.models.classification.resnet.resnetv2_152(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.resnet.ResNet[source]

                                      Standard ResNet V2 152 implementation; expected input shape is (B, 3, 224, 224)

                                      @@ -1494,7 +1494,7 @@

                                      Submodules
                                      -sparseml.pytorch.models.classification.resnet.resnetv2_18(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.resnet.ResNet[source]
                                      +sparseml.pytorch.models.classification.resnet.resnetv2_18(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.resnet.ResNet[source]

                                      Standard ResNet V2 18 implementation; expected input shape is (B, 3, 224, 224)

                                      @@ -1529,7 +1529,7 @@

                                      Submodules
                                      -sparseml.pytorch.models.classification.resnet.resnetv2_34(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.resnet.ResNet[source]
                                      +sparseml.pytorch.models.classification.resnet.resnetv2_34(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.resnet.ResNet[source]

                                      Standard ResNet V2 34 implementation; expected input shape is (B, 3, 224, 224)

                                      @@ -1564,7 +1564,7 @@

                                      Submodules
                                      -sparseml.pytorch.models.classification.resnet.resnetv2_50(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.resnet.ResNet[source]
                                      +sparseml.pytorch.models.classification.resnet.resnetv2_50(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.resnet.ResNet[source]

                                      Standard ResNet V2 50 implementation; expected input shape is (B, 3, 224, 224)

                                      @@ -1599,7 +1599,7 @@

                                      Submodules
                                      -sparseml.pytorch.models.classification.resnet.resnext101(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.resnet.ResNet[source]
                                      +sparseml.pytorch.models.classification.resnet.resnext101(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.resnet.ResNet[source]

                                      Standard ResNext 101 implementation; expected input shape is (B, 3, 224, 224)

                                      @@ -1634,7 +1634,7 @@

                                      Submodules
                                      -sparseml.pytorch.models.classification.resnet.resnext152(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.resnet.ResNet[source]
                                      +sparseml.pytorch.models.classification.resnet.resnext152(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.resnet.ResNet[source]

                                      Standard ResNext 152 implementation; expected input shape is (B, 3, 224, 224)

                                      @@ -1669,7 +1669,7 @@

                                      Submodules
                                      -sparseml.pytorch.models.classification.resnet.resnext50(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.resnet.ResNet[source]
                                      +sparseml.pytorch.models.classification.resnet.resnext50(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.resnet.ResNet[source]

                                      Standard ResNext 50 implementation; expected input shape is (B, 3, 224, 224)

                                      @@ -1709,7 +1709,7 @@

                                      Submoduleshere.

                                      -class sparseml.pytorch.models.classification.vgg.VGG(sec_settings: List[sparseml.pytorch.models.classification.vgg.VGGSectionSettings], num_classes: int, class_type: str)[source]
                                      +class sparseml.pytorch.models.classification.vgg.VGG(sec_settings: List[sparseml.pytorch.models.classification.vgg.VGGSectionSettings], num_classes: int, class_type: str)[source]

                                      Bases: torch.nn.modules.module.Module

                                      VGG implementation

                                      @@ -1724,12 +1724,12 @@

                                      Submodules
                                      -static create_section(settings: sparseml.pytorch.models.classification.vgg.VGGSectionSettings) → torch.nn.modules.container.Sequential[source]
                                      +static create_section(settings: sparseml.pytorch.models.classification.vgg.VGGSectionSettings)torch.nn.modules.container.Sequential[source]

                                      -forward(inp)[source]
                                      +forward(inp)[source]

                                      Defines the computation performed at every call.

                                      Should be overridden by all subclasses.

                                      @@ -1743,14 +1743,14 @@

                                      Submodules
                                      -training: bool
                                      +training: bool

                                      -sparseml.pytorch.models.classification.vgg.vgg11(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.vgg.VGG[source]
                                      +sparseml.pytorch.models.classification.vgg.vgg11(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.vgg.VGG[source]

                                      Standard VGG 11; expected input shape is (B, 3, 224, 224)

                                      Parameters
                                      @@ -1784,7 +1784,7 @@

                                      Submodules
                                      -sparseml.pytorch.models.classification.vgg.vgg11bn(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.vgg.VGG[source]
                                      +sparseml.pytorch.models.classification.vgg.vgg11bn(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.vgg.VGG[source]

                                      VGG 11 with batch norm added; expected input shape is (B, 3, 224, 224)

                                      Parameters
                                      @@ -1818,7 +1818,7 @@

                                      Submodules
                                      -sparseml.pytorch.models.classification.vgg.vgg13(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.vgg.VGG[source]
                                      +sparseml.pytorch.models.classification.vgg.vgg13(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.vgg.VGG[source]

                                      Standard VGG 13; expected input shape is (B, 3, 224, 224)

                                      Parameters
                                      @@ -1852,7 +1852,7 @@

                                      Submodules
                                      -sparseml.pytorch.models.classification.vgg.vgg13bn(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.vgg.VGG[source]
                                      +sparseml.pytorch.models.classification.vgg.vgg13bn(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.vgg.VGG[source]

                                      VGG 13 with batch norm added; expected input shape is (B, 3, 224, 224)

                                      Parameters
                                      @@ -1886,7 +1886,7 @@

                                      Submodules
                                      -sparseml.pytorch.models.classification.vgg.vgg16(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.vgg.VGG[source]
                                      +sparseml.pytorch.models.classification.vgg.vgg16(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.vgg.VGG[source]

                                      Standard VGG 16; expected input shape is (B, 3, 224, 224)

                                      Parameters
                                      @@ -1920,7 +1920,7 @@

                                      Submodules
                                      -sparseml.pytorch.models.classification.vgg.vgg16bn(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.vgg.VGG[source]
                                      +sparseml.pytorch.models.classification.vgg.vgg16bn(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.vgg.VGG[source]

                                      VGG 16 with batch norm added; expected input shape is (B, 3, 224, 224)

                                      Parameters
                                      @@ -1954,7 +1954,7 @@

                                      Submodules
                                      -sparseml.pytorch.models.classification.vgg.vgg19(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.vgg.VGG[source]
                                      +sparseml.pytorch.models.classification.vgg.vgg19(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.vgg.VGG[source]

                                      Standard VGG 19; expected input shape is (B, 3, 224, 224)

                                      Parameters
                                      @@ -1988,7 +1988,7 @@

                                      Submodules
                                      -sparseml.pytorch.models.classification.vgg.vgg19bn(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.vgg.VGG[source]
                                      +sparseml.pytorch.models.classification.vgg.vgg19bn(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 1000, class_type: str = 'single')sparseml.pytorch.models.classification.vgg.VGG[source]

                                      VGG 19 with batch norm added; expected input shape is (B, 3, 224, 224)

                                      Parameters
                                      diff --git a/sparseml/api/sparseml.pytorch.models.detection.html b/sparseml/api/sparseml.pytorch.models.detection.html index 2e189a2bcae..687bb3cf821 100644 --- a/sparseml/api/sparseml.pytorch.models.detection.html +++ b/sparseml/api/sparseml.pytorch.models.detection.html @@ -214,7 +214,7 @@

                                      Submoduleshere.

                                      -class sparseml.pytorch.models.detection.ssd.SSD300(backbone: sparseml.pytorch.models.detection.ssd.SSDBackbone, num_classes: int = 91)[source]
                                      +class sparseml.pytorch.models.detection.ssd.SSD300(backbone: sparseml.pytorch.models.detection.ssd.SSDBackbone, num_classes: int = 91)[source]

                                      Bases: torch.nn.modules.module.Module

                                      Single Shot Detector model that takes in a generic CNN backbone

                                      @@ -229,7 +229,7 @@

                                      Submodules
                                      -forward(inp: torch.Tensor) → Tuple[torch.Tensor, torch.Tensor][source]
                                      +forward(inp: torch.Tensor)Tuple[torch.Tensor, torch.Tensor][source]

                                      Defines the computation performed at every call.

                                      Should be overridden by all subclasses.

                                      @@ -243,19 +243,19 @@

                                      Submodules
                                      -training: bool
                                      +training: bool

                                      -class sparseml.pytorch.models.detection.ssd.SSDBackbone[source]
                                      +class sparseml.pytorch.models.detection.ssd.SSDBackbone[source]

                                      Bases: abc.ABC

                                      Abstract class for representing backbone models for Single Shot Detectors

                                      -abstract get_feature_extractor() → torch.nn.modules.module.Module[source]
                                      +abstract get_feature_extractor()torch.nn.modules.module.Module[source]
                                      Returns

                                      A feature extrator module to be used for an SSD model

                                      @@ -265,7 +265,7 @@

                                      Submodules
                                      -abstract property out_channels
                                      +abstract property out_channels

                                      a list of the sizes of the addtional out channels to be used with this backbone

                                      @@ -285,7 +285,7 @@

                                      Submoduleshere.

                                      -class sparseml.pytorch.models.detection.ssd_lite.SSD300Lite(backbone: sparseml.pytorch.models.detection.ssd.SSDBackbone, backbone_early_output_idx: int, num_classes: int = 91)[source]
                                      +class sparseml.pytorch.models.detection.ssd_lite.SSD300Lite(backbone: sparseml.pytorch.models.detection.ssd.SSDBackbone, backbone_early_output_idx: int, num_classes: int = 91)[source]

                                      Bases: torch.nn.modules.module.Module

                                      Single Shot Detector model that takes in a CNN backbone and uses depthwise convolutions to perform fast object detection.

                                      @@ -304,7 +304,7 @@

                                      Submodules
                                      -forward(tens: torch.Tensor) → Tuple[torch.Tensor, torch.Tensor][source]
                                      +forward(tens: torch.Tensor)Tuple[torch.Tensor, torch.Tensor][source]

                                      Defines the computation performed at every call.

                                      Should be overridden by all subclasses.

                                      @@ -318,7 +318,7 @@

                                      Submodules
                                      -training: bool
                                      +training: bool

                                      @@ -329,7 +329,7 @@

                                      Submodules
                                      -class sparseml.pytorch.models.detection.ssd_mobilenet.SSD300MobileNetBackbone(version: Union[str, int] = '2', pretrained: Union[bool, str] = True, pretrained_path: Optional[str] = None)[source]
                                      +class sparseml.pytorch.models.detection.ssd_mobilenet.SSD300MobileNetBackbone(version: Union[str, int] = '2', pretrained: Union[bool, str] = True, pretrained_path: Optional[str] = None)[source]

                                      Bases: sparseml.pytorch.models.detection.ssd.SSDBackbone

                                      Class to provide the feature extractor and define the additional conv layers for an SSD300 model for various MobileNet architecture backbones

                                      @@ -347,7 +347,7 @@

                                      Submodules
                                      -get_feature_extractor() → torch.nn.modules.module.Module[source]
                                      +get_feature_extractor()torch.nn.modules.module.Module[source]
                                      Returns

                                      MobileNet feature extractor module to be used for an SSD model

                                      @@ -357,7 +357,7 @@

                                      Submodules
                                      -property out_channels
                                      +property out_channels

                                      The number of output channels that should be used for the additional conv layers with this backbone

                                      @@ -371,7 +371,7 @@

                                      Submodules
                                      -sparseml.pytorch.models.detection.ssd_mobilenet.ssd300lite_mobilenetv2(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 91, pretrained_backbone: Union[bool, str] = True, pretrained_path_backbone: str = None)sparseml.pytorch.models.detection.ssd_lite.SSD300Lite[source]
                                      +sparseml.pytorch.models.detection.ssd_mobilenet.ssd300lite_mobilenetv2(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 91, pretrained_backbone: Union[bool, str] = True, pretrained_path_backbone: str = None)sparseml.pytorch.models.detection.ssd_lite.SSD300Lite[source]

                                      SSD 300 Lite with MobileNet V2 backbone; expected input shape is (B, 3, 300, 300)

                                      @@ -413,7 +413,7 @@

                                      Submodules
                                      -class sparseml.pytorch.models.detection.ssd_resnet.SSD300ResNetBackbone(sub_arch: Union[str, int], pretrained: Union[bool, str] = True, pretrained_path: Optional[str] = None)[source]
                                      +class sparseml.pytorch.models.detection.ssd_resnet.SSD300ResNetBackbone(sub_arch: Union[str, int], pretrained: Union[bool, str] = True, pretrained_path: Optional[str] = None)[source]

                                      Bases: sparseml.pytorch.models.detection.ssd.SSDBackbone

                                      Class to provide the feature extractor and define the additional conv layers for an SSD300 model for various ResNet sub architecture backbones

                                      @@ -431,7 +431,7 @@

                                      Submodules
                                      -get_feature_extractor() → torch.nn.modules.module.Module[source]
                                      +get_feature_extractor()torch.nn.modules.module.Module[source]
                                      Returns

                                      ResNet feature extrator module to be used for an SSD model

                                      @@ -441,7 +441,7 @@

                                      Submodules
                                      -property out_channels
                                      +property out_channels

                                      The number of output channels that should be used for the additional conv layers with this backbone

                                      @@ -455,7 +455,7 @@

                                      Submodules
                                      -sparseml.pytorch.models.detection.ssd_resnet.ssd300_resnet101(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 91, pretrained_backbone: Union[bool, str] = True, pretrained_path_backbone: str = None)sparseml.pytorch.models.detection.ssd.SSD300[source]
                                      +sparseml.pytorch.models.detection.ssd_resnet.ssd300_resnet101(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 91, pretrained_backbone: Union[bool, str] = True, pretrained_path_backbone: str = None)sparseml.pytorch.models.detection.ssd.SSD300[source]

                                      SSD 300 with ResNet 101 backbone; expected input shape is (B, 3, 300, 300)

                                      @@ -493,7 +493,7 @@

                                      Submodules
                                      -sparseml.pytorch.models.detection.ssd_resnet.ssd300_resnet152(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 91, pretrained_backbone: Union[bool, str] = True, pretrained_path_backbone: str = None)sparseml.pytorch.models.detection.ssd.SSD300[source]
                                      +sparseml.pytorch.models.detection.ssd_resnet.ssd300_resnet152(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 91, pretrained_backbone: Union[bool, str] = True, pretrained_path_backbone: str = None)sparseml.pytorch.models.detection.ssd.SSD300[source]

                                      SSD 300 with ResNet 152 backbone; expected input shape is (B, 3, 300, 300)

                                      @@ -531,7 +531,7 @@

                                      Submodules
                                      -sparseml.pytorch.models.detection.ssd_resnet.ssd300_resnet18(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 91, pretrained_backbone: Union[bool, str] = True, pretrained_path_backbone: str = None)sparseml.pytorch.models.detection.ssd.SSD300[source]
                                      +sparseml.pytorch.models.detection.ssd_resnet.ssd300_resnet18(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 91, pretrained_backbone: Union[bool, str] = True, pretrained_path_backbone: str = None)sparseml.pytorch.models.detection.ssd.SSD300[source]

                                      SSD 300 with ResNet 18 backbone; expected input shape is (B, 3, 300, 300)

                                      @@ -569,7 +569,7 @@

                                      Submodules
                                      -sparseml.pytorch.models.detection.ssd_resnet.ssd300_resnet34(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 91, pretrained_backbone: Union[bool, str] = True, pretrained_path_backbone: str = None)sparseml.pytorch.models.detection.ssd.SSD300[source]
                                      +sparseml.pytorch.models.detection.ssd_resnet.ssd300_resnet34(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 91, pretrained_backbone: Union[bool, str] = True, pretrained_path_backbone: str = None)sparseml.pytorch.models.detection.ssd.SSD300[source]

                                      SSD 300 with ResNet 34 backbone; expected input shape is (B, 3, 300, 300)

                                      @@ -607,7 +607,7 @@

                                      Submodules
                                      -sparseml.pytorch.models.detection.ssd_resnet.ssd300_resnet50(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 91, pretrained_backbone: Union[bool, str] = True, pretrained_path_backbone: str = None)sparseml.pytorch.models.detection.ssd.SSD300[source]
                                      +sparseml.pytorch.models.detection.ssd_resnet.ssd300_resnet50(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 91, pretrained_backbone: Union[bool, str] = True, pretrained_path_backbone: str = None)sparseml.pytorch.models.detection.ssd.SSD300[source]

                                      SSD 300 with ResNet 50 backbone; expected input shape is (B, 3, 300, 300)

                                      @@ -649,7 +649,7 @@

                                      Submodules
                                      -class sparseml.pytorch.models.detection.yolo_v3.YoloV3(num_classes: int, backbone: torch.nn.modules.module.Module, backbone_out_channels: List[int], anchor_groups: List[torch.Tensor])[source]
                                      +class sparseml.pytorch.models.detection.yolo_v3.YoloV3(num_classes: int, backbone: torch.nn.modules.module.Module, backbone_out_channels: List[int], anchor_groups: List[torch.Tensor])[source]

                                      Bases: torch.nn.modules.module.Module

                                      Yolo v3 implementation matching standard Yolo v3 SPP configuration

                                      @@ -666,7 +666,7 @@

                                      Submodules
                                      -forward(inp: torch.Tensor)[source]
                                      +forward(inp: torch.Tensor)[source]

                                      Defines the computation performed at every call.

                                      Should be overridden by all subclasses.

                                      @@ -680,14 +680,14 @@

                                      Submodules
                                      -training: bool
                                      +training: bool

                                      -sparseml.pytorch.models.detection.yolo_v3.yolo_v3(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 80, pretrained_backbone: Union[bool, str] = False, pretrained_path_backbone: str = None)sparseml.pytorch.models.detection.yolo_v3.YoloV3[source]
                                      +sparseml.pytorch.models.detection.yolo_v3.yolo_v3(pretrained_path: Optional[str] = None, pretrained: Union[bool, str] = False, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, num_classes: int = 80, pretrained_backbone: Union[bool, str] = False, pretrained_path_backbone: str = None)sparseml.pytorch.models.detection.yolo_v3.YoloV3[source]

                                      Yolo-V3 model with standard DarkNet-53 backbone; expected input shape is (B, 3, 300, 300)

                                      diff --git a/sparseml/api/sparseml.pytorch.models.html b/sparseml/api/sparseml.pytorch.models.html index 4e8476486c6..21fe984d5a3 100644 --- a/sparseml/api/sparseml.pytorch.models.html +++ b/sparseml/api/sparseml.pytorch.models.html @@ -250,12 +250,12 @@

                                      Submodules
                                      -class sparseml.pytorch.models.registry.ModelRegistry[source]
                                      +class sparseml.pytorch.models.registry.ModelRegistry[source]

                                      Bases: object

                                      Registry class for creating models

                                      -static available_keys() → List[str][source]
                                      +static available_keys()List[str][source]
                                      Returns

                                      the keys (models) currently available in the registry

                                      @@ -265,7 +265,7 @@

                                      Submodules
                                      -static create(key: str, pretrained: Union[bool, str] = False, pretrained_path: Optional[str] = None, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, **kwargs) → torch.nn.modules.module.Module[source]
                                      +static create(key: str, pretrained: Union[bool, str] = False, pretrained_path: Optional[str] = None, pretrained_dataset: Optional[str] = None, load_strict: bool = True, ignore_error_tensors: Optional[List[str]] = None, **kwargs)torch.nn.modules.module.Module[source]

                                      Create a new model for the given key

                                      Parameters
                                      @@ -290,7 +290,7 @@

                                      Submodules
                                      -static create_zoo_model(key: str, pretrained: Union[bool, str] = True, pretrained_dataset: Optional[str] = None) → sparsezoo.objects.model.Model[source]
                                      +static create_zoo_model(key: str, pretrained: Union[bool, str] = True, pretrained_dataset: Optional[str] = None)sparsezoo.objects.model.Model[source]

                                      Create a sparsezoo Model for the desired model in the zoo

                                      Parameters
                                      @@ -309,7 +309,7 @@

                                      Submodules
                                      -static input_shape(key: str) → Any[source]
                                      +static input_shape(key: str)Any[source]
                                      Parameters

                                      key – the model key (name) to create

                                      @@ -322,7 +322,7 @@

                                      Submodules
                                      -static register(key: Union[str, List[str]], input_shape: Any, domain: str, sub_domain: str, architecture: str, sub_architecture: str, default_dataset: str, default_desc: str, repo_source: str = 'sparseml', def_ignore_error_tensors: Optional[List[str]] = None, desc_args: Optional[Dict[str, Tuple[str, Any]]] = None)[source]
                                      +static register(key: Union[str, List[str]], input_shape: Any, domain: str, sub_domain: str, architecture: str, sub_architecture: str, default_dataset: str, default_desc: str, repo_source: str = 'sparseml', def_ignore_error_tensors: Optional[List[str]] = None, desc_args: Optional[Dict[str, Tuple[str, Any]]] = None)[source]

                                      Register a model with the registry. Should be used as a decorator

                                      Parameters
                                      @@ -354,7 +354,7 @@

                                      Submodules
                                      -static register_wrapped_model_constructor(wrapped_constructor: Callable, key: Union[str, List[str]], input_shape: Any, domain: str, sub_domain: str, architecture: str, sub_architecture: str, default_dataset: str, default_desc: str, repo_source: str, def_ignore_error_tensors: Optional[List[str]] = None, desc_args: Optional[Dict[str, Tuple[str, Any]]] = None)[source]
                                      +static register_wrapped_model_constructor(wrapped_constructor: Callable, key: Union[str, List[str]], input_shape: Any, domain: str, sub_domain: str, architecture: str, sub_architecture: str, default_dataset: str, default_desc: str, repo_source: str, def_ignore_error_tensors: Optional[List[str]] = None, desc_args: Optional[Dict[str, Tuple[str, Any]]] = None)[source]

                                      Register a model with the registry from a model constructor or provider function

                                      Parameters
                                      diff --git a/sparseml/api/sparseml.pytorch.nn.html b/sparseml/api/sparseml.pytorch.nn.html index 0edeeb76eff..b65f15ee548 100644 --- a/sparseml/api/sparseml.pytorch.nn.html +++ b/sparseml/api/sparseml.pytorch.nn.html @@ -210,7 +210,7 @@

                                      Submodules
                                      -class sparseml.pytorch.nn.activations.Hardswish(num_channels: int = - 1, inplace: bool = False)[source]
                                      +class sparseml.pytorch.nn.activations.Hardswish(num_channels: int = - 1, inplace: bool = False)[source]

                                      Bases: torch.nn.modules.module.Module

                                      Hardswish layer implementation:
                                      @@ -232,7 +232,7 @@

                                      Submodules
                                      -forward(inp: torch.Tensor)[source]
                                      +forward(inp: torch.Tensor)[source]

                                      Defines the computation performed at every call.

                                      Should be overridden by all subclasses.

                                      @@ -246,14 +246,14 @@

                                      Submodules
                                      -training: bool
                                      +training: bool

                                      -class sparseml.pytorch.nn.activations.ReLU(num_channels: int = - 1, inplace: bool = False)[source]
                                      +class sparseml.pytorch.nn.activations.ReLU(num_channels: int = - 1, inplace: bool = False)[source]

                                      Bases: torch.nn.modules.activation.ReLU

                                      ReLU wrapper to enforce that number of channels for the layer is passed in. Useful for activation sparsity work.

                                      @@ -267,14 +267,14 @@

                                      Submodules
                                      -inplace: bool
                                      +inplace: bool

                                      -class sparseml.pytorch.nn.activations.ReLU6(num_channels: int = - 1, inplace: bool = False)[source]
                                      +class sparseml.pytorch.nn.activations.ReLU6(num_channels: int = - 1, inplace: bool = False)[source]

                                      Bases: torch.nn.modules.activation.ReLU6

                                      ReLU6 wrapper to enforce that number of channels for the layer is passed in. Useful for activation sparsity work.

                                      @@ -288,24 +288,24 @@

                                      Submodules
                                      -inplace: bool
                                      +inplace: bool

                                      -max_val: float
                                      +max_val: float
                                      -min_val: float
                                      +min_val: float

                                      -class sparseml.pytorch.nn.activations.Swish(num_channels: int = - 1)[source]
                                      +class sparseml.pytorch.nn.activations.Swish(num_channels: int = - 1)[source]

                                      Bases: torch.nn.modules.module.Module

                                      Swish layer OOP implementation: x * sigmoid(x). More information can be found in the paper @@ -317,7 +317,7 @@

                                      Submodules
                                      -forward(inp: torch.Tensor)[source]
                                      +forward(inp: torch.Tensor)[source]

                                      Defines the computation performed at every call.

                                      Should be overridden by all subclasses.

                                      @@ -331,14 +331,14 @@

                                      Submodules
                                      -training: bool
                                      +training: bool

                                      -sparseml.pytorch.nn.activations.create_activation(act_type: str, inplace: bool, num_channels: int, **kwargs) → torch.nn.modules.module.Module[source]
                                      +sparseml.pytorch.nn.activations.create_activation(act_type: str, inplace: bool, num_channels: int, **kwargs)torch.nn.modules.module.Module[source]

                                      Create an activation function using the given parameters.

                                      Parameters
                                      @@ -358,7 +358,7 @@

                                      Submodules
                                      -sparseml.pytorch.nn.activations.hard_swish(x_tens: torch.Tensor, inplace: bool = False)[source]
                                      +sparseml.pytorch.nn.activations.hard_swish(x_tens: torch.Tensor, inplace: bool = False)[source]
                                      Hardswish layer implementation:
                                      @@ -384,7 +384,7 @@

                                      Submodules
                                      -sparseml.pytorch.nn.activations.is_activation(module: torch.nn.modules.module.Module) → bool[source]
                                      +sparseml.pytorch.nn.activations.is_activation(module: torch.nn.modules.module.Module)bool[source]
                                      Parameters

                                      module – the module to check whether it is a common activation function or not

                                      @@ -398,7 +398,7 @@

                                      Submodules
                                      -sparseml.pytorch.nn.activations.replace_activation(module: torch.nn.modules.module.Module, name: str, act_type: str, inplace: bool = False, num_channels: Union[None, int] = None, **kwargs) → torch.nn.modules.module.Module[source]
                                      +sparseml.pytorch.nn.activations.replace_activation(module: torch.nn.modules.module.Module, name: str, act_type: str, inplace: bool = False, num_channels: Union[None, int] = None, **kwargs)torch.nn.modules.module.Module[source]

                                      General function to replace the activation for a specific layer in a Module with a new one.

                                      @@ -421,7 +421,7 @@

                                      Submodules
                                      -sparseml.pytorch.nn.activations.swish(x_tens: torch.Tensor)[source]
                                      +sparseml.pytorch.nn.activations.swish(x_tens: torch.Tensor)[source]

                                      Swish layer functional implementation: x * sigmoid(x). More information can be found in the paper here.

                                      @@ -442,7 +442,7 @@

                                      Submodules
                                      -class sparseml.pytorch.nn.fatrelu.FATReLU(threshold: Union[float, List[float]] = 0.0, inplace: bool = False)[source]
                                      +class sparseml.pytorch.nn.fatrelu.FATReLU(threshold: Union[float, List[float]] = 0.0, inplace: bool = False)[source]

                                      Bases: torch.nn.modules.module.Module

                                      Applies a FAT ReLU (forced activation threshold) over the input. Instead of setting all negative values to 0 like with ReLU, @@ -462,7 +462,7 @@

                                      Submodules
                                      -property channel_wise
                                      +property channel_wise

                                      True if the FATReLU is applied per channel, False otherwise

                                      Type
                                      @@ -473,7 +473,7 @@

                                      Submodules
                                      -property dynamic
                                      +property dynamic

                                      True if the layer is in dynamic mode (gathering the number of channels), False otherwise

                                      @@ -485,7 +485,7 @@

                                      Submodules
                                      -extra_repr()[source]
                                      +extra_repr()[source]

                                      Set the extra representation of the module

                                      To print customized extra information, you should re-implement this method in your own modules. Both single-line and multi-line @@ -494,7 +494,7 @@

                                      Submodules
                                      -forward(inp: torch.Tensor)[source]
                                      +forward(inp: torch.Tensor)[source]

                                      Defines the computation performed at every call.

                                      Should be overridden by all subclasses.

                                      @@ -508,7 +508,7 @@

                                      Submodules
                                      -get_threshold() → Union[float, List[float]][source]
                                      +get_threshold()Union[float, List[float]][source]
                                      Returns

                                      the current threshold being applied for the activation

                                      @@ -518,7 +518,7 @@

                                      Submodules
                                      -load_state_dict(state_dict, strict=True)[source]
                                      +load_state_dict(state_dict, strict=True)[source]

                                      Copies parameters and buffers from state_dict into this module and its descendants. If strict is True, then the keys of state_dict must exactly match the keys returned @@ -548,7 +548,7 @@

                                      Submodules
                                      -property num_channels
                                      +property num_channels

                                      The number of channels the FATReLU is acting on

                                      Type
                                      @@ -559,7 +559,7 @@

                                      Submodules
                                      -set_threshold(threshold: Union[float, List[float]])[source]
                                      +set_threshold(threshold: Union[float, List[float]])[source]
                                      Parameters

                                      threshold – the threshold value to set for the activation

                                      @@ -569,14 +569,14 @@

                                      Submodules
                                      -training: bool
                                      +training: bool

                                      -sparseml.pytorch.nn.fatrelu.convert_relus_to_fat(module: torch.nn.modules.module.Module, **kwargs) → Dict[str, sparseml.pytorch.nn.fatrelu.FATReLU][source]
                                      +sparseml.pytorch.nn.fatrelu.convert_relus_to_fat(module: torch.nn.modules.module.Module, **kwargs)Dict[str, sparseml.pytorch.nn.fatrelu.FATReLU][source]

                                      Replace all of the ReLUs in a module with FATReLU instances.

                                      Note: only works if the ReLUs are layers in the module, will not work with torch.functional ones.

                                      @@ -596,7 +596,7 @@

                                      Submodules
                                      -sparseml.pytorch.nn.fatrelu.fat_exp_relu(tens: torch.Tensor, threshold: torch.Tensor, compression: torch.Tensor) → torch.Tensor[source]
                                      +sparseml.pytorch.nn.fatrelu.fat_exp_relu(tens: torch.Tensor, threshold: torch.Tensor, compression: torch.Tensor)torch.Tensor[source]

                                      Create a piecewise separable exp approximated FATReLU function to a tensor (forced activation threshold): f(x, t, c) = 0 if x <= 0; = x if x >= t; @@ -620,7 +620,7 @@

                                      Submodules
                                      -sparseml.pytorch.nn.fatrelu.fat_pw_relu(tens: torch.Tensor, threshold: torch.Tensor, compression: torch.Tensor, inplace: bool) → torch.Tensor[source]
                                      +sparseml.pytorch.nn.fatrelu.fat_pw_relu(tens: torch.Tensor, threshold: torch.Tensor, compression: torch.Tensor, inplace: bool)torch.Tensor[source]

                                      Apply a piecewise separable FATReLU function to a tensor (forced activation threshold): f(x, t, c) = 0 if x <= (t - t/c); x if x >= t; @@ -646,7 +646,7 @@

                                      Submodules
                                      -sparseml.pytorch.nn.fatrelu.fat_relu(tens: torch.Tensor, threshold: Union[torch.Tensor, float], inplace: bool) → torch.Tensor[source]
                                      +sparseml.pytorch.nn.fatrelu.fat_relu(tens: torch.Tensor, threshold: Union[torch.Tensor, float], inplace: bool)torch.Tensor[source]

                                      Apply a FATReLU function to a tensor (forced activation threshold): f(x, t) = 0 if x < t; x if x >= t

                                      @@ -667,7 +667,7 @@

                                      Submodules
                                      -sparseml.pytorch.nn.fatrelu.fat_sig_relu(tens: torch.Tensor, threshold: torch.Tensor, compression: torch.Tensor) → torch.Tensor[source]
                                      +sparseml.pytorch.nn.fatrelu.fat_sig_relu(tens: torch.Tensor, threshold: torch.Tensor, compression: torch.Tensor)torch.Tensor[source]

                                      Create a sigmoid approximated FATReLU function to a tensor (forced activation threshold): f(x, t, c) = x / e^(c*(t-x))

                                      @@ -689,7 +689,7 @@

                                      Submodules
                                      -sparseml.pytorch.nn.fatrelu.set_relu_to_fat(module: torch.nn.modules.module.Module, layer_name: str, **kwargs)sparseml.pytorch.nn.fatrelu.FATReLU[source]
                                      +sparseml.pytorch.nn.fatrelu.set_relu_to_fat(module: torch.nn.modules.module.Module, layer_name: str, **kwargs)sparseml.pytorch.nn.fatrelu.FATReLU[source]

                                      Replace a given layer in a module to a FATReLU instance.

                                      Parameters
                                      @@ -713,7 +713,7 @@

                                      Submoduleshere.

                                      -class sparseml.pytorch.nn.se.SqueezeExcite(expanded_channels: int, squeezed_channels: int, act_type: str = 'relu')[source]
                                      +class sparseml.pytorch.nn.se.SqueezeExcite(expanded_channels: int, squeezed_channels: int, act_type: str = 'relu')[source]

                                      Bases: torch.nn.modules.module.Module

                                      Standard implementation for SqueezeExcite in PyTorch

                                      @@ -728,7 +728,7 @@

                                      Submodules
                                      -forward(inp: torch.Tensor)[source]
                                      +forward(inp: torch.Tensor)[source]

                                      Defines the computation performed at every call.

                                      Should be overridden by all subclasses.

                                      @@ -742,7 +742,7 @@

                                      Submodules
                                      -training: bool
                                      +training: bool

                                      diff --git a/sparseml/api/sparseml.pytorch.optim.html b/sparseml/api/sparseml.pytorch.optim.html index 68c3074f47e..9f2c4450220 100644 --- a/sparseml/api/sparseml.pytorch.optim.html +++ b/sparseml/api/sparseml.pytorch.optim.html @@ -226,34 +226,34 @@

                                      Submoduleshere.

                                      -class sparseml.pytorch.optim.analyzer_as.ASResultType(value)[source]
                                      +class sparseml.pytorch.optim.analyzer_as.ASResultType(value)[source]

                                      Bases: enum.Enum

                                      Result type to track for activation sparsity.

                                      -inputs_sample = 'inputs_sample'
                                      +inputs_sample = 'inputs_sample'
                                      -inputs_sparsity = 'inputs_sparsity'
                                      +inputs_sparsity = 'inputs_sparsity'
                                      -outputs_sample = 'outputs_sample'
                                      +outputs_sample = 'outputs_sample'
                                      -outputs_sparsity = 'outputs_sparsity'
                                      +outputs_sparsity = 'outputs_sparsity'
                                      -class sparseml.pytorch.optim.analyzer_as.ModuleASAnalyzer(module: torch.nn.modules.module.Module, dim: Union[None, int, Tuple[int, ]] = None, track_inputs_sparsity: bool = False, track_outputs_sparsity: bool = False, inputs_sample_size: int = 0, outputs_sample_size: int = 0, enabled: bool = True)[source]
                                      +class sparseml.pytorch.optim.analyzer_as.ModuleASAnalyzer(module: torch.nn.modules.module.Module, dim: Union[None, int, Tuple[int, ]] = None, track_inputs_sparsity: bool = False, track_outputs_sparsity: bool = False, inputs_sample_size: int = 0, outputs_sample_size: int = 0, enabled: bool = True)[source]

                                      Bases: object

                                      An analyzer implementation used to monitor the activation sparsity with a module. Generally used to monitor an individual layer.

                                      @@ -278,7 +278,7 @@

                                      Submodules
                                      -static analyze_layers(module: torch.nn.modules.module.Module, layers: List[str], dim: Union[None, int, Tuple[int, ]] = None, track_inputs_sparsity: bool = False, track_outputs_sparsity: bool = False, inputs_sample_size: int = 0, outputs_sample_size: int = 0, enabled: bool = True)[source]
                                      +static analyze_layers(module: torch.nn.modules.module.Module, layers: List[str], dim: Union[None, int, Tuple[int, ]] = None, track_inputs_sparsity: bool = False, track_outputs_sparsity: bool = False, inputs_sample_size: int = 0, outputs_sample_size: int = 0, enabled: bool = True)[source]
                                      Parameters
                                      -property dim
                                      +property dim
                                      -disable()[source]
                                      +disable()[source]
                                      -enable()[source]
                                      +enable()[source]
                                      -property enabled
                                      +property enabled
                                      -property inputs_sample
                                      +property inputs_sample
                                      -property inputs_sample_max
                                      +property inputs_sample_max
                                      -property inputs_sample_mean
                                      +property inputs_sample_mean
                                      -property inputs_sample_min
                                      +property inputs_sample_min
                                      -property inputs_sample_size
                                      +property inputs_sample_size
                                      -property inputs_sample_std
                                      +property inputs_sample_std
                                      -property inputs_sparsity
                                      +property inputs_sparsity
                                      -property inputs_sparsity_max
                                      +property inputs_sparsity_max
                                      -property inputs_sparsity_mean
                                      +property inputs_sparsity_mean
                                      -property inputs_sparsity_min
                                      +property inputs_sparsity_min
                                      -property inputs_sparsity_std
                                      +property inputs_sparsity_std
                                      -property module
                                      +property module
                                      -property outputs_sample
                                      +property outputs_sample
                                      -property outputs_sample_max
                                      +property outputs_sample_max
                                      -property outputs_sample_mean
                                      +property outputs_sample_mean
                                      -property outputs_sample_min
                                      +property outputs_sample_min
                                      -property outputs_sample_size
                                      +property outputs_sample_size
                                      -property outputs_sample_std
                                      +property outputs_sample_std
                                      -property outputs_sparsity
                                      +property outputs_sparsity
                                      -property outputs_sparsity_max
                                      +property outputs_sparsity_max
                                      -property outputs_sparsity_mean
                                      +property outputs_sparsity_mean
                                      -property outputs_sparsity_min
                                      +property outputs_sparsity_min
                                      -property outputs_sparsity_std
                                      +property outputs_sparsity_std
                                      -results(result_type: sparseml.pytorch.optim.analyzer_as.ASResultType) → List[torch.Tensor][source]
                                      +results(result_type: sparseml.pytorch.optim.analyzer_as.ASResultType)List[torch.Tensor][source]
                                      -results_max(result_type: sparseml.pytorch.optim.analyzer_as.ASResultType) → torch.Tensor[source]
                                      +results_max(result_type: sparseml.pytorch.optim.analyzer_as.ASResultType)torch.Tensor[source]
                                      -results_mean(result_type: sparseml.pytorch.optim.analyzer_as.ASResultType) → torch.Tensor[source]
                                      +results_mean(result_type: sparseml.pytorch.optim.analyzer_as.ASResultType)torch.Tensor[source]
                                      -results_min(result_type: sparseml.pytorch.optim.analyzer_as.ASResultType) → torch.Tensor[source]
                                      +results_min(result_type: sparseml.pytorch.optim.analyzer_as.ASResultType)torch.Tensor[source]
                                      -results_std(result_type: sparseml.pytorch.optim.analyzer_as.ASResultType) → torch.Tensor[source]
                                      +results_std(result_type: sparseml.pytorch.optim.analyzer_as.ASResultType)torch.Tensor[source]
                                      -property track_inputs_sparsity
                                      +property track_inputs_sparsity
                                      -property track_outputs_sparsity
                                      +property track_outputs_sparsity

                                      @@ -488,7 +488,7 @@

                                      Submodules
                                      -class sparseml.pytorch.optim.analyzer_module.ModuleAnalyzer(module: torch.nn.modules.module.Module, enabled: bool = False)[source]
                                      +class sparseml.pytorch.optim.analyzer_module.ModuleAnalyzer(module: torch.nn.modules.module.Module, enabled: bool = False)[source]

                                      Bases: object

                                      An analyzer implementation for monitoring the execution profile and graph of a Module in PyTorch.

                                      @@ -503,7 +503,7 @@

                                      Submodules
                                      -property enabled
                                      +property enabled

                                      True if enabled and the hooks for analyzing are active, False otherwise

                                      Type
                                      @@ -514,7 +514,7 @@

                                      Submodules
                                      -ks_layer_descs() → List[sparseml.optim.analyzer.AnalyzedLayerDesc][source]
                                      +ks_layer_descs()List[sparseml.optim.analyzer.AnalyzedLayerDesc][source]

                                      Get the descriptions for all layers in the module that support kernel sparsity (model pruning). Ex: all convolutions and linear layers.

                                      @@ -526,7 +526,7 @@

                                      Submodules
                                      -layer_desc(name: Optional[str] = None)sparseml.optim.analyzer.AnalyzedLayerDesc[source]
                                      +layer_desc(name: Optional[str] = None)sparseml.optim.analyzer.AnalyzedLayerDesc[source]

                                      Get a specific layer’s description within the Module. Set to None to get the overall Module’s description.

                                      @@ -542,7 +542,7 @@

                                      Submodules
                                      -property module
                                      +property module

                                      The module that is being actively analyzed

                                      Type
                                      @@ -561,7 +561,7 @@

                                      Submodules
                                      -class sparseml.pytorch.optim.analyzer_pruning.ModulePruningAnalyzer(module: torch.nn.modules.module.Module, name: str, param_name: str = 'weight')[source]
                                      +class sparseml.pytorch.optim.analyzer_pruning.ModulePruningAnalyzer(module: torch.nn.modules.module.Module, name: str, param_name: str = 'weight')[source]

                                      Bases: object

                                      An analyzer implementation monitoring the kernel sparsity of a given param in a module.

                                      @@ -577,7 +577,7 @@

                                      Submodules
                                      -static analyze_layers(module: torch.nn.modules.module.Module, layers: List[str], param_name: str = 'weight')[source]
                                      +static analyze_layers(module: torch.nn.modules.module.Module, layers: List[str], param_name: str = 'weight')[source]
                                      Parameters
                                        @@ -595,7 +595,7 @@

                                        Submodules
                                        -property module
                                        +property module

                                        the module containing the param to analyze the sparsity for

                                        Type
                                        @@ -606,7 +606,7 @@

                                        Submodules
                                        -property name
                                        +property name

                                        name of the layer, used for tracking

                                        Type
                                        @@ -617,7 +617,7 @@

                                        Submodules
                                        -property param
                                        +property param

                                        the parameter that is being monitored for kernel sparsity

                                        Type
                                        @@ -628,7 +628,7 @@

                                        Submodules
                                        -property param_name
                                        +property param_name

                                        name of the parameter to analyze the sparsity for, defaults to weight

                                        Type
                                        @@ -639,7 +639,7 @@

                                        Submodules
                                        -property param_sparsity
                                        +property param_sparsity

                                        the sparsity of the contained parameter (how many zeros are in it)

                                        Type
                                        @@ -650,7 +650,7 @@

                                        Submodules
                                        -param_sparsity_dim(dim: Union[None, int, Tuple[int, ]] = None) → torch.Tensor[source]
                                        +param_sparsity_dim(dim: Union[None, int, Tuple[int, ]] = None)torch.Tensor[source]
                                        Parameters

                                        dim – a dimension(s) to calculate the sparsity over, ex over channels

                                        @@ -664,7 +664,7 @@

                                        Submodules
                                        -property tag
                                        +property tag

                                        combines the layer name and param name in to a single string separated by a period

                                        @@ -684,7 +684,7 @@

                                        Submodules
                                        -class sparseml.pytorch.optim.manager.ScheduledModifierManager(modifiers: List[sparseml.pytorch.optim.modifier.ScheduledModifier])[source]
                                        +class sparseml.pytorch.optim.manager.ScheduledModifierManager(modifiers: List[sparseml.pytorch.optim.modifier.ScheduledModifier])[source]

                                        Bases: sparseml.optim.manager.BaseManager, sparseml.pytorch.optim.modifier.Modifier

                                        The base modifier manager, handles managing multiple ScheduledModifers.

                                        @@ -719,7 +719,7 @@

                                        Submodules
                                        -static from_yaml(file_path: Union[str, sparsezoo.objects.optimization_recipe.OptimizationRecipe], add_modifiers: Optional[List[sparseml.pytorch.optim.modifier.Modifier]] = None)[source]
                                        +static from_yaml(file_path: Union[str, sparsezoo.objects.optimization_recipe.OptimizationRecipe], add_modifiers: Optional[List[sparseml.pytorch.optim.modifier.Modifier]] = None)[source]

                                        Convenience function used to create the manager of multiple modifiers from a recipe file.

                                        @@ -743,7 +743,7 @@

                                        Submodules
                                        -initialize(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer)[source]
                                        +initialize(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer)[source]

                                        Handles initializing and setting up the contained modifiers Called once on construction of the scheduled optimizer

                                        @@ -758,7 +758,7 @@

                                        Submodules
                                        -initialize_loggers(loggers: Union[None, List[sparseml.pytorch.utils.logger.PyTorchLogger]])[source]
                                        +initialize_loggers(loggers: Union[None, List[sparseml.pytorch.utils.logger.PyTorchLogger]])[source]

                                        Handles initializing and setting up the loggers for the contained modifiers Called once on construction of the scheduled optimizer

                                        @@ -771,7 +771,7 @@

                                        Submodules
                                        -load_state_dict(state_dict: Dict[str, Dict])[source]
                                        +load_state_dict(state_dict: Dict[str, Dict])[source]

                                        Loads the given state dict into this object’s modifiers

                                        Parameters
                                        @@ -787,7 +787,7 @@

                                        Submodules
                                        -loss_update(loss: torch.Tensor, module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int) → torch.Tensor[source]
                                        +loss_update(loss: torch.Tensor, module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)torch.Tensor[source]

                                        Optional call that can be made on the optimizer to update the contained modifiers once loss has been calculated

                                        @@ -809,7 +809,7 @@

                                        Submodules
                                        -optimizer_post_step(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]
                                        +optimizer_post_step(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]

                                        Called after the optimizer step happens and weights have updated Calls into the contained modifiers

                                        @@ -827,7 +827,7 @@

                                        Submodules
                                        -optimizer_pre_step(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]
                                        +optimizer_pre_step(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]

                                        Called before the optimizer step happens (after backward has been called, before optimizer.step) Calls into the contained modifiers

                                        @@ -846,7 +846,7 @@

                                        Submodules
                                        -state_dict() → Dict[str, Dict][source]
                                        +state_dict()Dict[str, Dict][source]
                                        Returns

                                        Dictionary to store any state variables from this Manager’s Modifiers. @@ -859,7 +859,7 @@

                                        Submodules
                                        -update(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int, log_updates: bool = True)[source]
                                        +update(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int, log_updates: bool = True)[source]

                                        Handles updating the contained modifiers’ states, module, or optimizer Only calls scheduled_update on the each modifier if modifier.update_ready()

                                        @@ -881,7 +881,7 @@

                                        Submodules
                                        -sparseml.pytorch.optim.manager.load_manager(path: str, manager: sparseml.pytorch.optim.manager.ScheduledModifierManager, map_location: Union[None, str] = 'cpu')[source]
                                        +sparseml.pytorch.optim.manager.load_manager(path: str, manager: sparseml.pytorch.optim.manager.ScheduledModifierManager, map_location: Union[None, str] = 'cpu')[source]

                                        Load the state dict into a ScheduledModifierManager from a given file.

                                        Parameters
                                        @@ -900,7 +900,7 @@

                                        Submodules
                                        -class sparseml.pytorch.optim.mask_creator_pruning.BlockPruningMaskCreator(block_shape: List[int], grouping_fn_name: str = 'mean')[source]
                                        +class sparseml.pytorch.optim.mask_creator_pruning.BlockPruningMaskCreator(block_shape: List[int], grouping_fn_name: str = 'mean')[source]

                                        Bases: sparseml.pytorch.optim.mask_creator_pruning.GroupedPruningMaskCreator

                                        Structured sparsity mask creator that groups the input tensor into blocks of shape block_shape.

                                        @@ -917,7 +917,7 @@

                                        Submodules
                                        -group_tensor(tensor: torch.Tensor) → torch.Tensor[source]
                                        +group_tensor(tensor: torch.Tensor)torch.Tensor[source]
                                        Parameters

                                        tensor – The tensor to transform

                                        @@ -933,7 +933,7 @@

                                        Submodules
                                        -class sparseml.pytorch.optim.mask_creator_pruning.DimensionSparsityMaskCreator(dim: Union[str, int, List[int]], grouping_fn_name: str = 'mean')[source]
                                        +class sparseml.pytorch.optim.mask_creator_pruning.DimensionSparsityMaskCreator(dim: Union[str, int, List[int]], grouping_fn_name: str = 'mean')[source]

                                        Bases: sparseml.pytorch.optim.mask_creator_pruning.GroupedPruningMaskCreator

                                        Structured sparsity mask creator that groups sparsity blocks by the given dimension(s)

                                        @@ -949,7 +949,7 @@

                                        Submodules
                                        -group_tensor(tensor: torch.Tensor) → torch.Tensor[source]
                                        +group_tensor(tensor: torch.Tensor)torch.Tensor[source]
                                        Parameters

                                        tensor – The tensor to transform

                                        @@ -965,14 +965,14 @@

                                        Submodules
                                        -class sparseml.pytorch.optim.mask_creator_pruning.GroupedPruningMaskCreator[source]
                                        +class sparseml.pytorch.optim.mask_creator_pruning.GroupedPruningMaskCreator[source]

                                        Bases: sparseml.pytorch.optim.mask_creator_pruning.UnstructuredPruningMaskCreator

                                        Abstract class for a sparsity mask creator that structures masks according to grouping functions. Subclasses should implement group_tensor and _map_mask_to_tensor

                                        -create_sparsity_mask(tensor: torch.Tensor, sparsity: float) → torch.Tensor[source]
                                        +create_sparsity_mask(tensor: torch.Tensor, sparsity: float)torch.Tensor[source]
                                        Parameters
                                          @@ -992,7 +992,7 @@

                                          Submodules
                                          -create_sparsity_mask_from_abs_threshold(tensor: torch.Tensor, threshold: Union[float, torch.Tensor]) → torch.Tensor[source]
                                          +create_sparsity_mask_from_abs_threshold(tensor: torch.Tensor, threshold: Union[float, torch.Tensor])torch.Tensor[source]
                                          Parameters
                                            @@ -1010,7 +1010,7 @@

                                            Submodules
                                            -create_sparsity_mask_from_tensor(tensor: torch.Tensor) → torch.Tensor[source]
                                            +create_sparsity_mask_from_tensor(tensor: torch.Tensor)torch.Tensor[source]
                                            Parameters

                                            tensor – the tensor to calculate a mask based on its values

                                            @@ -1022,28 +1022,34 @@

                                            Submodules -
                                            -static get_grouping_fn(grouping_fn_name: str) → Callable[[torch.Tensor, List[int]], torch.Tensor][source]
                                            +
                                            +abstract group_tensor(tensor: torch.Tensor)torch.Tensor[source]
                                            Parameters
                                            -

                                            grouping_fn_name – name of grouping function to get torch function for

                                            +

                                            tensor – The tensor to reduce in groups

                                            Returns
                                            -

                                            torch function for grouping_fn_name if available, -raises error otherwise

                                            +

                                            The grouped tensor

                                            -
                                            -abstract group_tensor(tensor: torch.Tensor) → torch.Tensor[source]
                                            +
                                            +static reduce_tensor(tensor: torch.Tensor, dim: Union[int, List[int]], reduce_fn_name: str, keepdim: bool = True)torch.Tensor[source]
                                            Parameters
                                            -

                                            tensor – The tensor to reduce in groups

                                            +
                                              +
                                            • tensor – the tensor to reduce

                                            • +
                                            • dim – dimension or list of dimension to reduce along

                                            • +
                                            • reduce_fn_name – function name to reduce tensor with. valid options +are ‘mean’, ‘max’, ‘min’

                                            • +
                                            • keepdim – preserves the reduced dimension(s) in returned tensor shape +as shape 1. default is True

                                            • +
                                            Returns
                                            -

                                            The grouped tensor

                                            +

                                            Tensor reduced along the given dimension(s)

                                            @@ -1052,13 +1058,13 @@

                                            Submodules
                                            -class sparseml.pytorch.optim.mask_creator_pruning.PruningMaskCreator[source]
                                            +class sparseml.pytorch.optim.mask_creator_pruning.PruningMaskCreator[source]

                                            Bases: abc.ABC

                                            Base abstract class for a sparsity mask creator. Subclasses should define all methods for creating masks

                                            -abstract create_sparsity_mask(tensor: torch.Tensor, sparsity: float) → torch.Tensor[source]
                                            +abstract create_sparsity_mask(tensor: torch.Tensor, sparsity: float)torch.Tensor[source]
                                            Parameters
                                              @@ -1077,7 +1083,7 @@

                                              Submodules
                                              -abstract create_sparsity_mask_from_abs_threshold(tensor: torch.Tensor, threshold: Union[float, torch.Tensor]) → torch.Tensor[source]
                                              +abstract create_sparsity_mask_from_abs_threshold(tensor: torch.Tensor, threshold: Union[float, torch.Tensor])torch.Tensor[source]
                                              Parameters
                                                @@ -1094,7 +1100,7 @@

                                                Submodules
                                                -create_sparsity_mask_from_tensor(tensor: torch.Tensor) → torch.Tensor[source]
                                                +create_sparsity_mask_from_tensor(tensor: torch.Tensor)torch.Tensor[source]
                                                Parameters

                                                tensor – the tensor to calculate a mask based on its values

                                                @@ -1109,14 +1115,14 @@

                                                Submodules
                                                -class sparseml.pytorch.optim.mask_creator_pruning.UnstructuredPruningMaskCreator[source]
                                                +class sparseml.pytorch.optim.mask_creator_pruning.UnstructuredPruningMaskCreator[source]

                                                Bases: sparseml.pytorch.optim.mask_creator_pruning.PruningMaskCreator

                                                Class for creating unstructured sparsity masks. Masks will be created using unstructured sparsity by pruning weights ranked by their magnitude.

                                                -create_sparsity_mask(tensor: torch.Tensor, sparsity: float) → torch.Tensor[source]
                                                +create_sparsity_mask(tensor: torch.Tensor, sparsity: float)torch.Tensor[source]
                                                Parameters
                                                  @@ -1136,7 +1142,7 @@

                                                  Submodules
                                                  -create_sparsity_mask_from_abs_threshold(tensor: torch.Tensor, threshold: Union[float, torch.Tensor]) → torch.Tensor[source]
                                                  +create_sparsity_mask_from_abs_threshold(tensor: torch.Tensor, threshold: Union[float, torch.Tensor])torch.Tensor[source]
                                                  Parameters
                                                    @@ -1157,7 +1163,7 @@

                                                    Submodules
                                                    -sparseml.pytorch.optim.mask_creator_pruning.load_mask_creator(obj: Union[str, Iterable[int]])sparseml.pytorch.optim.mask_creator_pruning.PruningMaskCreator[source]
                                                    +sparseml.pytorch.optim.mask_creator_pruning.load_mask_creator(obj: Union[str, Iterable[int]])sparseml.pytorch.optim.mask_creator_pruning.PruningMaskCreator[source]
                                                    Parameters

                                                    obj – Formatted string or block shape iterable specifying SparsityMaskCreator @@ -1176,18 +1182,18 @@

                                                    Submodules
                                                    -class sparseml.pytorch.optim.mask_pruning.ModuleParamPruningMask(layer: torch.nn.modules.module.Module, param_name: str = 'weight', store_init: bool = False, store_unmasked: bool = False, track_grad_mom: float = - 1.0, mask_creator: sparseml.pytorch.optim.mask_creator_pruning.PruningMaskCreator = unstructured, layer_name: Optional[str] = None)[source]
                                                    +class sparseml.pytorch.optim.mask_pruning.ModuleParamPruningMask(layer: torch.nn.modules.module.Module, param_name: str = 'weight', store_init: bool = False, store_unmasked: bool = False, track_grad_mom: float = - 1.0, mask_creator: sparseml.pytorch.optim.mask_creator_pruning.PruningMaskCreator = unstructured, layer_name: Optional[str] = None)[source]

                                                    Bases: object

                                                    Mask to apply kernel sparsity (model pruning) to a specific parameter in a layer

                                                    -apply()[source]
                                                    +apply()[source]

                                                    apply the current mask to the params tensor (zero out the desired values)

                                                    -property enabled
                                                    +property enabled

                                                    True if the parameter is currently being masked, False otherwise

                                                    Type
                                                    @@ -1198,7 +1204,7 @@

                                                    Submodules
                                                    -property layer
                                                    +property layer

                                                    the layer containing the parameter to mask

                                                    Type
                                                    @@ -1209,7 +1215,7 @@

                                                    Submodules
                                                    -property layer_name
                                                    +property layer_name

                                                    the name of the layer the parameter to mask is located in

                                                    Type
                                                    @@ -1220,7 +1226,7 @@

                                                    Submodules
                                                    -property mask_creator
                                                    +property mask_creator

                                                    SparsityMaskCreator object used to generate masks

                                                    Type
                                                    @@ -1231,7 +1237,7 @@

                                                    Submodules
                                                    -property name
                                                    +property name

                                                    the full name of this sparsity mask in the following format: <LAYER>.<PARAM>.sparsity_mask

                                                    @@ -1243,7 +1249,7 @@

                                                    Submodules
                                                    -property param_data
                                                    +property param_data

                                                    the current tensor in the parameter

                                                    Type
                                                    @@ -1254,7 +1260,7 @@

                                                    Submodules
                                                    -property param_grad
                                                    +property param_grad

                                                    the current gradient values for the parameter

                                                    Type
                                                    @@ -1265,7 +1271,7 @@

                                                    Submodules
                                                    -property param_init
                                                    +property param_init

                                                    the initial value of the parameter before being masked

                                                    Type
                                                    @@ -1276,7 +1282,7 @@

                                                    Submodules
                                                    -property param_mask
                                                    +property param_mask

                                                    the current mask applied to the parameter

                                                    Type
                                                    @@ -1287,7 +1293,7 @@

                                                    Submodules
                                                    -property param_name
                                                    +property param_name

                                                    the name of the parameter to mask in the layer, default is weight

                                                    Type
                                                    @@ -1298,7 +1304,7 @@

                                                    Submodules
                                                    -property param_unmasked
                                                    +property param_unmasked

                                                    the unmasked value of the parameter (stores the last unmasked value before masking)

                                                    @@ -1310,14 +1316,14 @@

                                                    Submodules
                                                    -reset()[source]
                                                    +reset()[source]

                                                    resets the current stored tensors such that they will be on the same device and have the proper data

                                                    -set_param_data(value: torch.Tensor)[source]
                                                    +set_param_data(value: torch.Tensor)[source]
                                                    Parameters

                                                    value – the value to set as the current tensor for the parameter, @@ -1328,7 +1334,7 @@

                                                    Submodules
                                                    -set_param_mask(value: torch.Tensor)[source]
                                                    +set_param_mask(value: torch.Tensor)[source]
                                                    Parameters

                                                    value – the mask to set and apply as the current tensor, @@ -1339,7 +1345,7 @@

                                                    Submodules
                                                    -set_param_mask_from_abs_threshold(threshold: Union[float, torch.Tensor]) → torch.Tensor[source]
                                                    +set_param_mask_from_abs_threshold(threshold: Union[float, torch.Tensor])torch.Tensor[source]

                                                    Convenience function to set the parameter mask such that if abs(value) <= threshold the it is masked to 0

                                                    @@ -1351,7 +1357,7 @@

                                                    Submodules
                                                    -set_param_mask_from_sparsity(sparsity: float) → torch.Tensor[source]
                                                    +set_param_mask_from_sparsity(sparsity: float)torch.Tensor[source]

                                                    Convenience function to set the parameter mask such that it has a specific amount of masked values such that the percentage equals the sparsity amount given. Masks the absolute smallest values up until sparsity is reached.

                                                    @@ -1364,7 +1370,7 @@

                                                    Submodules
                                                    -set_param_mask_from_weights() → torch.Tensor[source]
                                                    +set_param_mask_from_weights()torch.Tensor[source]

                                                    Convenience function to set the parameter mask such that the mask is 1 if the parameter value is non zero and 0 otherwise, unless otherwise defined by this object’s mask_creator.

                                                    @@ -1372,7 +1378,7 @@

                                                    Submodules
                                                    -property store_init
                                                    +property store_init

                                                    store the init weights in a separate variable that can be used and referenced later

                                                    @@ -1384,7 +1390,7 @@

                                                    Submodules
                                                    -property store_unmasked
                                                    +property store_unmasked

                                                    store the unmasked weights in a separate variable that can be used and referenced later

                                                    @@ -1396,7 +1402,7 @@

                                                    Submodules
                                                    -property track_grad_mom
                                                    +property track_grad_mom

                                                    store the gradient updates to the parameter with a momentum variable must be in the range [0.0, 1.0), if set to 0.0 then will only keep most recent

                                                    @@ -1418,7 +1424,7 @@

                                                    Submodules
                                                    -class sparseml.pytorch.optim.modifier.Modifier(log_types: Optional[Union[str, List[str]]] = None, **kwargs)[source]
                                                    +class sparseml.pytorch.optim.modifier.Modifier(log_types: Optional[Union[str, List[str]]] = None, **kwargs)[source]

                                                    Bases: sparseml.optim.modifier.BaseModifier

                                                    The base pytorch modifier implementation, all modifiers must inherit from this class. @@ -1449,7 +1455,7 @@

                                                    Submodules
                                                    -initialize(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer)[source]
                                                    +initialize(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer)[source]

                                                    Handles initializing and setting up the modifier. Called once on construction of the scheduled optimizer.

                                                    @@ -1464,7 +1470,7 @@

                                                    Submodules
                                                    -initialize_loggers(loggers: Union[None, List[sparseml.pytorch.utils.logger.PyTorchLogger]])[source]
                                                    +initialize_loggers(loggers: Union[None, List[sparseml.pytorch.utils.logger.PyTorchLogger]])[source]
                                                    Parameters

                                                    loggers – the loggers to setup this modifier with for logging important @@ -1475,7 +1481,7 @@

                                                    Submodules
                                                    -static load_list(yaml_str: str)[source]
                                                    +static load_list(yaml_str: str)[source]
                                                    Parameters

                                                    yaml_str – a string representation of the yaml syntax to @@ -1489,7 +1495,7 @@

                                                    Submodules
                                                    -static load_obj(yaml_str: str)[source]
                                                    +static load_obj(yaml_str: str)[source]
                                                    Parameters

                                                    yaml_str – a string representation of the yaml syntax to @@ -1503,7 +1509,7 @@

                                                    Submodules
                                                    -log_update(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]
                                                    +log_update(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]

                                                    Handles logging updates for the modifier for better tracking and visualization. Should be overwritten for logging.

                                                    @@ -1521,17 +1527,17 @@

                                                    Submodules
                                                    -loggers
                                                    +loggers

                                                    -loggers_initialized
                                                    +loggers_initialized
                                                    -loss_update(loss: torch.Tensor, module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]
                                                    +loss_update(loss: torch.Tensor, module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]

                                                    Optional call that can be made on the optimizer to update the modifiers once the loss has been calculated. Called independent of if the modifier is currently active or not.

                                                    @@ -1554,7 +1560,7 @@

                                                    Submodules
                                                    -optimizer_post_step(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]
                                                    +optimizer_post_step(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]

                                                    Called after the optimizer step happens and weights have updated. Called independent of if the modifier is currently active or not.

                                                    @@ -1572,7 +1578,7 @@

                                                    Submodules
                                                    -optimizer_pre_step(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]
                                                    +optimizer_pre_step(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]

                                                    Called before the optimizer step happens (after backward has been called, before optimizer.step). Called independent of if the modifier is currently active or not.

                                                    @@ -1591,7 +1597,7 @@

                                                    Submodules
                                                    -update(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]
                                                    +update(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]

                                                    Handles updating the modifier’s state, module, or optimizer. Called when update_ready() returns True.

                                                    @@ -1611,7 +1617,7 @@

                                                    Submodules
                                                    -class sparseml.pytorch.optim.modifier.ModifierProp(serializable: bool = True, restrict_initialized: bool = True, restrict_enabled: bool = False, restrict_extras: Optional[List[str]] = None, no_serialize_val: Optional[Any] = None, func_get: Optional[Callable] = None, func_set: Optional[Callable] = None, doc: Optional[Callable] = None)[source]
                                                    +class sparseml.pytorch.optim.modifier.ModifierProp(serializable: bool = True, restrict_initialized: bool = True, restrict_enabled: bool = False, restrict_extras: Optional[List[str]] = None, no_serialize_val: Optional[Any] = None, func_get: Optional[Callable] = None, func_set: Optional[Callable] = None, doc: Optional[Callable] = None)[source]

                                                    Bases: sparseml.optim.modifier.BaseProp

                                                    Property used to decorate a modifier. Use for creating getters and setters in a modifier. @@ -1638,7 +1644,7 @@

                                                    Submodules
                                                    -getter(func_get: Callable)sparseml.optim.modifier.BaseProp[source]
                                                    +getter(func_get: Callable)sparseml.optim.modifier.BaseProp[source]

                                                    Create a ModifierProp based off the current instance with the getter function

                                                    Parameters
                                                    @@ -1652,7 +1658,7 @@

                                                    Submodules
                                                    -property no_serialize_val
                                                    +property no_serialize_val

                                                    a value that if the prop is equal to, will not serialize the prop

                                                    Type
                                                    @@ -1663,7 +1669,7 @@

                                                    Submodules
                                                    -property restrictions
                                                    +property restrictions

                                                    The attributes to check for restricting when the attribute can be set

                                                    Type
                                                    @@ -1674,7 +1680,7 @@

                                                    Submodules
                                                    -property serializable
                                                    +property serializable

                                                    True if the property should be serialized (ex in yaml), False otherwise

                                                    Type
                                                    @@ -1685,7 +1691,7 @@

                                                    Submodules
                                                    -setter(func_set: Callable)sparseml.optim.modifier.BaseProp[source]
                                                    +setter(func_set: Callable)sparseml.optim.modifier.BaseProp[source]

                                                    Create a ModifierProp based off the current instance with the setter function

                                                    Parameters
                                                    @@ -1701,7 +1707,7 @@

                                                    Submodules
                                                    -class sparseml.pytorch.optim.modifier.PyTorchModifierYAML[source]
                                                    +class sparseml.pytorch.optim.modifier.PyTorchModifierYAML[source]

                                                    Bases: sparseml.optim.modifier.ModifierYAML

                                                    A decorator to handle making a pytorch modifier class YAML ready. IE it can be loaded in through the yaml plugin easily.

                                                    @@ -1709,7 +1715,7 @@

                                                    Submodules
                                                    -class sparseml.pytorch.optim.modifier.ScheduledModifier(log_types: Optional[Union[str, List[str]]] = None, start_epoch: float = - 1.0, min_start: float = - 1.0, end_epoch: float = - 1.0, min_end: float = - 1.0, end_comparator: Optional[int] = 0, **kwargs)[source]
                                                    +class sparseml.pytorch.optim.modifier.ScheduledModifier(log_types: Optional[Union[str, List[str]]] = None, start_epoch: float = - 1.0, min_start: float = - 1.0, end_epoch: float = - 1.0, min_end: float = - 1.0, end_comparator: Optional[int] = 0, **kwargs)[source]

                                                    Bases: sparseml.pytorch.optim.modifier.Modifier, sparseml.optim.modifier.BaseScheduled

                                                    The base scheduled modifier implementation, all scheduled modifiers must inherit from this class. @@ -1762,7 +1768,7 @@

                                                    Submodules
                                                    -end_pending(epoch: float, steps_per_epoch: int) → bool[source]
                                                    +end_pending(epoch: float, steps_per_epoch: int)bool[source]

                                                    Base implementation compares current epoch with the end epoch and that it has been started.

                                                    @@ -1781,12 +1787,12 @@

                                                    Submodules
                                                    -ended
                                                    +ended

                                                    -log_update(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]
                                                    +log_update(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]

                                                    Handles logging updates for the modifier for better tracking and visualization. Should be overridden for logging but not called directly, use scheduled_log_update instead.

                                                    @@ -1805,7 +1811,7 @@

                                                    Submodules
                                                    -scheduled_log_update(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]
                                                    +scheduled_log_update(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]

                                                    Handles checking if a log update should happen. IE, is the modifier currently in the range of its start and end epochs. No restrictions are placed on it by update_ready in the event that the modifier @@ -1827,7 +1833,7 @@

                                                    Submodules
                                                    -scheduled_update(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]
                                                    +scheduled_update(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]

                                                    Called by the system and calls into update() method Tracks state and should not be overridden!!

                                                    @@ -1845,7 +1851,7 @@

                                                    Submodules
                                                    -start_pending(epoch: float, steps_per_epoch: int) → bool[source]
                                                    +start_pending(epoch: float, steps_per_epoch: int)bool[source]

                                                    Base implementation compares current epoch with the start epoch.

                                                    Parameters
                                                    @@ -1863,12 +1869,12 @@

                                                    Submodules
                                                    -started
                                                    +started

                                                    -update(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]
                                                    +update(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]

                                                    Handles updating the modifier’s state, module, or optimizer. Called when update_ready() returns True.

                                                    @@ -1886,7 +1892,7 @@

                                                    Submodules
                                                    -update_ready(epoch: float, steps_per_epoch: int) → bool[source]
                                                    +update_ready(epoch: float, steps_per_epoch: int)bool[source]

                                                    Base implementation checks if start_pending() or end_pending().

                                                    Parameters
                                                    @@ -1906,7 +1912,7 @@

                                                    Submodules
                                                    -class sparseml.pytorch.optim.modifier.ScheduledUpdateModifier(log_types: Optional[Union[str, List[str]]] = None, start_epoch: float = - 1.0, min_start: float = - 1.0, end_epoch: float = - 1.0, min_end: float = - 1.0, end_comparator: Optional[int] = 0, update_frequency: float = - 1.0, min_frequency: float = - 1.0, **kwargs)[source]
                                                    +class sparseml.pytorch.optim.modifier.ScheduledUpdateModifier(log_types: Optional[Union[str, List[str]]] = None, start_epoch: float = - 1.0, min_start: float = - 1.0, end_epoch: float = - 1.0, min_end: float = - 1.0, end_comparator: Optional[int] = 0, update_frequency: float = - 1.0, min_frequency: float = - 1.0, **kwargs)[source]

                                                    Bases: sparseml.pytorch.optim.modifier.ScheduledModifier, sparseml.optim.modifier.BaseUpdate

                                                    The base scheduled update modifier implementation, all scheduled update modifiers must inherit from this class. @@ -1957,7 +1963,7 @@

                                                    Submodules
                                                    -update(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]
                                                    +update(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]

                                                    Handles updating the modifier’s state, module, or optimizer. Called when update_ready() returns True.

                                                    @@ -1975,7 +1981,7 @@

                                                    Submodules
                                                    -update_ready(epoch: float, steps_per_epoch: int) → bool[source]
                                                    +update_ready(epoch: float, steps_per_epoch: int)bool[source]

                                                    Calls base implementation to check if start_pending() or end_pending(). Additionally checks if an update is ready based on the frequency and current’ epoch vs last epoch updated.

                                                    @@ -2001,7 +2007,7 @@

                                                    Submodules
                                                    -class sparseml.pytorch.optim.modifier_as.ASRegModifier(layers: Union[str, List[str]], alpha: Union[float, List[float]], layer_normalized: bool = False, reg_func: str = 'l1', reg_tens: str = 'inp', start_epoch: float = - 1.0, end_epoch: float = - 1.0)[source]
                                                    +class sparseml.pytorch.optim.modifier_as.ASRegModifier(layers: Union[str, List[str]], alpha: Union[float, List[float]], layer_normalized: bool = False, reg_func: str = 'l1', reg_tens: str = 'inp', start_epoch: float = - 1.0, end_epoch: float = - 1.0)[source]

                                                    Bases: sparseml.pytorch.optim.modifier.ScheduledModifier

                                                    Add a regularizer over the inputs or outputs to given layers (activation regularization). @@ -2045,7 +2051,7 @@

                                                    Submodules
                                                    -alpha
                                                    +alpha

                                                    the weight to use for the regularization, ie cost = loss + alpha * reg

                                                    Type
                                                    @@ -2056,7 +2062,7 @@

                                                    Submodules
                                                    -initialize(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer)[source]
                                                    +initialize(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer)[source]

                                                    Grab the layer’s to control activation sparsity for

                                                    Parameters
                                                    @@ -2070,7 +2076,7 @@

                                                    Submodules
                                                    -layer_normalized
                                                    +layer_normalized

                                                    True to normalize the values by 1 / L where L is the number of layers

                                                    Type
                                                    @@ -2081,7 +2087,7 @@

                                                    Submodules
                                                    -layers
                                                    +layers

                                                    str or list of str for the layers to apply the AS modifier to can also use the token __ALL__ to specify all layers

                                                    @@ -2093,7 +2099,7 @@

                                                    Submodules
                                                    -loss_update(loss: torch.Tensor, module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int) → torch.Tensor[source]
                                                    +loss_update(loss: torch.Tensor, module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)torch.Tensor[source]

                                                    Modify the loss to include the norms for the outputs of the layers being modified.

                                                    @@ -2115,7 +2121,7 @@

                                                    Submodules
                                                    -optimizer_post_step(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]
                                                    +optimizer_post_step(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]

                                                    be sure to clear out the values after the update step has been taken

                                                    Parameters
                                                    @@ -2132,7 +2138,7 @@

                                                    Submodules
                                                    -reg_func
                                                    +reg_func

                                                    the regularization function to apply to the activations, one of: l1, l2, relu, hs

                                                    @@ -2144,7 +2150,7 @@

                                                    Submodules
                                                    -reg_tens
                                                    +reg_tens

                                                    the regularization tensor to apply a function to, one of: inp, out

                                                    @@ -2156,7 +2162,7 @@

                                                    Submodules
                                                    -update(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]
                                                    +update(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]

                                                    Update the loss tracking for each layer that is being modified on start and stop

                                                    Parameters
                                                    @@ -2173,7 +2179,7 @@

                                                    Submodules
                                                    -validate()[source]
                                                    +validate()[source]

                                                    Validate the values of the params for the current instance are valid

                                                    @@ -2185,7 +2191,7 @@

                                                    Submodules
                                                    -class sparseml.pytorch.optim.modifier_epoch.EpochRangeModifier(start_epoch: float, end_epoch: float)[source]
                                                    +class sparseml.pytorch.optim.modifier_epoch.EpochRangeModifier(start_epoch: float, end_epoch: float)[source]

                                                    Bases: sparseml.pytorch.optim.modifier.ScheduledModifier

                                                    Simple modifier to set the range of epochs for running in a scheduled optimizer (ie to set min and max epochs within a range without hacking other modifiers).

                                                    @@ -2218,7 +2224,7 @@

                                                    Submodules
                                                    -class sparseml.pytorch.optim.modifier_lr.LearningRateModifier(lr_class: str, lr_kwargs: Dict, init_lr: float, start_epoch: float, end_epoch: float = - 1.0, update_frequency: float = - 1.0, log_types: Union[str, List[str]] = '__ALL__', constant_logging: bool = False)[source]
                                                    +class sparseml.pytorch.optim.modifier_lr.LearningRateModifier(lr_class: str, lr_kwargs: Dict, init_lr: float, start_epoch: float, end_epoch: float = - 1.0, update_frequency: float = - 1.0, log_types: Union[str, List[str]] = '__ALL__', constant_logging: bool = False)[source]

                                                    Bases: sparseml.pytorch.optim.modifier.ScheduledUpdateModifier, sparseml.optim.learning_rate.LearningRate

                                                    Modifier to set the learning rate to specific values at certain points in the training process between set epochs. @@ -2265,7 +2271,7 @@

                                                    Submodules
                                                    -constant_logging
                                                    +constant_logging

                                                    True to constantly log on every step, False to only log on an LR change, default True

                                                    @@ -2277,7 +2283,7 @@

                                                    Submodules
                                                    -log_update(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]
                                                    +log_update(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]

                                                    Check whether to log an update for the learning rate of the modifier If constant logging is enabled, then will always log Otherwise checks for a change in the LR before logging

                                                    @@ -2296,7 +2302,7 @@

                                                    Submodules
                                                    -update(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]
                                                    +update(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]

                                                    Calls into the lr scheduler to step given the epoch Additionally will first set the lr to the init_lr if not set yet

                                                    @@ -2314,7 +2320,7 @@

                                                    Submodules
                                                    -validate()[source]
                                                    +validate()[source]

                                                    Validate the values of the params for the current instance are valid

                                                    @@ -2322,7 +2328,7 @@

                                                    Submodules
                                                    -class sparseml.pytorch.optim.modifier_lr.SetLearningRateModifier(learning_rate: Optional[float], start_epoch: float = - 1.0, end_epoch: float = - 1.0, log_types: Union[str, List[str]] = '__ALL__', constant_logging: bool = False)[source]
                                                    +class sparseml.pytorch.optim.modifier_lr.SetLearningRateModifier(learning_rate: Optional[float], start_epoch: float = - 1.0, end_epoch: float = - 1.0, log_types: Union[str, List[str]] = '__ALL__', constant_logging: bool = False)[source]

                                                    Bases: sparseml.pytorch.optim.modifier.ScheduledModifier, sparseml.optim.learning_rate.SetLearningRate

                                                    Modifier to set the learning rate to a specific value at a certain point in the training process. @@ -2356,12 +2362,12 @@

                                                    Submodules
                                                    -applied_learning_rate
                                                    +applied_learning_rate

                                                    -constant_logging
                                                    +constant_logging

                                                    True to constantly log on every step, False to only log on an LR change, default True

                                                    @@ -2373,7 +2379,7 @@

                                                    Submodules
                                                    -log_update(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]
                                                    +log_update(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]

                                                    Check whether to log an update for the learning rate of the modifier If constant logging is enabled, then will always log Otherwise checks for a change in the LR before logging

                                                    @@ -2392,7 +2398,7 @@

                                                    Submodules
                                                    -update(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]
                                                    +update(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]

                                                    Check whether to update the learning rate for the optimizer or not

                                                    Parameters
                                                    @@ -2416,7 +2422,7 @@

                                                    Submodules
                                                    -class sparseml.pytorch.optim.modifier_params.GradualParamModifier(params: Union[str, List[str]], init_val: Any, final_val: Any, start_epoch: float, end_epoch: float, update_frequency: float, inter_func: str = 'linear', params_strict: bool = True)[source]
                                                    +class sparseml.pytorch.optim.modifier_params.GradualParamModifier(params: Union[str, List[str]], init_val: Any, final_val: Any, start_epoch: float, end_epoch: float, update_frequency: float, inter_func: str = 'linear', params_strict: bool = True)[source]

                                                    Bases: sparseml.pytorch.optim.modifier.ScheduledUpdateModifier

                                                    Modifier to set the param values for a given list of parameter regex patterns from a start value through an end value and using an interpolation function @@ -2440,7 +2446,7 @@

                                                    Submodules
                                                    -final_val
                                                    +final_val

                                                    The final value to set for the given param in the given layers at end_epoch

                                                    @@ -2452,7 +2458,7 @@

                                                    Submodules
                                                    -init_val
                                                    +init_val

                                                    The initial value to set for the given param in the given layers at start_epoch

                                                    @@ -2464,7 +2470,7 @@

                                                    Submodules
                                                    -initialize(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer)[source]
                                                    +initialize(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer)[source]

                                                    Grab the layers params to control the values for within the given module

                                                    Parameters
                                                    @@ -2478,7 +2484,7 @@

                                                    Submodules
                                                    -inter_func
                                                    +inter_func

                                                    the type of interpolation function to use: [linear, cubic, inverse_cubic]; default is linear

                                                    @@ -2490,7 +2496,7 @@

                                                    Submodules
                                                    -params
                                                    +params

                                                    A list of full parameter names or regex patterns of names to apply pruning to. Regex patterns must be specified with the prefix ‘re:’. __ALL__ will match to all parameters.

                                                    @@ -2503,7 +2509,7 @@

                                                    Submodules
                                                    -params_strict
                                                    +params_strict

                                                    True if every regex pattern in params must match at least one parameter name in the module False if missing params are ok – will not raise an err

                                                    @@ -2516,7 +2522,7 @@

                                                    Submodules
                                                    -update(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]
                                                    +update(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]

                                                    Updates the modules layers params to the interpolated value based on given settings and current epoch.

                                                    @@ -2534,7 +2540,7 @@

                                                    Submodules
                                                    -validate()[source]
                                                    +validate()[source]

                                                    Validate the values of the params for the current instance are valid

                                                    @@ -2542,7 +2548,7 @@

                                                    Submodules
                                                    -class sparseml.pytorch.optim.modifier_params.SetParamModifier(params: Union[str, List[str]], val: Any, params_strict: bool = True, start_epoch: float = 0.0, end_epoch: float = - 1.0)[source]
                                                    +class sparseml.pytorch.optim.modifier_params.SetParamModifier(params: Union[str, List[str]], val: Any, params_strict: bool = True, start_epoch: float = 0.0, end_epoch: float = - 1.0)[source]

                                                    Bases: sparseml.pytorch.optim.modifier.ScheduledModifier

                                                    Modifier to set the param values for a given list of parameter name regex patterns. To set all parameters in the given module, set to the ALL_TOKEN string: __ALL__

                                                    @@ -2576,7 +2582,7 @@

                                                    Submodules
                                                    -initialize(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer)[source]
                                                    +initialize(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer)[source]

                                                    Grab the layers params to control the values for within the given module

                                                    Parameters
                                                    @@ -2590,7 +2596,7 @@

                                                    Submodules
                                                    -params
                                                    +params

                                                    A list of full parameter names or regex patterns of names to apply pruning to. Regex patterns must be specified with the prefix ‘re:’. __ALL__ will match to all parameters.

                                                    @@ -2603,7 +2609,7 @@

                                                    Submodules
                                                    -params_strict
                                                    +params_strict

                                                    True if every regex pattern in params must match at least one parameter name in the module, False if missing params are ok and will not raise an err

                                                    @@ -2616,7 +2622,7 @@

                                                    Submodules
                                                    -update(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]
                                                    +update(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]

                                                    If start_pending(), updates the modules layers params to the value based on given settings.

                                                    @@ -2634,7 +2640,7 @@

                                                    Submodules
                                                    -val
                                                    +val

                                                    The value to set for the given param in the given layers at start_epoch

                                                    Type
                                                    @@ -2647,7 +2653,7 @@

                                                    Submodules
                                                    -class sparseml.pytorch.optim.modifier_params.TrainableParamsModifier(params: Union[str, List[str]], trainable: bool, params_strict: bool = True, start_epoch: float = - 1.0, end_epoch: float = - 1.0)[source]
                                                    +class sparseml.pytorch.optim.modifier_params.TrainableParamsModifier(params: Union[str, List[str]], trainable: bool, params_strict: bool = True, start_epoch: float = - 1.0, end_epoch: float = - 1.0)[source]

                                                    Bases: sparseml.pytorch.optim.modifier.ScheduledModifier

                                                    Modifier to control the params for a given list of parameter regex patterns. If end_epoch is supplied and greater than 0, then it will revert to the trainable @@ -2687,7 +2693,7 @@

                                                    Submodules
                                                    -initialize(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer)[source]
                                                    +initialize(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer)[source]

                                                    Grab the layers params to control trainable or not for within the given module

                                                    Parameters
                                                    @@ -2701,7 +2707,7 @@

                                                    Submodules
                                                    -params
                                                    +params

                                                    A list of full parameter names or regex patterns of names to apply pruning to. Regex patterns must be specified with the prefix ‘re:’. __ALL__ will match to all parameters.

                                                    @@ -2714,7 +2720,7 @@

                                                    Submodules
                                                    -params_strict
                                                    +params_strict

                                                    True if every regex pattern in params must match at least one parameter name in the module False if missing params are ok and will not raise an err

                                                    @@ -2727,7 +2733,7 @@

                                                    Submodules
                                                    -trainable
                                                    +trainable

                                                    True if the param(s) should be made trainable, False to make them non-trainable

                                                    @@ -2739,7 +2745,7 @@

                                                    Submodules
                                                    -update(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]
                                                    +update(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]

                                                    If start_pending(), updates the modules layers params to be trainable or not depending on given settings. If end_pending(), updates the modules layers params to their original @@ -2766,7 +2772,7 @@

                                                    Submodules
                                                    -class sparseml.pytorch.optim.modifier_pruning.ConstantPruningModifier(params: Union[str, List[str]], start_epoch: float = - 1.0, end_epoch: float = - 1.0, log_types: Union[str, List[str]] = '__ALL__')[source]
                                                    +class sparseml.pytorch.optim.modifier_pruning.ConstantPruningModifier(params: Union[str, List[str]], start_epoch: float = - 1.0, end_epoch: float = - 1.0, log_types: Union[str, List[str]] = '__ALL__')[source]

                                                    Bases: sparseml.pytorch.optim.modifier.ScheduledModifier

                                                    Holds the sparsity level and shape for a given parameter(s) constant while training. Useful for transfer learning use cases.

                                                    @@ -2797,7 +2803,7 @@

                                                    Submodules
                                                    -static from_sparse_model(model: torch.nn.modules.module.Module) → List[sparseml.pytorch.optim.modifier.ScheduledModifier][source]
                                                    +static from_sparse_model(model: torch.nn.modules.module.Module)List[sparseml.pytorch.optim.modifier.ScheduledModifier][source]

                                                    Create constant ks modifiers for all prunable params in the given model (conv, linear) that have been artificially sparsified (sparsity > 40%). Useful for transfer learning from a pruned model.

                                                    @@ -2813,7 +2819,7 @@

                                                    Submodules
                                                    -initialize(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer)[source]
                                                    +initialize(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer)[source]

                                                    Grab the params to control kernel sparsity for.

                                                    Parameters
                                                    @@ -2827,7 +2833,7 @@

                                                    Submodules
                                                    -load_state_dict(state_dict: Dict[str, torch.Tensor])[source]
                                                    +load_state_dict(state_dict: Dict[str, torch.Tensor])[source]

                                                    Loads the given state dict into this object’s modifiers

                                                    Parameters
                                                    @@ -2843,7 +2849,7 @@

                                                    Submodules
                                                    -log_update(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]
                                                    +log_update(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]

                                                    Check whether to log an update for the learning rate of the modifier.

                                                    Parameters
                                                    @@ -2860,7 +2866,7 @@

                                                    Submodules
                                                    -optimizer_post_step(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]
                                                    +optimizer_post_step(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]

                                                    Reapply the mask after the optimizer step in case the optimizer has momentum that may have moved weights from 0.

                                                    @@ -2878,7 +2884,7 @@

                                                    Submodules
                                                    -params
                                                    +params

                                                    A list of full parameter names or regex patterns of names to apply pruning to. Regex patterns must be specified with the prefix ‘re:’. __ALL__ will match to all parameters.

                                                    @@ -2891,7 +2897,7 @@

                                                    Submodules
                                                    -state_dict() → Dict[str, torch.Tensor][source]
                                                    +state_dict()Dict[str, torch.Tensor][source]
                                                    Returns

                                                    Dictionary to store the masks currently created by this object. The @@ -2902,7 +2908,7 @@

                                                    Submodules
                                                    -update(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]
                                                    +update(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]

                                                    Update to enable and disable the mask when chosen.

                                                    Parameters
                                                    @@ -2921,7 +2927,7 @@

                                                    Submodules
                                                    -class sparseml.pytorch.optim.modifier_pruning.GMPruningModifier(init_sparsity: float, final_sparsity: float, start_epoch: float, end_epoch: float, update_frequency: float, params: Union[str, List[str]], leave_enabled: bool = True, inter_func: str = 'cubic', log_types: Union[str, List[str]] = '__ALL__', mask_type: Union[str, List[int], sparseml.pytorch.optim.mask_creator_pruning.PruningMaskCreator] = 'unstructured')[source]
                                                    +class sparseml.pytorch.optim.modifier_pruning.GMPruningModifier(init_sparsity: float, final_sparsity: float, start_epoch: float, end_epoch: float, update_frequency: float, params: Union[str, List[str]], leave_enabled: bool = True, inter_func: str = 'cubic', log_types: Union[str, List[str]] = '__ALL__', mask_type: Union[str, List[int], sparseml.pytorch.optim.mask_creator_pruning.PruningMaskCreator] = 'unstructured')[source]

                                                    Bases: sparseml.pytorch.optim.modifier.ScheduledUpdateModifier

                                                    Gradually applies kernel sparsity to a given parameter or parameters from init_sparsity until final_sparsity is reached over a given amount of time @@ -2973,12 +2979,12 @@

                                                    Submodules
                                                    -applied_sparsity
                                                    +applied_sparsity

                                                    -final_sparsity
                                                    +final_sparsity

                                                    the final sparsity for the param to end with at end_epoch

                                                    Type
                                                    @@ -2989,7 +2995,7 @@

                                                    Submodules
                                                    -init_sparsity
                                                    +init_sparsity

                                                    the initial sparsity for the param to start with at start_epoch

                                                    Type
                                                    @@ -3000,7 +3006,7 @@

                                                    Submodules
                                                    -initialize(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer)[source]
                                                    +initialize(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer)[source]

                                                    Grab the params to control kernel sparsity for

                                                    Parameters
                                                    @@ -3014,7 +3020,7 @@

                                                    Submodules
                                                    -inter_func
                                                    +inter_func

                                                    the type of interpolation function to use: [linear, cubic, inverse_cubic]

                                                    @@ -3026,7 +3032,7 @@

                                                    Submodules
                                                    -leave_enabled
                                                    +leave_enabled

                                                    True to continue masking the weights after end_epoch, False to stop masking. Note, if set as False, sparsity will not be enforced and the model will likely deviate from the sparse solution

                                                    @@ -3039,7 +3045,7 @@

                                                    Submodules
                                                    -load_state_dict(state_dict: Dict[str, torch.Tensor])[source]
                                                    +load_state_dict(state_dict: Dict[str, torch.Tensor])[source]

                                                    Loads the given state dict into this object’s modifiers

                                                    Parameters
                                                    @@ -3055,7 +3061,7 @@

                                                    Submodules
                                                    -log_update(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]
                                                    +log_update(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]

                                                    Check whether to log an update for the learning rate of the modifier.

                                                    Parameters
                                                    @@ -3072,7 +3078,7 @@

                                                    Submodules
                                                    -mask_type
                                                    +mask_type

                                                    the SparsityMaskCreator object used

                                                    Type
                                                    @@ -3083,7 +3089,7 @@

                                                    Submodules
                                                    -optimizer_post_step(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]
                                                    +optimizer_post_step(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]

                                                    Reapply the mask after the optimizer step in case the optimizer has momentum that may have moved weights from 0.

                                                    @@ -3101,7 +3107,7 @@

                                                    Submodules
                                                    -params
                                                    +params

                                                    A list of full parameter names or regex patterns of names to apply pruning to. Regex patterns must be specified with the prefix ‘re:’. __ALL__ will match to all parameters.

                                                    @@ -3114,7 +3120,7 @@

                                                    Submodules
                                                    -state_dict() → Dict[str, torch.Tensor][source]
                                                    +state_dict()Dict[str, torch.Tensor][source]
                                                    Returns

                                                    Dictionary to store the masks currently created by this object. The @@ -3125,7 +3131,7 @@

                                                    Submodules
                                                    -update(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]
                                                    +update(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]

                                                    Update the sparsity mask for the selected parameters. If start, enables the masks. If end, disables the masks if leave_enabled is False.

                                                    @@ -3144,7 +3150,7 @@

                                                    Submodules
                                                    -validate()[source]
                                                    +validate()[source]

                                                    Validate the values of the params for the current instance are valid

                                                    @@ -3157,7 +3163,7 @@

                                                    Submodules
                                                    -class sparseml.pytorch.optim.modifier_quantization.QuantizationModifier(start_epoch: float = - 1.0, submodules: Optional[List[str]] = None, model_fuse_fn_name: Optional[str] = None, disable_quantization_observer_epoch: Union[None, float] = None, freeze_bn_stats_epoch: Union[None, float] = None, end_epoch: float = - 1, model_fuse_fn_kwargs: Optional[Dict[str, Any]] = None)[source]
                                                    +class sparseml.pytorch.optim.modifier_quantization.QuantizationModifier(start_epoch: float = - 1.0, submodules: Optional[List[str]] = None, model_fuse_fn_name: Optional[str] = None, disable_quantization_observer_epoch: Union[None, float] = None, freeze_bn_stats_epoch: Union[None, float] = None, end_epoch: float = - 1, model_fuse_fn_kwargs: Optional[Dict[str, Any]] = None)[source]

                                                    Bases: sparseml.pytorch.optim.modifier.ScheduledModifier

                                                    Enables quantization aware training (QAT) for a given module or its submodules After the start epoch, the specified module(s)’ forward pass will emulate @@ -3199,7 +3205,7 @@

                                                    Submodules
                                                    -disable_quantization_observer_epoch
                                                    +disable_quantization_observer_epoch

                                                    Epoch to disable updates to the module’s quantization observers. After this point, quantized weights and zero points will not be updated. When None, observers never disabled during QAT

                                                    @@ -3212,7 +3218,7 @@

                                                    Submodules
                                                    -freeze_bn_stats_epoch
                                                    +freeze_bn_stats_epoch

                                                    Epoch to stop the tracking of batch norm stats. When None, batch norm stats are track for all of training

                                                    @@ -3224,7 +3230,7 @@

                                                    Submodules
                                                    -initialize(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer)[source]
                                                    +initialize(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer)[source]

                                                    Grab the module / submodule to perform QAT on

                                                    Parameters
                                                    @@ -3238,7 +3244,7 @@

                                                    Submodules
                                                    -model_fuse_fn_name
                                                    +model_fuse_fn_name

                                                    Name of model function to fuse the model in place prior to performing QAT. None to uses the default function sparseml.pytorch.utils.fuse_module_conv_bn_relus.

                                                    @@ -3251,7 +3257,7 @@

                                                    Submodules
                                                    -submodules
                                                    +submodules

                                                    List of submodule names to perform QAT on. None quantizes the entire model

                                                    @@ -3263,7 +3269,7 @@

                                                    Submodules
                                                    -update(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]
                                                    +update(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]

                                                    If start_pending(), fuses the model, sets the model quantization config, calls torch.quantization.prepare_qat on the model to begin QAT If end_pending(), updates the modules layers params to their original @@ -3283,7 +3289,7 @@

                                                    Submodules
                                                    -update_ready(epoch: float, steps_per_epoch: int) → bool[source]
                                                    +update_ready(epoch: float, steps_per_epoch: int)bool[source]
                                                    Parameters
                                                      @@ -3306,7 +3312,7 @@

                                                      Submodules
                                                      -class sparseml.pytorch.optim.modifier_regularizer.SetWeightDecayModifier(weight_decay: float, start_epoch: float = - 1.0, param_groups: Optional[List[int]] = None, end_epoch: float = - 1.0, log_types: Union[str, List[str]] = '__ALL__', constant_logging: bool = False)[source]
                                                      +class sparseml.pytorch.optim.modifier_regularizer.SetWeightDecayModifier(weight_decay: float, start_epoch: float = - 1.0, param_groups: Optional[List[int]] = None, end_epoch: float = - 1.0, log_types: Union[str, List[str]] = '__ALL__', constant_logging: bool = False)[source]

                                                      Bases: sparseml.pytorch.optim.modifier.ScheduledModifier

                                                      Modifies the weight decay (L2 penalty) applied to with an optimizer during training

                                                      @@ -3338,7 +3344,7 @@

                                                      Submodules
                                                      -constant_logging
                                                      +constant_logging

                                                      True to constantly log on every step, False to only log on an LR change, default True

                                                      @@ -3350,7 +3356,7 @@

                                                      Submodules
                                                      -log_update(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]
                                                      +log_update(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]

                                                      Check whether to log an update for the weight decay of the modifier If constant logging is enabled, then will always log Otherwise only logs after this modifier makes a change to the weight decay

                                                      @@ -3369,7 +3375,7 @@

                                                      Submodules
                                                      -param_groups
                                                      +param_groups

                                                      The indices of param groups in the optimizer to be modified. If None, all param groups will be modified.

                                                      @@ -3381,7 +3387,7 @@

                                                      Submodules
                                                      -update(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]
                                                      +update(module: torch.nn.modules.module.Module, optimizer: torch.optim.optimizer.Optimizer, epoch: float, steps_per_epoch: int)[source]

                                                      If start_pending(), updates the optimizers weight decay according to the parameters of this modifier

                                                      @@ -3399,7 +3405,7 @@

                                                      Submodules
                                                      -weight_decay
                                                      +weight_decay

                                                      weight decay (L2 penalty) value to set for the given optimizer

                                                      Type
                                                      @@ -3416,7 +3422,7 @@

                                                      Submodules
                                                      -class sparseml.pytorch.optim.optimizer.ScheduledOptimizer(optimizer: torch.optim.optimizer.Optimizer, module: torch.nn.modules.module.Module, manager: sparseml.pytorch.optim.manager.ScheduledModifierManager, steps_per_epoch: int, loggers: Optional[List[sparseml.pytorch.utils.logger.PyTorchLogger]] = None)[source]
                                                      +class sparseml.pytorch.optim.optimizer.ScheduledOptimizer(optimizer: torch.optim.optimizer.Optimizer, module: torch.nn.modules.module.Module, manager: sparseml.pytorch.optim.manager.ScheduledModifierManager, steps_per_epoch: int, loggers: Optional[List[sparseml.pytorch.utils.logger.PyTorchLogger]] = None)[source]

                                                      Bases: torch.optim.optimizer.Optimizer

                                                      An optimizer wrapper to handle applying modifiers according to their schedule to both the passed in optimizer and the module.

                                                      @@ -3461,7 +3467,7 @@

                                                      Submodules
                                                      -add_param_group(param_group)[source]
                                                      +add_param_group(param_group)[source]

                                                      Add a param group to the Optimizer s param_groups.

                                                      This can be useful when fine tuning a pre-trained network as frozen layers can be made trainable and added to the Optimizer as training progresses.

                                                      @@ -3477,7 +3483,7 @@

                                                      Submodules
                                                      -adjust_current_step(epoch: int, step: int)[source]
                                                      +adjust_current_step(epoch: int, step: int)[source]

                                                      Adjust the current step for the manager’s schedule to the given epoch and step.

                                                      Parameters
                                                      @@ -3492,7 +3498,7 @@

                                                      Submodules
                                                      -property learning_rate
                                                      +property learning_rate

                                                      convenience function to get the first learning rate for any of the param groups in the optimizer

                                                      @@ -3504,12 +3510,12 @@

                                                      Submodules
                                                      -load_manager_state_dict(state_dict)[source]
                                                      +load_manager_state_dict(state_dict)[source]

                                                      -load_state_dict(state_dict)[source]
                                                      +load_state_dict(state_dict)[source]

                                                      Loads the optimizer state.

                                                      Parameters
                                                      @@ -3521,7 +3527,7 @@

                                                      Submodules
                                                      -loss_update(loss: torch.Tensor) → torch.Tensor[source]
                                                      +loss_update(loss: torch.Tensor)torch.Tensor[source]

                                                      Optional call to update modifiers based on the calculated loss. Not needed unless one or more of the modifier is using the loss to make a modification or is modifying the loss itself.

                                                      @@ -3537,7 +3543,7 @@

                                                      Submodules
                                                      -property manager
                                                      +property manager

                                                      The ScheduledModifierManager for this optimizer

                                                      Type
                                                      @@ -3548,17 +3554,17 @@

                                                      Submodules
                                                      -manager_state_dict()[source]
                                                      +manager_state_dict()[source]

                                                      -property param_groups
                                                      +property param_groups
                                                      -state_dict()[source]
                                                      +state_dict()[source]

                                                      Returns the state of the optimizer as a dict.

                                                      It contains two entries:

                                                        @@ -3573,7 +3579,7 @@

                                                        Submodules
                                                        -step(closure=None)[source]
                                                        +step(closure=None)[source]

                                                        Called to perform a step on the optimizer activation normal. Updates the current epoch based on the step count. Calls into modifiers before the step happens. @@ -3588,7 +3594,7 @@

                                                        Submodules
                                                        -zero_grad()[source]
                                                        +zero_grad()[source]

                                                        Sets the gradients of all optimized torch.Tensor s to zero.

                                                        Parameters
                                                        @@ -3614,7 +3620,7 @@

                                                        Submodules
                                                        -class sparseml.pytorch.optim.sensitivity_as.ASLayerTracker(layer: torch.nn.modules.module.Module, track_input: bool = False, track_output: bool = False, input_func: Union[None, Callable] = None, output_func: Union[None, Callable] = None)[source]
                                                        +class sparseml.pytorch.optim.sensitivity_as.ASLayerTracker(layer: torch.nn.modules.module.Module, track_input: bool = False, track_output: bool = False, input_func: Union[None, Callable] = None, output_func: Union[None, Callable] = None)[source]

                                                        Bases: object

                                                        An implementation for tracking activation sparsity properties for a module.

                                                        @@ -3632,25 +3638,25 @@

                                                        Submodules
                                                        -clear()[source]
                                                        +clear()[source]

                                                        Clear out current results for the model

                                                        -disable()[source]
                                                        +disable()[source]

                                                        Disable the forward hooks for the layer

                                                        -enable()[source]
                                                        +enable()[source]

                                                        Enable the forward hooks to the layer

                                                        -property tracked_input
                                                        +property tracked_input

                                                        the current tracked input results

                                                        Type
                                                        @@ -3661,7 +3667,7 @@

                                                        Submodules
                                                        -property tracked_output
                                                        +property tracked_output

                                                        the current tracked output results

                                                        Type
                                                        @@ -3674,7 +3680,7 @@

                                                        Submodules
                                                        -class sparseml.pytorch.optim.sensitivity_as.LayerBoostResults(name: str, threshold: float, boosted_as: torch.Tensor, boosted_loss: sparseml.pytorch.utils.module.ModuleRunResults, baseline_as: torch.Tensor, baseline_loss: sparseml.pytorch.utils.module.ModuleRunResults)[source]
                                                        +class sparseml.pytorch.optim.sensitivity_as.LayerBoostResults(name: str, threshold: float, boosted_as: torch.Tensor, boosted_loss: sparseml.pytorch.utils.module.ModuleRunResults, baseline_as: torch.Tensor, baseline_loss: sparseml.pytorch.utils.module.ModuleRunResults)[source]

                                                        Bases: object

                                                        Results for a specific threshold set in a FATReLU layer.

                                                        @@ -3691,7 +3697,7 @@

                                                        Submodules
                                                        -property baseline_as
                                                        +property baseline_as

                                                        the measured activation sparsity before threshold is applied

                                                        Type
                                                        @@ -3702,7 +3708,7 @@

                                                        Submodules
                                                        -property baseline_loss
                                                        +property baseline_loss

                                                        the measured loss before threshold is applied

                                                        Type
                                                        @@ -3713,7 +3719,7 @@

                                                        Submodules
                                                        -property boosted_as
                                                        +property boosted_as

                                                        the measured activation sparsity after threshold is applied

                                                        Type
                                                        @@ -3724,7 +3730,7 @@

                                                        Submodules
                                                        -property boosted_loss
                                                        +property boosted_loss

                                                        the measured loss after threshold is applied

                                                        Type
                                                        @@ -3735,7 +3741,7 @@

                                                        Submodules
                                                        -property name
                                                        +property name

                                                        the name of the layer the results are for

                                                        Type
                                                        @@ -3746,7 +3752,7 @@

                                                        Submodules
                                                        -property threshold
                                                        +property threshold

                                                        the threshold used in the FATReLU layer

                                                        Type
                                                        @@ -3759,7 +3765,7 @@

                                                        Submodules
                                                        -class sparseml.pytorch.optim.sensitivity_as.ModuleASOneShootBooster(module: torch.nn.modules.module.Module, device: str, dataset: torch.utils.data.dataset.Dataset, batch_size: int, loss: sparseml.pytorch.utils.loss.LossWrapper, data_loader_kwargs: Dict)[source]
                                                        +class sparseml.pytorch.optim.sensitivity_as.ModuleASOneShootBooster(module: torch.nn.modules.module.Module, device: str, dataset: torch.utils.data.dataset.Dataset, batch_size: int, loss: sparseml.pytorch.utils.loss.LossWrapper, data_loader_kwargs: Dict)[source]

                                                        Bases: object

                                                        Implementation class for boosting the activation sparsity in a given module using FATReLUs. @@ -3780,7 +3786,7 @@

                                                        Submodules
                                                        -run_layers(layers: List[str], max_target_metric_loss: float, metric_key: str, metric_increases: bool, precision: float = 0.001) → Dict[str, sparseml.pytorch.optim.sensitivity_as.LayerBoostResults][source]
                                                        +run_layers(layers: List[str], max_target_metric_loss: float, metric_key: str, metric_increases: bool, precision: float = 0.001)Dict[str, sparseml.pytorch.optim.sensitivity_as.LayerBoostResults][source]

                                                        Run the booster for the specified layers.

                                                        Parameters
                                                        @@ -3811,7 +3817,7 @@

                                                        Submodules
                                                        -sparseml.pytorch.optim.sensitivity_lr.default_exponential_check_lrs(init_lr: float = 1e-06, final_lr: float = 0.5, lr_mult: float = 1.1) → Tuple[float, ][source]
                                                        +sparseml.pytorch.optim.sensitivity_lr.default_exponential_check_lrs(init_lr: float = 1e-06, final_lr: float = 0.5, lr_mult: float = 1.1)Tuple[float, ][source]

                                                        Get the default learning rates to check between init_lr and final_lr.

                                                        Parameters
                                                        @@ -3831,7 +3837,7 @@

                                                        Submodules
                                                        -sparseml.pytorch.optim.sensitivity_lr.lr_loss_sensitivity(module: torch.nn.modules.module.Module, data: torch.utils.data.dataloader.DataLoader, loss: Union[sparseml.pytorch.utils.loss.LossWrapper, Callable[[Any, Any], torch.Tensor]], optim: torch.optim.optimizer.Optimizer, device: str, steps_per_measurement: int, check_lrs: Union[List[float], Tuple[float, ]] = (1e-06, 1.1e-06, 1.21e-06, 1.3310000000000003e-06, 1.4641000000000003e-06, 1.6105100000000006e-06, 1.7715610000000007e-06, 1.948717100000001e-06, 2.1435888100000012e-06, 2.3579476910000015e-06, 2.5937424601000017e-06, 2.853116706110002e-06, 3.1384283767210024e-06, 3.452271214393103e-06, 3.7974983358324136e-06, 4.177248169415655e-06, 4.594972986357221e-06, 5.0544702849929435e-06, 5.559917313492238e-06, 6.115909044841462e-06, 6.727499949325609e-06, 7.40024994425817e-06, 8.140274938683989e-06, 8.954302432552388e-06, 9.849732675807628e-06, 1.0834705943388392e-05, 1.1918176537727232e-05, 1.3109994191499957e-05, 1.4420993610649954e-05, 1.586309297171495e-05, 1.7449402268886447e-05, 1.9194342495775094e-05, 2.1113776745352607e-05, 2.322515441988787e-05, 2.554766986187666e-05, 2.8102436848064327e-05, 3.091268053287076e-05, 3.4003948586157844e-05, 3.7404343444773634e-05, 4.1144777789251e-05, 4.52592555681761e-05, 4.978518112499371e-05, 5.4763699237493086e-05, 6.02400691612424e-05, 6.626407607736664e-05, 7.289048368510331e-05, 8.017953205361364e-05, 8.819748525897502e-05, 9.701723378487253e-05, 0.00010671895716335979, 0.00011739085287969578, 0.00012912993816766537, 0.00014204293198443192, 0.00015624722518287512, 0.00017187194770116264, 0.00018905914247127894, 0.00020796505671840686, 0.00022876156239024756, 0.00025163771862927233, 0.0002768014904921996, 0.0003044816395414196, 0.00033492980349556157, 0.00036842278384511775, 0.0004052650622296296, 0.0004457915684525926, 0.0004903707252978519, 0.0005394077978276372, 0.000593348577610401, 0.0006526834353714411, 0.0007179517789085853, 0.0007897469567994438, 0.0008687216524793883, 0.0009555938177273272, 0.00105115319950006, 0.001156268519450066, 0.0012718953713950728, 0.0013990849085345801, 0.0015389933993880383, 0.0016928927393268422, 0.0018621820132595267, 0.0020484002145854797, 0.0022532402360440277, 0.0024785642596484307, 0.002726420685613274, 0.0029990627541746015, 0.003298969029592062, 0.0036288659325512686, 0.003991752525806396, 0.0043909277783870364, 0.004830020556225741, 0.005313022611848316, 0.005844324873033148, 0.006428757360336463, 0.00707163309637011, 0.007778796406007121, 0.008556676046607835, 0.009412343651268619, 0.010353578016395481, 0.01138893581803503, 0.012527829399838533, 0.013780612339822387, 0.015158673573804626, 0.01667454093118509, 0.0183419950243036, 0.020176194526733963, 0.02219381397940736, 0.0244131953773481, 0.02685451491508291, 0.029539966406591206, 0.03249396304725033, 0.03574335935197537, 0.03931769528717291, 0.043249464815890204, 0.047574411297479226, 0.052331852427227155, 0.05756503766994987, 0.06332154143694486, 0.06965369558063936, 0.0766190651387033, 0.08428097165257363, 0.092709068817831, 0.10197997569961412, 0.11217797326957554, 0.1233957705965331, 0.13573534765618642, 0.14930888242180507, 0.1642397706639856, 0.18066374773038418, 0.19873012250342262, 0.2186031347537649, 0.2404634482291414, 0.2645097930520556, 0.29096077235726114, 0.3200568495929873, 0.3520625345522861, 0.38726878800751474, 0.4259956668082662, 0.4685952334890929, 0.5154547568380022, 0.5), loss_key: str = '__loss__', trainer_run_funcs: Optional[sparseml.pytorch.utils.module.ModuleRunFuncs] = None, trainer_loggers: Optional[List[sparseml.pytorch.utils.logger.PyTorchLogger]] = None, show_progress: bool = True)sparseml.optim.sensitivity.LRLossSensitivityAnalysis[source]
                                                        +sparseml.pytorch.optim.sensitivity_lr.lr_loss_sensitivity(module: torch.nn.modules.module.Module, data: torch.utils.data.dataloader.DataLoader, loss: Union[sparseml.pytorch.utils.loss.LossWrapper, Callable[[Any, Any], torch.Tensor]], optim: torch.optim.optimizer.Optimizer, device: str, steps_per_measurement: int, check_lrs: Union[List[float], Tuple[float, ]] = (1e-06, 1.1e-06, 1.21e-06, 1.3310000000000003e-06, 1.4641000000000003e-06, 1.6105100000000006e-06, 1.7715610000000007e-06, 1.948717100000001e-06, 2.1435888100000012e-06, 2.3579476910000015e-06, 2.5937424601000017e-06, 2.853116706110002e-06, 3.1384283767210024e-06, 3.452271214393103e-06, 3.7974983358324136e-06, 4.177248169415655e-06, 4.594972986357221e-06, 5.0544702849929435e-06, 5.559917313492238e-06, 6.115909044841462e-06, 6.727499949325609e-06, 7.40024994425817e-06, 8.140274938683989e-06, 8.954302432552388e-06, 9.849732675807628e-06, 1.0834705943388392e-05, 1.1918176537727232e-05, 1.3109994191499957e-05, 1.4420993610649954e-05, 1.586309297171495e-05, 1.7449402268886447e-05, 1.9194342495775094e-05, 2.1113776745352607e-05, 2.322515441988787e-05, 2.554766986187666e-05, 2.8102436848064327e-05, 3.091268053287076e-05, 3.4003948586157844e-05, 3.7404343444773634e-05, 4.1144777789251e-05, 4.52592555681761e-05, 4.978518112499371e-05, 5.4763699237493086e-05, 6.02400691612424e-05, 6.626407607736664e-05, 7.289048368510331e-05, 8.017953205361364e-05, 8.819748525897502e-05, 9.701723378487253e-05, 0.00010671895716335979, 0.00011739085287969578, 0.00012912993816766537, 0.00014204293198443192, 0.00015624722518287512, 0.00017187194770116264, 0.00018905914247127894, 0.00020796505671840686, 0.00022876156239024756, 0.00025163771862927233, 0.0002768014904921996, 0.0003044816395414196, 0.00033492980349556157, 0.00036842278384511775, 0.0004052650622296296, 0.0004457915684525926, 0.0004903707252978519, 0.0005394077978276372, 0.000593348577610401, 0.0006526834353714411, 0.0007179517789085853, 0.0007897469567994438, 0.0008687216524793883, 0.0009555938177273272, 0.00105115319950006, 0.001156268519450066, 0.0012718953713950728, 0.0013990849085345801, 0.0015389933993880383, 0.0016928927393268422, 0.0018621820132595267, 0.0020484002145854797, 0.0022532402360440277, 0.0024785642596484307, 0.002726420685613274, 0.0029990627541746015, 0.003298969029592062, 0.0036288659325512686, 0.003991752525806396, 0.0043909277783870364, 0.004830020556225741, 0.005313022611848316, 0.005844324873033148, 0.006428757360336463, 0.00707163309637011, 0.007778796406007121, 0.008556676046607835, 0.009412343651268619, 0.010353578016395481, 0.01138893581803503, 0.012527829399838533, 0.013780612339822387, 0.015158673573804626, 0.01667454093118509, 0.0183419950243036, 0.020176194526733963, 0.02219381397940736, 0.0244131953773481, 0.02685451491508291, 0.029539966406591206, 0.03249396304725033, 0.03574335935197537, 0.03931769528717291, 0.043249464815890204, 0.047574411297479226, 0.052331852427227155, 0.05756503766994987, 0.06332154143694486, 0.06965369558063936, 0.0766190651387033, 0.08428097165257363, 0.092709068817831, 0.10197997569961412, 0.11217797326957554, 0.1233957705965331, 0.13573534765618642, 0.14930888242180507, 0.1642397706639856, 0.18066374773038418, 0.19873012250342262, 0.2186031347537649, 0.2404634482291414, 0.2645097930520556, 0.29096077235726114, 0.3200568495929873, 0.3520625345522861, 0.38726878800751474, 0.4259956668082662, 0.4685952334890929, 0.5154547568380022, 0.5), loss_key: str = '__loss__', trainer_run_funcs: Optional[sparseml.pytorch.utils.module.ModuleRunFuncs] = None, trainer_loggers: Optional[List[sparseml.pytorch.utils.logger.PyTorchLogger]] = None, show_progress: bool = True)sparseml.optim.sensitivity.LRLossSensitivityAnalysis[source]

                                                        Implementation for handling running sensitivity analysis for learning rates on modules.

                                                        @@ -3870,7 +3876,7 @@

                                                        Submodules
                                                        -sparseml.pytorch.optim.sensitivity_pruning.model_prunability_magnitude(module: torch.nn.modules.module.Module)[source]
                                                        +sparseml.pytorch.optim.sensitivity_pruning.model_prunability_magnitude(module: torch.nn.modules.module.Module)[source]

                                                        Calculate the approximate sensitivity for an overall model. Range of the values are not scaled to anything, so must be taken in context with other known models.

                                                        @@ -3886,7 +3892,7 @@

                                                        Submodules
                                                        -sparseml.pytorch.optim.sensitivity_pruning.pruning_loss_sens_magnitude(module: torch.nn.modules.module.Module, sparsity_levels: Union[List[float], Tuple[float, ]] = (0.0, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.2, 0.21, 0.22, 0.23, 0.24, 0.25, 0.26, 0.27, 0.28, 0.29, 0.3, 0.31, 0.32, 0.33, 0.34, 0.35, 0.36, 0.37, 0.38, 0.39, 0.4, 0.41, 0.42, 0.43, 0.44, 0.45, 0.46, 0.47, 0.48, 0.49, 0.5, 0.51, 0.52, 0.53, 0.54, 0.55, 0.56, 0.57, 0.58, 0.59, 0.6, 0.61, 0.62, 0.63, 0.64, 0.65, 0.66, 0.67, 0.68, 0.69, 0.7, 0.71, 0.72, 0.73, 0.74, 0.75, 0.76, 0.77, 0.78, 0.79, 0.8, 0.81, 0.82, 0.83, 0.84, 0.85, 0.86, 0.87, 0.88, 0.89, 0.9, 0.91, 0.92, 0.93, 0.94, 0.95, 0.96, 0.97, 0.98, 0.99))sparseml.optim.sensitivity.PruningLossSensitivityAnalysis[source]
                                                        +sparseml.pytorch.optim.sensitivity_pruning.pruning_loss_sens_magnitude(module: torch.nn.modules.module.Module, sparsity_levels: Union[List[float], Tuple[float, ]] = (0.0, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.2, 0.21, 0.22, 0.23, 0.24, 0.25, 0.26, 0.27, 0.28, 0.29, 0.3, 0.31, 0.32, 0.33, 0.34, 0.35, 0.36, 0.37, 0.38, 0.39, 0.4, 0.41, 0.42, 0.43, 0.44, 0.45, 0.46, 0.47, 0.48, 0.49, 0.5, 0.51, 0.52, 0.53, 0.54, 0.55, 0.56, 0.57, 0.58, 0.59, 0.6, 0.61, 0.62, 0.63, 0.64, 0.65, 0.66, 0.67, 0.68, 0.69, 0.7, 0.71, 0.72, 0.73, 0.74, 0.75, 0.76, 0.77, 0.78, 0.79, 0.8, 0.81, 0.82, 0.83, 0.84, 0.85, 0.86, 0.87, 0.88, 0.89, 0.9, 0.91, 0.92, 0.93, 0.94, 0.95, 0.96, 0.97, 0.98, 0.99))sparseml.optim.sensitivity.PruningLossSensitivityAnalysis[source]

                                                        Approximated kernel sparsity (pruning) loss analysis for a given model. Returns the results for each prunable param (conv, linear) in the model.

                                                        @@ -3904,7 +3910,7 @@

                                                        Submodules
                                                        -sparseml.pytorch.optim.sensitivity_pruning.pruning_loss_sens_one_shot(module: torch.nn.modules.module.Module, data: torch.utils.data.dataloader.DataLoader, loss: Union[sparseml.pytorch.utils.loss.LossWrapper, Callable[[Any, Any], torch.Tensor]], device: str, steps_per_measurement: int, sparsity_levels: List[int] = (0.0, 0.2, 0.4, 0.6, 0.7, 0.8, 0.85, 0.9, 0.95, 0.99), loss_key: str = '__loss__', tester_run_funcs: Optional[sparseml.pytorch.utils.module.ModuleRunFuncs] = None, tester_loggers: Optional[List[sparseml.pytorch.utils.logger.PyTorchLogger]] = None, show_progress: bool = True)sparseml.optim.sensitivity.PruningLossSensitivityAnalysis[source]
                                                        +sparseml.pytorch.optim.sensitivity_pruning.pruning_loss_sens_one_shot(module: torch.nn.modules.module.Module, data: torch.utils.data.dataloader.DataLoader, loss: Union[sparseml.pytorch.utils.loss.LossWrapper, Callable[[Any, Any], torch.Tensor]], device: str, steps_per_measurement: int, sparsity_levels: List[int] = (0.0, 0.2, 0.4, 0.6, 0.7, 0.8, 0.85, 0.9, 0.95, 0.99), loss_key: str = '__loss__', tester_run_funcs: Optional[sparseml.pytorch.utils.module.ModuleRunFuncs] = None, tester_loggers: Optional[List[sparseml.pytorch.utils.logger.PyTorchLogger]] = None, show_progress: bool = True)sparseml.optim.sensitivity.PruningLossSensitivityAnalysis[source]

                                                        Run a one shot sensitivity analysis for kernel sparsity. It does not retrain, and instead puts the model to eval mode. Moves layer by layer to calculate the sensitivity analysis for each and diff --git a/sparseml/api/sparseml.pytorch.optim.quantization.html b/sparseml/api/sparseml.pytorch.optim.quantization.html index 7e6a84b436f..30e668b4dd8 100644 --- a/sparseml/api/sparseml.pytorch.optim.quantization.html +++ b/sparseml/api/sparseml.pytorch.optim.quantization.html @@ -212,14 +212,14 @@

                                                        Submodules
                                                        -sparseml.pytorch.optim.quantization.helpers.add_quant_dequant(module)[source]
                                                        +sparseml.pytorch.optim.quantization.helpers.add_quant_dequant(module)[source]

                                                        Wraps all Conv and Linear submodule with a qconfig with a QuantWrapper :param module: the module to modify

                                                        -sparseml.pytorch.optim.quantization.helpers.fuse_module_conv_bn_relus(module: torch.nn.modules.module.Module, inplace: bool = True, override_bn_subclasses_forward: Union[bool, str] = True) → torch.nn.modules.module.Module[source]
                                                        +sparseml.pytorch.optim.quantization.helpers.fuse_module_conv_bn_relus(module: torch.nn.modules.module.Module, inplace: bool = True, override_bn_subclasses_forward: Union[bool, str] = True)torch.nn.modules.module.Module[source]

                                                        Performs fusion of Conv2d, BatchNorm2d, and ReLU layers found in the given module. To be fused, these layers must appear sequentially in module.named_modules() and be in the same submodule. @@ -247,7 +247,7 @@

                                                        Submodules
                                                        -sparseml.pytorch.optim.quantization.helpers.get_qat_qconfig() → torch.quantization.qconfig.QConfig[source]
                                                        +sparseml.pytorch.optim.quantization.helpers.get_qat_qconfig()torch.quantization.qconfig.QConfig[source]
                                                        Returns

                                                        A QAT fake quantization config for symmetric weight quantization and @@ -265,23 +265,23 @@

                                                        Submodules
                                                        -class sparseml.pytorch.optim.quantization.quantize_qat_export.QuantizationParams(scale, zero_point, target)
                                                        +class sparseml.pytorch.optim.quantization.quantize_qat_export.QuantizationParams(scale, zero_point, target)

                                                        Bases: tuple

                                                        -property scale
                                                        +property scale

                                                        Alias for field number 0

                                                        -property target
                                                        +property target

                                                        Alias for field number 2

                                                        -property zero_point
                                                        +property zero_point

                                                        Alias for field number 1

                                                        @@ -289,7 +289,7 @@

                                                        Submodules
                                                        -sparseml.pytorch.optim.quantization.quantize_qat_export.get_quantization_params(model: onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto, node: onnx.onnx_ONNX_REL_1_6_ml_pb2.NodeProto, include_target: bool = False)sparseml.pytorch.optim.quantization.quantize_qat_export.QuantizationParams[source]
                                                        +sparseml.pytorch.optim.quantization.quantize_qat_export.get_quantization_params(model: onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto, node: onnx.onnx_ONNX_REL_1_7_ml_pb2.NodeProto, include_target: bool = False)sparseml.pytorch.optim.quantization.quantize_qat_export.QuantizationParams[source]
                                                        Parameters
                                                          @@ -308,7 +308,7 @@

                                                          Submodules
                                                          -sparseml.pytorch.optim.quantization.quantize_qat_export.quantize_torch_qat_export(model: Union[onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto, str], output_file_path: Optional[str] = None, inplace: bool = True) → onnx.onnx_ONNX_REL_1_6_ml_pb2.ModelProto[source]
                                                          +sparseml.pytorch.optim.quantization.quantize_qat_export.quantize_torch_qat_export(model: Union[onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto, str], output_file_path: Optional[str] = None, inplace: bool = True)onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto[source]
                                                          Parameters
                                                            diff --git a/sparseml/api/sparseml.pytorch.utils.html b/sparseml/api/sparseml.pytorch.utils.html index e61d748bf92..8d0db9e8e33 100644 --- a/sparseml/api/sparseml.pytorch.utils.html +++ b/sparseml/api/sparseml.pytorch.utils.html @@ -210,7 +210,7 @@

                                                            Submodules
                                                            -class sparseml.pytorch.utils.benchmarker.BatchBenchmarkResults(batch_size: int)[source]
                                                            +class sparseml.pytorch.utils.benchmarker.BatchBenchmarkResults(batch_size: int)[source]

                                                            Bases: object

                                                            Container class for the results of a benchmark run for a given batch size. Contains convenience methods for calculating different metrics around the time @@ -222,7 +222,7 @@

                                                            Submodules
                                                            -add(model_sec: float, e2e_sec: float, batch_size: int)[source]
                                                            +add(model_sec: float, e2e_sec: float, batch_size: int)[source]

                                                            Add a new batch result

                                                            Parameters
                                                            @@ -238,7 +238,7 @@

                                                            Submodules
                                                            -property batch_size
                                                            +property batch_size

                                                            the batch size the results are for

                                                            Type
                                                            @@ -249,7 +249,7 @@

                                                            Submodules
                                                            -property e2e_batch_seconds
                                                            +property e2e_batch_seconds

                                                            the average overall time to execute the batches through the model and the system. Includes model execution time as well as time to transfer the data to @@ -263,7 +263,7 @@

                                                            Submodules
                                                            -property e2e_batch_timings
                                                            +property e2e_batch_timings

                                                            the overall timings in seconds for each batch to run through the model and the system. Includes model execution time as well as time to transfer the data to and @@ -277,7 +277,7 @@

                                                            Submodules
                                                            -property e2e_batches_per_second
                                                            +property e2e_batches_per_second

                                                            inverse of e2e_batch_seconds

                                                            Type
                                                            @@ -288,7 +288,7 @@

                                                            Submodules
                                                            -property e2e_item_seconds
                                                            +property e2e_item_seconds

                                                            the batch averaged overall time to execute the batches through the model and the system (e2e_batch_seconds / batch_size). Includes model execution time as well as time to transfer the data to @@ -302,7 +302,7 @@

                                                            Submodules
                                                            -property e2e_items_per_second
                                                            +property e2e_items_per_second

                                                            inverse of e2e_item_seconds

                                                            Type
                                                            @@ -313,7 +313,7 @@

                                                            Submodules
                                                            -property model_batch_seconds
                                                            +property model_batch_seconds

                                                            the average time it took to execute the batches through the model. Does not include time for transferring data to and from device (if any)

                                                            @@ -325,7 +325,7 @@

                                                            Submodules
                                                            -property model_batch_timings
                                                            +property model_batch_timings

                                                            the overall timings in seconds for each batch to run through the model. Does not include time for transferring data to and from device (if any)

                                                            @@ -337,7 +337,7 @@

                                                            Submodules
                                                            -property model_batches_per_second
                                                            +property model_batches_per_second

                                                            inverse of model_batch_seconds

                                                            Type
                                                            @@ -348,7 +348,7 @@

                                                            Submodules
                                                            -property model_item_seconds
                                                            +property model_item_seconds

                                                            the batch averaged time it took in seconds to execute one item through the model (model_batch_seconds / batch_size). Does not include time for transferring data to and from device (if any)

                                                            @@ -361,7 +361,7 @@

                                                            Submodules
                                                            -property model_items_per_second
                                                            +property model_items_per_second

                                                            inverse of model_items_per_second

                                                            Type
                                                            @@ -374,7 +374,7 @@

                                                            Submodules
                                                            -class sparseml.pytorch.utils.benchmarker.ModuleBenchmarker(module: torch.nn.modules.module.Module)[source]
                                                            +class sparseml.pytorch.utils.benchmarker.ModuleBenchmarker(module: torch.nn.modules.module.Module)[source]

                                                            Bases: object

                                                            Convenience class for benchmarking a model on a given device for given batches at a given precision.

                                                            @@ -385,7 +385,7 @@

                                                            Submodules
                                                            -run_batches_on_device(batches: List[Any], device: str, full_precision: bool = True, test_size: int = 100, warmup_size: int = 10)sparseml.pytorch.utils.benchmarker.BatchBenchmarkResults[source]
                                                            +run_batches_on_device(batches: List[Any], device: str, full_precision: bool = True, test_size: int = 100, warmup_size: int = 10)sparseml.pytorch.utils.benchmarker.BatchBenchmarkResults[source]
                                                            Parameters
                                                              @@ -411,7 +411,7 @@

                                                              Submodules
                                                              -class sparseml.pytorch.utils.exporter.ModuleExporter(module: torch.nn.modules.module.Module, output_dir: str)[source]
                                                              +class sparseml.pytorch.utils.exporter.ModuleExporter(module: torch.nn.modules.module.Module, output_dir: str)[source]

                                                              Bases: object

                                                              An exporter for exporting PyTorch modules into ONNX format as well as numpy arrays for the input and output tensors.

                                                              @@ -425,7 +425,7 @@

                                                              Submodules
                                                              -export_onnx(sample_batch: Any, name: str = 'model.onnx', opset: int = 11, disable_bn_fusing: bool = True)[source]
                                                              +export_onnx(sample_batch: Any, name: str = 'model.onnx', opset: int = 11, disable_bn_fusing: bool = True)[source]

                                                              Export an onnx file for the current module and for a sample batch. Sample batch used to feed through the model to freeze the graph for a particular execution.

                                                              @@ -450,7 +450,7 @@

                                                              Submodules
                                                              -export_pytorch(optimizer: Optional[torch.optim.optimizer.Optimizer] = None, epoch: Optional[int] = None, name: str = 'model.pth', use_zipfile_serialization_if_available: bool = True, include_modifiers: bool = False)[source]
                                                              +export_pytorch(optimizer: Optional[torch.optim.optimizer.Optimizer] = None, epoch: Optional[int] = None, name: str = 'model.pth', use_zipfile_serialization_if_available: bool = True, include_modifiers: bool = False)[source]

                                                              Export the pytorch state dicts into pth file within a pytorch framework directory.

                                                              @@ -471,7 +471,7 @@

                                                              Submodules
                                                              -export_samples(sample_batches: List[Any], sample_labels: Optional[List[Any]] = None, exp_counter: int = 0)[source]
                                                              +export_samples(sample_batches: List[Any], sample_labels: Optional[List[Any]] = None, exp_counter: int = 0)[source]

                                                              Export a set list of sample batches as inputs and outputs through the model.

                                                              Parameters
                                                              @@ -494,29 +494,29 @@

                                                              Submodules
                                                              -class sparseml.pytorch.utils.helpers.NamedLayerParam(layer_name, layer, param_name, param)
                                                              +class sparseml.pytorch.utils.helpers.NamedLayerParam(layer_name, layer, param_name, param)

                                                              Bases: tuple

                                                              -property layer
                                                              +property layer

                                                              Alias for field number 1

                                                              -property layer_name
                                                              +property layer_name

                                                              Alias for field number 0

                                                              -property param
                                                              +property param

                                                              Alias for field number 3

                                                              -property param_name
                                                              +property param_name

                                                              Alias for field number 2

                                                              @@ -524,7 +524,7 @@

                                                              Submodules
                                                              -sparseml.pytorch.utils.helpers.any_str_or_regex_matches_param_name(param_name: str, name_or_regex_patterns: List[str]) → bool[source]
                                                              +sparseml.pytorch.utils.helpers.any_str_or_regex_matches_param_name(param_name: str, name_or_regex_patterns: List[str])bool[source]
                                                              Parameters
                                                                @@ -541,7 +541,7 @@

                                                                Submodules
                                                                -sparseml.pytorch.utils.helpers.default_device() → str[source]
                                                                +sparseml.pytorch.utils.helpers.default_device()str[source]
                                                                Returns

                                                                the device that should be defaulted to for the current setup. @@ -554,7 +554,7 @@

                                                                Submodules
                                                                -sparseml.pytorch.utils.helpers.early_stop_data_loader(data_loader: torch.utils.data.dataloader.DataLoader, early_stop_steps: int)[source]
                                                                +sparseml.pytorch.utils.helpers.early_stop_data_loader(data_loader: torch.utils.data.dataloader.DataLoader, early_stop_steps: int)[source]

                                                                An iterator that goes through the data_loader for yields and stops after early_stop_steps instead of the full loader

                                                                @@ -574,7 +574,7 @@

                                                                Submodules
                                                                -sparseml.pytorch.utils.helpers.get_conv_layers(module: torch.nn.modules.module.Module) → Dict[str, torch.nn.modules.module.Module][source]
                                                                +sparseml.pytorch.utils.helpers.get_conv_layers(module: torch.nn.modules.module.Module)Dict[str, torch.nn.modules.module.Module][source]
                                                                Parameters

                                                                module – the module to grab all conv layers for

                                                                @@ -587,7 +587,7 @@

                                                                Submodules
                                                                -sparseml.pytorch.utils.helpers.get_layer(name: str, module: torch.nn.modules.module.Module) → torch.nn.modules.module.Module[source]
                                                                +sparseml.pytorch.utils.helpers.get_layer(name: str, module: torch.nn.modules.module.Module)torch.nn.modules.module.Module[source]
                                                                Parameters
                                                                  @@ -603,7 +603,7 @@

                                                                  Submodules
                                                                  -sparseml.pytorch.utils.helpers.get_layer_param(param: str, layer: str, module: torch.nn.modules.module.Module) → torch.nn.parameter.Parameter[source]
                                                                  +sparseml.pytorch.utils.helpers.get_layer_param(param: str, layer: str, module: torch.nn.modules.module.Module)torch.nn.parameter.Parameter[source]
                                                                  Parameters
                                                                    @@ -620,7 +620,7 @@

                                                                    Submodules
                                                                    -sparseml.pytorch.utils.helpers.get_linear_layers(module: torch.nn.modules.module.Module) → Dict[str, torch.nn.modules.module.Module][source]
                                                                    +sparseml.pytorch.utils.helpers.get_linear_layers(module: torch.nn.modules.module.Module)Dict[str, torch.nn.modules.module.Module][source]
                                                                    Parameters

                                                                    module – the module to grab all linear layers for

                                                                    @@ -633,7 +633,7 @@

                                                                    Submodules
                                                                    -sparseml.pytorch.utils.helpers.get_named_layers_and_params_by_regex(module: torch.nn.modules.module.Module, param_names: List[str], params_strict: bool = False) → List[sparseml.pytorch.utils.helpers.NamedLayerParam][source]
                                                                    +sparseml.pytorch.utils.helpers.get_named_layers_and_params_by_regex(module: torch.nn.modules.module.Module, param_names: List[str], params_strict: bool = False)List[sparseml.pytorch.utils.helpers.NamedLayerParam][source]
                                                                    Parameters
                                                                      @@ -653,7 +653,7 @@

                                                                      Submodules
                                                                      -sparseml.pytorch.utils.helpers.get_optim_learning_rate(optim: torch.optim.optimizer.Optimizer) → float[source]
                                                                      +sparseml.pytorch.utils.helpers.get_optim_learning_rate(optim: torch.optim.optimizer.Optimizer)float[source]
                                                                      Parameters

                                                                      optim – The optimizer to get the learning rate for

                                                                      @@ -667,7 +667,7 @@

                                                                      Submodules
                                                                      -sparseml.pytorch.utils.helpers.get_prunable_layers(module: torch.nn.modules.module.Module) → List[Tuple[str, torch.nn.modules.module.Module]][source]
                                                                      +sparseml.pytorch.utils.helpers.get_prunable_layers(module: torch.nn.modules.module.Module)List[Tuple[str, torch.nn.modules.module.Module]][source]
                                                                      Parameters

                                                                      module – the module to get the prunable layers from

                                                                      @@ -681,7 +681,7 @@

                                                                      Submodules
                                                                      -sparseml.pytorch.utils.helpers.get_terminal_layers(module: torch.nn.modules.module.Module) → Dict[str, torch.nn.modules.module.Module][source]
                                                                      +sparseml.pytorch.utils.helpers.get_terminal_layers(module: torch.nn.modules.module.Module)Dict[str, torch.nn.modules.module.Module][source]
                                                                      Parameters

                                                                      module – the module to grab all terminal layers for

                                                                      @@ -695,7 +695,7 @@

                                                                      Submodules
                                                                      -sparseml.pytorch.utils.helpers.infinite_data_loader(data_loader: torch.utils.data.dataloader.DataLoader, early_stop_steps: int = - 1, cache: bool = False)[source]
                                                                      +sparseml.pytorch.utils.helpers.infinite_data_loader(data_loader: torch.utils.data.dataloader.DataLoader, early_stop_steps: int = - 1, cache: bool = False)[source]

                                                                      A never ending data loader that will keep repeating the one passed in. Will additionally cache the data if requested.

                                                                      @@ -716,7 +716,7 @@

                                                                      Submodules
                                                                      -sparseml.pytorch.utils.helpers.mask_difference(old_mask: torch.Tensor, new_mask: torch.Tensor) → torch.Tensor[source]
                                                                      +sparseml.pytorch.utils.helpers.mask_difference(old_mask: torch.Tensor, new_mask: torch.Tensor)torch.Tensor[source]
                                                                      Parameters
                                                                        @@ -735,7 +735,7 @@

                                                                        Submodules
                                                                        -sparseml.pytorch.utils.helpers.set_deterministic_seeds(seed: int = 0)[source]
                                                                        +sparseml.pytorch.utils.helpers.set_deterministic_seeds(seed: int = 0)[source]

                                                                        Manually seeds the numpy, random, and torch packages. Also sets torch.backends.cudnn.deterministic to True :param seed: the manual seed to use. Default is 0

                                                                        @@ -743,7 +743,7 @@

                                                                        Submodules
                                                                        -sparseml.pytorch.utils.helpers.set_optim_learning_rate(optim: torch.optim.optimizer.Optimizer, value: float)[source]
                                                                        +sparseml.pytorch.utils.helpers.set_optim_learning_rate(optim: torch.optim.optimizer.Optimizer, value: float)[source]
                                                                        Parameters
                                                                          @@ -757,7 +757,7 @@

                                                                          Submodules
                                                                          -sparseml.pytorch.utils.helpers.tensor_density(tens: torch.Tensor, dim: Union[None, int, Iterable[int]] = None) → torch.Tensor[source]
                                                                          +sparseml.pytorch.utils.helpers.tensor_density(tens: torch.Tensor, dim: Union[None, int, Iterable[int]] = None)torch.Tensor[source]
                                                                          Parameters
                                                                            @@ -774,7 +774,7 @@

                                                                            Submodules
                                                                            -sparseml.pytorch.utils.helpers.tensor_export(tensor: Union[torch.Tensor, Dict[str, torch.Tensor], Iterable[torch.Tensor]], export_dir: str, name: str, npz: bool = True) → str[source]
                                                                            +sparseml.pytorch.utils.helpers.tensor_export(tensor: Union[torch.Tensor, Dict[str, torch.Tensor], Iterable[torch.Tensor]], export_dir: str, name: str, npz: bool = True)str[source]
                                                                            Parameters
                                                                              @@ -792,7 +792,7 @@

                                                                              Submodules
                                                                              -sparseml.pytorch.utils.helpers.tensor_sample(tens: torch.Tensor, sample_size: int, dim: Union[None, int, List[int], Tuple[int, ]] = None) → torch.Tensor[source]
                                                                              +sparseml.pytorch.utils.helpers.tensor_sample(tens: torch.Tensor, sample_size: int, dim: Union[None, int, List[int], Tuple[int, ]] = None)torch.Tensor[source]
                                                                              Parameters
                                                                                @@ -811,7 +811,7 @@

                                                                                Submodules
                                                                                -sparseml.pytorch.utils.helpers.tensor_sparsity(tens: torch.Tensor, dim: Union[None, int, List[int], Tuple[int, ]] = None) → torch.Tensor[source]
                                                                                +sparseml.pytorch.utils.helpers.tensor_sparsity(tens: torch.Tensor, dim: Union[None, int, List[int], Tuple[int, ]] = None)torch.Tensor[source]
                                                                                Parameters
                                                                                  @@ -828,7 +828,7 @@

                                                                                  Submodules
                                                                                  -sparseml.pytorch.utils.helpers.tensors_batch_size(tensors: Union[torch.Tensor, Iterable[torch.Tensor], Dict[Any, torch.Tensor]])[source]
                                                                                  +sparseml.pytorch.utils.helpers.tensors_batch_size(tensors: Union[torch.Tensor, Iterable[torch.Tensor], Dict[Any, torch.Tensor]])[source]

                                                                                  Default function for getting the batch size from a tensor or collection of tensors. Returns the batch size (zeroth index for shape) of the first found tensor.

                                                                                  @@ -857,7 +857,7 @@

                                                                                  Submodules
                                                                                  -sparseml.pytorch.utils.helpers.tensors_export(tensors: Union[torch.Tensor, Iterable[torch.Tensor]], export_dir: str, name_prefix: str, counter: int = 0, break_batch: bool = False) → List[str][source]
                                                                                  +sparseml.pytorch.utils.helpers.tensors_export(tensors: Union[torch.Tensor, Iterable[torch.Tensor]], export_dir: str, name_prefix: str, counter: int = 0, break_batch: bool = False)List[str][source]
                                                                                  Parameters
                                                                                    @@ -879,7 +879,7 @@

                                                                                    Submodules
                                                                                    -sparseml.pytorch.utils.helpers.tensors_module_forward(tensors: Union[torch.Tensor, Iterable[torch.Tensor], Dict[Any, torch.Tensor]], module: torch.nn.modules.module.Module, check_feat_lab_inp: bool = True) → Any[source]
                                                                                    +sparseml.pytorch.utils.helpers.tensors_module_forward(tensors: Union[torch.Tensor, Iterable[torch.Tensor], Dict[Any, torch.Tensor]], module: torch.nn.modules.module.Module, check_feat_lab_inp: bool = True)Any[source]

                                                                                    Default function for calling into a model with data for a forward execution. Returns the model result. Note, if an iterable the features to be passed into the model are considered @@ -907,7 +907,7 @@

                                                                                    Submodules
                                                                                    -sparseml.pytorch.utils.helpers.tensors_to_device(tensors: Union[torch.Tensor, Iterable[torch.Tensor], Dict[Any, torch.Tensor]], device: str) → Union[torch.Tensor, Iterable[torch.Tensor], Dict[Any, torch.Tensor]][source]
                                                                                    +sparseml.pytorch.utils.helpers.tensors_to_device(tensors: Union[torch.Tensor, Iterable[torch.Tensor], Dict[Any, torch.Tensor]], device: str)Union[torch.Tensor, Iterable[torch.Tensor], Dict[Any, torch.Tensor]][source]

                                                                                    Default function for putting a tensor or collection of tensors to the proper device. Returns the tensor references after being placed on the proper device.

                                                                                    @@ -938,7 +938,7 @@

                                                                                    Submodules
                                                                                    -sparseml.pytorch.utils.helpers.tensors_to_precision(tensors: Union[torch.Tensor, Iterable[torch.Tensor], Dict[Any, torch.Tensor]], full_precision: bool) → Union[torch.Tensor, Iterable[torch.Tensor], Dict[Any, torch.Tensor]][source]
                                                                                    +sparseml.pytorch.utils.helpers.tensors_to_precision(tensors: Union[torch.Tensor, Iterable[torch.Tensor], Dict[Any, torch.Tensor]], full_precision: bool)Union[torch.Tensor, Iterable[torch.Tensor], Dict[Any, torch.Tensor]][source]
                                                                                    Parameters
                                                                                      @@ -955,7 +955,7 @@

                                                                                      Submodules
                                                                                      -sparseml.pytorch.utils.helpers.torch_distributed_zero_first(local_rank: int)[source]
                                                                                      +sparseml.pytorch.utils.helpers.torch_distributed_zero_first(local_rank: int)[source]

                                                                                      Decorator to make all processes in distributed training wait for each local 0 ranked process to do something. :param local_rank: the local rank of this process

                                                                                      @@ -967,7 +967,7 @@

                                                                                      Submodules
                                                                                      -class sparseml.pytorch.utils.logger.PyTorchLogger(name: str)[source]
                                                                                      +class sparseml.pytorch.utils.logger.PyTorchLogger(name: str)[source]

                                                                                      Bases: abc.ABC

                                                                                      Base class that all modifier loggers must implement.

                                                                                      @@ -977,7 +977,7 @@

                                                                                      Submodules
                                                                                      -abstract log_histogram(tag: str, values: Union[torch.Tensor, numpy.ndarray], bins: str = 'tensorflow', max_bins: Union[None, int] = None, step: Union[None, int] = None, wall_time: Union[None, float] = None)[source]
                                                                                      +abstract log_histogram(tag: str, values: Union[torch.Tensor, numpy.ndarray], bins: str = 'tensorflow', max_bins: Union[None, int] = None, step: Union[None, int] = None, wall_time: Union[None, float] = None)[source]
                                                                                      Parameters
                                                                                        @@ -995,7 +995,7 @@

                                                                                        Submodules
                                                                                        -abstract log_histogram_raw(tag: str, min_val: Union[float, int], max_val: Union[float, int], num_vals: int, sum_vals: Union[float, int], sum_squares: Union[float, int], bucket_limits: Union[torch.Tensor, numpy.ndarray], bucket_counts: Union[torch.Tensor, numpy.ndarray], step: Union[None, int] = None, wall_time: Union[None, float] = None)[source]
                                                                                        +abstract log_histogram_raw(tag: str, min_val: Union[float, int], max_val: Union[float, int], num_vals: int, sum_vals: Union[float, int], sum_squares: Union[float, int], bucket_limits: Union[torch.Tensor, numpy.ndarray], bucket_counts: Union[torch.Tensor, numpy.ndarray], step: Union[None, int] = None, wall_time: Union[None, float] = None)[source]
                                                                                        Parameters
                                                                                          @@ -1016,7 +1016,7 @@

                                                                                          Submodules
                                                                                          -abstract log_hyperparams(params: Dict)[source]
                                                                                          +abstract log_hyperparams(params: Dict)[source]
                                                                                          Parameters

                                                                                          params – Each key-value pair in the dictionary is the name of the @@ -1027,7 +1027,7 @@

                                                                                          Submodules
                                                                                          -abstract log_scalar(tag: str, value: float, step: Union[None, int] = None, wall_time: Union[None, float] = None)[source]
                                                                                          +abstract log_scalar(tag: str, value: float, step: Union[None, int] = None, wall_time: Union[None, float] = None)[source]
                                                                                          Parameters
                                                                                            @@ -1042,7 +1042,7 @@

                                                                                            Submodules
                                                                                            -abstract log_scalars(tag: str, values: Dict[str, float], step: Union[None, int] = None, wall_time: Union[None, float] = None)[source]
                                                                                            +abstract log_scalars(tag: str, values: Dict[str, float], step: Union[None, int] = None, wall_time: Union[None, float] = None)[source]
                                                                                            Parameters
                                                                                              @@ -1057,7 +1057,7 @@

                                                                                              Submodules
                                                                                              -property name
                                                                                              +property name

                                                                                              name given to the logger, used for identification

                                                                                              Type
                                                                                              @@ -1070,7 +1070,7 @@

                                                                                              Submodules
                                                                                              -class sparseml.pytorch.utils.logger.PythonLogger(logger: Optional[logging.Logger] = None, name: str = 'python')[source]
                                                                                              +class sparseml.pytorch.utils.logger.PythonLogger(logger: Optional[logging.Logger] = None, name: str = 'python')[source]

                                                                                              Bases: sparseml.pytorch.utils.logger.PyTorchLogger

                                                                                              Modifier logger that handles printing values into a python logger instance.

                                                                                              @@ -1084,7 +1084,7 @@

                                                                                              Submodules
                                                                                              -log_histogram(tag: str, values: Union[torch.Tensor, numpy.ndarray], bins: str = 'tensorflow', max_bins: Union[None, int] = None, step: Union[None, int] = None, wall_time: Union[None, float] = None)[source]
                                                                                              +log_histogram(tag: str, values: Union[torch.Tensor, numpy.ndarray], bins: str = 'tensorflow', max_bins: Union[None, int] = None, step: Union[None, int] = None, wall_time: Union[None, float] = None)[source]
                                                                                              Parameters
                                                                                                @@ -1103,7 +1103,7 @@

                                                                                                Submodules
                                                                                                -log_histogram_raw(tag: str, min_val: Union[float, int], max_val: Union[float, int], num_vals: int, sum_vals: Union[float, int], sum_squares: Union[float, int], bucket_limits: Union[torch.Tensor, numpy.ndarray], bucket_counts: Union[torch.Tensor, numpy.ndarray], step: Union[None, int] = None, wall_time: Union[None, float] = None)[source]
                                                                                                +log_histogram_raw(tag: str, min_val: Union[float, int], max_val: Union[float, int], num_vals: int, sum_vals: Union[float, int], sum_squares: Union[float, int], bucket_limits: Union[torch.Tensor, numpy.ndarray], bucket_counts: Union[torch.Tensor, numpy.ndarray], step: Union[None, int] = None, wall_time: Union[None, float] = None)[source]
                                                                                                Parameters
                                                                                                  @@ -1125,7 +1125,7 @@

                                                                                                  Submodules
                                                                                                  -log_hyperparams(params: Dict)[source]
                                                                                                  +log_hyperparams(params: Dict)[source]
                                                                                                  Parameters

                                                                                                  params – Each key-value pair in the dictionary is the name of the @@ -1136,7 +1136,7 @@

                                                                                                  Submodules
                                                                                                  -log_scalar(tag: str, value: float, step: Union[None, int] = None, wall_time: Union[None, float] = None)[source]
                                                                                                  +log_scalar(tag: str, value: float, step: Union[None, int] = None, wall_time: Union[None, float] = None)[source]
                                                                                                  Parameters
                                                                                                    @@ -1152,7 +1152,7 @@

                                                                                                    Submodules
                                                                                                    -log_scalars(tag: str, values: Dict[str, float], step: Union[None, int] = None, wall_time: Union[None, float] = None)[source]
                                                                                                    +log_scalars(tag: str, values: Dict[str, float], step: Union[None, int] = None, wall_time: Union[None, float] = None)[source]
                                                                                                    Parameters
                                                                                                      @@ -1170,7 +1170,7 @@

                                                                                                      Submodules
                                                                                                      -class sparseml.pytorch.utils.logger.TensorBoardLogger(log_path: Optional[str] = None, writer: Optional[torch.utils.tensorboard.writer.SummaryWriter] = None, name: str = 'tensorboard')[source]
                                                                                                      +class sparseml.pytorch.utils.logger.TensorBoardLogger(log_path: Optional[str] = None, writer: Optional[torch.utils.tensorboard.writer.SummaryWriter] = None, name: str = 'tensorboard')[source]

                                                                                                      Bases: sparseml.pytorch.utils.logger.PyTorchLogger

                                                                                                      Modifier logger that handles outputting values into a TensorBoard log directory for viewing in TensorBoard.

                                                                                                      @@ -1189,7 +1189,7 @@

                                                                                                      Submodules
                                                                                                      -log_histogram(tag: str, values: Union[torch.Tensor, numpy.ndarray], bins: str = 'tensorflow', max_bins: Union[None, int] = None, step: Union[None, int] = None, wall_time: Union[None, float] = None)[source]
                                                                                                      +log_histogram(tag: str, values: Union[torch.Tensor, numpy.ndarray], bins: str = 'tensorflow', max_bins: Union[None, int] = None, step: Union[None, int] = None, wall_time: Union[None, float] = None)[source]
                                                                                                      Parameters
                                                                                                        @@ -1208,7 +1208,7 @@

                                                                                                        Submodules
                                                                                                        -log_histogram_raw(tag: str, min_val: Union[float, int], max_val: Union[float, int], num_vals: int, sum_vals: Union[float, int], sum_squares: Union[float, int], bucket_limits: Union[torch.Tensor, numpy.ndarray], bucket_counts: Union[torch.Tensor, numpy.ndarray], step: Union[None, int] = None, wall_time: Union[None, float] = None)[source]
                                                                                                        +log_histogram_raw(tag: str, min_val: Union[float, int], max_val: Union[float, int], num_vals: int, sum_vals: Union[float, int], sum_squares: Union[float, int], bucket_limits: Union[torch.Tensor, numpy.ndarray], bucket_counts: Union[torch.Tensor, numpy.ndarray], step: Union[None, int] = None, wall_time: Union[None, float] = None)[source]
                                                                                                        Parameters
                                                                                                          @@ -1230,7 +1230,7 @@

                                                                                                          Submodules
                                                                                                          -log_hyperparams(params: Dict)[source]
                                                                                                          +log_hyperparams(params: Dict)[source]
                                                                                                          Parameters

                                                                                                          params – Each key-value pair in the dictionary is the name of the @@ -1241,7 +1241,7 @@

                                                                                                          Submodules
                                                                                                          -log_scalar(tag: str, value: float, step: Union[None, int] = None, wall_time: Union[None, float] = None)[source]
                                                                                                          +log_scalar(tag: str, value: float, step: Union[None, int] = None, wall_time: Union[None, float] = None)[source]
                                                                                                          Parameters
                                                                                                            @@ -1257,7 +1257,7 @@

                                                                                                            Submodules
                                                                                                            -log_scalars(tag: str, values: Dict[str, float], step: Union[None, int] = None, wall_time: Union[None, float] = None)[source]
                                                                                                            +log_scalars(tag: str, values: Dict[str, float], step: Union[None, int] = None, wall_time: Union[None, float] = None)[source]
                                                                                                            Parameters
                                                                                                              @@ -1281,7 +1281,7 @@

                                                                                                              Submodules
                                                                                                              -class sparseml.pytorch.utils.loss.Accuracy[source]
                                                                                                              +class sparseml.pytorch.utils.loss.Accuracy[source]

                                                                                                              Bases: torch.nn.modules.module.Module

                                                                                                              Class for calculating the accuracy for a given prediction and the labels for comparison. @@ -1289,7 +1289,7 @@

                                                                                                              Submodules
                                                                                                              -static calculate(pred: torch.Tensor, lab: torch.Tensor)[source]
                                                                                                              +static calculate(pred: torch.Tensor, lab: torch.Tensor)[source]
                                                                                                              Parameters
                                                                                                              -class sparseml.pytorch.utils.loss.BinaryCrossEntropyLossWrapper(extras: Union[None, Dict] = None)[source]
                                                                                                              +class sparseml.pytorch.utils.loss.BinaryCrossEntropyLossWrapper(extras: Union[None, Dict] = None)[source]

                                                                                                              Bases: sparseml.pytorch.utils.loss.LossWrapper

                                                                                                              Convenience class for doing binary cross entropy loss calculations, ie the default loss function is TF.binary_cross_entropy_with_logits.

                                                                                                              @@ -1342,7 +1342,7 @@

                                                                                                              Submodules
                                                                                                              -class sparseml.pytorch.utils.loss.CrossEntropyLossWrapper(extras: Union[None, Dict] = None)[source]
                                                                                                              +class sparseml.pytorch.utils.loss.CrossEntropyLossWrapper(extras: Union[None, Dict] = None)[source]

                                                                                                              Bases: sparseml.pytorch.utils.loss.LossWrapper

                                                                                                              Convenience class for doing cross entropy loss calculations, ie the default loss function is TF.cross_entropy.

                                                                                                              @@ -1356,7 +1356,7 @@

                                                                                                              Submodules
                                                                                                              -class sparseml.pytorch.utils.loss.InceptionCrossEntropyLossWrapper(extras: Union[None, Dict] = None, aux_weight: float = 0.4)[source]
                                                                                                              +class sparseml.pytorch.utils.loss.InceptionCrossEntropyLossWrapper(extras: Union[None, Dict] = None, aux_weight: float = 0.4)[source]

                                                                                                              Bases: sparseml.pytorch.utils.loss.LossWrapper

                                                                                                              Loss wrapper for training an inception model that as an aux output with cross entropy.

                                                                                                              @@ -1375,7 +1375,7 @@

                                                                                                              Submodules
                                                                                                              -get_preds(data: Any, pred: Tuple[torch.Tensor, torch.Tensor, torch.Tensor], name: str) → Union[torch.Tensor, Tuple[torch.Tensor, torch.Tensor]][source]
                                                                                                              +get_preds(data: Any, pred: Tuple[torch.Tensor, torch.Tensor, torch.Tensor], name: str)Union[torch.Tensor, Tuple[torch.Tensor, torch.Tensor]][source]

                                                                                                              Override get_preds for the inception training output. Specifically expects the pred from the model to be a three tensor tuple: (aux logits, logits, classes)

                                                                                                              @@ -1401,7 +1401,7 @@

                                                                                                              Submodules
                                                                                                              -loss(preds: Tuple[torch.Tensor, torch.Tensor], labels: torch.Tensor)[source]
                                                                                                              +loss(preds: Tuple[torch.Tensor, torch.Tensor], labels: torch.Tensor)[source]

                                                                                                              Loss function for inception to combine the overall outputs from the model along with the the auxiliary loss from an earlier point in the model

                                                                                                              @@ -1421,7 +1421,7 @@

                                                                                                              Submodules
                                                                                                              -class sparseml.pytorch.utils.loss.KDLossWrapper(loss_fn: Callable[[Any, Any], torch.Tensor], extras: Union[None, Dict[str, Callable]] = None, deconstruct_tensors: bool = True, kd_settings: Union[None, sparseml.pytorch.utils.loss.KDSettings] = None)[source]
                                                                                                              +class sparseml.pytorch.utils.loss.KDLossWrapper(loss_fn: Callable[[Any, Any], torch.Tensor], extras: Union[None, Dict[str, Callable]] = None, deconstruct_tensors: bool = True, kd_settings: Union[None, sparseml.pytorch.utils.loss.KDSettings] = None)[source]

                                                                                                              Bases: sparseml.pytorch.utils.loss.LossWrapper

                                                                                                              Special case of the loss wrapper that allows knowledge distillation. Makes some assumptions specifically for image classification tasks, @@ -1442,7 +1442,7 @@

                                                                                                              Submodules
                                                                                                              -forward(data: Any, pred: Any) → Dict[str, torch.Tensor][source]
                                                                                                              +forward(data: Any, pred: Any)Dict[str, torch.Tensor][source]

                                                                                                              override to calculate the knowledge distillation loss if kd_settings is supplied and not None

                                                                                                              @@ -1461,7 +1461,7 @@

                                                                                                              Submodules
                                                                                                              -get_inputs(data: Any, pred: Any, name: str) → Any[source]
                                                                                                              +get_inputs(data: Any, pred: Any, name: str)Any[source]

                                                                                                              overridable function that is responsible for extracting the inputs to the model from the input data to the model and the output from the model

                                                                                                              @@ -1484,7 +1484,7 @@

                                                                                                              Submodules
                                                                                                              -class sparseml.pytorch.utils.loss.KDSettings(teacher: torch.nn.modules.module.Module, temp_student: float = 5.0, temp_teacher: float = 5.0, weight: float = 0.5, contradict_hinton: bool = False)[source]
                                                                                                              +class sparseml.pytorch.utils.loss.KDSettings(teacher: torch.nn.modules.module.Module, temp_student: float = 5.0, temp_teacher: float = 5.0, weight: float = 0.5, contradict_hinton: bool = False)[source]

                                                                                                              Bases: object

                                                                                                              properties class for settings for applying knowledge distillation as part of the loss calculation.

                                                                                                              @@ -1504,7 +1504,7 @@

                                                                                                              Submodules
                                                                                                              -property contradict_hinton
                                                                                                              +property contradict_hinton

                                                                                                              in hinton’s original paper they included T^2 as a scaling factor some implementations dropped this factor so contradicting hinton does not scale by T^2

                                                                                                              @@ -1517,7 +1517,7 @@

                                                                                                              Submodules
                                                                                                              -property teacher
                                                                                                              +property teacher

                                                                                                              the teacher that provides targets for the student to learn from

                                                                                                              Type
                                                                                                              @@ -1528,7 +1528,7 @@

                                                                                                              Submodules
                                                                                                              -property temp_student
                                                                                                              +property temp_student

                                                                                                              temperature coefficient for the student

                                                                                                              Type
                                                                                                              @@ -1539,7 +1539,7 @@

                                                                                                              Submodules
                                                                                                              -property temp_teacher
                                                                                                              +property temp_teacher

                                                                                                              temperature coefficient for the teacher

                                                                                                              Type
                                                                                                              @@ -1550,7 +1550,7 @@

                                                                                                              Submodules
                                                                                                              -property weight
                                                                                                              +property weight

                                                                                                              the weight for how much of the kd loss to use in proportion with the original loss

                                                                                                              @@ -1564,7 +1564,7 @@

                                                                                                              Submodules
                                                                                                              -class sparseml.pytorch.utils.loss.LossWrapper(loss_fn: Callable[[Any, Any], torch.Tensor], extras: Union[None, Dict[str, Callable]] = None, deconstruct_tensors: bool = True)[source]
                                                                                                              +class sparseml.pytorch.utils.loss.LossWrapper(loss_fn: Callable[[Any, Any], torch.Tensor], extras: Union[None, Dict[str, Callable]] = None, deconstruct_tensors: bool = True)[source]

                                                                                                              Bases: object

                                                                                                              Generic loss class for controlling how to feed inputs and compare with predictions for standard loss functions and metrics.

                                                                                                              @@ -1582,7 +1582,7 @@

                                                                                                              Submodules
                                                                                                              -property available_losses
                                                                                                              +property available_losses

                                                                                                              a collection of all the loss and metrics keys available for this instance

                                                                                                              @@ -1594,7 +1594,7 @@

                                                                                                              Submodules
                                                                                                              -forward(data: Any, pred: Any) → Dict[str, torch.Tensor][source]
                                                                                                              +forward(data: Any, pred: Any)Dict[str, torch.Tensor][source]
                                                                                                              Parameters
                                                                                                                @@ -1611,7 +1611,7 @@

                                                                                                                Submodules
                                                                                                                -get_labels(data: Any, pred: Any, name: str) → Any[source]
                                                                                                                +get_labels(data: Any, pred: Any, name: str)Any[source]

                                                                                                                overridable function that is responsible for extracting the labels for the loss calculation from the input data to the model

                                                                                                                @@ -1632,7 +1632,7 @@

                                                                                                                Submodules
                                                                                                                -get_preds(data: Any, pred: Any, name: str) → Any[source]
                                                                                                                +get_preds(data: Any, pred: Any, name: str)Any[source]

                                                                                                                overridable function that is responsible for extracting the predictions from a model’s output

                                                                                                                @@ -1655,7 +1655,7 @@

                                                                                                                Submodules
                                                                                                                -class sparseml.pytorch.utils.loss.SSDLossWrapper(extras: Union[None, Dict] = None)[source]
                                                                                                                +class sparseml.pytorch.utils.loss.SSDLossWrapper(extras: Union[None, Dict] = None)[source]

                                                                                                                Bases: sparseml.pytorch.utils.loss.LossWrapper

                                                                                                                Loss wrapper for SSD models. Implements the loss as the sum of:

                                                                                                                  @@ -1670,7 +1670,7 @@

                                                                                                                  Submodules
                                                                                                                  -get_preds(data: Any, pred: Tuple[torch.Tensor, torch.Tensor], name: str) → Tuple[torch.Tensor, torch.Tensor][source]
                                                                                                                  +get_preds(data: Any, pred: Tuple[torch.Tensor, torch.Tensor], name: str)Tuple[torch.Tensor, torch.Tensor][source]

                                                                                                                  Override get_preds for SSD model output.

                                                                                                                  Parameters
                                                                                                                  @@ -1690,7 +1690,7 @@

                                                                                                                  Submodules
                                                                                                                  -loss(preds: Tuple[torch.Tensor, torch.Tensor], labels: Tuple[torch.Tensor, torch.Tensor, torch.Tensor])[source]
                                                                                                                  +loss(preds: Tuple[torch.Tensor, torch.Tensor], labels: Tuple[torch.Tensor, torch.Tensor, torch.Tensor])[source]

                                                                                                                  Calculates the loss for a multibox SSD output as the sum of the confidence and localization loss for the positive samples in the predictor with hard negative mining.

                                                                                                                  @@ -1712,7 +1712,7 @@

                                                                                                                  Submodules
                                                                                                                  -class sparseml.pytorch.utils.loss.TopKAccuracy(topk: int = 1)[source]
                                                                                                                  +class sparseml.pytorch.utils.loss.TopKAccuracy(topk: int = 1)[source]

                                                                                                                  Bases: torch.nn.modules.module.Module

                                                                                                                  Class for calculating the top k accuracy for a given prediction and the labels for comparison; ie the top1 or top5 accuracy. top1 is equivalent to the Accuracy class

                                                                                                                  @@ -1723,7 +1723,7 @@

                                                                                                                  Submodules
                                                                                                                  -static calculate(pred: torch.Tensor, lab: torch.Tensor, topk: int)[source]
                                                                                                                  +static calculate(pred: torch.Tensor, lab: torch.Tensor, topk: int)[source]
                                                                                                                  Parameters
                                                                                                                  -class sparseml.pytorch.utils.loss.YoloLossWrapper(extras: Union[None, Dict] = None, anchor_groups: Optional[List[torch.Tensor]] = None)[source]
                                                                                                                  +class sparseml.pytorch.utils.loss.YoloLossWrapper(extras: Union[None, Dict] = None, anchor_groups: Optional[List[torch.Tensor]] = None)[source]

                                                                                                                  Bases: sparseml.pytorch.utils.loss.LossWrapper

                                                                                                                  Loss wrapper for Yolo models. Implements the loss as a sum of class loss, objectness loss, and GIoU

                                                                                                                  @@ -1779,7 +1779,7 @@

                                                                                                                  Submodules
                                                                                                                  -forward(data: Any, pred: Any) → Dict[str, torch.Tensor][source]
                                                                                                                  +forward(data: Any, pred: Any)Dict[str, torch.Tensor][source]
                                                                                                                  Parameters
                                                                                                                    @@ -1797,7 +1797,7 @@

                                                                                                                    Submodules
                                                                                                                    -get_preds(data: Any, pred: List[torch.Tensor], name: str) → List[torch.Tensor][source]
                                                                                                                    +get_preds(data: Any, pred: List[torch.Tensor], name: str)List[torch.Tensor][source]

                                                                                                                    Override get_preds for SSD model output.

                                                                                                                    Parameters
                                                                                                                    @@ -1817,7 +1817,7 @@

                                                                                                                    Submodules
                                                                                                                    -loss(preds: List[torch.Tensor], labels: Tuple[torch.Tensor, torch.Tensor])[source]
                                                                                                                    +loss(preds: List[torch.Tensor], labels: Tuple[torch.Tensor, torch.Tensor])[source]

                                                                                                                    Calculates the loss for a Yolo model output as the sum of the box, object, and class losses

                                                                                                                    @@ -1842,7 +1842,7 @@

                                                                                                                    Submodules
                                                                                                                    -sparseml.pytorch.utils.model.device_to_name_ids(device: str) → Tuple[str, Union[None, List[int]]][source]
                                                                                                                    +sparseml.pytorch.utils.model.device_to_name_ids(device: str)Tuple[str, Union[None, List[int]]][source]

                                                                                                                    Split a device string into a device and ids

                                                                                                                    Parameters
                                                                                                                    @@ -1856,7 +1856,7 @@

                                                                                                                    Submodules
                                                                                                                    -sparseml.pytorch.utils.model.is_parallel_model(model: torch.nn.modules.module.Module) → bool[source]
                                                                                                                    +sparseml.pytorch.utils.model.is_parallel_model(model: torch.nn.modules.module.Module)bool[source]
                                                                                                                    Parameters

                                                                                                                    model – the model to test

                                                                                                                    @@ -1870,12 +1870,12 @@

                                                                                                                    Submodules
                                                                                                                    -sparseml.pytorch.utils.model.load_epoch(path: str, map_location: Union[None, str] = 'cpu') → Optional[int][source]
                                                                                                                    +sparseml.pytorch.utils.model.load_epoch(path: str, map_location: Union[None, str] = 'cpu')Optional[int][source]

                                                                                                                    -sparseml.pytorch.utils.model.load_model(path: str, model: torch.nn.modules.module.Module, strict: bool = False, ignore_error_tensors: Optional[List[str]] = None, fix_data_parallel: bool = True)[source]
                                                                                                                    +sparseml.pytorch.utils.model.load_model(path: str, model: torch.nn.modules.module.Module, strict: bool = False, ignore_error_tensors: Optional[List[str]] = None, fix_data_parallel: bool = True)[source]

                                                                                                                    Load the state dict into a model from a given file.

                                                                                                                    Parameters
                                                                                                                    @@ -1899,7 +1899,7 @@

                                                                                                                    Submodules
                                                                                                                    -sparseml.pytorch.utils.model.load_optimizer(path: str, optimizer: torch.optim.optimizer.Optimizer, map_location: Union[None, str] = 'cpu')[source]
                                                                                                                    +sparseml.pytorch.utils.model.load_optimizer(path: str, optimizer: torch.optim.optimizer.Optimizer, map_location: Union[None, str] = 'cpu')[source]

                                                                                                                    Load the state dict into an optimizer from a given file.

                                                                                                                    Parameters
                                                                                                                    @@ -1917,7 +1917,7 @@

                                                                                                                    Submodules
                                                                                                                    -sparseml.pytorch.utils.model.model_to_device(model: torch.nn.modules.module.Module, device: Union[str, int], ddp: bool = False) → Tuple[torch.nn.modules.module.Module, str, Union[None, List[int]]][source]
                                                                                                                    +sparseml.pytorch.utils.model.model_to_device(model: torch.nn.modules.module.Module, device: Union[str, int], ddp: bool = False)Tuple[torch.nn.modules.module.Module, str, Union[None, List[int]]][source]

                                                                                                                    The model to push onto a device or multiple devices.

                                                                                                                    Parameters
                                                                                                                    @@ -1938,7 +1938,7 @@

                                                                                                                    Submodules
                                                                                                                    -sparseml.pytorch.utils.model.parallelize_model(model: torch.nn.modules.module.Module, ids: Union[None, List[int]]) → torch.nn.modules.module.Module[source]
                                                                                                                    +sparseml.pytorch.utils.model.parallelize_model(model: torch.nn.modules.module.Module, ids: Union[None, List[int]])torch.nn.modules.module.Module[source]

                                                                                                                    Data parallelize a model across multiple devices

                                                                                                                    Parameters
                                                                                                                    @@ -1955,7 +1955,7 @@

                                                                                                                    Submodules
                                                                                                                    -sparseml.pytorch.utils.model.save_model(path: str, model: torch.nn.modules.module.Module, optimizer: Optional[torch.optim.optimizer.Optimizer] = None, epoch: Union[None, int] = None, use_zipfile_serialization_if_available: bool = True, include_modifiers: bool = False)[source]
                                                                                                                    +sparseml.pytorch.utils.model.save_model(path: str, model: torch.nn.modules.module.Module, optimizer: Optional[torch.optim.optimizer.Optimizer] = None, epoch: Union[None, int] = None, use_zipfile_serialization_if_available: bool = True, include_modifiers: bool = False)[source]

                                                                                                                    Save a model’s state dict into a file at the given path. Additionally can save an optimizer’s state and the current epoch.

                                                                                                                    @@ -1982,7 +1982,7 @@

                                                                                                                    Submodules
                                                                                                                    -class sparseml.pytorch.utils.module.ModuleDeviceContext(use_mixed_precision: bool = False, world_size: int = 1)[source]
                                                                                                                    +class sparseml.pytorch.utils.module.ModuleDeviceContext(use_mixed_precision: bool = False, world_size: int = 1)[source]

                                                                                                                    Bases: object

                                                                                                                    Simple class to define device settings or context to be used when running a Module

                                                                                                                    @@ -1998,7 +1998,7 @@

                                                                                                                    Submodules
                                                                                                                    -static default_context()[source]
                                                                                                                    +static default_context()[source]
                                                                                                                    Returns

                                                                                                                    A ModuleDeviceContext with default settings enabled

                                                                                                                    @@ -2008,7 +2008,7 @@

                                                                                                                    Submodules
                                                                                                                    -property use_mixed_precision
                                                                                                                    +property use_mixed_precision

                                                                                                                    True if mixed precision with torch.cuda.amp should be used. False otherwise

                                                                                                                    @@ -2020,7 +2020,7 @@

                                                                                                                    Submodules
                                                                                                                    -property world_size
                                                                                                                    +property world_size

                                                                                                                    the world size (total number of devices) used when running the given module using DistributedDataParallel. Losses will be scaled by the world size

                                                                                                                    @@ -2035,7 +2035,7 @@

                                                                                                                    Submodules
                                                                                                                    -class sparseml.pytorch.utils.module.ModuleRunFuncs[source]
                                                                                                                    +class sparseml.pytorch.utils.module.ModuleRunFuncs[source]

                                                                                                                    Bases: object

                                                                                                                    Functions used as callables to calculate or perform necessary operations for running a model through training or testing.

                                                                                                                    @@ -2057,7 +2057,7 @@

                                                                                                                    Submodules
                                                                                                                    -property batch_size
                                                                                                                    +property batch_size

                                                                                                                    return used to calculate the batch size of a given grouping of tensors. Expected to be called with the output from a data loader and then return an int representing the batch size.

                                                                                                                    @@ -2065,7 +2065,7 @@

                                                                                                                    Submodules
                                                                                                                    -copy(run_funcs)[source]
                                                                                                                    +copy(run_funcs)[source]

                                                                                                                    Copy the functions from the current instance into a new instance

                                                                                                                    Parameters
                                                                                                                    @@ -2076,7 +2076,7 @@

                                                                                                                    Submodules
                                                                                                                    -property model_backward
                                                                                                                    +property model_backward

                                                                                                                    return used to call backward for a given model and the calculated losses. Expected to be called with the model and the output from the loss function as a dict mapping of names to tensors returns nothing

                                                                                                                    @@ -2084,7 +2084,7 @@

                                                                                                                    Submodules
                                                                                                                    -property model_forward
                                                                                                                    +property model_forward

                                                                                                                    return used to propagate a given grouping of tensors through a model and return the result. Expected to be called with the model and the output from a data loader @@ -2093,7 +2093,7 @@

                                                                                                                    Submodules
                                                                                                                    -property to_device
                                                                                                                    +property to_device

                                                                                                                    return used to place a given grouping of tensors onto the proper device. Expected to be called with the output from a data loader and the desired device as a string then return the grouping on the proper device.

                                                                                                                    @@ -2103,7 +2103,7 @@

                                                                                                                    Submodules
                                                                                                                    -class sparseml.pytorch.utils.module.ModuleRunHooks[source]
                                                                                                                    +class sparseml.pytorch.utils.module.ModuleRunHooks[source]

                                                                                                                    Bases: object

                                                                                                                    Container for hooks that can be added to module runs like training and testing for different stages of running a batch through a model.

                                                                                                                    @@ -2125,32 +2125,32 @@

                                                                                                                    Submodules
                                                                                                                    -invoke_batch_backward(counter: int, step_count: int, batch_size: int, data: Any, pred: Any, losses: Dict[str, torch.Tensor])[source]
                                                                                                                    +invoke_batch_backward(counter: int, step_count: int, batch_size: int, data: Any, pred: Any, losses: Dict[str, torch.Tensor])[source]

                                                                                                                    -invoke_batch_end(counter: int, step_count: int, batch_size: int, data: Any, pred: Any, losses: Dict[str, torch.Tensor])[source]
                                                                                                                    +invoke_batch_end(counter: int, step_count: int, batch_size: int, data: Any, pred: Any, losses: Dict[str, torch.Tensor])[source]
                                                                                                                    -invoke_batch_forward(counter: int, step_count: int, batch_size: int, data: Any, pred: Any)[source]
                                                                                                                    +invoke_batch_forward(counter: int, step_count: int, batch_size: int, data: Any, pred: Any)[source]
                                                                                                                    -invoke_batch_loss(counter: int, step_count: int, batch_size: int, data: Any, pred: Any, losses: Dict[str, torch.Tensor])[source]
                                                                                                                    +invoke_batch_loss(counter: int, step_count: int, batch_size: int, data: Any, pred: Any, losses: Dict[str, torch.Tensor])[source]
                                                                                                                    -invoke_batch_start(counter: int, step_count: int, batch_size: int, data: Any)[source]
                                                                                                                    +invoke_batch_start(counter: int, step_count: int, batch_size: int, data: Any)[source]
                                                                                                                    -register_batch_backward_hook(hook: Callable[[int, int, int, Any, Any, Dict[str, torch.Tensor]], None])[source]
                                                                                                                    +register_batch_backward_hook(hook: Callable[[int, int, int, Any, Any, Dict[str, torch.Tensor]], None])[source]

                                                                                                                    Called after calling backward on the loss for the batch with the following info: (counter, step_count, batch_size, data, pred, losses) where counter is passed in to the run (ex: epoch), @@ -2172,7 +2172,7 @@

                                                                                                                    Submodules
                                                                                                                    -register_batch_end_hook(hook: Callable[[int, int, int, Any, Any, Dict[str, torch.Tensor]], None])[source]
                                                                                                                    +register_batch_end_hook(hook: Callable[[int, int, int, Any, Any, Dict[str, torch.Tensor]], None])[source]

                                                                                                                    Called after all calculations are done for the batch with the following info: (counter, step_count, batch_size, data, pred, losses) where counter is passed in to the run (ex: epoch), @@ -2194,7 +2194,7 @@

                                                                                                                    Submodules
                                                                                                                    -register_batch_forward_hook(hook: Callable[[int, int, int, Any, Any], None]) → torch.utils.hooks.RemovableHandle[source]
                                                                                                                    +register_batch_forward_hook(hook: Callable[[int, int, int, Any, Any], None])torch.utils.hooks.RemovableHandle[source]

                                                                                                                    Called after forward execution of a batch in the model with the following info: (counter, step_count, batch_size, data, pred) where counter is passed in to the run (ex: epoch), @@ -2215,7 +2215,7 @@

                                                                                                                    Submodules
                                                                                                                    -register_batch_loss_hook(hook: Callable[[int, int, int, Any, Any, Dict[str, torch.Tensor]], None])[source]
                                                                                                                    +register_batch_loss_hook(hook: Callable[[int, int, int, Any, Any, Dict[str, torch.Tensor]], None])[source]

                                                                                                                    Called after loss calculation of the batch with the following info: (counter, step_count, batch_size, data, pred, losses) where counter is passed in to the run (ex: epoch), @@ -2237,7 +2237,7 @@

                                                                                                                    Submodules
                                                                                                                    -register_batch_start_hook(hook: Callable[[int, int, int, Any], None]) → torch.utils.hooks.RemovableHandle[source]
                                                                                                                    +register_batch_start_hook(hook: Callable[[int, int, int, Any], None])torch.utils.hooks.RemovableHandle[source]

                                                                                                                    Called at the start of a batch with the following info: (counter, step_count, batch_size, data) where counter is passed in to the run (ex: epoch), @@ -2259,13 +2259,13 @@

                                                                                                                    Submodules
                                                                                                                    -class sparseml.pytorch.utils.module.ModuleRunResults[source]
                                                                                                                    +class sparseml.pytorch.utils.module.ModuleRunResults[source]

                                                                                                                    Bases: object

                                                                                                                    Class containing the results / losses from a model run for training or testing Keeps all result values as a dictionary and Tensor containing all values

                                                                                                                    -append(losses: Dict[str, torch.Tensor], batch_size: int)[source]
                                                                                                                    +append(losses: Dict[str, torch.Tensor], batch_size: int)[source]

                                                                                                                    add new losses to the current stored results

                                                                                                                    Parameters
                                                                                                                    @@ -2279,7 +2279,7 @@

                                                                                                                    Submodules
                                                                                                                    -result(key: str) → List[torch.Tensor][source]
                                                                                                                    +result(key: str)List[torch.Tensor][source]

                                                                                                                    The result of a single loss function

                                                                                                                    Parameters
                                                                                                                    @@ -2293,7 +2293,7 @@

                                                                                                                    Submodules
                                                                                                                    -result_list_tensor(key: str) → torch.Tensor[source]
                                                                                                                    +result_list_tensor(key: str)torch.Tensor[source]

                                                                                                                    Get the results as a list tensor where all items have been stacked into the first index of the tensor.

                                                                                                                    @@ -2308,7 +2308,7 @@

                                                                                                                    Submodules
                                                                                                                    -result_mean(key: str) → torch.Tensor[source]
                                                                                                                    +result_mean(key: str)torch.Tensor[source]

                                                                                                                    The mean result of a single loss function

                                                                                                                    Parameters
                                                                                                                    @@ -2322,7 +2322,7 @@

                                                                                                                    Submodules
                                                                                                                    -result_std(key: str) → torch.Tensor[source]
                                                                                                                    +result_std(key: str)torch.Tensor[source]

                                                                                                                    The standard deviation of the result for a single loss function

                                                                                                                    Parameters
                                                                                                                    @@ -2338,7 +2338,7 @@

                                                                                                                    Submodules
                                                                                                                    -property results
                                                                                                                    +property results

                                                                                                                    All of the stored results for the loss functions

                                                                                                                    Returns
                                                                                                                    @@ -2352,7 +2352,7 @@

                                                                                                                    Submodules
                                                                                                                    -class sparseml.pytorch.utils.module.ModuleTester(module: torch.nn.modules.module.Module, device: str, loss: Union[sparseml.pytorch.utils.loss.LossWrapper, Callable[[Any, Any], torch.Tensor]], loggers: Optional[List[sparseml.pytorch.utils.logger.PyTorchLogger]] = None, log_name: str = 'Test', log_steps: int = 100, log_summary: bool = True, device_context: sparseml.pytorch.utils.module.ModuleDeviceContext = <sparseml.pytorch.utils.module.ModuleDeviceContext object>)[source]
                                                                                                                    +class sparseml.pytorch.utils.module.ModuleTester(module: torch.nn.modules.module.Module, device: str, loss: Union[sparseml.pytorch.utils.loss.LossWrapper, Callable[[Any, Any], torch.Tensor]], loggers: Optional[List[sparseml.pytorch.utils.logger.PyTorchLogger]] = None, log_name: str = 'Test', log_steps: int = 100, log_summary: bool = True, device_context: sparseml.pytorch.utils.module.ModuleDeviceContext = <sparseml.pytorch.utils.module.ModuleDeviceContext object>)[source]

                                                                                                                    Bases: sparseml.pytorch.utils.module.ModuleRunner

                                                                                                                    Container for running a module through evaluation over a given data loader for specific settings.

                                                                                                                    @@ -2393,7 +2393,7 @@

                                                                                                                    Submodules
                                                                                                                    -class sparseml.pytorch.utils.module.ModuleTrainer(module: torch.nn.modules.module.Module, device: str, loss: Union[sparseml.pytorch.utils.loss.LossWrapper, Callable[[Any, Any], torch.Tensor]], optimizer: torch.optim.optimizer.Optimizer, num_accumulated_batches: int = 1, optim_closure: Union[None, Callable] = None, loggers: Optional[List[sparseml.pytorch.utils.logger.PyTorchLogger]] = None, log_name: str = 'Train', log_steps: int = 100, log_summary: bool = True, device_context: sparseml.pytorch.utils.module.ModuleDeviceContext = <sparseml.pytorch.utils.module.ModuleDeviceContext object>)[source]
                                                                                                                    +class sparseml.pytorch.utils.module.ModuleTrainer(module: torch.nn.modules.module.Module, device: str, loss: Union[sparseml.pytorch.utils.loss.LossWrapper, Callable[[Any, Any], torch.Tensor]], optimizer: torch.optim.optimizer.Optimizer, num_accumulated_batches: int = 1, optim_closure: Union[None, Callable] = None, loggers: Optional[List[sparseml.pytorch.utils.logger.PyTorchLogger]] = None, log_name: str = 'Train', log_steps: int = 100, log_summary: bool = True, device_context: sparseml.pytorch.utils.module.ModuleDeviceContext = <sparseml.pytorch.utils.module.ModuleDeviceContext object>)[source]

                                                                                                                    Bases: sparseml.pytorch.utils.module.ModuleRunner

                                                                                                                    Container for running a module through training over a given data loader for specific settings.

                                                                                                                    @@ -2438,7 +2438,7 @@

                                                                                                                    Submodules
                                                                                                                    -property num_accumulated_batches
                                                                                                                    +property num_accumulated_batches

                                                                                                                    number of batches to accumulate before updating the optimizer

                                                                                                                    Type
                                                                                                                    @@ -2449,7 +2449,7 @@

                                                                                                                    Submodules
                                                                                                                    -property optim_closure
                                                                                                                    +property optim_closure

                                                                                                                    a closure passed into the optimizer on step

                                                                                                                    Type
                                                                                                                    @@ -2460,7 +2460,7 @@

                                                                                                                    Submodules
                                                                                                                    -property optimizer
                                                                                                                    +property optimizer

                                                                                                                    the optimizer used to apply gradient updates with

                                                                                                                    Type
                                                                                                                    @@ -2473,7 +2473,7 @@

                                                                                                                    Submodules
                                                                                                                    -sparseml.pytorch.utils.module.def_model_backward(losses: Dict[str, torch.Tensor], model: torch.nn.modules.module.Module, scaler: Optional[torch.cuda.amp.grad_scaler.GradScaler] = None)[source]
                                                                                                                    +sparseml.pytorch.utils.module.def_model_backward(losses: Dict[str, torch.Tensor], model: torch.nn.modules.module.Module, scaler: Optional[torch.cuda.amp.grad_scaler.GradScaler] = None)[source]

                                                                                                                    Default function to perform a backwards pass for a model and the calculated losses Calls backwards for the DEFAULT_LOSS_KEY in losses Dict

                                                                                                                    @@ -2495,7 +2495,7 @@

                                                                                                                    Submodules
                                                                                                                    -class sparseml.pytorch.utils.ssd_helpers.DefaultBoxes(image_size: int, feature_maps: List[int], steps: List[int], scales: List[int], aspect_ratios: List[List[int]], scale_xy: float = 0.1, scale_wh: float = 0.2)[source]
                                                                                                                    +class sparseml.pytorch.utils.ssd_helpers.DefaultBoxes(image_size: int, feature_maps: List[int], steps: List[int], scales: List[int], aspect_ratios: List[List[int]], scale_xy: float = 0.1, scale_wh: float = 0.2)[source]

                                                                                                                    Bases: object

                                                                                                                    Convenience class for creating, representing, encoding, and decoding default boxes

                                                                                                                    @@ -2513,7 +2513,7 @@

                                                                                                                    Submodules
                                                                                                                    -as_ltrb() → torch.Tensor[source]
                                                                                                                    +as_ltrb()torch.Tensor[source]
                                                                                                                    Returns

                                                                                                                    The default boxes represented by this object in @@ -2524,7 +2524,7 @@

                                                                                                                    Submodules
                                                                                                                    -as_xywh() → torch.Tensor[source]
                                                                                                                    +as_xywh()torch.Tensor[source]
                                                                                                                    Returns

                                                                                                                    The default boxes represented by this object in @@ -2535,7 +2535,7 @@

                                                                                                                    Submodules
                                                                                                                    -decode_output_batch(boxes: torch.Tensor, scores: torch.Tensor, score_threhsold: float = 0.01, iou_threshold: float = 0.45, max_detections: int = 200) → List[Tuple[torch.Tensor, torch.Tensor, torch.Tensor]][source]
                                                                                                                    +decode_output_batch(boxes: torch.Tensor, scores: torch.Tensor, score_threhsold: float = 0.01, iou_threshold: float = 0.45, max_detections: int = 200)List[Tuple[torch.Tensor, torch.Tensor, torch.Tensor]][source]

                                                                                                                    Decodes a batch detection model outputs from default box offsets and class scores to ltrb formatted bounding boxes, predicted labels, and scores for each image of the batch using non maximum suppression.

                                                                                                                    @@ -2563,7 +2563,7 @@

                                                                                                                    Submodules
                                                                                                                    -encode_image_box_labels(boxes: torch.Tensor, labels: torch.Tensor, threshold: float = 0.5) → Tuple[torch.Tensor, torch.Tensor][source]
                                                                                                                    +encode_image_box_labels(boxes: torch.Tensor, labels: torch.Tensor, threshold: float = 0.5)Tuple[torch.Tensor, torch.Tensor][source]

                                                                                                                    Given the bounding box and image annotations for a single image with N objects will encode the box annotations as offsets to the default boxes and labels to the associated default boxes based on the annotation boxes and default @@ -2587,7 +2587,7 @@

                                                                                                                    Submodules
                                                                                                                    -property num_default_boxes
                                                                                                                    +property num_default_boxes

                                                                                                                    the number of default boxes this object defines

                                                                                                                    Type
                                                                                                                    @@ -2598,7 +2598,7 @@

                                                                                                                    Submodules
                                                                                                                    -property scale_wh
                                                                                                                    +property scale_wh

                                                                                                                    parameter to scale box dimensions by when encoding

                                                                                                                    Type
                                                                                                                    @@ -2609,7 +2609,7 @@

                                                                                                                    Submodules
                                                                                                                    -property scale_xy
                                                                                                                    +property scale_xy

                                                                                                                    parameter to scale box center by when encoding

                                                                                                                    Type
                                                                                                                    @@ -2622,7 +2622,7 @@

                                                                                                                    Submodules
                                                                                                                    -class sparseml.pytorch.utils.ssd_helpers.MeanAveragePrecision(postprocessing_fn: Callable[Any, Tuple[torch.Tensor, torch.Tensor, torch.Tensor]], iou_threshold: Union[float, Tuple[float, float]] = 0.5, iou_steps: float = 0.05)[source]
                                                                                                                    +class sparseml.pytorch.utils.ssd_helpers.MeanAveragePrecision(postprocessing_fn: Callable[Any, Tuple[torch.Tensor, torch.Tensor, torch.Tensor]], iou_threshold: Union[float, Tuple[float, float]] = 0.5, iou_steps: float = 0.05)[source]

                                                                                                                    Bases: object

                                                                                                                    Class for computing the mean average precision of an object detection model output. Inputs will be decoded by the provided post-processing function. @@ -2646,7 +2646,7 @@

                                                                                                                    Submodules
                                                                                                                    -batch_forward(model_output: Tuple[torch.Tensor, torch.Tensor], ground_truth_annotations: List[Tuple[torch.Tensor, torch.Tensor]])[source]
                                                                                                                    +batch_forward(model_output: Tuple[torch.Tensor, torch.Tensor], ground_truth_annotations: List[Tuple[torch.Tensor, torch.Tensor]])[source]

                                                                                                                    Decodes the model outputs using non maximum suppression, then stores the number of ground truth objects per class, true positives, and true negatives that can be used to calculate the overall mAP in the calculate_map function

                                                                                                                    @@ -2664,7 +2664,7 @@

                                                                                                                    Submodules
                                                                                                                    -calculate_map(num_recall_levels: int = 11) → Tuple[float, Dict[float, Dict[int, float]]][source]
                                                                                                                    +calculate_map(num_recall_levels: int = 11)Tuple[float, Dict[float, Dict[int, float]]][source]

                                                                                                                    Calculates mAP at the given threshold values based on the results stored in forward passes

                                                                                                                    @@ -2681,13 +2681,13 @@

                                                                                                                    Submodules
                                                                                                                    -clear()[source]
                                                                                                                    +clear()[source]

                                                                                                                    Resets the ground truth class count and results dictionaries

                                                                                                                    -static get_recall_levels(num_recall_levels: int = 11)[source]
                                                                                                                    +static get_recall_levels(num_recall_levels: int = 11)[source]
                                                                                                                    Parameters

                                                                                                                    num_recall_levels – the number of recall levels to use between @@ -2704,7 +2704,7 @@

                                                                                                                    Submodules
                                                                                                                    -sparseml.pytorch.utils.ssd_helpers.get_default_boxes_300(voc: bool = False)sparseml.pytorch.utils.ssd_helpers.DefaultBoxes[source]
                                                                                                                    +sparseml.pytorch.utils.ssd_helpers.get_default_boxes_300(voc: bool = False)sparseml.pytorch.utils.ssd_helpers.DefaultBoxes[source]

                                                                                                                    Convenience function for generating DefaultBoxes object for standard SSD300 model

                                                                                                                    Parameters
                                                                                                                    @@ -2720,7 +2720,7 @@

                                                                                                                    Submodules
                                                                                                                    -sparseml.pytorch.utils.ssd_helpers.ssd_random_crop(image: PIL.Image.Image, boxes: torch.Tensor, labels: torch.Tensor) → Tuple[PIL.Image.Image, torch.Tensor, torch.Tensor][source]
                                                                                                                    +sparseml.pytorch.utils.ssd_helpers.ssd_random_crop(image: PIL.Image.Image, boxes: torch.Tensor, labels: torch.Tensor)Tuple[PIL.Image.Image, torch.Tensor, torch.Tensor][source]

                                                                                                                    Performs one of the random SSD crops on a given image, bounding boxes, and labels as implemented in the original paper.

                                                                                                                    @@ -2752,7 +2752,7 @@

                                                                                                                    Submodules
                                                                                                                    -class sparseml.pytorch.utils.yolo_helpers.YoloGrids(anchor_groups: Optional[List[torch.Tensor]] = None)[source]
                                                                                                                    +class sparseml.pytorch.utils.yolo_helpers.YoloGrids(anchor_groups: Optional[List[torch.Tensor]] = None)[source]

                                                                                                                    Bases: object

                                                                                                                    Helper class to compute and store Yolo output and anchor box grids

                                                                                                                    @@ -2763,7 +2763,7 @@

                                                                                                                    Submodules
                                                                                                                    -get_anchor_grid(group_idx: int) → torch.Tensor[source]
                                                                                                                    +get_anchor_grid(group_idx: int)torch.Tensor[source]
                                                                                                                    Parameters

                                                                                                                    group_idx – Index of output group for this anchor grid

                                                                                                                    @@ -2776,7 +2776,7 @@

                                                                                                                    Submodules
                                                                                                                    -get_grid(size_x: int, size_y: int) → torch.Tensor[source]
                                                                                                                    +get_grid(size_x: int, size_y: int)torch.Tensor[source]
                                                                                                                    Parameters
                                                                                                                      @@ -2793,7 +2793,7 @@

                                                                                                                      Submodules
                                                                                                                      -num_anchor_grids() → int[source]
                                                                                                                      +num_anchor_grids()int[source]
                                                                                                                      Returns

                                                                                                                      The number of anchor grids available (number of yolo model outputs)

                                                                                                                      @@ -2805,7 +2805,7 @@

                                                                                                                      Submodules
                                                                                                                      -sparseml.pytorch.utils.yolo_helpers.box_giou(boxes_a: torch.Tensor, boxes_b: torch.Tensor) → torch.Tensor[source]
                                                                                                                      +sparseml.pytorch.utils.yolo_helpers.box_giou(boxes_a: torch.Tensor, boxes_b: torch.Tensor)torch.Tensor[source]
                                                                                                                      Parameters
                                                                                                                        @@ -2821,7 +2821,7 @@

                                                                                                                        Submodules
                                                                                                                        -sparseml.pytorch.utils.yolo_helpers.build_targets(targets: torch.Tensor, anchors_groups: List[torch.Tensor], grid_shapes: List[torch.Tensor], iou_threshold: float = 0.2) → Tuple[List[torch.Tensor], List[torch.Tensor], List[torch.Tensor], List[torch.Tensor]][source]
                                                                                                                        +sparseml.pytorch.utils.yolo_helpers.build_targets(targets: torch.Tensor, anchors_groups: List[torch.Tensor], grid_shapes: List[torch.Tensor], iou_threshold: float = 0.2)Tuple[List[torch.Tensor], List[torch.Tensor], List[torch.Tensor], List[torch.Tensor]][source]

                                                                                                                        Returns a representation of the image targets according to the given anchor groups and grid shapes.

                                                                                                                        @@ -2845,7 +2845,7 @@

                                                                                                                        Submodules
                                                                                                                        -sparseml.pytorch.utils.yolo_helpers.get_output_grid_shapes(outputs: List[torch.Tensor]) → List[torch.Tensor][source]
                                                                                                                        +sparseml.pytorch.utils.yolo_helpers.get_output_grid_shapes(outputs: List[torch.Tensor])List[torch.Tensor][source]
                                                                                                                        Parameters

                                                                                                                        outputs – List of Yolo model outputs

                                                                                                                        @@ -2858,7 +2858,7 @@

                                                                                                                        Submodules
                                                                                                                        -sparseml.pytorch.utils.yolo_helpers.postprocess_yolo(preds: List[torch.Tensor], input_shape: Iterable[int], yolo_grids: Optional[sparseml.pytorch.utils.yolo_helpers.YoloGrids] = None, confidence_threshold: float = 0.1, iou_threshold: float = 0.6, max_detections: int = 300) → List[Tuple[torch.Tensor, torch.Tensor, torch.Tensor]][source]
                                                                                                                        +sparseml.pytorch.utils.yolo_helpers.postprocess_yolo(preds: List[torch.Tensor], input_shape: Iterable[int], yolo_grids: Optional[sparseml.pytorch.utils.yolo_helpers.YoloGrids] = None, confidence_threshold: float = 0.1, iou_threshold: float = 0.6, max_detections: int = 300)List[Tuple[torch.Tensor, torch.Tensor, torch.Tensor]][source]

                                                                                                                        Decode the outputs of a Yolo model and perform non maximum suppression on the predicted boxes.

                                                                                                                        @@ -2882,7 +2882,7 @@

                                                                                                                        Submodules
                                                                                                                        -sparseml.pytorch.utils.yolo_helpers.yolo_v3_anchor_groups() → List[torch.Tensor][source]
                                                                                                                        +sparseml.pytorch.utils.yolo_helpers.yolo_v3_anchor_groups()List[torch.Tensor][source]
                                                                                                                        Returns

                                                                                                                        List of the default anchor coordinate groups for Yolo V3 outputs

                                                                                                                        diff --git a/sparseml/api/sparseml.tensorflow_v1.datasets.classification.html b/sparseml/api/sparseml.tensorflow_v1.datasets.classification.html index 06945db28ff..726cb46855c 100644 --- a/sparseml/api/sparseml.tensorflow_v1.datasets.classification.html +++ b/sparseml/api/sparseml.tensorflow_v1.datasets.classification.html @@ -211,11 +211,11 @@

                                                                                                                        Submodules

                                                                                                                        sparseml.tensorflow_v1.datasets.classification.cifar module

                                                                                                                        -class sparseml.tensorflow_v1.datasets.classification.cifar.Cifar100DataSet(root: str, train: bool = True, image_size: int = 32, pre_resize_transforms: Optional[sparseml.tensorflow_v1.datasets.classification.imagefolder.SplitsTransforms] = SplitsTransforms(train=(<function preprocess_for_train>, ), val=(<function preprocess_for_eval>, )), post_resize_transforms: Optional[sparseml.tensorflow_v1.datasets.classification.imagefolder.SplitsTransforms] = SplitsTransforms(train=None, val=None), download: bool = True)[source]
                                                                                                                        +class sparseml.tensorflow_v1.datasets.classification.cifar.Cifar100DataSet(root: str, train: bool = True, image_size: int = 32, pre_resize_transforms: Optional[sparseml.tensorflow_v1.datasets.classification.imagefolder.SplitsTransforms] = SplitsTransforms(train=(<function preprocess_for_train>, ), val=(<function preprocess_for_eval>, )), post_resize_transforms: Optional[sparseml.tensorflow_v1.datasets.classification.imagefolder.SplitsTransforms] = SplitsTransforms(train=None, val=None), download: bool = True)[source]

                                                                                                                        Bases: sparseml.tensorflow_v1.datasets.classification.cifar.CifarDataSet

                                                                                                                        -name_scope() → str[source]
                                                                                                                        +name_scope()str[source]
                                                                                                                        Returns

                                                                                                                        the name scope the dataset should be built under in the graph

                                                                                                                        @@ -227,11 +227,11 @@

                                                                                                                        Submodules
                                                                                                                        -class sparseml.tensorflow_v1.datasets.classification.cifar.Cifar10DataSet(root: str, train: bool = True, image_size: int = 32, pre_resize_transforms: Optional[sparseml.tensorflow_v1.datasets.classification.imagefolder.SplitsTransforms] = SplitsTransforms(train=(<function preprocess_for_train>, ), val=(<function preprocess_for_eval>, )), post_resize_transforms: Optional[sparseml.tensorflow_v1.datasets.classification.imagefolder.SplitsTransforms] = SplitsTransforms(train=None, val=None), download: bool = True)[source]
                                                                                                                        +class sparseml.tensorflow_v1.datasets.classification.cifar.Cifar10DataSet(root: str, train: bool = True, image_size: int = 32, pre_resize_transforms: Optional[sparseml.tensorflow_v1.datasets.classification.imagefolder.SplitsTransforms] = SplitsTransforms(train=(<function preprocess_for_train>, ), val=(<function preprocess_for_eval>, )), post_resize_transforms: Optional[sparseml.tensorflow_v1.datasets.classification.imagefolder.SplitsTransforms] = SplitsTransforms(train=None, val=None), download: bool = True)[source]

                                                                                                                        Bases: sparseml.tensorflow_v1.datasets.classification.cifar.CifarDataSet

                                                                                                                        -name_scope() → str[source]
                                                                                                                        +name_scope()str[source]
                                                                                                                        Returns

                                                                                                                        the name scope the dataset should be built under in the graph

                                                                                                                        @@ -248,7 +248,7 @@

                                                                                                                        Submodules
                                                                                                                        -class sparseml.tensorflow_v1.datasets.classification.imagefolder.ImageFolderDataset(root: str, train: bool, image_size: int = 224, pre_resize_transforms: Optional[sparseml.tensorflow_v1.datasets.classification.imagefolder.SplitsTransforms] = SplitsTransforms(train=(<function random_scaling_crop.<locals>.rand_crop>, <function random_flip_left_right>, <function random_flip_up_down>), val=None), post_resize_transforms: Optional[sparseml.tensorflow_v1.datasets.classification.imagefolder.SplitsTransforms] = SplitsTransforms(train=(<function imagenet_normalizer>, ), val=(<function center_square_crop.<locals>.cent_crop>, <function imagenet_normalizer>)))[source]
                                                                                                                        +class sparseml.tensorflow_v1.datasets.classification.imagefolder.ImageFolderDataset(root: str, train: bool, image_size: int = 224, pre_resize_transforms: Optional[sparseml.tensorflow_v1.datasets.classification.imagefolder.SplitsTransforms] = SplitsTransforms(train=(<function random_scaling_crop.<locals>.rand_crop>, <function random_flip_left_right>, <function random_flip_up_down>), val=None), post_resize_transforms: Optional[sparseml.tensorflow_v1.datasets.classification.imagefolder.SplitsTransforms] = SplitsTransforms(train=(<function imagenet_normalizer>, ), val=(<function center_square_crop.<locals>.cent_crop>, <function imagenet_normalizer>)))[source]

                                                                                                                        Bases: sparseml.tensorflow_v1.datasets.dataset.Dataset

                                                                                                                        Implementation for loading an image folder structure into a dataset.

                                                                                                                        @@ -277,7 +277,7 @@

                                                                                                                        Submodules
                                                                                                                        -creator()[source]
                                                                                                                        +creator()[source]
                                                                                                                        Returns

                                                                                                                        a created dataset that gives the file_path and label for each @@ -288,7 +288,7 @@

                                                                                                                        Submodules
                                                                                                                        -format_iterator_batch(iter_batch: Tuple[tensorflow.python.framework.ops.Tensor, ]) → Tuple[Dict[str, tensorflow.python.framework.ops.Tensor], Dict[str, tensorflow.python.framework.ops.Tensor]][source]
                                                                                                                        +format_iterator_batch(iter_batch: Tuple[tensorflow.python.framework.ops.Tensor, ])Tuple[Dict[str, tensorflow.python.framework.ops.Tensor], Dict[str, tensorflow.python.framework.ops.Tensor]][source]
                                                                                                                        Parameters

                                                                                                                        iter_batch – the batch ref returned from the iterator

                                                                                                                        @@ -301,7 +301,7 @@

                                                                                                                        Submodules
                                                                                                                        -property image_size
                                                                                                                        +property image_size

                                                                                                                        the size of the images to resize to

                                                                                                                        Type
                                                                                                                        @@ -312,7 +312,7 @@

                                                                                                                        Submodules
                                                                                                                        -name_scope() → str[source]
                                                                                                                        +name_scope()str[source]
                                                                                                                        Returns

                                                                                                                        the name scope the dataset should be built under in the graph

                                                                                                                        @@ -322,7 +322,7 @@

                                                                                                                        Submodules
                                                                                                                        -property num_classes
                                                                                                                        +property num_classes

                                                                                                                        the number of classes found for the dataset

                                                                                                                        Type
                                                                                                                        @@ -333,7 +333,7 @@

                                                                                                                        Submodules
                                                                                                                        -property num_images
                                                                                                                        +property num_images

                                                                                                                        the number of images found for the dataset

                                                                                                                        Type
                                                                                                                        @@ -344,7 +344,7 @@

                                                                                                                        Submodules
                                                                                                                        -property post_resize_transforms
                                                                                                                        +property post_resize_transforms

                                                                                                                        transforms to be applied after resizing the image

                                                                                                                        Type
                                                                                                                        @@ -355,7 +355,7 @@

                                                                                                                        Submodules
                                                                                                                        -property pre_resize_transforms
                                                                                                                        +property pre_resize_transforms

                                                                                                                        transforms to be applied before resizing the image

                                                                                                                        Type
                                                                                                                        @@ -366,7 +366,7 @@

                                                                                                                        Submodules
                                                                                                                        -processor(file_path: tensorflow.python.framework.ops.Tensor, label: tensorflow.python.framework.ops.Tensor)[source]
                                                                                                                        +processor(file_path: tensorflow.python.framework.ops.Tensor, label: tensorflow.python.framework.ops.Tensor)[source]
                                                                                                                        Parameters
                                                                                                                          @@ -382,7 +382,7 @@

                                                                                                                          Submodules
                                                                                                                          -property root
                                                                                                                          +property root

                                                                                                                          the root location for the dataset’s images to load

                                                                                                                          Type
                                                                                                                          @@ -393,7 +393,7 @@

                                                                                                                          Submodules
                                                                                                                          -property train
                                                                                                                          +property train

                                                                                                                          True to load the training dataset from the root, False for validation

                                                                                                                          Type
                                                                                                                          @@ -406,17 +406,17 @@

                                                                                                                          Submodules
                                                                                                                          -class sparseml.tensorflow_v1.datasets.classification.imagefolder.SplitsTransforms(train, val)
                                                                                                                          +class sparseml.tensorflow_v1.datasets.classification.imagefolder.SplitsTransforms(train, val)

                                                                                                                          Bases: tuple

                                                                                                                          -property train
                                                                                                                          +property train

                                                                                                                          Alias for field number 0

                                                                                                                          -property val
                                                                                                                          +property val

                                                                                                                          Alias for field number 1

                                                                                                                          @@ -424,7 +424,7 @@

                                                                                                                          Submodules
                                                                                                                          -sparseml.tensorflow_v1.datasets.classification.imagefolder.imagenet_normalizer(img)[source]
                                                                                                                          +sparseml.tensorflow_v1.datasets.classification.imagefolder.imagenet_normalizer(img)[source]

                                                                                                                          Normalize an image using mean and std of the imagenet dataset

                                                                                                                          Parameters
                                                                                                                          @@ -443,7 +443,7 @@

                                                                                                                          Submoduleshere.

                                                                                                                          -class sparseml.tensorflow_v1.datasets.classification.imagenet.ImageNetDataset(root: str = '~/.cache/nm_datasets/imagenet', train: bool = True, image_size: int = 224)[source]
                                                                                                                          +class sparseml.tensorflow_v1.datasets.classification.imagenet.ImageNetDataset(root: str = '~/.cache/nm_datasets/imagenet', train: bool = True, image_size: int = 224)[source]

                                                                                                                          Bases: sparseml.tensorflow_v1.datasets.classification.imagefolder.ImageFolderDataset

                                                                                                                          ImageNet dataset implementation

                                                                                                                          @@ -458,7 +458,7 @@

                                                                                                                          Submodules
                                                                                                                          -name_scope() → str[source]
                                                                                                                          +name_scope()str[source]
                                                                                                                          Returns

                                                                                                                          the name scope the dataset should be built under in the graph

                                                                                                                          @@ -476,7 +476,7 @@

                                                                                                                          Submoduleshere.

                                                                                                                          -class sparseml.tensorflow_v1.datasets.classification.imagenette.ImagenetteDataset(root: str = '~/.cache/nm_datasets/imagenette', train: bool = True, dataset_size: sparseml.utils.datasets.imagenette.ImagenetteSize = <ImagenetteSize.s160: 's160'>, image_size: Union[None, int] = None, download: bool = True)[source]
                                                                                                                          +class sparseml.tensorflow_v1.datasets.classification.imagenette.ImagenetteDataset(root: str = '~/.cache/nm_datasets/imagenette', train: bool = True, dataset_size: sparseml.utils.datasets.imagenette.ImagenetteSize = <ImagenetteSize.s160: 's160'>, image_size: Union[None, int] = None, download: bool = True)[source]

                                                                                                                          Bases: sparseml.tensorflow_v1.datasets.classification.imagefolder.ImageFolderDataset, sparseml.utils.datasets.imagenette.ImagenetteDownloader

                                                                                                                          Wrapper for the imagenette (10 class) dataset that fastai created. Handles downloading and applying standard transforms.

                                                                                                                          @@ -496,7 +496,7 @@

                                                                                                                          Submodules
                                                                                                                          -name_scope() → str[source]
                                                                                                                          +name_scope()str[source]
                                                                                                                          Returns

                                                                                                                          the name scope the dataset should be built under in the graph

                                                                                                                          @@ -508,7 +508,7 @@

                                                                                                                          Submodules
                                                                                                                          -class sparseml.tensorflow_v1.datasets.classification.imagenette.ImagenetteSize(value)[source]
                                                                                                                          +class sparseml.tensorflow_v1.datasets.classification.imagenette.ImagenetteSize(value)[source]

                                                                                                                          Bases: enum.Enum

                                                                                                                          Dataset size for Imagenette / Imagewoof. full does not resize the original dataset at all. @@ -516,24 +516,24 @@

                                                                                                                          Submodules
                                                                                                                          -full = 'full'
                                                                                                                          +full = 'full'

                                                                                                                          -s160 = 's160'
                                                                                                                          +s160 = 's160'
                                                                                                                          -s320 = 's320'
                                                                                                                          +s320 = 's320'

                                                                                                                          -class sparseml.tensorflow_v1.datasets.classification.imagenette.ImagewoofDataset(root: str = '~/.cache/nm_datasets/imagewoof', train: bool = True, dataset_size: sparseml.utils.datasets.imagenette.ImagenetteSize = <ImagenetteSize.s160: 's160'>, image_size: Union[None, int] = None, download: bool = True)[source]
                                                                                                                          +class sparseml.tensorflow_v1.datasets.classification.imagenette.ImagewoofDataset(root: str = '~/.cache/nm_datasets/imagewoof', train: bool = True, dataset_size: sparseml.utils.datasets.imagenette.ImagenetteSize = <ImagenetteSize.s160: 's160'>, image_size: Union[None, int] = None, download: bool = True)[source]

                                                                                                                          Bases: sparseml.tensorflow_v1.datasets.classification.imagefolder.ImageFolderDataset, sparseml.utils.datasets.imagenette.ImagewoofDownloader

                                                                                                                          Wrapper for the imagewoof (10 class) dataset that fastai created. Handles downloading and applying standard transforms. @@ -556,7 +556,7 @@

                                                                                                                          Submodules
                                                                                                                          -name_scope() → str[source]
                                                                                                                          +name_scope()str[source]
                                                                                                                          Returns

                                                                                                                          the name scope the dataset should be built under in the graph

                                                                                                                          diff --git a/sparseml/api/sparseml.tensorflow_v1.datasets.html b/sparseml/api/sparseml.tensorflow_v1.datasets.html index ee8a561e676..4f587c9c554 100644 --- a/sparseml/api/sparseml.tensorflow_v1.datasets.html +++ b/sparseml/api/sparseml.tensorflow_v1.datasets.html @@ -226,13 +226,13 @@

                                                                                                                          Submodules
                                                                                                                          -class sparseml.tensorflow_v1.datasets.dataset.Dataset[source]
                                                                                                                          +class sparseml.tensorflow_v1.datasets.dataset.Dataset[source]

                                                                                                                          Bases: object

                                                                                                                          Generic dataset implementation for TensorFlow. Expected to work with the tf.data APIs

                                                                                                                          -build(batch_size: int, repeat_count: Optional[int] = None, shuffle_buffer_size: Optional[int] = None, prefetch_buffer_size: Optional[int] = None, num_parallel_calls: Optional[int] = None) → tensorflow.python.data.ops.dataset_ops.DatasetV1[source]
                                                                                                                          +build(batch_size: int, repeat_count: Optional[int] = None, shuffle_buffer_size: Optional[int] = None, prefetch_buffer_size: Optional[int] = None, num_parallel_calls: Optional[int] = None)tensorflow.python.data.ops.dataset_ops.DatasetV1[source]

                                                                                                                          Create the dataset in the current graph using tf.data APIs

                                                                                                                          Parameters
                                                                                                                          @@ -256,7 +256,7 @@

                                                                                                                          Submodules
                                                                                                                          -build_input_fn(batch_size: int, repeat_count: Optional[int] = None, shuffle_buffer_size: Optional[int] = None, prefetch_buffer_size: Optional[int] = None, num_parallel_calls: Optional[int] = None) → Callable[Tuple[Dict[str, tensorflow.python.framework.ops.Tensor], Dict[str, tensorflow.python.framework.ops.Tensor]]][source]
                                                                                                                          +build_input_fn(batch_size: int, repeat_count: Optional[int] = None, shuffle_buffer_size: Optional[int] = None, prefetch_buffer_size: Optional[int] = None, num_parallel_calls: Optional[int] = None)Callable[Tuple[Dict[str, tensorflow.python.framework.ops.Tensor], Dict[str, tensorflow.python.framework.ops.Tensor]]][source]

                                                                                                                          Create an input_fn to be used with Estimators. Invocation of the input_fn will create the dataset in the current graph as well as return a tuple containing @@ -283,7 +283,7 @@

                                                                                                                          Submodules
                                                                                                                          -abstract creator() → tensorflow.python.data.ops.dataset_ops.DatasetV1[source]
                                                                                                                          +abstract creator()tensorflow.python.data.ops.dataset_ops.DatasetV1[source]

                                                                                                                          Implemented by sub classes to create a tf.data dataset for the given impl.

                                                                                                                          Returns
                                                                                                                          @@ -294,7 +294,7 @@

                                                                                                                          Submodules
                                                                                                                          -abstract format_iterator_batch(iter_batch: Tuple[tensorflow.python.framework.ops.Tensor, ]) → Tuple[Dict[str, tensorflow.python.framework.ops.Tensor], Dict[str, tensorflow.python.framework.ops.Tensor]][source]
                                                                                                                          +abstract format_iterator_batch(iter_batch: Tuple[tensorflow.python.framework.ops.Tensor, ])Tuple[Dict[str, tensorflow.python.framework.ops.Tensor], Dict[str, tensorflow.python.framework.ops.Tensor]][source]

                                                                                                                          Implemented by sub classes to parse the output from make_one_shot_iterator into a features and labels dict to be used with Estimators

                                                                                                                          @@ -310,7 +310,7 @@

                                                                                                                          Submodules
                                                                                                                          -abstract name_scope() → str[source]
                                                                                                                          +abstract name_scope()str[source]

                                                                                                                          Implemented by sub classes to get a name scope for building the dataset in the graph

                                                                                                                          @@ -322,7 +322,7 @@

                                                                                                                          Submodules
                                                                                                                          -abstract processor(*args, **kwargs)[source]
                                                                                                                          +abstract processor(*args, **kwargs)[source]

                                                                                                                          Implemented by sub classes to parallelize and map processing functions for loading the data of the dataset into memory.

                                                                                                                          @@ -342,7 +342,7 @@

                                                                                                                          Submodules
                                                                                                                          -sparseml.tensorflow_v1.datasets.dataset.create_split_iterators_handle(split_datasets: Iterable) → Tuple[Any, Any, List][source]
                                                                                                                          +sparseml.tensorflow_v1.datasets.dataset.create_split_iterators_handle(split_datasets: Iterable)Tuple[Any, Any, List][source]

                                                                                                                          Create an iterators handle for switching between datasets easily while training.

                                                                                                                          Parameters
                                                                                                                          @@ -362,7 +362,7 @@

                                                                                                                          Submodules
                                                                                                                          -sparseml.tensorflow_v1.datasets.helpers.center_square_crop(padding: int = 0, name: str = 'center_square_crop')[source]
                                                                                                                          +sparseml.tensorflow_v1.datasets.helpers.center_square_crop(padding: int = 0, name: str = 'center_square_crop')[source]

                                                                                                                          Take a square crop centered in the a image

                                                                                                                          Parameters
                                                                                                                          @@ -381,7 +381,7 @@

                                                                                                                          Submodules
                                                                                                                          -sparseml.tensorflow_v1.datasets.helpers.random_scaling_crop(scale_range: Tuple[int, int] = (0.08, 1.0), ratio_range: Tuple[int, int] = (0.75, 1.3333333333333333), name: str = 'random_scaling_crop')[source]
                                                                                                                          +sparseml.tensorflow_v1.datasets.helpers.random_scaling_crop(scale_range: Tuple[int, int] = (0.08, 1.0), ratio_range: Tuple[int, int] = (0.75, 1.3333333333333333), name: str = 'random_scaling_crop')[source]

                                                                                                                          Random crop implementation which also randomly scales the crop taken as well as the aspect ratio of the crop.

                                                                                                                          @@ -401,7 +401,7 @@

                                                                                                                          Submodules
                                                                                                                          -sparseml.tensorflow_v1.datasets.helpers.resize(image_size: Tuple[int, int], name: str = 'resize')[source]
                                                                                                                          +sparseml.tensorflow_v1.datasets.helpers.resize(image_size: Tuple[int, int], name: str = 'resize')[source]

                                                                                                                          Resize an image tensor to the desired size

                                                                                                                          Parameters
                                                                                                                          @@ -423,12 +423,12 @@

                                                                                                                          Submodules
                                                                                                                          -class sparseml.tensorflow_v1.datasets.registry.DatasetRegistry[source]
                                                                                                                          +class sparseml.tensorflow_v1.datasets.registry.DatasetRegistry[source]

                                                                                                                          Bases: object

                                                                                                                          Registry class for creating datasets

                                                                                                                          -static attributes(key: str) → Dict[str, Any][source]
                                                                                                                          +static attributes(key: str)Dict[str, Any][source]
                                                                                                                          Parameters

                                                                                                                          key – the dataset key (name) to create

                                                                                                                          @@ -441,7 +441,7 @@

                                                                                                                          Submodules
                                                                                                                          -static create(key: str, *args, **kwargs)[source]
                                                                                                                          +static create(key: str, *args, **kwargs)[source]

                                                                                                                          Create a new dataset for the given key

                                                                                                                          Parameters
                                                                                                                          @@ -455,7 +455,7 @@

                                                                                                                          Submodules
                                                                                                                          -static register(key: Union[str, List[str]], attributes: Dict[str, Any])[source]
                                                                                                                          +static register(key: Union[str, List[str]], attributes: Dict[str, Any])[source]

                                                                                                                          Register a dataset with the registry. Should be used as a decorator

                                                                                                                          Parameters
                                                                                                                          diff --git a/sparseml/api/sparseml.tensorflow_v1.models.classification.html b/sparseml/api/sparseml.tensorflow_v1.models.classification.html index 5b74b673ff9..5cf98a5f171 100644 --- a/sparseml/api/sparseml.tensorflow_v1.models.classification.html +++ b/sparseml/api/sparseml.tensorflow_v1.models.classification.html @@ -211,7 +211,7 @@

                                                                                                                          Submodules

                                                                                                                          sparseml.tensorflow_v1.models.classification.mnist module

                                                                                                                          -sparseml.tensorflow_v1.models.classification.mnist.mnist_net(inputs: tensorflow.python.framework.ops.Tensor, num_classes: int = 10, act: Optional[str] = None) → tensorflow.python.framework.ops.Tensor[source]
                                                                                                                          +sparseml.tensorflow_v1.models.classification.mnist.mnist_net(inputs: tensorflow.python.framework.ops.Tensor, num_classes: int = 10, act: Optional[str] = None)tensorflow.python.framework.ops.Tensor[source]

                                                                                                                          A simple convolutional model created for the MNIST dataset

                                                                                                                          Parameters
                                                                                                                          @@ -235,7 +235,7 @@

                                                                                                                          Submoduleshere.

                                                                                                                          -class sparseml.tensorflow_v1.models.classification.mobilenet.MobileNetSection(num_blocks: int, out_channels: int, downsample: bool)[source]
                                                                                                                          +class sparseml.tensorflow_v1.models.classification.mobilenet.MobileNetSection(num_blocks: int, out_channels: int, downsample: bool)[source]

                                                                                                                          Bases: object

                                                                                                                          Settings to describe how to put together a MobileNet architecture using user supplied configurations.

                                                                                                                          @@ -251,7 +251,7 @@

                                                                                                                          Submodules
                                                                                                                          -create(name: str, x_tens: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor], kernel_initializer, bias_initializer, beta_initializer, gamma_initializer) → tensorflow.python.framework.ops.Tensor[source]
                                                                                                                          +create(name: str, x_tens: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor], kernel_initializer, bias_initializer, beta_initializer, gamma_initializer)tensorflow.python.framework.ops.Tensor[source]

                                                                                                                          Create the section in the current graph and scope

                                                                                                                          Parameters
                                                                                                                          @@ -277,7 +277,7 @@

                                                                                                                          Submodules
                                                                                                                          -sparseml.tensorflow_v1.models.classification.mobilenet.mobilenet(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: str = 'single', kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>) → tensorflow.python.framework.ops.Tensor[source]
                                                                                                                          +sparseml.tensorflow_v1.models.classification.mobilenet.mobilenet(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: str = 'single', kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>)tensorflow.python.framework.ops.Tensor[source]

                                                                                                                          Standard MobileNet implementation with width=1.0; expected input shape is (B, 224, 224, 3)

                                                                                                                          @@ -304,7 +304,7 @@

                                                                                                                          Submodules
                                                                                                                          -sparseml.tensorflow_v1.models.classification.mobilenet.mobilenet_const(x_tens: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor], sec_settings: List[sparseml.tensorflow_v1.models.classification.mobilenet.MobileNetSection], num_classes: int, class_type: str, kernel_initializer, bias_initializer, beta_initializer, gamma_initializer) → tensorflow.python.framework.ops.Tensor[source]
                                                                                                                          +sparseml.tensorflow_v1.models.classification.mobilenet.mobilenet_const(x_tens: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor], sec_settings: List[sparseml.tensorflow_v1.models.classification.mobilenet.MobileNetSection], num_classes: int, class_type: str, kernel_initializer, bias_initializer, beta_initializer, gamma_initializer)tensorflow.python.framework.ops.Tensor[source]

                                                                                                                          Graph constructor for MobileNet implementation.

                                                                                                                          Parameters
                                                                                                                          @@ -336,7 +336,7 @@

                                                                                                                          Submoduleshere.

                                                                                                                          -class sparseml.tensorflow_v1.models.classification.mobilenet_v2.MobileNetV2Section(num_blocks: int, out_channels: int, downsample: bool, exp_channels: Union[None, int] = None, exp_ratio: float = 1.0, init_section: bool = False, width_mult: float = 1.0)[source]
                                                                                                                          +class sparseml.tensorflow_v1.models.classification.mobilenet_v2.MobileNetV2Section(num_blocks: int, out_channels: int, downsample: bool, exp_channels: Union[None, int] = None, exp_ratio: float = 1.0, init_section: bool = False, width_mult: float = 1.0)[source]

                                                                                                                          Bases: object

                                                                                                                          Settings to describe how to put together MobileNet V2 architecture using user supplied configurations.

                                                                                                                          @@ -357,7 +357,7 @@

                                                                                                                          Submodules
                                                                                                                          -create(name: str, x_tens: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor], kernel_initializer, bias_initializer, beta_initializer, gamma_initializer) → tensorflow.python.framework.ops.Tensor[source]
                                                                                                                          +create(name: str, x_tens: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor], kernel_initializer, bias_initializer, beta_initializer, gamma_initializer)tensorflow.python.framework.ops.Tensor[source]

                                                                                                                          Create the section in the current graph and scope

                                                                                                                          Parameters
                                                                                                                          @@ -383,7 +383,7 @@

                                                                                                                          Submodules
                                                                                                                          -sparseml.tensorflow_v1.models.classification.mobilenet_v2.mobilenet_v2(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: Optional[str] = None, kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>) → tensorflow.python.framework.ops.Tensor[source]
                                                                                                                          +sparseml.tensorflow_v1.models.classification.mobilenet_v2.mobilenet_v2(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: Optional[str] = None, kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>)tensorflow.python.framework.ops.Tensor[source]

                                                                                                                          Standard MobileNet V2 implementation with width=1.0; expected input shape is (B, 224, 224, 3)

                                                                                                                          @@ -410,7 +410,7 @@

                                                                                                                          Submodules
                                                                                                                          -sparseml.tensorflow_v1.models.classification.mobilenet_v2.mobilenet_v2_const(x_tens: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor], sec_settings: List[sparseml.tensorflow_v1.models.classification.mobilenet_v2.MobileNetV2Section], num_classes: int, class_type: str, kernel_initializer, bias_initializer, beta_initializer, gamma_initializer) → tensorflow.python.framework.ops.Tensor[source]
                                                                                                                          +sparseml.tensorflow_v1.models.classification.mobilenet_v2.mobilenet_v2_const(x_tens: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor], sec_settings: List[sparseml.tensorflow_v1.models.classification.mobilenet_v2.MobileNetV2Section], num_classes: int, class_type: str, kernel_initializer, bias_initializer, beta_initializer, gamma_initializer)tensorflow.python.framework.ops.Tensor[source]

                                                                                                                          Graph constructor for MobileNet V2 implementation.

                                                                                                                          Parameters
                                                                                                                          @@ -437,7 +437,7 @@

                                                                                                                          Submodules
                                                                                                                          -sparseml.tensorflow_v1.models.classification.mobilenet_v2.mobilenet_v2_width(width_mult: float, inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: Optional[str] = None, kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>) → tensorflow.python.framework.ops.Tensor[source]
                                                                                                                          +sparseml.tensorflow_v1.models.classification.mobilenet_v2.mobilenet_v2_width(width_mult: float, inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: Optional[str] = None, kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>)tensorflow.python.framework.ops.Tensor[source]

                                                                                                                          Standard MobileNetV2 implementation for a given width; expected input shape is (B, 224, 224, 3)

                                                                                                                          @@ -472,7 +472,7 @@

                                                                                                                          Submoduleshere.

                                                                                                                          -class sparseml.tensorflow_v1.models.classification.resnet.ResNetSection(num_blocks: int, out_channels: int, downsample: bool, proj_channels: int = - 1)[source]
                                                                                                                          +class sparseml.tensorflow_v1.models.classification.resnet.ResNetSection(num_blocks: int, out_channels: int, downsample: bool, proj_channels: int = - 1)[source]

                                                                                                                          Bases: object

                                                                                                                          Settings to describe how to put together a ResNet based architecture using user supplied configurations.

                                                                                                                          @@ -491,7 +491,7 @@

                                                                                                                          Submodules
                                                                                                                          -create(name: str, x_tens: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor], kernel_initializer, bias_initializer, beta_initializer, gamma_initializer) → tensorflow.python.framework.ops.Tensor[source]
                                                                                                                          +create(name: str, x_tens: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor], kernel_initializer, bias_initializer, beta_initializer, gamma_initializer)tensorflow.python.framework.ops.Tensor[source]

                                                                                                                          Create the section in the current graph and scope

                                                                                                                          Parameters
                                                                                                                          @@ -517,7 +517,7 @@

                                                                                                                          Submodules
                                                                                                                          -sparseml.tensorflow_v1.models.classification.resnet.resnet101(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: Optional[str] = None, kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>) → tensorflow.python.framework.ops.Tensor[source]
                                                                                                                          +sparseml.tensorflow_v1.models.classification.resnet.resnet101(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: Optional[str] = None, kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>)tensorflow.python.framework.ops.Tensor[source]

                                                                                                                          Standard ResNet101 implementation; expected input shape is (B, 224, 224, 3)

                                                                                                                          @@ -544,7 +544,7 @@

                                                                                                                          Submodules
                                                                                                                          -sparseml.tensorflow_v1.models.classification.resnet.resnet152(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: Optional[str] = None, kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>) → tensorflow.python.framework.ops.Tensor[source]
                                                                                                                          +sparseml.tensorflow_v1.models.classification.resnet.resnet152(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: Optional[str] = None, kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>)tensorflow.python.framework.ops.Tensor[source]

                                                                                                                          Standard ResNet152 implementation; expected input shape is (B, 224, 224, 3)

                                                                                                                          @@ -571,7 +571,7 @@

                                                                                                                          Submodules
                                                                                                                          -sparseml.tensorflow_v1.models.classification.resnet.resnet18(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: Optional[str] = None, kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>) → tensorflow.python.framework.ops.Tensor[source]
                                                                                                                          +sparseml.tensorflow_v1.models.classification.resnet.resnet18(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: Optional[str] = None, kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>)tensorflow.python.framework.ops.Tensor[source]

                                                                                                                          Standard ResNet18 implementation; expected input shape is (B, 224, 224, 3)

                                                                                                                          @@ -598,12 +598,12 @@

                                                                                                                          Submodules
                                                                                                                          -sparseml.tensorflow_v1.models.classification.resnet.resnet20(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 10, class_type: str = 'single', kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>) → tensorflow.python.framework.ops.Tensor[source]
                                                                                                                          +sparseml.tensorflow_v1.models.classification.resnet.resnet20(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 10, class_type: str = 'single', kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>)tensorflow.python.framework.ops.Tensor[source]

                                                                                                                          -sparseml.tensorflow_v1.models.classification.resnet.resnet34(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: Optional[str] = None, kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>) → tensorflow.python.framework.ops.Tensor[source]
                                                                                                                          +sparseml.tensorflow_v1.models.classification.resnet.resnet34(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: Optional[str] = None, kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>)tensorflow.python.framework.ops.Tensor[source]

                                                                                                                          Standard ResNet34 implementation; expected input shape is (B, 224, 224, 3)

                                                                                                                          @@ -630,7 +630,7 @@

                                                                                                                          Submodules
                                                                                                                          -sparseml.tensorflow_v1.models.classification.resnet.resnet50(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: Optional[str] = None, kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>) → tensorflow.python.framework.ops.Tensor[source]
                                                                                                                          +sparseml.tensorflow_v1.models.classification.resnet.resnet50(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: Optional[str] = None, kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>)tensorflow.python.framework.ops.Tensor[source]

                                                                                                                          Standard ResNet50 implementation; expected input shape is (B, 224, 224, 3)

                                                                                                                          @@ -657,7 +657,7 @@

                                                                                                                          Submodules
                                                                                                                          -sparseml.tensorflow_v1.models.classification.resnet.resnet_const(x_tens: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor], sec_settings: List[sparseml.tensorflow_v1.models.classification.resnet.ResNetSection], num_classes: int, class_type: str, kernel_initializer, bias_initializer, beta_initializer, gamma_initializer, simplified_arch: bool = False) → tensorflow.python.framework.ops.Tensor[source]
                                                                                                                          +sparseml.tensorflow_v1.models.classification.resnet.resnet_const(x_tens: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor], sec_settings: List[sparseml.tensorflow_v1.models.classification.resnet.ResNetSection], num_classes: int, class_type: str, kernel_initializer, bias_initializer, beta_initializer, gamma_initializer, simplified_arch: bool = False)tensorflow.python.framework.ops.Tensor[source]

                                                                                                                          Graph constructor for ResNet implementation.

                                                                                                                          Parameters
                                                                                                                          @@ -691,7 +691,7 @@

                                                                                                                          Submoduleshere.

                                                                                                                          -class sparseml.tensorflow_v1.models.classification.vgg.VGGSection(num_blocks: int, out_channels: int, use_batchnorm: bool)[source]
                                                                                                                          +class sparseml.tensorflow_v1.models.classification.vgg.VGGSection(num_blocks: int, out_channels: int, use_batchnorm: bool)[source]

                                                                                                                          Bases: object

                                                                                                                          Settings to describe how to put together a VGG architecture using user supplied configurations.

                                                                                                                          @@ -706,7 +706,7 @@

                                                                                                                          Submodules
                                                                                                                          -create(name: str, x_tens: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor], kernel_initializer, bias_initializer, beta_initializer, gamma_initializer) → tensorflow.python.framework.ops.Tensor[source]
                                                                                                                          +create(name: str, x_tens: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor], kernel_initializer, bias_initializer, beta_initializer, gamma_initializer)tensorflow.python.framework.ops.Tensor[source]

                                                                                                                          Create the section in the current graph and scope

                                                                                                                          Parameters
                                                                                                                          @@ -732,7 +732,7 @@

                                                                                                                          Submodules
                                                                                                                          -sparseml.tensorflow_v1.models.classification.vgg.vgg11(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: Optional[str] = None, kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>) → tensorflow.python.framework.ops.Tensor[source]
                                                                                                                          +sparseml.tensorflow_v1.models.classification.vgg.vgg11(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: Optional[str] = None, kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>)tensorflow.python.framework.ops.Tensor[source]

                                                                                                                          Standard VGG 11 implementation; expected input shape is (B, 224, 224, 3)

                                                                                                                          @@ -759,7 +759,7 @@

                                                                                                                          Submodules
                                                                                                                          -sparseml.tensorflow_v1.models.classification.vgg.vgg11bn(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: Optional[str] = None, kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>) → tensorflow.python.framework.ops.Tensor[source]
                                                                                                                          +sparseml.tensorflow_v1.models.classification.vgg.vgg11bn(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: Optional[str] = None, kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>)tensorflow.python.framework.ops.Tensor[source]

                                                                                                                          Standard VGG 11 batch normalized implementation; expected input shape is (B, 224, 224, 3)

                                                                                                                          @@ -786,7 +786,7 @@

                                                                                                                          Submodules
                                                                                                                          -sparseml.tensorflow_v1.models.classification.vgg.vgg13(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: Optional[str] = None, kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>) → tensorflow.python.framework.ops.Tensor[source]
                                                                                                                          +sparseml.tensorflow_v1.models.classification.vgg.vgg13(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: Optional[str] = None, kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>)tensorflow.python.framework.ops.Tensor[source]

                                                                                                                          Standard VGG 13 implementation; expected input shape is (B, 224, 224, 3)

                                                                                                                          @@ -813,7 +813,7 @@

                                                                                                                          Submodules
                                                                                                                          -sparseml.tensorflow_v1.models.classification.vgg.vgg13bn(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: Optional[str] = None, kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>) → tensorflow.python.framework.ops.Tensor[source]
                                                                                                                          +sparseml.tensorflow_v1.models.classification.vgg.vgg13bn(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: Optional[str] = None, kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>)tensorflow.python.framework.ops.Tensor[source]

                                                                                                                          Standard VGG 13 batch normalized implementation; expected input shape is (B, 224, 224, 3)

                                                                                                                          @@ -840,7 +840,7 @@

                                                                                                                          Submodules
                                                                                                                          -sparseml.tensorflow_v1.models.classification.vgg.vgg16(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: Optional[str] = None, kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>) → tensorflow.python.framework.ops.Tensor[source]
                                                                                                                          +sparseml.tensorflow_v1.models.classification.vgg.vgg16(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: Optional[str] = None, kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>)tensorflow.python.framework.ops.Tensor[source]

                                                                                                                          Standard VGG 16 implementation; expected input shape is (B, 224, 224, 3)

                                                                                                                          @@ -867,7 +867,7 @@

                                                                                                                          Submodules
                                                                                                                          -sparseml.tensorflow_v1.models.classification.vgg.vgg16bn(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: Optional[str] = None, kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>) → tensorflow.python.framework.ops.Tensor[source]
                                                                                                                          +sparseml.tensorflow_v1.models.classification.vgg.vgg16bn(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: Optional[str] = None, kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>)tensorflow.python.framework.ops.Tensor[source]

                                                                                                                          Standard VGG 16 batch normalized implementation; expected input shape is (B, 224, 224, 3)

                                                                                                                          @@ -894,7 +894,7 @@

                                                                                                                          Submodules
                                                                                                                          -sparseml.tensorflow_v1.models.classification.vgg.vgg19(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: Optional[str] = None, kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>) → tensorflow.python.framework.ops.Tensor[source]
                                                                                                                          +sparseml.tensorflow_v1.models.classification.vgg.vgg19(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: Optional[str] = None, kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>)tensorflow.python.framework.ops.Tensor[source]

                                                                                                                          Standard VGG 19 implementation; expected input shape is (B, 224, 224, 3)

                                                                                                                          @@ -921,7 +921,7 @@

                                                                                                                          Submodules
                                                                                                                          -sparseml.tensorflow_v1.models.classification.vgg.vgg19bn(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: Optional[str] = None, kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>) → tensorflow.python.framework.ops.Tensor[source]
                                                                                                                          +sparseml.tensorflow_v1.models.classification.vgg.vgg19bn(inputs: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor] = True, num_classes: int = 1000, class_type: Optional[str] = None, kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>)tensorflow.python.framework.ops.Tensor[source]

                                                                                                                          Standard VGG 19 batch normalized implementation; expected input shape is (B, 224, 224, 3)

                                                                                                                          @@ -948,7 +948,7 @@

                                                                                                                          Submodules
                                                                                                                          -sparseml.tensorflow_v1.models.classification.vgg.vgg_const(x_tens: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor], sec_settings: List[sparseml.tensorflow_v1.models.classification.vgg.VGGSection], num_classes: int, class_type: str, kernel_initializer, bias_initializer, beta_initializer, gamma_initializer) → tensorflow.python.framework.ops.Tensor[source]
                                                                                                                          +sparseml.tensorflow_v1.models.classification.vgg.vgg_const(x_tens: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor], sec_settings: List[sparseml.tensorflow_v1.models.classification.vgg.VGGSection], num_classes: int, class_type: str, kernel_initializer, bias_initializer, beta_initializer, gamma_initializer)tensorflow.python.framework.ops.Tensor[source]

                                                                                                                          Graph constructor for VGG implementation.

                                                                                                                          Parameters
                                                                                                                          diff --git a/sparseml/api/sparseml.tensorflow_v1.models.html b/sparseml/api/sparseml.tensorflow_v1.models.html index b90a20397ca..b20460b2dae 100644 --- a/sparseml/api/sparseml.tensorflow_v1.models.html +++ b/sparseml/api/sparseml.tensorflow_v1.models.html @@ -227,12 +227,12 @@

                                                                                                                          Submodules
                                                                                                                          -class sparseml.tensorflow_v1.models.estimator.ClassificationEstimatorModelFn[source]
                                                                                                                          +class sparseml.tensorflow_v1.models.estimator.ClassificationEstimatorModelFn[source]

                                                                                                                          Bases: sparseml.tensorflow_v1.models.estimator.EstimatorModelFn

                                                                                                                          Model function creator for classification models

                                                                                                                          -create_loss(net_outputs: Union[tensorflow.python.framework.ops.Tensor, Dict[str, tensorflow.python.framework.ops.Tensor]], labels: Union[tensorflow.python.framework.ops.Tensor, Dict[str, tensorflow.python.framework.ops.Tensor]], params: Dict[str, Any]) → tensorflow.python.framework.ops.Tensor[source]
                                                                                                                          +create_loss(net_outputs: Union[tensorflow.python.framework.ops.Tensor, Dict[str, tensorflow.python.framework.ops.Tensor]], labels: Union[tensorflow.python.framework.ops.Tensor, Dict[str, tensorflow.python.framework.ops.Tensor]], params: Dict[str, Any])tensorflow.python.framework.ops.Tensor[source]

                                                                                                                          Create loss function

                                                                                                                          Parameters
                                                                                                                          @@ -250,7 +250,7 @@

                                                                                                                          Submodules
                                                                                                                          -create_metric_update_ops_hook(metrics_dict: Dict[str, Tuple[tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Operation]], metrics_initializers_dict: Dict[str, List[tensorflow.python.framework.ops.Tensor]], params: Dict[str, Any]) → sparseml.tensorflow_v1.models.estimator.MetricUpdateOpsHook[source]
                                                                                                                          +create_metric_update_ops_hook(metrics_dict: Dict[str, Tuple[tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Operation]], metrics_initializers_dict: Dict[str, List[tensorflow.python.framework.ops.Tensor]], params: Dict[str, Any])sparseml.tensorflow_v1.models.estimator.MetricUpdateOpsHook[source]

                                                                                                                          Create hooks for the update operations of the collected metrics

                                                                                                                          Parameters
                                                                                                                          @@ -268,7 +268,7 @@

                                                                                                                          Submodules
                                                                                                                          -create_metrics(net_outputs: Union[tensorflow.python.framework.ops.Tensor, Dict[str, tensorflow.python.framework.ops.Tensor]], labels: Union[tensorflow.python.framework.ops.Tensor, Dict[str, tensorflow.python.framework.ops.Tensor]], params: Dict[str, Any])[source]
                                                                                                                          +create_metrics(net_outputs: Union[tensorflow.python.framework.ops.Tensor, Dict[str, tensorflow.python.framework.ops.Tensor]], labels: Union[tensorflow.python.framework.ops.Tensor, Dict[str, tensorflow.python.framework.ops.Tensor]], params: Dict[str, Any])[source]

                                                                                                                          Create metrics for evaluation

                                                                                                                          Parameters
                                                                                                                          @@ -286,7 +286,7 @@

                                                                                                                          Submodules
                                                                                                                          -create_modifier_ops_and_update_hook(params: Dict[str, Any]) -> (<class 'sparseml.tensorflow_v1.optim.manager.ScheduledModifierManager'>, <class 'sparseml.tensorflow_v1.optim.modifier.ModifierSessionRunHook'>)[source]
                                                                                                                          +create_modifier_ops_and_update_hook(params: Dict[str, Any]) -> (<class 'sparseml.tensorflow_v1.optim.manager.ScheduledModifierManager'>, <class 'sparseml.tensorflow_v1.optim.modifier.ModifierSessionRunHook'>)[source]

                                                                                                                          Create modifier ops and their update hook to run

                                                                                                                          Parameters
                                                                                                                          @@ -300,7 +300,7 @@

                                                                                                                          Submodules
                                                                                                                          -create_predictions(net_outputs: Union[tensorflow.python.framework.ops.Tensor, Dict[str, tensorflow.python.framework.ops.Tensor]], params: Dict[str, Any]) → Dict[str, Any][source]
                                                                                                                          +create_predictions(net_outputs: Union[tensorflow.python.framework.ops.Tensor, Dict[str, tensorflow.python.framework.ops.Tensor]], params: Dict[str, Any])Dict[str, Any][source]

                                                                                                                          Create predictions used to define the estimator spec in prediction mode

                                                                                                                          Parameters
                                                                                                                          @@ -317,7 +317,7 @@

                                                                                                                          Submodules
                                                                                                                          -create_scaffold(modifier_manager: sparseml.tensorflow_v1.optim.manager.ScheduledModifierManager, params: Dict[str, Any]) → tensorflow.python.training.monitored_session.Scaffold[source]
                                                                                                                          +create_scaffold(modifier_manager: sparseml.tensorflow_v1.optim.manager.ScheduledModifierManager, params: Dict[str, Any])tensorflow.python.training.monitored_session.Scaffold[source]

                                                                                                                          Create scaffold to be attached to the train estimator spec, containing at least the saver

                                                                                                                          @@ -332,13 +332,13 @@

                                                                                                                          Submodules
                                                                                                                          -create_summary_op(metrics_dict: Dict[str, Tuple[tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Operation]], params: Dict[str, Any])[source]
                                                                                                                          +create_summary_op(metrics_dict: Dict[str, Tuple[tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Operation]], params: Dict[str, Any])[source]

                                                                                                                          Create summary op given metric dictionary

                                                                                                                          -create_train_summary_hook(metrics_dict: Dict[str, Tuple[tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Operation]], params: Dict[str, Any]) → tensorflow.python.training.basic_session_run_hooks.SummarySaverHook[source]
                                                                                                                          +create_train_summary_hook(metrics_dict: Dict[str, Tuple[tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Operation]], params: Dict[str, Any])tensorflow.python.training.basic_session_run_hooks.SummarySaverHook[source]

                                                                                                                          Create hook for the summary of metrics

                                                                                                                          Parameters
                                                                                                                          @@ -356,7 +356,7 @@

                                                                                                                          Submodules
                                                                                                                          -create_training_op(loss: tensorflow.python.framework.ops.Tensor, params: Dict[str, Any]) → tensorflow.python.framework.ops.Operation[source]
                                                                                                                          +create_training_op(loss: tensorflow.python.framework.ops.Tensor, params: Dict[str, Any])tensorflow.python.framework.ops.Operation[source]

                                                                                                                          Create training op for optimization

                                                                                                                          Parameters
                                                                                                                          @@ -375,12 +375,12 @@

                                                                                                                          Submodules
                                                                                                                          -class sparseml.tensorflow_v1.models.estimator.EstimatorModelFn[source]
                                                                                                                          +class sparseml.tensorflow_v1.models.estimator.EstimatorModelFn[source]

                                                                                                                          Bases: abc.ABC

                                                                                                                          Base class for model function creator

                                                                                                                          -create(model_const: Callable, *args, **kwargs)[source]
                                                                                                                          +create(model_const: Callable, *args, **kwargs)[source]

                                                                                                                          Create a model function to be used to create estimator

                                                                                                                          Parameters
                                                                                                                          @@ -395,7 +395,7 @@

                                                                                                                          Submodules
                                                                                                                          -abstract create_loss(net_outputs: Union[tensorflow.python.framework.ops.Tensor, Dict[str, tensorflow.python.framework.ops.Tensor]], labels: Union[tensorflow.python.framework.ops.Tensor, Dict[str, tensorflow.python.framework.ops.Tensor]], params: Dict[str, Any]) → tensorflow.python.framework.ops.Tensor[source]
                                                                                                                          +abstract create_loss(net_outputs: Union[tensorflow.python.framework.ops.Tensor, Dict[str, tensorflow.python.framework.ops.Tensor]], labels: Union[tensorflow.python.framework.ops.Tensor, Dict[str, tensorflow.python.framework.ops.Tensor]], params: Dict[str, Any])tensorflow.python.framework.ops.Tensor[source]

                                                                                                                          Create loss function

                                                                                                                          Parameters
                                                                                                                          @@ -413,7 +413,7 @@

                                                                                                                          Submodules
                                                                                                                          -abstract create_metric_update_ops_hook(metrics_dict: Dict[str, Tuple[tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Operation]], metrics_initializers_dict: Dict[str, List[tensorflow.python.framework.ops.Tensor]], params: Dict[str, Any]) → sparseml.tensorflow_v1.models.estimator.MetricUpdateOpsHook[source]
                                                                                                                          +abstract create_metric_update_ops_hook(metrics_dict: Dict[str, Tuple[tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Operation]], metrics_initializers_dict: Dict[str, List[tensorflow.python.framework.ops.Tensor]], params: Dict[str, Any])sparseml.tensorflow_v1.models.estimator.MetricUpdateOpsHook[source]

                                                                                                                          Create hooks for the update operations of the collected metrics

                                                                                                                          Parameters
                                                                                                                          @@ -431,7 +431,7 @@

                                                                                                                          Submodules
                                                                                                                          -abstract create_metrics(net_outputs: Union[tensorflow.python.framework.ops.Tensor, Dict[str, tensorflow.python.framework.ops.Tensor]], labels: Union[tensorflow.python.framework.ops.Tensor, Dict[str, tensorflow.python.framework.ops.Tensor]], params: Dict[str, Any])[source]
                                                                                                                          +abstract create_metrics(net_outputs: Union[tensorflow.python.framework.ops.Tensor, Dict[str, tensorflow.python.framework.ops.Tensor]], labels: Union[tensorflow.python.framework.ops.Tensor, Dict[str, tensorflow.python.framework.ops.Tensor]], params: Dict[str, Any])[source]

                                                                                                                          Create metrics for evaluation

                                                                                                                          Parameters
                                                                                                                          @@ -453,7 +453,7 @@

                                                                                                                          Submodules
                                                                                                                          -abstract create_modifier_ops_and_update_hook(params: Dict[str, Any]) -> (<class 'sparseml.tensorflow_v1.optim.manager.ScheduledModifierManager'>, <class 'sparseml.tensorflow_v1.optim.modifier.ModifierSessionRunHook'>)[source]
                                                                                                                          +abstract create_modifier_ops_and_update_hook(params: Dict[str, Any]) -> (<class 'sparseml.tensorflow_v1.optim.manager.ScheduledModifierManager'>, <class 'sparseml.tensorflow_v1.optim.modifier.ModifierSessionRunHook'>)[source]

                                                                                                                          Create modifier ops and their update hook to run

                                                                                                                          Parameters
                                                                                                                          @@ -467,7 +467,7 @@

                                                                                                                          Submodules
                                                                                                                          -abstract create_predictions(net_outputs: Union[tensorflow.python.framework.ops.Tensor, Dict[str, tensorflow.python.framework.ops.Tensor]], params: Dict[str, Any]) → Dict[str, Any][source]
                                                                                                                          +abstract create_predictions(net_outputs: Union[tensorflow.python.framework.ops.Tensor, Dict[str, tensorflow.python.framework.ops.Tensor]], params: Dict[str, Any])Dict[str, Any][source]

                                                                                                                          Create predictions used to define the estimator spec in prediction mode

                                                                                                                          Parameters
                                                                                                                          @@ -485,7 +485,7 @@

                                                                                                                          Submodules
                                                                                                                          -abstract create_scaffold(modifier_manager: sparseml.tensorflow_v1.optim.manager.ScheduledModifierManager, params: Dict[str, Any]) → tensorflow.python.training.monitored_session.Scaffold[source]
                                                                                                                          +abstract create_scaffold(modifier_manager: sparseml.tensorflow_v1.optim.manager.ScheduledModifierManager, params: Dict[str, Any])tensorflow.python.training.monitored_session.Scaffold[source]

                                                                                                                          Create scaffold to be attached to the train estimator spec, containing at least the saver

                                                                                                                          @@ -500,7 +500,7 @@

                                                                                                                          Submodules
                                                                                                                          -abstract create_train_summary_hook(metrics_dict: Dict[str, Tuple[tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Operation]], params: Dict[str, Any]) → tensorflow.python.training.basic_session_run_hooks.SummarySaverHook[source]
                                                                                                                          +abstract create_train_summary_hook(metrics_dict: Dict[str, Tuple[tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Operation]], params: Dict[str, Any])tensorflow.python.training.basic_session_run_hooks.SummarySaverHook[source]

                                                                                                                          Create hook for the summary of metrics

                                                                                                                          Parameters
                                                                                                                          @@ -518,7 +518,7 @@

                                                                                                                          Submodules
                                                                                                                          -abstract create_training_op(loss: tensorflow.python.framework.ops.Tensor, params: Dict[str, Any]) → tensorflow.python.framework.ops.Operation[source]
                                                                                                                          +abstract create_training_op(loss: tensorflow.python.framework.ops.Tensor, params: Dict[str, Any])tensorflow.python.framework.ops.Operation[source]

                                                                                                                          Create training op for optimization

                                                                                                                          Parameters
                                                                                                                          @@ -541,12 +541,12 @@

                                                                                                                          Submodules
                                                                                                                          -class sparseml.tensorflow_v1.models.registry.ModelRegistry[source]
                                                                                                                          +class sparseml.tensorflow_v1.models.registry.ModelRegistry[source]

                                                                                                                          Bases: object

                                                                                                                          Registry class for creating models

                                                                                                                          -static available_keys() → List[str][source]
                                                                                                                          +static available_keys()List[str][source]
                                                                                                                          Returns

                                                                                                                          the keys (models) currently available in the registry

                                                                                                                          @@ -556,7 +556,7 @@

                                                                                                                          Submodules
                                                                                                                          -static create(key: str, *args, **kwargs) → Any[source]
                                                                                                                          +static create(key: str, *args, **kwargs)Any[source]

                                                                                                                          Create a new model for the given key

                                                                                                                          Parameters
                                                                                                                          @@ -574,7 +574,7 @@

                                                                                                                          Submodules
                                                                                                                          -static create_estimator(key: str, model_dir: str, model_fn_params: Optional[Dict[str, Any]], run_config: tensorflow_estimator.python.estimator.run_config.RunConfig, *args, **kwargs) → tensorflow_estimator.python.estimator.estimator.Estimator[source]
                                                                                                                          +static create_estimator(key: str, model_dir: str, model_fn_params: Optional[Dict[str, Any]], run_config: tensorflow_estimator.python.estimator.run_config.RunConfig, *args, **kwargs)tensorflow_estimator.python.estimator.estimator.Estimator[source]

                                                                                                                          Create Estimator for a model given the key and extra parameters

                                                                                                                          Parameters
                                                                                                                          @@ -595,7 +595,7 @@

                                                                                                                          Submodules
                                                                                                                          -static create_zoo_model(key: str, pretrained: Union[bool, str] = True, pretrained_dataset: Optional[str] = None) → sparsezoo.objects.model.Model[source]
                                                                                                                          +static create_zoo_model(key: str, pretrained: Union[bool, str] = True, pretrained_dataset: Optional[str] = None)sparsezoo.objects.model.Model[source]

                                                                                                                          Create a sparsezoo Model for the desired model in the zoo

                                                                                                                          Parameters
                                                                                                                          @@ -615,7 +615,7 @@

                                                                                                                          Submodules
                                                                                                                          -static input_shape(key: str)[source]
                                                                                                                          +static input_shape(key: str)[source]
                                                                                                                          Parameters

                                                                                                                          key – the model key (name) to create

                                                                                                                          @@ -628,7 +628,7 @@

                                                                                                                          Submodules
                                                                                                                          -static load_pretrained(key: str, pretrained: Union[bool, str] = True, pretrained_dataset: Optional[str] = None, pretrained_path: Optional[str] = None, remove_dynamic_tl_vars: bool = False, sess: Optional[tensorflow.python.client.session.Session] = None, saver: Optional[tensorflow.python.training.saver.Saver] = None)[source]
                                                                                                                          +static load_pretrained(key: str, pretrained: Union[bool, str] = True, pretrained_dataset: Optional[str] = None, pretrained_path: Optional[str] = None, remove_dynamic_tl_vars: bool = False, sess: Optional[tensorflow.python.client.session.Session] = None, saver: Optional[tensorflow.python.training.saver.Saver] = None)[source]

                                                                                                                          Load pre-trained variables for a given model into a session. Uses a Saver object from TensorFlow to restore the variables from an index and data file.

                                                                                                                          @@ -663,7 +663,7 @@

                                                                                                                          Submodules
                                                                                                                          -static register(key: Union[str, List[str]], input_shape: Any, domain: str, sub_domain: str, architecture: str, sub_architecture: str, default_dataset: str, default_desc: str, default_model_fn_creator: sparseml.tensorflow_v1.models.estimator.EstimatorModelFn, base_name_scope: str, tl_ignore_tens: List[str], repo_source: str = 'sparseml')[source]
                                                                                                                          +static register(key: Union[str, List[str]], input_shape: Any, domain: str, sub_domain: str, architecture: str, sub_architecture: str, default_dataset: str, default_desc: str, default_model_fn_creator: sparseml.tensorflow_v1.models.estimator.EstimatorModelFn, base_name_scope: str, tl_ignore_tens: List[str], repo_source: str = 'sparseml')[source]

                                                                                                                          Register a model with the registry. Should be used as a decorator

                                                                                                                          Parameters
                                                                                                                          @@ -697,7 +697,7 @@

                                                                                                                          Submodules
                                                                                                                          -static saver(key: str, remove_dynamic_tl_vars: bool = False) → tensorflow.python.training.saver.Saver[source]
                                                                                                                          +static saver(key: str, remove_dynamic_tl_vars: bool = False)tensorflow.python.training.saver.Saver[source]

                                                                                                                          Get a tf compat saver that contains only the variables for the desired architecture specified by key. Note, the architecture must have been created in the current graph already diff --git a/sparseml/api/sparseml.tensorflow_v1.nn.html b/sparseml/api/sparseml.tensorflow_v1.nn.html index e8636a9c71e..a0157a776f3 100644 --- a/sparseml/api/sparseml.tensorflow_v1.nn.html +++ b/sparseml/api/sparseml.tensorflow_v1.nn.html @@ -209,7 +209,7 @@

                                                                                                                          Submodules

                                                                                                                          sparseml.tensorflow_v1.nn.layers module

                                                                                                                          -sparseml.tensorflow_v1.nn.layers.activation(x_tens: tensorflow.python.framework.ops.Tensor, act: Union[None, str], name: str = 'act')[source]
                                                                                                                          +sparseml.tensorflow_v1.nn.layers.activation(x_tens: tensorflow.python.framework.ops.Tensor, act: Union[None, str], name: str = 'act')[source]

                                                                                                                          Create an activation operation in the current graph and scope.

                                                                                                                          Parameters
                                                                                                                          @@ -228,7 +228,7 @@

                                                                                                                          Submodules
                                                                                                                          -sparseml.tensorflow_v1.nn.layers.conv2d(name: str, x_tens: tensorflow.python.framework.ops.Tensor, in_chan: int, out_chan: int, kernel: int, stride: int, padding: str, act: Optional[str] = None)[source]
                                                                                                                          +sparseml.tensorflow_v1.nn.layers.conv2d(name: str, x_tens: tensorflow.python.framework.ops.Tensor, in_chan: int, out_chan: int, kernel: int, stride: int, padding: str, act: Optional[str] = None)[source]

                                                                                                                          Create a convolutional layer with the proper ops and variables.

                                                                                                                          Parameters
                                                                                                                          @@ -252,7 +252,7 @@

                                                                                                                          Submodules
                                                                                                                          -sparseml.tensorflow_v1.nn.layers.conv2d_block(name: str, x_tens: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor], channels: int, kernel_size: int, padding: Union[str, int, Tuple[int, ...]] = 'same', stride: int = 1, data_format: str = 'channels_last', include_bn: bool = True, include_bias: Optional[bool] = None, act: Union[None, str] = 'relu', kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>)[source]
                                                                                                                          +sparseml.tensorflow_v1.nn.layers.conv2d_block(name: str, x_tens: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor], channels: int, kernel_size: int, padding: Union[str, int, Tuple[int, ...]] = 'same', stride: int = 1, data_format: str = 'channels_last', include_bn: bool = True, include_bias: Optional[bool] = None, act: Union[None, str] = 'relu', kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>)[source]

                                                                                                                          Create a convolution op and supporting ops (batch norm, activation, etc) in the current graph and scope.

                                                                                                                          @@ -292,7 +292,7 @@

                                                                                                                          Submodules
                                                                                                                          -sparseml.tensorflow_v1.nn.layers.dense_block(name: str, x_tens: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor], channels: int, include_bn: bool = False, include_bias: Optional[bool] = None, dropout_rate: Optional[float] = None, act: Union[None, str] = 'relu', kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>)[source]
                                                                                                                          +sparseml.tensorflow_v1.nn.layers.dense_block(name: str, x_tens: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor], channels: int, include_bn: bool = False, include_bias: Optional[bool] = None, dropout_rate: Optional[float] = None, act: Union[None, str] = 'relu', kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>)[source]

                                                                                                                          Create a dense or fully connected op and supporting ops (batch norm, activation, etc) in the current graph and scope.

                                                                                                                          @@ -329,7 +329,7 @@

                                                                                                                          Submodules
                                                                                                                          -sparseml.tensorflow_v1.nn.layers.depthwise_conv2d_block(name: str, x_tens: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor], channels: int, kernel_size: int, padding: Union[str, int, Tuple[int, ...]] = 'same', stride: int = 1, data_format: str = 'channels_last', include_bn: bool = True, include_bias: Optional[bool] = None, act: Union[None, str] = 'relu', kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>)[source]
                                                                                                                          +sparseml.tensorflow_v1.nn.layers.depthwise_conv2d_block(name: str, x_tens: tensorflow.python.framework.ops.Tensor, training: Union[bool, tensorflow.python.framework.ops.Tensor], channels: int, kernel_size: int, padding: Union[str, int, Tuple[int, ...]] = 'same', stride: int = 1, data_format: str = 'channels_last', include_bn: bool = True, include_bias: Optional[bool] = None, act: Union[None, str] = 'relu', kernel_initializer=<tensorflow.python.ops.init_ops.GlorotUniform object>, bias_initializer=<tensorflow.python.ops.init_ops.Zeros object>, beta_initializer=<tensorflow.python.ops.init_ops.Zeros object>, gamma_initializer=<tensorflow.python.ops.init_ops.Ones object>)[source]

                                                                                                                          Create a depthwise convolution op and supporting ops (batch norm, activation, etc) in the current graph and scope.

                                                                                                                          @@ -369,7 +369,7 @@

                                                                                                                          Submodules
                                                                                                                          -sparseml.tensorflow_v1.nn.layers.fc(name: str, x_tens: tensorflow.python.framework.ops.Tensor, in_chan: int, out_chan: int, act: Optional[str] = None)[source]
                                                                                                                          +sparseml.tensorflow_v1.nn.layers.fc(name: str, x_tens: tensorflow.python.framework.ops.Tensor, in_chan: int, out_chan: int, act: Optional[str] = None)[source]

                                                                                                                          Create a fully connected layer with the proper ops and variables.

                                                                                                                          Parameters
                                                                                                                          @@ -390,7 +390,7 @@

                                                                                                                          Submodules
                                                                                                                          -sparseml.tensorflow_v1.nn.layers.pool2d(name: str, x_tens: tensorflow.python.framework.ops.Tensor, type_: str, pool_size: Union[int, Tuple[int, int]], strides: Union[int, Tuple[int, int]] = 1, padding: Union[str, int, Tuple[int, ]] = 'same', data_format: str = 'channels_last')[source]
                                                                                                                          +sparseml.tensorflow_v1.nn.layers.pool2d(name: str, x_tens: tensorflow.python.framework.ops.Tensor, type_: str, pool_size: Union[int, Tuple[int, int]], strides: Union[int, Tuple[int, int]] = 1, padding: Union[str, int, Tuple[int, ]] = 'same', data_format: str = 'channels_last')[source]

                                                                                                                          Create a pool op with the given name in the current graph and scope. Supported are [max, avg, global_avg]

                                                                                                                          diff --git a/sparseml/api/sparseml.tensorflow_v1.optim.html b/sparseml/api/sparseml.tensorflow_v1.optim.html index ada6b6ef53e..7ee289b0570 100644 --- a/sparseml/api/sparseml.tensorflow_v1.optim.html +++ b/sparseml/api/sparseml.tensorflow_v1.optim.html @@ -209,7 +209,7 @@

                                                                                                                          Submodules

                                                                                                                          sparseml.tensorflow_v1.optim.analyzer_module module

                                                                                                                          -sparseml.tensorflow_v1.optim.analyzer_module.analyze_module(session: Optional[tensorflow.python.client.session.Session], graph: Optional[tensorflow.python.framework.ops.Graph], op_names: Optional[List[str]] = None, op_types: Optional[List[str]] = None)[source]
                                                                                                                          +sparseml.tensorflow_v1.optim.analyzer_module.analyze_module(session: Optional[tensorflow.python.client.session.Session], graph: Optional[tensorflow.python.framework.ops.Graph], op_names: Optional[List[str]] = None, op_types: Optional[List[str]] = None)[source]

                                                                                                                          Analyze a module at certain layers

                                                                                                                          Parameters
                                                                                                                          @@ -236,7 +236,7 @@

                                                                                                                          Submodules
                                                                                                                          -class sparseml.tensorflow_v1.optim.manager.ScheduledModifierManager(modifiers: List[sparseml.tensorflow_v1.optim.modifier.ScheduledModifier])[source]
                                                                                                                          +class sparseml.tensorflow_v1.optim.manager.ScheduledModifierManager(modifiers: List[sparseml.tensorflow_v1.optim.modifier.ScheduledModifier])[source]

                                                                                                                          Bases: sparseml.optim.manager.BaseManager, sparseml.tensorflow_v1.optim.modifier.Modifier

                                                                                                                          The base modifier manager, handles managing multiple ScheduledModifier.

                                                                                                                          @@ -264,12 +264,12 @@

                                                                                                                          Submodules
                                                                                                                          -RECAL_UPDATE = 'recal_update'
                                                                                                                          +RECAL_UPDATE = 'recal_update'

                                                                                                                          -complete_graph(graph: Optional[tensorflow.python.framework.ops.Graph] = None, sess: Optional[tensorflow.python.client.session.Session] = None)[source]
                                                                                                                          +complete_graph(graph: Optional[tensorflow.python.framework.ops.Graph] = None, sess: Optional[tensorflow.python.client.session.Session] = None)[source]

                                                                                                                          Complete modifying the graph. Should be called after modifying is complete. Cleans up any ops that should be removed or reordered.

                                                                                                                          @@ -289,7 +289,7 @@

                                                                                                                          Submodules
                                                                                                                          -create_ops(steps_per_epoch: int, global_step: Optional[tensorflow.python.framework.ops.Tensor] = None, graph: Optional[tensorflow.python.framework.ops.Graph] = None) → Tuple[List[Union[tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Operation]], Dict[str, Any]][source]
                                                                                                                          +create_ops(steps_per_epoch: int, global_step: Optional[tensorflow.python.framework.ops.Tensor] = None, graph: Optional[tensorflow.python.framework.ops.Graph] = None)Tuple[List[Union[tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Operation]], Dict[str, Any]][source]

                                                                                                                          Create modifying operations and tensors in the graph.

                                                                                                                          Returns a tuple containing:
                                                                                                                          @@ -320,7 +320,7 @@

                                                                                                                          Submodules
                                                                                                                          -static from_yaml(file_path: Union[str, sparsezoo.objects.optimization_recipe.OptimizationRecipe], add_modifiers: Optional[List[sparseml.tensorflow_v1.optim.modifier.Modifier]] = None)[source]
                                                                                                                          +static from_yaml(file_path: Union[str, sparsezoo.objects.optimization_recipe.OptimizationRecipe], add_modifiers: Optional[List[sparseml.tensorflow_v1.optim.modifier.Modifier]] = None)[source]

                                                                                                                          Convenience function used to create the manager of multiple modifiers from a recipe file.

                                                                                                                          @@ -344,7 +344,7 @@

                                                                                                                          Submodules
                                                                                                                          -initialize_session(sess: Optional[tensorflow.python.client.session.Session] = None)[source]
                                                                                                                          +initialize_session(sess: Optional[tensorflow.python.client.session.Session] = None)[source]

                                                                                                                          Initialize any state for a session such as variables. This is an optional call, only needed if global_variables_initializer is not used.

                                                                                                                          @@ -357,7 +357,7 @@

                                                                                                                          Submodules
                                                                                                                          -modifiers_to_string_lines(modifiers: List[sparseml.optim.modifier.BaseScheduled]) → List[str][source]
                                                                                                                          +modifiers_to_string_lines(modifiers: List[sparseml.optim.modifier.BaseScheduled])List[str][source]
                                                                                                                          Parameters

                                                                                                                          modifiers – ignored and overwritten with the original @@ -378,7 +378,7 @@

                                                                                                                          Submodules
                                                                                                                          -class sparseml.tensorflow_v1.optim.mask_creator_pruning.BlockPruningMaskCreator(block_shape: List[int], grouping_op_name: str = 'mean')[source]
                                                                                                                          +class sparseml.tensorflow_v1.optim.mask_creator_pruning.BlockPruningMaskCreator(block_shape: List[int], grouping_op_name: str = 'mean')[source]

                                                                                                                          Bases: sparseml.tensorflow_v1.optim.mask_creator_pruning.GroupedPruningMaskCreator

                                                                                                                          Structured sparsity mask creator that groups the input tensor into blocks of shape block_shape. @@ -392,7 +392,7 @@

                                                                                                                          Submodules
                                                                                                                          -group_tensor(tensor: tensorflow.python.framework.ops.Tensor) → tensorflow.python.framework.ops.Tensor[source]
                                                                                                                          +group_tensor(tensor: tensorflow.python.framework.ops.Tensor)tensorflow.python.framework.ops.Tensor[source]
                                                                                                                          Parameters

                                                                                                                          tensor – The tensor to transform

                                                                                                                          @@ -408,7 +408,7 @@

                                                                                                                          Submodules
                                                                                                                          -class sparseml.tensorflow_v1.optim.mask_creator_pruning.DimensionPruningMaskCreator(dim: Union[str, int, List[int]], grouping_op_name: str = 'mean')[source]
                                                                                                                          +class sparseml.tensorflow_v1.optim.mask_creator_pruning.DimensionPruningMaskCreator(dim: Union[str, int, List[int]], grouping_op_name: str = 'mean')[source]

                                                                                                                          Bases: sparseml.tensorflow_v1.optim.mask_creator_pruning.GroupedPruningMaskCreator

                                                                                                                          Structured sparsity mask creator that groups sparsity blocks by the given dimension(s)

                                                                                                                          @@ -420,7 +420,7 @@

                                                                                                                          Submodules
                                                                                                                          -group_tensor(tensor: tensorflow.python.framework.ops.Tensor) → tensorflow.python.framework.ops.Tensor[source]
                                                                                                                          +group_tensor(tensor: tensorflow.python.framework.ops.Tensor)tensorflow.python.framework.ops.Tensor[source]
                                                                                                                          Parameters

                                                                                                                          tensor – The tensor to transform

                                                                                                                          @@ -436,14 +436,14 @@

                                                                                                                          Submodules
                                                                                                                          -class sparseml.tensorflow_v1.optim.mask_creator_pruning.GroupedPruningMaskCreator[source]
                                                                                                                          +class sparseml.tensorflow_v1.optim.mask_creator_pruning.GroupedPruningMaskCreator[source]

                                                                                                                          Bases: sparseml.tensorflow_v1.optim.mask_creator_pruning.UnstructuredPruningMaskCreator

                                                                                                                          Abstract class for a sparsity mask creator that structures masks according to grouping functions. Subclasses should implement group_tensor and _map_mask_to_tensor

                                                                                                                          -create_sparsity_mask(tensor: tensorflow.python.framework.ops.Tensor, sparsity: tensorflow.python.framework.ops.Tensor) → tensorflow.python.framework.ops.Tensor[source]
                                                                                                                          +create_sparsity_mask(tensor: tensorflow.python.framework.ops.Tensor, sparsity: tensorflow.python.framework.ops.Tensor)tensorflow.python.framework.ops.Tensor[source]
                                                                                                                          Parameters
                                                                                                                            @@ -460,7 +460,7 @@

                                                                                                                            Submodules
                                                                                                                            -static get_grouping_op(grouping_op_name: str) → tensorflow.python.framework.ops.Operation[source]
                                                                                                                            +static get_grouping_op(grouping_op_name: str)tensorflow.python.framework.ops.Operation[source]
                                                                                                                            Parameters

                                                                                                                            grouping_op_name – name of grouping operation to get tf operation for

                                                                                                                            @@ -473,7 +473,7 @@

                                                                                                                            Submodules
                                                                                                                            -get_mask_initializer(tensor: tensorflow.python.framework.ops.Tensor) → Callable[tensorflow.python.framework.ops.Tensor][source]
                                                                                                                            +get_mask_initializer(tensor: tensorflow.python.framework.ops.Tensor)Callable[tensorflow.python.framework.ops.Tensor][source]
                                                                                                                            Parameters

                                                                                                                            tensor – A tensor of a model layer’s weights

                                                                                                                            @@ -486,7 +486,7 @@

                                                                                                                            Submodules
                                                                                                                            -abstract group_tensor(tensor: tensorflow.python.framework.ops.Tensor) → tensorflow.python.framework.ops.Tensor[source]
                                                                                                                            +abstract group_tensor(tensor: tensorflow.python.framework.ops.Tensor)tensorflow.python.framework.ops.Tensor[source]
                                                                                                                            Parameters

                                                                                                                            tensor – The tensor to reduce in groups

                                                                                                                            @@ -501,13 +501,13 @@

                                                                                                                            Submodules
                                                                                                                            -class sparseml.tensorflow_v1.optim.mask_creator_pruning.PruningMaskCreator[source]
                                                                                                                            +class sparseml.tensorflow_v1.optim.mask_creator_pruning.PruningMaskCreator[source]

                                                                                                                            Bases: abc.ABC

                                                                                                                            Base abstract class for a sparsity mask creator. Subclasses should define all methods for creating masks and their initializers

                                                                                                                            -abstract create_sparsity_mask(tensor: tensorflow.python.framework.ops.Tensor, sparsity: tensorflow.python.framework.ops.Tensor) → tensorflow.python.framework.ops.Tensor[source]
                                                                                                                            +abstract create_sparsity_mask(tensor: tensorflow.python.framework.ops.Tensor, sparsity: tensorflow.python.framework.ops.Tensor)tensorflow.python.framework.ops.Tensor[source]
                                                                                                                            Parameters
                                                                                                                              @@ -524,7 +524,7 @@

                                                                                                                              Submodules
                                                                                                                              -abstract get_mask_initializer(tensor: tensorflow.python.framework.ops.Tensor) → Callable[tensorflow.python.framework.ops.Tensor][source]
                                                                                                                              +abstract get_mask_initializer(tensor: tensorflow.python.framework.ops.Tensor)Callable[tensorflow.python.framework.ops.Tensor][source]
                                                                                                                              Parameters

                                                                                                                              tensor – A tensor of a model layer’s weights

                                                                                                                              @@ -539,14 +539,14 @@

                                                                                                                              Submodules
                                                                                                                              -class sparseml.tensorflow_v1.optim.mask_creator_pruning.UnstructuredPruningMaskCreator[source]
                                                                                                                              +class sparseml.tensorflow_v1.optim.mask_creator_pruning.UnstructuredPruningMaskCreator[source]

                                                                                                                              Bases: sparseml.tensorflow_v1.optim.mask_creator_pruning.PruningMaskCreator

                                                                                                                              Class for creating unstructured sparsity masks. Masks will be created using unstructured sparsity by pruning weights ranked by their magnitude.

                                                                                                                              -create_sparsity_mask(tensor: tensorflow.python.framework.ops.Tensor, sparsity: tensorflow.python.framework.ops.Tensor) → tensorflow.python.framework.ops.Tensor[source]
                                                                                                                              +create_sparsity_mask(tensor: tensorflow.python.framework.ops.Tensor, sparsity: tensorflow.python.framework.ops.Tensor)tensorflow.python.framework.ops.Tensor[source]
                                                                                                                              Parameters
                                                                                                                                @@ -563,7 +563,7 @@

                                                                                                                                Submodules
                                                                                                                                -get_mask_initializer(tensor: tensorflow.python.framework.ops.Tensor) → Callable[tensorflow.python.framework.ops.Tensor][source]
                                                                                                                                +get_mask_initializer(tensor: tensorflow.python.framework.ops.Tensor)Callable[tensorflow.python.framework.ops.Tensor][source]
                                                                                                                                Parameters

                                                                                                                                tensor – A tensor of a model layer’s weights

                                                                                                                                @@ -582,7 +582,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparseml.tensorflow_v1.optim.mask_creator_pruning.load_mask_creator(obj: Union[str, Iterable[int]])sparseml.tensorflow_v1.optim.mask_creator_pruning.PruningMaskCreator[source]
                                                                                                                                +sparseml.tensorflow_v1.optim.mask_creator_pruning.load_mask_creator(obj: Union[str, Iterable[int]])sparseml.tensorflow_v1.optim.mask_creator_pruning.PruningMaskCreator[source]
                                                                                                                                Parameters

                                                                                                                                obj – Formatted string or iterable of block_shape specifying @@ -601,35 +601,35 @@

                                                                                                                                Submodules
                                                                                                                                -class sparseml.tensorflow_v1.optim.mask_pruning.PruningOpVars(op, op_input, update, mask, masked)
                                                                                                                                +class sparseml.tensorflow_v1.optim.mask_pruning.PruningOpVars(op, op_input, update, mask, masked)

                                                                                                                                Bases: tuple

                                                                                                                                -property mask
                                                                                                                                +property mask

                                                                                                                                Alias for field number 3

                                                                                                                                -property masked
                                                                                                                                +property masked

                                                                                                                                Alias for field number 4

                                                                                                                                -property op
                                                                                                                                +property op

                                                                                                                                Alias for field number 0

                                                                                                                                -property op_input
                                                                                                                                +property op_input

                                                                                                                                Alias for field number 1

                                                                                                                                -property update
                                                                                                                                +property update

                                                                                                                                Alias for field number 2

                                                                                                                                @@ -637,113 +637,113 @@

                                                                                                                                Submodules
                                                                                                                                -class sparseml.tensorflow_v1.optim.mask_pruning.PruningScope[source]
                                                                                                                                +class sparseml.tensorflow_v1.optim.mask_pruning.PruningScope[source]

                                                                                                                                Bases: object

                                                                                                                                Convenience class for dealing with scope and names for kernel sparsity in the tf graph.

                                                                                                                                -NM_KS = 'nm_ks'
                                                                                                                                +NM_KS = 'nm_ks'
                                                                                                                                -NM_KS_OPS = 'nm_ks_ops'
                                                                                                                                +NM_KS_OPS = 'nm_ks_ops'
                                                                                                                                -OPS = 'ops'
                                                                                                                                +OPS = 'ops'
                                                                                                                                -OPS_INPUT = 'input_ops'
                                                                                                                                +OPS_INPUT = 'input_ops'
                                                                                                                                -OPS_SCHEDULE = 'schedule_ops'
                                                                                                                                +OPS_SCHEDULE = 'schedule_ops'
                                                                                                                                -OPS_SPARSITY = 'sparsity_ops'
                                                                                                                                +OPS_SPARSITY = 'sparsity_ops'
                                                                                                                                -OPS_SUMMARY = 'summary_ops'
                                                                                                                                +OPS_SUMMARY = 'summary_ops'
                                                                                                                                -OPS_UPDATE = 'update_ops'
                                                                                                                                +OPS_UPDATE = 'update_ops'
                                                                                                                                -OP_COND_UPDATE = 'nm_conditional_update'
                                                                                                                                +OP_COND_UPDATE = 'nm_conditional_update'
                                                                                                                                -OP_MASKED_VAR = 'nm_masked_var'
                                                                                                                                +OP_MASKED_VAR = 'nm_masked_var'
                                                                                                                                -OP_MASK_ASSIGN = 'nm_mask_assign'
                                                                                                                                +OP_MASK_ASSIGN = 'nm_mask_assign'
                                                                                                                                -OP_MASK_UPDATE = 'nm_mask_update'
                                                                                                                                +OP_MASK_UPDATE = 'nm_mask_update'
                                                                                                                                -OP_MASK_UPDATE_NO_OP = 'nm_mask_update_no_op'
                                                                                                                                +OP_MASK_UPDATE_NO_OP = 'nm_mask_update_no_op'
                                                                                                                                -OP_PRUNE_VARS_ASSIGN = 'nm_prune_vars_assign'
                                                                                                                                +OP_PRUNE_VARS_ASSIGN = 'nm_prune_vars_assign'
                                                                                                                                -OP_SAVE = 'nm_save'
                                                                                                                                +OP_SAVE = 'nm_save'
                                                                                                                                -OP_SPARSITY = 'nm_sparsity'
                                                                                                                                +OP_SPARSITY = 'nm_sparsity'
                                                                                                                                -OP_UPDATE_READY = 'nm_update_ready'
                                                                                                                                +OP_UPDATE_READY = 'nm_update_ready'
                                                                                                                                -OP_WEIGHT_UPDATE = 'nm_weight_update'
                                                                                                                                +OP_WEIGHT_UPDATE = 'nm_weight_update'
                                                                                                                                -VAR_MASK = 'nm_mask'
                                                                                                                                +VAR_MASK = 'nm_mask'
                                                                                                                                -VAR_THRESHOLD = 'nm_threshold'
                                                                                                                                +VAR_THRESHOLD = 'nm_threshold'
                                                                                                                                -static collection_name(ks_group: str, name: str) → str[source]
                                                                                                                                +static collection_name(ks_group: str, name: str)str[source]

                                                                                                                                Create a predictable name for a given variable / op in a group for lookup / storage in a collection

                                                                                                                                @@ -761,7 +761,7 @@

                                                                                                                                Submodules
                                                                                                                                -static general(ks_group: str, additional: Optional[str] = None, trailing_slash: bool = False)[source]
                                                                                                                                +static general(ks_group: str, additional: Optional[str] = None, trailing_slash: bool = False)[source]

                                                                                                                                Create a general kernel sparsity scope in the tf graph. Use cases are for generic ops like target sparsity, conditional updates, etc.

                                                                                                                                @@ -780,7 +780,7 @@

                                                                                                                                Submodules
                                                                                                                                -static model(op_tens: tensorflow.python.framework.ops.Tensor, ks_group: str, additional: Optional[str] = None, trailing_slash: bool = False) → str[source]
                                                                                                                                +static model(op_tens: tensorflow.python.framework.ops.Tensor, ks_group: str, additional: Optional[str] = None, trailing_slash: bool = False)str[source]

                                                                                                                                Create a model specific kernel sparsity scope in the tf graph. Use cases are for the specific mask, threshold, etc variables to induce sparsity along with the ops to update those vars.

                                                                                                                                @@ -803,7 +803,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparseml.tensorflow_v1.optim.mask_pruning.apply_op_vars_masks(pruning_op_vars: List[sparseml.tensorflow_v1.optim.mask_pruning.PruningOpVars], ks_group: str, sess: tensorflow.python.client.session.Session)[source]
                                                                                                                                +sparseml.tensorflow_v1.optim.mask_pruning.apply_op_vars_masks(pruning_op_vars: List[sparseml.tensorflow_v1.optim.mask_pruning.PruningOpVars], ks_group: str, sess: tensorflow.python.client.session.Session)[source]

                                                                                                                                Apply the masks to the original ops input var so that it can be saved with the desired sparsity for later.

                                                                                                                                @@ -820,7 +820,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparseml.tensorflow_v1.optim.mask_pruning.create_graph_ops_pruning(graph: tensorflow.python.framework.ops.Graph, var_names: List[str], sparsity: tensorflow.python.framework.ops.Tensor, update_ready: tensorflow.python.framework.ops.Tensor, leave_enabled: bool, is_after_end_step: tensorflow.python.framework.ops.Tensor, ks_group: str, mask_creator: sparseml.tensorflow_v1.optim.mask_creator_pruning.PruningMaskCreator) → List[sparseml.tensorflow_v1.optim.mask_pruning.PruningOpVars][source]
                                                                                                                                +sparseml.tensorflow_v1.optim.mask_pruning.create_graph_ops_pruning(graph: tensorflow.python.framework.ops.Graph, var_names: List[str], sparsity: tensorflow.python.framework.ops.Tensor, update_ready: tensorflow.python.framework.ops.Tensor, leave_enabled: bool, is_after_end_step: tensorflow.python.framework.ops.Tensor, ks_group: str, mask_creator: sparseml.tensorflow_v1.optim.mask_creator_pruning.PruningMaskCreator)List[sparseml.tensorflow_v1.optim.mask_pruning.PruningOpVars][source]

                                                                                                                                Creates the necessary variables and operators to gradually apply sparsity to a given list of operators in a graph.

                                                                                                                                Handles setting a mask on an operator to the given sparsity. @@ -851,7 +851,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparseml.tensorflow_v1.optim.mask_pruning.create_ks_schedule_ops(global_step: tensorflow.python.ops.variables.VariableV1, begin_step: int, end_step: int, update_step_freq: int, init_sparsity: float, final_sparsity: float, exponent: float, ks_group: str) → Tuple[tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Tensor][source]
                                                                                                                                +sparseml.tensorflow_v1.optim.mask_pruning.create_ks_schedule_ops(global_step: tensorflow.python.ops.variables.VariableV1, begin_step: int, end_step: int, update_step_freq: int, init_sparsity: float, final_sparsity: float, exponent: float, ks_group: str)Tuple[tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Tensor][source]

                                                                                                                                Create a gradual schedule for model pruning (kernel sparsity). Creates a sparsity tensor that goes from init_sparsity til final_sparsity starting at begin_step and ending at end_step. @@ -882,7 +882,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparseml.tensorflow_v1.optim.mask_pruning.create_ks_scheduled_constant_graph_ops(graph: tensorflow.python.framework.ops.Graph, global_step: tensorflow.python.ops.variables.VariableV1, var_names: List[str], begin_step: int, end_step: int, ks_group: str) → Tuple[tensorflow.python.framework.ops.Tensor, List[sparseml.tensorflow_v1.optim.mask_pruning.PruningOpVars]][source]
                                                                                                                                +sparseml.tensorflow_v1.optim.mask_pruning.create_ks_scheduled_constant_graph_ops(graph: tensorflow.python.framework.ops.Graph, global_step: tensorflow.python.ops.variables.VariableV1, var_names: List[str], begin_step: int, end_step: int, ks_group: str)Tuple[tensorflow.python.framework.ops.Tensor, List[sparseml.tensorflow_v1.optim.mask_pruning.PruningOpVars]][source]

                                                                                                                                Creates constant model pruning ops. Does not modify the graph.

                                                                                                                                Parameters
                                                                                                                                @@ -905,7 +905,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparseml.tensorflow_v1.optim.mask_pruning.create_op_pruning(op: tensorflow.python.framework.ops.Operation, op_input: tensorflow.python.framework.ops.Tensor, sparsity: tensorflow.python.framework.ops.Tensor, update_ready: tensorflow.python.framework.ops.Tensor, leave_enabled: bool, is_after_end_step: tensorflow.python.framework.ops.Tensor, ks_group: str, mask_creator: sparseml.tensorflow_v1.optim.mask_creator_pruning.PruningMaskCreator)sparseml.tensorflow_v1.optim.mask_pruning.PruningOpVars[source]
                                                                                                                                +sparseml.tensorflow_v1.optim.mask_pruning.create_op_pruning(op: tensorflow.python.framework.ops.Operation, op_input: tensorflow.python.framework.ops.Tensor, sparsity: tensorflow.python.framework.ops.Tensor, update_ready: tensorflow.python.framework.ops.Tensor, leave_enabled: bool, is_after_end_step: tensorflow.python.framework.ops.Tensor, ks_group: str, mask_creator: sparseml.tensorflow_v1.optim.mask_creator_pruning.PruningMaskCreator)sparseml.tensorflow_v1.optim.mask_pruning.PruningOpVars[source]

                                                                                                                                Creates the necessary variables and operators to gradually apply sparsity to an operators variable.

                                                                                                                                Handles setting a mask on an operator to the given sparsity. @@ -935,7 +935,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparseml.tensorflow_v1.optim.mask_pruning.create_summaries_pruning(pruning_op_vars: List[sparseml.tensorflow_v1.optim.mask_pruning.PruningOpVars])[source]
                                                                                                                                +sparseml.tensorflow_v1.optim.mask_pruning.create_summaries_pruning(pruning_op_vars: List[sparseml.tensorflow_v1.optim.mask_pruning.PruningOpVars])[source]

                                                                                                                                Create TensorBoard summary ops in the current graph for the given list of PruningOpVars.

                                                                                                                                @@ -951,7 +951,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparseml.tensorflow_v1.optim.mask_pruning.get_or_create_graph_ops_pruning(graph: tensorflow.python.framework.ops.Graph, var_names: List[str], sparsity: tensorflow.python.framework.ops.Tensor, update_ready: tensorflow.python.framework.ops.Tensor, leave_enabled: bool, is_after_end_step: tensorflow.python.framework.ops.Tensor, ks_group: str, mask_creator: sparseml.tensorflow_v1.optim.mask_creator_pruning.PruningMaskCreator) → List[sparseml.tensorflow_v1.optim.mask_pruning.PruningOpVars][source]
                                                                                                                                +sparseml.tensorflow_v1.optim.mask_pruning.get_or_create_graph_ops_pruning(graph: tensorflow.python.framework.ops.Graph, var_names: List[str], sparsity: tensorflow.python.framework.ops.Tensor, update_ready: tensorflow.python.framework.ops.Tensor, leave_enabled: bool, is_after_end_step: tensorflow.python.framework.ops.Tensor, ks_group: str, mask_creator: sparseml.tensorflow_v1.optim.mask_creator_pruning.PruningMaskCreator)List[sparseml.tensorflow_v1.optim.mask_pruning.PruningOpVars][source]

                                                                                                                                Creates or retrieves (if previously created) the necessary variables and operators to gradually apply sparsity to a given list of operators in a graph.

                                                                                                                                Handles setting a mask on an operator to the given sparsity. @@ -982,7 +982,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparseml.tensorflow_v1.optim.mask_pruning.get_or_create_ks_schedule_ops(global_step: tensorflow.python.framework.ops.Tensor, begin_step: int, end_step: int, update_step_freq: int, init_sparsity: float, final_sparsity: float, exponent: float, ks_group: str) → Tuple[tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Tensor][source]
                                                                                                                                +sparseml.tensorflow_v1.optim.mask_pruning.get_or_create_ks_schedule_ops(global_step: tensorflow.python.framework.ops.Tensor, begin_step: int, end_step: int, update_step_freq: int, init_sparsity: float, final_sparsity: float, exponent: float, ks_group: str)Tuple[tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Tensor][source]

                                                                                                                                Creates or retrieves (if previously created) a gradual schedule for model pruning (kernel sparsity). Creates a sparsity tensor that goes from init_sparsity til final_sparsity @@ -1014,7 +1014,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparseml.tensorflow_v1.optim.mask_pruning.get_or_create_ks_scheduled_graph_ops(graph: tensorflow.python.framework.ops.Graph, global_step: tensorflow.python.ops.variables.VariableV1, var_names: List[str], begin_step: int, end_step: int, update_step_freq: int, init_sparsity: float, final_sparsity: float, exponent: float, leave_enabled: bool, ks_group: str, mask_creator: sparseml.tensorflow_v1.optim.mask_creator_pruning.PruningMaskCreator) → Tuple[tensorflow.python.framework.ops.Tensor, List[sparseml.tensorflow_v1.optim.mask_pruning.PruningOpVars], tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Tensor][source]
                                                                                                                                +sparseml.tensorflow_v1.optim.mask_pruning.get_or_create_ks_scheduled_graph_ops(graph: tensorflow.python.framework.ops.Graph, global_step: tensorflow.python.ops.variables.VariableV1, var_names: List[str], begin_step: int, end_step: int, update_step_freq: int, init_sparsity: float, final_sparsity: float, exponent: float, leave_enabled: bool, ks_group: str, mask_creator: sparseml.tensorflow_v1.optim.mask_creator_pruning.PruningMaskCreator)Tuple[tensorflow.python.framework.ops.Tensor, List[sparseml.tensorflow_v1.optim.mask_pruning.PruningOpVars], tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Tensor][source]

                                                                                                                                Gets or creates model pruning (kernel sparsity) ops and vars in the graph to be applied over a specific schedule. Creates them for the var_names in the graph such that they follow a schedule @@ -1059,7 +1059,7 @@

                                                                                                                                Submodules
                                                                                                                                -class sparseml.tensorflow_v1.optim.modifier.Modifier(log_types: Optional[Union[str, List[str]]] = None, **kwargs)[source]
                                                                                                                                +class sparseml.tensorflow_v1.optim.modifier.Modifier(log_types: Optional[Union[str, List[str]]] = None, **kwargs)[source]

                                                                                                                                Bases: sparseml.optim.modifier.BaseModifier

                                                                                                                                Base modifier class that all TensorFlow modifiers should derive themselves from. Handles setting up the expected contracts for modifying graphs, ops, and extras.

                                                                                                                                @@ -1091,7 +1091,7 @@

                                                                                                                                Submodules
                                                                                                                                -complete_graph(graph: tensorflow.python.framework.ops.Graph, sess: tensorflow.python.client.session.Session)[source]
                                                                                                                                +complete_graph(graph: tensorflow.python.framework.ops.Graph, sess: tensorflow.python.client.session.Session)[source]

                                                                                                                                Complete modifying the graph. Should be called after modifying is complete. Cleans up any ops that should be removed or reordered.

                                                                                                                                @@ -1109,7 +1109,7 @@

                                                                                                                                Submodules
                                                                                                                                -create_ops(steps_per_epoch: int, global_step: tensorflow.python.framework.ops.Tensor, graph: tensorflow.python.framework.ops.Graph) → Tuple[List[Union[tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Operation]], Dict[str, Any]][source]
                                                                                                                                +create_ops(steps_per_epoch: int, global_step: tensorflow.python.framework.ops.Tensor, graph: tensorflow.python.framework.ops.Graph)Tuple[List[Union[tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Operation]], Dict[str, Any]][source]

                                                                                                                                Create modifying operations and tensors in the graph.

                                                                                                                                Returns a tuple containing:
                                                                                                                                @@ -1138,7 +1138,7 @@

                                                                                                                                Submodules
                                                                                                                                -get_group() → Any[source]
                                                                                                                                +get_group()Any[source]

                                                                                                                                Function to be override by a subclass indicating the modifier container into which the subclass should be combined As an example, the two learning rate modifier classes SetLearningRateModifier @@ -1149,7 +1149,7 @@

                                                                                                                                Submodules
                                                                                                                                -initialize_session(sess: tensorflow.python.client.session.Session)[source]
                                                                                                                                +initialize_session(sess: tensorflow.python.client.session.Session)[source]

                                                                                                                                Initialize any state for a session such as variables.

                                                                                                                                Parameters
                                                                                                                                @@ -1160,7 +1160,7 @@

                                                                                                                                Submodules
                                                                                                                                -static load_list(yaml_str: str)[source]
                                                                                                                                +static load_list(yaml_str: str)[source]
                                                                                                                                Parameters

                                                                                                                                yaml_str – a string representation of the yaml syntax to @@ -1174,7 +1174,7 @@

                                                                                                                                Submodules
                                                                                                                                -static load_obj(yaml_str: str)[source]
                                                                                                                                +static load_obj(yaml_str: str)[source]
                                                                                                                                Parameters

                                                                                                                                yaml_str – a string representation of the yaml syntax to @@ -1188,7 +1188,7 @@

                                                                                                                                Submodules
                                                                                                                                -modify_estimator(estimator: tensorflow_estimator.python.estimator.estimator.Estimator, steps_per_epoch: int)[source]
                                                                                                                                +modify_estimator(estimator: tensorflow_estimator.python.estimator.estimator.Estimator, steps_per_epoch: int)[source]

                                                                                                                                Modify a tf Estimator. Overrides the model_fn so that on invocation it creates the original graph and then calls into create_ops. Additionally will recreate the Scaffold with a new Save instance @@ -1210,7 +1210,7 @@

                                                                                                                                Submodules
                                                                                                                                -class sparseml.tensorflow_v1.optim.modifier.ModifierProp(serializable: bool = True, restrict_initialized: bool = True, restrict_enabled: bool = False, restrict_extras: Optional[List[str]] = None, no_serialize_val: Optional[Any] = None, func_get: Optional[Callable] = None, func_set: Optional[Callable] = None, doc: Optional[Callable] = None)[source]
                                                                                                                                +class sparseml.tensorflow_v1.optim.modifier.ModifierProp(serializable: bool = True, restrict_initialized: bool = True, restrict_enabled: bool = False, restrict_extras: Optional[List[str]] = None, no_serialize_val: Optional[Any] = None, func_get: Optional[Callable] = None, func_set: Optional[Callable] = None, doc: Optional[Callable] = None)[source]

                                                                                                                                Bases: sparseml.optim.modifier.BaseProp

                                                                                                                                Property used to decorate a modifier. Use for creating getters and setters in a modifier. @@ -1237,7 +1237,7 @@

                                                                                                                                Submodules
                                                                                                                                -getter(func_get: Callable)sparseml.optim.modifier.BaseProp[source]
                                                                                                                                +getter(func_get: Callable)sparseml.optim.modifier.BaseProp[source]

                                                                                                                                Create a ModifierProp based off the current instance with the getter function

                                                                                                                                Parameters
                                                                                                                                @@ -1251,7 +1251,7 @@

                                                                                                                                Submodules
                                                                                                                                -property no_serialize_val
                                                                                                                                +property no_serialize_val

                                                                                                                                a value that if the prop is equal to, will not serialize the prop

                                                                                                                                Type
                                                                                                                                @@ -1262,7 +1262,7 @@

                                                                                                                                Submodules
                                                                                                                                -property restrictions
                                                                                                                                +property restrictions

                                                                                                                                The attributes to check for restricting when the attribute can be set

                                                                                                                                Type
                                                                                                                                @@ -1273,7 +1273,7 @@

                                                                                                                                Submodules
                                                                                                                                -property serializable
                                                                                                                                +property serializable

                                                                                                                                True if the property should be serialized (ex in yaml), False otherwise

                                                                                                                                Type
                                                                                                                                @@ -1284,7 +1284,7 @@

                                                                                                                                Submodules
                                                                                                                                -setter(func_set: Callable)sparseml.optim.modifier.BaseProp[source]
                                                                                                                                +setter(func_set: Callable)sparseml.optim.modifier.BaseProp[source]

                                                                                                                                Create a ModifierProp based off the current instance with the setter function

                                                                                                                                Parameters
                                                                                                                                @@ -1300,7 +1300,7 @@

                                                                                                                                Submodules
                                                                                                                                -class sparseml.tensorflow_v1.optim.modifier.ModifierSessionRunHook(mod_ops: List[Union[tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Operation]])[source]
                                                                                                                                +class sparseml.tensorflow_v1.optim.modifier.ModifierSessionRunHook(mod_ops: List[Union[tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Operation]])[source]

                                                                                                                                Bases: tensorflow.python.training.session_run_hook.SessionRunHook

                                                                                                                                A session run hook for the tf Estimator flow. Used to integrate so that any extra ops for modifying the graph @@ -1317,7 +1317,7 @@

                                                                                                                                Submodules
                                                                                                                                -after_run(run_context, run_values)[source]
                                                                                                                                +after_run(run_context, run_values)[source]

                                                                                                                                Called by the estimator after each call to run()

                                                                                                                                Parameters
                                                                                                                                @@ -1333,7 +1333,7 @@

                                                                                                                                Submodules
                                                                                                                                -class sparseml.tensorflow_v1.optim.modifier.ScheduledModifier(log_types: Optional[Union[str, List[str]]] = None, start_epoch: float = - 1.0, end_epoch: float = - 1.0, min_start: float = - 1.0, min_end: float = - 1.0, end_comparator: Optional[int] = 0, **kwargs)[source]
                                                                                                                                +class sparseml.tensorflow_v1.optim.modifier.ScheduledModifier(log_types: Optional[Union[str, List[str]]] = None, start_epoch: float = - 1.0, end_epoch: float = - 1.0, min_start: float = - 1.0, min_end: float = - 1.0, end_comparator: Optional[int] = 0, **kwargs)[source]

                                                                                                                                Bases: sparseml.tensorflow_v1.optim.modifier.Modifier, sparseml.optim.modifier.BaseScheduled

                                                                                                                                The base scheduled update modifier implementation, all scheduled modifiers should inherit from this class. @@ -1377,7 +1377,7 @@

                                                                                                                                Submodules
                                                                                                                                -start_end_steps(steps_per_epoch: int, after_optim: bool) → Tuple[int, int][source]
                                                                                                                                +start_end_steps(steps_per_epoch: int, after_optim: bool)Tuple[int, int][source]

                                                                                                                                Calculate the start and end steps for this modifier given a certain amount of steps per epoch

                                                                                                                                @@ -1399,7 +1399,7 @@

                                                                                                                                Submodules
                                                                                                                                -class sparseml.tensorflow_v1.optim.modifier.ScheduledUpdateModifier(log_types: Optional[Union[str, List[str]]] = None, start_epoch: float = - 1.0, end_epoch: float = - 1.0, min_start: float = - 1.0, min_end: float = - 1.0, end_comparator: int = 0, update_frequency: float = - 1.0, min_frequency: float = - 1.0, **kwargs)[source]
                                                                                                                                +class sparseml.tensorflow_v1.optim.modifier.ScheduledUpdateModifier(log_types: Optional[Union[str, List[str]]] = None, start_epoch: float = - 1.0, end_epoch: float = - 1.0, min_start: float = - 1.0, min_end: float = - 1.0, end_comparator: int = 0, update_frequency: float = - 1.0, min_frequency: float = - 1.0, **kwargs)[source]

                                                                                                                                Bases: sparseml.tensorflow_v1.optim.modifier.ScheduledModifier, sparseml.optim.modifier.BaseUpdate

                                                                                                                                The base scheduled update modifier implementation, all scheduled update modifiers should inherit from this class. @@ -1444,7 +1444,7 @@

                                                                                                                                Submodules
                                                                                                                                -update_frequency_steps(steps_per_epoch: int) → int[source]
                                                                                                                                +update_frequency_steps(steps_per_epoch: int)int[source]

                                                                                                                                Calculate the update frequency steps for this modifier given a certain amount of steps per epoch

                                                                                                                                @@ -1462,7 +1462,7 @@

                                                                                                                                Submodules
                                                                                                                                -class sparseml.tensorflow_v1.optim.modifier.TensorFlowModifierYAML[source]
                                                                                                                                +class sparseml.tensorflow_v1.optim.modifier.TensorFlowModifierYAML[source]

                                                                                                                                Bases: sparseml.optim.modifier.ModifierYAML

                                                                                                                                A decorator to handle making a TensorFlow modifier class YAML ready. IE it can be loaded in through the yaml plugin easily.

                                                                                                                                @@ -1474,7 +1474,7 @@

                                                                                                                                Submodules
                                                                                                                                -class sparseml.tensorflow_v1.optim.modifier_epoch.EpochRangeModifier(start_epoch: float, end_epoch: float)[source]
                                                                                                                                +class sparseml.tensorflow_v1.optim.modifier_epoch.EpochRangeModifier(start_epoch: float, end_epoch: float)[source]

                                                                                                                                Bases: sparseml.tensorflow_v1.optim.modifier.ScheduledModifier

                                                                                                                                Simple modifier to set the range of epochs to train over for the recalibration process. @@ -1498,7 +1498,7 @@

                                                                                                                                Submodules
                                                                                                                                -class sparseml.tensorflow_v1.optim.modifier_lr.GroupLearningRateModifier(lr_modifiers: List[sparseml.tensorflow_v1.optim.modifier.ScheduledModifier])[source]
                                                                                                                                +class sparseml.tensorflow_v1.optim.modifier_lr.GroupLearningRateModifier(lr_modifiers: List[sparseml.tensorflow_v1.optim.modifier.ScheduledModifier])[source]

                                                                                                                                Bases: sparseml.tensorflow_v1.optim.modifier.ScheduledModifier

                                                                                                                                Combining multiple LR modifiers, correctly compute the learning rate

                                                                                                                                @@ -1508,7 +1508,7 @@

                                                                                                                                Submodules
                                                                                                                                -create_ops(steps_per_epoch: int, global_step: tensorflow.python.ops.variables.VariableV1, graph: tensorflow.python.framework.ops.Graph) → Tuple[List[Union[tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Operation]], Dict[str, Any]][source]
                                                                                                                                +create_ops(steps_per_epoch: int, global_step: tensorflow.python.ops.variables.VariableV1, graph: tensorflow.python.framework.ops.Graph)Tuple[List[Union[tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Operation]], Dict[str, Any]][source]

                                                                                                                                Create switch case computing the learning rate at a given global step and extras created by individual LR modifiers

                                                                                                                                @@ -1530,7 +1530,7 @@

                                                                                                                                Submodules
                                                                                                                                -class sparseml.tensorflow_v1.optim.modifier_lr.LearningRateModifier(lr_class: str, lr_kwargs: Dict, init_lr: float, start_epoch: float, end_epoch: float = - 1.0, update_frequency: float = - 1.0, log_types: Union[str, List[str]] = '__ALL__')[source]
                                                                                                                                +class sparseml.tensorflow_v1.optim.modifier_lr.LearningRateModifier(lr_class: str, lr_kwargs: Dict, init_lr: float, start_epoch: float, end_epoch: float = - 1.0, update_frequency: float = - 1.0, log_types: Union[str, List[str]] = '__ALL__')[source]

                                                                                                                                Bases: sparseml.tensorflow_v1.optim.modifier.ScheduledUpdateModifier, sparseml.optim.learning_rate.LearningRate

                                                                                                                                Modifier to set the learning rate to follow specific schedulers within a period of epochs. @@ -1574,7 +1574,7 @@

                                                                                                                                Submodules
                                                                                                                                -create_ops(steps_per_epoch: int, global_step: Optional[tensorflow.python.ops.variables.VariableV1], graph: Optional[tensorflow.python.framework.ops.Graph]) → Tuple[List[Union[tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Operation]], Dict[str, Any]][source]
                                                                                                                                +create_ops(steps_per_epoch: int, global_step: Optional[tensorflow.python.ops.variables.VariableV1], graph: Optional[tensorflow.python.framework.ops.Graph])Tuple[List[Union[tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Operation]], Dict[str, Any]][source]

                                                                                                                                Create ops to update the learning rate at the current global step

                                                                                                                                Parameters
                                                                                                                                @@ -1592,7 +1592,7 @@

                                                                                                                                Submodules
                                                                                                                                -get_group()[source]
                                                                                                                                +get_group()[source]
                                                                                                                                Returns

                                                                                                                                The group modifier class into which this modifier needs to be combined

                                                                                                                                @@ -1604,7 +1604,7 @@

                                                                                                                                Submodules
                                                                                                                                -class sparseml.tensorflow_v1.optim.modifier_lr.SetLearningRateModifier(learning_rate: float, start_epoch: float = - 1, end_epoch: float = - 1, log_types: Union[str, List[str]] = '__ALL__')[source]
                                                                                                                                +class sparseml.tensorflow_v1.optim.modifier_lr.SetLearningRateModifier(learning_rate: float, start_epoch: float = - 1, end_epoch: float = - 1, log_types: Union[str, List[str]] = '__ALL__')[source]

                                                                                                                                Bases: sparseml.tensorflow_v1.optim.modifier.ScheduledModifier, sparseml.optim.learning_rate.SetLearningRate

                                                                                                                                Modifier to set the learning rate to a specific value at a certain point in the training process. Once that point is reached, will update the optimizer’s @@ -1633,7 +1633,7 @@

                                                                                                                                Submodules
                                                                                                                                -create_ops(steps_per_epoch: int, global_step: Optional[tensorflow.python.ops.variables.VariableV1], graph: Optional[tensorflow.python.framework.ops.Graph]) → Tuple[List[Union[tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Operation]], Dict[str, Any]][source]
                                                                                                                                +create_ops(steps_per_epoch: int, global_step: Optional[tensorflow.python.ops.variables.VariableV1], graph: Optional[tensorflow.python.framework.ops.Graph])Tuple[List[Union[tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Operation]], Dict[str, Any]][source]

                                                                                                                                Create ops to set the learning rate at a given value if the global step reaches a given value

                                                                                                                                @@ -1653,7 +1653,7 @@

                                                                                                                                Submodules
                                                                                                                                -get_group()[source]
                                                                                                                                +get_group()[source]
                                                                                                                                Returns

                                                                                                                                The group modifier class into which this modifier needs to be combined

                                                                                                                                @@ -1670,7 +1670,7 @@

                                                                                                                                Submodules
                                                                                                                                -class sparseml.tensorflow_v1.optim.modifier_params.TrainableParamsModifier(params: Union[str, List[str]], trainable: bool, params_strict: bool = True, start_epoch: float = - 1.0, end_epoch: float = - 1.0)[source]
                                                                                                                                +class sparseml.tensorflow_v1.optim.modifier_params.TrainableParamsModifier(params: Union[str, List[str]], trainable: bool, params_strict: bool = True, start_epoch: float = - 1.0, end_epoch: float = - 1.0)[source]

                                                                                                                                Bases: sparseml.tensorflow_v1.optim.modifier.ScheduledModifier

                                                                                                                                Modifier to control the params for a given list of parameters. Applies the trainability over all epochs. @@ -1702,7 +1702,7 @@

                                                                                                                                Submodules
                                                                                                                                -complete_graph(graph: tensorflow.python.framework.ops.Graph, sess: tensorflow.python.client.session.Session)[source]
                                                                                                                                +complete_graph(graph: tensorflow.python.framework.ops.Graph, sess: tensorflow.python.client.session.Session)[source]

                                                                                                                                Complete modifying the graph. Resets the objects filtered variables to their original trainability

                                                                                                                                @@ -1719,7 +1719,7 @@

                                                                                                                                Submodules
                                                                                                                                -create_ops(steps_per_epoch: int, global_step: tensorflow.python.framework.ops.Tensor, graph: tensorflow.python.framework.ops.Graph) → Tuple[List[Union[tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Operation]], Dict[str, Any]][source]
                                                                                                                                +create_ops(steps_per_epoch: int, global_step: tensorflow.python.framework.ops.Tensor, graph: tensorflow.python.framework.ops.Graph)Tuple[List[Union[tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Operation]], Dict[str, Any]][source]

                                                                                                                                Create the sparsity ops to modify the training graph according to the settings for the current instance.

                                                                                                                                @@ -1739,7 +1739,7 @@

                                                                                                                                Submodules
                                                                                                                                -params
                                                                                                                                +params

                                                                                                                                A list of full parameter names or regex patterns of names to apply pruning to. Regex patterns must be specified with the prefix ‘re:’. __ALL__ will match to all parameters. Can also use the token __ALL__ to specify all @@ -1753,7 +1753,7 @@

                                                                                                                                Submodules
                                                                                                                                -params_strict
                                                                                                                                +params_strict

                                                                                                                                True if the given param(s) must be found in each layer and will raise an err if not found, False if missing params are ok and will not raise an err

                                                                                                                                @@ -1766,7 +1766,7 @@

                                                                                                                                Submodules
                                                                                                                                -trainable
                                                                                                                                +trainable

                                                                                                                                True if the param(s) should be made trainable, False to make them non-trainable

                                                                                                                                @@ -1778,7 +1778,7 @@

                                                                                                                                Submodules
                                                                                                                                -validate()[source]
                                                                                                                                +validate()[source]

                                                                                                                                Validate the values of the params for the current instance are valid

                                                                                                                                @@ -1791,7 +1791,7 @@

                                                                                                                                Submodules
                                                                                                                                -class sparseml.tensorflow_v1.optim.modifier_pruning.ConstantPruningModifier(params: Union[str, List[str]], start_epoch: float = - 1, end_epoch: float = - 1, log_types: Union[str, List[str]] = '__ALL__')[source]
                                                                                                                                +class sparseml.tensorflow_v1.optim.modifier_pruning.ConstantPruningModifier(params: Union[str, List[str]], start_epoch: float = - 1, end_epoch: float = - 1, log_types: Union[str, List[str]] = '__ALL__')[source]

                                                                                                                                Bases: sparseml.tensorflow_v1.optim.modifier.ScheduledModifier

                                                                                                                                Holds the sparsity level and shape for a given param constant while training. Useful for transfer learning use cases.

                                                                                                                                @@ -1823,7 +1823,7 @@

                                                                                                                                Submodules
                                                                                                                                -complete_graph(graph: tensorflow.python.framework.ops.Graph, sess: tensorflow.python.client.session.Session)[source]
                                                                                                                                +complete_graph(graph: tensorflow.python.framework.ops.Graph, sess: tensorflow.python.client.session.Session)[source]

                                                                                                                                Complete modifying the graph. Resets the pruned op’s variables using the created masks to zero out the pruned weights for saving.

                                                                                                                                @@ -1844,7 +1844,7 @@

                                                                                                                                Submodules
                                                                                                                                -create_ops(steps_per_epoch: int, global_step: tensorflow.python.framework.ops.Tensor, graph: tensorflow.python.framework.ops.Graph) → Tuple[List[Union[tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Operation]], Dict[str, Any]][source]
                                                                                                                                +create_ops(steps_per_epoch: int, global_step: tensorflow.python.framework.ops.Tensor, graph: tensorflow.python.framework.ops.Graph)Tuple[List[Union[tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Operation]], Dict[str, Any]][source]

                                                                                                                                Create the sparsity ops to modify the training graph according to the settings for the current instance.

                                                                                                                                @@ -1864,7 +1864,7 @@

                                                                                                                                Submodules
                                                                                                                                -initialize_session(sess: tensorflow.python.client.session.Session)[source]
                                                                                                                                +initialize_session(sess: tensorflow.python.client.session.Session)[source]

                                                                                                                                Initialize the mask variables for pruning.

                                                                                                                                Parameters
                                                                                                                                @@ -1875,12 +1875,12 @@

                                                                                                                                Submodules
                                                                                                                                -ks_group
                                                                                                                                +ks_group

                                                                                                                                -params
                                                                                                                                +params

                                                                                                                                List of str for the variable names or regex patterns of names to apply the pruning modifier to. Regex patterns must be specified with the prefix ‘re:’.

                                                                                                                                @@ -1893,7 +1893,7 @@

                                                                                                                                Submodules
                                                                                                                                -property prune_op_vars
                                                                                                                                +property prune_op_vars

                                                                                                                                the created pruning op vars in the graph if create_ops has been called, else None

                                                                                                                                @@ -1905,7 +1905,7 @@

                                                                                                                                Submodules
                                                                                                                                -property sparsity
                                                                                                                                +property sparsity

                                                                                                                                the created sparsity tensor for setting the pruning ops if create_ops has been called, else None

                                                                                                                                @@ -1917,7 +1917,7 @@

                                                                                                                                Submodules
                                                                                                                                -property update_ready
                                                                                                                                +property update_ready

                                                                                                                                the created update_ready tensor for setting the pruning ops if create_ops has been called, else None

                                                                                                                                @@ -1931,7 +1931,7 @@

                                                                                                                                Submodules
                                                                                                                                -class sparseml.tensorflow_v1.optim.modifier_pruning.GMPruningModifier(params: Union[str, List[str]], init_sparsity: float, final_sparsity: float, start_epoch: float, end_epoch: float, update_frequency: float, inter_func: str = 'cubic', log_types: Union[str, List[str]] = '__ALL__', mask_type: Union[str, List[int], sparseml.tensorflow_v1.optim.mask_creator_pruning.PruningMaskCreator] = 'unstructured', leave_enabled: bool = True)[source]
                                                                                                                                +class sparseml.tensorflow_v1.optim.modifier_pruning.GMPruningModifier(params: Union[str, List[str]], init_sparsity: float, final_sparsity: float, start_epoch: float, end_epoch: float, update_frequency: float, inter_func: str = 'cubic', log_types: Union[str, List[str]] = '__ALL__', mask_type: Union[str, List[int], sparseml.tensorflow_v1.optim.mask_creator_pruning.PruningMaskCreator] = 'unstructured', leave_enabled: bool = True)[source]

                                                                                                                                Bases: sparseml.tensorflow_v1.optim.modifier.ScheduledUpdateModifier

                                                                                                                                Gradually applies kernel sparsity to a given variable or variables from init_sparsity until final_sparsity is reached over a given amount of time and @@ -1986,7 +1986,7 @@

                                                                                                                                Submodules
                                                                                                                                -complete_graph(graph: tensorflow.python.framework.ops.Graph, sess: tensorflow.python.client.session.Session)[source]
                                                                                                                                +complete_graph(graph: tensorflow.python.framework.ops.Graph, sess: tensorflow.python.client.session.Session)[source]

                                                                                                                                Complete modifying the graph. Resets the pruned op’s variables using the created masks to zero out the pruned weights for saving.

                                                                                                                                @@ -2007,7 +2007,7 @@

                                                                                                                                Submodules
                                                                                                                                -create_ops(steps_per_epoch: int, global_step: tensorflow.python.framework.ops.Tensor, graph: tensorflow.python.framework.ops.Graph) → Tuple[List[Union[tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Operation]], Dict[str, Any]][source]
                                                                                                                                +create_ops(steps_per_epoch: int, global_step: tensorflow.python.framework.ops.Tensor, graph: tensorflow.python.framework.ops.Graph)Tuple[List[Union[tensorflow.python.framework.ops.Tensor, tensorflow.python.framework.ops.Operation]], Dict[str, Any]][source]

                                                                                                                                Create the sparsity ops to modify the training graph according to the settings for the current instance.

                                                                                                                                @@ -2027,12 +2027,12 @@

                                                                                                                                Submodules
                                                                                                                                -exponent
                                                                                                                                +exponent

                                                                                                                                -final_sparsity
                                                                                                                                +final_sparsity

                                                                                                                                The final sparsity for the variable to end with at end_epoch

                                                                                                                                Type
                                                                                                                                @@ -2043,7 +2043,7 @@

                                                                                                                                Submodules
                                                                                                                                -init_sparsity
                                                                                                                                +init_sparsity

                                                                                                                                The initial sparsity for the variable to start with at start_epoch

                                                                                                                                Type
                                                                                                                                @@ -2054,7 +2054,7 @@

                                                                                                                                Submodules
                                                                                                                                -initialize_session(sess: tensorflow.python.client.session.Session)[source]
                                                                                                                                +initialize_session(sess: tensorflow.python.client.session.Session)[source]

                                                                                                                                Initialize the mask variables for pruning.

                                                                                                                                Parameters
                                                                                                                                @@ -2065,7 +2065,7 @@

                                                                                                                                Submodules
                                                                                                                                -inter_func
                                                                                                                                +inter_func

                                                                                                                                The type of interpolation function to use: [linear, cubic, inverse_cubic]

                                                                                                                                @@ -2077,12 +2077,12 @@

                                                                                                                                Submodules
                                                                                                                                -ks_group
                                                                                                                                +ks_group

                                                                                                                                -leave_enabled
                                                                                                                                +leave_enabled

                                                                                                                                True to continue masking the weights after end_epoch, False to stop masking. Note, if set as False, sparsity will not be enforced and the model will likely deviate from the sparse solution

                                                                                                                                @@ -2095,7 +2095,7 @@

                                                                                                                                Submodules
                                                                                                                                -mask_type
                                                                                                                                +mask_type

                                                                                                                                the SparsityMaskCreator object used

                                                                                                                                Type
                                                                                                                                @@ -2106,7 +2106,7 @@

                                                                                                                                Submodules
                                                                                                                                -params
                                                                                                                                +params

                                                                                                                                List of str for the variable names or regex patterns of names to apply the pruning modifier to. Regex patterns must be specified with the prefix ‘re:’.

                                                                                                                                @@ -2119,7 +2119,7 @@

                                                                                                                                Submodules
                                                                                                                                -property prune_op_vars
                                                                                                                                +property prune_op_vars

                                                                                                                                the created pruning op vars in the graph if create_ops has been called, else None

                                                                                                                                @@ -2131,7 +2131,7 @@

                                                                                                                                Submodules
                                                                                                                                -property sparsity
                                                                                                                                +property sparsity

                                                                                                                                the created sparsity tensor for setting the pruning ops if create_ops has been called, else None

                                                                                                                                @@ -2143,7 +2143,7 @@

                                                                                                                                Submodules
                                                                                                                                -property update_ready
                                                                                                                                +property update_ready

                                                                                                                                the created update_ready tensor for setting the pruning ops if create_ops has been called, else None

                                                                                                                                @@ -2155,7 +2155,7 @@

                                                                                                                                Submodules
                                                                                                                                -validate()[source]
                                                                                                                                +validate()[source]

                                                                                                                                Validate the values of the params for the current instance are valid

                                                                                                                                @@ -2167,7 +2167,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparseml.tensorflow_v1.optim.schedule_lr.multi_step_lr_schedule(global_step: tensorflow.python.framework.ops.Tensor, start_step: int, milestone_steps: List[int], init_lr: float, gamma: float, name: str = 'multi_step_lr_schedule')[source]
                                                                                                                                +sparseml.tensorflow_v1.optim.schedule_lr.multi_step_lr_schedule(global_step: tensorflow.python.framework.ops.Tensor, start_step: int, milestone_steps: List[int], init_lr: float, gamma: float, name: str = 'multi_step_lr_schedule')[source]

                                                                                                                                Create a multi step learning rate schedule in the current graph. Multiplies init_lr by gamma after each milestone has passed. Ex: lr = init_lr * (gamma ** NUM_UPDATES)

                                                                                                                                @@ -2191,7 +2191,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparseml.tensorflow_v1.optim.schedule_lr.step_lr_schedule(global_step: tensorflow.python.framework.ops.Tensor, start_step: int, end_step: int, step_size: int, init_lr: float, gamma: float, name: str = 'exponential_lr_schedule') → tensorflow.python.framework.ops.Tensor[source]
                                                                                                                                +sparseml.tensorflow_v1.optim.schedule_lr.step_lr_schedule(global_step: tensorflow.python.framework.ops.Tensor, start_step: int, end_step: int, step_size: int, init_lr: float, gamma: float, name: str = 'exponential_lr_schedule')tensorflow.python.framework.ops.Tensor[source]

                                                                                                                                Create an exponential learning rate schedule in the current graph. Multiplies init_lr by gamma after each step_size interval has passed. Ex: lr = init_lr * (gamma ** NUM_UPDATES)

                                                                                                                                @@ -2220,17 +2220,17 @@

                                                                                                                                Submodules
                                                                                                                                -class sparseml.tensorflow_v1.optim.sensitivity_pruning.SparsePruningOpVars(op_vars, sparsity)
                                                                                                                                +class sparseml.tensorflow_v1.optim.sensitivity_pruning.SparsePruningOpVars(op_vars, sparsity)

                                                                                                                                Bases: tuple

                                                                                                                                -property op_vars
                                                                                                                                +property op_vars

                                                                                                                                Alias for field number 0

                                                                                                                                -property sparsity
                                                                                                                                +property sparsity

                                                                                                                                Alias for field number 1

                                                                                                                                @@ -2238,7 +2238,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparseml.tensorflow_v1.optim.sensitivity_pruning.pruning_loss_sens_magnitude(graph: Optional[tensorflow.python.framework.ops.Graph] = None, sess: Optional[tensorflow.python.client.session.Session] = None, sparsity_levels: Union[List[float], Tuple[float, ]] = (0.0, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.2, 0.21, 0.22, 0.23, 0.24, 0.25, 0.26, 0.27, 0.28, 0.29, 0.3, 0.31, 0.32, 0.33, 0.34, 0.35, 0.36, 0.37, 0.38, 0.39, 0.4, 0.41, 0.42, 0.43, 0.44, 0.45, 0.46, 0.47, 0.48, 0.49, 0.5, 0.51, 0.52, 0.53, 0.54, 0.55, 0.56, 0.57, 0.58, 0.59, 0.6, 0.61, 0.62, 0.63, 0.64, 0.65, 0.66, 0.67, 0.68, 0.69, 0.7, 0.71, 0.72, 0.73, 0.74, 0.75, 0.76, 0.77, 0.78, 0.79, 0.8, 0.81, 0.82, 0.83, 0.84, 0.85, 0.86, 0.87, 0.88, 0.89, 0.9, 0.91, 0.92, 0.93, 0.94, 0.95, 0.96, 0.97, 0.98, 0.99))sparseml.optim.sensitivity.PruningLossSensitivityAnalysis[source]
                                                                                                                                +sparseml.tensorflow_v1.optim.sensitivity_pruning.pruning_loss_sens_magnitude(graph: Optional[tensorflow.python.framework.ops.Graph] = None, sess: Optional[tensorflow.python.client.session.Session] = None, sparsity_levels: Union[List[float], Tuple[float, ]] = (0.0, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.2, 0.21, 0.22, 0.23, 0.24, 0.25, 0.26, 0.27, 0.28, 0.29, 0.3, 0.31, 0.32, 0.33, 0.34, 0.35, 0.36, 0.37, 0.38, 0.39, 0.4, 0.41, 0.42, 0.43, 0.44, 0.45, 0.46, 0.47, 0.48, 0.49, 0.5, 0.51, 0.52, 0.53, 0.54, 0.55, 0.56, 0.57, 0.58, 0.59, 0.6, 0.61, 0.62, 0.63, 0.64, 0.65, 0.66, 0.67, 0.68, 0.69, 0.7, 0.71, 0.72, 0.73, 0.74, 0.75, 0.76, 0.77, 0.78, 0.79, 0.8, 0.81, 0.82, 0.83, 0.84, 0.85, 0.86, 0.87, 0.88, 0.89, 0.9, 0.91, 0.92, 0.93, 0.94, 0.95, 0.96, 0.97, 0.98, 0.99))sparseml.optim.sensitivity.PruningLossSensitivityAnalysis[source]

                                                                                                                                Approximated kernel sparsity (pruning) loss analysis for a given model. Returns the results for each prunable param (conv, linear) in the model. Approximated by taking the magnitudes of the weights.

                                                                                                                                @@ -2259,7 +2259,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparseml.tensorflow_v1.optim.sensitivity_pruning.pruning_loss_sens_one_shot(op_vars: List[sparseml.tensorflow_v1.optim.sensitivity_pruning.SparsePruningOpVars], loss_tensor: tensorflow.python.framework.ops.Tensor, steps_per_measurement: int, add_ops_creator: Optional[Callable[int, List[tensorflow.python.framework.ops.Tensor]]] = None, feed_dict_creator: Optional[Callable[int, Dict[str, tensorflow.python.framework.ops.Tensor]]] = None, sess: Optional[tensorflow.python.client.session.Session] = None, sparsity_levels: List[int] = (0.0, 0.2, 0.4, 0.6, 0.7, 0.8, 0.85, 0.9, 0.95, 0.99), show_progress: bool = True)sparseml.optim.sensitivity.PruningLossSensitivityAnalysis[source]
                                                                                                                                +sparseml.tensorflow_v1.optim.sensitivity_pruning.pruning_loss_sens_one_shot(op_vars: List[sparseml.tensorflow_v1.optim.sensitivity_pruning.SparsePruningOpVars], loss_tensor: tensorflow.python.framework.ops.Tensor, steps_per_measurement: int, add_ops_creator: Optional[Callable[int, List[tensorflow.python.framework.ops.Tensor]]] = None, feed_dict_creator: Optional[Callable[int, Dict[str, tensorflow.python.framework.ops.Tensor]]] = None, sess: Optional[tensorflow.python.client.session.Session] = None, sparsity_levels: List[int] = (0.0, 0.2, 0.4, 0.6, 0.7, 0.8, 0.85, 0.9, 0.95, 0.99), show_progress: bool = True)sparseml.optim.sensitivity.PruningLossSensitivityAnalysis[source]

                                                                                                                                Run a one shot sensitivity analysis for kernel sparsity. It does not retrain, and instead puts the model to eval mode. Moves operation by operation to calculate the sensitivity analysis for each and @@ -2294,7 +2294,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparseml.tensorflow_v1.optim.sensitivity_pruning.pruning_loss_sens_op_vars(graph: Optional[tensorflow.python.framework.ops.Graph] = None, var_names: Union[List[str], Tuple[str]] = ('re:.*'), mask_type: Union[str, List[int], sparseml.tensorflow_v1.optim.mask_creator_pruning.PruningMaskCreator] = 'unstructured') → List[sparseml.tensorflow_v1.optim.sensitivity_pruning.SparsePruningOpVars][source]
                                                                                                                                +sparseml.tensorflow_v1.optim.sensitivity_pruning.pruning_loss_sens_op_vars(graph: Optional[tensorflow.python.framework.ops.Graph] = None, var_names: Union[List[str], Tuple[str]] = ('re:.*'), mask_type: Union[str, List[int], sparseml.tensorflow_v1.optim.mask_creator_pruning.PruningMaskCreator] = 'unstructured')List[sparseml.tensorflow_v1.optim.sensitivity_pruning.SparsePruningOpVars][source]

                                                                                                                                Edit the graph for to inject pruning ops and vars to allow for a ks loss sensitivity analysis.

                                                                                                                                Note: this must be run outside of a session for it to take effect.

                                                                                                                                diff --git a/sparseml/api/sparseml.tensorflow_v1.utils.html b/sparseml/api/sparseml.tensorflow_v1.utils.html index 004591f83ab..bc49afbddaa 100644 --- a/sparseml/api/sparseml.tensorflow_v1.utils.html +++ b/sparseml/api/sparseml.tensorflow_v1.utils.html @@ -210,7 +210,7 @@

                                                                                                                                Submodules
                                                                                                                                -class sparseml.tensorflow_v1.utils.exporter.GraphExporter(output_dir: str)[source]
                                                                                                                                +class sparseml.tensorflow_v1.utils.exporter.GraphExporter(output_dir: str)[source]

                                                                                                                                Bases: object

                                                                                                                                An exporter for exporting TensorFlow graphs and sessions into ONNX format as well as numpy arrays for the intput and output tensors

                                                                                                                                @@ -221,12 +221,12 @@

                                                                                                                                Submodules
                                                                                                                                -property checkpoint_path
                                                                                                                                +property checkpoint_path

                                                                                                                                -export_checkpoint(saver: Optional[tensorflow.python.training.saver.Saver] = None, sess: Optional[tensorflow.python.client.session.Session] = None)[source]
                                                                                                                                +export_checkpoint(saver: Optional[tensorflow.python.training.saver.Saver] = None, sess: Optional[tensorflow.python.client.session.Session] = None)[source]

                                                                                                                                Export a checkpoint for the current TensorFlow graph and session.

                                                                                                                                Parameters
                                                                                                                                @@ -242,7 +242,7 @@

                                                                                                                                Submodules
                                                                                                                                -export_named_samples(inp_dict: Dict[Union[str, tensorflow.python.framework.ops.Tensor], numpy.ndarray], out_dict: Dict[Union[str, tensorflow.python.framework.ops.Tensor], numpy.ndarray])[source]
                                                                                                                                +export_named_samples(inp_dict: Dict[Union[str, tensorflow.python.framework.ops.Tensor], numpy.ndarray], out_dict: Dict[Union[str, tensorflow.python.framework.ops.Tensor], numpy.ndarray])[source]

                                                                                                                                Export sample inputs and outputs for the model to the local system.

                                                                                                                                Parameters
                                                                                                                                @@ -256,7 +256,7 @@

                                                                                                                                Submodules
                                                                                                                                -export_onnx(inputs: List[Union[str, tensorflow.python.framework.ops.Tensor]], outputs: List[Union[str, tensorflow.python.framework.ops.Tensor]], opset: int = 11, custom_op_handlers=None, extra_opset=None, shape_override: Optional[Dict[str, List]] = None)[source]
                                                                                                                                +export_onnx(inputs: List[Union[str, tensorflow.python.framework.ops.Tensor]], outputs: List[Union[str, tensorflow.python.framework.ops.Tensor]], opset: int = 11, custom_op_handlers=None, extra_opset=None, shape_override: Optional[Dict[str, List]] = None)[source]

                                                                                                                                Export an ONNX format for the graph from the PB format. Should not be called within an active graph or session.

                                                                                                                                @@ -277,7 +277,7 @@

                                                                                                                                Submodules
                                                                                                                                -export_pb(outputs: List[Union[str, tensorflow.python.framework.ops.Tensor]], graph: Optional[tensorflow.python.framework.ops.Graph] = None, sess: Optional[tensorflow.python.client.session.Session] = None)[source]
                                                                                                                                +export_pb(outputs: List[Union[str, tensorflow.python.framework.ops.Tensor]], graph: Optional[tensorflow.python.framework.ops.Graph] = None, sess: Optional[tensorflow.python.client.session.Session] = None)[source]

                                                                                                                                Export a serialized pb version of the a graph and session.

                                                                                                                                Parameters
                                                                                                                                @@ -296,7 +296,7 @@

                                                                                                                                Submodules
                                                                                                                                -export_samples(inp_tensors: List[tensorflow.python.framework.ops.Tensor], inp_vals: List[numpy.ndarray], out_tensors: List[tensorflow.python.framework.ops.Tensor], sess: tensorflow.python.client.session.Session) → List[tensorflow.python.framework.ops.Tensor][source]
                                                                                                                                +export_samples(inp_tensors: List[tensorflow.python.framework.ops.Tensor], inp_vals: List[numpy.ndarray], out_tensors: List[tensorflow.python.framework.ops.Tensor], sess: tensorflow.python.client.session.Session)List[tensorflow.python.framework.ops.Tensor][source]

                                                                                                                                Export sample tensors for the model to the local system. Executes the inputs through the model using a session to get the outputs.

                                                                                                                                @@ -315,17 +315,17 @@

                                                                                                                                Submodules
                                                                                                                                -property onnx_path
                                                                                                                                +property onnx_path

                                                                                                                                -property pb_path
                                                                                                                                +property pb_path
                                                                                                                                -static pb_to_onnx(inputs: List[Union[str, tensorflow.python.framework.ops.Tensor]], outputs: List[Union[str, tensorflow.python.framework.ops.Tensor]], pb_path: str, onnx_path: str, opset: int = 11, custom_op_handlers=None, extra_opset=None, shape_override: Optional[Dict[str, List]] = None)[source]
                                                                                                                                +static pb_to_onnx(inputs: List[Union[str, tensorflow.python.framework.ops.Tensor]], outputs: List[Union[str, tensorflow.python.framework.ops.Tensor]], pb_path: str, onnx_path: str, opset: int = 11, custom_op_handlers=None, extra_opset=None, shape_override: Optional[Dict[str, List]] = None)[source]

                                                                                                                                Export an ONNX format for the graph from PB format. Should not be called within an active graph or session.

                                                                                                                                @@ -348,24 +348,24 @@

                                                                                                                                Submodules
                                                                                                                                -property sample_inputs_path
                                                                                                                                +property sample_inputs_path

                                                                                                                                -property sample_outputs_path
                                                                                                                                +property sample_outputs_path
                                                                                                                                -property tensorflow_path
                                                                                                                                +property tensorflow_path
                                                                                                                                -sparseml.tensorflow_v1.utils.exporter.default_onnx_opset() → int[source]
                                                                                                                                +sparseml.tensorflow_v1.utils.exporter.default_onnx_opset()int[source]

                                                                                                                                @@ -373,7 +373,7 @@

                                                                                                                                Submodules

                                                                                                                                sparseml.tensorflow_v1.utils.helpers module

                                                                                                                                -sparseml.tensorflow_v1.utils.helpers.tf_compat_div(x, y, name=None)
                                                                                                                                +sparseml.tensorflow_v1.utils.helpers.tf_compat_div(x, y, name=None)

                                                                                                                                Computes Python style division of x by y.

                                                                                                                                For example:

                                                                                                                                >>> x = tf.constant([16, 12, 11])
                                                                                                                                @@ -402,7 +402,7 @@ 

                                                                                                                                Submodules

                                                                                                                                sparseml.tensorflow_v1.utils.loss module

                                                                                                                                -sparseml.tensorflow_v1.utils.loss.accuracy(logits: tensorflow.python.framework.ops.Tensor, labels: tensorflow.python.framework.ops.Tensor, index: int = 1) → tensorflow.python.framework.ops.Tensor[source]
                                                                                                                                +sparseml.tensorflow_v1.utils.loss.accuracy(logits: tensorflow.python.framework.ops.Tensor, labels: tensorflow.python.framework.ops.Tensor, index: int = 1)tensorflow.python.framework.ops.Tensor[source]

                                                                                                                                Standard evaluation for accuracy.

                                                                                                                                Parameters
                                                                                                                                @@ -420,7 +420,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparseml.tensorflow_v1.utils.loss.batch_cross_entropy_loss(logits: tensorflow.python.framework.ops.Tensor, labels: tensorflow.python.framework.ops.Tensor) → tensorflow.python.framework.ops.Tensor[source]
                                                                                                                                +sparseml.tensorflow_v1.utils.loss.batch_cross_entropy_loss(logits: tensorflow.python.framework.ops.Tensor, labels: tensorflow.python.framework.ops.Tensor)tensorflow.python.framework.ops.Tensor[source]

                                                                                                                                Standard cross entropy loss that reduces across the batch dimension.

                                                                                                                                Parameters
                                                                                                                                @@ -441,7 +441,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparseml.tensorflow_v1.utils.nets_utils.get_gan_network_fn(name: str, is_training: bool = False)[source]
                                                                                                                                +sparseml.tensorflow_v1.utils.nets_utils.get_gan_network_fn(name: str, is_training: bool = False)[source]

                                                                                                                                Returns network_fn for a GAN sub-model

                                                                                                                                Parameters
                                                                                                                                @@ -461,7 +461,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparseml.tensorflow_v1.utils.nets_utils.get_model_scope(model_name: str, arg_scope_vars: Optional[Dict] = None)[source]
                                                                                                                                +sparseml.tensorflow_v1.utils.nets_utils.get_model_scope(model_name: str, arg_scope_vars: Optional[Dict] = None)[source]
                                                                                                                                Parameters
                                                                                                                                  @@ -477,7 +477,7 @@

                                                                                                                                  Submodules
                                                                                                                                  -sparseml.tensorflow_v1.utils.nets_utils.get_network_fn(name: str, num_classes: int, weight_decay: float = 0.0, is_training: bool = False, arg_scope_vars: Optional[Dict] = None)[source]
                                                                                                                                  +sparseml.tensorflow_v1.utils.nets_utils.get_network_fn(name: str, num_classes: int, weight_decay: float = 0.0, is_training: bool = False, arg_scope_vars: Optional[Dict] = None)[source]

                                                                                                                                  Modified from slim/nets/nets_factory Returns a network_fn such as logits, end_points = network_fn(images).

                                                                                                                                  @@ -515,7 +515,7 @@

                                                                                                                                  Submodules
                                                                                                                                  -sparseml.tensorflow_v1.utils.nets_utils.mobilenet_v1_arg_scope(is_training: bool = True, weight_decay: float = 4e-05, stddev: float = 0.09, regularize_depthwise: bool = False, batch_norm_decay: float = 0.9997, batch_norm_epsilon: float = 0.001, batch_norm_updates_collections: tensorflow.python.framework.ops.GraphKeys = 'update_ops', normalizer_fn: Optional[Callable] = None)[source]
                                                                                                                                  +sparseml.tensorflow_v1.utils.nets_utils.mobilenet_v1_arg_scope(is_training: bool = True, weight_decay: float = 4e-05, stddev: float = 0.09, regularize_depthwise: bool = False, batch_norm_decay: float = 0.9997, batch_norm_epsilon: float = 0.001, batch_norm_updates_collections: tensorflow.python.framework.ops.GraphKeys = 'update_ops', normalizer_fn: Optional[Callable] = None)[source]

                                                                                                                                  Adapted from slim to allow for Xavier initializer Defines the default MobilenetV1 arg scope.

                                                                                                                                  @@ -546,7 +546,7 @@

                                                                                                                                  Submodules
                                                                                                                                  -sparseml.tensorflow_v1.utils.summary.write_simple_summary(writer: tensorflow.python.summary.writer.writer.FileWriter, tag: str, val: Any, step: int)[source]
                                                                                                                                  +sparseml.tensorflow_v1.utils.summary.write_simple_summary(writer: tensorflow.python.summary.writer.writer.FileWriter, tag: str, val: Any, step: int)[source]

                                                                                                                                  Write a simple value summary to a writer

                                                                                                                                  Parameters
                                                                                                                                  @@ -565,7 +565,7 @@

                                                                                                                                  Submodules

                                                                                                                                  sparseml.tensorflow_v1.utils.variable module

                                                                                                                                  -sparseml.tensorflow_v1.utils.variable.any_str_or_regex_matches_tensor_name(tensor_name: str, name_or_regex_patterns: List[str])[source]
                                                                                                                                  +sparseml.tensorflow_v1.utils.variable.any_str_or_regex_matches_tensor_name(tensor_name: str, name_or_regex_patterns: List[str])[source]
                                                                                                                                  Parameters
                                                                                                                                    @@ -582,7 +582,7 @@

                                                                                                                                    Submodules
                                                                                                                                    -sparseml.tensorflow_v1.utils.variable.clean_tensor_name(var_tens: Union[str, tensorflow.python.framework.ops.Tensor]) → str[source]
                                                                                                                                    +sparseml.tensorflow_v1.utils.variable.clean_tensor_name(var_tens: Union[str, tensorflow.python.framework.ops.Tensor])str[source]
                                                                                                                                    Parameters

                                                                                                                                    var_tens – the tensor to get a variable for

                                                                                                                                    @@ -596,7 +596,7 @@

                                                                                                                                    Submodules
                                                                                                                                    -sparseml.tensorflow_v1.utils.variable.eval_tensor_density(tens: tensorflow.python.framework.ops.Tensor, sess: Optional[tensorflow.python.client.session.Session] = None) → float[source]
                                                                                                                                    +sparseml.tensorflow_v1.utils.variable.eval_tensor_density(tens: tensorflow.python.framework.ops.Tensor, sess: Optional[tensorflow.python.client.session.Session] = None)float[source]

                                                                                                                                    Get the density (fraction of non zero values) in a tensor

                                                                                                                                    Parameters
                                                                                                                                    @@ -614,7 +614,7 @@

                                                                                                                                    Submodules
                                                                                                                                    -sparseml.tensorflow_v1.utils.variable.eval_tensor_sparsity(tens: tensorflow.python.framework.ops.Tensor, sess: Optional[tensorflow.python.client.session.Session] = None) → float[source]
                                                                                                                                    +sparseml.tensorflow_v1.utils.variable.eval_tensor_sparsity(tens: tensorflow.python.framework.ops.Tensor, sess: Optional[tensorflow.python.client.session.Session] = None)float[source]

                                                                                                                                    Get the sparsity (fraction of zero values) in a tensor

                                                                                                                                    Parameters
                                                                                                                                    @@ -632,7 +632,7 @@

                                                                                                                                    Submodules
                                                                                                                                    -sparseml.tensorflow_v1.utils.variable.get_op_input_var(operation: tensorflow.python.framework.ops.Operation, var_index: Union[str, int] = 'from_trainable') → tensorflow.python.framework.ops.Tensor[source]
                                                                                                                                    +sparseml.tensorflow_v1.utils.variable.get_op_input_var(operation: tensorflow.python.framework.ops.Operation, var_index: Union[str, int] = 'from_trainable')tensorflow.python.framework.ops.Tensor[source]

                                                                                                                                    Get the input variable for an operation. Ex: the weight for a conv operator. See @get_op_var_index for proper values for var_index.

                                                                                                                                    @@ -651,7 +651,7 @@

                                                                                                                                    Submodules
                                                                                                                                    -sparseml.tensorflow_v1.utils.variable.get_op_var_index(var_index: Union[str, int], op_inputs: None) → int[source]
                                                                                                                                    +sparseml.tensorflow_v1.utils.variable.get_op_var_index(var_index: Union[str, int], op_inputs: None)int[source]

                                                                                                                                    Get the index of the variable input to an operation. Ex: getting the index of the weight for a convolutional operator.

                                                                                                                                    @@ -684,7 +684,7 @@

                                                                                                                                    Submodules
                                                                                                                                    -sparseml.tensorflow_v1.utils.variable.get_ops_and_inputs_by_name_or_regex(var_names: List[str], graph: Optional[tensorflow.python.framework.ops.Graph] = None) → List[Tuple[tensorflow.python.framework.ops.Operation, tensorflow.python.framework.ops.Tensor]][source]
                                                                                                                                    +sparseml.tensorflow_v1.utils.variable.get_ops_and_inputs_by_name_or_regex(var_names: List[str], graph: Optional[tensorflow.python.framework.ops.Graph] = None)List[Tuple[tensorflow.python.framework.ops.Operation, tensorflow.python.framework.ops.Tensor]][source]

                                                                                                                                    Get tuples of operations and the inputs for inputs of operations that match a regex pattern in the list params.

                                                                                                                                    @@ -706,7 +706,7 @@

                                                                                                                                    Submodules
                                                                                                                                    -sparseml.tensorflow_v1.utils.variable.get_prunable_ops(graph: Optional[tensorflow.python.framework.ops.Graph] = None) → List[Tuple[str, tensorflow.python.framework.ops.Operation]][source]
                                                                                                                                    +sparseml.tensorflow_v1.utils.variable.get_prunable_ops(graph: Optional[tensorflow.python.framework.ops.Graph] = None)List[Tuple[str, tensorflow.python.framework.ops.Operation]][source]

                                                                                                                                    Get the prunable operations from a TensorFlow graph.

                                                                                                                                    Parameters
                                                                                                                                    @@ -722,7 +722,7 @@

                                                                                                                                    Submodules
                                                                                                                                    -sparseml.tensorflow_v1.utils.variable.get_tensor_var(tens: tensorflow.python.framework.ops.Tensor) → tensorflow.python.ops.variables.VariableV1[source]
                                                                                                                                    +sparseml.tensorflow_v1.utils.variable.get_tensor_var(tens: tensorflow.python.framework.ops.Tensor)tensorflow.python.ops.variables.VariableV1[source]

                                                                                                                                    Get the variable associated with a given tensor. Raises a ValueError if not found

                                                                                                                                    @@ -737,7 +737,7 @@

                                                                                                                                    Submodules
                                                                                                                                    -sparseml.tensorflow_v1.utils.variable.is_prunable_op(op: tensorflow.python.framework.ops.Operation)[source]
                                                                                                                                    +sparseml.tensorflow_v1.utils.variable.is_prunable_op(op: tensorflow.python.framework.ops.Operation)[source]

                                                                                                                                    Check whether an op is prunable

                                                                                                                                    Parameters
                                                                                                                                    diff --git a/sparseml/api/sparseml.utils.datasets.html b/sparseml/api/sparseml.utils.datasets.html index 7fd2a97ae68..9d07b09afae 100644 --- a/sparseml/api/sparseml.utils.datasets.html +++ b/sparseml/api/sparseml.utils.datasets.html @@ -215,7 +215,7 @@

                                                                                                                                    Submodules
                                                                                                                                    -sparseml.utils.datasets.helpers.default_dataset_path(name: str) → str[source]
                                                                                                                                    +sparseml.utils.datasets.helpers.default_dataset_path(name: str)str[source]
                                                                                                                                    Parameters

                                                                                                                                    name – name of the dataset to get a path for

                                                                                                                                    @@ -240,7 +240,7 @@

                                                                                                                                    Submoduleshere.

                                                                                                                                    -class sparseml.utils.datasets.imagenette.ImagenetteDownloader(download_root: str, dataset_size: sparseml.utils.datasets.imagenette.ImagenetteSize, download: bool)[source]
                                                                                                                                    +class sparseml.utils.datasets.imagenette.ImagenetteDownloader(download_root: str, dataset_size: sparseml.utils.datasets.imagenette.ImagenetteSize, download: bool)[source]

                                                                                                                                    Bases: object

                                                                                                                                    Downloader implementation for the imagenette dataset. More info on the dataset can be found @@ -257,7 +257,7 @@

                                                                                                                                    Submodules
                                                                                                                                    -property dataset_size
                                                                                                                                    +property dataset_size

                                                                                                                                    which dataset size to download

                                                                                                                                    Type
                                                                                                                                    @@ -268,7 +268,7 @@

                                                                                                                                    Submodules
                                                                                                                                    -property download
                                                                                                                                    +property download

                                                                                                                                    True to run the download, False otherwise. If False, dataset must already exist at root.

                                                                                                                                    @@ -280,7 +280,7 @@

                                                                                                                                    Submodules
                                                                                                                                    -property download_root
                                                                                                                                    +property download_root

                                                                                                                                    the local path to download the files to

                                                                                                                                    Type
                                                                                                                                    @@ -291,7 +291,7 @@

                                                                                                                                    Submodules
                                                                                                                                    -property extracted_root
                                                                                                                                    +property extracted_root

                                                                                                                                    Where the specific dataset was extracted to

                                                                                                                                    Type
                                                                                                                                    @@ -302,7 +302,7 @@

                                                                                                                                    Submodules
                                                                                                                                    -split_root(train: bool) → str[source]
                                                                                                                                    +split_root(train: bool)str[source]
                                                                                                                                    Parameters

                                                                                                                                    train – True to get the path to the train dataset, False for validation

                                                                                                                                    @@ -317,7 +317,7 @@

                                                                                                                                    Submodules
                                                                                                                                    -class sparseml.utils.datasets.imagenette.ImagenetteSize(value)[source]
                                                                                                                                    +class sparseml.utils.datasets.imagenette.ImagenetteSize(value)[source]

                                                                                                                                    Bases: enum.Enum

                                                                                                                                    Dataset size for Imagenette / Imagewoof. full does not resize the original dataset at all. @@ -325,24 +325,24 @@

                                                                                                                                    Submodules
                                                                                                                                    -full = 'full'
                                                                                                                                    +full = 'full'

                                                                                                                                    -s160 = 's160'
                                                                                                                                    +s160 = 's160'
                                                                                                                                    -s320 = 's320'
                                                                                                                                    +s320 = 's320'

                                                                                                                                    -class sparseml.utils.datasets.imagenette.ImagewoofDownloader(download_root: str, dataset_size: sparseml.utils.datasets.imagenette.ImagenetteSize, download: bool)[source]
                                                                                                                                    +class sparseml.utils.datasets.imagenette.ImagewoofDownloader(download_root: str, dataset_size: sparseml.utils.datasets.imagenette.ImagenetteSize, download: bool)[source]

                                                                                                                                    Bases: object

                                                                                                                                    Downloader implementation for the imagewoof dataset. More info on the dataset can be found @@ -359,7 +359,7 @@

                                                                                                                                    Submodules
                                                                                                                                    -property dataset_size
                                                                                                                                    +property dataset_size

                                                                                                                                    which dataset size to download

                                                                                                                                    Type
                                                                                                                                    @@ -370,7 +370,7 @@

                                                                                                                                    Submodules
                                                                                                                                    -property download
                                                                                                                                    +property download

                                                                                                                                    True to run the download, False otherwise. If False, dataset must already exist at root.

                                                                                                                                    @@ -382,7 +382,7 @@

                                                                                                                                    Submodules
                                                                                                                                    -property download_root
                                                                                                                                    +property download_root

                                                                                                                                    the local path to download the files to

                                                                                                                                    Type
                                                                                                                                    @@ -393,7 +393,7 @@

                                                                                                                                    Submodules
                                                                                                                                    -property extracted_root
                                                                                                                                    +property extracted_root

                                                                                                                                    Where the specific dataset was extracted to

                                                                                                                                    Type
                                                                                                                                    @@ -404,7 +404,7 @@

                                                                                                                                    Submodules
                                                                                                                                    -split_root(train: bool) → str[source]
                                                                                                                                    +split_root(train: bool)str[source]
                                                                                                                                    Parameters

                                                                                                                                    train – True to get the path to the train dataset, False for validation

                                                                                                                                    diff --git a/sparseml/api/sparseml.utils.html b/sparseml/api/sparseml.utils.html index 4f4267e2a2e..a42631cc2c7 100644 --- a/sparseml/api/sparseml.utils.html +++ b/sparseml/api/sparseml.utils.html @@ -234,14 +234,14 @@

                                                                                                                                    Submodules
                                                                                                                                    -class sparseml.utils.helpers.NumpyArrayBatcher[source]
                                                                                                                                    +class sparseml.utils.helpers.NumpyArrayBatcher[source]

                                                                                                                                    Bases: object

                                                                                                                                    Batcher instance to handle taking in dictionaries of numpy arrays, appending multiple items to them to increase their batch size, and then stack them into a single batched numpy array for all keys in the dicts.

                                                                                                                                    -append(item: Union[numpy.ndarray, Dict[str, numpy.ndarray]])[source]
                                                                                                                                    +append(item: Union[numpy.ndarray, Dict[str, numpy.ndarray]])[source]

                                                                                                                                    Append a new item into the current batch. All keys and shapes must match the current state.

                                                                                                                                    @@ -253,7 +253,7 @@

                                                                                                                                    Submodules
                                                                                                                                    -stack() → Dict[str, numpy.ndarray][source]
                                                                                                                                    +stack()Dict[str, numpy.ndarray][source]

                                                                                                                                    Stack the current items into a batch along a new, zeroed dimension

                                                                                                                                    Returns
                                                                                                                                    @@ -266,7 +266,7 @@

                                                                                                                                    Submodules
                                                                                                                                    -sparseml.utils.helpers.bucket_iterable(val: Iterable[Any], num_buckets: int = 3, edge_percent: float = 0.05, sort_highest: bool = True, sort_key: Optional[Callable[Any, Any]] = None) → List[Tuple[int, Any]][source]
                                                                                                                                    +sparseml.utils.helpers.bucket_iterable(val: Iterable[Any], num_buckets: int = 3, edge_percent: float = 0.05, sort_highest: bool = True, sort_key: Optional[Callable[Any, Any]] = None)List[Tuple[int, Any]][source]

                                                                                                                                    Bucket iterable into subarray consisting of the first top percentage followed by the rest of the iterable sliced into equal sliced groups.

                                                                                                                                    @@ -293,7 +293,7 @@

                                                                                                                                    Submodules
                                                                                                                                    -sparseml.utils.helpers.clean_path(path: str) → str[source]
                                                                                                                                    +sparseml.utils.helpers.clean_path(path: str)str[source]
                                                                                                                                    Parameters

                                                                                                                                    path – the directory or file path to clean

                                                                                                                                    @@ -306,7 +306,7 @@

                                                                                                                                    Submodules
                                                                                                                                    -sparseml.utils.helpers.convert_to_bool(val: Any)[source]
                                                                                                                                    +sparseml.utils.helpers.convert_to_bool(val: Any)[source]
                                                                                                                                    Parameters

                                                                                                                                    val – the value to be converted to a bool, @@ -321,7 +321,7 @@

                                                                                                                                    Submodules
                                                                                                                                    -sparseml.utils.helpers.create_dirs(path: str)[source]
                                                                                                                                    +sparseml.utils.helpers.create_dirs(path: str)[source]
                                                                                                                                    Parameters

                                                                                                                                    path – the directory path to try and create

                                                                                                                                    @@ -331,7 +331,7 @@

                                                                                                                                    Submodules
                                                                                                                                    -sparseml.utils.helpers.create_parent_dirs(path: str)[source]
                                                                                                                                    +sparseml.utils.helpers.create_parent_dirs(path: str)[source]
                                                                                                                                    Parameters

                                                                                                                                    path – the file path to try to create the parent directories for

                                                                                                                                    @@ -341,7 +341,7 @@

                                                                                                                                    Submodules
                                                                                                                                    -sparseml.utils.helpers.create_unique_dir(path: str, check_number: int = 0) → str[source]
                                                                                                                                    +sparseml.utils.helpers.create_unique_dir(path: str, check_number: int = 0)str[source]
                                                                                                                                    Parameters
                                                                                                                                      @@ -358,7 +358,7 @@

                                                                                                                                      Submodules
                                                                                                                                      -sparseml.utils.helpers.flatten_iterable(li: Iterable)[source]
                                                                                                                                      +sparseml.utils.helpers.flatten_iterable(li: Iterable)[source]
                                                                                                                                      Parameters

                                                                                                                                      li – a possibly nested iterable of items to be flattened

                                                                                                                                      @@ -372,7 +372,7 @@

                                                                                                                                      Submodules
                                                                                                                                      -sparseml.utils.helpers.interpolate(x_cur: float, x0: float, x1: float, y0: Any, y1: Any, inter_func: str = 'linear') → Any[source]
                                                                                                                                      +sparseml.utils.helpers.interpolate(x_cur: float, x0: float, x1: float, y0: Any, y1: Any, inter_func: str = 'linear')Any[source]

                                                                                                                                      note, caps values at their min of x0 and max x1, designed to not work outside of that range for implementation reasons

                                                                                                                                      @@ -396,7 +396,7 @@

                                                                                                                                      Submodules
                                                                                                                                      -sparseml.utils.helpers.interpolate_list_linear(measurements: List[Tuple[float, float]], x_val: Union[float, List[float]]) → List[Tuple[float, float]][source]
                                                                                                                                      +sparseml.utils.helpers.interpolate_list_linear(measurements: List[Tuple[float, float]], x_val: Union[float, List[float]])List[Tuple[float, float]][source]

                                                                                                                                      interpolate for input values within a list of measurements linearly

                                                                                                                                      Parameters
                                                                                                                                      @@ -413,7 +413,7 @@

                                                                                                                                      Submodules
                                                                                                                                      -sparseml.utils.helpers.interpolated_integral(measurements: List[Tuple[float, float]])[source]
                                                                                                                                      +sparseml.utils.helpers.interpolated_integral(measurements: List[Tuple[float, float]])[source]

                                                                                                                                      Calculate the interpolated integal for a group of measurements of the form [(x0, y0), (x1, y1), …]

                                                                                                                                      @@ -428,7 +428,7 @@

                                                                                                                                      Submodules
                                                                                                                                      -sparseml.utils.helpers.is_url(val: str)[source]
                                                                                                                                      +sparseml.utils.helpers.is_url(val: str)[source]
                                                                                                                                      Parameters

                                                                                                                                      val – value to check if it is a url or not

                                                                                                                                      @@ -441,7 +441,7 @@

                                                                                                                                      Submodules
                                                                                                                                      -sparseml.utils.helpers.load_labeled_data(data: Union[str, Iterable[Union[str, numpy.ndarray, Dict[str, numpy.ndarray]]]], labels: Union[None, str, Iterable[Union[str, numpy.ndarray, Dict[str, numpy.ndarray]]]], raise_on_error: bool = True) → List[Tuple[Union[numpy.ndarray, Dict[str, numpy.ndarray]], Union[None, numpy.ndarray, Dict[str, numpy.ndarray]]]][source]
                                                                                                                                      +sparseml.utils.helpers.load_labeled_data(data: Union[str, Iterable[Union[str, numpy.ndarray, Dict[str, numpy.ndarray]]]], labels: Union[None, str, Iterable[Union[str, numpy.ndarray, Dict[str, numpy.ndarray]]]], raise_on_error: bool = True)List[Tuple[Union[numpy.ndarray, Dict[str, numpy.ndarray]], Union[None, numpy.ndarray, Dict[str, numpy.ndarray]]]][source]

                                                                                                                                      Load labels and data from disk or from memory and group them together. Assumes sorted ordering for on disk. Will match between when a file glob is passed for either data and/or labels.

                                                                                                                                      @@ -465,7 +465,7 @@

                                                                                                                                      Submodules
                                                                                                                                      -sparseml.utils.helpers.load_numpy(file_path: str) → Union[numpy.ndarray, Dict[str, numpy.ndarray]][source]
                                                                                                                                      +sparseml.utils.helpers.load_numpy(file_path: str)Union[numpy.ndarray, Dict[str, numpy.ndarray]][source]

                                                                                                                                      Load a numpy file into either an ndarray or an OrderedDict representing what was in the npz file

                                                                                                                                      @@ -480,7 +480,7 @@

                                                                                                                                      Submodules
                                                                                                                                      -sparseml.utils.helpers.load_recipe_yaml_str(file_path: Union[str, sparsezoo.objects.optimization_recipe.OptimizationRecipe]) → str[source]
                                                                                                                                      +sparseml.utils.helpers.load_recipe_yaml_str(file_path: Union[str, sparsezoo.objects.optimization_recipe.OptimizationRecipe])str[source]

                                                                                                                                      Loads a YAML recipe file to a string or extracts recipe from YAML front matter in a sparsezoo markdown recipe card. Recipes can also be provided as SparseZoo model stubs or OptimizationRecipe @@ -503,7 +503,7 @@

                                                                                                                                      Submodules
                                                                                                                                      -sparseml.utils.helpers.parse_optimization_str(optim_full_name: str) → Tuple[str, str, Any][source]
                                                                                                                                      +sparseml.utils.helpers.parse_optimization_str(optim_full_name: str)Tuple[str, str, Any][source]
                                                                                                                                      Parameters

                                                                                                                                      optim_full_name – A name of a pretrained model optimization. i.e. @@ -519,7 +519,7 @@

                                                                                                                                      Submodules
                                                                                                                                      -sparseml.utils.helpers.path_file_count(path: str, pattern: str = '*') → int[source]
                                                                                                                                      +sparseml.utils.helpers.path_file_count(path: str, pattern: str = '*')int[source]

                                                                                                                                      Return the number of files that match the given pattern under the given path

                                                                                                                                      Parameters
                                                                                                                                      @@ -536,7 +536,7 @@

                                                                                                                                      Submodules
                                                                                                                                      -sparseml.utils.helpers.path_file_size(path: str) → int[source]
                                                                                                                                      +sparseml.utils.helpers.path_file_size(path: str)int[source]

                                                                                                                                      Return the total size, in bytes, for a path on the file system

                                                                                                                                      Parameters
                                                                                                                                      @@ -550,7 +550,7 @@

                                                                                                                                      Submodules
                                                                                                                                      -sparseml.utils.helpers.save_numpy(array: Union[numpy.ndarray, Dict[str, numpy.ndarray], Iterable[numpy.ndarray]], export_dir: str, name: str, npz: bool = True)[source]
                                                                                                                                      +sparseml.utils.helpers.save_numpy(array: Union[numpy.ndarray, Dict[str, numpy.ndarray], Iterable[numpy.ndarray]], export_dir: str, name: str, npz: bool = True)[source]

                                                                                                                                      Save a numpy array or collection of numpy arrays to disk

                                                                                                                                      Parameters
                                                                                                                                      @@ -570,7 +570,7 @@

                                                                                                                                      Submodules
                                                                                                                                      -sparseml.utils.helpers.tensor_export(tensor: Union[numpy.ndarray, Dict[str, numpy.ndarray], Iterable[numpy.ndarray]], export_dir: str, name: str, npz: bool = True) → str[source]
                                                                                                                                      +sparseml.utils.helpers.tensor_export(tensor: Union[numpy.ndarray, Dict[str, numpy.ndarray], Iterable[numpy.ndarray]], export_dir: str, name: str, npz: bool = True)str[source]
                                                                                                                                      Parameters
                                                                                                                                        @@ -588,7 +588,7 @@

                                                                                                                                        Submodules
                                                                                                                                        -sparseml.utils.helpers.tensors_export(tensors: Union[numpy.ndarray, Dict[str, numpy.ndarray], Iterable[numpy.ndarray]], export_dir: str, name_prefix: str, counter: int = 0, break_batch: bool = False) → List[str][source]
                                                                                                                                        +sparseml.utils.helpers.tensors_export(tensors: Union[numpy.ndarray, Dict[str, numpy.ndarray], Iterable[numpy.ndarray]], export_dir: str, name_prefix: str, counter: int = 0, break_batch: bool = False)List[str][source]
                                                                                                                                        Parameters
                                                                                                                                          @@ -610,7 +610,7 @@

                                                                                                                                          Submodules
                                                                                                                                          -sparseml.utils.helpers.validate_str_iterable(val: Union[str, Iterable[str]], error_desc: str = '') → Union[str, Iterable[str]][source]
                                                                                                                                          +sparseml.utils.helpers.validate_str_iterable(val: Union[str, Iterable[str]], error_desc: str = '')Union[str, Iterable[str]][source]
                                                                                                                                          Parameters
                                                                                                                                          -
                                                                                                                                        • get_grouping_fn() (sparseml.pytorch.optim.mask_creator_pruning.GroupedPruningMaskCreator static method) -
                                                                                                                                        • get_grouping_op() (sparseml.keras.optim.mask_pruning_creator.GroupedPruningMaskCreator static method)
                                                                                                                                            @@ -2981,6 +2979,8 @@

                                                                                                                                            R

                                                                                                                                          • random_scaling_crop() (in module sparseml.tensorflow_v1.datasets.helpers)
                                                                                                                                          • RECAL_UPDATE (sparseml.tensorflow_v1.optim.manager.ScheduledModifierManager attribute) +
                                                                                                                                          • +
                                                                                                                                          • reduce_tensor() (sparseml.pytorch.optim.mask_creator_pruning.GroupedPruningMaskCreator static method)
                                                                                                                                          • reg_func (sparseml.pytorch.optim.modifier_as.ASRegModifier attribute)
                                                                                                                                          • diff --git a/sparseml/objects.inv b/sparseml/objects.inv index 1a540491b5e..40e5f137875 100644 Binary files a/sparseml/objects.inv and b/sparseml/objects.inv differ diff --git a/sparseml/searchindex.js b/sparseml/searchindex.js index 3cb5748c165..251633b80c6 100644 --- a/sparseml/searchindex.js +++ b/sparseml/searchindex.js @@ -1 +1 @@ -Search.setIndex({docnames:["api/modules","api/sparseml","api/sparseml.keras","api/sparseml.keras.optim","api/sparseml.keras.utils","api/sparseml.onnx","api/sparseml.onnx.optim","api/sparseml.onnx.optim.quantization","api/sparseml.onnx.utils","api/sparseml.optim","api/sparseml.pytorch","api/sparseml.pytorch.datasets","api/sparseml.pytorch.datasets.classification","api/sparseml.pytorch.datasets.detection","api/sparseml.pytorch.datasets.recommendation","api/sparseml.pytorch.datasets.video","api/sparseml.pytorch.models","api/sparseml.pytorch.models.classification","api/sparseml.pytorch.models.detection","api/sparseml.pytorch.models.external","api/sparseml.pytorch.models.recommendation","api/sparseml.pytorch.nn","api/sparseml.pytorch.optim","api/sparseml.pytorch.optim.quantization","api/sparseml.pytorch.utils","api/sparseml.tensorflow_v1","api/sparseml.tensorflow_v1.datasets","api/sparseml.tensorflow_v1.datasets.classification","api/sparseml.tensorflow_v1.models","api/sparseml.tensorflow_v1.models.classification","api/sparseml.tensorflow_v1.nn","api/sparseml.tensorflow_v1.optim","api/sparseml.tensorflow_v1.utils","api/sparseml.utils","api/sparseml.utils.datasets","index","installation","quicktour","recipes"],envversion:{"sphinx.domains.c":2,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":3,"sphinx.domains.index":1,"sphinx.domains.javascript":2,"sphinx.domains.math":2,"sphinx.domains.python":2,"sphinx.domains.rst":2,"sphinx.domains.std":1,"sphinx.ext.intersphinx":1,"sphinx.ext.viewcode":1,sphinx:56},filenames:["api/modules.rst","api/sparseml.rst","api/sparseml.keras.rst","api/sparseml.keras.optim.rst","api/sparseml.keras.utils.rst","api/sparseml.onnx.rst","api/sparseml.onnx.optim.rst","api/sparseml.onnx.optim.quantization.rst","api/sparseml.onnx.utils.rst","api/sparseml.optim.rst","api/sparseml.pytorch.rst","api/sparseml.pytorch.datasets.rst","api/sparseml.pytorch.datasets.classification.rst","api/sparseml.pytorch.datasets.detection.rst","api/sparseml.pytorch.datasets.recommendation.rst","api/sparseml.pytorch.datasets.video.rst","api/sparseml.pytorch.models.rst","api/sparseml.pytorch.models.classification.rst","api/sparseml.pytorch.models.detection.rst","api/sparseml.pytorch.models.external.rst","api/sparseml.pytorch.models.recommendation.rst","api/sparseml.pytorch.nn.rst","api/sparseml.pytorch.optim.rst","api/sparseml.pytorch.optim.quantization.rst","api/sparseml.pytorch.utils.rst","api/sparseml.tensorflow_v1.rst","api/sparseml.tensorflow_v1.datasets.rst","api/sparseml.tensorflow_v1.datasets.classification.rst","api/sparseml.tensorflow_v1.models.rst","api/sparseml.tensorflow_v1.models.classification.rst","api/sparseml.tensorflow_v1.nn.rst","api/sparseml.tensorflow_v1.optim.rst","api/sparseml.tensorflow_v1.utils.rst","api/sparseml.utils.rst","api/sparseml.utils.datasets.rst","index.rst","installation.md","quicktour.md","recipes.md"],objects:{"":{sparseml:[1,0,0,"-"]},"sparseml.keras":{optim:[3,0,0,"-"],utils:[4,0,0,"-"]},"sparseml.keras.optim":{manager:[3,0,0,"-"],mask_pruning:[3,0,0,"-"],mask_pruning_creator:[3,0,0,"-"],modifier:[3,0,0,"-"],modifier_epoch:[3,0,0,"-"],modifier_lr:[3,0,0,"-"],modifier_params:[3,0,0,"-"],modifier_pruning:[3,0,0,"-"],utils:[3,0,0,"-"]},"sparseml.keras.optim.manager":{ScheduledModifierManager:[3,1,1,""]},"sparseml.keras.optim.manager.ScheduledModifierManager":{finalize:[3,2,1,""],from_yaml:[3,2,1,""],modify:[3,2,1,""]},"sparseml.keras.optim.mask_pruning":{MaskedLayer:[3,1,1,""],PruningScheduler:[3,1,1,""],remove_pruning_masks:[3,3,1,""]},"sparseml.keras.optim.mask_pruning.MaskedLayer":{build:[3,2,1,""],call:[3,2,1,""],compute_output_shape:[3,2,1,""],from_config:[3,2,1,""],get_config:[3,2,1,""],global_step:[3,2,1,""],mask_updater:[3,2,1,""],masked_layer:[3,2,1,""],masks:[3,2,1,""],pruned_layer:[3,2,1,""],pruning_vars:[3,2,1,""]},"sparseml.keras.optim.mask_pruning.PruningScheduler":{deserialize:[3,2,1,""],get_config:[3,2,1,""],should_prune:[3,2,1,""],target_sparsity:[3,2,1,""]},"sparseml.keras.optim.mask_pruning_creator":{BlockPruningMaskCreator:[3,1,1,""],DimensionPruningMaskCreator:[3,1,1,""],GroupedPruningMaskCreator:[3,1,1,""],PruningMaskCreator:[3,1,1,""],UnstructuredPruningMaskCreator:[3,1,1,""],load_mask_creator:[3,3,1,""]},"sparseml.keras.optim.mask_pruning_creator.BlockPruningMaskCreator":{group_tensor:[3,2,1,""]},"sparseml.keras.optim.mask_pruning_creator.DimensionPruningMaskCreator":{group_tensor:[3,2,1,""]},"sparseml.keras.optim.mask_pruning_creator.GroupedPruningMaskCreator":{create_sparsity_mask:[3,2,1,""],get_grouping_op:[3,2,1,""],get_mask_initializer:[3,2,1,""],group_tensor:[3,2,1,""]},"sparseml.keras.optim.mask_pruning_creator.PruningMaskCreator":{create_sparsity_mask:[3,2,1,""],get_mask_initializer:[3,2,1,""]},"sparseml.keras.optim.mask_pruning_creator.UnstructuredPruningMaskCreator":{create_sparsity_mask:[3,2,1,""],get_mask_initializer:[3,2,1,""]},"sparseml.keras.optim.modifier":{KerasModifierYAML:[3,1,1,""],Modifier:[3,1,1,""],ModifierProp:[3,1,1,""],ScheduledModifier:[3,1,1,""],ScheduledUpdateModifier:[3,1,1,""]},"sparseml.keras.optim.modifier.Modifier":{finalize:[3,2,1,""],load_list:[3,2,1,""],load_obj:[3,2,1,""],modify:[3,2,1,""]},"sparseml.keras.optim.modifier.ModifierProp":{getter:[3,2,1,""],no_serialize_val:[3,2,1,""],restrictions:[3,2,1,""],serializable:[3,2,1,""],setter:[3,2,1,""]},"sparseml.keras.optim.modifier.ScheduledModifier":{end_epoch:[3,2,1,""],start_end_steps:[3,2,1,""],start_epoch:[3,2,1,""]},"sparseml.keras.optim.modifier.ScheduledUpdateModifier":{update_frequency_steps:[3,2,1,""]},"sparseml.keras.optim.modifier_epoch":{EpochRangeModifier:[3,1,1,""]},"sparseml.keras.optim.modifier_lr":{LearningRateModifier:[3,1,1,""],SetLearningRateModifier:[3,1,1,""]},"sparseml.keras.optim.modifier_lr.LearningRateModifier":{modify:[3,2,1,""]},"sparseml.keras.optim.modifier_lr.SetLearningRateModifier":{modify:[3,2,1,""]},"sparseml.keras.optim.modifier_params":{TrainableParamsModifier:[3,1,1,""]},"sparseml.keras.optim.modifier_params.TrainableParamsModifier":{layer_names:[3,2,1,""],modify:[3,2,1,""],params:[3,4,1,""],params_strict:[3,4,1,""],trainable:[3,4,1,""],validate:[3,2,1,""]},"sparseml.keras.optim.modifier_pruning":{ConstantPruningModifier:[3,1,1,""],GMPruningModifier:[3,1,1,""]},"sparseml.keras.optim.modifier_pruning.ConstantPruningModifier":{finalize:[3,2,1,""],is_pruning_step:[3,2,1,""],layer_names:[3,2,1,""],modify:[3,2,1,""],params:[3,4,1,""],sparsity:[3,2,1,""],update_ready:[3,2,1,""]},"sparseml.keras.optim.modifier_pruning.GMPruningModifier":{exponent:[3,4,1,""],final_sparsity:[3,4,1,""],finalize:[3,2,1,""],init_sparsity:[3,4,1,""],inter_func:[3,4,1,""],layer_names:[3,2,1,""],leave_enabled:[3,4,1,""],mask_type:[3,4,1,""],modify:[3,2,1,""],params:[3,4,1,""],prunable_layers:[3,2,1,""],sparsity:[3,2,1,""],update_ready:[3,2,1,""],validate:[3,2,1,""]},"sparseml.keras.optim.utils":{get_layer_name_from_param:[3,3,1,""]},"sparseml.keras.utils":{callbacks:[4,0,0,"-"],exporter:[4,0,0,"-"],logger:[4,0,0,"-"],model:[4,0,0,"-"]},"sparseml.keras.utils.callbacks":{LoggerSettingCallback:[4,1,1,""],LossesAndMetricsLoggingCallback:[4,1,1,""]},"sparseml.keras.utils.callbacks.LoggerSettingCallback":{on_epoch_begin:[4,2,1,""],on_epoch_end:[4,2,1,""],on_predict_batch_begin:[4,2,1,""],on_predict_batch_end:[4,2,1,""],on_predict_begin:[4,2,1,""],on_predict_end:[4,2,1,""],on_test_batch_begin:[4,2,1,""],on_test_batch_end:[4,2,1,""],on_test_begin:[4,2,1,""],on_test_end:[4,2,1,""],on_train_batch_begin:[4,2,1,""],on_train_batch_end:[4,2,1,""],on_train_begin:[4,2,1,""],on_train_end:[4,2,1,""]},"sparseml.keras.utils.callbacks.LossesAndMetricsLoggingCallback":{on_epoch_end:[4,2,1,""],on_test_end:[4,2,1,""],on_train_batch_end:[4,2,1,""],on_train_begin:[4,2,1,""]},"sparseml.keras.utils.exporter":{ModelExporter:[4,1,1,""]},"sparseml.keras.utils.exporter.ModelExporter":{export_h5:[4,2,1,""],export_keras:[4,2,1,""],export_onnx:[4,2,1,""],export_samples:[4,2,1,""]},"sparseml.keras.utils.logger":{KerasLogger:[4,1,1,""],LoggingMode:[4,1,1,""],PythonLogger:[4,1,1,""],TensorBoardLogger:[4,1,1,""]},"sparseml.keras.utils.logger.KerasLogger":{log_scalar:[4,2,1,""],mode:[4,2,1,""],name:[4,2,1,""],update_freq:[4,2,1,""]},"sparseml.keras.utils.logger.LoggingMode":{PREDICT:[4,4,1,""],TEST:[4,4,1,""],TRAIN:[4,4,1,""]},"sparseml.keras.utils.logger.PythonLogger":{log_scalar:[4,2,1,""]},"sparseml.keras.utils.logger.TensorBoardLogger":{log_scalar:[4,2,1,""]},"sparseml.keras.utils.model":{sparsity:[4,3,1,""]},"sparseml.log":{get_main_logger:[1,3,1,""],get_nm_root_logger:[1,3,1,""],set_logging_level:[1,3,1,""]},"sparseml.onnx":{optim:[6,0,0,"-"],utils:[8,0,0,"-"]},"sparseml.onnx.optim":{analyzer_model:[6,0,0,"-"],quantization:[7,0,0,"-"],sensitivity_pruning:[6,0,0,"-"]},"sparseml.onnx.optim.analyzer_model":{ModelAnalyzer:[6,1,1,""],NodeAnalyzer:[6,1,1,""]},"sparseml.onnx.optim.analyzer_model.ModelAnalyzer":{dict:[6,2,1,""],from_dict:[6,2,1,""],get_node:[6,2,1,""],load_json:[6,2,1,""],nodes:[6,2,1,""],save_json:[6,2,1,""]},"sparseml.onnx.optim.analyzer_model.NodeAnalyzer":{attributes:[6,2,1,""],bias_name:[6,2,1,""],bias_shape:[6,2,1,""],dict:[6,2,1,""],flops:[6,2,1,""],id_:[6,2,1,""],input_names:[6,2,1,""],input_shapes:[6,2,1,""],op_type:[6,2,1,""],output_names:[6,2,1,""],output_shapes:[6,2,1,""],params:[6,2,1,""],prunable:[6,2,1,""],prunable_equation_sensitivity:[6,2,1,""],prunable_params:[6,2,1,""],prunable_params_zeroed:[6,2,1,""],weight_name:[6,2,1,""],weight_shape:[6,2,1,""]},"sparseml.onnx.optim.quantization":{calibration:[7,0,0,"-"],quantize:[7,0,0,"-"],quantize_model_post_training:[7,0,0,"-"]},"sparseml.onnx.optim.quantization.calibration":{CalibrationSession:[7,1,1,""]},"sparseml.onnx.optim.quantization.calibration.CalibrationSession":{add_reduce_to_node_output:[7,2,1,""],generate_augmented_model:[7,2,1,""],get_model_input_names:[7,2,1,""],get_quantization_params_dict:[7,2,1,""],model:[7,2,1,""],model_augmented:[7,2,1,""],process_batch:[7,2,1,""]},"sparseml.onnx.optim.quantization.quantize":{ONNXQuantizer:[7,1,1,""],QuantizationMode:[7,1,1,""],QuantizedInitializer:[7,1,1,""],QuantizedValue:[7,1,1,""],QuantizedValueType:[7,1,1,""],check_opset_version:[7,3,1,""],quantize:[7,3,1,""],quantize_data:[7,3,1,""]},"sparseml.onnx.optim.quantization.quantize.ONNXQuantizer":{find_weight_data:[7,2,1,""],quantize_model:[7,2,1,""]},"sparseml.onnx.optim.quantization.quantize.QuantizationMode":{IntegerOps:[7,4,1,""],QLinearOps:[7,4,1,""]},"sparseml.onnx.optim.quantization.quantize.QuantizedValueType":{Initializer:[7,4,1,""],Input:[7,4,1,""]},"sparseml.onnx.optim.quantization.quantize_model_post_training":{quantize_model_post_training:[7,3,1,""]},"sparseml.onnx.optim.sensitivity_pruning":{PruningLossSensitivityAnalysis:[6,1,1,""],PruningPerfSensitivityAnalysis:[6,1,1,""],PruningSensitivityResult:[6,1,1,""],pruning_loss_sens_approx:[6,3,1,""],pruning_loss_sens_magnitude:[6,3,1,""],pruning_loss_sens_magnitude_iter:[6,3,1,""],pruning_loss_sens_one_shot:[6,3,1,""],pruning_loss_sens_one_shot_iter:[6,3,1,""],pruning_perf_sens_one_shot:[6,3,1,""],pruning_perf_sens_one_shot_iter:[6,3,1,""]},"sparseml.onnx.optim.sensitivity_pruning.PruningLossSensitivityAnalysis":{add_result:[6,2,1,""],dict:[6,2,1,""],from_dict:[6,2,1,""],get_result:[6,2,1,""],load_json:[6,2,1,""],plot:[6,2,1,""],print_res:[6,2,1,""],results:[6,2,1,""],results_model:[6,2,1,""],save_json:[6,2,1,""]},"sparseml.onnx.optim.sensitivity_pruning.PruningPerfSensitivityAnalysis":{add_model_result:[6,2,1,""],add_result:[6,2,1,""],batch_size:[6,2,1,""],dict:[6,2,1,""],from_dict:[6,2,1,""],get_result:[6,2,1,""],load_json:[6,2,1,""],num_cores:[6,2,1,""],plot:[6,2,1,""],print_res:[6,2,1,""],results:[6,2,1,""],results_model:[6,2,1,""],save_json:[6,2,1,""]},"sparseml.onnx.optim.sensitivity_pruning.PruningSensitivityResult":{add_measurement:[6,2,1,""],averages:[6,2,1,""],baseline_average:[6,2,1,""],baseline_measurement_index:[6,2,1,""],baseline_measurement_key:[6,2,1,""],dict:[6,2,1,""],from_dict:[6,2,1,""],has_baseline:[6,2,1,""],id_:[6,2,1,""],index:[6,2,1,""],name:[6,2,1,""],sparse_average:[6,2,1,""],sparse_comparison:[6,2,1,""],sparse_integral:[6,2,1,""],sparse_measurements:[6,2,1,""]},"sparseml.onnx.utils":{data:[8,0,0,"-"],graph_editor:[8,0,0,"-"],graph_optimizer:[8,0,0,"-"],helpers:[8,0,0,"-"],loss:[8,0,0,"-"],model:[8,0,0,"-"],sparse_tensor:[8,0,0,"-"]},"sparseml.onnx.utils.data":{DataLoader:[8,1,1,""]},"sparseml.onnx.utils.data.DataLoader":{batch_size:[8,2,1,""],from_model_random:[8,2,1,""],from_random:[8,2,1,""],infinite:[8,2,1,""],iter_steps:[8,2,1,""],labeled_data:[8,2,1,""]},"sparseml.onnx.utils.graph_editor":{override_model_batch_size:[8,3,1,""],prune_model_one_shot:[8,3,1,""],prune_model_one_shot_iter:[8,3,1,""],prune_unstructured:[8,3,1,""],remove_node_and_params_from_graph:[8,3,1,""],swap_node_output:[8,3,1,""],update_model_param:[8,3,1,""]},"sparseml.onnx.utils.graph_optimizer":{fold_conv_bns:[8,3,1,""],quantize_resnet_identity_add_inputs:[8,3,1,""]},"sparseml.onnx.utils.helpers":{BatchNormParams:[8,1,1,""],NodeParam:[8,1,1,""],NodeShape:[8,1,1,""],SparsityMeasurement:[8,1,1,""],calculate_flops:[8,3,1,""],check_load_model:[8,3,1,""],conv_node_params:[8,3,1,""],extract_node_id:[8,3,1,""],extract_node_shapes:[8,3,1,""],extract_nodes_shapes_ort:[8,3,1,""],extract_nodes_shapes_shape_inference:[8,3,1,""],extract_shape:[8,3,1,""],gemm_node_params:[8,3,1,""],get_attr_float_val_for_node:[8,3,1,""],get_batch_norm_params:[8,3,1,""],get_init_by_name:[8,3,1,""],get_kernel_shape:[8,3,1,""],get_node_attributes:[8,3,1,""],get_node_by_id:[8,3,1,""],get_node_input_nodes:[8,3,1,""],get_node_inputs:[8,3,1,""],get_node_output_nodes:[8,3,1,""],get_node_outputs:[8,3,1,""],get_node_params:[8,3,1,""],get_nodes_by_input_id:[8,3,1,""],get_nodes_by_output_id:[8,3,1,""],get_numpy_dtype:[8,3,1,""],get_prunable_node_from_foldable:[8,3,1,""],get_prunable_nodes:[8,3,1,""],get_quantize_parent_for_dequantize_node:[8,3,1,""],is_foldable_node:[8,3,1,""],is_prunable_node:[8,3,1,""],matmul_node_params:[8,3,1,""],model_inputs:[8,3,1,""],model_outputs:[8,3,1,""],onnx_nodes_sparsities:[8,3,1,""],validate_onnx_file:[8,3,1,""]},"sparseml.onnx.utils.helpers.BatchNormParams":{"var":[8,2,1,""],bias:[8,2,1,""],epsilon:[8,2,1,""],mean:[8,2,1,""],momentum:[8,2,1,""],scale:[8,2,1,""]},"sparseml.onnx.utils.helpers.NodeParam":{name:[8,2,1,""],val:[8,2,1,""]},"sparseml.onnx.utils.helpers.NodeShape":{id:[8,2,1,""],input_shapes:[8,2,1,""],output_shapes:[8,2,1,""]},"sparseml.onnx.utils.helpers.SparsityMeasurement":{density:[8,2,1,""],node_id:[8,2,1,""],params_count:[8,2,1,""],params_zero_count:[8,2,1,""],sparsity:[8,2,1,""]},"sparseml.onnx.utils.loss":{kl_divergence:[8,3,1,""]},"sparseml.onnx.utils.model":{DeepSparseAnalyzeModelRunner:[8,1,1,""],DeepSparseModelRunner:[8,1,1,""],ModelRunner:[8,1,1,""],ORTModelRunner:[8,1,1,""],OpenVINOModelRunner:[8,1,1,""],correct_nm_analyze_model_node_ids:[8,3,1,""],max_available_cores:[8,3,1,""],split_canonical_names:[8,3,1,""]},"sparseml.onnx.utils.model.DeepSparseAnalyzeModelRunner":{batch_forward:[8,2,1,""],run:[8,2,1,""]},"sparseml.onnx.utils.model.DeepSparseModelRunner":{batch_forward:[8,2,1,""],run:[8,2,1,""]},"sparseml.onnx.utils.model.ModelRunner":{batch_forward:[8,2,1,""],run:[8,2,1,""],run_iter:[8,2,1,""]},"sparseml.onnx.utils.model.ORTModelRunner":{batch_forward:[8,2,1,""],run:[8,2,1,""]},"sparseml.onnx.utils.model.OpenVINOModelRunner":{available:[8,2,1,""],batch_forward:[8,2,1,""],network_input_shapes:[8,2,1,""]},"sparseml.onnx.utils.sparse_tensor":{convert_model_initializers_to_sparse:[8,3,1,""],convert_sparse_initializers_to_dense:[8,3,1,""],create_sparse_tensor:[8,3,1,""],sparse_tensor_to_dense:[8,3,1,""]},"sparseml.optim":{analyzer:[9,0,0,"-"],learning_rate:[9,0,0,"-"],manager:[9,0,0,"-"],modifier:[9,0,0,"-"],sensitivity:[9,0,0,"-"]},"sparseml.optim.analyzer":{AnalyzedLayerDesc:[9,1,1,""]},"sparseml.optim.analyzer.AnalyzedLayerDesc":{dict:[9,2,1,""],load_descs:[9,2,1,""],merge_descs:[9,2,1,""],prunable:[9,2,1,""],save_descs:[9,2,1,""],terminal:[9,2,1,""]},"sparseml.optim.learning_rate":{LearningRate:[9,1,1,""],SetLearningRate:[9,1,1,""]},"sparseml.optim.learning_rate.LearningRate":{corrected_lr_info:[9,2,1,""],init_lr:[9,4,1,""],lr_class:[9,4,1,""],lr_kwargs:[9,4,1,""],validate_lr_info:[9,2,1,""]},"sparseml.optim.learning_rate.SetLearningRate":{learning_rate:[9,4,1,""],validate_learning_rate:[9,2,1,""]},"sparseml.optim.manager":{BaseManager:[9,1,1,""]},"sparseml.optim.manager.BaseManager":{max_epochs:[9,4,1,""],min_epochs:[9,4,1,""],modifiers:[9,4,1,""],modifiers_to_string_lines:[9,2,1,""],save:[9,2,1,""],to_string_lines:[9,2,1,""]},"sparseml.optim.modifier":{BaseModifier:[9,1,1,""],BaseObject:[9,1,1,""],BaseProp:[9,1,1,""],BaseScheduled:[9,1,1,""],BaseUpdate:[9,1,1,""],ModifierProp:[9,1,1,""],ModifierYAML:[9,1,1,""]},"sparseml.optim.modifier.BaseModifier":{enabled:[9,4,1,""],initialized:[9,4,1,""],load_framework_list:[9,2,1,""],load_framework_obj:[9,2,1,""],log_types:[9,4,1,""],props:[9,2,1,""],yaml_key:[9,2,1,""]},"sparseml.optim.modifier.BaseProp":{getter:[9,2,1,""],setter:[9,2,1,""]},"sparseml.optim.modifier.BaseScheduled":{end_epoch:[9,4,1,""],start_epoch:[9,4,1,""],validate_schedule:[9,2,1,""]},"sparseml.optim.modifier.BaseUpdate":{update_frequency:[9,4,1,""],validate_update:[9,2,1,""]},"sparseml.optim.modifier.ModifierProp":{getter:[9,2,1,""],no_serialize_val:[9,2,1,""],restrictions:[9,2,1,""],serializable:[9,2,1,""],setter:[9,2,1,""]},"sparseml.optim.sensitivity":{LRLossSensitivityAnalysis:[9,1,1,""],PruningLossSensitivityAnalysis:[9,1,1,""],PruningPerfSensitivityAnalysis:[9,1,1,""],PruningSensitivityResult:[9,1,1,""],default_pruning_sparsities_loss:[9,3,1,""],default_pruning_sparsities_perf:[9,3,1,""]},"sparseml.optim.sensitivity.LRLossSensitivityAnalysis":{add_result:[9,2,1,""],dict:[9,2,1,""],load_json:[9,2,1,""],plot:[9,2,1,""],print_res:[9,2,1,""],results:[9,2,1,""],save_json:[9,2,1,""]},"sparseml.optim.sensitivity.PruningLossSensitivityAnalysis":{add_result:[9,2,1,""],dict:[9,2,1,""],from_dict:[9,2,1,""],get_result:[9,2,1,""],load_json:[9,2,1,""],plot:[9,2,1,""],print_res:[9,2,1,""],results:[9,2,1,""],results_model:[9,2,1,""],save_json:[9,2,1,""]},"sparseml.optim.sensitivity.PruningPerfSensitivityAnalysis":{add_model_result:[9,2,1,""],add_result:[9,2,1,""],batch_size:[9,2,1,""],dict:[9,2,1,""],from_dict:[9,2,1,""],get_result:[9,2,1,""],load_json:[9,2,1,""],num_cores:[9,2,1,""],plot:[9,2,1,""],print_res:[9,2,1,""],results:[9,2,1,""],results_model:[9,2,1,""],save_json:[9,2,1,""]},"sparseml.optim.sensitivity.PruningSensitivityResult":{add_measurement:[9,2,1,""],averages:[9,2,1,""],baseline_average:[9,2,1,""],baseline_measurement_index:[9,2,1,""],baseline_measurement_key:[9,2,1,""],dict:[9,2,1,""],from_dict:[9,2,1,""],has_baseline:[9,2,1,""],id_:[9,2,1,""],index:[9,2,1,""],name:[9,2,1,""],sparse_average:[9,2,1,""],sparse_comparison:[9,2,1,""],sparse_integral:[9,2,1,""],sparse_measurements:[9,2,1,""]},"sparseml.pytorch":{datasets:[11,0,0,"-"],models:[16,0,0,"-"],nn:[21,0,0,"-"],optim:[22,0,0,"-"],utils:[24,0,0,"-"]},"sparseml.pytorch.datasets":{classification:[12,0,0,"-"],detection:[13,0,0,"-"],generic:[11,0,0,"-"],recommendation:[14,0,0,"-"],registry:[11,0,0,"-"],video:[15,0,0,"-"]},"sparseml.pytorch.datasets.classification":{cifar:[12,0,0,"-"],imagefolder:[12,0,0,"-"],imagenet:[12,0,0,"-"],imagenette:[12,0,0,"-"],mnist:[12,0,0,"-"]},"sparseml.pytorch.datasets.classification.cifar":{CIFAR100Dataset:[12,1,1,""],CIFAR10Dataset:[12,1,1,""]},"sparseml.pytorch.datasets.classification.imagefolder":{ImageFolderDataset:[12,1,1,""]},"sparseml.pytorch.datasets.classification.imagefolder.ImageFolderDataset":{num_classes:[12,2,1,""]},"sparseml.pytorch.datasets.classification.imagenet":{ImageNetDataset:[12,1,1,""]},"sparseml.pytorch.datasets.classification.imagenette":{ImagenetteDataset:[12,1,1,""],ImagenetteSize:[12,1,1,""],ImagewoofDataset:[12,1,1,""]},"sparseml.pytorch.datasets.classification.imagenette.ImagenetteSize":{full:[12,4,1,""],s160:[12,4,1,""],s320:[12,4,1,""]},"sparseml.pytorch.datasets.classification.mnist":{MNISTDataset:[12,1,1,""]},"sparseml.pytorch.datasets.detection":{coco:[13,0,0,"-"],helpers:[13,0,0,"-"],voc:[13,0,0,"-"]},"sparseml.pytorch.datasets.detection.coco":{CocoDetectionDataset:[13,1,1,""],coco_2017_yolo:[13,3,1,""]},"sparseml.pytorch.datasets.detection.coco.CocoDetectionDataset":{default_boxes:[13,2,1,""]},"sparseml.pytorch.datasets.detection.helpers":{AnnotatedImageTransforms:[13,1,1,""],bounding_box_and_labels_to_yolo_fmt:[13,3,1,""],random_horizontal_flip_image_and_annotations:[13,3,1,""],ssd_collate_fn:[13,3,1,""],ssd_random_crop_image_and_annotations:[13,3,1,""],yolo_collate_fn:[13,3,1,""]},"sparseml.pytorch.datasets.detection.helpers.AnnotatedImageTransforms":{transforms:[13,2,1,""]},"sparseml.pytorch.datasets.detection.voc":{VOCDetectionDataset:[13,1,1,""],VOCSegmentationDataset:[13,1,1,""]},"sparseml.pytorch.datasets.detection.voc.VOCDetectionDataset":{default_boxes:[13,2,1,""]},"sparseml.pytorch.datasets.generic":{CacheableDataset:[11,1,1,""],EarlyStopDataset:[11,1,1,""],NoisyDataset:[11,1,1,""],RandNDataset:[11,1,1,""]},"sparseml.pytorch.datasets.registry":{DatasetRegistry:[11,1,1,""]},"sparseml.pytorch.datasets.registry.DatasetRegistry":{attributes:[11,2,1,""],create:[11,2,1,""],register:[11,2,1,""]},"sparseml.pytorch.models":{classification:[17,0,0,"-"],detection:[18,0,0,"-"],external:[19,0,0,"-"],recommendation:[20,0,0,"-"],registry:[16,0,0,"-"]},"sparseml.pytorch.models.classification":{darknet:[17,0,0,"-"],efficientnet:[17,0,0,"-"],inception_v3:[17,0,0,"-"],mnist:[17,0,0,"-"],mobilenet:[17,0,0,"-"],mobilenet_v2:[17,0,0,"-"],resnet:[17,0,0,"-"],vgg:[17,0,0,"-"]},"sparseml.pytorch.models.classification.darknet":{DarkNet:[17,1,1,""],DarkNetSectionSettings:[17,1,1,""],darknet53:[17,3,1,""]},"sparseml.pytorch.models.classification.darknet.DarkNet":{as_classifier:[17,2,1,""],as_yolo_backbone:[17,2,1,""],create_section:[17,2,1,""],forward:[17,2,1,""],training:[17,4,1,""]},"sparseml.pytorch.models.classification.efficientnet":{EfficientNet:[17,1,1,""],EfficientNetSectionSettings:[17,1,1,""],efficientnet_b0:[17,3,1,""],efficientnet_b1:[17,3,1,""],efficientnet_b2:[17,3,1,""],efficientnet_b3:[17,3,1,""],efficientnet_b4:[17,3,1,""],efficientnet_b5:[17,3,1,""],efficientnet_b6:[17,3,1,""],efficientnet_b7:[17,3,1,""]},"sparseml.pytorch.models.classification.efficientnet.EfficientNet":{create_section:[17,2,1,""],forward:[17,2,1,""],training:[17,4,1,""]},"sparseml.pytorch.models.classification.inception_v3":{InceptionV3:[17,1,1,""],inception_v3:[17,3,1,""]},"sparseml.pytorch.models.classification.inception_v3.InceptionV3":{forward:[17,2,1,""],training:[17,4,1,""]},"sparseml.pytorch.models.classification.mnist":{MnistNet:[17,1,1,""],mnist_net:[17,3,1,""]},"sparseml.pytorch.models.classification.mnist.MnistNet":{forward:[17,2,1,""],training:[17,4,1,""]},"sparseml.pytorch.models.classification.mobilenet":{MobileNet:[17,1,1,""],MobileNetSectionSettings:[17,1,1,""],han_mobilenet:[17,3,1,""],mobilenet:[17,3,1,""]},"sparseml.pytorch.models.classification.mobilenet.MobileNet":{create_section:[17,2,1,""],forward:[17,2,1,""],training:[17,4,1,""]},"sparseml.pytorch.models.classification.mobilenet_v2":{MobilenetV2:[17,1,1,""],MobilenetV2SectionSettings:[17,1,1,""],mobilenet_v2:[17,3,1,""],mobilenet_v2_width:[17,3,1,""]},"sparseml.pytorch.models.classification.mobilenet_v2.MobilenetV2":{create_section:[17,2,1,""],forward:[17,2,1,""],training:[17,4,1,""]},"sparseml.pytorch.models.classification.resnet":{ResNet:[17,1,1,""],ResNetSectionSettings:[17,1,1,""],resnet101:[17,3,1,""],resnet101_2xwidth:[17,3,1,""],resnet152:[17,3,1,""],resnet18:[17,3,1,""],resnet34:[17,3,1,""],resnet50:[17,3,1,""],resnet50_2xwidth:[17,3,1,""],resnetv2_101:[17,3,1,""],resnetv2_152:[17,3,1,""],resnetv2_18:[17,3,1,""],resnetv2_34:[17,3,1,""],resnetv2_50:[17,3,1,""],resnext101:[17,3,1,""],resnext152:[17,3,1,""],resnext50:[17,3,1,""]},"sparseml.pytorch.models.classification.resnet.ResNet":{create_section:[17,2,1,""],forward:[17,2,1,""],training:[17,4,1,""]},"sparseml.pytorch.models.classification.vgg":{VGG:[17,1,1,""],vgg11:[17,3,1,""],vgg11bn:[17,3,1,""],vgg13:[17,3,1,""],vgg13bn:[17,3,1,""],vgg16:[17,3,1,""],vgg16bn:[17,3,1,""],vgg19:[17,3,1,""],vgg19bn:[17,3,1,""]},"sparseml.pytorch.models.classification.vgg.VGG":{create_section:[17,2,1,""],forward:[17,2,1,""],training:[17,4,1,""]},"sparseml.pytorch.models.detection":{ssd:[18,0,0,"-"],ssd_lite:[18,0,0,"-"],ssd_mobilenet:[18,0,0,"-"],ssd_resnet:[18,0,0,"-"],yolo_v3:[18,0,0,"-"]},"sparseml.pytorch.models.detection.ssd":{SSD300:[18,1,1,""],SSDBackbone:[18,1,1,""]},"sparseml.pytorch.models.detection.ssd.SSD300":{forward:[18,2,1,""],training:[18,4,1,""]},"sparseml.pytorch.models.detection.ssd.SSDBackbone":{get_feature_extractor:[18,2,1,""],out_channels:[18,2,1,""]},"sparseml.pytorch.models.detection.ssd_lite":{SSD300Lite:[18,1,1,""]},"sparseml.pytorch.models.detection.ssd_lite.SSD300Lite":{forward:[18,2,1,""],training:[18,4,1,""]},"sparseml.pytorch.models.detection.ssd_mobilenet":{SSD300MobileNetBackbone:[18,1,1,""],ssd300lite_mobilenetv2:[18,3,1,""]},"sparseml.pytorch.models.detection.ssd_mobilenet.SSD300MobileNetBackbone":{get_feature_extractor:[18,2,1,""],out_channels:[18,2,1,""]},"sparseml.pytorch.models.detection.ssd_resnet":{SSD300ResNetBackbone:[18,1,1,""],ssd300_resnet101:[18,3,1,""],ssd300_resnet152:[18,3,1,""],ssd300_resnet18:[18,3,1,""],ssd300_resnet34:[18,3,1,""],ssd300_resnet50:[18,3,1,""]},"sparseml.pytorch.models.detection.ssd_resnet.SSD300ResNetBackbone":{get_feature_extractor:[18,2,1,""],out_channels:[18,2,1,""]},"sparseml.pytorch.models.detection.yolo_v3":{YoloV3:[18,1,1,""],yolo_v3:[18,3,1,""]},"sparseml.pytorch.models.detection.yolo_v3.YoloV3":{forward:[18,2,1,""],training:[18,4,1,""]},"sparseml.pytorch.models.external":{torchvision:[19,0,0,"-"]},"sparseml.pytorch.models.registry":{ModelRegistry:[16,1,1,""]},"sparseml.pytorch.models.registry.ModelRegistry":{available_keys:[16,2,1,""],create:[16,2,1,""],create_zoo_model:[16,2,1,""],input_shape:[16,2,1,""],register:[16,2,1,""],register_wrapped_model_constructor:[16,2,1,""]},"sparseml.pytorch.nn":{activations:[21,0,0,"-"],fatrelu:[21,0,0,"-"],se:[21,0,0,"-"]},"sparseml.pytorch.nn.activations":{Hardswish:[21,1,1,""],ReLU6:[21,1,1,""],ReLU:[21,1,1,""],Swish:[21,1,1,""],create_activation:[21,3,1,""],hard_swish:[21,3,1,""],is_activation:[21,3,1,""],replace_activation:[21,3,1,""],swish:[21,3,1,""]},"sparseml.pytorch.nn.activations.Hardswish":{forward:[21,2,1,""],training:[21,4,1,""]},"sparseml.pytorch.nn.activations.ReLU":{inplace:[21,4,1,""]},"sparseml.pytorch.nn.activations.ReLU6":{inplace:[21,4,1,""],max_val:[21,4,1,""],min_val:[21,4,1,""]},"sparseml.pytorch.nn.activations.Swish":{forward:[21,2,1,""],training:[21,4,1,""]},"sparseml.pytorch.nn.fatrelu":{FATReLU:[21,1,1,""],convert_relus_to_fat:[21,3,1,""],fat_exp_relu:[21,3,1,""],fat_pw_relu:[21,3,1,""],fat_relu:[21,3,1,""],fat_sig_relu:[21,3,1,""],set_relu_to_fat:[21,3,1,""]},"sparseml.pytorch.nn.fatrelu.FATReLU":{channel_wise:[21,2,1,""],dynamic:[21,2,1,""],extra_repr:[21,2,1,""],forward:[21,2,1,""],get_threshold:[21,2,1,""],load_state_dict:[21,2,1,""],num_channels:[21,2,1,""],set_threshold:[21,2,1,""],training:[21,4,1,""]},"sparseml.pytorch.nn.se":{SqueezeExcite:[21,1,1,""]},"sparseml.pytorch.nn.se.SqueezeExcite":{forward:[21,2,1,""],training:[21,4,1,""]},"sparseml.pytorch.optim":{analyzer_as:[22,0,0,"-"],analyzer_module:[22,0,0,"-"],analyzer_pruning:[22,0,0,"-"],manager:[22,0,0,"-"],mask_creator_pruning:[22,0,0,"-"],mask_pruning:[22,0,0,"-"],modifier:[22,0,0,"-"],modifier_as:[22,0,0,"-"],modifier_epoch:[22,0,0,"-"],modifier_lr:[22,0,0,"-"],modifier_params:[22,0,0,"-"],modifier_pruning:[22,0,0,"-"],modifier_quantization:[22,0,0,"-"],modifier_regularizer:[22,0,0,"-"],optimizer:[22,0,0,"-"],quantization:[23,0,0,"-"],sensitivity_as:[22,0,0,"-"],sensitivity_lr:[22,0,0,"-"],sensitivity_pruning:[22,0,0,"-"]},"sparseml.pytorch.optim.analyzer_as":{ASResultType:[22,1,1,""],ModuleASAnalyzer:[22,1,1,""]},"sparseml.pytorch.optim.analyzer_as.ASResultType":{inputs_sample:[22,4,1,""],inputs_sparsity:[22,4,1,""],outputs_sample:[22,4,1,""],outputs_sparsity:[22,4,1,""]},"sparseml.pytorch.optim.analyzer_as.ModuleASAnalyzer":{analyze_layers:[22,2,1,""],clear:[22,2,1,""],dim:[22,2,1,""],disable:[22,2,1,""],enable:[22,2,1,""],enabled:[22,2,1,""],inputs_sample:[22,2,1,""],inputs_sample_max:[22,2,1,""],inputs_sample_mean:[22,2,1,""],inputs_sample_min:[22,2,1,""],inputs_sample_size:[22,2,1,""],inputs_sample_std:[22,2,1,""],inputs_sparsity:[22,2,1,""],inputs_sparsity_max:[22,2,1,""],inputs_sparsity_mean:[22,2,1,""],inputs_sparsity_min:[22,2,1,""],inputs_sparsity_std:[22,2,1,""],module:[22,2,1,""],outputs_sample:[22,2,1,""],outputs_sample_max:[22,2,1,""],outputs_sample_mean:[22,2,1,""],outputs_sample_min:[22,2,1,""],outputs_sample_size:[22,2,1,""],outputs_sample_std:[22,2,1,""],outputs_sparsity:[22,2,1,""],outputs_sparsity_max:[22,2,1,""],outputs_sparsity_mean:[22,2,1,""],outputs_sparsity_min:[22,2,1,""],outputs_sparsity_std:[22,2,1,""],results:[22,2,1,""],results_max:[22,2,1,""],results_mean:[22,2,1,""],results_min:[22,2,1,""],results_std:[22,2,1,""],track_inputs_sparsity:[22,2,1,""],track_outputs_sparsity:[22,2,1,""]},"sparseml.pytorch.optim.analyzer_module":{ModuleAnalyzer:[22,1,1,""]},"sparseml.pytorch.optim.analyzer_module.ModuleAnalyzer":{enabled:[22,2,1,""],ks_layer_descs:[22,2,1,""],layer_desc:[22,2,1,""],module:[22,2,1,""]},"sparseml.pytorch.optim.analyzer_pruning":{ModulePruningAnalyzer:[22,1,1,""]},"sparseml.pytorch.optim.analyzer_pruning.ModulePruningAnalyzer":{analyze_layers:[22,2,1,""],module:[22,2,1,""],name:[22,2,1,""],param:[22,2,1,""],param_name:[22,2,1,""],param_sparsity:[22,2,1,""],param_sparsity_dim:[22,2,1,""],tag:[22,2,1,""]},"sparseml.pytorch.optim.manager":{ScheduledModifierManager:[22,1,1,""],load_manager:[22,3,1,""]},"sparseml.pytorch.optim.manager.ScheduledModifierManager":{from_yaml:[22,2,1,""],initialize:[22,2,1,""],initialize_loggers:[22,2,1,""],load_state_dict:[22,2,1,""],loss_update:[22,2,1,""],optimizer_post_step:[22,2,1,""],optimizer_pre_step:[22,2,1,""],state_dict:[22,2,1,""],update:[22,2,1,""]},"sparseml.pytorch.optim.mask_creator_pruning":{BlockPruningMaskCreator:[22,1,1,""],DimensionSparsityMaskCreator:[22,1,1,""],GroupedPruningMaskCreator:[22,1,1,""],PruningMaskCreator:[22,1,1,""],UnstructuredPruningMaskCreator:[22,1,1,""],load_mask_creator:[22,3,1,""]},"sparseml.pytorch.optim.mask_creator_pruning.BlockPruningMaskCreator":{group_tensor:[22,2,1,""]},"sparseml.pytorch.optim.mask_creator_pruning.DimensionSparsityMaskCreator":{group_tensor:[22,2,1,""]},"sparseml.pytorch.optim.mask_creator_pruning.GroupedPruningMaskCreator":{create_sparsity_mask:[22,2,1,""],create_sparsity_mask_from_abs_threshold:[22,2,1,""],create_sparsity_mask_from_tensor:[22,2,1,""],get_grouping_fn:[22,2,1,""],group_tensor:[22,2,1,""]},"sparseml.pytorch.optim.mask_creator_pruning.PruningMaskCreator":{create_sparsity_mask:[22,2,1,""],create_sparsity_mask_from_abs_threshold:[22,2,1,""],create_sparsity_mask_from_tensor:[22,2,1,""]},"sparseml.pytorch.optim.mask_creator_pruning.UnstructuredPruningMaskCreator":{create_sparsity_mask:[22,2,1,""],create_sparsity_mask_from_abs_threshold:[22,2,1,""]},"sparseml.pytorch.optim.mask_pruning":{ModuleParamPruningMask:[22,1,1,""]},"sparseml.pytorch.optim.mask_pruning.ModuleParamPruningMask":{apply:[22,2,1,""],enabled:[22,2,1,""],layer:[22,2,1,""],layer_name:[22,2,1,""],mask_creator:[22,2,1,""],name:[22,2,1,""],param_data:[22,2,1,""],param_grad:[22,2,1,""],param_init:[22,2,1,""],param_mask:[22,2,1,""],param_name:[22,2,1,""],param_unmasked:[22,2,1,""],reset:[22,2,1,""],set_param_data:[22,2,1,""],set_param_mask:[22,2,1,""],set_param_mask_from_abs_threshold:[22,2,1,""],set_param_mask_from_sparsity:[22,2,1,""],set_param_mask_from_weights:[22,2,1,""],store_init:[22,2,1,""],store_unmasked:[22,2,1,""],track_grad_mom:[22,2,1,""]},"sparseml.pytorch.optim.modifier":{Modifier:[22,1,1,""],ModifierProp:[22,1,1,""],PyTorchModifierYAML:[22,1,1,""],ScheduledModifier:[22,1,1,""],ScheduledUpdateModifier:[22,1,1,""]},"sparseml.pytorch.optim.modifier.Modifier":{initialize:[22,2,1,""],initialize_loggers:[22,2,1,""],load_list:[22,2,1,""],load_obj:[22,2,1,""],log_update:[22,2,1,""],loggers:[22,4,1,""],loggers_initialized:[22,4,1,""],loss_update:[22,2,1,""],optimizer_post_step:[22,2,1,""],optimizer_pre_step:[22,2,1,""],update:[22,2,1,""]},"sparseml.pytorch.optim.modifier.ModifierProp":{getter:[22,2,1,""],no_serialize_val:[22,2,1,""],restrictions:[22,2,1,""],serializable:[22,2,1,""],setter:[22,2,1,""]},"sparseml.pytorch.optim.modifier.ScheduledModifier":{end_pending:[22,2,1,""],ended:[22,4,1,""],log_update:[22,2,1,""],scheduled_log_update:[22,2,1,""],scheduled_update:[22,2,1,""],start_pending:[22,2,1,""],started:[22,4,1,""],update:[22,2,1,""],update_ready:[22,2,1,""]},"sparseml.pytorch.optim.modifier.ScheduledUpdateModifier":{update:[22,2,1,""],update_ready:[22,2,1,""]},"sparseml.pytorch.optim.modifier_as":{ASRegModifier:[22,1,1,""]},"sparseml.pytorch.optim.modifier_as.ASRegModifier":{alpha:[22,4,1,""],initialize:[22,2,1,""],layer_normalized:[22,4,1,""],layers:[22,4,1,""],loss_update:[22,2,1,""],optimizer_post_step:[22,2,1,""],reg_func:[22,4,1,""],reg_tens:[22,4,1,""],update:[22,2,1,""],validate:[22,2,1,""]},"sparseml.pytorch.optim.modifier_epoch":{EpochRangeModifier:[22,1,1,""]},"sparseml.pytorch.optim.modifier_lr":{LearningRateModifier:[22,1,1,""],SetLearningRateModifier:[22,1,1,""]},"sparseml.pytorch.optim.modifier_lr.LearningRateModifier":{constant_logging:[22,4,1,""],log_update:[22,2,1,""],update:[22,2,1,""],validate:[22,2,1,""]},"sparseml.pytorch.optim.modifier_lr.SetLearningRateModifier":{applied_learning_rate:[22,4,1,""],constant_logging:[22,4,1,""],log_update:[22,2,1,""],update:[22,2,1,""]},"sparseml.pytorch.optim.modifier_params":{GradualParamModifier:[22,1,1,""],SetParamModifier:[22,1,1,""],TrainableParamsModifier:[22,1,1,""]},"sparseml.pytorch.optim.modifier_params.GradualParamModifier":{final_val:[22,4,1,""],init_val:[22,4,1,""],initialize:[22,2,1,""],inter_func:[22,4,1,""],params:[22,4,1,""],params_strict:[22,4,1,""],update:[22,2,1,""],validate:[22,2,1,""]},"sparseml.pytorch.optim.modifier_params.SetParamModifier":{initialize:[22,2,1,""],params:[22,4,1,""],params_strict:[22,4,1,""],update:[22,2,1,""],val:[22,4,1,""]},"sparseml.pytorch.optim.modifier_params.TrainableParamsModifier":{initialize:[22,2,1,""],params:[22,4,1,""],params_strict:[22,4,1,""],trainable:[22,4,1,""],update:[22,2,1,""]},"sparseml.pytorch.optim.modifier_pruning":{ConstantPruningModifier:[22,1,1,""],GMPruningModifier:[22,1,1,""]},"sparseml.pytorch.optim.modifier_pruning.ConstantPruningModifier":{from_sparse_model:[22,2,1,""],initialize:[22,2,1,""],load_state_dict:[22,2,1,""],log_update:[22,2,1,""],optimizer_post_step:[22,2,1,""],params:[22,4,1,""],state_dict:[22,2,1,""],update:[22,2,1,""]},"sparseml.pytorch.optim.modifier_pruning.GMPruningModifier":{applied_sparsity:[22,4,1,""],final_sparsity:[22,4,1,""],init_sparsity:[22,4,1,""],initialize:[22,2,1,""],inter_func:[22,4,1,""],leave_enabled:[22,4,1,""],load_state_dict:[22,2,1,""],log_update:[22,2,1,""],mask_type:[22,4,1,""],optimizer_post_step:[22,2,1,""],params:[22,4,1,""],state_dict:[22,2,1,""],update:[22,2,1,""],validate:[22,2,1,""]},"sparseml.pytorch.optim.modifier_quantization":{QuantizationModifier:[22,1,1,""]},"sparseml.pytorch.optim.modifier_quantization.QuantizationModifier":{disable_quantization_observer_epoch:[22,4,1,""],freeze_bn_stats_epoch:[22,4,1,""],initialize:[22,2,1,""],model_fuse_fn_name:[22,4,1,""],submodules:[22,4,1,""],update:[22,2,1,""],update_ready:[22,2,1,""]},"sparseml.pytorch.optim.modifier_regularizer":{SetWeightDecayModifier:[22,1,1,""]},"sparseml.pytorch.optim.modifier_regularizer.SetWeightDecayModifier":{constant_logging:[22,4,1,""],log_update:[22,2,1,""],param_groups:[22,4,1,""],update:[22,2,1,""],weight_decay:[22,4,1,""]},"sparseml.pytorch.optim.optimizer":{ScheduledOptimizer:[22,1,1,""]},"sparseml.pytorch.optim.optimizer.ScheduledOptimizer":{add_param_group:[22,2,1,""],adjust_current_step:[22,2,1,""],learning_rate:[22,2,1,""],load_manager_state_dict:[22,2,1,""],load_state_dict:[22,2,1,""],loss_update:[22,2,1,""],manager:[22,2,1,""],manager_state_dict:[22,2,1,""],param_groups:[22,2,1,""],state_dict:[22,2,1,""],step:[22,2,1,""],zero_grad:[22,2,1,""]},"sparseml.pytorch.optim.quantization":{helpers:[23,0,0,"-"],quantize_qat_export:[23,0,0,"-"]},"sparseml.pytorch.optim.quantization.helpers":{add_quant_dequant:[23,3,1,""],fuse_module_conv_bn_relus:[23,3,1,""],get_qat_qconfig:[23,3,1,""]},"sparseml.pytorch.optim.quantization.quantize_qat_export":{QuantizationParams:[23,1,1,""],get_quantization_params:[23,3,1,""],quantize_torch_qat_export:[23,3,1,""]},"sparseml.pytorch.optim.quantization.quantize_qat_export.QuantizationParams":{scale:[23,2,1,""],target:[23,2,1,""],zero_point:[23,2,1,""]},"sparseml.pytorch.optim.sensitivity_as":{ASLayerTracker:[22,1,1,""],LayerBoostResults:[22,1,1,""],ModuleASOneShootBooster:[22,1,1,""]},"sparseml.pytorch.optim.sensitivity_as.ASLayerTracker":{clear:[22,2,1,""],disable:[22,2,1,""],enable:[22,2,1,""],tracked_input:[22,2,1,""],tracked_output:[22,2,1,""]},"sparseml.pytorch.optim.sensitivity_as.LayerBoostResults":{baseline_as:[22,2,1,""],baseline_loss:[22,2,1,""],boosted_as:[22,2,1,""],boosted_loss:[22,2,1,""],name:[22,2,1,""],threshold:[22,2,1,""]},"sparseml.pytorch.optim.sensitivity_as.ModuleASOneShootBooster":{run_layers:[22,2,1,""]},"sparseml.pytorch.optim.sensitivity_lr":{default_exponential_check_lrs:[22,3,1,""],lr_loss_sensitivity:[22,3,1,""]},"sparseml.pytorch.optim.sensitivity_pruning":{model_prunability_magnitude:[22,3,1,""],pruning_loss_sens_magnitude:[22,3,1,""],pruning_loss_sens_one_shot:[22,3,1,""]},"sparseml.pytorch.utils":{benchmarker:[24,0,0,"-"],exporter:[24,0,0,"-"],helpers:[24,0,0,"-"],logger:[24,0,0,"-"],loss:[24,0,0,"-"],model:[24,0,0,"-"],module:[24,0,0,"-"],ssd_helpers:[24,0,0,"-"],yolo_helpers:[24,0,0,"-"]},"sparseml.pytorch.utils.benchmarker":{BatchBenchmarkResults:[24,1,1,""],ModuleBenchmarker:[24,1,1,""]},"sparseml.pytorch.utils.benchmarker.BatchBenchmarkResults":{add:[24,2,1,""],batch_size:[24,2,1,""],e2e_batch_seconds:[24,2,1,""],e2e_batch_timings:[24,2,1,""],e2e_batches_per_second:[24,2,1,""],e2e_item_seconds:[24,2,1,""],e2e_items_per_second:[24,2,1,""],model_batch_seconds:[24,2,1,""],model_batch_timings:[24,2,1,""],model_batches_per_second:[24,2,1,""],model_item_seconds:[24,2,1,""],model_items_per_second:[24,2,1,""]},"sparseml.pytorch.utils.benchmarker.ModuleBenchmarker":{run_batches_on_device:[24,2,1,""]},"sparseml.pytorch.utils.exporter":{ModuleExporter:[24,1,1,""]},"sparseml.pytorch.utils.exporter.ModuleExporter":{export_onnx:[24,2,1,""],export_pytorch:[24,2,1,""],export_samples:[24,2,1,""]},"sparseml.pytorch.utils.helpers":{NamedLayerParam:[24,1,1,""],any_str_or_regex_matches_param_name:[24,3,1,""],default_device:[24,3,1,""],early_stop_data_loader:[24,3,1,""],get_conv_layers:[24,3,1,""],get_layer:[24,3,1,""],get_layer_param:[24,3,1,""],get_linear_layers:[24,3,1,""],get_named_layers_and_params_by_regex:[24,3,1,""],get_optim_learning_rate:[24,3,1,""],get_prunable_layers:[24,3,1,""],get_terminal_layers:[24,3,1,""],infinite_data_loader:[24,3,1,""],mask_difference:[24,3,1,""],set_deterministic_seeds:[24,3,1,""],set_optim_learning_rate:[24,3,1,""],tensor_density:[24,3,1,""],tensor_export:[24,3,1,""],tensor_sample:[24,3,1,""],tensor_sparsity:[24,3,1,""],tensors_batch_size:[24,3,1,""],tensors_export:[24,3,1,""],tensors_module_forward:[24,3,1,""],tensors_to_device:[24,3,1,""],tensors_to_precision:[24,3,1,""],torch_distributed_zero_first:[24,3,1,""]},"sparseml.pytorch.utils.helpers.NamedLayerParam":{layer:[24,2,1,""],layer_name:[24,2,1,""],param:[24,2,1,""],param_name:[24,2,1,""]},"sparseml.pytorch.utils.logger":{PyTorchLogger:[24,1,1,""],PythonLogger:[24,1,1,""],TensorBoardLogger:[24,1,1,""]},"sparseml.pytorch.utils.logger.PyTorchLogger":{log_histogram:[24,2,1,""],log_histogram_raw:[24,2,1,""],log_hyperparams:[24,2,1,""],log_scalar:[24,2,1,""],log_scalars:[24,2,1,""],name:[24,2,1,""]},"sparseml.pytorch.utils.logger.PythonLogger":{log_histogram:[24,2,1,""],log_histogram_raw:[24,2,1,""],log_hyperparams:[24,2,1,""],log_scalar:[24,2,1,""],log_scalars:[24,2,1,""]},"sparseml.pytorch.utils.logger.TensorBoardLogger":{log_histogram:[24,2,1,""],log_histogram_raw:[24,2,1,""],log_hyperparams:[24,2,1,""],log_scalar:[24,2,1,""],log_scalars:[24,2,1,""]},"sparseml.pytorch.utils.loss":{Accuracy:[24,1,1,""],BinaryCrossEntropyLossWrapper:[24,1,1,""],CrossEntropyLossWrapper:[24,1,1,""],InceptionCrossEntropyLossWrapper:[24,1,1,""],KDLossWrapper:[24,1,1,""],KDSettings:[24,1,1,""],LossWrapper:[24,1,1,""],SSDLossWrapper:[24,1,1,""],TopKAccuracy:[24,1,1,""],YoloLossWrapper:[24,1,1,""]},"sparseml.pytorch.utils.loss.Accuracy":{calculate:[24,2,1,""],forward:[24,2,1,""],training:[24,4,1,""]},"sparseml.pytorch.utils.loss.InceptionCrossEntropyLossWrapper":{get_preds:[24,2,1,""],loss:[24,2,1,""]},"sparseml.pytorch.utils.loss.KDLossWrapper":{forward:[24,2,1,""],get_inputs:[24,2,1,""]},"sparseml.pytorch.utils.loss.KDSettings":{contradict_hinton:[24,2,1,""],teacher:[24,2,1,""],temp_student:[24,2,1,""],temp_teacher:[24,2,1,""],weight:[24,2,1,""]},"sparseml.pytorch.utils.loss.LossWrapper":{available_losses:[24,2,1,""],forward:[24,2,1,""],get_labels:[24,2,1,""],get_preds:[24,2,1,""]},"sparseml.pytorch.utils.loss.SSDLossWrapper":{get_preds:[24,2,1,""],loss:[24,2,1,""]},"sparseml.pytorch.utils.loss.TopKAccuracy":{calculate:[24,2,1,""],forward:[24,2,1,""],training:[24,4,1,""]},"sparseml.pytorch.utils.loss.YoloLossWrapper":{forward:[24,2,1,""],get_preds:[24,2,1,""],loss:[24,2,1,""]},"sparseml.pytorch.utils.model":{device_to_name_ids:[24,3,1,""],is_parallel_model:[24,3,1,""],load_epoch:[24,3,1,""],load_model:[24,3,1,""],load_optimizer:[24,3,1,""],model_to_device:[24,3,1,""],parallelize_model:[24,3,1,""],save_model:[24,3,1,""]},"sparseml.pytorch.utils.module":{ModuleDeviceContext:[24,1,1,""],ModuleRunFuncs:[24,1,1,""],ModuleRunHooks:[24,1,1,""],ModuleRunResults:[24,1,1,""],ModuleTester:[24,1,1,""],ModuleTrainer:[24,1,1,""],def_model_backward:[24,3,1,""]},"sparseml.pytorch.utils.module.ModuleDeviceContext":{default_context:[24,2,1,""],use_mixed_precision:[24,2,1,""],world_size:[24,2,1,""]},"sparseml.pytorch.utils.module.ModuleRunFuncs":{batch_size:[24,2,1,""],copy:[24,2,1,""],model_backward:[24,2,1,""],model_forward:[24,2,1,""],to_device:[24,2,1,""]},"sparseml.pytorch.utils.module.ModuleRunHooks":{invoke_batch_backward:[24,2,1,""],invoke_batch_end:[24,2,1,""],invoke_batch_forward:[24,2,1,""],invoke_batch_loss:[24,2,1,""],invoke_batch_start:[24,2,1,""],register_batch_backward_hook:[24,2,1,""],register_batch_end_hook:[24,2,1,""],register_batch_forward_hook:[24,2,1,""],register_batch_loss_hook:[24,2,1,""],register_batch_start_hook:[24,2,1,""]},"sparseml.pytorch.utils.module.ModuleRunResults":{append:[24,2,1,""],result:[24,2,1,""],result_list_tensor:[24,2,1,""],result_mean:[24,2,1,""],result_std:[24,2,1,""],results:[24,2,1,""]},"sparseml.pytorch.utils.module.ModuleTrainer":{num_accumulated_batches:[24,2,1,""],optim_closure:[24,2,1,""],optimizer:[24,2,1,""]},"sparseml.pytorch.utils.ssd_helpers":{DefaultBoxes:[24,1,1,""],MeanAveragePrecision:[24,1,1,""],get_default_boxes_300:[24,3,1,""],ssd_random_crop:[24,3,1,""]},"sparseml.pytorch.utils.ssd_helpers.DefaultBoxes":{as_ltrb:[24,2,1,""],as_xywh:[24,2,1,""],decode_output_batch:[24,2,1,""],encode_image_box_labels:[24,2,1,""],num_default_boxes:[24,2,1,""],scale_wh:[24,2,1,""],scale_xy:[24,2,1,""]},"sparseml.pytorch.utils.ssd_helpers.MeanAveragePrecision":{batch_forward:[24,2,1,""],calculate_map:[24,2,1,""],clear:[24,2,1,""],get_recall_levels:[24,2,1,""]},"sparseml.pytorch.utils.yolo_helpers":{YoloGrids:[24,1,1,""],box_giou:[24,3,1,""],build_targets:[24,3,1,""],get_output_grid_shapes:[24,3,1,""],postprocess_yolo:[24,3,1,""],yolo_v3_anchor_groups:[24,3,1,""]},"sparseml.pytorch.utils.yolo_helpers.YoloGrids":{get_anchor_grid:[24,2,1,""],get_grid:[24,2,1,""],num_anchor_grids:[24,2,1,""]},"sparseml.tensorflow_v1":{datasets:[26,0,0,"-"],models:[28,0,0,"-"],nn:[30,0,0,"-"],optim:[31,0,0,"-"],utils:[32,0,0,"-"]},"sparseml.tensorflow_v1.datasets":{classification:[27,0,0,"-"],dataset:[26,0,0,"-"],helpers:[26,0,0,"-"],registry:[26,0,0,"-"]},"sparseml.tensorflow_v1.datasets.classification":{cifar:[27,0,0,"-"],imagefolder:[27,0,0,"-"],imagenet:[27,0,0,"-"],imagenette:[27,0,0,"-"]},"sparseml.tensorflow_v1.datasets.classification.cifar":{Cifar100DataSet:[27,1,1,""],Cifar10DataSet:[27,1,1,""]},"sparseml.tensorflow_v1.datasets.classification.cifar.Cifar100DataSet":{name_scope:[27,2,1,""]},"sparseml.tensorflow_v1.datasets.classification.cifar.Cifar10DataSet":{name_scope:[27,2,1,""]},"sparseml.tensorflow_v1.datasets.classification.imagefolder":{ImageFolderDataset:[27,1,1,""],SplitsTransforms:[27,1,1,""],imagenet_normalizer:[27,3,1,""]},"sparseml.tensorflow_v1.datasets.classification.imagefolder.ImageFolderDataset":{creator:[27,2,1,""],format_iterator_batch:[27,2,1,""],image_size:[27,2,1,""],name_scope:[27,2,1,""],num_classes:[27,2,1,""],num_images:[27,2,1,""],post_resize_transforms:[27,2,1,""],pre_resize_transforms:[27,2,1,""],processor:[27,2,1,""],root:[27,2,1,""],train:[27,2,1,""]},"sparseml.tensorflow_v1.datasets.classification.imagefolder.SplitsTransforms":{train:[27,2,1,""],val:[27,2,1,""]},"sparseml.tensorflow_v1.datasets.classification.imagenet":{ImageNetDataset:[27,1,1,""]},"sparseml.tensorflow_v1.datasets.classification.imagenet.ImageNetDataset":{name_scope:[27,2,1,""]},"sparseml.tensorflow_v1.datasets.classification.imagenette":{ImagenetteDataset:[27,1,1,""],ImagenetteSize:[27,1,1,""],ImagewoofDataset:[27,1,1,""]},"sparseml.tensorflow_v1.datasets.classification.imagenette.ImagenetteDataset":{name_scope:[27,2,1,""]},"sparseml.tensorflow_v1.datasets.classification.imagenette.ImagenetteSize":{full:[27,4,1,""],s160:[27,4,1,""],s320:[27,4,1,""]},"sparseml.tensorflow_v1.datasets.classification.imagenette.ImagewoofDataset":{name_scope:[27,2,1,""]},"sparseml.tensorflow_v1.datasets.dataset":{Dataset:[26,1,1,""],create_split_iterators_handle:[26,3,1,""]},"sparseml.tensorflow_v1.datasets.dataset.Dataset":{build:[26,2,1,""],build_input_fn:[26,2,1,""],creator:[26,2,1,""],format_iterator_batch:[26,2,1,""],name_scope:[26,2,1,""],processor:[26,2,1,""]},"sparseml.tensorflow_v1.datasets.helpers":{center_square_crop:[26,3,1,""],random_scaling_crop:[26,3,1,""],resize:[26,3,1,""]},"sparseml.tensorflow_v1.datasets.registry":{DatasetRegistry:[26,1,1,""]},"sparseml.tensorflow_v1.datasets.registry.DatasetRegistry":{attributes:[26,2,1,""],create:[26,2,1,""],register:[26,2,1,""]},"sparseml.tensorflow_v1.models":{classification:[29,0,0,"-"],estimator:[28,0,0,"-"],registry:[28,0,0,"-"]},"sparseml.tensorflow_v1.models.classification":{mnist:[29,0,0,"-"],mobilenet:[29,0,0,"-"],mobilenet_v2:[29,0,0,"-"],resnet:[29,0,0,"-"],vgg:[29,0,0,"-"]},"sparseml.tensorflow_v1.models.classification.mnist":{mnist_net:[29,3,1,""]},"sparseml.tensorflow_v1.models.classification.mobilenet":{MobileNetSection:[29,1,1,""],mobilenet:[29,3,1,""],mobilenet_const:[29,3,1,""]},"sparseml.tensorflow_v1.models.classification.mobilenet.MobileNetSection":{create:[29,2,1,""]},"sparseml.tensorflow_v1.models.classification.mobilenet_v2":{MobileNetV2Section:[29,1,1,""],mobilenet_v2:[29,3,1,""],mobilenet_v2_const:[29,3,1,""],mobilenet_v2_width:[29,3,1,""]},"sparseml.tensorflow_v1.models.classification.mobilenet_v2.MobileNetV2Section":{create:[29,2,1,""]},"sparseml.tensorflow_v1.models.classification.resnet":{ResNetSection:[29,1,1,""],resnet101:[29,3,1,""],resnet152:[29,3,1,""],resnet18:[29,3,1,""],resnet20:[29,3,1,""],resnet34:[29,3,1,""],resnet50:[29,3,1,""],resnet_const:[29,3,1,""]},"sparseml.tensorflow_v1.models.classification.resnet.ResNetSection":{create:[29,2,1,""]},"sparseml.tensorflow_v1.models.classification.vgg":{VGGSection:[29,1,1,""],vgg11:[29,3,1,""],vgg11bn:[29,3,1,""],vgg13:[29,3,1,""],vgg13bn:[29,3,1,""],vgg16:[29,3,1,""],vgg16bn:[29,3,1,""],vgg19:[29,3,1,""],vgg19bn:[29,3,1,""],vgg_const:[29,3,1,""]},"sparseml.tensorflow_v1.models.classification.vgg.VGGSection":{create:[29,2,1,""]},"sparseml.tensorflow_v1.models.estimator":{ClassificationEstimatorModelFn:[28,1,1,""],EstimatorModelFn:[28,1,1,""]},"sparseml.tensorflow_v1.models.estimator.ClassificationEstimatorModelFn":{create_loss:[28,2,1,""],create_metric_update_ops_hook:[28,2,1,""],create_metrics:[28,2,1,""],create_modifier_ops_and_update_hook:[28,2,1,""],create_predictions:[28,2,1,""],create_scaffold:[28,2,1,""],create_summary_op:[28,2,1,""],create_train_summary_hook:[28,2,1,""],create_training_op:[28,2,1,""]},"sparseml.tensorflow_v1.models.estimator.EstimatorModelFn":{create:[28,2,1,""],create_loss:[28,2,1,""],create_metric_update_ops_hook:[28,2,1,""],create_metrics:[28,2,1,""],create_modifier_ops_and_update_hook:[28,2,1,""],create_predictions:[28,2,1,""],create_scaffold:[28,2,1,""],create_train_summary_hook:[28,2,1,""],create_training_op:[28,2,1,""]},"sparseml.tensorflow_v1.models.registry":{ModelRegistry:[28,1,1,""]},"sparseml.tensorflow_v1.models.registry.ModelRegistry":{available_keys:[28,2,1,""],create:[28,2,1,""],create_estimator:[28,2,1,""],create_zoo_model:[28,2,1,""],input_shape:[28,2,1,""],load_pretrained:[28,2,1,""],register:[28,2,1,""],saver:[28,2,1,""]},"sparseml.tensorflow_v1.nn":{layers:[30,0,0,"-"]},"sparseml.tensorflow_v1.nn.layers":{activation:[30,3,1,""],conv2d:[30,3,1,""],conv2d_block:[30,3,1,""],dense_block:[30,3,1,""],depthwise_conv2d_block:[30,3,1,""],fc:[30,3,1,""],pool2d:[30,3,1,""]},"sparseml.tensorflow_v1.optim":{analyzer_module:[31,0,0,"-"],manager:[31,0,0,"-"],mask_creator_pruning:[31,0,0,"-"],mask_pruning:[31,0,0,"-"],modifier:[31,0,0,"-"],modifier_epoch:[31,0,0,"-"],modifier_lr:[31,0,0,"-"],modifier_params:[31,0,0,"-"],modifier_pruning:[31,0,0,"-"],schedule_lr:[31,0,0,"-"],sensitivity_pruning:[31,0,0,"-"]},"sparseml.tensorflow_v1.optim.analyzer_module":{analyze_module:[31,3,1,""]},"sparseml.tensorflow_v1.optim.manager":{ScheduledModifierManager:[31,1,1,""]},"sparseml.tensorflow_v1.optim.manager.ScheduledModifierManager":{RECAL_UPDATE:[31,4,1,""],complete_graph:[31,2,1,""],create_ops:[31,2,1,""],from_yaml:[31,2,1,""],initialize_session:[31,2,1,""],modifiers_to_string_lines:[31,2,1,""]},"sparseml.tensorflow_v1.optim.mask_creator_pruning":{BlockPruningMaskCreator:[31,1,1,""],DimensionPruningMaskCreator:[31,1,1,""],GroupedPruningMaskCreator:[31,1,1,""],PruningMaskCreator:[31,1,1,""],UnstructuredPruningMaskCreator:[31,1,1,""],load_mask_creator:[31,3,1,""]},"sparseml.tensorflow_v1.optim.mask_creator_pruning.BlockPruningMaskCreator":{group_tensor:[31,2,1,""]},"sparseml.tensorflow_v1.optim.mask_creator_pruning.DimensionPruningMaskCreator":{group_tensor:[31,2,1,""]},"sparseml.tensorflow_v1.optim.mask_creator_pruning.GroupedPruningMaskCreator":{create_sparsity_mask:[31,2,1,""],get_grouping_op:[31,2,1,""],get_mask_initializer:[31,2,1,""],group_tensor:[31,2,1,""]},"sparseml.tensorflow_v1.optim.mask_creator_pruning.PruningMaskCreator":{create_sparsity_mask:[31,2,1,""],get_mask_initializer:[31,2,1,""]},"sparseml.tensorflow_v1.optim.mask_creator_pruning.UnstructuredPruningMaskCreator":{create_sparsity_mask:[31,2,1,""],get_mask_initializer:[31,2,1,""]},"sparseml.tensorflow_v1.optim.mask_pruning":{PruningOpVars:[31,1,1,""],PruningScope:[31,1,1,""],apply_op_vars_masks:[31,3,1,""],create_graph_ops_pruning:[31,3,1,""],create_ks_schedule_ops:[31,3,1,""],create_ks_scheduled_constant_graph_ops:[31,3,1,""],create_op_pruning:[31,3,1,""],create_summaries_pruning:[31,3,1,""],get_or_create_graph_ops_pruning:[31,3,1,""],get_or_create_ks_schedule_ops:[31,3,1,""],get_or_create_ks_scheduled_graph_ops:[31,3,1,""]},"sparseml.tensorflow_v1.optim.mask_pruning.PruningOpVars":{mask:[31,2,1,""],masked:[31,2,1,""],op:[31,2,1,""],op_input:[31,2,1,""],update:[31,2,1,""]},"sparseml.tensorflow_v1.optim.mask_pruning.PruningScope":{NM_KS:[31,4,1,""],NM_KS_OPS:[31,4,1,""],OPS:[31,4,1,""],OPS_INPUT:[31,4,1,""],OPS_SCHEDULE:[31,4,1,""],OPS_SPARSITY:[31,4,1,""],OPS_SUMMARY:[31,4,1,""],OPS_UPDATE:[31,4,1,""],OP_COND_UPDATE:[31,4,1,""],OP_MASKED_VAR:[31,4,1,""],OP_MASK_ASSIGN:[31,4,1,""],OP_MASK_UPDATE:[31,4,1,""],OP_MASK_UPDATE_NO_OP:[31,4,1,""],OP_PRUNE_VARS_ASSIGN:[31,4,1,""],OP_SAVE:[31,4,1,""],OP_SPARSITY:[31,4,1,""],OP_UPDATE_READY:[31,4,1,""],OP_WEIGHT_UPDATE:[31,4,1,""],VAR_MASK:[31,4,1,""],VAR_THRESHOLD:[31,4,1,""],collection_name:[31,2,1,""],general:[31,2,1,""],model:[31,2,1,""]},"sparseml.tensorflow_v1.optim.modifier":{Modifier:[31,1,1,""],ModifierProp:[31,1,1,""],ModifierSessionRunHook:[31,1,1,""],ScheduledModifier:[31,1,1,""],ScheduledUpdateModifier:[31,1,1,""],TensorFlowModifierYAML:[31,1,1,""]},"sparseml.tensorflow_v1.optim.modifier.Modifier":{complete_graph:[31,2,1,""],create_ops:[31,2,1,""],get_group:[31,2,1,""],initialize_session:[31,2,1,""],load_list:[31,2,1,""],load_obj:[31,2,1,""],modify_estimator:[31,2,1,""]},"sparseml.tensorflow_v1.optim.modifier.ModifierProp":{getter:[31,2,1,""],no_serialize_val:[31,2,1,""],restrictions:[31,2,1,""],serializable:[31,2,1,""],setter:[31,2,1,""]},"sparseml.tensorflow_v1.optim.modifier.ModifierSessionRunHook":{after_run:[31,2,1,""]},"sparseml.tensorflow_v1.optim.modifier.ScheduledModifier":{start_end_steps:[31,2,1,""]},"sparseml.tensorflow_v1.optim.modifier.ScheduledUpdateModifier":{update_frequency_steps:[31,2,1,""]},"sparseml.tensorflow_v1.optim.modifier_epoch":{EpochRangeModifier:[31,1,1,""]},"sparseml.tensorflow_v1.optim.modifier_lr":{GroupLearningRateModifier:[31,1,1,""],LearningRateModifier:[31,1,1,""],SetLearningRateModifier:[31,1,1,""]},"sparseml.tensorflow_v1.optim.modifier_lr.GroupLearningRateModifier":{create_ops:[31,2,1,""]},"sparseml.tensorflow_v1.optim.modifier_lr.LearningRateModifier":{create_ops:[31,2,1,""],get_group:[31,2,1,""]},"sparseml.tensorflow_v1.optim.modifier_lr.SetLearningRateModifier":{create_ops:[31,2,1,""],get_group:[31,2,1,""]},"sparseml.tensorflow_v1.optim.modifier_params":{TrainableParamsModifier:[31,1,1,""]},"sparseml.tensorflow_v1.optim.modifier_params.TrainableParamsModifier":{complete_graph:[31,2,1,""],create_ops:[31,2,1,""],params:[31,4,1,""],params_strict:[31,4,1,""],trainable:[31,4,1,""],validate:[31,2,1,""]},"sparseml.tensorflow_v1.optim.modifier_pruning":{ConstantPruningModifier:[31,1,1,""],GMPruningModifier:[31,1,1,""]},"sparseml.tensorflow_v1.optim.modifier_pruning.ConstantPruningModifier":{complete_graph:[31,2,1,""],create_ops:[31,2,1,""],initialize_session:[31,2,1,""],ks_group:[31,4,1,""],params:[31,4,1,""],prune_op_vars:[31,2,1,""],sparsity:[31,2,1,""],update_ready:[31,2,1,""]},"sparseml.tensorflow_v1.optim.modifier_pruning.GMPruningModifier":{complete_graph:[31,2,1,""],create_ops:[31,2,1,""],exponent:[31,4,1,""],final_sparsity:[31,4,1,""],init_sparsity:[31,4,1,""],initialize_session:[31,2,1,""],inter_func:[31,4,1,""],ks_group:[31,4,1,""],leave_enabled:[31,4,1,""],mask_type:[31,4,1,""],params:[31,4,1,""],prune_op_vars:[31,2,1,""],sparsity:[31,2,1,""],update_ready:[31,2,1,""],validate:[31,2,1,""]},"sparseml.tensorflow_v1.optim.schedule_lr":{multi_step_lr_schedule:[31,3,1,""],step_lr_schedule:[31,3,1,""]},"sparseml.tensorflow_v1.optim.sensitivity_pruning":{SparsePruningOpVars:[31,1,1,""],pruning_loss_sens_magnitude:[31,3,1,""],pruning_loss_sens_one_shot:[31,3,1,""],pruning_loss_sens_op_vars:[31,3,1,""]},"sparseml.tensorflow_v1.optim.sensitivity_pruning.SparsePruningOpVars":{op_vars:[31,2,1,""],sparsity:[31,2,1,""]},"sparseml.tensorflow_v1.utils":{exporter:[32,0,0,"-"],helpers:[32,0,0,"-"],loss:[32,0,0,"-"],nets_utils:[32,0,0,"-"],summary:[32,0,0,"-"],variable:[32,0,0,"-"]},"sparseml.tensorflow_v1.utils.exporter":{GraphExporter:[32,1,1,""],default_onnx_opset:[32,3,1,""]},"sparseml.tensorflow_v1.utils.exporter.GraphExporter":{checkpoint_path:[32,2,1,""],export_checkpoint:[32,2,1,""],export_named_samples:[32,2,1,""],export_onnx:[32,2,1,""],export_pb:[32,2,1,""],export_samples:[32,2,1,""],onnx_path:[32,2,1,""],pb_path:[32,2,1,""],pb_to_onnx:[32,2,1,""],sample_inputs_path:[32,2,1,""],sample_outputs_path:[32,2,1,""],tensorflow_path:[32,2,1,""]},"sparseml.tensorflow_v1.utils.helpers":{tf_compat_div:[32,3,1,""]},"sparseml.tensorflow_v1.utils.loss":{accuracy:[32,3,1,""],batch_cross_entropy_loss:[32,3,1,""]},"sparseml.tensorflow_v1.utils.nets_utils":{get_gan_network_fn:[32,3,1,""],get_model_scope:[32,3,1,""],get_network_fn:[32,3,1,""],mobilenet_v1_arg_scope:[32,3,1,""]},"sparseml.tensorflow_v1.utils.summary":{write_simple_summary:[32,3,1,""]},"sparseml.tensorflow_v1.utils.variable":{any_str_or_regex_matches_tensor_name:[32,3,1,""],clean_tensor_name:[32,3,1,""],eval_tensor_density:[32,3,1,""],eval_tensor_sparsity:[32,3,1,""],get_op_input_var:[32,3,1,""],get_op_var_index:[32,3,1,""],get_ops_and_inputs_by_name_or_regex:[32,3,1,""],get_prunable_ops:[32,3,1,""],get_tensor_var:[32,3,1,""],is_prunable_op:[32,3,1,""]},"sparseml.utils":{datasets:[34,0,0,"-"],frameworks:[33,0,0,"-"],helpers:[33,0,0,"-"],singleton:[33,0,0,"-"],worker:[33,0,0,"-"],wrapper:[33,0,0,"-"]},"sparseml.utils.datasets":{helpers:[34,0,0,"-"],imagenet:[34,0,0,"-"],imagenette:[34,0,0,"-"]},"sparseml.utils.datasets.helpers":{default_dataset_path:[34,3,1,""]},"sparseml.utils.datasets.imagenette":{ImagenetteDownloader:[34,1,1,""],ImagenetteSize:[34,1,1,""],ImagewoofDownloader:[34,1,1,""]},"sparseml.utils.datasets.imagenette.ImagenetteDownloader":{dataset_size:[34,2,1,""],download:[34,2,1,""],download_root:[34,2,1,""],extracted_root:[34,2,1,""],split_root:[34,2,1,""]},"sparseml.utils.datasets.imagenette.ImagenetteSize":{full:[34,4,1,""],s160:[34,4,1,""],s320:[34,4,1,""]},"sparseml.utils.datasets.imagenette.ImagewoofDownloader":{dataset_size:[34,2,1,""],download:[34,2,1,""],download_root:[34,2,1,""],extracted_root:[34,2,1,""],split_root:[34,2,1,""]},"sparseml.utils.helpers":{NumpyArrayBatcher:[33,1,1,""],bucket_iterable:[33,3,1,""],clean_path:[33,3,1,""],convert_to_bool:[33,3,1,""],create_dirs:[33,3,1,""],create_parent_dirs:[33,3,1,""],create_unique_dir:[33,3,1,""],flatten_iterable:[33,3,1,""],interpolate:[33,3,1,""],interpolate_list_linear:[33,3,1,""],interpolated_integral:[33,3,1,""],is_url:[33,3,1,""],load_labeled_data:[33,3,1,""],load_numpy:[33,3,1,""],load_recipe_yaml_str:[33,3,1,""],parse_optimization_str:[33,3,1,""],path_file_count:[33,3,1,""],path_file_size:[33,3,1,""],save_numpy:[33,3,1,""],tensor_export:[33,3,1,""],tensors_export:[33,3,1,""],validate_str_iterable:[33,3,1,""]},"sparseml.utils.helpers.NumpyArrayBatcher":{append:[33,2,1,""],stack:[33,2,1,""]},"sparseml.utils.singleton":{Singleton:[33,1,1,""]},"sparseml.utils.worker":{ParallelWorker:[33,1,1,""]},"sparseml.utils.worker.ParallelWorker":{add:[33,2,1,""],add_async:[33,2,1,""],add_async_generator:[33,2,1,""],add_item:[33,2,1,""],indefinite:[33,2,1,""],shutdown:[33,2,1,""],start:[33,2,1,""]},"sparseml.utils.wrapper":{wrapper_decorator:[33,3,1,""]},sparseml:{keras:[2,0,0,"-"],log:[1,0,0,"-"],onnx:[5,0,0,"-"],optim:[9,0,0,"-"],pytorch:[10,0,0,"-"],tensorflow_v1:[25,0,0,"-"],utils:[33,0,0,"-"]}},objnames:{"0":["py","module","Python module"],"1":["py","class","Python class"],"2":["py","method","Python method"],"3":["py","function","Python function"],"4":["py","attribute","Python attribute"]},objtypes:{"0":"py:module","1":"py:class","2":"py:method","3":"py:function","4":"py:attribute"},terms:{"00001":22,"00010671895716335979":22,"00011739085287969578":22,"00012912993816766537":22,"00014204293198443192":22,"00015624722518287512":22,"00017187194770116264":22,"00018905914247127894":22,"00020796505671840686":22,"00022876156239024756":22,"00025163771862927233":22,"0002768014904921996":22,"0003044816395414196":22,"00033492980349556157":22,"00036842278384511775":22,"0004052650622296296":22,"0004457915684525926":22,"0004903707252978519":22,"0005394077978276372":22,"000593348577610401":22,"0006526834353714411":22,"0007179517789085853":22,"0007897469567994438":22,"0008687216524793883":22,"0009555938177273272":22,"001":[3,22,31,32],"00105115319950006":22,"001156268519450066":22,"0012718953713950728":22,"0013990849085345801":22,"0015389933993880383":22,"0016928927393268422":22,"0018621820132595267":22,"0020484002145854797":22,"0022532402360440277":22,"0024785642596484307":22,"002726420685613274":22,"0029990627541746015":22,"003298969029592062":22,"0036288659325512686":22,"003991752525806396":22,"0043909277783870364":22,"004830020556225741":22,"005":[37,38],"005313022611848316":22,"005844324873033148":22,"006428757360336463":22,"00707163309637011":22,"007778796406007121":22,"008556676046607835":22,"009412343651268619":22,"010353578016395481":22,"011359662748873234":7,"01138893581803503":22,"012527829399838533":22,"013780612339822387":22,"015158673573804626":22,"01667454093118509":22,"017953205361364e":22,"0183419950243036":22,"019539741799235344":7,"020176194526733963":22,"02219381397940736":22,"02400691612424e":22,"0244131953773481":22,"02685451491508291":22,"029539966406591206":22,"03249396304725033":22,"03574335935197537":22,"03931769528717291":22,"043249464815890204":22,"04381":17,"047574411297479226":22,"052331852427227155":22,"0544702849929435e":22,"05756503766994987":22,"06332154143694486":22,"06965369558063936":22,"0766190651387033":22,"0834705943388392e":22,"08428097165257363":22,"091268053287076e":22,"092709068817831":22,"09574":22,"0th":24,"100":[8,24,29],"1000":[17,29],"10000":[3,31],"101":[16,17,18,28],"10197997569961412":22,"1113776745352607e":22,"11217797326957554":22,"1144777789251e":22,"115909044841462e":22,"123":[12,27],"1233957705965331":22,"13573534765618642":22,"1384283767210024e":22,"140274938683989e":22,"1435888100000012e":22,"14930888242180507":22,"152":[17,18],"160px":[12,27,34],"1642397706639856":22,"177248169415655e":22,"1801":17,"18066374773038418":22,"1902":22,"1918176537727232e":22,"19873012250342262":22,"1x1":17,"200":24,"2007":13,"2012":13,"2014":13,"2015":13,"2017":13,"2186031347537649":22,"21e":22,"224":[8,12,17,27,29],"240":17,"2404634482291414":22,"256":17,"25s":6,"260":17,"2645097930520556":22,"289048368510331e":22,"29096077235726114":22,"299":17,"300":[13,17,18,24],"3109994191499957e":22,"3200568495929873":22,"320px":[12,27,34],"322515441988787e":22,"3310000000000003e":22,"3333333333333333":26,"3520625345522861":22,"3579476910000015e":22,"380":17,"38726878800751474":22,"3x2":18,"3x3":17,"40024994425817e":22,"4003948586157844e":22,"4259956668082662":22,"4420993610649954e":22,"452271214393103e":22,"456":17,"4641000000000003e":22,"4685952334890929":22,"4763699237493086e":22,"5154547568380022":22,"52592555681761e":22,"528":17,"554766986187666e":22,"559917313492238e":22,"586309297171495e":22,"5937424601000017e":22,"594972986357221e":22,"600":17,"6105100000000006e":22,"626407607736664e":22,"640":[13,24],"701723378487253e":22,"727499949325609e":22,"7404343444773634e":22,"7449402268886447e":22,"7715610000000007e":22,"784":12,"7974983358324136e":22,"8102436848064327e":22,"819748525897502e":22,"849732675807628e":22,"853116706110002e":22,"9194342495775094e":22,"948717100000001e":22,"954302432552388e":22,"975":6,"978518112499371e":22,"9997":32,"abstract":[3,4,8,9,18,22,24,26,28,31],"boolean":[3,7,31,33],"break":[24,33],"byte":33,"case":[3,7,8,22,24,31],"class":[3,4,6,7,8,9,11,12,13,16,17,18,21,22,23,24,26,27,28,29,31,32,33,34,37,38],"default":[3,4,6,7,8,9,13,16,17,18,21,22,23,24,28,29,30,31,32,33,34],"enum":[4,12,22,27,34],"export":[1,2,3,10,22,23,25,31,33,35,38],"final":[3,6,17,22,24,29,31,35,37,38],"float":[3,4,6,7,8,9,11,13,17,21,22,24,29,30,31,32,33,38],"function":[3,7,8,9,13,16,17,18,21,22,23,24,26,27,28,31,32,33,34,37,38],"import":[22,37],"int":[1,3,4,6,7,8,9,11,12,13,17,18,21,22,24,26,27,29,30,31,32,33],"long":22,"new":[3,6,7,8,9,11,16,21,22,24,26,28,31,32,33],"null":9,"return":[1,3,4,6,7,8,9,11,13,16,17,18,21,22,23,24,26,27,28,29,30,31,32,33,34,37],"static":[3,6,7,8,9,11,16,17,22,24,26,28,31,32],"switch":[26,31],"true":[3,4,6,7,8,9,12,13,16,17,18,21,22,23,24,27,28,29,30,31,32,33,34,38],"try":[7,33],"var":[8,28,31],"while":[3,7,17,18,21,22,26,31,35,38],Axes:[6,9],For:[3,8,22,24,31,32,35,37,38],Its:22,Not:22,OPS:31,One:29,Ones:[29,30],The:[3,6,7,8,9,12,13,16,17,18,21,22,23,24,27,28,29,30,31,32,33,34,35,37,38],Then:36,There:32,Use:[3,9,22,31],Used:[21,30,31],Useful:[3,21,22,31],Uses:[28,31,32],Will:[7,8,13,18,24,33],With:37,__all__:[3,22,31,38],__loss__:22,__name__:9,_ax:[6,9],_block_shap:[3,22,31],_deepsparsebasemodelrunn:8,_dim:[3,22,31],_map_mask_to_tensor:[3,22,31],abc:[3,4,8,9,18,22,24,28,31],about:[9,18,24,33],abov:8,abs:[7,17,22],absolut:[3,8,22,31,33],accept:[3,9,21,22,31],access:[22,24],accord:[3,8,11,22,24,31],accordingli:7,account:24,accumul:24,accuraci:[22,24,32,35,38],achiev:[6,9],across:[6,9,21,22,24,32,33],act:[21,29,30],act_typ:21,activ:[1,3,7,9,10,22,23,24,29,30,31,32,35,38],adam:38,adapt:[24,32],add:[6,7,8,9,11,22,24,29,30,33,38],add_async:33,add_async_gener:33,add_item:33,add_measur:[6,9],add_model_result:[6,9],add_modifi:[3,22,31],add_ops_cr:31,add_param_group:22,add_quant_dequ:23,add_reduce_to_node_output:7,add_result:[6,9],added:[3,7,17,22,24,31,32,33],addit:[3,4,6,7,8,17,18,21,22,24,26,28,31,33,36],addition:[8,12,22,24,31,35,37,38],addtion:18,adjust:[6,22,24],adjust_current_step:22,affect:[6,9,24],after:[3,6,8,9,17,22,24,27,29,30,31,32,33,37,38],after_optim:[3,31],after_run:31,afterward:[17,18,21],again:3,against:[6,9,22,24,31,32],aggreg:[24,31],aggress:33,aka:[22,31],algorithm:[35,37],alia:[8,23,24,27,31],all:[1,3,4,6,7,8,9,12,13,16,17,18,21,22,23,24,26,27,28,30,31,32,33,34,35,37,38],all_token:[3,22,31],allow:[3,6,8,9,11,22,24,31,32,35],along:[1,3,6,13,22,24,31,33],alongsid:[3,9,22,31],alpha:22,alreadi:[8,13,22,28,34,38],also:[3,6,8,9,17,18,22,24,26,31,33,37,38],altern:35,although:[17,18,21],altogeth:22,alwai:22,among:24,amount:[3,8,17,22,24,31],amp:24,analys:24,analysi:[6,8,9,22,31],analyz:[0,1,6,22,31],analyze_lay:22,analyze_model:8,analyze_modul:31,analyzedlayerdesc:[9,22],analyzer_a:[1,10],analyzer_model:[1,5],analyzer_modul:[1,10,25],analyzer_prun:[1,10],ancestor:8,anchor:[18,24],anchor_group:[18,24],anchors_group:24,ani:[3,4,6,8,9,11,13,16,17,18,22,24,26,28,30,31,32,33,35,36,37,38],annot:[13,24,33],annotatedimagetransform:13,anoth:[3,31],any_str_or_regex_matches_param_nam:24,any_str_or_regex_matches_tensor_nam:32,anyth:[22,37,38],apart:[24,33],api:[8,26,35,37,38],appear:23,append:[24,33],appli:[3,6,7,8,9,11,12,13,17,21,22,24,26,27,28,29,30,31,32,33,35,37,38],applic:6,applied_learning_r:22,applied_spars:22,apply_op_vars_mask:31,apply_shape_change_mult:6,apply_softmax:28,approach:35,appropri:[22,28,33],approx_ks_loss_sensit:31,approxim:[6,21,22,31],architectur:[16,17,18,28,29],area:33,arg:[3,8,9,11,16,22,26,28,31,32],arg_scop:32,arg_scope_var:32,argument:[3,9,16,17,18,22,24,28,31,37,38],around:[3,24,35],arrai:[4,7,8,24,32,33],art:35,artifici:22,arxiv:[17,22],as_classifi:17,as_default:37,as_ltrb:24,as_xywh:24,as_yolo_backbon:17,ascend:33,asd932:12,asd932_:27,ask:24,aslayertrack:22,aspect:[3,22,24,26,31],aspect_ratio:24,asregmodifi:22,asresulttyp:22,assign:[3,31],associ:[8,24,32],assum:[3,8,24,33],assumpt:24,asymmetr:[23,38],async:33,attach:[8,28],attempt:32,attibut:8,attr:8,attribut:[3,4,6,8,9,11,22,26,31,33],augment:7,augmented_model_path:7,automat:[3,38],automl:37,aux:[17,24],aux_pr:24,aux_weight:24,auxiliari:24,avail:[3,6,8,16,22,24,28,31,37,38],available_kei:[16,28],available_loss:24,averag:[6,9,24,32],avg:30,avoid:[8,32],awai:[26,31],awar:[22,23,38],axes:[6,9],axi:7,back:[8,33],backbon:[17,18],backbone_early_output_idx:18,backbone_out_channel:18,backend:[7,24],backward:[22,24],ball:[8,33],bar:[6,7,8],base:[3,4,6,7,8,9,11,12,13,16,17,18,21,22,23,24,26,27,28,29,31,32,33,34,35],base_name_scop:28,baselin:[6,9,35],baseline_a:22,baseline_averag:[6,9],baseline_loss:22,baseline_measurement_index:[6,9],baseline_measurement_kei:[6,9],basemanag:[3,9,22,31],basemodifi:[3,9,22,31],baseobject:9,baseprop:[3,9,22,31],baseschedul:[3,9,22,31],baseupd:[3,9,22,31],basic:[9,17,29],basic_session_run_hook:28,batch:[3,4,6,7,8,9,13,17,22,24,26,27,29,30,31,32,33,37],batch_cross_entropy_loss:32,batch_forward:[8,24],batch_norm:32,batch_norm_decai:32,batch_norm_epsilon:32,batch_norm_updates_collect:32,batch_siz:[6,8,9,22,24,26,32,37],batchbenchmarkresult:24,batcher:33,batchnorm2d:23,batchnorm:[8,29],batchnormparam:8,becaus:8,been:[3,8,22,24,28,30,31,32],befor:[3,4,6,8,17,22,24,27,30,31,37,38],begin:[4,22,31,33],begin_step:31,behav:22,behavior:[4,8,22],being:[3,9,21,22,24,30,31,32],belong:[16,28,31],below:[3,8,24,38],benchmark:[1,6,8,10],best:22,beta:[29,30],beta_initi:[29,30],better:[1,22],between:[3,6,8,9,11,21,22,23,24,26,31,33,38],bia:[6,8,22,29,30],bias_initi:[29,30],bias_nam:6,bias_shap:[6,8],bin:24,binari:24,binary_cross_entropy_with_logit:24,binarycrossentropylosswrapp:24,bit:[7,37],blob:8,block:[3,7,8,17,22,23,29,31,38],block_shap:[3,22,31],blockpruningmaskcr:[3,22,31],blog:[35,38],bn_node:8,bool:[3,4,6,7,8,9,11,12,13,16,17,18,21,22,23,24,27,28,29,30,31,32,33,34],boost:22,boosted_a:22,boosted_loss:22,booster:22,both:[21,22,38],bottleneck:[17,29],bottom:33,boudn:24,bound:[13,24],bounding_box_and_labels_to_yolo_fmt:13,box:[13,24],box_giou:24,boxes_a:24,boxes_b:24,break_batch:[24,33],broadcast:21,bucket:[24,33],bucket_count:24,bucket_iter:33,bucket_limit:24,buffer:[21,26],bug:35,build:[3,6,22,26,35],build_input_fn:26,build_target:24,built:[3,4,8,26,27,30,35,37],builtin:22,cach:[11,12,13,22,24,27],cacheabl:11,cacheabledataset:11,calcul:[3,6,8,9,17,22,24,31,33],calculate_flop:8,calculate_map:24,calibr:[5,6],calibrate_op_typ:7,calibrationsess:7,call:[3,4,6,9,16,17,18,21,22,24,26,31,32,37],callabl:[3,8,9,16,22,24,26,28,31,32,33],callback:[1,2,3,24,31,37],caller:32,came:24,can:[1,3,6,7,8,9,11,12,13,17,18,21,22,23,24,27,29,30,31,32,33,34,35,37,38],cannot:[3,9,22,31,38],canon:8,canonical_nam:8,cap:33,capabl:3,card:33,care:[17,18,21],cat:12,cent_crop:27,center:[24,26],center_i:24,center_square_crop:[26,27],center_x:24,certain:[3,8,9,22,31,38],chain:13,chan:21,chang:[3,4,6,8,9,16,22,24,31],channel:[3,7,17,18,21,22,24,29,30,31],channel_wis:21,channels_first:30,channels_last:30,chart:[6,9],chauhan:24,check:[3,7,8,9,17,18,21,22,23,24,31,32,33,37],check_feat_lab_inp:24,check_load_model:8,check_lr:22,check_numb:33,check_opset_vers:7,checkpoint:32,checkpoint_path:32,child:8,choos:[8,22,24,38],chosen:22,cifar100:12,cifar100dataset:[12,27],cifar10:[12,29],cifar10dataset:[12,27],cifar:[10,11,25,26],cifardataset:27,class_i:27,class_nam:3,class_typ:[17,29],class_x:27,classif:[10,11,16,19,24,25,26,28,32,34],classifi:[17,18,29],classificationestimatormodelfn:28,classmethod:3,clazz:9,clean:[31,32,33,37],clean_path:33,clean_tensor_nam:32,clear:[22,24],cli:35,client:[28,31,32],clone:36,close:[3,31],closest:[6,9],closur:[22,24],cnn:18,coco:[10,11,18,24],coco_2017_yolo:13,cocodetectiondataset:13,code:[2,3,4,5,6,8,9,10,11,16,22,24,25,26,28,31,32,33,35,37,38],coeffici:[24,32],collat:13,collect:[3,9,22,24,28,31,32,33],collection_nam:31,column:24,com:[8,12,24,27,33,38],combin:[8,9,22,24,31],combo:24,common:[21,22,33],commonli:38,commun:35,compar:[3,6,8,9,22,24,31,32,37],compare_index:[6,9],comparison:[6,9,24],compat:[16,22,28],compil:[24,37],complet:[6,8,22,24,31,37],complete_graph:[31,37],compress:[21,33],comput:[3,7,9,12,13,15,17,18,21,24,27,29,31,32,34],compute_output_shap:3,condit:[24,31],confid:24,confidence_threshold:24,config:[3,9,22,23,37],configur:[17,18,24,29,33,37,38],connect:[3,29,30],consid:[6,24],consist:[1,33],consol:22,constant:[3,22,31,32],constant_log:22,constantli:22,constantpruningmodifi:[3,22,31,35],construct:[8,22,24],constructor:[3,9,16,21,22,28,29,31],contain:[3,4,6,8,9,17,21,22,24,26,27,28,31,32,33,35,37,38],content:[0,35],context:[22,24],continu:[3,8,22,24,31,33],contract:[3,31],contradict:24,contradict_hinton:24,control:[3,8,9,22,24,31,38],conv0:38,conv1:[22,31,37,38],conv1d:32,conv2:[37,38],conv2d:[23,30,31,32],conv2d_1:3,conv2d_5:3,conv2d_block:30,conv3:[37,38],conv3d:32,conv:[6,7,8,17,18,22,23,24,29,30,31,32,38],conv__224:7,conv__252:7,conv_net:[22,31],conv_node_param:8,conveni:[3,8,22,24,31,32,37,38],convers:[8,23,37],convert:[3,8,9,23,24,31,33,37,38],convert_kera:4,convert_model_initializers_to_spars:8,convert_relus_to_fat:21,convert_sparse_initializers_to_dens:8,convert_to_bool:33,convinteg:7,convnd:24,convolut:[8,17,18,22,29,30,32],coordin:[18,24],copi:[21,23,24],core:[6,8,9],correct:[8,9,22,24],correct_nm_analyze_model_node_id:8,corrected_lr_info:9,correctli:[4,31,35],correspond:[4,22,24,33],cosineannealingwarmrestart:[9,22],cost:22,could:[4,8,9],couldn:32,count:[22,24,33],counter:[4,24,33],cpu:[6,9,11,22,24,35],creat:[1,2,3,4,5,6,7,8,9,10,11,12,13,16,17,18,21,22,24,25,26,27,28,29,30,31,32,33,35,37,38],create_activ:21,create_dir:33,create_estim:28,create_extra:31,create_graph_ops_prun:31,create_ks_schedule_op:31,create_ks_scheduled_constant_graph_op:31,create_label:8,create_loss:28,create_metr:28,create_metric_update_ops_hook:28,create_modifier_ops_and_update_hook:28,create_op:[3,31,37],create_op_prun:31,create_parent_dir:33,create_predict:28,create_scaffold:28,create_sect:17,create_sparse_tensor:8,create_sparsity_mask:[3,22,31],create_sparsity_mask_from_abs_threshold:22,create_sparsity_mask_from_tensor:22,create_split_iterators_handl:26,create_summaries_prun:31,create_summary_op:28,create_train_summary_hook:28,create_training_op:28,create_unique_dir:33,create_zoo_model:[16,28],creation:[3,31,37,38],creator:[3,22,26,27,28,31],crop:[13,24,26],cross:[24,32],cross_entropi:24,crossentropyloss:22,crossentropylosswrapp:24,csv:9,cubic:[3,22,31,33],cuda:[22,24],cudnn:24,cumul:24,current:[3,4,6,7,8,9,16,21,22,24,26,28,29,30,31,32,33,37,38],curv:33,custom:[21,32,38],custom_op_handl:32,cutoff:22,cwd:[4,24],cycl:[22,31],darknet53:17,darknet:[10,16,18],darknetsectionset:17,data:[1,5,6,7,11,12,13,22,24,26,27,28,33],data_format:30,data_load:[7,8,24],data_loader_kwarg:22,data_shap:8,data_typ:8,dataload:[6,7,8,13,22,24],dataparallel:24,datapararallel:24,dataset:[1,10,16,17,18,22,24,25,28,29,33,35],dataset_op:26,dataset_s:[12,27,34],datasetregistri:[11,26],datasetv1:26,ddp:24,deal:31,debian:36,debug:4,debug_mod:4,decai:[22,31,32,38],decay_r:[3,31],decay_step:[3,31],decim:[8,22,38],decod:24,decode_output_batch:24,deconstruct_tensor:24,decor:[3,9,11,16,22,24,26,28,31,33],decreas:[22,31],deep:35,deepspars:[6,8,24,33,35,37],deepsparseanalyzemodelrunn:8,deepsparsemodelrunn:8,def_ignore_error_tensor:16,def_model_backward:24,default_box:13,default_context:24,default_dataset:[16,28],default_dataset_path:34,default_desc:[16,28],default_devic:24,default_exponential_check_lr:22,default_image_s:32,default_loss_kei:24,default_model_fn_cr:28,default_onnx_opset:32,default_pruning_sparsities_loss:9,default_pruning_sparsities_perf:9,default_qat_qconfig:23,defaultbox:[13,24],defin:[3,4,6,8,17,18,21,22,24,28,31,32,38],definit:37,delet:8,dens:[8,30],dense_block:30,densiti:[8,24,32],depend:[22,32,36,38],deploi:35,deploy:37,depth:[17,33,37],depthwis:[17,18,29,30,32],depthwise_conv2d_block:30,dequantize_nod:8,dequantizelinear:23,deriv:[3,4,6,22,31],desc:[8,9],desc_arg:16,descend:[21,33],descent:38,describ:[9,17,29],descript:[9,16,22,28,31,33],deseri:3,design:[33,37,38],desir:[8,16,22,23,24,26,28,30,31,32,34,37,38],destin:4,detail:6,detect:[8,10,11,16,17,24,28],detector:[18,24],determin:[8,22,32,33],determinist:24,dev:35,deviat:[3,11,22,24,31,32],devic:[4,22,24,32],device_context:24,device_to_name_id:24,dict:[3,6,7,8,9,11,16,17,18,21,22,24,26,27,28,31,32,33],dictionari:[3,4,6,7,8,9,21,22,24,26,28,31,32,33,38],did:[8,22],differ:[6,9,22,23,24,28,31,32,38],dim:[3,22,24,31],dimens:[3,8,9,21,22,24,31,32,33],dimensionpruningmaskcr:[3,31],dimensionsparsitymaskcr:22,dir:[4,24],direct:[8,35],directli:22,directori:[4,7,24,28,32,33],disabl:[22,24,38],disable_bn_fus:24,disable_quantization_observer_epoch:22,disclaim:8,disk:[11,12,33],displai:[6,7,8,9],distanc:8,distil:24,distribut:[6,9,11,12,13,24,27],distributeddataparallel:24,diverg:8,divid:[3,22,31,32],divis:32,doc:[3,4,8,9,22,31,33,35],doc_str:4,document:[35,37],doe:[3,6,7,8,12,13,22,23,24,27,31,32,33,34,38],doesn:[3,11,22,31,33],dog:12,doing:[3,9,22,24,31],domain:[16,28],domainadapt:24,done:[3,24,37,38],doubl:17,down:[17,21,29],download:[12,13,27,33,34,35,37],download_root:34,downsampl:[17,29],downsample_out_channel:17,driven:35,drop:24,dropout:[17,30,32],dropout_r:30,dtype:[3,8,31,32],due:8,dure:[4,7,22,24,28,31,38],dynam:[7,8,21],dynamicquantizelinear:7,e2e_batch_second:24,e2e_batch_tim:24,e2e_batches_per_second:24,e2e_item_second:24,e2e_items_per_second:24,e2e_sec:24,each:[3,4,6,7,8,9,13,17,18,22,24,27,29,31,33,37,38],earli:[11,24],earlier:[17,24],early_stop:11,early_stop_data_load:24,early_stop_step:24,earlystopdataset:11,eas:37,easi:37,easiest:38,easili:[3,9,11,16,22,26,28,31,35,38],edg:[8,33],edge_perc:33,edit:[2,5,8,10,25,31,35,37],editor:32,effect:[3,4,9,22,31,35],efficientnet:[10,16],efficientnet_b0:17,efficientnet_b1:17,efficientnet_b2:17,efficientnet_b3:17,efficientnet_b4:17,efficientnet_b5:17,efficientnet_b6:17,efficientnet_b7:17,efficientnetsectionset:17,either:[3,6,8,23,24,30,32,33,38],element:[3,24,31,33],els:[3,8,9,21,24,30,31,33],empti:[9,21,22,31],emul:[22,38],enabl:[3,9,17,22,23,24,31,35,37,38],enable_aux:17,encapsul:31,enclos:3,encod:[13,24,35,37,38],encode_annotation_bounding_box:13,encode_image_box_label:24,encompass:35,end:[3,4,9,17,22,24,29,31,32,38],end_compar:[3,9,22,31],end_epoch:[3,9,22,31,37,38],end_pend:22,end_point:32,end_step:31,enforc:[3,8,9,21,22,24,31,38],engin:[3,4,6,8,24,35,37],enhanc:3,ensur:7,entir:[3,18,22,31],entri:22,entropi:[8,24,32],enumer:38,environ:36,epoch:[3,4,9,22,24,31,35,37],epoch_end:22,epoch_start:22,epochrangemodifi:[3,22,31,37,38],epsilon:8,equal:[3,8,9,21,22,31,32,33],equat:7,equival:24,err:[3,22,31],error:[3,16,17,18,22,31,33],error_desc:33,estim:[1,25,26,31,35],estimatormodelfn:28,etc:[6,9,16,17,18,22,24,28,30,31,33],eval:[22,31],eval_tensor_dens:32,eval_tensor_spars:32,evalu:[4,8,22,24,28,32],even:32,evenli:[3,22,24,31],event:[8,22,31,33],everi:[6,11,17,18,21,22,24,31,37,38],everyth:[24,35],exactli:[3,21,22,31],exampl:[3,7,8,22,31,32,35,37,38],exce:[3,22,31],except:[7,13,22,24,32],excit:[17,21],exclud:7,exclude_nod:7,execut:[8,9,22,24,31,32],execution_ord:9,exist:[22,24,32,33,34],exp:21,exp_channel:[17,29],exp_count:[4,24],exp_ratio:[17,29],expand:[17,21,29,33],expanded_channel:21,expans:[17,29],expansion_ratio:17,expect:[3,6,8,9,17,18,22,24,26,29,31],explor:[36,37],expon:[3,31],exponenti:[21,22,31],exponential_lr_schedul:31,exponentialdecai:[3,31],exponentiallr:[3,9,22,31,38],export_checkpoint:32,export_dir:[24,33],export_h5:4,export_kera:4,export_named_sampl:32,export_onnx:[4,24,32,37],export_pb:[32,37],export_pytorch:24,export_sampl:[4,24,32],expos:8,ext:27,extend:9,extens:33,extern:[1,10,16],extra:[3,4,6,9,13,21,22,24,28,31,32,37],extra_opset:32,extra_repr:21,extract:[7,8,18,22,24,33,34],extract_node_id:8,extract_node_shap:8,extract_nodes_shapes_ort:8,extract_nodes_shapes_shape_infer:8,extract_shap:8,extracted_root:34,extractor:[17,18],extrat:18,extrem:[6,9],factor:24,fake:23,fall:33,fals:[3,6,7,8,9,12,13,16,17,18,21,22,23,24,27,28,29,30,31,32,33,34],far:24,fast:18,fastai:[12,27],faster:[22,31,35],fat:21,fat_exp_relu:21,fat_pw_relu:21,fat_relu:21,fat_sig_relu:21,fatrelu:[1,10,22],featur:[17,18,24,26,32,35,37],feature_map:24,fed:24,feed:[4,24,26,31,32],feed_dict_cr:31,few:[32,35,37],fft:35,field:[3,8,12,13,14,15,17,18,21,23,24,27,29,31,34],figur:[6,9,22,32],file:[1,3,4,6,7,8,9,16,18,22,23,24,27,28,31,32,33,34,37,38],file_path:[3,9,22,27,31,33],filepath:7,filewrit:32,fill:37,filter:[3,22,31],final_lr:22,final_spars:[3,22,31,37,38],final_v:22,find:[8,12,13,24,27,32],find_weight_data:7,fine:[8,22,38],first:[6,8,9,18,22,24,32,33,37],fit:37,fit_gener:37,fix:24,fix_data_parallel:24,flatten:[12,33],flatten_iter:33,flexibl:37,flip:13,float16:24,float32:[7,24,37],float64:32,flop:[6,8,9,22],flow:[8,31,35],fold:8,fold_conv_bn:8,foldabl:8,foldable_nod:8,folder:[12,13,27],follow:[3,7,8,12,22,24,31,32,33,37,38],footprint:22,forc:[7,21],force_fus:7,form:[12,27,33],format:[1,3,4,6,7,9,13,22,24,31,32,33,35,37,38],format_iterator_batch:[26,27],format_repr:9,format_str:9,former:[17,18,21],formula:[3,22,31],forward:[3,17,18,21,22,23,24,31],found:[3,6,8,9,12,13,16,17,18,21,22,23,24,27,29,31,32,34,35,37],fp32:8,fraction:[3,9,22,24,31,32,38],framework:[0,1,2,3,4,5,6,9,10,18,22,24,25,26,27,28,29,30,31,32,37,38],free:3,freez:24,freeze_bn_stats_epoch:22,frequenc:[3,4,22,31],from:[1,3,4,6,7,8,9,11,12,13,16,17,18,21,22,23,24,26,27,28,29,30,31,32,33,35,37,38],from_config:3,from_dict:[6,9],from_model_random:8,from_random:8,from_sparse_model:22,from_train:32,from_yaml:[3,22,31,37],front:[33,37,38],frozen:[22,38],full:[3,7,9,12,22,24,27,31,32,34,35],full_precis:24,fulli:[29,30,38],func:[6,9,12,22,27,31],func_get:[3,9,22,31],func_set:[3,9,22,31],further:[17,29],fuse:[7,22,23,24],fuse_dynamic_qu:7,fuse_modul:22,fuse_module_conv_bn_relu:[22,23],fusion:[7,23],futur:8,gama:29,gamma:[22,30,31,37,38],gamma_initi:[29,30],gan:32,gather:[9,21],gemm:[6,7,8],gemm_node_param:8,gen:33,gener:[1,4,6,7,8,9,10,18,21,22,24,26,31,32,33,34,35,37,38],generate_augmented_model:7,get:[3,6,8,9,22,24,26,28,31,32,33,34,38],get_anchor_grid:24,get_attr_float_val_for_nod:8,get_available_provid:8,get_batch_norm_param:8,get_config:3,get_conv_lay:24,get_default_boxes_300:24,get_default_graph:[31,32],get_default_sess:32,get_feature_extractor:18,get_gan_network_fn:32,get_grid:24,get_group:31,get_grouping_fn:22,get_grouping_op:[3,31],get_init_by_nam:8,get_input:24,get_kernel_shap:8,get_label:24,get_lay:24,get_layer_name_from_param:3,get_layer_param:24,get_linear_lay:24,get_main_logg:1,get_mask_initi:[3,31],get_model_input_nam:7,get_model_scop:32,get_named_layers_and_params_by_regex:24,get_network_fn:32,get_nm_root_logg:1,get_nod:6,get_node_attribut:8,get_node_by_id:8,get_node_input:8,get_node_input_nod:8,get_node_output:8,get_node_output_nod:8,get_node_param:8,get_nodes_by_input_id:8,get_nodes_by_output_id:8,get_numpy_dtyp:8,get_op_input_var:32,get_op_var_index:32,get_ops_and_inputs_by_name_or_regex:32,get_optim_learning_r:24,get_or_create_global_step:31,get_or_create_graph_ops_prun:31,get_or_create_ks_schedule_op:31,get_or_create_ks_scheduled_graph_op:31,get_output_grid_shap:24,get_pr:24,get_prunable_lay:24,get_prunable_nod:8,get_prunable_node_from_fold:8,get_prunable_op:32,get_qat_qconfig:23,get_quantization_param:23,get_quantization_params_dict:7,get_quantize_parent_for_dequantize_nod:8,get_recall_level:24,get_result:[6,9],get_tensor_var:32,get_terminal_lay:24,get_threshold:21,getter:[3,9,22,31],giou:24,github:[8,12,24,27,35],give:[8,16,18,22,24,27,28,30,35,38],given:[3,4,6,7,8,9,11,13,16,17,18,21,22,23,24,26,27,28,29,30,31,32,33,38],glob:[8,33],global:[4,22,24,31,32],global_avg:30,global_step:[3,31],global_variables_initi:[31,37],glorotuniform:[29,30],gmp:38,gmpruningmodifi:[3,22,31,37],goe:[22,24,31],gpu:[24,35],grab:[8,22,24,32],grad:22,grad_scal:24,gradient:[22,24,38],gradscal:24,gradual:[3,22,31,37,38],gradualparammodifi:22,grain:38,granular:8,graph:[3,6,7,8,22,23,24,26,27,28,29,30,31,32,37],graph_editor:[1,5],graph_optim:[1,5],graphexport:[32,37],graphkei:32,greater:[3,9,22,24,31],grid:24,grid_shap:24,ground:[24,28],ground_truth_annot:24,group:[3,8,9,17,22,24,30,31,33],group_idx:24,group_tensor:[3,22,31],groupedpruningmaskcr:[3,22,31],grouping_fn_nam:22,grouping_op_nam:[3,31],grouplearningratemodifi:31,guarante:[8,22],guid:[24,32],hack:22,had:24,half:[24,29,38],han_mobilenet:17,hand:[37,38],handl:[1,3,4,6,8,9,11,12,22,24,26,27,31,33,37,38],handler:32,happen:[4,22],hard:[24,38],hard_swish:21,hardcod:8,hardswish:21,has:[3,6,7,8,9,11,22,31,32,38],has_baselin:[6,9],have:[3,8,11,16,19,22,23,24,28,30,31,32,38],hdf5:4,head:18,height:[24,26,32],help:[1,4,24,35],helper:[0,1,4,5,6,10,11,22,25],here:[3,12,13,17,18,21,22,27,29,34,37],hidden:17,hidden_channel:17,higher:31,highest:33,hinton:24,his:37,histogram:24,hold:[3,22,31],hook:[17,18,21,22,24,28,31],horizont:13,host:35,how:[3,6,8,9,17,22,24,29,31,35],howev:[3,22,37,38],http:[8,12,17,22,24,27,33,38],human:[6,9],hyper:24,id_:[6,9],id_or_nam:[6,9],ident:[7,8],identif:[4,24],identifi:[4,6,9,24,31],ides:24,ids:[8,24],ignor:[16,17,18,21,24,28,31,33],ignore_error_tensor:[16,17,18,24],iin:8,imag:[12,13,17,24,26,27,29,32,34],image_s:[12,13,24,26,27],imagefold:[10,11,25,26],imagefolderdataset:[12,27],imagenet:[1,10,11,17,18,19,25,26,28,33],imagenet_norm:27,imagenetdataset:[12,27],imagenett:[1,10,11,25,26,33],imagenettedataset:[12,27],imagenettedownload:[12,27,34],imagenettes:[12,27,34],imagewoof:[12,27,34],imagewoofdataset:[12,27],imagewoofdownload:[12,27,34],imagewoofs:[12,27],img:[6,9,27],immedi:[3,9,22,31],impl:26,implement:[3,4,6,8,9,12,13,17,18,21,22,23,24,26,27,29,31,33,34,35,37,38],impos:[8,22,31],imposed_k:8,improv:[22,35],in_chan:30,in_channel:17,incept:[17,24],inception_v3:[10,16],inceptioncrossentropylosswrapp:24,inceptionv3:17,inclin:38,includ:[3,6,8,22,23,24,30,31,33,35,38],include_bia:30,include_bn:30,include_modifi:24,include_nod:7,include_target:23,include_valu:8,inclus:24,incom:24,increas:[3,9,21,22,31,33,38],indefinit:[26,33],independ:22,index:[3,4,6,9,11,18,22,24,28,31,32,33,38],indic:[3,17,22,24,30,31,32],individu:[6,8,9,22,31],induc:[3,22,31,35],infer:[6,8,24,29,37],inferencesess:8,infinit:8,infinite_data_load:24,info:[1,4,6,8,9,12,13,17,22,24,27,29,33,34],inform:[3,4,6,8,9,18,21,22,24,35,37],inherit:[3,9,22,31],init:22,init_lr:[3,9,22,31,37,38],init_nam:8,init_op:[29,30],init_sect:[17,29],init_spars:[3,22,31,37,38],init_v:22,initi:[3,7,8,9,17,21,22,23,29,30,31,32,38],initial_learning_r:[3,31],initialize_logg:22,initialize_sess:31,inject:31,inp:[17,18,21,22],inp_dict:32,inp_tensor:32,inp_val:32,inplac:[8,21,23],input1:8,input2:8,input:[3,4,6,7,8,9,12,13,16,17,18,21,22,23,24,26,27,28,29,30,31,32,33,37],input_batch:7,input_fn:26,input_func:22,input_id:8,input_nam:[6,7,37],input_op:31,input_qtyp:7,input_shap:[3,6,8,9,16,24,28],input_tensor:3,inputs_sampl:22,inputs_sample_max:22,inputs_sample_mean:22,inputs_sample_min:22,inputs_sample_s:22,inputs_sample_std:22,inputs_spars:22,inputs_sparsity_max:22,inputs_sparsity_mean:22,inputs_sparsity_min:22,inputs_sparsity_std:22,insid:[37,38],instal:[19,35],instanc:[3,4,6,8,9,17,18,21,22,24,26,28,31,32,33],instanti:[3,11,16,26],instead:[3,7,8,9,17,18,21,22,24,31,32,38],instruct:[37,38],int8:[7,38],integ:[3,4,7,8,9,22,31,32,33],integerop:7,integr:[6,9,19,31,33,35,36,37],intend:37,intens:11,inter_func:[3,22,31,33],interact:24,interfac:33,intermedi:[7,8,32],intern:28,interpol:[3,21,22,31,33],interpolate_list_linear:33,interpolated_integr:33,intersect:24,interv:[22,31,38],intial:7,intput:32,intro:35,introduc:[6,8,9,22],invers:24,inverse_cub:[3,22,31,33],invert:[17,29],invoc:[26,31],invok:37,invoke_batch_backward:24,invoke_batch_end:24,invoke_batch_forward:24,invoke_batch_loss:24,invoke_batch_start:24,iou:24,iou_step:24,iou_threshold:24,irregular:22,is_activ:21,is_after_end_step:31,is_foldable_nod:8,is_parallel_model:24,is_prunable_nod:8,is_prunable_op:32,is_pruning_step:3,is_train:32,is_url:33,issu:[17,18],item:[8,11,13,22,24,33],iter:[3,6,7,8,11,22,24,26,27,31,33],iter_batch:[26,27],iter_step:8,iterations_per_check:6,iters_sleep_tim:6,its:[3,4,7,8,9,13,21,22,24,31,32,33,37,38],itself:22,jekyllrb:33,join:37,json:[6,9],just:[13,24],kd_set:24,kdlosswrapp:24,kdset:24,keep:[3,6,8,9,22,24,28,31,33,36],keep_param:8,kei:[3,6,8,9,11,16,19,21,22,24,26,28,31,33],kept:38,kera:[0,1,35],keras2onnx:37,keraslogg:[3,4],kerasmodifieryaml:3,kernel:[3,6,8,9,17,22,29,30,31],kernel_initi:[29,30],kernel_s:[17,30],kernel_shap:8,keyword:[3,9,16,22,28,31],kl_diverg:[6,8],knowledg:24,known:22,ks_group:31,ks_layer_desc:22,ks_loss_sensitivity_op_var:31,kslosssensitivityanalysi:[6,9],kslosssensitivityresult:[6,9],ksperfsensitivityanalysi:[6,9],kssensitivityprogress:6,kwarg:[3,4,6,8,9,11,16,21,22,26,28,31],lab:24,label:[4,8,13,24,26,27,28,32,33],label_shap:8,labeled_data:8,larg:[22,35],larger:[22,24,31,38],last:[17,21,22,32],later:[3,9,22,31],latter:[17,18,21],layer1:22,layer2:22,layer:[1,3,4,6,8,9,17,18,21,22,23,24,25,29,31,32,38],layer_desc:22,layer_nam:[3,21,22,24],layer_norm:22,layerboostresult:22,layerwis:8,lead:31,learn:[3,9,22,24,28,31,37],learning_r:[0,1,3,22,31,38],learningr:[3,9,22,31],learningratemodifi:[3,22,31,37],least:[22,28],leav:[13,22],leave_en:[3,22,31,38],left:[24,30],len:37,length:[11,24],less:[3,9,22,31,38],lesser:38,lev:22,level:[1,3,6,8,9,11,17,22,24,31,35,38],librari:[35,37],life:31,lifecycl:[22,24],lifetim:4,like:[3,6,9,21,22,24,31,32,36,37,38],limit:[8,22,35,38],line:[9,21,31,35,37],linear:[3,6,7,22,23,24,31,33],linearli:[7,33],linux:36,list:[3,4,6,7,8,9,11,13,16,17,18,21,22,24,26,28,29,31,32,33,37,38],lite:18,littl:37,load:[3,6,7,8,9,11,16,17,18,22,24,26,27,28,31,32,33],load_desc:9,load_epoch:24,load_framework_list:9,load_framework_obj:9,load_json:[6,9],load_labeled_data:33,load_list:[3,22,31],load_manag:22,load_manager_state_dict:22,load_mask_cr:[3,22,31],load_model:24,load_numpi:33,load_obj:[3,22,31],load_optim:24,load_pretrain:28,load_recipe_yaml_str:33,load_state_dict:[21,22],load_strict:[16,17,18],loader:[8,11,13,24],local:[3,4,12,22,24,27,31,32,33,34],local_rank:24,locat:[22,24,27,37],log:[0,3,4,6,22,24,31,33,35],log_dir:4,log_histogram:24,log_histogram_raw:24,log_hyperparam:24,log_nam:24,log_path:24,log_scalar:[4,24],log_step:24,log_summari:24,log_typ:[3,9,22,31],log_upd:22,logger:[1,2,3,9,10,22,31,33],loggers_initi:22,loggersettingcallback:4,loggingmod:4,logic:[3,33],logit:[17,24,29,32,37],longer:22,look:[24,33,37,38],lookup:31,loop:22,loss:[1,4,5,6,9,10,13,22,25,28,31,38],loss_fn:[22,24],loss_kei:22,loss_measur:9,loss_tensor:31,loss_upd:22,lossesandmetricsloggingcallback:4,losswrapp:[22,24],lower:[8,22],lowest:[8,22,31,33],lr_class:[3,9,22,31,37,38],lr_kwarg:[3,9,22,31,37,38],lr_loss_sensit:22,lr_modifi:31,lr_mult:22,lrelu:21,lrlosssensitivityanalysi:[9,22],lrs:22,ltrb:[13,24],made:[3,8,22,24,31],magic:[2,5,6,8,10,25,35],magnitud:[3,8,22,31,37,38],mai:[17,18,22,24,38],main:1,make:[3,9,16,22,24,31,37],make_one_shot_iter:26,manag:[0,1,2,10,24,25,28,37],manager_state_dict:22,mani:22,manual:[22,24],map:[7,8,9,21,22,24,26,31,33],map_loc:[22,24],mark:[3,9,22,31,38],markdown:[33,37,38],mask:[3,22,24,31],mask_creat:[3,22,31],mask_creator_prun:[1,10,25],mask_differ:24,mask_prun:[1,2,10,25],mask_pruning_cr:[1,2],mask_typ:[3,22,31,37,38],mask_updat:3,masked_lay:3,maskedlay:3,master:8,match:[3,6,7,8,9,11,18,21,22,24,31,32,33,38],matmul:[7,8,31,32],matmul_node_param:8,matmulinteg:7,matplotlib:[6,9],matter:[33,37,38],max:[3,7,22,24,26,30,31,33],max_available_cor:8,max_bin:24,max_detect:24,max_epoch:9,max_node_dist:8,max_source_s:33,max_step:8,max_target_metric_loss:22,max_val:[21,24],maxim:6,maximum:[6,7,8,24,33],mdoel:8,mean:[3,6,8,9,11,12,22,24,27,31],meanaverageprecis:24,meant:[9,33],measur:[6,8,9,22,24,31,33],memori:[8,11,21,22,24,26,33],merg:[9,33],merge_desc:9,meta_canonical_nam:8,metaclass:33,metadata:6,method:[3,8,9,21,22,24,31,37],metric:[4,22,24,28,35],metric_increas:22,metric_kei:22,metrics_dict:28,metrics_initializers_dict:28,metricupdateopshook:28,microsoft:8,middl:38,might:3,mileston:[22,31,37,38],milestone_step:31,min:[3,22,24,26,31,33],min_end:[3,9,22,31],min_epoch:9,min_frequ:[3,9,22,31],min_start:[3,9,22,31],min_val:[21,24],min_valu:8,mine:24,minim:[6,28],minimum:[3,7,8,9,22,24,31,33],miss:[3,21,22,31],missing_kei:21,mix:24,mnist:[10,11,16,18,25,28,37],mnist_net:[17,29,37,38],mnistdataset:12,mnistnet:17,mobilenet:[10,16,18,25,28,32],mobilenet_const:29,mobilenet_v1_arg_scop:32,mobilenet_v2:[10,16,19,25,28],mobilenet_v2_const:29,mobilenet_v2_width:[17,29],mobilenetsect:29,mobilenetsectionset:17,mobilenetv1:32,mobilenetv2:[17,29],mobilenetv2sect:29,mobilenetv2sectionset:17,mod_extra:[31,37],mod_op:[31,37],mode:[4,7,21,22,28,29,30,31,32],model:[1,2,3,5,6,7,9,10,11,13,21,22,23,25,26,31,32,33,35,37,38],model_aug:7,model_backward:24,model_batch_second:24,model_batch_tim:24,model_batches_per_second:24,model_const:28,model_dir:28,model_fn:31,model_fn_nam:19,model_fn_param:28,model_forward:24,model_fuse_fn_kwarg:22,model_fuse_fn_nam:22,model_input:8,model_item_second:24,model_items_per_second:24,model_nam:32,model_output:[8,24],model_prunability_magnitud:22,model_quantize_qat_export:38,model_sec:24,model_to_devic:24,modelanalyz:6,modelexport:[4,37],modelproto:[6,7,8,23],modelregistri:[16,28],modelrunn:8,moder:[16,28,33],modestli:22,modif:[22,37,38],modifi:[0,1,2,4,8,10,23,24,25,28,32,35,37],modifier_a:[1,10],modifier_epoch:[1,2,10,25],modifier_idx:22,modifier_lr:[1,2,10,25],modifier_manag:28,modifier_param:[1,2,10,25],modifier_prun:[1,2,10,25],modifier_quant:[1,10],modifier_regular:[1,10],modifierprop:[3,9,22,31],modifiers_to_string_lin:[9,31],modifiersessionrunhook:[28,31],modifieryaml:[3,9,22,31],modify_estim:[31,37],modoel:29,modul:[0,35],moduleanalyz:22,moduleasanalyz:22,moduleasoneshootboost:22,modulebenchmark:24,moduledevicecontext:24,moduleexport:[24,37],moduleparampruningmask:22,modulepruninganalyz:22,modulerunfunc:[22,24],modulerunhook:24,modulerunn:24,modulerunresult:[22,24],moduletest:[22,24],moduletrain:[22,24],momentum:[8,22],monitor:[6,22],monitored_sess:28,more:[6,8,12,13,21,22,27,33,34,37,38],most:[22,32,37,38],move:[6,17,22,31,32],much:[6,9,22,24,31],multi:[3,9,17,21,22,29,31,33],multi_step_lr_schedul:31,multibox:24,multipl:[3,7,9,22,24,31,33,38],multipli:[17,22,29,31,38],multisteplr:[3,9,22,31,37,38],must:[3,4,8,9,11,19,21,22,23,24,28,31,33,34,37,38],n_box:24,name:[3,4,6,7,8,9,11,16,18,21,22,24,26,27,28,29,30,31,32,33,34,37,38],name_or_regex_pattern:[24,32],name_prefix:[24,33],name_scop:[26,27],named_modul:[22,23],namedlayerparam:24,namedtupl:21,namespac:1,nativ:[37,38],natur:35,nbit:7,ndarrai:[7,8,24,32,33],nearli:35,necessari:[3,7,8,24,31,37],need:[3,17,18,21,22,31,37,38],neg:[21,24],nest:33,net:[28,30,32],net_output:28,nets_factori:32,nets_util:[1,25],network:[3,6,8,9,17,18,21,22,29,30,32,35,37],network_fn:32,network_input_shap:8,neural:[2,5,6,8,9,10,21,22,25,30,35,37],neuralmag:38,neuralmagicml:38,never:[3,9,22,24],new_mask:24,new_quantized_nam:7,newli:24,next:[4,26],nightli:35,nlp:[16,28],nm_conditional_upd:31,nm_dataset:[12,13,27],nm_k:31,nm_ks_op:31,nm_mask:31,nm_mask_assign:31,nm_mask_upd:31,nm_mask_update_no_op:31,nm_masked_var:31,nm_prune_vars_assign:31,nm_result:8,nm_root:1,nm_save:31,nm_sparsiti:31,nm_threshold:31,nm_update_readi:31,nm_weight_upd:31,nms:24,no_fus:22,no_serialize_v:[3,9,22,31],node:[6,7,8,9,23],node_id:8,node_shap:6,nodeanalyz:6,nodearg:8,nodeparam:8,nodeproto:[7,8,23],nodes_to_exclud:7,nodes_to_quant:7,nodeshap:[6,8],nois:[6,9,11],noisydataset:11,non:[3,8,22,24,31,32],none:[3,4,6,7,8,9,12,13,16,17,18,21,22,23,24,26,27,28,29,30,31,32,33,37],nonzero:[3,31],nor:3,norm:[8,17,22,24,29,30,32],normal:[6,8,9,11,13,22,27,29,32,37],normalizer_fn:32,note:[3,8,11,21,22,24,28,31,33,37,38],notebook:36,noth:[8,24],notic:35,now:[7,33],npy:[24,33],npz:[7,24,33],nsdf3:[12,27],nthread:8,num:21,num_accumulated_batch:24,num_anchor:24,num_anchor_grid:24,num_block:[17,29],num_bucket:33,num_channel:21,num_class:[12,17,18,24,27,29,32],num_cor:[6,8,9],num_default_box:24,num_featur:32,num_imag:27,num_iter:8,num_parallel_cal:26,num_recall_level:24,num_sampl:8,num_train_batch:37,num_upd:31,num_val:24,num_warmup_iter:8,num_work:[11,33],number:[3,4,6,7,8,9,11,17,18,21,22,23,24,26,27,29,30,31,32,33,37,38],numer:[3,31],numpi:[4,7,8,24,32,33],numpyarraybatch:33,obj:[3,22,31],object:[3,4,6,7,8,9,11,13,16,17,18,22,23,24,26,28,29,30,31,32,33,34,37],observ:[22,23],obtain:8,occur:[33,35],off:[3,9,12,22,31],offer:[3,31],offici:[35,37],offset:[13,24],old:24,old_mask:24,omit:[17,32],on_epoch_begin:4,on_epoch_end:4,on_predict_batch_begin:4,on_predict_batch_end:4,on_predict_begin:4,on_predict_end:4,on_test_batch_begin:4,on_test_batch_end:4,on_test_begin:4,on_test_end:4,on_train_batch_begin:4,on_train_batch_end:4,on_train_begin:4,on_train_end:4,onc:[3,8,9,22,31,37,38],one:[3,6,7,8,17,18,21,22,24,28,30,31,32,33,38],one_shot_ks_loss_sensit:31,ones:[3,21,22,31],onli:[3,7,8,9,11,13,21,22,23,24,28,31,33,35,37,38],only_serializ:9,onnx:[0,1,4,22,23,24,32,35,38],onnx_fil:[7,8],onnx_nodes_spars:8,onnx_onnx_rel_1_6_ml_pb2:[6,7,8,23],onnx_path:32,onnx_runtime_graph_optim:8,onnxquant:7,onnxruntim:[6,8],onto:[22,24,31],oop:21,op_cond_upd:31,op_input:[31,32],op_mask_assign:31,op_mask_upd:31,op_mask_update_no_op:31,op_masked_var:31,op_nam:31,op_prune_vars_assign:31,op_sav:31,op_spars:31,op_ten:31,op_typ:[6,7,8,31],op_update_readi:31,op_var:31,op_weight_upd:31,openvino:8,openvinomodelrunn:8,oper:[3,6,7,8,9,21,23,24,28,30,31,32],ops:[3,4,7,8,22,23,26,27,28,29,30,31,32,37],ops_input:31,ops_schedul:31,ops_spars:31,ops_summari:31,ops_upd:31,opset:[4,7,24,32],optim:[0,1,2,5,8,10,16,17,18,24,25,28,33,35],optim_categori:33,optim_closur:24,optim_full_nam:33,optim_nam:33,optim_target:33,optimization_level:[6,8],optimization_recip:[3,22,31,33],optimizationrecip:[3,22,31,33],optimizer_post_step:22,optimizer_pre_step:22,optimizer_v2:3,optimizers_post_step:22,optimizerv2:3,option:[3,4,6,7,8,9,12,13,16,17,18,21,22,23,24,26,27,28,29,30,31,32,33,38],order:[6,7,9,22,33,36],ordereddict:33,org:[17,22],org_model:7,orig:[9,26],origin:[3,7,8,9,11,12,13,17,22,24,27,31,32,34],ort:8,ortmodelrunn:8,other:[1,3,6,8,9,18,22,24,31,32,33,38],otherwis:[3,6,8,9,12,13,16,17,21,22,23,24,26,27,29,30,31,32,33,34],ouput:8,out:[3,6,9,17,18,22,24,29,31,32,37],out_chan:30,out_channel:[17,18,29],out_dict:32,out_tensor:32,output:[3,4,6,7,8,9,12,13,17,18,21,22,23,24,26,27,28,29,30,32,33,37],output_block:17,output_dir:[4,24,32,37],output_edg:7,output_file_path:23,output_func:22,output_id:8,output_model_path:7,output_nam:[6,37],output_shap:[6,8,9],outputs_sampl:22,outputs_sample_max:22,outputs_sample_mean:22,outputs_sample_min:22,outputs_sample_s:22,outputs_sample_std:22,outputs_spars:22,outputs_sparsity_max:22,outputs_sparsity_mean:22,outputs_sparsity_min:22,outputs_sparsity_std:22,outsid:[22,31,33],over:[3,8,21,22,24,31,35,38],overal:[6,8,9,22,24],overprecis:35,overrid:[3,8,17,18,22,23,24,28,31,32,37],overridden:[17,18,21,22],override_bn_subclasses_forward:23,override_model_batch_s:8,overwrit:[8,21],overwrite_input_nam:8,overwritten:[22,23,31],own:[4,21,24,33,38],pack:7,packag:[0,35,37],pad:[6,26,30],pair:[24,32],paper:[17,18,21,22,24,29],parallel:[22,24,26,33],parallelize_model:24,parallelwork:33,param:[3,6,8,9,17,18,22,23,24,28,31,32,33,35,37],param_data:22,param_grad:22,param_group:22,param_init:22,param_mask:22,param_nam:[7,8,22,24],param_spars:22,param_sparsity_dim:22,param_unmask:22,paramet:[1,3,4,6,7,8,9,11,12,13,16,17,18,21,22,23,24,26,27,28,29,30,31,32,33,34,38],parameter:35,params_count:8,params_dim:9,params_strict:[3,22,24,31],params_zero_count:8,parent:[9,33],pars:[23,26,37,38],parse_optimization_str:33,part:[7,24],particular:[8,24],pass:[3,4,6,8,9,17,18,21,22,23,24,28,31,32,33,37],path:[3,4,6,7,8,9,16,17,18,22,23,24,27,28,31,32,33,34,37],path_file_count:33,path_file_s:33,pattern:[3,8,22,24,31,32,33,38],pb_path:32,pb_to_onnx:32,penalti:[22,38],pend:22,per:[3,7,17,18,21,22,24,31,37,38],per_channel:7,percent:33,percentag:[22,33,38],perf:[6,9,16,17,18,28],perform:[1,2,5,6,7,8,9,10,13,17,18,21,22,23,24,25,35,38],period:[3,22,31,38],permiss:32,persist:21,physic:[6,8,9],pick:32,piecewis:21,pil:[13,24],pip:36,pipelin:[13,35,38],pixel:24,place:[3,8,21,22,23,24],placehold:37,plot:[6,9],plot_integr:[6,9],plot_loss_kei:9,plu:35,plugin:[3,9,22,31],png:12,point:[3,7,8,9,13,17,18,22,23,24,31,38],pool2d:30,pool:[30,33],pool_siz:30,portion:38,posit:[8,24,28,33],possibl:[8,33,37],post:[7,24],post_resize_transform:27,postprocess_yolo:24,postprocessing_fn:24,potenti:24,power:38,pre:[7,13,22,28,37,38],pre_resize_transform:27,preced:[3,17,18,22,24,31,33],precis:[22,24,38],preconfigur:[17,18,28],pred:24,predict:[4,8,24,28,31],predicted_box:24,predicted_l:24,predicted_label:24,predictor:24,prefetch:26,prefetch_buffer_s:26,prefix:[3,22,24,31,32,33,38],prelu:21,prepare_qat:22,prepopul:[6,9],preprocess_for_ev:27,preprocess_for_train:27,preprocessing_typ:13,present:[8,33],preserv:[24,38],pretrain:[16,17,18,28,33],pretrained_backbon:18,pretrained_dataset:[16,17,18,28],pretrained_path:[16,17,18,28],pretrained_path_backbon:18,previou:[6,8,9],previous:[6,22,24,31],primit:33,print:[4,6,9,21,24],print_r:[6,9],prior:22,probabl:13,process:[3,6,7,8,9,13,22,24,26,27,31,33,35,37,38],process_batch:7,processor:[26,27],product:35,profil:22,programmat:22,progress:[6,7,22,24,31],proj_channel:[17,29],project:[17,29,33],promot:22,prop:[3,9,22,31],propag:24,proper:[8,22,24,30,31,32],properli:[9,13,33],properti:[3,4,6,7,8,9,12,13,18,21,22,23,24,27,31,32,33,34],proport:24,proto:8,protobuf:37,provid:[3,7,8,13,16,17,18,22,24,28,32,33,37,38],prunabl:[3,6,8,9,22,24,31,32],prunable_equation_sensit:6,prunable_lay:3,prunable_param:[6,9],prunable_params_dim:9,prunable_params_zero:6,prune:[3,6,8,9,16,22,28,31,33,35,37],prune_model_one_shot:8,prune_model_one_shot_it:8,prune_op_var:31,prune_unstructur:8,pruned_lay:3,pruning_loss_sens_approx:6,pruning_loss_sens_magnitud:[6,22,31],pruning_loss_sens_magnitude_it:6,pruning_loss_sens_one_shot:[6,22,31],pruning_loss_sens_one_shot_it:6,pruning_loss_sens_op_var:31,pruning_op_var:31,pruning_perf_sens_one_shot:6,pruning_perf_sens_one_shot_it:6,pruning_schedul:3,pruning_var:3,pruninglosssensitivityanalysi:[6,9,22,31],pruningmaskcr:[3,22,31],pruningopvar:31,pruningperfsensitivityanalysi:[6,9],pruningschedul:3,pruningscop:31,pruningsensitivityresult:[6,9],pth:[22,24],pull:[31,33],push:24,put:[6,9,17,22,24,26,29,31],pypi:35,python:[3,4,8,24,26,27,28,29,30,31,32,33,36],pythonlogg:[4,24],pytorch:[0,1,28,29,35,38],pytorchlogg:[22,24],pytorchmodifieryaml:22,qat:[22,23,38],qconfig:23,qlinear:7,qlinearconv:7,qlinearmatmul:7,qlinearop:7,qtype:7,quantiz:[5,6,8,10,22,35],quantization_mod:7,quantization_param:7,quantizationmod:7,quantizationmodifi:[22,38],quantizationparam:23,quantize_data:7,quantize_model:7,quantize_model_post_train:[5,6],quantize_qat_export:[10,22,38],quantize_rang:7,quantize_resnet_identity_add_input:8,quantize_torch_qat_export:23,quantized_data:7,quantized_model:8,quantized_value_typ:7,quantizediniti:7,quantizedvalu:7,quantizedvaluetyp:7,quantizelinear:23,quantizerd:38,quantwrapp:23,queue:33,quick:35,quickli:38,rais:[3,7,8,9,17,18,22,24,31,32,33],raise_on_error:33,rand_crop:27,rand_tran:[12,13,27],randn:37,randndataset:11,random:[8,11,24,26],random_flip_left_right:27,random_flip_up_down:27,random_horizontal_flip_image_and_annot:13,random_scaling_crop:[26,27],randomcrop:[12,13,27],randomhorizontalflip:[12,13,27],randomli:[13,22,26],rang:[3,6,9,22,24,31,33,38],rank:[3,22,24,31],rate:[3,9,22,24,30,31,35,37],ratio:[17,24,26,29],ratio_rang:26,reach:[3,22,24,31],read:[23,32,37],readabl:[6,9],readi:[3,9,22,31],real:7,reappli:22,reason:[6,9,33],recal:24,recal_upd:31,recalibr:[3,6,9,22,31],receiv:22,recent:22,recip:[3,17,18,21,22,24,31,33,35,37],recipe_typ:[3,17,18,22,24,31,33],recogn:32,recommend:[10,11,16,36],record:[6,9,22,24,31],recov:[35,38],recreat:[3,9,22,31],reduc:[3,7,22,31,32],reduce_rang:23,reducemax:7,reducemin:7,redund:35,ref:[26,27],refer:[16,24,28],referenc:22,reg:22,reg_func:22,reg_ten:22,regex:[3,22,24,31,32,38],region:21,regist:[11,16,17,18,19,21,26,28],register_batch_backward_hook:24,register_batch_end_hook:24,register_batch_forward_hook:24,register_batch_loss_hook:24,register_batch_start_hook:24,register_wrapped_model_constructor:16,registri:[1,10,13,19,25],regular:[22,32],regularize_depthwis:32,relat:[3,6,9,11,12,13,14,15,16,17,18,20,21,22,24,26,27,28,29,31,33],relev:8,reli:4,relu6:[21,30],relu:[7,8,21,22,23,29,30],relu_1:7,relu_2:7,remain:[32,38],remov:[3,8,22,24,28,31,32,35,37],removablehandl:24,remove_dynamic_tl_var:28,remove_node_and_params_from_graph:8,remove_pruning_mask:3,reorder:31,repeat:[24,26,37],repeat_count:26,replac:[8,21],replace_activ:21,repo:[16,19,28],repo_sourc:[16,28],report:[6,22,24],repositori:[35,36],repr:9,repres:[3,6,7,9,13,18,22,24,26,31,32,33],represent:[3,6,8,9,21,22,24,31,33,37],request:[22,24,35],requir:[3,8,22,28,31,36,37,38],reset:[6,22,24,28,31],reshap:[8,27],residu:17,resiz:[12,26,27,34],resnet101:[17,29],resnet101_2xwidth:17,resnet152:[17,29],resnet18:[17,29],resnet20:29,resnet34:[17,29],resnet50:[17,29],resnet50_2xwidth:17,resnet:[7,8,10,16,18,25,28],resnet_const:29,resnet_model:7,resnetsect:29,resnetsectionset:17,resnetv2_101:17,resnetv2_152:17,resnetv2_18:17,resnetv2_34:17,resnetv2_50:17,resnext101:17,resnext152:17,resnext50:17,resnext:17,respect:[8,24],respons:24,rest:[33,37,38],restor:28,restrict:[3,9,22,31],restrict_en:[3,9,22,31],restrict_extra:[3,9,22,31],restrict_initi:[3,9,22,31],result:[3,6,8,9,22,24,28,31,35,37],result_list_tensor:24,result_mean:24,result_std:24,result_typ:22,results_max:22,results_mean:22,results_min:22,results_model:[6,9],results_std:22,retrain:[6,8,22,31],retriev:[3,4,8,16,28,31,38],reus:31,revers:3,revert:22,rewrit:8,right:[3,24],rmax:7,rmin:7,root:[1,12,13,27,34],round:24,routin:7,rule:38,run:[3,4,6,7,8,9,11,17,18,21,22,24,26,28,29,30,31,32,33,34,37,38],run_batches_on_devic:24,run_config:28,run_context:31,run_extra_opt:7,run_func:24,run_it:8,run_lay:22,run_valu:31,runconfig:28,runner:8,runtim:8,runtimeerror:22,s160:[12,27,34],s320:[12,27,34],same:[3,8,22,23,24,30,32,35],sampl:[3,4,8,17,22,24,29,31,32,37,38],sample_batch:[4,24,37],sample_inputs_path:32,sample_label:[4,24],sample_outputs_path:32,sample_s:24,save:[4,6,7,9,23,24,28,31,32,33,34,37],save_desc:9,save_json:[6,9],save_model:[24,37],save_numpi:33,saver:[28,32],scaffold:[28,31],scale:[7,8,12,22,23,24,26],scale_nam:7,scale_rang:26,scale_wh:24,scale_xi:24,scaler:24,schedul:[3,9,22,31,38],schedule_lr:[1,25],schedule_op:31,scheduled_log_upd:22,scheduled_upd:22,scheduledmodif:22,scheduledmodifi:[3,9,22,31],scheduledmodifiermanag:[3,22,24,28,31,37],scheduledoptim:[22,24,37],scheduledupdatemodifi:[3,22,31],scope:[26,27,29,30,31,32],score:24,score_threhsold:24,script:[1,35,36,38],se_mod:17,se_ratio:17,seamless:35,seamlessli:37,search:8,sec_set:[17,29],second:[6,8,9,24,33,38],section:[17,29,37,38],see:[4,12,27,32],seed:24,segment:13,select:[3,22,31],self:[3,22,27,31],sensit:[0,1,6,22,24,31],sensitivity_a:[1,10],sensitivity_lr:[1,10],sensitivity_prun:[1,5,10,25],separ:[17,21,22,29],sequenc:31,sequenti:[17,18,23],serial:[3,9,22,24,31,32],serializ:[3,9,22,31],sess:[28,31,32,37],session:[23,28,31,32,35],session_run_hook:31,sessionrunhook:[28,31],sessionrunvalu:31,set:[1,3,4,6,7,8,9,17,21,22,23,24,26,29,30,31,32,37,38],set_deterministic_se:24,set_logging_level:1,set_optim_learning_r:24,set_param_data:22,set_param_mask:22,set_param_mask_from_abs_threshold:22,set_param_mask_from_spars:22,set_param_mask_from_weight:22,set_relu_to_fat:21,set_threshold:21,set_to_non:22,set_weight:3,setlearningr:[3,9,22,31],setlearningratemodifi:[3,22,31],setparammodifi:22,setter:[3,9,22,31],setup:[1,8,22,24,37,38],setweightdecaymodifi:22,shall:4,shape:[3,6,8,9,11,16,17,18,22,24,28,29,31,32,33],shape_overrid:32,share:[3,8,9,24],shift:[8,24],shot:[6,8,18,22,31],should:[3,4,6,7,8,9,11,12,16,17,18,21,22,24,26,27,28,29,31,32,33,38],should_prun:3,show:8,show_progress:[6,7,8,22,31],shuffl:26,shuffle_buffer_s:26,shutdown:33,side:26,sigmoid:[21,29,30],sign:7,signal:31,signatur:32,significantli:35,silent:[17,18,21],similarli:24,simpl:[3,17,22,24,29,31,32,35],simpler:37,simplif:35,simplifi:29,simplified_arch:29,sinc:[17,18,21],singl:[4,8,17,18,21,22,24,29,33],singleton:[0,1],size:[6,8,9,12,13,17,18,22,24,26,27,29,30,32,33,34],size_i:24,size_x:24,skip:22,slash:31,sleep:6,slice:33,slightli:24,slim:32,slope:21,small:[22,32],smaller:[35,38],smallest:22,smoother:17,softmax:[24,28,29,30],solut:[3,22,31],some:[3,4,8,22,24,31,37],someth:24,somewher:38,sort:[22,33],sort_highest:33,sort_kei:33,sourc:[1,3,4,6,7,8,9,11,12,13,16,17,18,21,22,23,24,26,27,28,29,30,31,32,33,34],space:24,sparisti:31,spars:[3,6,8,9,22,31,35,38],sparse_averag:[6,9],sparse_comparison:[6,9],sparse_integr:[6,9],sparse_measur:[6,9],sparse_tensor:[1,5],sparse_tensor_to_dens:8,sparseml:[36,37,38],sparsepruningopvar:31,sparsetensorproto:8,sparsezoo:[3,16,17,18,22,24,28,31,33,35,37,38],sparsif:22,sparsifi:[22,35,37,38],sparsiti:[3,4,6,8,9,21,22,24,31,32,35,38],sparsity_level:[6,22,31],sparsity_mask:22,sparsity_op:31,sparsity_threshold:8,sparsitymaskcr:[3,22,31],sparsitymeasur:8,sparsti:9,sparstii:9,spec:[8,28],special:[7,24],specif:[3,6,9,16,17,18,21,22,24,28,31,34,38],specifi:[3,7,8,11,16,22,24,26,28,29,31,38],specific_result_typ:22,split:[8,24,26,34],split_canonical_nam:8,split_dataset:26,split_root:34,splitstransform:27,spp:18,squar:[24,26],squeez:[17,21],squeezed_channel:21,squeezeexcit:21,src:24,ssd300:[18,24],ssd300_resnet101:18,ssd300_resnet152:18,ssd300_resnet18:18,ssd300_resnet34:18,ssd300_resnet50:18,ssd300lite:18,ssd300lite_mobilenetv2:18,ssd300mobilenetbackbon:18,ssd300resnetbackbon:18,ssd:[10,13,16,24],ssd_collate_fn:13,ssd_helper:[1,10,13],ssd_lite:[10,16],ssd_mobilenet:[10,16],ssd_random_crop:[13,24],ssd_random_crop_image_and_annot:13,ssd_resnet:[10,16],ssdbackbon:18,ssdlite:18,ssdlosswrapp:24,ssummarysaverhook:28,stabl:35,stack:[13,24,33],stage:24,standard:[1,3,9,11,12,13,17,18,21,22,24,27,29,31,32,33,38],start:[3,4,9,22,24,31,33,38],start_end_step:[3,31],start_epoch:[3,9,22,31,37,38],start_pend:22,start_step:[4,31],startup:38,stat:22,state:[3,16,17,18,22,23,24,31,33,35],state_dict:[21,22],std:[6,9,12,27],stddev:32,stdev:11,step:[3,4,6,8,9,22,24,31,32,37,38],step_count:24,step_lr_schedul:31,step_siz:31,steplr:[3,9,22,31,38],steps_per_epoch:[3,9,22,31,37],steps_per_measur:[6,22,31],still:37,stochast:38,stop:[3,9,11,22,24,31,33,38],storag:31,store:[3,6,7,8,9,11,22,24,31,33,37,38],store_init:22,store_unmask:22,str:[3,4,6,7,8,9,11,12,13,16,17,18,21,22,23,24,26,27,28,29,30,31,32,33,34],strict:[21,24],strictli:[21,22],stride:[6,9,17,29,30],string:[3,4,8,9,16,17,18,21,22,24,28,30,31,32,33,38],strip:8,strip_first_dim:8,structur:[3,6,22,27,31,38],strucur:[3,31],stub:[3,17,18,22,24,31,33],student:24,style:[32,37],sub:[16,18,26,28,32],sub_arch:18,sub_architectur:[16,28],sub_domain:[16,28],subarrai:33,subclass:[3,8,17,18,21,22,23,31],submodul:[0,2,5,10,25,35],subpackag:[0,35],subsect:38,subsequ:[22,24,31],subset:9,suggest:24,suit:35,sum:24,sum_squar:24,sum_val:24,summari:[1,24,25,28,31,37],summary_op:31,summarysaverhook:28,summarywrit:[4,24],suppli:[4,6,8,9,16,17,18,22,24,28,29,31,32],support:[3,7,8,9,13,17,22,24,29,30,31,33,35,37,38],suppress:24,sure:[3,9,16,22,31,37],surround:23,swap_node_output:8,swish:21,symmetr:[7,23,38],symmetric_activ:7,symmetric_pad2d:30,symmetric_weight:7,syntax:[3,9,22,31],system:[2,5,8,10,22,24,25,31,32,33,36,37,38],tag:[4,22,24,32],take:[3,4,6,8,13,17,18,21,22,24,26,31,33,35,37],taken:[3,4,9,22,24,26,31],tar:[8,33],target:[3,9,18,22,23,24,31,33,38],target_spars:3,task:[24,33],teacher:24,techniqu:35,temp_stud:24,temp_teach:24,temperatur:24,ten:[18,21,22,24,31,32],tensor:[3,4,8,9,13,16,17,18,21,22,24,26,27,28,29,30,31,32,33],tensor_dens:24,tensor_export:[24,33],tensor_nam:32,tensor_sampl:24,tensor_spars:24,tensorboard:[4,22,24,31,32,37],tensorboardlogg:[4,24],tensorflow:[3,4,24,26,27,28,29,30,31,32,35,38],tensorflow_estim:[28,31],tensorflow_path:32,tensorflow_v1:[0,1,37],tensorflowmodifieryaml:31,tensorproto:[7,8],tensors_batch_s:24,tensors_export:[24,33],tensors_module_forward:24,tensors_to_devic:24,tensors_to_precis:24,tensorshap:3,termin:[9,24],terminolog:24,test:[1,4,6,9,22,24,36],test_siz:24,tester_logg:22,tester_run_func:22,tf2onnx:37,tf_compat:37,tf_compat_div:32,than:[3,9,22,24,31,38],thei:[3,8,9,22,24,31,38],them:[3,8,17,18,21,22,24,31,33],themselv:[3,31,38],therefor:[3,8],thi:[3,4,6,7,8,9,11,12,13,17,18,21,22,23,24,27,31,32,33,35,36,37,38],thing:[3,6,9,22,31],those:[8,13,24,31,38],thread:[6,8,33],three:[13,24],threshold:[7,8,21,22,24,31],through:[3,4,6,7,8,9,11,17,22,24,31,32,37,38],throughout:33,til:31,time:[3,4,6,8,9,11,22,24,26,31],titl:[6,9],tl_ignore_ten:28,to_devic:24,to_string_lin:9,togeth:[3,17,22,29,31,33],token:[3,22,31,33],too:[6,9],took:24,tool:[1,7,23,37],toolkit:35,top1:24,top1acc:22,top5:24,top5acc:22,top:[11,22,24,33,35,37],topk:24,topkaccuraci:24,topmost:32,torch:[11,13,16,17,18,21,22,23,24,37],torch_distributed_zero_first:24,torchvis:[10,12,13,16],total:[8,9,11,24,33],total_flop:9,tour:35,toward:[6,38],tqdm:[6,7,8],track:[9,22,24,31],track_grad_mom:22,track_input:22,track_inputs_spars:22,track_output:22,track_outputs_spars:22,tracked_input:22,tracked_output:22,trail:31,trailing_slash:31,train:[1,3,4,7,9,12,13,17,18,21,22,23,24,26,27,28,29,30,31,32,34,35,37],train_data:37,train_on_batch:37,trainabl:[3,22,31,32,38],trainable_vari:32,trainableparamsmodifi:[3,22,31],trainer_logg:22,trainer_run_func:22,transfer:[3,22,24,28,31,33,38],transform:[3,7,12,13,22,27,31],trasnform:7,travers:8,traverse_previ:8,treat:[24,32,33],treatment:32,tri:22,truncat:8,trunctat:32,truth:[24,28],truthi:[3,9,22,31],tune:22,tupl:[3,6,7,8,9,11,13,16,17,18,22,23,24,26,27,28,30,31,32,33],twice:[29,38],two:[8,13,22,24,31],type:[3,4,6,7,8,9,13,17,18,21,22,23,24,27,30,31,33,34],type_:[9,30],typic:[3,8,24],uint8:7,unchang:38,under:[9,24,26,27,28,29,30,31,32,33,37],unexpect:21,unexpected_kei:21,union:[3,4,6,7,8,9,11,12,16,17,18,21,22,23,24,26,27,28,29,30,31,32,33],uniqu:[8,33],unit:[6,9],unless:22,unmask:[22,24],unset:[26,30],unsign:7,unstructur:[3,8,22,31,37,38],unstructuredpruningmaskcr:[3,22,31],until:[3,22,31,33,38],unus:[3,9,22,30,31],updat:[3,4,6,7,8,9,22,24,28,31,32,37,38],update_freq:4,update_frequ:[3,9,22,31,37,38],update_frequency_step:[3,31],update_model_param:8,update_op:[31,32],update_readi:[3,22,31],update_step_freq:31,upper:24,url:33,use:[3,4,6,7,8,9,12,16,17,18,21,22,24,26,27,28,29,30,31,32,33,37,38],use_batchnorm:29,use_deepsparse_infer:6,use_mixed_precis:24,use_s:17,use_zipfile_serialization_if_avail:24,used:[1,3,4,6,7,8,9,11,13,16,18,22,24,26,28,31,32,33,37,38],useful:[22,38],user:[17,22,29,33,38],uses:[17,18,22,24,29,30,31],using:[3,4,7,8,13,17,21,22,24,26,27,28,29,31,32,35,36,37,38],util:[0,1,2,5,6,7,10,11,12,13,22,25,26,27,37],utk:24,val:[8,22,27,32,33],valid:[3,4,6,8,9,12,13,22,27,31,33,34],validate_learning_r:9,validate_lr_info:9,validate_onnx_fil:8,validate_schedul:9,validate_str_iter:33,validate_upd:9,valu:[3,4,6,7,8,9,12,13,21,22,23,24,27,31,32,33,34,38],valueerror:[3,8,9,31,32,33],valueinfoproto:7,var_index:32,var_index_from_train:32,var_mask:31,var_nam:[31,32],var_ten:32,var_threshold:31,variabl:[1,3,22,23,25,28,29,30,31,35],variablev1:[31,32],varianc:32,variou:18,verif:7,version:[6,7,9,16,17,18,22,24,28,29,32,33,37,38],vgg11:[17,29],vgg11bn:[17,29],vgg13:[17,29],vgg13bn:[17,29],vgg16:[17,29],vgg16bn:[17,29],vgg19:[17,29],vgg19bn:[17,29],vgg:[10,16,25,28],vgg_const:29,vggsection:29,vggsectionset:17,via:35,video:[10,11],view:[4,24],virtual:36,vision:[12,13,15,17,18,27,29,34],visual:[4,22,24],voc:[10,11,24],vocdetect:13,vocdetectiondataset:13,vocsegment:13,vocsegmentationdataset:13,wai:[8,23,24,38],wait:24,wait_between_it:6,wall:[4,24],wall_tim:[4,24],want:7,warmup:8,warmup_iterations_per_check:6,warmup_s:24,warn:33,wasn:33,websit:35,weight:[3,6,7,8,16,17,18,22,23,24,28,31,32,37,38],weight_decai:[22,32,38],weight_nam:6,weight_qtyp:7,weight_shap:[6,8],well:[4,8,24,26,32],were:[8,24],what:[3,8,9,22,31,33],when:[3,4,6,7,8,9,11,13,22,23,24,28,31,33,35,38],where:[3,6,7,8,9,17,22,24,31,33,34],whether:[4,21,22,29,32],which:[3,7,21,22,26,31,32,34,37,38],whole:11,whose:[8,18,24,33],width:[17,24,26,29,32],width_mult:[17,29],wildcard:32,window:30,winograd:35,wise:17,within:[3,7,8,9,17,18,21,22,24,31,32,33,35],without:[3,7,22,24,31,33],won:22,word:[3,9,22,31],work:[2,5,9,10,13,21,24,25,26,28,31,32,33,38],worker:[0,1],worker_func:33,world:24,world_siz:24,wors:22,would:[8,36],wrap:[3,9,13,16,22,23,24,31,33,37],wrapped_constructor:16,wrapper:[0,1,3,7,12,13,16,21,22,24,27],wrapper_decor:33,write:[32,37],write_simple_summari:32,writer:[4,24,32],written:[37,38],x_cur:33,x_ten:[17,21,29,30],x_val:33,xavier:32,xml:8,xxx:[12,27],xxy:[12,27],xxz:[12,27],xywh:24,yaml:[3,9,22,31,33,37,38],yaml_kei:9,yaml_str:[3,9,22,31],year:13,yeild:6,yet:22,yield:[6,24],yolo:[13,17,18,24],yolo_collate_fn:13,yolo_grid:24,yolo_help:[1,10],yolo_v3:[10,16],yolo_v3_anchor_group:24,yologrid:24,yololosswrapp:24,yolov3:18,you:[21,35,36,37,38],your:[21,35,36,37,38],zero:[3,6,7,8,9,21,22,23,24,29,30,31,32,33,38],zero_grad:22,zero_point:[7,8,23],zero_point_nam:7,zeroed_param:9,zeroth:24,zipfil:24,zoo:[3,16,17,18,22,24,28,31,33]},titles:["sparseml","sparseml package","sparseml.keras package","sparseml.keras.optim package","sparseml.keras.utils package","sparseml.onnx package","sparseml.onnx.optim package","sparseml.onnx.optim.quantization package","sparseml.onnx.utils package","sparseml.optim package","sparseml.pytorch package","sparseml.pytorch.datasets package","sparseml.pytorch.datasets.classification package","sparseml.pytorch.datasets.detection package","sparseml.pytorch.datasets.recommendation package","sparseml.pytorch.datasets.video package","sparseml.pytorch.models package","sparseml.pytorch.models.classification package","sparseml.pytorch.models.detection package","sparseml.pytorch.models.external package","sparseml.pytorch.models.recommendation package","sparseml.pytorch.nn package","sparseml.pytorch.optim package","sparseml.pytorch.optim.quantization package","sparseml.pytorch.utils package","sparseml.tensorflow_v1 package","sparseml.tensorflow_v1.datasets package","sparseml.tensorflow_v1.datasets.classification package","sparseml.tensorflow_v1.models package","sparseml.tensorflow_v1.models.classification package","sparseml.tensorflow_v1.nn package","sparseml.tensorflow_v1.optim package","sparseml.tensorflow_v1.utils package","sparseml.utils package","sparseml.utils.datasets package","SparseML 0.1","Installation","Quick Tour","Sparsification Recipes"],titleterms:{"export":[4,24,32,37],activ:21,analyz:9,analyzer_a:22,analyzer_model:6,analyzer_modul:[22,31],analyzer_prun:22,base:37,benchmark:24,calibr:7,callback:4,cifar:[12,27],classif:[12,17,27,29],coco:13,constantpruningmodifi:38,content:[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34],darknet:17,data:8,dataset:[11,12,13,14,15,26,27,34],detect:[13,18],efficientnet:17,epoch:38,estim:[28,37],extern:19,fatrelu:21,framework:33,gener:11,gmpruningmodifi:38,graph_editor:8,graph_optim:8,helper:[8,13,23,24,26,32,33,34],histori:35,imagefold:[12,27],imagenet:[12,27,34],imagenett:[12,27,34],inception_v3:17,instal:36,intro:38,kera:[2,3,4,37],layer:30,learn:[35,38],learning_r:9,learningratemodifi:38,log:1,logger:[4,24],loss:[8,24,32],manag:[3,9,22,31],mask_creator_prun:[22,31],mask_prun:[3,22,31],mask_pruning_cr:3,mnist:[12,17,29],mobilenet:[17,29],mobilenet_v2:[17,29],model:[4,8,16,17,18,19,20,24,28,29],modifi:[3,9,22,31,38],modifier_a:22,modifier_epoch:[3,22,31],modifier_lr:[3,22,31],modifier_param:[3,22,31],modifier_prun:[3,22,31],modifier_quant:22,modifier_regular:22,modul:[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34],more:35,nets_util:32,onnx:[5,6,7,8,37],optim:[3,6,7,9,22,23,31,37,38],overview:35,packag:[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34],param:38,pipelin:37,prune:38,pytorch:[10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,37],quantiz:[7,23,38],quantize_model_post_train:7,quantize_qat_export:23,quick:37,rate:38,recip:38,recommend:[14,20],registri:[11,16,26,28],releas:35,resnet:[17,29],resourc:35,schedule_lr:31,sensit:9,sensitivity_a:22,sensitivity_lr:22,sensitivity_prun:[6,22,31],session:37,setlearningratemodifi:38,setweightdecaymodifi:38,singleton:33,sparse_tensor:8,sparseml:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35],sparsif:[35,37,38],ssd:18,ssd_helper:24,ssd_lite:18,ssd_mobilenet:18,ssd_resnet:18,submodul:[1,3,4,6,7,8,9,11,12,13,16,17,18,19,21,22,23,24,26,27,28,29,30,31,32,33,34],subpackag:[1,2,5,6,10,11,16,22,25,26,28,33],summari:32,tensorflow:37,tensorflow_v1:[25,26,27,28,29,30,31,32],torchvis:19,tour:37,train:38,trainableparamsmodifi:38,util:[3,4,8,24,32,33,34],variabl:[32,38],vgg:[17,29],video:15,voc:13,worker:33,wrapper:33,yolo_help:24,yolo_v3:18}}) \ No newline at end of file +Search.setIndex({docnames:["api/modules","api/sparseml","api/sparseml.keras","api/sparseml.keras.optim","api/sparseml.keras.utils","api/sparseml.onnx","api/sparseml.onnx.optim","api/sparseml.onnx.optim.quantization","api/sparseml.onnx.utils","api/sparseml.optim","api/sparseml.pytorch","api/sparseml.pytorch.datasets","api/sparseml.pytorch.datasets.classification","api/sparseml.pytorch.datasets.detection","api/sparseml.pytorch.datasets.recommendation","api/sparseml.pytorch.datasets.video","api/sparseml.pytorch.models","api/sparseml.pytorch.models.classification","api/sparseml.pytorch.models.detection","api/sparseml.pytorch.models.external","api/sparseml.pytorch.models.recommendation","api/sparseml.pytorch.nn","api/sparseml.pytorch.optim","api/sparseml.pytorch.optim.quantization","api/sparseml.pytorch.utils","api/sparseml.tensorflow_v1","api/sparseml.tensorflow_v1.datasets","api/sparseml.tensorflow_v1.datasets.classification","api/sparseml.tensorflow_v1.models","api/sparseml.tensorflow_v1.models.classification","api/sparseml.tensorflow_v1.nn","api/sparseml.tensorflow_v1.optim","api/sparseml.tensorflow_v1.utils","api/sparseml.utils","api/sparseml.utils.datasets","index","installation","quicktour","recipes"],envversion:{"sphinx.domains.c":2,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":3,"sphinx.domains.index":1,"sphinx.domains.javascript":2,"sphinx.domains.math":2,"sphinx.domains.python":2,"sphinx.domains.rst":2,"sphinx.domains.std":2,"sphinx.ext.intersphinx":1,"sphinx.ext.viewcode":1,sphinx:56},filenames:["api/modules.rst","api/sparseml.rst","api/sparseml.keras.rst","api/sparseml.keras.optim.rst","api/sparseml.keras.utils.rst","api/sparseml.onnx.rst","api/sparseml.onnx.optim.rst","api/sparseml.onnx.optim.quantization.rst","api/sparseml.onnx.utils.rst","api/sparseml.optim.rst","api/sparseml.pytorch.rst","api/sparseml.pytorch.datasets.rst","api/sparseml.pytorch.datasets.classification.rst","api/sparseml.pytorch.datasets.detection.rst","api/sparseml.pytorch.datasets.recommendation.rst","api/sparseml.pytorch.datasets.video.rst","api/sparseml.pytorch.models.rst","api/sparseml.pytorch.models.classification.rst","api/sparseml.pytorch.models.detection.rst","api/sparseml.pytorch.models.external.rst","api/sparseml.pytorch.models.recommendation.rst","api/sparseml.pytorch.nn.rst","api/sparseml.pytorch.optim.rst","api/sparseml.pytorch.optim.quantization.rst","api/sparseml.pytorch.utils.rst","api/sparseml.tensorflow_v1.rst","api/sparseml.tensorflow_v1.datasets.rst","api/sparseml.tensorflow_v1.datasets.classification.rst","api/sparseml.tensorflow_v1.models.rst","api/sparseml.tensorflow_v1.models.classification.rst","api/sparseml.tensorflow_v1.nn.rst","api/sparseml.tensorflow_v1.optim.rst","api/sparseml.tensorflow_v1.utils.rst","api/sparseml.utils.rst","api/sparseml.utils.datasets.rst","index.rst","installation.md","quicktour.md","recipes.md"],objects:{"":{sparseml:[1,0,0,"-"]},"sparseml.keras":{optim:[3,0,0,"-"],utils:[4,0,0,"-"]},"sparseml.keras.optim":{manager:[3,0,0,"-"],mask_pruning:[3,0,0,"-"],mask_pruning_creator:[3,0,0,"-"],modifier:[3,0,0,"-"],modifier_epoch:[3,0,0,"-"],modifier_lr:[3,0,0,"-"],modifier_params:[3,0,0,"-"],modifier_pruning:[3,0,0,"-"],utils:[3,0,0,"-"]},"sparseml.keras.optim.manager":{ScheduledModifierManager:[3,1,1,""]},"sparseml.keras.optim.manager.ScheduledModifierManager":{finalize:[3,2,1,""],from_yaml:[3,2,1,""],modify:[3,2,1,""]},"sparseml.keras.optim.mask_pruning":{MaskedLayer:[3,1,1,""],PruningScheduler:[3,1,1,""],remove_pruning_masks:[3,3,1,""]},"sparseml.keras.optim.mask_pruning.MaskedLayer":{build:[3,2,1,""],call:[3,2,1,""],compute_output_shape:[3,2,1,""],from_config:[3,2,1,""],get_config:[3,2,1,""],global_step:[3,2,1,""],mask_updater:[3,2,1,""],masked_layer:[3,2,1,""],masks:[3,2,1,""],pruned_layer:[3,2,1,""],pruning_vars:[3,2,1,""]},"sparseml.keras.optim.mask_pruning.PruningScheduler":{deserialize:[3,2,1,""],get_config:[3,2,1,""],should_prune:[3,2,1,""],target_sparsity:[3,2,1,""]},"sparseml.keras.optim.mask_pruning_creator":{BlockPruningMaskCreator:[3,1,1,""],DimensionPruningMaskCreator:[3,1,1,""],GroupedPruningMaskCreator:[3,1,1,""],PruningMaskCreator:[3,1,1,""],UnstructuredPruningMaskCreator:[3,1,1,""],load_mask_creator:[3,3,1,""]},"sparseml.keras.optim.mask_pruning_creator.BlockPruningMaskCreator":{group_tensor:[3,2,1,""]},"sparseml.keras.optim.mask_pruning_creator.DimensionPruningMaskCreator":{group_tensor:[3,2,1,""]},"sparseml.keras.optim.mask_pruning_creator.GroupedPruningMaskCreator":{create_sparsity_mask:[3,2,1,""],get_grouping_op:[3,2,1,""],get_mask_initializer:[3,2,1,""],group_tensor:[3,2,1,""]},"sparseml.keras.optim.mask_pruning_creator.PruningMaskCreator":{create_sparsity_mask:[3,2,1,""],get_mask_initializer:[3,2,1,""]},"sparseml.keras.optim.mask_pruning_creator.UnstructuredPruningMaskCreator":{create_sparsity_mask:[3,2,1,""],get_mask_initializer:[3,2,1,""]},"sparseml.keras.optim.modifier":{KerasModifierYAML:[3,1,1,""],Modifier:[3,1,1,""],ModifierProp:[3,1,1,""],ScheduledModifier:[3,1,1,""],ScheduledUpdateModifier:[3,1,1,""]},"sparseml.keras.optim.modifier.Modifier":{finalize:[3,2,1,""],load_list:[3,2,1,""],load_obj:[3,2,1,""],modify:[3,2,1,""]},"sparseml.keras.optim.modifier.ModifierProp":{getter:[3,2,1,""],no_serialize_val:[3,2,1,""],restrictions:[3,2,1,""],serializable:[3,2,1,""],setter:[3,2,1,""]},"sparseml.keras.optim.modifier.ScheduledModifier":{end_epoch:[3,2,1,""],start_end_steps:[3,2,1,""],start_epoch:[3,2,1,""]},"sparseml.keras.optim.modifier.ScheduledUpdateModifier":{update_frequency_steps:[3,2,1,""]},"sparseml.keras.optim.modifier_epoch":{EpochRangeModifier:[3,1,1,""]},"sparseml.keras.optim.modifier_lr":{LearningRateModifier:[3,1,1,""],SetLearningRateModifier:[3,1,1,""]},"sparseml.keras.optim.modifier_lr.LearningRateModifier":{modify:[3,2,1,""]},"sparseml.keras.optim.modifier_lr.SetLearningRateModifier":{modify:[3,2,1,""]},"sparseml.keras.optim.modifier_params":{TrainableParamsModifier:[3,1,1,""]},"sparseml.keras.optim.modifier_params.TrainableParamsModifier":{layer_names:[3,2,1,""],modify:[3,2,1,""],params:[3,4,1,""],params_strict:[3,4,1,""],trainable:[3,4,1,""],validate:[3,2,1,""]},"sparseml.keras.optim.modifier_pruning":{ConstantPruningModifier:[3,1,1,""],GMPruningModifier:[3,1,1,""]},"sparseml.keras.optim.modifier_pruning.ConstantPruningModifier":{finalize:[3,2,1,""],is_pruning_step:[3,2,1,""],layer_names:[3,2,1,""],modify:[3,2,1,""],params:[3,4,1,""],sparsity:[3,2,1,""],update_ready:[3,2,1,""]},"sparseml.keras.optim.modifier_pruning.GMPruningModifier":{exponent:[3,4,1,""],final_sparsity:[3,4,1,""],finalize:[3,2,1,""],init_sparsity:[3,4,1,""],inter_func:[3,4,1,""],layer_names:[3,2,1,""],leave_enabled:[3,4,1,""],mask_type:[3,4,1,""],modify:[3,2,1,""],params:[3,4,1,""],prunable_layers:[3,2,1,""],sparsity:[3,2,1,""],update_ready:[3,2,1,""],validate:[3,2,1,""]},"sparseml.keras.optim.utils":{get_layer_name_from_param:[3,3,1,""]},"sparseml.keras.utils":{callbacks:[4,0,0,"-"],exporter:[4,0,0,"-"],logger:[4,0,0,"-"],model:[4,0,0,"-"]},"sparseml.keras.utils.callbacks":{LoggerSettingCallback:[4,1,1,""],LossesAndMetricsLoggingCallback:[4,1,1,""]},"sparseml.keras.utils.callbacks.LoggerSettingCallback":{on_epoch_begin:[4,2,1,""],on_epoch_end:[4,2,1,""],on_predict_batch_begin:[4,2,1,""],on_predict_batch_end:[4,2,1,""],on_predict_begin:[4,2,1,""],on_predict_end:[4,2,1,""],on_test_batch_begin:[4,2,1,""],on_test_batch_end:[4,2,1,""],on_test_begin:[4,2,1,""],on_test_end:[4,2,1,""],on_train_batch_begin:[4,2,1,""],on_train_batch_end:[4,2,1,""],on_train_begin:[4,2,1,""],on_train_end:[4,2,1,""]},"sparseml.keras.utils.callbacks.LossesAndMetricsLoggingCallback":{on_epoch_end:[4,2,1,""],on_test_end:[4,2,1,""],on_train_batch_end:[4,2,1,""],on_train_begin:[4,2,1,""]},"sparseml.keras.utils.exporter":{ModelExporter:[4,1,1,""]},"sparseml.keras.utils.exporter.ModelExporter":{export_h5:[4,2,1,""],export_keras:[4,2,1,""],export_onnx:[4,2,1,""],export_samples:[4,2,1,""]},"sparseml.keras.utils.logger":{KerasLogger:[4,1,1,""],LoggingMode:[4,1,1,""],PythonLogger:[4,1,1,""],TensorBoardLogger:[4,1,1,""]},"sparseml.keras.utils.logger.KerasLogger":{log_scalar:[4,2,1,""],mode:[4,2,1,""],name:[4,2,1,""],update_freq:[4,2,1,""]},"sparseml.keras.utils.logger.LoggingMode":{PREDICT:[4,4,1,""],TEST:[4,4,1,""],TRAIN:[4,4,1,""]},"sparseml.keras.utils.logger.PythonLogger":{log_scalar:[4,2,1,""]},"sparseml.keras.utils.logger.TensorBoardLogger":{log_scalar:[4,2,1,""]},"sparseml.keras.utils.model":{sparsity:[4,3,1,""]},"sparseml.log":{get_main_logger:[1,3,1,""],get_nm_root_logger:[1,3,1,""],set_logging_level:[1,3,1,""]},"sparseml.onnx":{optim:[6,0,0,"-"],utils:[8,0,0,"-"]},"sparseml.onnx.optim":{analyzer_model:[6,0,0,"-"],quantization:[7,0,0,"-"],sensitivity_pruning:[6,0,0,"-"]},"sparseml.onnx.optim.analyzer_model":{ModelAnalyzer:[6,1,1,""],NodeAnalyzer:[6,1,1,""]},"sparseml.onnx.optim.analyzer_model.ModelAnalyzer":{dict:[6,2,1,""],from_dict:[6,2,1,""],get_node:[6,2,1,""],load_json:[6,2,1,""],nodes:[6,2,1,""],save_json:[6,2,1,""]},"sparseml.onnx.optim.analyzer_model.NodeAnalyzer":{attributes:[6,2,1,""],bias_name:[6,2,1,""],bias_shape:[6,2,1,""],dict:[6,2,1,""],flops:[6,2,1,""],id_:[6,2,1,""],input_names:[6,2,1,""],input_shapes:[6,2,1,""],op_type:[6,2,1,""],output_names:[6,2,1,""],output_shapes:[6,2,1,""],params:[6,2,1,""],prunable:[6,2,1,""],prunable_equation_sensitivity:[6,2,1,""],prunable_params:[6,2,1,""],prunable_params_zeroed:[6,2,1,""],weight_name:[6,2,1,""],weight_shape:[6,2,1,""]},"sparseml.onnx.optim.quantization":{calibration:[7,0,0,"-"],quantize:[7,0,0,"-"],quantize_model_post_training:[7,0,0,"-"]},"sparseml.onnx.optim.quantization.calibration":{CalibrationSession:[7,1,1,""]},"sparseml.onnx.optim.quantization.calibration.CalibrationSession":{add_reduce_to_node_output:[7,2,1,""],generate_augmented_model:[7,2,1,""],get_model_input_names:[7,2,1,""],get_quantization_params_dict:[7,2,1,""],model:[7,2,1,""],model_augmented:[7,2,1,""],process_batch:[7,2,1,""]},"sparseml.onnx.optim.quantization.quantize":{ONNXQuantizer:[7,1,1,""],QuantizationMode:[7,1,1,""],QuantizedInitializer:[7,1,1,""],QuantizedValue:[7,1,1,""],QuantizedValueType:[7,1,1,""],check_opset_version:[7,3,1,""],quantize:[7,3,1,""],quantize_data:[7,3,1,""]},"sparseml.onnx.optim.quantization.quantize.ONNXQuantizer":{find_weight_data:[7,2,1,""],quantize_model:[7,2,1,""]},"sparseml.onnx.optim.quantization.quantize.QuantizationMode":{IntegerOps:[7,4,1,""],QLinearOps:[7,4,1,""]},"sparseml.onnx.optim.quantization.quantize.QuantizedValueType":{Initializer:[7,4,1,""],Input:[7,4,1,""]},"sparseml.onnx.optim.quantization.quantize_model_post_training":{quantize_model_post_training:[7,3,1,""]},"sparseml.onnx.optim.sensitivity_pruning":{PruningLossSensitivityAnalysis:[6,1,1,""],PruningPerfSensitivityAnalysis:[6,1,1,""],PruningSensitivityResult:[6,1,1,""],pruning_loss_sens_approx:[6,3,1,""],pruning_loss_sens_magnitude:[6,3,1,""],pruning_loss_sens_magnitude_iter:[6,3,1,""],pruning_loss_sens_one_shot:[6,3,1,""],pruning_loss_sens_one_shot_iter:[6,3,1,""],pruning_perf_sens_one_shot:[6,3,1,""],pruning_perf_sens_one_shot_iter:[6,3,1,""]},"sparseml.onnx.optim.sensitivity_pruning.PruningLossSensitivityAnalysis":{add_result:[6,2,1,""],dict:[6,2,1,""],from_dict:[6,2,1,""],get_result:[6,2,1,""],load_json:[6,2,1,""],plot:[6,2,1,""],print_res:[6,2,1,""],results:[6,2,1,""],results_model:[6,2,1,""],save_json:[6,2,1,""]},"sparseml.onnx.optim.sensitivity_pruning.PruningPerfSensitivityAnalysis":{add_model_result:[6,2,1,""],add_result:[6,2,1,""],batch_size:[6,2,1,""],dict:[6,2,1,""],from_dict:[6,2,1,""],get_result:[6,2,1,""],load_json:[6,2,1,""],num_cores:[6,2,1,""],plot:[6,2,1,""],print_res:[6,2,1,""],results:[6,2,1,""],results_model:[6,2,1,""],save_json:[6,2,1,""]},"sparseml.onnx.optim.sensitivity_pruning.PruningSensitivityResult":{add_measurement:[6,2,1,""],averages:[6,2,1,""],baseline_average:[6,2,1,""],baseline_measurement_index:[6,2,1,""],baseline_measurement_key:[6,2,1,""],dict:[6,2,1,""],from_dict:[6,2,1,""],has_baseline:[6,2,1,""],id_:[6,2,1,""],index:[6,2,1,""],name:[6,2,1,""],sparse_average:[6,2,1,""],sparse_comparison:[6,2,1,""],sparse_integral:[6,2,1,""],sparse_measurements:[6,2,1,""]},"sparseml.onnx.utils":{data:[8,0,0,"-"],graph_editor:[8,0,0,"-"],graph_optimizer:[8,0,0,"-"],helpers:[8,0,0,"-"],loss:[8,0,0,"-"],model:[8,0,0,"-"],sparse_tensor:[8,0,0,"-"]},"sparseml.onnx.utils.data":{DataLoader:[8,1,1,""]},"sparseml.onnx.utils.data.DataLoader":{batch_size:[8,2,1,""],from_model_random:[8,2,1,""],from_random:[8,2,1,""],infinite:[8,2,1,""],iter_steps:[8,2,1,""],labeled_data:[8,2,1,""]},"sparseml.onnx.utils.graph_editor":{override_model_batch_size:[8,3,1,""],prune_model_one_shot:[8,3,1,""],prune_model_one_shot_iter:[8,3,1,""],prune_unstructured:[8,3,1,""],remove_node_and_params_from_graph:[8,3,1,""],swap_node_output:[8,3,1,""],update_model_param:[8,3,1,""]},"sparseml.onnx.utils.graph_optimizer":{fold_conv_bns:[8,3,1,""],quantize_resnet_identity_add_inputs:[8,3,1,""]},"sparseml.onnx.utils.helpers":{BatchNormParams:[8,1,1,""],NodeParam:[8,1,1,""],NodeShape:[8,1,1,""],SparsityMeasurement:[8,1,1,""],calculate_flops:[8,3,1,""],check_load_model:[8,3,1,""],conv_node_params:[8,3,1,""],extract_node_id:[8,3,1,""],extract_node_shapes:[8,3,1,""],extract_nodes_shapes_ort:[8,3,1,""],extract_nodes_shapes_shape_inference:[8,3,1,""],extract_shape:[8,3,1,""],gemm_node_params:[8,3,1,""],get_attr_float_val_for_node:[8,3,1,""],get_batch_norm_params:[8,3,1,""],get_init_by_name:[8,3,1,""],get_kernel_shape:[8,3,1,""],get_node_attributes:[8,3,1,""],get_node_by_id:[8,3,1,""],get_node_input_nodes:[8,3,1,""],get_node_inputs:[8,3,1,""],get_node_output_nodes:[8,3,1,""],get_node_outputs:[8,3,1,""],get_node_params:[8,3,1,""],get_nodes_by_input_id:[8,3,1,""],get_nodes_by_output_id:[8,3,1,""],get_numpy_dtype:[8,3,1,""],get_prunable_node_from_foldable:[8,3,1,""],get_prunable_nodes:[8,3,1,""],get_quantize_parent_for_dequantize_node:[8,3,1,""],is_foldable_node:[8,3,1,""],is_prunable_node:[8,3,1,""],matmul_node_params:[8,3,1,""],model_inputs:[8,3,1,""],model_outputs:[8,3,1,""],onnx_nodes_sparsities:[8,3,1,""],validate_onnx_file:[8,3,1,""]},"sparseml.onnx.utils.helpers.BatchNormParams":{"var":[8,2,1,""],bias:[8,2,1,""],epsilon:[8,2,1,""],mean:[8,2,1,""],momentum:[8,2,1,""],scale:[8,2,1,""]},"sparseml.onnx.utils.helpers.NodeParam":{name:[8,2,1,""],val:[8,2,1,""]},"sparseml.onnx.utils.helpers.NodeShape":{id:[8,2,1,""],input_shapes:[8,2,1,""],output_shapes:[8,2,1,""]},"sparseml.onnx.utils.helpers.SparsityMeasurement":{density:[8,2,1,""],node_id:[8,2,1,""],params_count:[8,2,1,""],params_zero_count:[8,2,1,""],sparsity:[8,2,1,""]},"sparseml.onnx.utils.loss":{kl_divergence:[8,3,1,""]},"sparseml.onnx.utils.model":{DeepSparseAnalyzeModelRunner:[8,1,1,""],DeepSparseModelRunner:[8,1,1,""],ModelRunner:[8,1,1,""],ORTModelRunner:[8,1,1,""],OpenVINOModelRunner:[8,1,1,""],correct_nm_analyze_model_node_ids:[8,3,1,""],max_available_cores:[8,3,1,""],split_canonical_names:[8,3,1,""]},"sparseml.onnx.utils.model.DeepSparseAnalyzeModelRunner":{batch_forward:[8,2,1,""],run:[8,2,1,""]},"sparseml.onnx.utils.model.DeepSparseModelRunner":{batch_forward:[8,2,1,""],run:[8,2,1,""]},"sparseml.onnx.utils.model.ModelRunner":{batch_forward:[8,2,1,""],run:[8,2,1,""],run_iter:[8,2,1,""]},"sparseml.onnx.utils.model.ORTModelRunner":{batch_forward:[8,2,1,""],run:[8,2,1,""]},"sparseml.onnx.utils.model.OpenVINOModelRunner":{available:[8,2,1,""],batch_forward:[8,2,1,""],network_input_shapes:[8,2,1,""]},"sparseml.onnx.utils.sparse_tensor":{convert_model_initializers_to_sparse:[8,3,1,""],convert_sparse_initializers_to_dense:[8,3,1,""],create_sparse_tensor:[8,3,1,""],sparse_tensor_to_dense:[8,3,1,""]},"sparseml.optim":{analyzer:[9,0,0,"-"],learning_rate:[9,0,0,"-"],manager:[9,0,0,"-"],modifier:[9,0,0,"-"],sensitivity:[9,0,0,"-"]},"sparseml.optim.analyzer":{AnalyzedLayerDesc:[9,1,1,""]},"sparseml.optim.analyzer.AnalyzedLayerDesc":{dict:[9,2,1,""],load_descs:[9,2,1,""],merge_descs:[9,2,1,""],prunable:[9,2,1,""],save_descs:[9,2,1,""],terminal:[9,2,1,""]},"sparseml.optim.learning_rate":{LearningRate:[9,1,1,""],SetLearningRate:[9,1,1,""]},"sparseml.optim.learning_rate.LearningRate":{corrected_lr_info:[9,2,1,""],init_lr:[9,4,1,""],lr_class:[9,4,1,""],lr_kwargs:[9,4,1,""],validate_lr_info:[9,2,1,""]},"sparseml.optim.learning_rate.SetLearningRate":{learning_rate:[9,4,1,""],validate_learning_rate:[9,2,1,""]},"sparseml.optim.manager":{BaseManager:[9,1,1,""]},"sparseml.optim.manager.BaseManager":{max_epochs:[9,4,1,""],min_epochs:[9,4,1,""],modifiers:[9,4,1,""],modifiers_to_string_lines:[9,2,1,""],save:[9,2,1,""],to_string_lines:[9,2,1,""]},"sparseml.optim.modifier":{BaseModifier:[9,1,1,""],BaseObject:[9,1,1,""],BaseProp:[9,1,1,""],BaseScheduled:[9,1,1,""],BaseUpdate:[9,1,1,""],ModifierProp:[9,1,1,""],ModifierYAML:[9,1,1,""]},"sparseml.optim.modifier.BaseModifier":{enabled:[9,4,1,""],initialized:[9,4,1,""],load_framework_list:[9,2,1,""],load_framework_obj:[9,2,1,""],log_types:[9,4,1,""],props:[9,2,1,""],yaml_key:[9,2,1,""]},"sparseml.optim.modifier.BaseProp":{getter:[9,2,1,""],setter:[9,2,1,""]},"sparseml.optim.modifier.BaseScheduled":{end_epoch:[9,4,1,""],start_epoch:[9,4,1,""],validate_schedule:[9,2,1,""]},"sparseml.optim.modifier.BaseUpdate":{update_frequency:[9,4,1,""],validate_update:[9,2,1,""]},"sparseml.optim.modifier.ModifierProp":{getter:[9,2,1,""],no_serialize_val:[9,2,1,""],restrictions:[9,2,1,""],serializable:[9,2,1,""],setter:[9,2,1,""]},"sparseml.optim.sensitivity":{LRLossSensitivityAnalysis:[9,1,1,""],PruningLossSensitivityAnalysis:[9,1,1,""],PruningPerfSensitivityAnalysis:[9,1,1,""],PruningSensitivityResult:[9,1,1,""],default_pruning_sparsities_loss:[9,3,1,""],default_pruning_sparsities_perf:[9,3,1,""]},"sparseml.optim.sensitivity.LRLossSensitivityAnalysis":{add_result:[9,2,1,""],dict:[9,2,1,""],load_json:[9,2,1,""],plot:[9,2,1,""],print_res:[9,2,1,""],results:[9,2,1,""],save_json:[9,2,1,""]},"sparseml.optim.sensitivity.PruningLossSensitivityAnalysis":{add_result:[9,2,1,""],dict:[9,2,1,""],from_dict:[9,2,1,""],get_result:[9,2,1,""],load_json:[9,2,1,""],plot:[9,2,1,""],print_res:[9,2,1,""],results:[9,2,1,""],results_model:[9,2,1,""],save_json:[9,2,1,""]},"sparseml.optim.sensitivity.PruningPerfSensitivityAnalysis":{add_model_result:[9,2,1,""],add_result:[9,2,1,""],batch_size:[9,2,1,""],dict:[9,2,1,""],from_dict:[9,2,1,""],get_result:[9,2,1,""],load_json:[9,2,1,""],num_cores:[9,2,1,""],plot:[9,2,1,""],print_res:[9,2,1,""],results:[9,2,1,""],results_model:[9,2,1,""],save_json:[9,2,1,""]},"sparseml.optim.sensitivity.PruningSensitivityResult":{add_measurement:[9,2,1,""],averages:[9,2,1,""],baseline_average:[9,2,1,""],baseline_measurement_index:[9,2,1,""],baseline_measurement_key:[9,2,1,""],dict:[9,2,1,""],from_dict:[9,2,1,""],has_baseline:[9,2,1,""],id_:[9,2,1,""],index:[9,2,1,""],name:[9,2,1,""],sparse_average:[9,2,1,""],sparse_comparison:[9,2,1,""],sparse_integral:[9,2,1,""],sparse_measurements:[9,2,1,""]},"sparseml.pytorch":{datasets:[11,0,0,"-"],models:[16,0,0,"-"],nn:[21,0,0,"-"],optim:[22,0,0,"-"],utils:[24,0,0,"-"]},"sparseml.pytorch.datasets":{classification:[12,0,0,"-"],detection:[13,0,0,"-"],generic:[11,0,0,"-"],recommendation:[14,0,0,"-"],registry:[11,0,0,"-"],video:[15,0,0,"-"]},"sparseml.pytorch.datasets.classification":{cifar:[12,0,0,"-"],imagefolder:[12,0,0,"-"],imagenet:[12,0,0,"-"],imagenette:[12,0,0,"-"],mnist:[12,0,0,"-"]},"sparseml.pytorch.datasets.classification.cifar":{CIFAR100Dataset:[12,1,1,""],CIFAR10Dataset:[12,1,1,""]},"sparseml.pytorch.datasets.classification.imagefolder":{ImageFolderDataset:[12,1,1,""]},"sparseml.pytorch.datasets.classification.imagefolder.ImageFolderDataset":{num_classes:[12,2,1,""]},"sparseml.pytorch.datasets.classification.imagenet":{ImageNetDataset:[12,1,1,""]},"sparseml.pytorch.datasets.classification.imagenette":{ImagenetteDataset:[12,1,1,""],ImagenetteSize:[12,1,1,""],ImagewoofDataset:[12,1,1,""]},"sparseml.pytorch.datasets.classification.imagenette.ImagenetteSize":{full:[12,4,1,""],s160:[12,4,1,""],s320:[12,4,1,""]},"sparseml.pytorch.datasets.classification.mnist":{MNISTDataset:[12,1,1,""]},"sparseml.pytorch.datasets.detection":{coco:[13,0,0,"-"],helpers:[13,0,0,"-"],voc:[13,0,0,"-"]},"sparseml.pytorch.datasets.detection.coco":{CocoDetectionDataset:[13,1,1,""],coco_2017_yolo:[13,3,1,""]},"sparseml.pytorch.datasets.detection.coco.CocoDetectionDataset":{default_boxes:[13,2,1,""]},"sparseml.pytorch.datasets.detection.helpers":{AnnotatedImageTransforms:[13,1,1,""],bounding_box_and_labels_to_yolo_fmt:[13,3,1,""],random_horizontal_flip_image_and_annotations:[13,3,1,""],ssd_collate_fn:[13,3,1,""],ssd_random_crop_image_and_annotations:[13,3,1,""],yolo_collate_fn:[13,3,1,""]},"sparseml.pytorch.datasets.detection.helpers.AnnotatedImageTransforms":{transforms:[13,2,1,""]},"sparseml.pytorch.datasets.detection.voc":{VOCDetectionDataset:[13,1,1,""],VOCSegmentationDataset:[13,1,1,""]},"sparseml.pytorch.datasets.detection.voc.VOCDetectionDataset":{default_boxes:[13,2,1,""]},"sparseml.pytorch.datasets.generic":{CacheableDataset:[11,1,1,""],EarlyStopDataset:[11,1,1,""],NoisyDataset:[11,1,1,""],RandNDataset:[11,1,1,""]},"sparseml.pytorch.datasets.registry":{DatasetRegistry:[11,1,1,""]},"sparseml.pytorch.datasets.registry.DatasetRegistry":{attributes:[11,2,1,""],create:[11,2,1,""],register:[11,2,1,""]},"sparseml.pytorch.models":{classification:[17,0,0,"-"],detection:[18,0,0,"-"],external:[19,0,0,"-"],recommendation:[20,0,0,"-"],registry:[16,0,0,"-"]},"sparseml.pytorch.models.classification":{darknet:[17,0,0,"-"],efficientnet:[17,0,0,"-"],inception_v3:[17,0,0,"-"],mnist:[17,0,0,"-"],mobilenet:[17,0,0,"-"],mobilenet_v2:[17,0,0,"-"],resnet:[17,0,0,"-"],vgg:[17,0,0,"-"]},"sparseml.pytorch.models.classification.darknet":{DarkNet:[17,1,1,""],DarkNetSectionSettings:[17,1,1,""],darknet53:[17,3,1,""]},"sparseml.pytorch.models.classification.darknet.DarkNet":{as_classifier:[17,2,1,""],as_yolo_backbone:[17,2,1,""],create_section:[17,2,1,""],forward:[17,2,1,""],training:[17,4,1,""]},"sparseml.pytorch.models.classification.efficientnet":{EfficientNet:[17,1,1,""],EfficientNetSectionSettings:[17,1,1,""],efficientnet_b0:[17,3,1,""],efficientnet_b1:[17,3,1,""],efficientnet_b2:[17,3,1,""],efficientnet_b3:[17,3,1,""],efficientnet_b4:[17,3,1,""],efficientnet_b5:[17,3,1,""],efficientnet_b6:[17,3,1,""],efficientnet_b7:[17,3,1,""]},"sparseml.pytorch.models.classification.efficientnet.EfficientNet":{create_section:[17,2,1,""],forward:[17,2,1,""],training:[17,4,1,""]},"sparseml.pytorch.models.classification.inception_v3":{InceptionV3:[17,1,1,""],inception_v3:[17,3,1,""]},"sparseml.pytorch.models.classification.inception_v3.InceptionV3":{forward:[17,2,1,""],training:[17,4,1,""]},"sparseml.pytorch.models.classification.mnist":{MnistNet:[17,1,1,""],mnist_net:[17,3,1,""]},"sparseml.pytorch.models.classification.mnist.MnistNet":{forward:[17,2,1,""],training:[17,4,1,""]},"sparseml.pytorch.models.classification.mobilenet":{MobileNet:[17,1,1,""],MobileNetSectionSettings:[17,1,1,""],han_mobilenet:[17,3,1,""],mobilenet:[17,3,1,""]},"sparseml.pytorch.models.classification.mobilenet.MobileNet":{create_section:[17,2,1,""],forward:[17,2,1,""],training:[17,4,1,""]},"sparseml.pytorch.models.classification.mobilenet_v2":{MobilenetV2:[17,1,1,""],MobilenetV2SectionSettings:[17,1,1,""],mobilenet_v2:[17,3,1,""],mobilenet_v2_width:[17,3,1,""]},"sparseml.pytorch.models.classification.mobilenet_v2.MobilenetV2":{create_section:[17,2,1,""],forward:[17,2,1,""],training:[17,4,1,""]},"sparseml.pytorch.models.classification.resnet":{ResNet:[17,1,1,""],ResNetSectionSettings:[17,1,1,""],resnet101:[17,3,1,""],resnet101_2xwidth:[17,3,1,""],resnet152:[17,3,1,""],resnet18:[17,3,1,""],resnet34:[17,3,1,""],resnet50:[17,3,1,""],resnet50_2xwidth:[17,3,1,""],resnetv2_101:[17,3,1,""],resnetv2_152:[17,3,1,""],resnetv2_18:[17,3,1,""],resnetv2_34:[17,3,1,""],resnetv2_50:[17,3,1,""],resnext101:[17,3,1,""],resnext152:[17,3,1,""],resnext50:[17,3,1,""]},"sparseml.pytorch.models.classification.resnet.ResNet":{create_section:[17,2,1,""],forward:[17,2,1,""],training:[17,4,1,""]},"sparseml.pytorch.models.classification.vgg":{VGG:[17,1,1,""],vgg11:[17,3,1,""],vgg11bn:[17,3,1,""],vgg13:[17,3,1,""],vgg13bn:[17,3,1,""],vgg16:[17,3,1,""],vgg16bn:[17,3,1,""],vgg19:[17,3,1,""],vgg19bn:[17,3,1,""]},"sparseml.pytorch.models.classification.vgg.VGG":{create_section:[17,2,1,""],forward:[17,2,1,""],training:[17,4,1,""]},"sparseml.pytorch.models.detection":{ssd:[18,0,0,"-"],ssd_lite:[18,0,0,"-"],ssd_mobilenet:[18,0,0,"-"],ssd_resnet:[18,0,0,"-"],yolo_v3:[18,0,0,"-"]},"sparseml.pytorch.models.detection.ssd":{SSD300:[18,1,1,""],SSDBackbone:[18,1,1,""]},"sparseml.pytorch.models.detection.ssd.SSD300":{forward:[18,2,1,""],training:[18,4,1,""]},"sparseml.pytorch.models.detection.ssd.SSDBackbone":{get_feature_extractor:[18,2,1,""],out_channels:[18,2,1,""]},"sparseml.pytorch.models.detection.ssd_lite":{SSD300Lite:[18,1,1,""]},"sparseml.pytorch.models.detection.ssd_lite.SSD300Lite":{forward:[18,2,1,""],training:[18,4,1,""]},"sparseml.pytorch.models.detection.ssd_mobilenet":{SSD300MobileNetBackbone:[18,1,1,""],ssd300lite_mobilenetv2:[18,3,1,""]},"sparseml.pytorch.models.detection.ssd_mobilenet.SSD300MobileNetBackbone":{get_feature_extractor:[18,2,1,""],out_channels:[18,2,1,""]},"sparseml.pytorch.models.detection.ssd_resnet":{SSD300ResNetBackbone:[18,1,1,""],ssd300_resnet101:[18,3,1,""],ssd300_resnet152:[18,3,1,""],ssd300_resnet18:[18,3,1,""],ssd300_resnet34:[18,3,1,""],ssd300_resnet50:[18,3,1,""]},"sparseml.pytorch.models.detection.ssd_resnet.SSD300ResNetBackbone":{get_feature_extractor:[18,2,1,""],out_channels:[18,2,1,""]},"sparseml.pytorch.models.detection.yolo_v3":{YoloV3:[18,1,1,""],yolo_v3:[18,3,1,""]},"sparseml.pytorch.models.detection.yolo_v3.YoloV3":{forward:[18,2,1,""],training:[18,4,1,""]},"sparseml.pytorch.models.external":{torchvision:[19,0,0,"-"]},"sparseml.pytorch.models.registry":{ModelRegistry:[16,1,1,""]},"sparseml.pytorch.models.registry.ModelRegistry":{available_keys:[16,2,1,""],create:[16,2,1,""],create_zoo_model:[16,2,1,""],input_shape:[16,2,1,""],register:[16,2,1,""],register_wrapped_model_constructor:[16,2,1,""]},"sparseml.pytorch.nn":{activations:[21,0,0,"-"],fatrelu:[21,0,0,"-"],se:[21,0,0,"-"]},"sparseml.pytorch.nn.activations":{Hardswish:[21,1,1,""],ReLU6:[21,1,1,""],ReLU:[21,1,1,""],Swish:[21,1,1,""],create_activation:[21,3,1,""],hard_swish:[21,3,1,""],is_activation:[21,3,1,""],replace_activation:[21,3,1,""],swish:[21,3,1,""]},"sparseml.pytorch.nn.activations.Hardswish":{forward:[21,2,1,""],training:[21,4,1,""]},"sparseml.pytorch.nn.activations.ReLU":{inplace:[21,4,1,""]},"sparseml.pytorch.nn.activations.ReLU6":{inplace:[21,4,1,""],max_val:[21,4,1,""],min_val:[21,4,1,""]},"sparseml.pytorch.nn.activations.Swish":{forward:[21,2,1,""],training:[21,4,1,""]},"sparseml.pytorch.nn.fatrelu":{FATReLU:[21,1,1,""],convert_relus_to_fat:[21,3,1,""],fat_exp_relu:[21,3,1,""],fat_pw_relu:[21,3,1,""],fat_relu:[21,3,1,""],fat_sig_relu:[21,3,1,""],set_relu_to_fat:[21,3,1,""]},"sparseml.pytorch.nn.fatrelu.FATReLU":{channel_wise:[21,2,1,""],dynamic:[21,2,1,""],extra_repr:[21,2,1,""],forward:[21,2,1,""],get_threshold:[21,2,1,""],load_state_dict:[21,2,1,""],num_channels:[21,2,1,""],set_threshold:[21,2,1,""],training:[21,4,1,""]},"sparseml.pytorch.nn.se":{SqueezeExcite:[21,1,1,""]},"sparseml.pytorch.nn.se.SqueezeExcite":{forward:[21,2,1,""],training:[21,4,1,""]},"sparseml.pytorch.optim":{analyzer_as:[22,0,0,"-"],analyzer_module:[22,0,0,"-"],analyzer_pruning:[22,0,0,"-"],manager:[22,0,0,"-"],mask_creator_pruning:[22,0,0,"-"],mask_pruning:[22,0,0,"-"],modifier:[22,0,0,"-"],modifier_as:[22,0,0,"-"],modifier_epoch:[22,0,0,"-"],modifier_lr:[22,0,0,"-"],modifier_params:[22,0,0,"-"],modifier_pruning:[22,0,0,"-"],modifier_quantization:[22,0,0,"-"],modifier_regularizer:[22,0,0,"-"],optimizer:[22,0,0,"-"],quantization:[23,0,0,"-"],sensitivity_as:[22,0,0,"-"],sensitivity_lr:[22,0,0,"-"],sensitivity_pruning:[22,0,0,"-"]},"sparseml.pytorch.optim.analyzer_as":{ASResultType:[22,1,1,""],ModuleASAnalyzer:[22,1,1,""]},"sparseml.pytorch.optim.analyzer_as.ASResultType":{inputs_sample:[22,4,1,""],inputs_sparsity:[22,4,1,""],outputs_sample:[22,4,1,""],outputs_sparsity:[22,4,1,""]},"sparseml.pytorch.optim.analyzer_as.ModuleASAnalyzer":{analyze_layers:[22,2,1,""],clear:[22,2,1,""],dim:[22,2,1,""],disable:[22,2,1,""],enable:[22,2,1,""],enabled:[22,2,1,""],inputs_sample:[22,2,1,""],inputs_sample_max:[22,2,1,""],inputs_sample_mean:[22,2,1,""],inputs_sample_min:[22,2,1,""],inputs_sample_size:[22,2,1,""],inputs_sample_std:[22,2,1,""],inputs_sparsity:[22,2,1,""],inputs_sparsity_max:[22,2,1,""],inputs_sparsity_mean:[22,2,1,""],inputs_sparsity_min:[22,2,1,""],inputs_sparsity_std:[22,2,1,""],module:[22,2,1,""],outputs_sample:[22,2,1,""],outputs_sample_max:[22,2,1,""],outputs_sample_mean:[22,2,1,""],outputs_sample_min:[22,2,1,""],outputs_sample_size:[22,2,1,""],outputs_sample_std:[22,2,1,""],outputs_sparsity:[22,2,1,""],outputs_sparsity_max:[22,2,1,""],outputs_sparsity_mean:[22,2,1,""],outputs_sparsity_min:[22,2,1,""],outputs_sparsity_std:[22,2,1,""],results:[22,2,1,""],results_max:[22,2,1,""],results_mean:[22,2,1,""],results_min:[22,2,1,""],results_std:[22,2,1,""],track_inputs_sparsity:[22,2,1,""],track_outputs_sparsity:[22,2,1,""]},"sparseml.pytorch.optim.analyzer_module":{ModuleAnalyzer:[22,1,1,""]},"sparseml.pytorch.optim.analyzer_module.ModuleAnalyzer":{enabled:[22,2,1,""],ks_layer_descs:[22,2,1,""],layer_desc:[22,2,1,""],module:[22,2,1,""]},"sparseml.pytorch.optim.analyzer_pruning":{ModulePruningAnalyzer:[22,1,1,""]},"sparseml.pytorch.optim.analyzer_pruning.ModulePruningAnalyzer":{analyze_layers:[22,2,1,""],module:[22,2,1,""],name:[22,2,1,""],param:[22,2,1,""],param_name:[22,2,1,""],param_sparsity:[22,2,1,""],param_sparsity_dim:[22,2,1,""],tag:[22,2,1,""]},"sparseml.pytorch.optim.manager":{ScheduledModifierManager:[22,1,1,""],load_manager:[22,3,1,""]},"sparseml.pytorch.optim.manager.ScheduledModifierManager":{from_yaml:[22,2,1,""],initialize:[22,2,1,""],initialize_loggers:[22,2,1,""],load_state_dict:[22,2,1,""],loss_update:[22,2,1,""],optimizer_post_step:[22,2,1,""],optimizer_pre_step:[22,2,1,""],state_dict:[22,2,1,""],update:[22,2,1,""]},"sparseml.pytorch.optim.mask_creator_pruning":{BlockPruningMaskCreator:[22,1,1,""],DimensionSparsityMaskCreator:[22,1,1,""],GroupedPruningMaskCreator:[22,1,1,""],PruningMaskCreator:[22,1,1,""],UnstructuredPruningMaskCreator:[22,1,1,""],load_mask_creator:[22,3,1,""]},"sparseml.pytorch.optim.mask_creator_pruning.BlockPruningMaskCreator":{group_tensor:[22,2,1,""]},"sparseml.pytorch.optim.mask_creator_pruning.DimensionSparsityMaskCreator":{group_tensor:[22,2,1,""]},"sparseml.pytorch.optim.mask_creator_pruning.GroupedPruningMaskCreator":{create_sparsity_mask:[22,2,1,""],create_sparsity_mask_from_abs_threshold:[22,2,1,""],create_sparsity_mask_from_tensor:[22,2,1,""],group_tensor:[22,2,1,""],reduce_tensor:[22,2,1,""]},"sparseml.pytorch.optim.mask_creator_pruning.PruningMaskCreator":{create_sparsity_mask:[22,2,1,""],create_sparsity_mask_from_abs_threshold:[22,2,1,""],create_sparsity_mask_from_tensor:[22,2,1,""]},"sparseml.pytorch.optim.mask_creator_pruning.UnstructuredPruningMaskCreator":{create_sparsity_mask:[22,2,1,""],create_sparsity_mask_from_abs_threshold:[22,2,1,""]},"sparseml.pytorch.optim.mask_pruning":{ModuleParamPruningMask:[22,1,1,""]},"sparseml.pytorch.optim.mask_pruning.ModuleParamPruningMask":{apply:[22,2,1,""],enabled:[22,2,1,""],layer:[22,2,1,""],layer_name:[22,2,1,""],mask_creator:[22,2,1,""],name:[22,2,1,""],param_data:[22,2,1,""],param_grad:[22,2,1,""],param_init:[22,2,1,""],param_mask:[22,2,1,""],param_name:[22,2,1,""],param_unmasked:[22,2,1,""],reset:[22,2,1,""],set_param_data:[22,2,1,""],set_param_mask:[22,2,1,""],set_param_mask_from_abs_threshold:[22,2,1,""],set_param_mask_from_sparsity:[22,2,1,""],set_param_mask_from_weights:[22,2,1,""],store_init:[22,2,1,""],store_unmasked:[22,2,1,""],track_grad_mom:[22,2,1,""]},"sparseml.pytorch.optim.modifier":{Modifier:[22,1,1,""],ModifierProp:[22,1,1,""],PyTorchModifierYAML:[22,1,1,""],ScheduledModifier:[22,1,1,""],ScheduledUpdateModifier:[22,1,1,""]},"sparseml.pytorch.optim.modifier.Modifier":{initialize:[22,2,1,""],initialize_loggers:[22,2,1,""],load_list:[22,2,1,""],load_obj:[22,2,1,""],log_update:[22,2,1,""],loggers:[22,4,1,""],loggers_initialized:[22,4,1,""],loss_update:[22,2,1,""],optimizer_post_step:[22,2,1,""],optimizer_pre_step:[22,2,1,""],update:[22,2,1,""]},"sparseml.pytorch.optim.modifier.ModifierProp":{getter:[22,2,1,""],no_serialize_val:[22,2,1,""],restrictions:[22,2,1,""],serializable:[22,2,1,""],setter:[22,2,1,""]},"sparseml.pytorch.optim.modifier.ScheduledModifier":{end_pending:[22,2,1,""],ended:[22,4,1,""],log_update:[22,2,1,""],scheduled_log_update:[22,2,1,""],scheduled_update:[22,2,1,""],start_pending:[22,2,1,""],started:[22,4,1,""],update:[22,2,1,""],update_ready:[22,2,1,""]},"sparseml.pytorch.optim.modifier.ScheduledUpdateModifier":{update:[22,2,1,""],update_ready:[22,2,1,""]},"sparseml.pytorch.optim.modifier_as":{ASRegModifier:[22,1,1,""]},"sparseml.pytorch.optim.modifier_as.ASRegModifier":{alpha:[22,4,1,""],initialize:[22,2,1,""],layer_normalized:[22,4,1,""],layers:[22,4,1,""],loss_update:[22,2,1,""],optimizer_post_step:[22,2,1,""],reg_func:[22,4,1,""],reg_tens:[22,4,1,""],update:[22,2,1,""],validate:[22,2,1,""]},"sparseml.pytorch.optim.modifier_epoch":{EpochRangeModifier:[22,1,1,""]},"sparseml.pytorch.optim.modifier_lr":{LearningRateModifier:[22,1,1,""],SetLearningRateModifier:[22,1,1,""]},"sparseml.pytorch.optim.modifier_lr.LearningRateModifier":{constant_logging:[22,4,1,""],log_update:[22,2,1,""],update:[22,2,1,""],validate:[22,2,1,""]},"sparseml.pytorch.optim.modifier_lr.SetLearningRateModifier":{applied_learning_rate:[22,4,1,""],constant_logging:[22,4,1,""],log_update:[22,2,1,""],update:[22,2,1,""]},"sparseml.pytorch.optim.modifier_params":{GradualParamModifier:[22,1,1,""],SetParamModifier:[22,1,1,""],TrainableParamsModifier:[22,1,1,""]},"sparseml.pytorch.optim.modifier_params.GradualParamModifier":{final_val:[22,4,1,""],init_val:[22,4,1,""],initialize:[22,2,1,""],inter_func:[22,4,1,""],params:[22,4,1,""],params_strict:[22,4,1,""],update:[22,2,1,""],validate:[22,2,1,""]},"sparseml.pytorch.optim.modifier_params.SetParamModifier":{initialize:[22,2,1,""],params:[22,4,1,""],params_strict:[22,4,1,""],update:[22,2,1,""],val:[22,4,1,""]},"sparseml.pytorch.optim.modifier_params.TrainableParamsModifier":{initialize:[22,2,1,""],params:[22,4,1,""],params_strict:[22,4,1,""],trainable:[22,4,1,""],update:[22,2,1,""]},"sparseml.pytorch.optim.modifier_pruning":{ConstantPruningModifier:[22,1,1,""],GMPruningModifier:[22,1,1,""]},"sparseml.pytorch.optim.modifier_pruning.ConstantPruningModifier":{from_sparse_model:[22,2,1,""],initialize:[22,2,1,""],load_state_dict:[22,2,1,""],log_update:[22,2,1,""],optimizer_post_step:[22,2,1,""],params:[22,4,1,""],state_dict:[22,2,1,""],update:[22,2,1,""]},"sparseml.pytorch.optim.modifier_pruning.GMPruningModifier":{applied_sparsity:[22,4,1,""],final_sparsity:[22,4,1,""],init_sparsity:[22,4,1,""],initialize:[22,2,1,""],inter_func:[22,4,1,""],leave_enabled:[22,4,1,""],load_state_dict:[22,2,1,""],log_update:[22,2,1,""],mask_type:[22,4,1,""],optimizer_post_step:[22,2,1,""],params:[22,4,1,""],state_dict:[22,2,1,""],update:[22,2,1,""],validate:[22,2,1,""]},"sparseml.pytorch.optim.modifier_quantization":{QuantizationModifier:[22,1,1,""]},"sparseml.pytorch.optim.modifier_quantization.QuantizationModifier":{disable_quantization_observer_epoch:[22,4,1,""],freeze_bn_stats_epoch:[22,4,1,""],initialize:[22,2,1,""],model_fuse_fn_name:[22,4,1,""],submodules:[22,4,1,""],update:[22,2,1,""],update_ready:[22,2,1,""]},"sparseml.pytorch.optim.modifier_regularizer":{SetWeightDecayModifier:[22,1,1,""]},"sparseml.pytorch.optim.modifier_regularizer.SetWeightDecayModifier":{constant_logging:[22,4,1,""],log_update:[22,2,1,""],param_groups:[22,4,1,""],update:[22,2,1,""],weight_decay:[22,4,1,""]},"sparseml.pytorch.optim.optimizer":{ScheduledOptimizer:[22,1,1,""]},"sparseml.pytorch.optim.optimizer.ScheduledOptimizer":{add_param_group:[22,2,1,""],adjust_current_step:[22,2,1,""],learning_rate:[22,2,1,""],load_manager_state_dict:[22,2,1,""],load_state_dict:[22,2,1,""],loss_update:[22,2,1,""],manager:[22,2,1,""],manager_state_dict:[22,2,1,""],param_groups:[22,2,1,""],state_dict:[22,2,1,""],step:[22,2,1,""],zero_grad:[22,2,1,""]},"sparseml.pytorch.optim.quantization":{helpers:[23,0,0,"-"],quantize_qat_export:[23,0,0,"-"]},"sparseml.pytorch.optim.quantization.helpers":{add_quant_dequant:[23,3,1,""],fuse_module_conv_bn_relus:[23,3,1,""],get_qat_qconfig:[23,3,1,""]},"sparseml.pytorch.optim.quantization.quantize_qat_export":{QuantizationParams:[23,1,1,""],get_quantization_params:[23,3,1,""],quantize_torch_qat_export:[23,3,1,""]},"sparseml.pytorch.optim.quantization.quantize_qat_export.QuantizationParams":{scale:[23,2,1,""],target:[23,2,1,""],zero_point:[23,2,1,""]},"sparseml.pytorch.optim.sensitivity_as":{ASLayerTracker:[22,1,1,""],LayerBoostResults:[22,1,1,""],ModuleASOneShootBooster:[22,1,1,""]},"sparseml.pytorch.optim.sensitivity_as.ASLayerTracker":{clear:[22,2,1,""],disable:[22,2,1,""],enable:[22,2,1,""],tracked_input:[22,2,1,""],tracked_output:[22,2,1,""]},"sparseml.pytorch.optim.sensitivity_as.LayerBoostResults":{baseline_as:[22,2,1,""],baseline_loss:[22,2,1,""],boosted_as:[22,2,1,""],boosted_loss:[22,2,1,""],name:[22,2,1,""],threshold:[22,2,1,""]},"sparseml.pytorch.optim.sensitivity_as.ModuleASOneShootBooster":{run_layers:[22,2,1,""]},"sparseml.pytorch.optim.sensitivity_lr":{default_exponential_check_lrs:[22,3,1,""],lr_loss_sensitivity:[22,3,1,""]},"sparseml.pytorch.optim.sensitivity_pruning":{model_prunability_magnitude:[22,3,1,""],pruning_loss_sens_magnitude:[22,3,1,""],pruning_loss_sens_one_shot:[22,3,1,""]},"sparseml.pytorch.utils":{benchmarker:[24,0,0,"-"],exporter:[24,0,0,"-"],helpers:[24,0,0,"-"],logger:[24,0,0,"-"],loss:[24,0,0,"-"],model:[24,0,0,"-"],module:[24,0,0,"-"],ssd_helpers:[24,0,0,"-"],yolo_helpers:[24,0,0,"-"]},"sparseml.pytorch.utils.benchmarker":{BatchBenchmarkResults:[24,1,1,""],ModuleBenchmarker:[24,1,1,""]},"sparseml.pytorch.utils.benchmarker.BatchBenchmarkResults":{add:[24,2,1,""],batch_size:[24,2,1,""],e2e_batch_seconds:[24,2,1,""],e2e_batch_timings:[24,2,1,""],e2e_batches_per_second:[24,2,1,""],e2e_item_seconds:[24,2,1,""],e2e_items_per_second:[24,2,1,""],model_batch_seconds:[24,2,1,""],model_batch_timings:[24,2,1,""],model_batches_per_second:[24,2,1,""],model_item_seconds:[24,2,1,""],model_items_per_second:[24,2,1,""]},"sparseml.pytorch.utils.benchmarker.ModuleBenchmarker":{run_batches_on_device:[24,2,1,""]},"sparseml.pytorch.utils.exporter":{ModuleExporter:[24,1,1,""]},"sparseml.pytorch.utils.exporter.ModuleExporter":{export_onnx:[24,2,1,""],export_pytorch:[24,2,1,""],export_samples:[24,2,1,""]},"sparseml.pytorch.utils.helpers":{NamedLayerParam:[24,1,1,""],any_str_or_regex_matches_param_name:[24,3,1,""],default_device:[24,3,1,""],early_stop_data_loader:[24,3,1,""],get_conv_layers:[24,3,1,""],get_layer:[24,3,1,""],get_layer_param:[24,3,1,""],get_linear_layers:[24,3,1,""],get_named_layers_and_params_by_regex:[24,3,1,""],get_optim_learning_rate:[24,3,1,""],get_prunable_layers:[24,3,1,""],get_terminal_layers:[24,3,1,""],infinite_data_loader:[24,3,1,""],mask_difference:[24,3,1,""],set_deterministic_seeds:[24,3,1,""],set_optim_learning_rate:[24,3,1,""],tensor_density:[24,3,1,""],tensor_export:[24,3,1,""],tensor_sample:[24,3,1,""],tensor_sparsity:[24,3,1,""],tensors_batch_size:[24,3,1,""],tensors_export:[24,3,1,""],tensors_module_forward:[24,3,1,""],tensors_to_device:[24,3,1,""],tensors_to_precision:[24,3,1,""],torch_distributed_zero_first:[24,3,1,""]},"sparseml.pytorch.utils.helpers.NamedLayerParam":{layer:[24,2,1,""],layer_name:[24,2,1,""],param:[24,2,1,""],param_name:[24,2,1,""]},"sparseml.pytorch.utils.logger":{PyTorchLogger:[24,1,1,""],PythonLogger:[24,1,1,""],TensorBoardLogger:[24,1,1,""]},"sparseml.pytorch.utils.logger.PyTorchLogger":{log_histogram:[24,2,1,""],log_histogram_raw:[24,2,1,""],log_hyperparams:[24,2,1,""],log_scalar:[24,2,1,""],log_scalars:[24,2,1,""],name:[24,2,1,""]},"sparseml.pytorch.utils.logger.PythonLogger":{log_histogram:[24,2,1,""],log_histogram_raw:[24,2,1,""],log_hyperparams:[24,2,1,""],log_scalar:[24,2,1,""],log_scalars:[24,2,1,""]},"sparseml.pytorch.utils.logger.TensorBoardLogger":{log_histogram:[24,2,1,""],log_histogram_raw:[24,2,1,""],log_hyperparams:[24,2,1,""],log_scalar:[24,2,1,""],log_scalars:[24,2,1,""]},"sparseml.pytorch.utils.loss":{Accuracy:[24,1,1,""],BinaryCrossEntropyLossWrapper:[24,1,1,""],CrossEntropyLossWrapper:[24,1,1,""],InceptionCrossEntropyLossWrapper:[24,1,1,""],KDLossWrapper:[24,1,1,""],KDSettings:[24,1,1,""],LossWrapper:[24,1,1,""],SSDLossWrapper:[24,1,1,""],TopKAccuracy:[24,1,1,""],YoloLossWrapper:[24,1,1,""]},"sparseml.pytorch.utils.loss.Accuracy":{calculate:[24,2,1,""],forward:[24,2,1,""],training:[24,4,1,""]},"sparseml.pytorch.utils.loss.InceptionCrossEntropyLossWrapper":{get_preds:[24,2,1,""],loss:[24,2,1,""]},"sparseml.pytorch.utils.loss.KDLossWrapper":{forward:[24,2,1,""],get_inputs:[24,2,1,""]},"sparseml.pytorch.utils.loss.KDSettings":{contradict_hinton:[24,2,1,""],teacher:[24,2,1,""],temp_student:[24,2,1,""],temp_teacher:[24,2,1,""],weight:[24,2,1,""]},"sparseml.pytorch.utils.loss.LossWrapper":{available_losses:[24,2,1,""],forward:[24,2,1,""],get_labels:[24,2,1,""],get_preds:[24,2,1,""]},"sparseml.pytorch.utils.loss.SSDLossWrapper":{get_preds:[24,2,1,""],loss:[24,2,1,""]},"sparseml.pytorch.utils.loss.TopKAccuracy":{calculate:[24,2,1,""],forward:[24,2,1,""],training:[24,4,1,""]},"sparseml.pytorch.utils.loss.YoloLossWrapper":{forward:[24,2,1,""],get_preds:[24,2,1,""],loss:[24,2,1,""]},"sparseml.pytorch.utils.model":{device_to_name_ids:[24,3,1,""],is_parallel_model:[24,3,1,""],load_epoch:[24,3,1,""],load_model:[24,3,1,""],load_optimizer:[24,3,1,""],model_to_device:[24,3,1,""],parallelize_model:[24,3,1,""],save_model:[24,3,1,""]},"sparseml.pytorch.utils.module":{ModuleDeviceContext:[24,1,1,""],ModuleRunFuncs:[24,1,1,""],ModuleRunHooks:[24,1,1,""],ModuleRunResults:[24,1,1,""],ModuleTester:[24,1,1,""],ModuleTrainer:[24,1,1,""],def_model_backward:[24,3,1,""]},"sparseml.pytorch.utils.module.ModuleDeviceContext":{default_context:[24,2,1,""],use_mixed_precision:[24,2,1,""],world_size:[24,2,1,""]},"sparseml.pytorch.utils.module.ModuleRunFuncs":{batch_size:[24,2,1,""],copy:[24,2,1,""],model_backward:[24,2,1,""],model_forward:[24,2,1,""],to_device:[24,2,1,""]},"sparseml.pytorch.utils.module.ModuleRunHooks":{invoke_batch_backward:[24,2,1,""],invoke_batch_end:[24,2,1,""],invoke_batch_forward:[24,2,1,""],invoke_batch_loss:[24,2,1,""],invoke_batch_start:[24,2,1,""],register_batch_backward_hook:[24,2,1,""],register_batch_end_hook:[24,2,1,""],register_batch_forward_hook:[24,2,1,""],register_batch_loss_hook:[24,2,1,""],register_batch_start_hook:[24,2,1,""]},"sparseml.pytorch.utils.module.ModuleRunResults":{append:[24,2,1,""],result:[24,2,1,""],result_list_tensor:[24,2,1,""],result_mean:[24,2,1,""],result_std:[24,2,1,""],results:[24,2,1,""]},"sparseml.pytorch.utils.module.ModuleTrainer":{num_accumulated_batches:[24,2,1,""],optim_closure:[24,2,1,""],optimizer:[24,2,1,""]},"sparseml.pytorch.utils.ssd_helpers":{DefaultBoxes:[24,1,1,""],MeanAveragePrecision:[24,1,1,""],get_default_boxes_300:[24,3,1,""],ssd_random_crop:[24,3,1,""]},"sparseml.pytorch.utils.ssd_helpers.DefaultBoxes":{as_ltrb:[24,2,1,""],as_xywh:[24,2,1,""],decode_output_batch:[24,2,1,""],encode_image_box_labels:[24,2,1,""],num_default_boxes:[24,2,1,""],scale_wh:[24,2,1,""],scale_xy:[24,2,1,""]},"sparseml.pytorch.utils.ssd_helpers.MeanAveragePrecision":{batch_forward:[24,2,1,""],calculate_map:[24,2,1,""],clear:[24,2,1,""],get_recall_levels:[24,2,1,""]},"sparseml.pytorch.utils.yolo_helpers":{YoloGrids:[24,1,1,""],box_giou:[24,3,1,""],build_targets:[24,3,1,""],get_output_grid_shapes:[24,3,1,""],postprocess_yolo:[24,3,1,""],yolo_v3_anchor_groups:[24,3,1,""]},"sparseml.pytorch.utils.yolo_helpers.YoloGrids":{get_anchor_grid:[24,2,1,""],get_grid:[24,2,1,""],num_anchor_grids:[24,2,1,""]},"sparseml.tensorflow_v1":{datasets:[26,0,0,"-"],models:[28,0,0,"-"],nn:[30,0,0,"-"],optim:[31,0,0,"-"],utils:[32,0,0,"-"]},"sparseml.tensorflow_v1.datasets":{classification:[27,0,0,"-"],dataset:[26,0,0,"-"],helpers:[26,0,0,"-"],registry:[26,0,0,"-"]},"sparseml.tensorflow_v1.datasets.classification":{cifar:[27,0,0,"-"],imagefolder:[27,0,0,"-"],imagenet:[27,0,0,"-"],imagenette:[27,0,0,"-"]},"sparseml.tensorflow_v1.datasets.classification.cifar":{Cifar100DataSet:[27,1,1,""],Cifar10DataSet:[27,1,1,""]},"sparseml.tensorflow_v1.datasets.classification.cifar.Cifar100DataSet":{name_scope:[27,2,1,""]},"sparseml.tensorflow_v1.datasets.classification.cifar.Cifar10DataSet":{name_scope:[27,2,1,""]},"sparseml.tensorflow_v1.datasets.classification.imagefolder":{ImageFolderDataset:[27,1,1,""],SplitsTransforms:[27,1,1,""],imagenet_normalizer:[27,3,1,""]},"sparseml.tensorflow_v1.datasets.classification.imagefolder.ImageFolderDataset":{creator:[27,2,1,""],format_iterator_batch:[27,2,1,""],image_size:[27,2,1,""],name_scope:[27,2,1,""],num_classes:[27,2,1,""],num_images:[27,2,1,""],post_resize_transforms:[27,2,1,""],pre_resize_transforms:[27,2,1,""],processor:[27,2,1,""],root:[27,2,1,""],train:[27,2,1,""]},"sparseml.tensorflow_v1.datasets.classification.imagefolder.SplitsTransforms":{train:[27,2,1,""],val:[27,2,1,""]},"sparseml.tensorflow_v1.datasets.classification.imagenet":{ImageNetDataset:[27,1,1,""]},"sparseml.tensorflow_v1.datasets.classification.imagenet.ImageNetDataset":{name_scope:[27,2,1,""]},"sparseml.tensorflow_v1.datasets.classification.imagenette":{ImagenetteDataset:[27,1,1,""],ImagenetteSize:[27,1,1,""],ImagewoofDataset:[27,1,1,""]},"sparseml.tensorflow_v1.datasets.classification.imagenette.ImagenetteDataset":{name_scope:[27,2,1,""]},"sparseml.tensorflow_v1.datasets.classification.imagenette.ImagenetteSize":{full:[27,4,1,""],s160:[27,4,1,""],s320:[27,4,1,""]},"sparseml.tensorflow_v1.datasets.classification.imagenette.ImagewoofDataset":{name_scope:[27,2,1,""]},"sparseml.tensorflow_v1.datasets.dataset":{Dataset:[26,1,1,""],create_split_iterators_handle:[26,3,1,""]},"sparseml.tensorflow_v1.datasets.dataset.Dataset":{build:[26,2,1,""],build_input_fn:[26,2,1,""],creator:[26,2,1,""],format_iterator_batch:[26,2,1,""],name_scope:[26,2,1,""],processor:[26,2,1,""]},"sparseml.tensorflow_v1.datasets.helpers":{center_square_crop:[26,3,1,""],random_scaling_crop:[26,3,1,""],resize:[26,3,1,""]},"sparseml.tensorflow_v1.datasets.registry":{DatasetRegistry:[26,1,1,""]},"sparseml.tensorflow_v1.datasets.registry.DatasetRegistry":{attributes:[26,2,1,""],create:[26,2,1,""],register:[26,2,1,""]},"sparseml.tensorflow_v1.models":{classification:[29,0,0,"-"],estimator:[28,0,0,"-"],registry:[28,0,0,"-"]},"sparseml.tensorflow_v1.models.classification":{mnist:[29,0,0,"-"],mobilenet:[29,0,0,"-"],mobilenet_v2:[29,0,0,"-"],resnet:[29,0,0,"-"],vgg:[29,0,0,"-"]},"sparseml.tensorflow_v1.models.classification.mnist":{mnist_net:[29,3,1,""]},"sparseml.tensorflow_v1.models.classification.mobilenet":{MobileNetSection:[29,1,1,""],mobilenet:[29,3,1,""],mobilenet_const:[29,3,1,""]},"sparseml.tensorflow_v1.models.classification.mobilenet.MobileNetSection":{create:[29,2,1,""]},"sparseml.tensorflow_v1.models.classification.mobilenet_v2":{MobileNetV2Section:[29,1,1,""],mobilenet_v2:[29,3,1,""],mobilenet_v2_const:[29,3,1,""],mobilenet_v2_width:[29,3,1,""]},"sparseml.tensorflow_v1.models.classification.mobilenet_v2.MobileNetV2Section":{create:[29,2,1,""]},"sparseml.tensorflow_v1.models.classification.resnet":{ResNetSection:[29,1,1,""],resnet101:[29,3,1,""],resnet152:[29,3,1,""],resnet18:[29,3,1,""],resnet20:[29,3,1,""],resnet34:[29,3,1,""],resnet50:[29,3,1,""],resnet_const:[29,3,1,""]},"sparseml.tensorflow_v1.models.classification.resnet.ResNetSection":{create:[29,2,1,""]},"sparseml.tensorflow_v1.models.classification.vgg":{VGGSection:[29,1,1,""],vgg11:[29,3,1,""],vgg11bn:[29,3,1,""],vgg13:[29,3,1,""],vgg13bn:[29,3,1,""],vgg16:[29,3,1,""],vgg16bn:[29,3,1,""],vgg19:[29,3,1,""],vgg19bn:[29,3,1,""],vgg_const:[29,3,1,""]},"sparseml.tensorflow_v1.models.classification.vgg.VGGSection":{create:[29,2,1,""]},"sparseml.tensorflow_v1.models.estimator":{ClassificationEstimatorModelFn:[28,1,1,""],EstimatorModelFn:[28,1,1,""]},"sparseml.tensorflow_v1.models.estimator.ClassificationEstimatorModelFn":{create_loss:[28,2,1,""],create_metric_update_ops_hook:[28,2,1,""],create_metrics:[28,2,1,""],create_modifier_ops_and_update_hook:[28,2,1,""],create_predictions:[28,2,1,""],create_scaffold:[28,2,1,""],create_summary_op:[28,2,1,""],create_train_summary_hook:[28,2,1,""],create_training_op:[28,2,1,""]},"sparseml.tensorflow_v1.models.estimator.EstimatorModelFn":{create:[28,2,1,""],create_loss:[28,2,1,""],create_metric_update_ops_hook:[28,2,1,""],create_metrics:[28,2,1,""],create_modifier_ops_and_update_hook:[28,2,1,""],create_predictions:[28,2,1,""],create_scaffold:[28,2,1,""],create_train_summary_hook:[28,2,1,""],create_training_op:[28,2,1,""]},"sparseml.tensorflow_v1.models.registry":{ModelRegistry:[28,1,1,""]},"sparseml.tensorflow_v1.models.registry.ModelRegistry":{available_keys:[28,2,1,""],create:[28,2,1,""],create_estimator:[28,2,1,""],create_zoo_model:[28,2,1,""],input_shape:[28,2,1,""],load_pretrained:[28,2,1,""],register:[28,2,1,""],saver:[28,2,1,""]},"sparseml.tensorflow_v1.nn":{layers:[30,0,0,"-"]},"sparseml.tensorflow_v1.nn.layers":{activation:[30,3,1,""],conv2d:[30,3,1,""],conv2d_block:[30,3,1,""],dense_block:[30,3,1,""],depthwise_conv2d_block:[30,3,1,""],fc:[30,3,1,""],pool2d:[30,3,1,""]},"sparseml.tensorflow_v1.optim":{analyzer_module:[31,0,0,"-"],manager:[31,0,0,"-"],mask_creator_pruning:[31,0,0,"-"],mask_pruning:[31,0,0,"-"],modifier:[31,0,0,"-"],modifier_epoch:[31,0,0,"-"],modifier_lr:[31,0,0,"-"],modifier_params:[31,0,0,"-"],modifier_pruning:[31,0,0,"-"],schedule_lr:[31,0,0,"-"],sensitivity_pruning:[31,0,0,"-"]},"sparseml.tensorflow_v1.optim.analyzer_module":{analyze_module:[31,3,1,""]},"sparseml.tensorflow_v1.optim.manager":{ScheduledModifierManager:[31,1,1,""]},"sparseml.tensorflow_v1.optim.manager.ScheduledModifierManager":{RECAL_UPDATE:[31,4,1,""],complete_graph:[31,2,1,""],create_ops:[31,2,1,""],from_yaml:[31,2,1,""],initialize_session:[31,2,1,""],modifiers_to_string_lines:[31,2,1,""]},"sparseml.tensorflow_v1.optim.mask_creator_pruning":{BlockPruningMaskCreator:[31,1,1,""],DimensionPruningMaskCreator:[31,1,1,""],GroupedPruningMaskCreator:[31,1,1,""],PruningMaskCreator:[31,1,1,""],UnstructuredPruningMaskCreator:[31,1,1,""],load_mask_creator:[31,3,1,""]},"sparseml.tensorflow_v1.optim.mask_creator_pruning.BlockPruningMaskCreator":{group_tensor:[31,2,1,""]},"sparseml.tensorflow_v1.optim.mask_creator_pruning.DimensionPruningMaskCreator":{group_tensor:[31,2,1,""]},"sparseml.tensorflow_v1.optim.mask_creator_pruning.GroupedPruningMaskCreator":{create_sparsity_mask:[31,2,1,""],get_grouping_op:[31,2,1,""],get_mask_initializer:[31,2,1,""],group_tensor:[31,2,1,""]},"sparseml.tensorflow_v1.optim.mask_creator_pruning.PruningMaskCreator":{create_sparsity_mask:[31,2,1,""],get_mask_initializer:[31,2,1,""]},"sparseml.tensorflow_v1.optim.mask_creator_pruning.UnstructuredPruningMaskCreator":{create_sparsity_mask:[31,2,1,""],get_mask_initializer:[31,2,1,""]},"sparseml.tensorflow_v1.optim.mask_pruning":{PruningOpVars:[31,1,1,""],PruningScope:[31,1,1,""],apply_op_vars_masks:[31,3,1,""],create_graph_ops_pruning:[31,3,1,""],create_ks_schedule_ops:[31,3,1,""],create_ks_scheduled_constant_graph_ops:[31,3,1,""],create_op_pruning:[31,3,1,""],create_summaries_pruning:[31,3,1,""],get_or_create_graph_ops_pruning:[31,3,1,""],get_or_create_ks_schedule_ops:[31,3,1,""],get_or_create_ks_scheduled_graph_ops:[31,3,1,""]},"sparseml.tensorflow_v1.optim.mask_pruning.PruningOpVars":{mask:[31,2,1,""],masked:[31,2,1,""],op:[31,2,1,""],op_input:[31,2,1,""],update:[31,2,1,""]},"sparseml.tensorflow_v1.optim.mask_pruning.PruningScope":{NM_KS:[31,4,1,""],NM_KS_OPS:[31,4,1,""],OPS:[31,4,1,""],OPS_INPUT:[31,4,1,""],OPS_SCHEDULE:[31,4,1,""],OPS_SPARSITY:[31,4,1,""],OPS_SUMMARY:[31,4,1,""],OPS_UPDATE:[31,4,1,""],OP_COND_UPDATE:[31,4,1,""],OP_MASKED_VAR:[31,4,1,""],OP_MASK_ASSIGN:[31,4,1,""],OP_MASK_UPDATE:[31,4,1,""],OP_MASK_UPDATE_NO_OP:[31,4,1,""],OP_PRUNE_VARS_ASSIGN:[31,4,1,""],OP_SAVE:[31,4,1,""],OP_SPARSITY:[31,4,1,""],OP_UPDATE_READY:[31,4,1,""],OP_WEIGHT_UPDATE:[31,4,1,""],VAR_MASK:[31,4,1,""],VAR_THRESHOLD:[31,4,1,""],collection_name:[31,2,1,""],general:[31,2,1,""],model:[31,2,1,""]},"sparseml.tensorflow_v1.optim.modifier":{Modifier:[31,1,1,""],ModifierProp:[31,1,1,""],ModifierSessionRunHook:[31,1,1,""],ScheduledModifier:[31,1,1,""],ScheduledUpdateModifier:[31,1,1,""],TensorFlowModifierYAML:[31,1,1,""]},"sparseml.tensorflow_v1.optim.modifier.Modifier":{complete_graph:[31,2,1,""],create_ops:[31,2,1,""],get_group:[31,2,1,""],initialize_session:[31,2,1,""],load_list:[31,2,1,""],load_obj:[31,2,1,""],modify_estimator:[31,2,1,""]},"sparseml.tensorflow_v1.optim.modifier.ModifierProp":{getter:[31,2,1,""],no_serialize_val:[31,2,1,""],restrictions:[31,2,1,""],serializable:[31,2,1,""],setter:[31,2,1,""]},"sparseml.tensorflow_v1.optim.modifier.ModifierSessionRunHook":{after_run:[31,2,1,""]},"sparseml.tensorflow_v1.optim.modifier.ScheduledModifier":{start_end_steps:[31,2,1,""]},"sparseml.tensorflow_v1.optim.modifier.ScheduledUpdateModifier":{update_frequency_steps:[31,2,1,""]},"sparseml.tensorflow_v1.optim.modifier_epoch":{EpochRangeModifier:[31,1,1,""]},"sparseml.tensorflow_v1.optim.modifier_lr":{GroupLearningRateModifier:[31,1,1,""],LearningRateModifier:[31,1,1,""],SetLearningRateModifier:[31,1,1,""]},"sparseml.tensorflow_v1.optim.modifier_lr.GroupLearningRateModifier":{create_ops:[31,2,1,""]},"sparseml.tensorflow_v1.optim.modifier_lr.LearningRateModifier":{create_ops:[31,2,1,""],get_group:[31,2,1,""]},"sparseml.tensorflow_v1.optim.modifier_lr.SetLearningRateModifier":{create_ops:[31,2,1,""],get_group:[31,2,1,""]},"sparseml.tensorflow_v1.optim.modifier_params":{TrainableParamsModifier:[31,1,1,""]},"sparseml.tensorflow_v1.optim.modifier_params.TrainableParamsModifier":{complete_graph:[31,2,1,""],create_ops:[31,2,1,""],params:[31,4,1,""],params_strict:[31,4,1,""],trainable:[31,4,1,""],validate:[31,2,1,""]},"sparseml.tensorflow_v1.optim.modifier_pruning":{ConstantPruningModifier:[31,1,1,""],GMPruningModifier:[31,1,1,""]},"sparseml.tensorflow_v1.optim.modifier_pruning.ConstantPruningModifier":{complete_graph:[31,2,1,""],create_ops:[31,2,1,""],initialize_session:[31,2,1,""],ks_group:[31,4,1,""],params:[31,4,1,""],prune_op_vars:[31,2,1,""],sparsity:[31,2,1,""],update_ready:[31,2,1,""]},"sparseml.tensorflow_v1.optim.modifier_pruning.GMPruningModifier":{complete_graph:[31,2,1,""],create_ops:[31,2,1,""],exponent:[31,4,1,""],final_sparsity:[31,4,1,""],init_sparsity:[31,4,1,""],initialize_session:[31,2,1,""],inter_func:[31,4,1,""],ks_group:[31,4,1,""],leave_enabled:[31,4,1,""],mask_type:[31,4,1,""],params:[31,4,1,""],prune_op_vars:[31,2,1,""],sparsity:[31,2,1,""],update_ready:[31,2,1,""],validate:[31,2,1,""]},"sparseml.tensorflow_v1.optim.schedule_lr":{multi_step_lr_schedule:[31,3,1,""],step_lr_schedule:[31,3,1,""]},"sparseml.tensorflow_v1.optim.sensitivity_pruning":{SparsePruningOpVars:[31,1,1,""],pruning_loss_sens_magnitude:[31,3,1,""],pruning_loss_sens_one_shot:[31,3,1,""],pruning_loss_sens_op_vars:[31,3,1,""]},"sparseml.tensorflow_v1.optim.sensitivity_pruning.SparsePruningOpVars":{op_vars:[31,2,1,""],sparsity:[31,2,1,""]},"sparseml.tensorflow_v1.utils":{exporter:[32,0,0,"-"],helpers:[32,0,0,"-"],loss:[32,0,0,"-"],nets_utils:[32,0,0,"-"],summary:[32,0,0,"-"],variable:[32,0,0,"-"]},"sparseml.tensorflow_v1.utils.exporter":{GraphExporter:[32,1,1,""],default_onnx_opset:[32,3,1,""]},"sparseml.tensorflow_v1.utils.exporter.GraphExporter":{checkpoint_path:[32,2,1,""],export_checkpoint:[32,2,1,""],export_named_samples:[32,2,1,""],export_onnx:[32,2,1,""],export_pb:[32,2,1,""],export_samples:[32,2,1,""],onnx_path:[32,2,1,""],pb_path:[32,2,1,""],pb_to_onnx:[32,2,1,""],sample_inputs_path:[32,2,1,""],sample_outputs_path:[32,2,1,""],tensorflow_path:[32,2,1,""]},"sparseml.tensorflow_v1.utils.helpers":{tf_compat_div:[32,3,1,""]},"sparseml.tensorflow_v1.utils.loss":{accuracy:[32,3,1,""],batch_cross_entropy_loss:[32,3,1,""]},"sparseml.tensorflow_v1.utils.nets_utils":{get_gan_network_fn:[32,3,1,""],get_model_scope:[32,3,1,""],get_network_fn:[32,3,1,""],mobilenet_v1_arg_scope:[32,3,1,""]},"sparseml.tensorflow_v1.utils.summary":{write_simple_summary:[32,3,1,""]},"sparseml.tensorflow_v1.utils.variable":{any_str_or_regex_matches_tensor_name:[32,3,1,""],clean_tensor_name:[32,3,1,""],eval_tensor_density:[32,3,1,""],eval_tensor_sparsity:[32,3,1,""],get_op_input_var:[32,3,1,""],get_op_var_index:[32,3,1,""],get_ops_and_inputs_by_name_or_regex:[32,3,1,""],get_prunable_ops:[32,3,1,""],get_tensor_var:[32,3,1,""],is_prunable_op:[32,3,1,""]},"sparseml.utils":{datasets:[34,0,0,"-"],frameworks:[33,0,0,"-"],helpers:[33,0,0,"-"],singleton:[33,0,0,"-"],worker:[33,0,0,"-"],wrapper:[33,0,0,"-"]},"sparseml.utils.datasets":{helpers:[34,0,0,"-"],imagenet:[34,0,0,"-"],imagenette:[34,0,0,"-"]},"sparseml.utils.datasets.helpers":{default_dataset_path:[34,3,1,""]},"sparseml.utils.datasets.imagenette":{ImagenetteDownloader:[34,1,1,""],ImagenetteSize:[34,1,1,""],ImagewoofDownloader:[34,1,1,""]},"sparseml.utils.datasets.imagenette.ImagenetteDownloader":{dataset_size:[34,2,1,""],download:[34,2,1,""],download_root:[34,2,1,""],extracted_root:[34,2,1,""],split_root:[34,2,1,""]},"sparseml.utils.datasets.imagenette.ImagenetteSize":{full:[34,4,1,""],s160:[34,4,1,""],s320:[34,4,1,""]},"sparseml.utils.datasets.imagenette.ImagewoofDownloader":{dataset_size:[34,2,1,""],download:[34,2,1,""],download_root:[34,2,1,""],extracted_root:[34,2,1,""],split_root:[34,2,1,""]},"sparseml.utils.helpers":{NumpyArrayBatcher:[33,1,1,""],bucket_iterable:[33,3,1,""],clean_path:[33,3,1,""],convert_to_bool:[33,3,1,""],create_dirs:[33,3,1,""],create_parent_dirs:[33,3,1,""],create_unique_dir:[33,3,1,""],flatten_iterable:[33,3,1,""],interpolate:[33,3,1,""],interpolate_list_linear:[33,3,1,""],interpolated_integral:[33,3,1,""],is_url:[33,3,1,""],load_labeled_data:[33,3,1,""],load_numpy:[33,3,1,""],load_recipe_yaml_str:[33,3,1,""],parse_optimization_str:[33,3,1,""],path_file_count:[33,3,1,""],path_file_size:[33,3,1,""],save_numpy:[33,3,1,""],tensor_export:[33,3,1,""],tensors_export:[33,3,1,""],validate_str_iterable:[33,3,1,""]},"sparseml.utils.helpers.NumpyArrayBatcher":{append:[33,2,1,""],stack:[33,2,1,""]},"sparseml.utils.singleton":{Singleton:[33,1,1,""]},"sparseml.utils.worker":{ParallelWorker:[33,1,1,""]},"sparseml.utils.worker.ParallelWorker":{add:[33,2,1,""],add_async:[33,2,1,""],add_async_generator:[33,2,1,""],add_item:[33,2,1,""],indefinite:[33,2,1,""],shutdown:[33,2,1,""],start:[33,2,1,""]},"sparseml.utils.wrapper":{wrapper_decorator:[33,3,1,""]},sparseml:{keras:[2,0,0,"-"],log:[1,0,0,"-"],onnx:[5,0,0,"-"],optim:[9,0,0,"-"],pytorch:[10,0,0,"-"],tensorflow_v1:[25,0,0,"-"],utils:[33,0,0,"-"]}},objnames:{"0":["py","module","Python module"],"1":["py","class","Python class"],"2":["py","method","Python method"],"3":["py","function","Python function"],"4":["py","attribute","Python attribute"]},objtypes:{"0":"py:module","1":"py:class","2":"py:method","3":"py:function","4":"py:attribute"},terms:{"00001":22,"00010671895716335979":22,"00011739085287969578":22,"00012912993816766537":22,"00014204293198443192":22,"00015624722518287512":22,"00017187194770116264":22,"00018905914247127894":22,"00020796505671840686":22,"00022876156239024756":22,"00025163771862927233":22,"0002768014904921996":22,"0003044816395414196":22,"00033492980349556157":22,"00036842278384511775":22,"0004052650622296296":22,"0004457915684525926":22,"0004903707252978519":22,"0005394077978276372":22,"000593348577610401":22,"0006526834353714411":22,"0007179517789085853":22,"0007897469567994438":22,"0008687216524793883":22,"0009555938177273272":22,"001":[3,22,31,32],"00105115319950006":22,"001156268519450066":22,"0012718953713950728":22,"0013990849085345801":22,"0015389933993880383":22,"0016928927393268422":22,"0018621820132595267":22,"0020484002145854797":22,"0022532402360440277":22,"0024785642596484307":22,"002726420685613274":22,"0029990627541746015":22,"003298969029592062":22,"0036288659325512686":22,"003991752525806396":22,"0043909277783870364":22,"004830020556225741":22,"005":[37,38],"005313022611848316":22,"005844324873033148":22,"006428757360336463":22,"00707163309637011":22,"007778796406007121":22,"008556676046607835":22,"009412343651268619":22,"010353578016395481":22,"011359662748873234":7,"01138893581803503":22,"012527829399838533":22,"013780612339822387":22,"015158673573804626":22,"01667454093118509":22,"017953205361364e":22,"0183419950243036":22,"019539741799235344":7,"020176194526733963":22,"02219381397940736":22,"02400691612424e":22,"0244131953773481":22,"02685451491508291":22,"029539966406591206":22,"03249396304725033":22,"03574335935197537":22,"03931769528717291":22,"043249464815890204":22,"04381":17,"047574411297479226":22,"052331852427227155":22,"0544702849929435e":22,"05756503766994987":22,"06332154143694486":22,"06965369558063936":22,"0766190651387033":22,"0834705943388392e":22,"08428097165257363":22,"091268053287076e":22,"092709068817831":22,"09574":22,"0th":24,"100":[8,24,29],"1000":[17,29],"10000":[3,31],"101":[16,17,18,28],"10197997569961412":22,"1113776745352607e":22,"11217797326957554":22,"1144777789251e":22,"115909044841462e":22,"123":[12,27],"1233957705965331":22,"13573534765618642":22,"1384283767210024e":22,"140274938683989e":22,"1435888100000012e":22,"14930888242180507":22,"152":[17,18],"160px":[12,27,34],"1642397706639856":22,"177248169415655e":22,"1801":17,"18066374773038418":22,"1902":22,"1918176537727232e":22,"19873012250342262":22,"1x1":17,"200":24,"2007":13,"2012":13,"2014":13,"2015":13,"2017":13,"2186031347537649":22,"21e":22,"224":[8,12,17,27,29],"240":17,"2404634482291414":22,"256":17,"25s":6,"260":17,"2645097930520556":22,"289048368510331e":22,"29096077235726114":22,"299":17,"300":[13,17,18,24],"3109994191499957e":22,"3200568495929873":22,"320px":[12,27,34],"322515441988787e":22,"3310000000000003e":22,"3333333333333333":26,"3520625345522861":22,"3579476910000015e":22,"380":17,"38726878800751474":22,"3x2":18,"3x3":17,"40024994425817e":22,"4003948586157844e":22,"4259956668082662":22,"4420993610649954e":22,"452271214393103e":22,"456":17,"4641000000000003e":22,"4685952334890929":22,"4763699237493086e":22,"5154547568380022":22,"52592555681761e":22,"528":17,"554766986187666e":22,"559917313492238e":22,"586309297171495e":22,"5937424601000017e":22,"594972986357221e":22,"600":17,"6105100000000006e":22,"626407607736664e":22,"640":[13,24],"701723378487253e":22,"727499949325609e":22,"7404343444773634e":22,"7449402268886447e":22,"7715610000000007e":22,"784":12,"7974983358324136e":22,"8102436848064327e":22,"819748525897502e":22,"849732675807628e":22,"853116706110002e":22,"9194342495775094e":22,"948717100000001e":22,"954302432552388e":22,"975":6,"978518112499371e":22,"9997":32,"abstract":[3,4,8,9,18,22,24,26,28,31],"boolean":[3,7,31,33],"break":[24,33],"byte":33,"case":[3,7,8,22,24,31],"class":[3,4,6,7,8,9,11,12,13,16,17,18,21,22,23,24,26,27,28,29,31,32,33,34,37,38],"default":[3,4,6,7,8,9,13,16,17,18,21,22,23,24,28,29,30,31,32,33,34],"enum":[4,12,22,27,34],"export":[1,2,3,10,22,23,25,31,33,35,38],"final":[3,6,17,22,24,29,31,35,37,38],"float":[3,4,6,7,8,9,11,13,17,21,22,24,29,30,31,32,33,38],"function":[3,7,8,9,13,16,17,18,21,22,23,24,26,27,28,31,32,33,34,37,38],"import":[22,37],"int":[1,3,4,6,7,8,9,11,12,13,17,18,21,22,24,26,27,29,30,31,32,33],"long":22,"new":[3,6,7,8,9,11,16,21,22,24,26,28,31,32,33],"null":9,"return":[1,3,4,6,7,8,9,11,13,16,17,18,21,22,23,24,26,27,28,29,30,31,32,33,34,37],"static":[3,6,7,8,9,11,16,17,22,24,26,28,31,32],"switch":[26,31],"true":[3,4,6,7,8,9,12,13,16,17,18,21,22,23,24,27,28,29,30,31,32,33,34,38],"try":[7,33],"var":[8,28,31],"while":[3,7,17,18,21,22,26,31,35,38],Axes:[6,9],For:[3,8,22,24,31,32,35,37,38],Its:22,Not:22,OPS:31,One:29,Ones:[29,30],The:[3,6,7,8,9,12,13,16,17,18,21,22,23,24,27,28,29,30,31,32,33,34,35,37,38],Then:36,There:32,Use:[3,9,22,31],Used:[21,30,31],Useful:[3,21,22,31],Uses:[28,31,32],Will:[7,8,13,18,24,33],With:37,__all__:[3,22,31,38],__loss__:22,__name__:9,_ax:[6,9],_block_shap:[3,22,31],_deepsparsebasemodelrunn:8,_dim:[3,22,31],_map_mask_to_tensor:[3,22,31],abc:[3,4,8,9,18,22,24,28,31],about:[9,18,24,33],abov:8,abs:[7,17,22],absolut:[3,8,22,31,33],accept:[3,9,21,22,31],access:[22,24],accord:[3,8,11,22,24,31],accordingli:7,account:24,accumul:24,accuraci:[22,24,32,35,38],achiev:[6,9],across:[6,9,21,22,24,32,33],act:[21,29,30],act_typ:21,activ:[1,3,7,9,10,22,23,24,29,30,31,32,35,38],adam:38,adapt:[24,32],add:[6,7,8,9,11,22,24,29,30,33,38],add_async:33,add_async_gener:33,add_item:33,add_measur:[6,9],add_model_result:[6,9],add_modifi:[3,22,31],add_ops_cr:31,add_param_group:22,add_quant_dequ:23,add_reduce_to_node_output:7,add_result:[6,9],added:[3,7,17,22,24,31,32,33],addit:[3,4,6,7,8,17,18,21,22,24,26,28,31,33,36],addition:[8,12,22,24,31,35,37,38],addtion:18,adjust:[6,22,24],adjust_current_step:22,affect:[6,9,24],after:[3,6,8,9,17,22,24,27,29,30,31,32,33,37,38],after_optim:[3,31],after_run:31,afterward:[17,18,21],again:3,against:[6,9,22,24,31,32],aggreg:[24,31],aggress:33,aka:[22,31],algorithm:[35,37],alia:[8,23,24,27,31],all:[1,3,4,6,7,8,9,12,13,16,17,18,21,22,23,24,26,27,28,30,31,32,33,34,35,37,38],all_token:[3,22,31],allow:[3,6,8,9,11,22,24,31,32,35],along:[1,3,6,13,22,24,31,33],alongsid:[3,9,22,31],alpha:22,alreadi:[8,13,22,28,34,38],also:[3,6,8,9,17,18,22,24,26,31,33,37,38],altern:35,although:[17,18,21],altogeth:22,alwai:22,among:24,amount:[3,8,17,22,24,31],amp:24,analys:24,analysi:[6,8,9,22,31],analyz:[0,1,6,22,31],analyze_lay:22,analyze_model:8,analyze_modul:31,analyzedlayerdesc:[9,22],analyzer_a:[1,10],analyzer_model:[1,5],analyzer_modul:[1,10,25],analyzer_prun:[1,10],ancestor:8,anchor:[18,24],anchor_group:[18,24],anchors_group:24,ani:[3,4,6,8,9,11,13,16,17,18,22,24,26,28,30,31,32,33,35,36,37,38],annot:[13,24,33],annotatedimagetransform:13,anoth:[3,31],any_str_or_regex_matches_param_nam:24,any_str_or_regex_matches_tensor_nam:32,anyth:[22,37,38],apart:[24,33],api:[8,26,35,37,38],appear:23,append:[24,33],appli:[3,6,7,8,9,11,12,13,17,21,22,24,26,27,28,29,30,31,32,33,35,37,38],applic:6,applied_learning_r:22,applied_spars:22,apply_op_vars_mask:31,apply_shape_change_mult:6,apply_softmax:28,approach:35,appropri:[22,28,33],approx_ks_loss_sensit:31,approxim:[6,21,22,31],architectur:[16,17,18,28,29],area:33,arg:[3,8,9,11,16,22,26,28,31,32],arg_scop:32,arg_scope_var:32,argument:[3,9,16,17,18,22,24,28,31,37,38],around:[3,24,35],arrai:[4,7,8,24,32,33],art:35,artifici:22,arxiv:[17,22],as_classifi:17,as_default:37,as_ltrb:24,as_xywh:24,as_yolo_backbon:17,ascend:33,asd932:12,asd932_:27,ask:24,aslayertrack:22,aspect:[3,22,24,26,31],aspect_ratio:24,asregmodifi:22,asresulttyp:22,assign:[3,31],associ:[8,24,32],assum:[3,8,24,33],assumpt:24,asymmetr:[23,38],async:33,attach:[8,28],attempt:32,attibut:8,attr:8,attribut:[3,4,6,8,9,11,22,26,31,33],augment:7,augmented_model_path:7,automat:[3,38],automl:37,aux:[17,24],aux_pr:24,aux_weight:24,auxiliari:24,avail:[3,6,8,16,24,28,31,37,38],available_kei:[16,28],available_loss:24,averag:[6,9,24,32],avg:30,avoid:[8,32],awai:[26,31],awar:[22,23,38],axes:[6,9],axi:7,back:[8,33],backbon:[17,18],backbone_early_output_idx:18,backbone_out_channel:18,backend:[7,24],backward:[22,24],ball:[8,33],bar:[6,7,8],base:[3,4,6,7,8,9,11,12,13,16,17,18,21,22,23,24,26,27,28,29,31,32,33,34,35],base_name_scop:28,baselin:[6,9,35],baseline_a:22,baseline_averag:[6,9],baseline_loss:22,baseline_measurement_index:[6,9],baseline_measurement_kei:[6,9],basemanag:[3,9,22,31],basemodifi:[3,9,22,31],baseobject:9,baseprop:[3,9,22,31],baseschedul:[3,9,22,31],baseupd:[3,9,22,31],basic:[9,17,29],basic_session_run_hook:28,batch:[3,4,6,7,8,9,13,17,22,24,26,27,29,30,31,32,33,37],batch_cross_entropy_loss:32,batch_forward:[8,24],batch_norm:32,batch_norm_decai:32,batch_norm_epsilon:32,batch_norm_updates_collect:32,batch_siz:[6,8,9,22,24,26,32,37],batchbenchmarkresult:24,batcher:33,batchnorm2d:23,batchnorm:[8,29],batchnormparam:8,becaus:8,been:[3,8,22,24,28,30,31,32],befor:[3,4,6,8,17,22,24,27,30,31,37,38],begin:[4,22,31,33],begin_step:31,behav:22,behavior:[4,8,22],being:[3,9,21,22,24,30,31,32],belong:[16,28,31],below:[3,8,24,38],benchmark:[1,6,8,10],best:22,beta:[29,30],beta_initi:[29,30],better:[1,22],between:[3,6,8,9,11,21,22,23,24,26,31,33,38],bia:[6,8,22,29,30],bias_initi:[29,30],bias_nam:6,bias_shap:[6,8],bin:24,binari:24,binary_cross_entropy_with_logit:24,binarycrossentropylosswrapp:24,bit:[7,37],blob:8,block:[3,7,8,17,22,23,29,31,38],block_shap:[3,22,31],blockpruningmaskcr:[3,22,31],blog:[35,38],bn_node:8,bool:[3,4,6,7,8,9,11,12,13,16,17,18,21,22,23,24,27,28,29,30,31,32,33,34],boost:22,boosted_a:22,boosted_loss:22,booster:22,both:[21,22,38],bottleneck:[17,29],bottom:33,boudn:24,bound:[13,24],bounding_box_and_labels_to_yolo_fmt:13,box:[13,24],box_giou:24,boxes_a:24,boxes_b:24,break_batch:[24,33],broadcast:21,bucket:[24,33],bucket_count:24,bucket_iter:33,bucket_limit:24,buffer:[21,26],bug:35,build:[3,6,22,26,35],build_input_fn:26,build_target:24,built:[3,4,8,26,27,30,35,37],builtin:22,cach:[11,12,13,22,24,27],cacheabl:11,cacheabledataset:11,calcul:[3,6,8,9,17,22,24,31,33],calculate_flop:8,calculate_map:24,calibr:[5,6],calibrate_op_typ:7,calibrationsess:7,call:[3,4,6,9,16,17,18,21,22,24,26,31,32,37],callabl:[3,8,9,16,22,24,26,28,31,32,33],callback:[1,2,3,24,31,37],caller:32,came:24,can:[1,3,6,7,8,9,11,12,13,17,18,21,22,23,24,27,29,30,31,32,33,34,35,37,38],cannot:[3,9,22,31,38],canon:8,canonical_nam:8,cap:33,capabl:3,card:33,care:[17,18,21],cat:12,cent_crop:27,center:[24,26],center_i:24,center_square_crop:[26,27],center_x:24,certain:[3,8,9,22,31,38],chain:13,chan:21,chang:[3,4,6,8,9,16,22,24,31],channel:[3,7,17,18,21,22,24,29,30,31],channel_wis:21,channels_first:30,channels_last:30,chart:[6,9],chauhan:24,check:[3,7,8,9,17,18,21,22,23,24,31,32,33,37],check_feat_lab_inp:24,check_load_model:8,check_lr:22,check_numb:33,check_opset_vers:7,checkpoint:32,checkpoint_path:32,child:8,choos:[8,22,24,38],chosen:22,cifar100:12,cifar100dataset:[12,27],cifar10:[12,29],cifar10dataset:[12,27],cifar:[10,11,25,26],cifardataset:27,class_i:27,class_nam:3,class_typ:[17,29],class_x:27,classif:[10,11,16,19,24,25,26,28,32,34],classifi:[17,18,29],classificationestimatormodelfn:28,classmethod:3,clazz:9,clean:[31,32,33,37],clean_path:33,clean_tensor_nam:32,clear:[22,24],cli:35,client:[28,31,32],clone:36,close:[3,31],closest:[6,9],closur:[22,24],cnn:18,coco:[10,11,18,24],coco_2017_yolo:13,cocodetectiondataset:13,code:[2,3,4,5,6,8,9,10,11,16,22,24,25,26,28,31,32,33,35,37,38],coeffici:[24,32],collat:13,collect:[3,9,22,24,28,31,32,33],collection_nam:31,column:24,com:[8,12,24,27,33,38],combin:[8,9,22,24,31],combo:24,common:[21,22,33],commonli:38,commun:35,compar:[3,6,8,9,22,24,31,32,37],compare_index:[6,9],comparison:[6,9,24],compat:[16,22,28],compil:[24,37],complet:[6,8,22,24,31,37],complete_graph:[31,37],compress:[21,33],comput:[3,7,9,12,13,15,17,18,21,24,27,29,31,32,34],compute_output_shap:3,condit:[24,31],confid:24,confidence_threshold:24,config:[3,9,22,23,37],configur:[17,18,24,29,33,37,38],connect:[3,29,30],consid:[6,24],consist:[1,33],consol:22,constant:[3,22,31,32],constant_log:22,constantli:22,constantpruningmodifi:[3,22,31,35],construct:[8,22,24],constructor:[3,9,16,21,22,28,29,31],contain:[3,4,6,8,9,17,21,22,24,26,27,28,31,32,33,35,37,38],content:[0,35],context:[22,24],continu:[3,8,22,24,31,33],contract:[3,31],contradict:24,contradict_hinton:24,control:[3,8,9,22,24,31,38],conv0:38,conv1:[22,31,37,38],conv1d:32,conv2:[37,38],conv2d:[23,30,31,32],conv2d_1:3,conv2d_5:3,conv2d_block:30,conv3:[37,38],conv3d:32,conv:[6,7,8,17,18,22,23,24,29,30,31,32,38],conv__224:7,conv__252:7,conv_net:[22,31],conv_node_param:8,conveni:[3,8,22,24,31,32,37,38],convers:[8,23,37],convert:[3,8,9,23,24,31,33,37,38],convert_kera:4,convert_model_initializers_to_spars:8,convert_relus_to_fat:21,convert_sparse_initializers_to_dens:8,convert_to_bool:33,convinteg:7,convnd:24,convolut:[8,17,18,22,29,30,32],coordin:[18,24],copi:[21,23,24],core:[6,8,9],correct:[8,9,22,24],correct_nm_analyze_model_node_id:8,corrected_lr_info:9,correctli:[4,31,35],correspond:[4,22,24,33],cosineannealingwarmrestart:[9,22],cost:22,could:[4,8,9],couldn:32,count:[22,24,33],counter:[4,24,33],cpu:[6,9,11,22,24,35],creat:[1,2,3,4,5,6,7,8,9,10,11,12,13,16,17,18,21,22,24,25,26,27,28,29,30,31,32,33,35,37,38],create_activ:21,create_dir:33,create_estim:28,create_extra:31,create_graph_ops_prun:31,create_ks_schedule_op:31,create_ks_scheduled_constant_graph_op:31,create_label:8,create_loss:28,create_metr:28,create_metric_update_ops_hook:28,create_modifier_ops_and_update_hook:28,create_op:[3,31,37],create_op_prun:31,create_parent_dir:33,create_predict:28,create_scaffold:28,create_sect:17,create_sparse_tensor:8,create_sparsity_mask:[3,22,31],create_sparsity_mask_from_abs_threshold:22,create_sparsity_mask_from_tensor:22,create_split_iterators_handl:26,create_summaries_prun:31,create_summary_op:28,create_train_summary_hook:28,create_training_op:28,create_unique_dir:33,create_zoo_model:[16,28],creation:[3,31,37,38],creator:[3,22,26,27,28,31],crop:[13,24,26],cross:[24,32],cross_entropi:24,crossentropyloss:22,crossentropylosswrapp:24,csv:9,cubic:[3,22,31,33],cuda:[22,24],cudnn:24,cumul:24,current:[3,4,6,7,8,9,16,21,22,24,26,28,29,30,31,32,33,37,38],curv:33,custom:[21,32,38],custom_op_handl:32,cutoff:22,cwd:[4,24],cycl:[22,31],darknet53:17,darknet:[10,16,18],darknetsectionset:17,data:[1,5,6,7,11,12,13,22,24,26,27,28,33],data_format:30,data_load:[7,8,24],data_loader_kwarg:22,data_shap:8,data_typ:8,dataload:[6,7,8,13,22,24],dataparallel:24,datapararallel:24,dataset:[1,10,16,17,18,22,24,25,28,29,33,35],dataset_op:26,dataset_s:[12,27,34],datasetregistri:[11,26],datasetv1:26,ddp:24,deal:31,debian:36,debug:4,debug_mod:4,decai:[22,31,32,38],decay_r:[3,31],decay_step:[3,31],decim:[8,22,38],decod:24,decode_output_batch:24,deconstruct_tensor:24,decor:[3,9,11,16,22,24,26,28,31,33],decreas:[22,31],deep:35,deepspars:[6,8,24,33,35,37],deepsparseanalyzemodelrunn:8,deepsparsemodelrunn:8,def_ignore_error_tensor:16,def_model_backward:24,default_box:13,default_context:24,default_dataset:[16,28],default_dataset_path:34,default_desc:[16,28],default_devic:24,default_exponential_check_lr:22,default_image_s:32,default_loss_kei:24,default_model_fn_cr:28,default_onnx_opset:32,default_pruning_sparsities_loss:9,default_pruning_sparsities_perf:9,default_qat_qconfig:23,defaultbox:[13,24],defin:[3,4,6,8,17,18,21,22,24,28,31,32,38],definit:37,delet:8,dens:[8,30],dense_block:30,densiti:[8,24,32],depend:[22,32,36,38],deploi:35,deploy:37,depth:[17,33,37],depthwis:[17,18,29,30,32],depthwise_conv2d_block:30,dequantize_nod:8,dequantizelinear:23,deriv:[3,4,6,22,31],desc:[8,9],desc_arg:16,descend:[21,33],descent:38,describ:[9,17,29],descript:[9,16,22,28,31,33],deseri:3,design:[33,37,38],desir:[8,16,22,23,24,26,28,30,31,32,34,37,38],destin:4,detail:6,detect:[8,10,11,16,17,24,28],detector:[18,24],determin:[8,22,32,33],determinist:24,dev:35,deviat:[3,11,22,24,31,32],devic:[4,22,24,32],device_context:24,device_to_name_id:24,dict:[3,6,7,8,9,11,16,17,18,21,22,24,26,27,28,31,32,33],dictionari:[3,4,6,7,8,9,21,22,24,26,28,31,32,33,38],did:[8,22],differ:[6,9,22,23,24,28,31,32,38],dim:[3,22,24,31],dimens:[3,8,9,21,22,24,31,32,33],dimensionpruningmaskcr:[3,31],dimensionsparsitymaskcr:22,dir:[4,24],direct:[8,35],directli:22,directori:[4,7,24,28,32,33],disabl:[22,24,38],disable_bn_fus:24,disable_quantization_observer_epoch:22,disclaim:8,disk:[11,12,33],displai:[6,7,8,9],distanc:8,distil:24,distribut:[6,9,11,12,13,24,27],distributeddataparallel:24,diverg:8,divid:[3,22,31,32],divis:32,doc:[3,4,8,9,22,31,33,35],doc_str:4,document:[35,37],doe:[3,6,7,8,12,13,22,23,24,27,31,32,33,34,38],doesn:[3,11,22,31,33],dog:12,doing:[3,9,22,24,31],domain:[16,28],domainadapt:24,done:[3,24,37,38],doubl:17,down:[17,21,29],download:[12,13,27,33,34,35,37],download_root:34,downsampl:[17,29],downsample_out_channel:17,driven:35,drop:24,dropout:[17,30,32],dropout_r:30,dtype:[3,8,31,32],due:8,dure:[4,7,22,24,28,31,38],dynam:[7,8,21],dynamicquantizelinear:7,e2e_batch_second:24,e2e_batch_tim:24,e2e_batches_per_second:24,e2e_item_second:24,e2e_items_per_second:24,e2e_sec:24,each:[3,4,6,7,8,9,13,17,18,22,24,27,29,31,33,37,38],earli:[11,24],earlier:[17,24],early_stop:11,early_stop_data_load:24,early_stop_step:24,earlystopdataset:11,eas:37,easi:37,easiest:38,easili:[3,9,11,16,22,26,28,31,35,38],edg:[8,33],edge_perc:33,edit:[2,5,8,10,25,31,35,37],editor:32,effect:[3,4,9,22,31,35],efficientnet:[10,16],efficientnet_b0:17,efficientnet_b1:17,efficientnet_b2:17,efficientnet_b3:17,efficientnet_b4:17,efficientnet_b5:17,efficientnet_b6:17,efficientnet_b7:17,efficientnetsectionset:17,either:[3,6,8,23,24,30,32,33,38],element:[3,24,31,33],els:[3,8,9,21,24,30,31,33],empti:[9,21,22,31],emul:[22,38],enabl:[3,9,17,22,23,24,31,35,37,38],enable_aux:17,encapsul:31,enclos:3,encod:[13,24,35,37,38],encode_annotation_bounding_box:13,encode_image_box_label:24,encompass:35,end:[3,4,9,17,22,24,29,31,32,38],end_compar:[3,9,22,31],end_epoch:[3,9,22,31,37,38],end_pend:22,end_point:32,end_step:31,enforc:[3,8,9,21,22,24,31,38],engin:[3,4,6,8,24,35,37],enhanc:3,ensur:7,entir:[3,18,22,31],entri:22,entropi:[8,24,32],enumer:38,environ:36,epoch:[3,4,9,22,24,31,35,37],epoch_end:22,epoch_start:22,epochrangemodifi:[3,22,31,37,38],epsilon:8,equal:[3,8,9,21,22,31,32,33],equat:7,equival:24,err:[3,22,31],error:[3,16,17,18,31,33],error_desc:33,estim:[1,25,26,31,35],estimatormodelfn:28,etc:[6,9,16,17,18,22,24,28,30,31,33],eval:[22,31],eval_tensor_dens:32,eval_tensor_spars:32,evalu:[4,8,22,24,28,32],even:32,evenli:[3,22,24,31],event:[8,22,31,33],everi:[6,11,17,18,21,22,24,31,37,38],everyth:[24,35],exactli:[3,21,22,31],exampl:[3,7,8,22,31,32,35,37,38],exce:[3,22,31],except:[7,13,22,24,32],excit:[17,21],exclud:7,exclude_nod:7,execut:[8,9,22,24,31,32],execution_ord:9,exist:[22,24,32,33,34],exp:21,exp_channel:[17,29],exp_count:[4,24],exp_ratio:[17,29],expand:[17,21,29,33],expanded_channel:21,expans:[17,29],expansion_ratio:17,expect:[3,6,8,9,17,18,22,24,26,29,31],explor:[36,37],expon:[3,31],exponenti:[21,22,31],exponential_lr_schedul:31,exponentialdecai:[3,31],exponentiallr:[3,9,22,31,38],export_checkpoint:32,export_dir:[24,33],export_h5:4,export_kera:4,export_named_sampl:32,export_onnx:[4,24,32,37],export_pb:[32,37],export_pytorch:24,export_sampl:[4,24,32],expos:8,ext:27,extend:9,extens:33,extern:[1,10,16],extra:[3,4,6,9,13,21,22,24,28,31,32,37],extra_opset:32,extra_repr:21,extract:[7,8,18,22,24,33,34],extract_node_id:8,extract_node_shap:8,extract_nodes_shapes_ort:8,extract_nodes_shapes_shape_infer:8,extract_shap:8,extracted_root:34,extractor:[17,18],extrat:18,extrem:[6,9],factor:24,fake:23,fall:33,fals:[3,6,7,8,9,12,13,16,17,18,21,22,23,24,27,28,29,30,31,32,33,34],far:24,fast:18,fastai:[12,27],faster:[22,31,35],fat:21,fat_exp_relu:21,fat_pw_relu:21,fat_relu:21,fat_sig_relu:21,fatrelu:[1,10,22],featur:[17,18,24,26,32,35,37],feature_map:24,fed:24,feed:[4,24,26,31,32],feed_dict_cr:31,few:[32,35,37],fft:35,field:[3,8,12,13,14,15,17,18,21,23,24,27,29,31,34],figur:[6,9,22,32],file:[1,3,4,6,7,8,9,16,18,22,23,24,27,28,31,32,33,34,37,38],file_path:[3,9,22,27,31,33],filepath:7,filewrit:32,fill:37,filter:[3,22,31],final_lr:22,final_spars:[3,22,31,37,38],final_v:22,find:[8,12,13,24,27,32],find_weight_data:7,fine:[8,22,38],first:[6,8,9,18,22,24,32,33,37],fit:37,fit_gener:37,fix:24,fix_data_parallel:24,flatten:[12,33],flatten_iter:33,flexibl:37,flip:13,float16:24,float32:[7,24,37],float64:32,flop:[6,8,9,22],flow:[8,31,35],fold:8,fold_conv_bn:8,foldabl:8,foldable_nod:8,folder:[12,13,27],follow:[3,7,8,12,22,24,31,32,33,37,38],footprint:22,forc:[7,21],force_fus:7,form:[12,27,33],format:[1,3,4,6,7,9,13,22,24,31,32,33,35,37,38],format_iterator_batch:[26,27],format_repr:9,format_str:9,former:[17,18,21],formula:[3,22,31],forward:[3,17,18,21,22,23,24,31],found:[3,6,8,9,12,13,16,17,18,21,22,23,24,27,29,31,32,34,35,37],fp32:8,fraction:[3,9,22,24,31,32,38],framework:[0,1,2,3,4,5,6,9,10,18,22,24,25,26,27,28,29,30,31,32,37,38],free:3,freez:24,freeze_bn_stats_epoch:22,frequenc:[3,4,22,31],from:[1,3,4,6,7,8,9,11,12,13,16,17,18,21,22,23,24,26,27,28,29,30,31,32,33,35,37,38],from_config:3,from_dict:[6,9],from_model_random:8,from_random:8,from_sparse_model:22,from_train:32,from_yaml:[3,22,31,37],front:[33,37,38],frozen:[22,38],full:[3,7,9,12,22,24,27,31,32,34,35],full_precis:24,fulli:[29,30,38],func:[6,9,12,22,27,31],func_get:[3,9,22,31],func_set:[3,9,22,31],further:[17,29],fuse:[7,22,23,24],fuse_dynamic_qu:7,fuse_modul:22,fuse_module_conv_bn_relu:[22,23],fusion:[7,23],futur:8,gama:29,gamma:[22,30,31,37,38],gamma_initi:[29,30],gan:32,gather:[9,21],gemm:[6,7,8],gemm_node_param:8,gen:33,gener:[1,4,6,7,8,9,10,18,21,22,24,26,31,32,33,34,35,37,38],generate_augmented_model:7,get:[3,6,8,9,22,24,26,28,31,32,33,34,38],get_anchor_grid:24,get_attr_float_val_for_nod:8,get_available_provid:8,get_batch_norm_param:8,get_config:3,get_conv_lay:24,get_default_boxes_300:24,get_default_graph:[31,32],get_default_sess:32,get_feature_extractor:18,get_gan_network_fn:32,get_grid:24,get_group:31,get_grouping_op:[3,31],get_init_by_nam:8,get_input:24,get_kernel_shap:8,get_label:24,get_lay:24,get_layer_name_from_param:3,get_layer_param:24,get_linear_lay:24,get_main_logg:1,get_mask_initi:[3,31],get_model_input_nam:7,get_model_scop:32,get_named_layers_and_params_by_regex:24,get_network_fn:32,get_nm_root_logg:1,get_nod:6,get_node_attribut:8,get_node_by_id:8,get_node_input:8,get_node_input_nod:8,get_node_output:8,get_node_output_nod:8,get_node_param:8,get_nodes_by_input_id:8,get_nodes_by_output_id:8,get_numpy_dtyp:8,get_op_input_var:32,get_op_var_index:32,get_ops_and_inputs_by_name_or_regex:32,get_optim_learning_r:24,get_or_create_global_step:31,get_or_create_graph_ops_prun:31,get_or_create_ks_schedule_op:31,get_or_create_ks_scheduled_graph_op:31,get_output_grid_shap:24,get_pr:24,get_prunable_lay:24,get_prunable_nod:8,get_prunable_node_from_fold:8,get_prunable_op:32,get_qat_qconfig:23,get_quantization_param:23,get_quantization_params_dict:7,get_quantize_parent_for_dequantize_nod:8,get_recall_level:24,get_result:[6,9],get_tensor_var:32,get_terminal_lay:24,get_threshold:21,getter:[3,9,22,31],giou:24,github:[8,12,24,27,35],give:[8,16,18,22,24,27,28,30,35,38],given:[3,4,6,7,8,9,11,13,16,17,18,21,22,23,24,26,27,28,29,30,31,32,33,38],glob:[8,33],global:[4,22,24,31,32],global_avg:30,global_step:[3,31],global_variables_initi:[31,37],glorotuniform:[29,30],gmp:38,gmpruningmodifi:[3,22,31,37],goe:[22,24,31],gpu:[24,35],grab:[8,22,24,32],grad:22,grad_scal:24,gradient:[22,24,38],gradscal:24,gradual:[3,22,31,37,38],gradualparammodifi:22,grain:38,granular:8,graph:[3,6,7,8,22,23,24,26,27,28,29,30,31,32,37],graph_editor:[1,5],graph_optim:[1,5],graphexport:[32,37],graphkei:32,greater:[3,9,22,24,31],grid:24,grid_shap:24,ground:[24,28],ground_truth_annot:24,group:[3,8,9,17,22,24,30,31,33],group_idx:24,group_tensor:[3,22,31],groupedpruningmaskcr:[3,22,31],grouping_fn_nam:22,grouping_op_nam:[3,31],grouplearningratemodifi:31,guarante:[8,22],guid:[24,32],hack:22,had:24,half:[24,29,38],han_mobilenet:17,hand:[37,38],handl:[1,3,4,6,8,9,11,12,22,24,26,27,31,33,37,38],handler:32,happen:[4,22],hard:[24,38],hard_swish:21,hardcod:8,hardswish:21,has:[3,6,7,8,9,11,22,31,32,38],has_baselin:[6,9],have:[3,8,11,16,19,22,23,24,28,30,31,32,38],hdf5:4,head:18,height:[24,26,32],help:[1,4,24,35],helper:[0,1,4,5,6,10,11,22,25],here:[3,12,13,17,18,21,22,27,29,34,37],hidden:17,hidden_channel:17,higher:31,highest:33,hinton:24,his:37,histogram:24,hold:[3,22,31],hook:[17,18,21,22,24,28,31],horizont:13,host:35,how:[3,6,8,9,17,22,24,29,31,35],howev:[3,22,37,38],http:[8,12,17,22,24,27,33,38],human:[6,9],hyper:24,id_:[6,9],id_or_nam:[6,9],ident:[7,8],identif:[4,24],identifi:[4,6,9,24,31],ides:24,ids:[8,24],ignor:[16,17,18,21,24,28,31,33],ignore_error_tensor:[16,17,18,24],iin:8,imag:[12,13,17,24,26,27,29,32,34],image_s:[12,13,24,26,27],imagefold:[10,11,25,26],imagefolderdataset:[12,27],imagenet:[1,10,11,17,18,19,25,26,28,33],imagenet_norm:27,imagenetdataset:[12,27],imagenett:[1,10,11,25,26,33],imagenettedataset:[12,27],imagenettedownload:[12,27,34],imagenettes:[12,27,34],imagewoof:[12,27,34],imagewoofdataset:[12,27],imagewoofdownload:[12,27,34],imagewoofs:[12,27],img:[6,9,27],immedi:[3,9,22,31],impl:26,implement:[3,4,6,8,9,12,13,17,18,21,22,23,24,26,27,29,31,33,34,35,37,38],impos:[8,22,31],imposed_k:8,improv:[22,35],in_chan:30,in_channel:17,incept:[17,24],inception_v3:[10,16],inceptioncrossentropylosswrapp:24,inceptionv3:17,inclin:38,includ:[3,6,8,22,23,24,30,31,33,35,38],include_bia:30,include_bn:30,include_modifi:24,include_nod:7,include_target:23,include_valu:8,inclus:24,incom:24,increas:[3,9,21,22,31,33,38],indefinit:[26,33],independ:22,index:[3,4,6,9,11,18,22,24,28,31,32,33,38],indic:[3,17,22,24,30,31,32],individu:[6,8,9,22,31],induc:[3,22,31,35],infer:[6,8,24,29,37],inferencesess:8,infinit:8,infinite_data_load:24,info:[1,4,6,8,9,12,13,17,22,24,27,29,33,34],inform:[3,4,6,8,9,18,21,22,24,35,37],inherit:[3,9,22,31],init:22,init_lr:[3,9,22,31,37,38],init_nam:8,init_op:[29,30],init_sect:[17,29],init_spars:[3,22,31,37,38],init_v:22,initi:[3,7,8,9,17,21,22,23,29,30,31,32,38],initial_learning_r:[3,31],initialize_logg:22,initialize_sess:31,inject:31,inp:[17,18,21,22],inp_dict:32,inp_tensor:32,inp_val:32,inplac:[8,21,23],input1:8,input2:8,input:[3,4,6,7,8,9,12,13,16,17,18,21,22,23,24,26,27,28,29,30,31,32,33,37],input_batch:7,input_fn:26,input_func:22,input_id:8,input_nam:[6,7,37],input_op:31,input_qtyp:7,input_shap:[3,6,8,9,16,24,28],input_tensor:3,inputs_sampl:22,inputs_sample_max:22,inputs_sample_mean:22,inputs_sample_min:22,inputs_sample_s:22,inputs_sample_std:22,inputs_spars:22,inputs_sparsity_max:22,inputs_sparsity_mean:22,inputs_sparsity_min:22,inputs_sparsity_std:22,insid:[37,38],instal:[19,35],instanc:[3,4,6,8,9,17,18,21,22,24,26,28,31,32,33],instanti:[3,11,16,26],instead:[3,7,8,9,17,18,21,22,24,31,32,38],instruct:[37,38],int8:[7,38],integ:[3,4,7,8,9,22,31,32,33],integerop:7,integr:[6,9,19,31,33,35,36,37],intend:37,intens:11,inter_func:[3,22,31,33],interact:24,interfac:33,intermedi:[7,8,32],intern:28,interpol:[3,21,22,31,33],interpolate_list_linear:33,interpolated_integr:33,intersect:24,interv:[22,31,38],intial:7,intput:32,intro:35,introduc:[6,8,9,22],invers:24,inverse_cub:[3,22,31,33],invert:[17,29],invoc:[26,31],invok:37,invoke_batch_backward:24,invoke_batch_end:24,invoke_batch_forward:24,invoke_batch_loss:24,invoke_batch_start:24,iou:24,iou_step:24,iou_threshold:24,irregular:22,is_activ:21,is_after_end_step:31,is_foldable_nod:8,is_parallel_model:24,is_prunable_nod:8,is_prunable_op:32,is_pruning_step:3,is_train:32,is_url:33,issu:[17,18],item:[8,11,13,22,24,33],iter:[3,6,7,8,11,22,24,26,27,31,33],iter_batch:[26,27],iter_step:8,iterations_per_check:6,iters_sleep_tim:6,its:[3,4,7,8,9,13,21,22,24,31,32,33,37,38],itself:22,jekyllrb:33,join:37,json:[6,9],just:[13,24],kd_set:24,kdlosswrapp:24,kdset:24,keep:[3,6,8,9,22,24,28,31,33,36],keep_param:8,keepdim:22,kei:[3,6,8,9,11,16,19,21,22,24,26,28,31,33],kept:38,kera:[0,1,35],keras2onnx:37,keraslogg:[3,4],kerasmodifieryaml:3,kernel:[3,6,8,9,17,22,29,30,31],kernel_initi:[29,30],kernel_s:[17,30],kernel_shap:8,keyword:[3,9,16,22,28,31],kl_diverg:[6,8],knowledg:24,known:22,ks_group:31,ks_layer_desc:22,ks_loss_sensitivity_op_var:31,kslosssensitivityanalysi:[6,9],kslosssensitivityresult:[6,9],ksperfsensitivityanalysi:[6,9],kssensitivityprogress:6,kwarg:[3,4,6,8,9,11,16,21,22,26,28,31],lab:24,label:[4,8,13,24,26,27,28,32,33],label_shap:8,labeled_data:8,larg:[22,35],larger:[22,24,31,38],last:[17,21,22,32],later:[3,9,22,31],latter:[17,18,21],layer1:22,layer2:22,layer:[1,3,4,6,8,9,17,18,21,22,23,24,25,29,31,32,38],layer_desc:22,layer_nam:[3,21,22,24],layer_norm:22,layerboostresult:22,layerwis:8,lead:31,learn:[3,9,22,24,28,31,37],learning_r:[0,1,3,22,31,38],learningr:[3,9,22,31],learningratemodifi:[3,22,31,37],least:[22,28],leav:[13,22],leave_en:[3,22,31,38],left:[24,30],len:37,length:[11,24],less:[3,9,22,31,38],lesser:38,lev:22,level:[1,3,6,8,9,11,17,22,24,31,35,38],librari:[35,37],life:31,lifecycl:[22,24],lifetim:4,like:[3,6,9,21,22,24,31,32,36,37,38],limit:[8,22,35,38],line:[9,21,31,35,37],linear:[3,6,7,22,23,24,31,33],linearli:[7,33],linux:36,list:[3,4,6,7,8,9,11,13,16,17,18,21,22,24,26,28,29,31,32,33,37,38],lite:18,littl:37,load:[3,6,7,8,9,11,16,17,18,22,24,26,27,28,31,32,33],load_desc:9,load_epoch:24,load_framework_list:9,load_framework_obj:9,load_json:[6,9],load_labeled_data:33,load_list:[3,22,31],load_manag:22,load_manager_state_dict:22,load_mask_cr:[3,22,31],load_model:24,load_numpi:33,load_obj:[3,22,31],load_optim:24,load_pretrain:28,load_recipe_yaml_str:33,load_state_dict:[21,22],load_strict:[16,17,18],loader:[8,11,13,24],local:[3,4,12,22,24,27,31,32,33,34],local_rank:24,locat:[22,24,27,37],log:[0,3,4,6,22,24,31,33,35],log_dir:4,log_histogram:24,log_histogram_raw:24,log_hyperparam:24,log_nam:24,log_path:24,log_scalar:[4,24],log_step:24,log_summari:24,log_typ:[3,9,22,31],log_upd:22,logger:[1,2,3,9,10,22,31,33],loggers_initi:22,loggersettingcallback:4,loggingmod:4,logic:[3,33],logit:[17,24,29,32,37],longer:22,look:[24,33,37,38],lookup:31,loop:22,loss:[1,4,5,6,9,10,13,22,25,28,31,38],loss_fn:[22,24],loss_kei:22,loss_measur:9,loss_tensor:31,loss_upd:22,lossesandmetricsloggingcallback:4,losswrapp:[22,24],lower:[8,22],lowest:[8,22,31,33],lr_class:[3,9,22,31,37,38],lr_kwarg:[3,9,22,31,37,38],lr_loss_sensit:22,lr_modifi:31,lr_mult:22,lrelu:21,lrlosssensitivityanalysi:[9,22],lrs:22,ltrb:[13,24],made:[3,8,22,24,31],magic:[2,5,6,8,10,25,35],magnitud:[3,8,22,31,37,38],mai:[17,18,22,24,38],main:1,make:[3,9,16,22,24,31,37],make_one_shot_iter:26,manag:[0,1,2,10,24,25,28,37],manager_state_dict:22,mani:22,manual:[22,24],map:[7,8,9,21,22,24,26,31,33],map_loc:[22,24],mark:[3,9,22,31,38],markdown:[33,37,38],mask:[3,22,24,31],mask_creat:[3,22,31],mask_creator_prun:[1,10,25],mask_differ:24,mask_prun:[1,2,10,25],mask_pruning_cr:[1,2],mask_typ:[3,22,31,37,38],mask_updat:3,masked_lay:3,maskedlay:3,master:8,match:[3,6,7,8,9,11,18,21,22,24,31,32,33,38],matmul:[7,8,31,32],matmul_node_param:8,matmulinteg:7,matplotlib:[6,9],matter:[33,37,38],max:[3,7,22,24,26,30,31,33],max_available_cor:8,max_bin:24,max_detect:24,max_epoch:9,max_node_dist:8,max_source_s:33,max_step:8,max_target_metric_loss:22,max_val:[21,24],maxim:6,maximum:[6,7,8,24,33],mdoel:8,mean:[3,6,8,9,11,12,22,24,27,31],meanaverageprecis:24,meant:[9,33],measur:[6,8,9,22,24,31,33],memori:[8,11,21,22,24,26,33],merg:[9,33],merge_desc:9,meta_canonical_nam:8,metaclass:33,metadata:6,method:[3,8,9,21,22,24,31,37],metric:[4,22,24,28,35],metric_increas:22,metric_kei:22,metrics_dict:28,metrics_initializers_dict:28,metricupdateopshook:28,microsoft:8,middl:38,might:3,mileston:[22,31,37,38],milestone_step:31,min:[3,22,24,26,31,33],min_end:[3,9,22,31],min_epoch:9,min_frequ:[3,9,22,31],min_start:[3,9,22,31],min_val:[21,24],min_valu:8,mine:24,minim:[6,28],minimum:[3,7,8,9,22,24,31,33],miss:[3,21,22,31],missing_kei:21,mix:24,mnist:[10,11,16,18,25,28,37],mnist_net:[17,29,37,38],mnistdataset:12,mnistnet:17,mobilenet:[10,16,18,25,28,32],mobilenet_const:29,mobilenet_v1_arg_scop:32,mobilenet_v2:[10,16,19,25,28],mobilenet_v2_const:29,mobilenet_v2_width:[17,29],mobilenetsect:29,mobilenetsectionset:17,mobilenetv1:32,mobilenetv2:[17,29],mobilenetv2sect:29,mobilenetv2sectionset:17,mod_extra:[31,37],mod_op:[31,37],mode:[4,7,21,22,28,29,30,31,32],model:[1,2,3,5,6,7,9,10,11,13,21,22,23,25,26,31,32,33,35,37,38],model_aug:7,model_backward:24,model_batch_second:24,model_batch_tim:24,model_batches_per_second:24,model_const:28,model_dir:28,model_fn:31,model_fn_nam:19,model_fn_param:28,model_forward:24,model_fuse_fn_kwarg:22,model_fuse_fn_nam:22,model_input:8,model_item_second:24,model_items_per_second:24,model_nam:32,model_output:[8,24],model_prunability_magnitud:22,model_quantize_qat_export:38,model_sec:24,model_to_devic:24,modelanalyz:6,modelexport:[4,37],modelproto:[6,7,8,23],modelregistri:[16,28],modelrunn:8,moder:[16,28,33],modestli:22,modif:[22,37,38],modifi:[0,1,2,4,8,10,23,24,25,28,32,35,37],modifier_a:[1,10],modifier_epoch:[1,2,10,25],modifier_idx:22,modifier_lr:[1,2,10,25],modifier_manag:28,modifier_param:[1,2,10,25],modifier_prun:[1,2,10,25],modifier_quant:[1,10],modifier_regular:[1,10],modifierprop:[3,9,22,31],modifiers_to_string_lin:[9,31],modifiersessionrunhook:[28,31],modifieryaml:[3,9,22,31],modify_estim:[31,37],modoel:29,modul:[0,35],moduleanalyz:22,moduleasanalyz:22,moduleasoneshootboost:22,modulebenchmark:24,moduledevicecontext:24,moduleexport:[24,37],moduleparampruningmask:22,modulepruninganalyz:22,modulerunfunc:[22,24],modulerunhook:24,modulerunn:24,modulerunresult:[22,24],moduletest:[22,24],moduletrain:[22,24],momentum:[8,22],monitor:[6,22],monitored_sess:28,more:[6,8,12,13,21,22,27,33,34,37,38],most:[22,32,37,38],move:[6,17,22,31,32],much:[6,9,22,24,31],multi:[3,9,17,21,22,29,31,33],multi_step_lr_schedul:31,multibox:24,multipl:[3,7,9,22,24,31,33,38],multipli:[17,22,29,31,38],multisteplr:[3,9,22,31,37,38],must:[3,4,8,9,11,19,21,22,23,24,28,31,33,34,37,38],n_box:24,name:[3,4,6,7,8,9,11,16,18,21,22,24,26,27,28,29,30,31,32,33,34,37,38],name_or_regex_pattern:[24,32],name_prefix:[24,33],name_scop:[26,27],named_modul:[22,23],namedlayerparam:24,namedtupl:21,namespac:1,nativ:[37,38],natur:35,nbit:7,ndarrai:[7,8,24,32,33],nearli:35,necessari:[3,7,8,24,31,37],need:[3,17,18,21,22,31,37,38],neg:[21,24],nest:33,net:[28,30,32],net_output:28,nets_factori:32,nets_util:[1,25],network:[3,6,8,9,17,18,21,22,29,30,32,35,37],network_fn:32,network_input_shap:8,neural:[2,5,6,8,9,10,21,22,25,30,35,37],neuralmag:38,neuralmagicml:38,never:[3,9,22,24],new_mask:24,new_quantized_nam:7,newli:24,next:[4,26],nightli:35,nlp:[16,28],nm_conditional_upd:31,nm_dataset:[12,13,27],nm_k:31,nm_ks_op:31,nm_mask:31,nm_mask_assign:31,nm_mask_upd:31,nm_mask_update_no_op:31,nm_masked_var:31,nm_prune_vars_assign:31,nm_result:8,nm_root:1,nm_save:31,nm_sparsiti:31,nm_threshold:31,nm_update_readi:31,nm_weight_upd:31,nms:24,no_fus:22,no_serialize_v:[3,9,22,31],node:[6,7,8,9,23],node_id:8,node_shap:6,nodeanalyz:6,nodearg:8,nodeparam:8,nodeproto:[7,8,23],nodes_to_exclud:7,nodes_to_quant:7,nodeshap:[6,8],nois:[6,9,11],noisydataset:11,non:[3,8,22,24,31,32],none:[3,4,6,7,8,9,12,13,16,17,18,21,22,23,24,26,27,28,29,30,31,32,33,37],nonzero:[3,31],nor:3,norm:[8,17,22,24,29,30,32],normal:[6,8,9,11,13,22,27,29,32,37],normalizer_fn:32,note:[3,8,11,21,22,24,28,31,33,37,38],notebook:36,noth:[8,24],notic:35,now:[7,33],npy:[24,33],npz:[7,24,33],nsdf3:[12,27],nthread:8,num:21,num_accumulated_batch:24,num_anchor:24,num_anchor_grid:24,num_block:[17,29],num_bucket:33,num_channel:21,num_class:[12,17,18,24,27,29,32],num_cor:[6,8,9],num_default_box:24,num_featur:32,num_imag:27,num_iter:8,num_parallel_cal:26,num_recall_level:24,num_sampl:8,num_train_batch:37,num_upd:31,num_val:24,num_warmup_iter:8,num_work:[11,33],number:[3,4,6,7,8,9,11,17,18,21,22,23,24,26,27,29,30,31,32,33,37,38],numer:[3,31],numpi:[4,7,8,24,32,33],numpyarraybatch:33,obj:[3,22,31],object:[3,4,6,7,8,9,11,13,16,17,18,22,23,24,26,28,29,30,31,32,33,34,37],observ:[22,23],obtain:8,occur:[33,35],off:[3,9,12,22,31],offer:[3,31],offici:[35,37],offset:[13,24],old:24,old_mask:24,omit:[17,32],on_epoch_begin:4,on_epoch_end:4,on_predict_batch_begin:4,on_predict_batch_end:4,on_predict_begin:4,on_predict_end:4,on_test_batch_begin:4,on_test_batch_end:4,on_test_begin:4,on_test_end:4,on_train_batch_begin:4,on_train_batch_end:4,on_train_begin:4,on_train_end:4,onc:[3,8,9,22,31,37,38],one:[3,6,7,8,17,18,21,22,24,28,30,31,32,33,38],one_shot_ks_loss_sensit:31,ones:[3,21,22,31],onli:[3,7,8,9,11,13,21,22,23,24,28,31,33,35,37,38],only_serializ:9,onnx:[0,1,4,22,23,24,32,35,38],onnx_fil:[7,8],onnx_nodes_spars:8,onnx_onnx_rel_1_7_ml_pb2:[6,7,8,23],onnx_path:32,onnx_runtime_graph_optim:8,onnxquant:7,onnxruntim:[6,8],onto:[22,24,31],oop:21,op_cond_upd:31,op_input:[31,32],op_mask_assign:31,op_mask_upd:31,op_mask_update_no_op:31,op_masked_var:31,op_nam:31,op_prune_vars_assign:31,op_sav:31,op_spars:31,op_ten:31,op_typ:[6,7,8,31],op_update_readi:31,op_var:31,op_weight_upd:31,openvino:8,openvinomodelrunn:8,oper:[3,6,7,8,9,21,23,24,28,30,31,32],ops:[3,4,7,8,22,23,26,27,28,29,30,31,32,37],ops_input:31,ops_schedul:31,ops_spars:31,ops_summari:31,ops_upd:31,opset:[4,7,24,32],optim:[0,1,2,5,8,10,16,17,18,24,25,28,33,35],optim_categori:33,optim_closur:24,optim_full_nam:33,optim_nam:33,optim_target:33,optimization_level:[6,8],optimization_recip:[3,22,31,33],optimizationrecip:[3,22,31,33],optimizer_post_step:22,optimizer_pre_step:22,optimizer_v2:3,optimizers_post_step:22,optimizerv2:3,option:[3,4,6,7,8,9,12,13,16,17,18,21,22,23,24,26,27,28,29,30,31,32,33,38],order:[6,7,9,22,33,36],ordereddict:33,org:[17,22],org_model:7,orig:[9,26],origin:[3,7,8,9,11,12,13,17,22,24,27,31,32,34],ort:8,ortmodelrunn:8,other:[1,3,6,8,9,18,22,24,31,32,33,38],otherwis:[3,6,8,9,12,13,16,17,21,22,23,24,26,27,29,30,31,32,33,34],ouput:8,out:[3,6,9,17,18,22,24,29,31,32,37],out_chan:30,out_channel:[17,18,29],out_dict:32,out_tensor:32,output:[3,4,6,7,8,9,12,13,17,18,21,22,23,24,26,27,28,29,30,32,33,37],output_block:17,output_dir:[4,24,32,37],output_edg:7,output_file_path:23,output_func:22,output_id:8,output_model_path:7,output_nam:[6,37],output_shap:[6,8,9],outputs_sampl:22,outputs_sample_max:22,outputs_sample_mean:22,outputs_sample_min:22,outputs_sample_s:22,outputs_sample_std:22,outputs_spars:22,outputs_sparsity_max:22,outputs_sparsity_mean:22,outputs_sparsity_min:22,outputs_sparsity_std:22,outsid:[22,31,33],over:[3,8,21,22,24,31,35,38],overal:[6,8,9,22,24],overprecis:35,overrid:[3,8,17,18,22,23,24,28,31,32,37],overridden:[17,18,21,22],override_bn_subclasses_forward:23,override_model_batch_s:8,overwrit:[8,21],overwrite_input_nam:8,overwritten:[22,23,31],own:[4,21,24,33,38],pack:7,packag:[0,35,37],pad:[6,26,30],pair:[24,32],paper:[17,18,21,22,24,29],parallel:[22,24,26,33],parallelize_model:24,parallelwork:33,param:[3,6,8,9,17,18,22,23,24,28,31,32,33,35,37],param_data:22,param_grad:22,param_group:22,param_init:22,param_mask:22,param_nam:[7,8,22,24],param_spars:22,param_sparsity_dim:22,param_unmask:22,paramet:[1,3,4,6,7,8,9,11,12,13,16,17,18,21,22,23,24,26,27,28,29,30,31,32,33,34,38],parameter:35,params_count:8,params_dim:9,params_strict:[3,22,24,31],params_zero_count:8,parent:[9,33],pars:[23,26,37,38],parse_optimization_str:33,part:[7,24],particular:[8,24],pass:[3,4,6,8,9,17,18,21,22,23,24,28,31,32,33,37],path:[3,4,6,7,8,9,16,17,18,22,23,24,27,28,31,32,33,34,37],path_file_count:33,path_file_s:33,pattern:[3,8,22,24,31,32,33,38],pb_path:32,pb_to_onnx:32,penalti:[22,38],pend:22,per:[3,7,17,18,21,22,24,31,37,38],per_channel:7,percent:33,percentag:[22,33,38],perf:[6,9,16,17,18,28],perform:[1,2,5,6,7,8,9,10,13,17,18,21,22,23,24,25,35,38],period:[3,22,31,38],permiss:32,persist:21,physic:[6,8,9],pick:32,piecewis:21,pil:[13,24],pip:36,pipelin:[13,35,38],pixel:24,place:[3,8,21,22,23,24],placehold:37,plot:[6,9],plot_integr:[6,9],plot_loss_kei:9,plu:35,plugin:[3,9,22,31],png:12,point:[3,7,8,9,13,17,18,22,23,24,31,38],pool2d:30,pool:[30,33],pool_siz:30,portion:38,posit:[8,24,28,33],possibl:[8,33,37],post:[7,24],post_resize_transform:27,postprocess_yolo:24,postprocessing_fn:24,potenti:24,power:38,pre:[7,13,22,28,37,38],pre_resize_transform:27,preced:[3,17,18,22,24,31,33],precis:[22,24,38],preconfigur:[17,18,28],pred:24,predict:[4,8,24,28,31],predicted_box:24,predicted_l:24,predicted_label:24,predictor:24,prefetch:26,prefetch_buffer_s:26,prefix:[3,22,24,31,32,33,38],prelu:21,prepare_qat:22,prepopul:[6,9],preprocess_for_ev:27,preprocess_for_train:27,preprocessing_typ:13,present:[8,33],preserv:[22,24,38],pretrain:[16,17,18,28,33],pretrained_backbon:18,pretrained_dataset:[16,17,18,28],pretrained_path:[16,17,18,28],pretrained_path_backbon:18,previou:[6,8,9],previous:[6,22,24,31],primit:33,print:[4,6,9,21,24],print_r:[6,9],prior:22,probabl:13,process:[3,6,7,8,9,13,22,24,26,27,31,33,35,37,38],process_batch:7,processor:[26,27],product:35,profil:22,programmat:22,progress:[6,7,22,24,31],proj_channel:[17,29],project:[17,29,33],promot:22,prop:[3,9,22,31],propag:24,proper:[8,22,24,30,31,32],properli:[9,13,33],properti:[3,4,6,7,8,9,12,13,18,21,22,23,24,27,31,32,33,34],proport:24,proto:8,protobuf:37,provid:[3,7,8,13,16,17,18,22,24,28,32,33,37,38],prunabl:[3,6,8,9,22,24,31,32],prunable_equation_sensit:6,prunable_lay:3,prunable_param:[6,9],prunable_params_dim:9,prunable_params_zero:6,prune:[3,6,8,9,16,22,28,31,33,35,37],prune_model_one_shot:8,prune_model_one_shot_it:8,prune_op_var:31,prune_unstructur:8,pruned_lay:3,pruning_loss_sens_approx:6,pruning_loss_sens_magnitud:[6,22,31],pruning_loss_sens_magnitude_it:6,pruning_loss_sens_one_shot:[6,22,31],pruning_loss_sens_one_shot_it:6,pruning_loss_sens_op_var:31,pruning_op_var:31,pruning_perf_sens_one_shot:6,pruning_perf_sens_one_shot_it:6,pruning_schedul:3,pruning_var:3,pruninglosssensitivityanalysi:[6,9,22,31],pruningmaskcr:[3,22,31],pruningopvar:31,pruningperfsensitivityanalysi:[6,9],pruningschedul:3,pruningscop:31,pruningsensitivityresult:[6,9],pth:[22,24],pull:[31,33],push:24,put:[6,9,17,22,24,26,29,31],pypi:35,python:[3,4,8,24,26,27,28,29,30,31,32,33,36],pythonlogg:[4,24],pytorch:[0,1,28,29,35,38],pytorchlogg:[22,24],pytorchmodifieryaml:22,qat:[22,23,38],qconfig:23,qlinear:7,qlinearconv:7,qlinearmatmul:7,qlinearop:7,qtype:7,quantiz:[5,6,8,10,22,35],quantization_mod:7,quantization_param:7,quantizationmod:7,quantizationmodifi:[22,38],quantizationparam:23,quantize_data:7,quantize_model:7,quantize_model_post_train:[5,6],quantize_qat_export:[10,22,38],quantize_rang:7,quantize_resnet_identity_add_input:8,quantize_torch_qat_export:23,quantized_data:7,quantized_model:8,quantized_value_typ:7,quantizediniti:7,quantizedvalu:7,quantizedvaluetyp:7,quantizelinear:23,quantizerd:38,quantwrapp:23,queue:33,quick:35,quickli:38,rais:[3,7,8,9,17,18,22,24,31,32,33],raise_on_error:33,rand_crop:27,rand_tran:[12,13,27],randn:37,randndataset:11,random:[8,11,24,26],random_flip_left_right:27,random_flip_up_down:27,random_horizontal_flip_image_and_annot:13,random_scaling_crop:[26,27],randomcrop:[12,13,27],randomhorizontalflip:[12,13,27],randomli:[13,22,26],rang:[3,6,9,22,24,31,33,38],rank:[3,22,24,31],rate:[3,9,22,24,30,31,35,37],ratio:[17,24,26,29],ratio_rang:26,reach:[3,22,24,31],read:[23,32,37],readabl:[6,9],readi:[3,9,22,31],real:7,reappli:22,reason:[6,9,33],recal:24,recal_upd:31,recalibr:[3,6,9,22,31],receiv:22,recent:22,recip:[3,17,18,21,22,24,31,33,35,37],recipe_typ:[3,17,18,22,24,31,33],recogn:32,recommend:[10,11,16,36],record:[6,9,22,24,31],recov:[35,38],recreat:[3,9,22,31],reduc:[3,7,22,31,32],reduce_fn_nam:22,reduce_rang:23,reduce_tensor:22,reducemax:7,reducemin:7,redund:35,ref:[26,27],refer:[16,24,28],referenc:22,reg:22,reg_func:22,reg_ten:22,regex:[3,22,24,31,32,38],region:21,regist:[11,16,17,18,19,21,26,28],register_batch_backward_hook:24,register_batch_end_hook:24,register_batch_forward_hook:24,register_batch_loss_hook:24,register_batch_start_hook:24,register_wrapped_model_constructor:16,registri:[1,10,13,19,25],regular:[22,32],regularize_depthwis:32,relat:[3,6,9,11,12,13,14,15,16,17,18,20,21,22,24,26,27,28,29,31,33],relev:8,reli:4,relu6:[21,30],relu:[7,8,21,22,23,29,30],relu_1:7,relu_2:7,remain:[32,38],remov:[3,8,22,24,28,31,32,35,37],removablehandl:24,remove_dynamic_tl_var:28,remove_node_and_params_from_graph:8,remove_pruning_mask:3,reorder:31,repeat:[24,26,37],repeat_count:26,replac:[8,21],replace_activ:21,repo:[16,19,28],repo_sourc:[16,28],report:[6,22,24],repositori:[35,36],repr:9,repres:[3,6,7,9,13,18,22,24,26,31,32,33],represent:[3,6,8,9,21,22,24,31,33,37],request:[22,24,35],requir:[3,8,22,28,31,36,37,38],reset:[6,22,24,28,31],reshap:[8,27],residu:17,resiz:[12,26,27,34],resnet101:[17,29],resnet101_2xwidth:17,resnet152:[17,29],resnet18:[17,29],resnet20:29,resnet34:[17,29],resnet50:[17,29],resnet50_2xwidth:17,resnet:[7,8,10,16,18,25,28],resnet_const:29,resnet_model:7,resnetsect:29,resnetsectionset:17,resnetv2_101:17,resnetv2_152:17,resnetv2_18:17,resnetv2_34:17,resnetv2_50:17,resnext101:17,resnext152:17,resnext50:17,resnext:17,respect:[8,24],respons:24,rest:[33,37,38],restor:28,restrict:[3,9,22,31],restrict_en:[3,9,22,31],restrict_extra:[3,9,22,31],restrict_initi:[3,9,22,31],result:[3,6,8,9,22,24,28,31,35,37],result_list_tensor:24,result_mean:24,result_std:24,result_typ:22,results_max:22,results_mean:22,results_min:22,results_model:[6,9],results_std:22,retrain:[6,8,22,31],retriev:[3,4,8,16,28,31,38],reus:31,revers:3,revert:22,rewrit:8,right:[3,24],rmax:7,rmin:7,root:[1,12,13,27,34],round:24,routin:7,rule:38,run:[3,4,6,7,8,9,11,17,18,21,22,24,26,28,29,30,31,32,33,34,37,38],run_batches_on_devic:24,run_config:28,run_context:31,run_extra_opt:7,run_func:24,run_it:8,run_lay:22,run_valu:31,runconfig:28,runner:8,runtim:8,runtimeerror:22,s160:[12,27,34],s320:[12,27,34],same:[3,8,22,23,24,30,32,35],sampl:[3,4,8,17,22,24,29,31,32,37,38],sample_batch:[4,24,37],sample_inputs_path:32,sample_label:[4,24],sample_outputs_path:32,sample_s:24,save:[4,6,7,9,23,24,28,31,32,33,34,37],save_desc:9,save_json:[6,9],save_model:[24,37],save_numpi:33,saver:[28,32],scaffold:[28,31],scale:[7,8,12,22,23,24,26],scale_nam:7,scale_rang:26,scale_wh:24,scale_xi:24,scaler:24,schedul:[3,9,22,31,38],schedule_lr:[1,25],schedule_op:31,scheduled_log_upd:22,scheduled_upd:22,scheduledmodif:22,scheduledmodifi:[3,9,22,31],scheduledmodifiermanag:[3,22,24,28,31,37],scheduledoptim:[22,24,37],scheduledupdatemodifi:[3,22,31],scope:[26,27,29,30,31,32],score:24,score_threhsold:24,script:[1,35,36,38],se_mod:17,se_ratio:17,seamless:35,seamlessli:37,search:8,sec_set:[17,29],second:[6,8,9,24,33,38],section:[17,29,37,38],see:[4,12,27,32],seed:24,segment:13,select:[3,22,31],self:[3,22,27,31],sensit:[0,1,6,22,24,31],sensitivity_a:[1,10],sensitivity_lr:[1,10],sensitivity_prun:[1,5,10,25],separ:[17,21,22,29],sequenc:31,sequenti:[17,18,23],serial:[3,9,22,24,31,32],serializ:[3,9,22,31],sess:[28,31,32,37],session:[23,28,31,32,35],session_run_hook:31,sessionrunhook:[28,31],sessionrunvalu:31,set:[1,3,4,6,7,8,9,17,21,22,23,24,26,29,30,31,32,37,38],set_deterministic_se:24,set_logging_level:1,set_optim_learning_r:24,set_param_data:22,set_param_mask:22,set_param_mask_from_abs_threshold:22,set_param_mask_from_spars:22,set_param_mask_from_weight:22,set_relu_to_fat:21,set_threshold:21,set_to_non:22,set_weight:3,setlearningr:[3,9,22,31],setlearningratemodifi:[3,22,31],setparammodifi:22,setter:[3,9,22,31],setup:[1,8,22,24,37,38],setweightdecaymodifi:22,shall:4,shape:[3,6,8,9,11,16,17,18,22,24,28,29,31,32,33],shape_overrid:32,share:[3,8,9,24],shift:[8,24],shot:[6,8,18,22,31],should:[3,4,6,7,8,9,11,12,16,17,18,21,22,24,26,27,28,29,31,32,33,38],should_prun:3,show:8,show_progress:[6,7,8,22,31],shuffl:26,shuffle_buffer_s:26,shutdown:33,side:26,sigmoid:[21,29,30],sign:7,signal:31,signatur:32,significantli:35,silent:[17,18,21],similarli:24,simpl:[3,17,22,24,29,31,32,35],simpler:37,simplif:35,simplifi:29,simplified_arch:29,sinc:[17,18,21],singl:[4,8,17,18,21,22,24,29,33],singleton:[0,1],size:[6,8,9,12,13,17,18,22,24,26,27,29,30,32,33,34],size_i:24,size_x:24,skip:22,slash:31,sleep:6,slice:33,slightli:24,slim:32,slope:21,small:[22,32],smaller:[35,38],smallest:22,smoother:17,softmax:[24,28,29,30],solut:[3,22,31],some:[3,4,8,22,24,31,37],someth:24,somewher:38,sort:[22,33],sort_highest:33,sort_kei:33,sourc:[1,3,4,6,7,8,9,11,12,13,16,17,18,21,22,23,24,26,27,28,29,30,31,32,33,34],space:24,sparisti:31,spars:[3,6,8,9,22,31,35,38],sparse_averag:[6,9],sparse_comparison:[6,9],sparse_integr:[6,9],sparse_measur:[6,9],sparse_tensor:[1,5],sparse_tensor_to_dens:8,sparseml:[36,37,38],sparsepruningopvar:31,sparsetensorproto:8,sparsezoo:[3,16,17,18,22,24,28,31,33,35,37,38],sparsif:22,sparsifi:[22,35,37,38],sparsiti:[3,4,6,8,9,21,22,24,31,32,35,38],sparsity_level:[6,22,31],sparsity_mask:22,sparsity_op:31,sparsity_threshold:8,sparsitymaskcr:[3,22,31],sparsitymeasur:8,sparsti:9,sparstii:9,spec:[8,28],special:[7,24],specif:[3,6,9,16,17,18,21,22,24,28,31,34,38],specifi:[3,7,8,11,16,22,24,26,28,29,31,38],specific_result_typ:22,split:[8,24,26,34],split_canonical_nam:8,split_dataset:26,split_root:34,splitstransform:27,spp:18,squar:[24,26],squeez:[17,21],squeezed_channel:21,squeezeexcit:21,src:24,ssd300:[18,24],ssd300_resnet101:18,ssd300_resnet152:18,ssd300_resnet18:18,ssd300_resnet34:18,ssd300_resnet50:18,ssd300lite:18,ssd300lite_mobilenetv2:18,ssd300mobilenetbackbon:18,ssd300resnetbackbon:18,ssd:[10,13,16,24],ssd_collate_fn:13,ssd_helper:[1,10,13],ssd_lite:[10,16],ssd_mobilenet:[10,16],ssd_random_crop:[13,24],ssd_random_crop_image_and_annot:13,ssd_resnet:[10,16],ssdbackbon:18,ssdlite:18,ssdlosswrapp:24,ssummarysaverhook:28,stabl:35,stack:[13,24,33],stage:24,standard:[1,3,9,11,12,13,17,18,21,22,24,27,29,31,32,33,38],start:[3,4,9,22,24,31,33,38],start_end_step:[3,31],start_epoch:[3,9,22,31,37,38],start_pend:22,start_step:[4,31],startup:38,stat:22,state:[3,16,17,18,22,23,24,31,33,35],state_dict:[21,22],std:[6,9,12,27],stddev:32,stdev:11,step:[3,4,6,8,9,22,24,31,32,37,38],step_count:24,step_lr_schedul:31,step_siz:31,steplr:[3,9,22,31,38],steps_per_epoch:[3,9,22,31,37],steps_per_measur:[6,22,31],still:37,stochast:38,stop:[3,9,11,22,24,31,33,38],storag:31,store:[3,6,7,8,9,11,22,24,31,33,37,38],store_init:22,store_unmask:22,str:[3,4,6,7,8,9,11,12,13,16,17,18,21,22,23,24,26,27,28,29,30,31,32,33,34],strict:[21,24],strictli:[21,22],stride:[6,9,17,29,30],string:[3,4,8,9,16,17,18,21,22,24,28,30,31,32,33,38],strip:8,strip_first_dim:8,structur:[3,6,22,27,31,38],strucur:[3,31],stub:[3,17,18,22,24,31,33],student:24,style:[32,37],sub:[16,18,26,28,32],sub_arch:18,sub_architectur:[16,28],sub_domain:[16,28],subarrai:33,subclass:[3,8,17,18,21,22,23,31],submodul:[0,2,5,10,25,35],subpackag:[0,35],subsect:38,subsequ:[22,24,31],subset:9,suggest:24,suit:35,sum:24,sum_squar:24,sum_val:24,summari:[1,24,25,28,31,37],summary_op:31,summarysaverhook:28,summarywrit:[4,24],suppli:[4,6,8,9,16,17,18,22,24,28,29,31,32],support:[3,7,8,9,13,17,22,24,29,30,31,33,35,37,38],suppress:24,sure:[3,9,16,22,31,37],surround:23,swap_node_output:8,swish:21,symmetr:[7,23,38],symmetric_activ:7,symmetric_pad2d:30,symmetric_weight:7,syntax:[3,9,22,31],system:[2,5,8,10,22,24,25,31,32,33,36,37,38],tag:[4,22,24,32],take:[3,4,6,8,13,17,18,21,22,24,26,31,33,35,37],taken:[3,4,9,22,24,26,31],tar:[8,33],target:[3,9,18,22,23,24,31,33,38],target_spars:3,task:[24,33],teacher:24,techniqu:35,temp_stud:24,temp_teach:24,temperatur:24,ten:[18,21,22,24,31,32],tensor:[3,4,8,9,13,16,17,18,21,22,24,26,27,28,29,30,31,32,33],tensor_dens:24,tensor_export:[24,33],tensor_nam:32,tensor_sampl:24,tensor_spars:24,tensorboard:[4,22,24,31,32,37],tensorboardlogg:[4,24],tensorflow:[3,4,24,26,27,28,29,30,31,32,35,38],tensorflow_estim:[28,31],tensorflow_path:32,tensorflow_v1:[0,1,37],tensorflowmodifieryaml:31,tensorproto:[7,8],tensors_batch_s:24,tensors_export:[24,33],tensors_module_forward:24,tensors_to_devic:24,tensors_to_precis:24,tensorshap:3,termin:[9,24],terminolog:24,test:[1,4,6,9,22,24,36],test_siz:24,tester_logg:22,tester_run_func:22,tf2onnx:37,tf_compat:37,tf_compat_div:32,than:[3,9,22,24,31,38],thei:[3,8,9,22,24,31,38],them:[3,8,17,18,21,22,24,31,33],themselv:[3,31,38],therefor:[3,8],thi:[3,4,6,7,8,9,11,12,13,17,18,21,22,23,24,27,31,32,33,35,36,37,38],thing:[3,6,9,22,31],those:[8,13,24,31,38],thread:[6,8,33],three:[13,24],threshold:[7,8,21,22,24,31],through:[3,4,6,7,8,9,11,17,22,24,31,32,37,38],throughout:33,til:31,time:[3,4,6,8,9,11,22,24,26,31],titl:[6,9],tl_ignore_ten:28,to_devic:24,to_string_lin:9,togeth:[3,17,22,29,31,33],token:[3,22,31,33],too:[6,9],took:24,tool:[1,7,23,37],toolkit:35,top1:24,top1acc:22,top5:24,top5acc:22,top:[11,22,24,33,35,37],topk:24,topkaccuraci:24,topmost:32,torch:[11,13,16,17,18,21,22,23,24,37],torch_distributed_zero_first:24,torchvis:[10,12,13,16],total:[8,9,11,24,33],total_flop:9,tour:35,toward:[6,38],tqdm:[6,7,8],track:[9,22,24,31],track_grad_mom:22,track_input:22,track_inputs_spars:22,track_output:22,track_outputs_spars:22,tracked_input:22,tracked_output:22,trail:31,trailing_slash:31,train:[1,3,4,7,9,12,13,17,18,21,22,23,24,26,27,28,29,30,31,32,34,35,37],train_data:37,train_on_batch:37,trainabl:[3,22,31,32,38],trainable_vari:32,trainableparamsmodifi:[3,22,31],trainer_logg:22,trainer_run_func:22,transfer:[3,22,24,28,31,33,38],transform:[3,7,12,13,22,27,31],trasnform:7,travers:8,traverse_previ:8,treat:[24,32,33],treatment:32,tri:22,truncat:8,trunctat:32,truth:[24,28],truthi:[3,9,22,31],tune:22,tupl:[3,6,7,8,9,11,13,16,17,18,22,23,24,26,27,28,30,31,32,33],twice:[29,38],two:[8,13,22,24,31],type:[3,4,6,7,8,9,13,17,18,21,22,23,24,27,30,31,33,34],type_:[9,30],typic:[3,8,24],uint8:7,unchang:38,under:[9,24,26,27,28,29,30,31,32,33,37],unexpect:21,unexpected_kei:21,union:[3,4,6,7,8,9,11,12,16,17,18,21,22,23,24,26,27,28,29,30,31,32,33],uniqu:[8,33],unit:[6,9],unless:22,unmask:[22,24],unset:[26,30],unsign:7,unstructur:[3,8,22,31,37,38],unstructuredpruningmaskcr:[3,22,31],until:[3,22,31,33,38],unus:[3,9,22,30,31],updat:[3,4,6,7,8,9,22,24,28,31,32,37,38],update_freq:4,update_frequ:[3,9,22,31,37,38],update_frequency_step:[3,31],update_model_param:8,update_op:[31,32],update_readi:[3,22,31],update_step_freq:31,upper:24,url:33,use:[3,4,6,7,8,9,12,16,17,18,21,22,24,26,27,28,29,30,31,32,33,37,38],use_batchnorm:29,use_deepsparse_infer:6,use_mixed_precis:24,use_s:17,use_zipfile_serialization_if_avail:24,used:[1,3,4,6,7,8,9,11,13,16,18,22,24,26,28,31,32,33,37,38],useful:[22,38],user:[17,22,29,33,38],uses:[17,18,22,24,29,30,31],using:[3,4,7,8,13,17,21,22,24,26,27,28,29,31,32,35,36,37,38],util:[0,1,2,5,6,7,10,11,12,13,22,25,26,27,37],utk:24,val:[8,22,27,32,33],valid:[3,4,6,8,9,12,13,22,27,31,33,34],validate_learning_r:9,validate_lr_info:9,validate_onnx_fil:8,validate_schedul:9,validate_str_iter:33,validate_upd:9,valu:[3,4,6,7,8,9,12,13,21,22,23,24,27,31,32,33,34,38],valueerror:[3,8,9,31,32,33],valueinfoproto:7,var_index:32,var_index_from_train:32,var_mask:31,var_nam:[31,32],var_ten:32,var_threshold:31,variabl:[1,3,22,23,25,28,29,30,31,35],variablev1:[31,32],varianc:32,variou:18,verif:7,version:[6,7,9,16,17,18,22,24,28,29,32,33,37,38],vgg11:[17,29],vgg11bn:[17,29],vgg13:[17,29],vgg13bn:[17,29],vgg16:[17,29],vgg16bn:[17,29],vgg19:[17,29],vgg19bn:[17,29],vgg:[10,16,25,28],vgg_const:29,vggsection:29,vggsectionset:17,via:35,video:[10,11],view:[4,24],virtual:36,vision:[12,13,15,17,18,27,29,34],visual:[4,22,24],voc:[10,11,24],vocdetect:13,vocdetectiondataset:13,vocsegment:13,vocsegmentationdataset:13,wai:[8,23,24,38],wait:24,wait_between_it:6,wall:[4,24],wall_tim:[4,24],want:7,warmup:8,warmup_iterations_per_check:6,warmup_s:24,warn:33,wasn:33,websit:35,weight:[3,6,7,8,16,17,18,22,23,24,28,31,32,37,38],weight_decai:[22,32,38],weight_nam:6,weight_qtyp:7,weight_shap:[6,8],well:[4,8,24,26,32],were:[8,24],what:[3,8,9,22,31,33],when:[3,4,6,7,8,9,11,13,22,23,24,28,31,33,35,38],where:[3,6,7,8,9,17,22,24,31,33,34],whether:[4,21,22,29,32],which:[3,7,21,22,26,31,32,34,37,38],whole:11,whose:[8,18,24,33],width:[17,24,26,29,32],width_mult:[17,29],wildcard:32,window:30,winograd:35,wise:17,within:[3,7,8,9,17,18,21,22,24,31,32,33,35],without:[3,7,22,24,31,33],won:22,word:[3,9,22,31],work:[2,5,9,10,13,21,24,25,26,28,31,32,33,38],worker:[0,1],worker_func:33,world:24,world_siz:24,wors:22,would:[8,36],wrap:[3,9,13,16,22,23,24,31,33,37],wrapped_constructor:16,wrapper:[0,1,3,7,12,13,16,21,22,24,27],wrapper_decor:33,write:[32,37],write_simple_summari:32,writer:[4,24,32],written:[37,38],x_cur:33,x_ten:[17,21,29,30],x_val:33,xavier:32,xml:8,xxx:[12,27],xxy:[12,27],xxz:[12,27],xywh:24,yaml:[3,9,22,31,33,37,38],yaml_kei:9,yaml_str:[3,9,22,31],year:13,yeild:6,yet:22,yield:[6,24],yolo:[13,17,18,24],yolo_collate_fn:13,yolo_grid:24,yolo_help:[1,10],yolo_v3:[10,16],yolo_v3_anchor_group:24,yologrid:24,yololosswrapp:24,yolov3:18,you:[21,35,36,37,38],your:[21,35,36,37,38],zero:[3,6,7,8,9,21,22,23,24,29,30,31,32,33,38],zero_grad:22,zero_point:[7,8,23],zero_point_nam:7,zeroed_param:9,zeroth:24,zipfil:24,zoo:[3,16,17,18,22,24,28,31,33]},titles:["sparseml","sparseml package","sparseml.keras package","sparseml.keras.optim package","sparseml.keras.utils package","sparseml.onnx package","sparseml.onnx.optim package","sparseml.onnx.optim.quantization package","sparseml.onnx.utils package","sparseml.optim package","sparseml.pytorch package","sparseml.pytorch.datasets package","sparseml.pytorch.datasets.classification package","sparseml.pytorch.datasets.detection package","sparseml.pytorch.datasets.recommendation package","sparseml.pytorch.datasets.video package","sparseml.pytorch.models package","sparseml.pytorch.models.classification package","sparseml.pytorch.models.detection package","sparseml.pytorch.models.external package","sparseml.pytorch.models.recommendation package","sparseml.pytorch.nn package","sparseml.pytorch.optim package","sparseml.pytorch.optim.quantization package","sparseml.pytorch.utils package","sparseml.tensorflow_v1 package","sparseml.tensorflow_v1.datasets package","sparseml.tensorflow_v1.datasets.classification package","sparseml.tensorflow_v1.models package","sparseml.tensorflow_v1.models.classification package","sparseml.tensorflow_v1.nn package","sparseml.tensorflow_v1.optim package","sparseml.tensorflow_v1.utils package","sparseml.utils package","sparseml.utils.datasets package","SparseML 0.1","Installation","Quick Tour","Sparsification Recipes"],titleterms:{"export":[4,24,32,37],activ:21,analyz:9,analyzer_a:22,analyzer_model:6,analyzer_modul:[22,31],analyzer_prun:22,base:37,benchmark:24,calibr:7,callback:4,cifar:[12,27],classif:[12,17,27,29],coco:13,constantpruningmodifi:38,content:[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34],darknet:17,data:8,dataset:[11,12,13,14,15,26,27,34],detect:[13,18],efficientnet:17,epoch:38,estim:[28,37],extern:19,fatrelu:21,framework:33,gener:11,gmpruningmodifi:38,graph_editor:8,graph_optim:8,helper:[8,13,23,24,26,32,33,34],histori:35,imagefold:[12,27],imagenet:[12,27,34],imagenett:[12,27,34],inception_v3:17,instal:36,intro:38,kera:[2,3,4,37],layer:30,learn:[35,38],learning_r:9,learningratemodifi:38,log:1,logger:[4,24],loss:[8,24,32],manag:[3,9,22,31],mask_creator_prun:[22,31],mask_prun:[3,22,31],mask_pruning_cr:3,mnist:[12,17,29],mobilenet:[17,29],mobilenet_v2:[17,29],model:[4,8,16,17,18,19,20,24,28,29],modifi:[3,9,22,31,38],modifier_a:22,modifier_epoch:[3,22,31],modifier_lr:[3,22,31],modifier_param:[3,22,31],modifier_prun:[3,22,31],modifier_quant:22,modifier_regular:22,modul:[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34],more:35,nets_util:32,onnx:[5,6,7,8,37],optim:[3,6,7,9,22,23,31,37,38],overview:35,packag:[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34],param:38,pipelin:37,prune:38,pytorch:[10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,37],quantiz:[7,23,38],quantize_model_post_train:7,quantize_qat_export:23,quick:37,rate:38,recip:38,recommend:[14,20],registri:[11,16,26,28],releas:35,resnet:[17,29],resourc:35,schedule_lr:31,sensit:9,sensitivity_a:22,sensitivity_lr:22,sensitivity_prun:[6,22,31],session:37,setlearningratemodifi:38,setweightdecaymodifi:38,singleton:33,sparse_tensor:8,sparseml:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35],sparsif:[35,37,38],ssd:18,ssd_helper:24,ssd_lite:18,ssd_mobilenet:18,ssd_resnet:18,submodul:[1,3,4,6,7,8,9,11,12,13,16,17,18,19,21,22,23,24,26,27,28,29,30,31,32,33,34],subpackag:[1,2,5,6,10,11,16,22,25,26,28,33],summari:32,tensorflow:37,tensorflow_v1:[25,26,27,28,29,30,31,32],torchvis:19,tour:37,train:38,trainableparamsmodifi:38,util:[3,4,8,24,32,33,34],variabl:[32,38],vgg:[17,29],video:15,voc:13,worker:33,wrapper:33,yolo_help:24,yolo_v3:18}}) \ No newline at end of file diff --git a/sparsezoo/.buildinfo b/sparsezoo/.buildinfo index c41a72fb91b..72f49fa3d9c 100644 --- a/sparsezoo/.buildinfo +++ b/sparsezoo/.buildinfo @@ -1,4 +1,4 @@ # Sphinx build info version 1 # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. -config: 772e7053a5e6b3d8b54e7ed0917c84b9 +config: 0d1246d1af673590b0b47a885a50ec9e tags: 645f666f9bcd5a90fca523b33c5a78b7 diff --git a/sparsezoo/_modules/index.html b/sparsezoo/_modules/index.html index 4b5dbac8773..22c1be55862 100644 --- a/sparsezoo/_modules/index.html +++ b/sparsezoo/_modules/index.html @@ -183,7 +183,6 @@

                                                                                                                                            All modules for which code is available

                                                                                                                                          • sparsezoo.models.detection.ssd
                                                                                                                                          • sparsezoo.models.detection.yolo
                                                                                                                                          • sparsezoo.models.zoo
                                                                                                                                          • -
                                                                                                                                          • sparsezoo.nbutils.utils
                                                                                                                                          • sparsezoo.objects.base
                                                                                                                                          • sparsezoo.objects.data
                                                                                                                                          • sparsezoo.objects.downloadable
                                                                                                                                          • @@ -203,7 +202,6 @@

                                                                                                                                            All modules for which code is available

                                                                                                                                          • sparsezoo.utils.downloader
                                                                                                                                          • sparsezoo.utils.helpers
                                                                                                                                          • sparsezoo.utils.numpy
                                                                                                                                          • -
                                                                                                                                          • tqdm.asyncio

                                                                                                                                    diff --git a/sparsezoo/_modules/sparsezoo/nbutils/utils.html b/sparsezoo/_modules/sparsezoo/nbutils/utils.html deleted file mode 100644 index 61456b650d9..00000000000 --- a/sparsezoo/_modules/sparsezoo/nbutils/utils.html +++ /dev/null @@ -1,629 +0,0 @@ - - - - - - - - - - sparsezoo.nbutils.utils — SparseZoo 0.1.0 documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                                                                                                                                    - - - -
                                                                                                                                    - - - - - -
                                                                                                                                    - -
                                                                                                                                    - - - - - - - - - - - - - - - - - - - -
                                                                                                                                    - -
                                                                                                                                      - -
                                                                                                                                    • »
                                                                                                                                    • - -
                                                                                                                                    • Module code »
                                                                                                                                    • - -
                                                                                                                                    • sparsezoo.nbutils.utils
                                                                                                                                    • - - -
                                                                                                                                    • - -
                                                                                                                                    • - -
                                                                                                                                    - - -
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    - -

                                                                                                                                    Source code for sparsezoo.nbutils.utils

                                                                                                                                    -# Copyright (c) 2021 - present / Neuralmagic, Inc. All Rights Reserved.
                                                                                                                                    -#
                                                                                                                                    -# Licensed under the Apache License, Version 2.0 (the "License");
                                                                                                                                    -# you may not use this file except in compliance with the License.
                                                                                                                                    -# You may obtain a copy of the License at
                                                                                                                                    -#
                                                                                                                                    -#    http://www.apache.org/licenses/LICENSE-2.0
                                                                                                                                    -#
                                                                                                                                    -# Unless required by applicable law or agreed to in writing,
                                                                                                                                    -# software distributed under the License is distributed on an "AS IS" BASIS,
                                                                                                                                    -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                                                                                                                                    -# See the License for the specific language governing permissions and
                                                                                                                                    -# limitations under the License.
                                                                                                                                    -
                                                                                                                                    -"""
                                                                                                                                    -Code related to model repo selection display in a jupyter notebook using ipywidgets
                                                                                                                                    -"""
                                                                                                                                    -
                                                                                                                                    -from typing import Dict, List, Tuple
                                                                                                                                    -
                                                                                                                                    -import ipywidgets as widgets
                                                                                                                                    -from sparsezoo.objects import Model
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -__all__ = ["ModelSelectWidgetContainer", "SelectDomainWidgetContainer"]
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -def format_html(
                                                                                                                                    -    message: str, header: str = None, color: str = None, italic: bool = False
                                                                                                                                    -):
                                                                                                                                    -    """
                                                                                                                                    -    Create a message formatted as html using the given parameters.
                                                                                                                                    -    Expected to be used in ipywidgets.HTML.
                                                                                                                                    -
                                                                                                                                    -    :param message: the message string to display
                                                                                                                                    -    :param header: the header type to use for the html (h1, h2, h3, h4, etc)
                                                                                                                                    -    :param color: the color to apply as a style (black, red, green, etc)
                                                                                                                                    -    :param italic: True to format the HTML as italic, False otherwise
                                                                                                                                    -    :return: the message formatted as html
                                                                                                                                    -    """
                                                                                                                                    -    if not message:
                                                                                                                                    -        message = ""
                                                                                                                                    -
                                                                                                                                    -    message = "<i>{}</i>".format(message) if italic else message
                                                                                                                                    -    color = 'style="color: {}"'.format(color) if color else ""
                                                                                                                                    -    obj = "span" if not header else header
                                                                                                                                    -    html = "<{} {}>{}</{}>".format(obj, color, message, obj)
                                                                                                                                    -
                                                                                                                                    -    return html
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    [docs]class SelectDomainWidgetContainer(object): - """ - Widget used in model repo notebooks for selecting domain and subdomain to - search within - - :param domains: list of domains to look through - :param sub_domain: a map of sub domains for each domain - """ - - def __init__( - self, - domains: List[str] = ["cv"], - sub_domains: Dict[str, List[str]] = { - "cv": ["classification"], - }, - ): - self._domains_dropdown = widgets.Dropdown(options=domains, value=domains[0]) - self._sub_domains_dropdown = widgets.Dropdown( - options=sub_domains[domains[0]], value=sub_domains[domains[0]][0] - ) - self._domains = domains - self._sub_domains = sub_domains - -
                                                                                                                                    [docs] def create(self): - def _domain_selector(change): - domain = change["new"] - sub_domains = ( - self._sub_domains[domain] if domain in self._sub_domains else [] - ) - self._sub_domains_dropdown.options = sub_domains - if self._sub_domains_dropdown.value not in sub_domains: - self._sub_domains_dropdown.value = ( - sub_domains[0] if len(sub_domains) > 0 else None - ) - - self._domains_dropdown.observe(_domain_selector, names="value") - self.container = widgets.VBox( - ( - widgets.HTML(format_html("Model Search Domains", header="h2")), - widgets.HBox( - (widgets.HTML(format_html("Domains:")), self._domains_dropdown) - ), - widgets.HBox( - ( - widgets.HTML(format_html("Sub Domains:")), - self._sub_domains_dropdown, - ) - ), - ) - ) - return self.container
                                                                                                                                    - - @property - def selected_domain_info(self) -> Tuple[str, str]: - return (self._domains_dropdown.value, self._sub_domains_dropdown.value)
                                                                                                                                    - - -def _optimazation_id(mod: Model): - return ( - "-".join([mod.optim_name, mod.optim_category]) - if mod.optim_target is None - else "-".join([mod.optim_name, mod.optim_category, mod.optim_target]) - ) - - -class _ModelsWidget(object): - def __init__(self, all_models: List[Model]): - self._all_models = all_models - self._architecture_selector = widgets.Select( - options=[], description="Networks:" - ) - self._dataset_selector = widgets.Select(options=[], description="Dataset:") - self._framework_selector = widgets.Select( - options=[], description="ML Framework:" - ) - self._opt_name_selector = widgets.Select(options=[], description="Type:") - self._selected_text = widgets.HTML(format_html("", italic=True)) - - self.container = widgets.VBox( - ( - widgets.HTML(format_html("Selection", header="h4")), - widgets.HBox( - ( - self._architecture_selector, - self._dataset_selector, - self._framework_selector, - self._opt_name_selector, - ) - ), - widgets.HBox( - ( - widgets.HTML(format_html("Selected:", header="h5")), - self._selected_text, - ) - ), - ) - ) - self._filtered: List[Model] = [] - self._setup_hooks() - self.selected = None - - @property - def selected_framework(self) -> str: - return self._framework_selector.value - - def update(self, filtered: List[Model]): - self._filtered = filtered - self._update_selectors() - - def _setup_hooks(self): - def _selector_change(change): - if change["new"] != change["old"]: - self._update_selectors() - - self._architecture_selector.observe(_selector_change, names="value") - self._dataset_selector.observe(_selector_change, names="value") - self._framework_selector.observe(_selector_change, names="value") - self._opt_name_selector.observe(_selector_change, names="value") - - def _update_selectors(self): - architecture = self._architecture_selector.value - dataset = self._dataset_selector.value - framework = self._framework_selector.value - optimization_name = self._opt_name_selector.value - - architectures = {mod.architecture for mod in self._filtered} - architectures = list(architectures) - architectures.sort() - if architecture not in architectures: - architecture = architectures[0] if len(architectures) > 0 else None - self._architecture_selector.options = architectures - self._architecture_selector.value = architecture - - datasets = { - mod.dataset for mod in self._filtered if mod.architecture == architecture - } - datasets = list(datasets) - datasets.sort() - if dataset not in datasets: - dataset = datasets[0] if len(datasets) > 0 else None - self._dataset_selector.options = datasets - self._dataset_selector.value = dataset - - frameworks = { - mod.framework - for mod in self._filtered - if mod.architecture == architecture and mod.dataset == dataset - } - frameworks = list(frameworks) - frameworks.sort() - if framework not in frameworks: - framework = frameworks[0] if len(frameworks) > 0 else None - self._framework_selector.options = frameworks - self._framework_selector.value = framework - - opt_names = { - _optimazation_id(mod) - for mod in self._filtered - if mod.architecture == architecture - and mod.dataset == dataset - and (mod.framework == framework) - } - opt_names = list(opt_names) - opt_names.sort() - if optimization_name not in opt_names: - optimization_name = opt_names[0] if len(opt_names) > 0 else None - self._opt_name_selector.options = opt_names - self._opt_name_selector.value = optimization_name - - self._update_selected() - - def _update_selected(self): - self.selected = None - self._selected_text.value = "" - - mods = [ - mod - for mod in self._filtered - if ( - mod.architecture == self._architecture_selector.value - and mod.dataset == self._dataset_selector.value - and (mod.framework == self._framework_selector.value) - and _optimazation_id(mod) == self._opt_name_selector.value - ) - ] - if len(mods) > 0: - mod = mods[0] - self.selected = mod - self._selected_text.value = format_html(mod.display_name, italic=True) - - -class _FilterWidget(object): - def __init__(self, all_models: List[Model]): - self._all_models = all_models - self._datasets = self._init_datasets() - self._repos = self._init_repos() - - self._recal_checkbox = widgets.Checkbox(value=False, indent=False) - self._datasets_dropdown = widgets.Dropdown( - options=self._datasets, value=self._datasets[0] - ) - self._repo_dropdown = widgets.Dropdown( - options=self._repos, value=self._repos[0] - ) - self._setup_hooks() - - self.container = widgets.VBox( - ( - widgets.HTML(format_html("Filters", header="h4")), - widgets.HBox( - (widgets.HTML(format_html("Datasets:")), self._datasets_dropdown) - ), - widgets.HBox( - (widgets.HTML(format_html("Repos:")), self._repo_dropdown) - ), - widgets.HBox( - ( - widgets.HTML(format_html("Recalibrated Only:")), - self._recal_checkbox, - ) - ), - ) - ) - self.filtered_callback = None - - def _init_datasets(self): - datasets = [mod.dataset for mod in self._all_models] - datasets = list(dict.fromkeys(datasets)) - datasets.sort() - return ["all datasets"] + datasets - - def _init_repos(self): - repos = [mod.repo for mod in self._all_models] - repos = list(dict.fromkeys(repos)) - repos.sort() - return ["all repos"] + repos - - def _setup_hooks(self): - def _invoke_callback(): - datasets = ( - [self._datasets_dropdown.value] - if self._datasets_dropdown.value != "all datasets" - and self._datasets_dropdown.value - else None - ) - repos = ( - [self._repo_dropdown.value] - if self._repo_dropdown.value != "all repos" - and self._repo_dropdown.value - else None - ) - descs = ( - [ - _optimazation_id(mod) - for mod in self._all_models - if mod.optim_name != "base" - ] - if self._recal_checkbox.value - else None - ) - - if self.filtered_callback: - self.filtered_callback(datasets, repos, descs) - - def _recal_change(change): - _invoke_callback() - - def _repos_change(change): - self._selected_domain = change["new"] - _invoke_callback() - - def _datasets_change(change): - self._selected_dataset = change["new"] - _invoke_callback() - - self._recal_checkbox.observe(_recal_change, names="value") - self._repo_dropdown.observe(_repos_change, names="value") - self._datasets_dropdown.observe(_datasets_change, names="value") - - -
                                                                                                                                    [docs]class ModelSelectWidgetContainer(object): - """ - Widget used in model download notebooks for selecting a model for download - - :param filter_frameworks: if provided, will force all models - to be one of these frameworks - :param filter_datasets: if provided, will force all models - to be trained on one of these datasets - """ - - def __init__(self, models: List[Model]): - self._models = models - self._models_widget = _ModelsWidget(self._models) - self._filter_widget = _FilterWidget(self._models) - - @property - def selected_model(self) -> Model: - """ - :return: the selected model in the widget - """ - return self._models_widget.selected - - @property - def selected_framework(self) -> str: - """ - :return: the selected framework in the widget - """ - return self._models_widget.selected_framework - -
                                                                                                                                    [docs] def create(self): - """ - :return: a created ipywidget that allows selection of models - """ - - def _filter_change_callback( - datasets: List[str], - repos: List[str], - opt_names: List[str], - ): - filtered = [] - filtered = [ - mod - for mod in self._models - if ( - (datasets is None or mod.dataset in datasets) - and (repos is None or mod.repo in repos) - and (opt_names is None or _optimazation_id(mod) in opt_names) - ) - ] - self._models_widget.update(filtered) - - self._filter_widget.filtered_callback = _filter_change_callback - self._models_widget.update(self._models) - - return widgets.VBox( - ( - widgets.HTML(format_html("Model Selector", header="h2")), - self._filter_widget.container, - self._models_widget.container, - ) - )
                                                                                                                                    -
                                                                                                                                    - -
                                                                                                                                    - -
                                                                                                                                    -
                                                                                                                                    - -
                                                                                                                                    - -
                                                                                                                                    -

                                                                                                                                    - © Copyright 2021 - present / Neuralmagic, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"). - -

                                                                                                                                    -
                                                                                                                                    - - - - Built with Sphinx using a - - theme - - provided by Read the Docs. - -
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    - -
                                                                                                                                    - -
                                                                                                                                    - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sparsezoo/_modules/tqdm/asyncio.html b/sparsezoo/_modules/tqdm/asyncio.html deleted file mode 100644 index 47ddbafcdda..00000000000 --- a/sparsezoo/_modules/tqdm/asyncio.html +++ /dev/null @@ -1,313 +0,0 @@ - - - - - - - - - - tqdm.asyncio — SparseZoo 0.1.0 documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                                                                                                                                    - - - -
                                                                                                                                    - - - - - -
                                                                                                                                    - -
                                                                                                                                    - - - - - - - - - - - - - - - - - - - -
                                                                                                                                    - -
                                                                                                                                      - -
                                                                                                                                    • »
                                                                                                                                    • - -
                                                                                                                                    • Module code »
                                                                                                                                    • - -
                                                                                                                                    • tqdm.asyncio
                                                                                                                                    • - - -
                                                                                                                                    • - -
                                                                                                                                    • - -
                                                                                                                                    - - -
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    - -

                                                                                                                                    Source code for tqdm.asyncio

                                                                                                                                    -"""
                                                                                                                                    -Asynchronous progressbar decorator for iterators.
                                                                                                                                    -Includes a default `range` iterator printing to `stderr`.
                                                                                                                                    -
                                                                                                                                    -Usage:
                                                                                                                                    ->>> from tqdm.asyncio import trange, tqdm
                                                                                                                                    ->>> async for i in trange(10):
                                                                                                                                    -...     ...
                                                                                                                                    -"""
                                                                                                                                    -import asyncio
                                                                                                                                    -
                                                                                                                                    -from .std import tqdm as std_tqdm
                                                                                                                                    -
                                                                                                                                    -__author__ = {"github.com/": ["casperdcl"]}
                                                                                                                                    -__all__ = ['tqdm_asyncio', 'tarange', 'tqdm', 'trange']
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class tqdm_asyncio(std_tqdm):
                                                                                                                                    -    """
                                                                                                                                    -    Asynchronous-friendly version of tqdm (Python 3.5+).
                                                                                                                                    -    """
                                                                                                                                    -    def __init__(self, iterable=None, *args, **kwargs):
                                                                                                                                    -        super(tqdm_asyncio, self).__init__(iterable, *args, **kwargs)
                                                                                                                                    -        self.iterable_awaitable = False
                                                                                                                                    -        if iterable is not None:
                                                                                                                                    -            if hasattr(iterable, "__anext__"):
                                                                                                                                    -                self.iterable_next = iterable.__anext__
                                                                                                                                    -                self.iterable_awaitable = True
                                                                                                                                    -            elif hasattr(iterable, "__next__"):
                                                                                                                                    -                self.iterable_next = iterable.__next__
                                                                                                                                    -            else:
                                                                                                                                    -                self.iterable_iterator = iter(iterable)
                                                                                                                                    -                self.iterable_next = self.iterable_iterator.__next__
                                                                                                                                    -
                                                                                                                                    -    def __aiter__(self):
                                                                                                                                    -        return self
                                                                                                                                    -
                                                                                                                                    -    async def __anext__(self):
                                                                                                                                    -        try:
                                                                                                                                    -            if self.iterable_awaitable:
                                                                                                                                    -                res = await self.iterable_next()
                                                                                                                                    -            else:
                                                                                                                                    -                res = self.iterable_next()
                                                                                                                                    -            self.update()
                                                                                                                                    -            return res
                                                                                                                                    -        except StopIteration:
                                                                                                                                    -            self.close()
                                                                                                                                    -            raise StopAsyncIteration
                                                                                                                                    -        except BaseException:
                                                                                                                                    -            self.close()
                                                                                                                                    -            raise
                                                                                                                                    -
                                                                                                                                    -    def send(self, *args, **kwargs):
                                                                                                                                    -        return self.iterable.send(*args, **kwargs)
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def as_completed(cls, fs, *, loop=None, timeout=None, total=None, **tqdm_kwargs):
                                                                                                                                    -        """
                                                                                                                                    -        Wrapper for `asyncio.as_completed`.
                                                                                                                                    -        """
                                                                                                                                    -        if total is None:
                                                                                                                                    -            total = len(fs)
                                                                                                                                    -        yield from cls(asyncio.as_completed(fs, loop=loop, timeout=timeout),
                                                                                                                                    -                       total=total, **tqdm_kwargs)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -def tarange(*args, **kwargs):
                                                                                                                                    -    """
                                                                                                                                    -    A shortcut for `tqdm.asyncio.tqdm(range(*args), **kwargs)`.
                                                                                                                                    -    """
                                                                                                                                    -    return tqdm_asyncio(range(*args), **kwargs)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -# Aliases
                                                                                                                                    -tqdm = tqdm_asyncio
                                                                                                                                    -trange = tarange
                                                                                                                                    -
                                                                                                                                    - -
                                                                                                                                    - -
                                                                                                                                    -
                                                                                                                                    - -
                                                                                                                                    - -
                                                                                                                                    -

                                                                                                                                    - © Copyright 2021 - present / Neuralmagic, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"). - -

                                                                                                                                    -
                                                                                                                                    - - - - Built with Sphinx using a - - theme - - provided by Read the Docs. - -
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    - -
                                                                                                                                    - -
                                                                                                                                    - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sparsezoo/_static/doctools.js b/sparsezoo/_static/doctools.js index 144884ea651..61ac9d266f9 100644 --- a/sparsezoo/_static/doctools.js +++ b/sparsezoo/_static/doctools.js @@ -29,9 +29,14 @@ if (!window.console || !console.firebug) { /** * small helper function to urldecode strings + * + * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent#Decoding_query_parameters_from_a_URL */ jQuery.urldecode = function(x) { - return decodeURIComponent(x).replace(/\+/g, ' '); + if (!x) { + return x + } + return decodeURIComponent(x.replace(/\+/g, ' ')); }; /** diff --git a/sparsezoo/_static/language_data.js b/sparsezoo/_static/language_data.js index 0e7dc7e9ef0..863704b310d 100644 --- a/sparsezoo/_static/language_data.js +++ b/sparsezoo/_static/language_data.js @@ -13,7 +13,8 @@ var stopwords = ["a","and","are","as","at","be","but","by","for","if","in","into","is","it","near","no","not","of","on","or","such","that","the","their","then","there","these","they","this","to","was","will","with"]; -/* Non-minified version JS is _stemmer.js if file is provided */ +/* Non-minified version is copied as a separate JS file, is available */ + /** * Porter Stemmer */ @@ -199,7 +200,6 @@ var Stemmer = function() { - var splitChars = (function() { var result = {}; var singles = [96, 180, 187, 191, 215, 247, 749, 885, 903, 907, 909, 930, 1014, 1648, diff --git a/sparsezoo/_static/pygments.css b/sparsezoo/_static/pygments.css index de7af262ffb..691aeb82d00 100644 --- a/sparsezoo/_static/pygments.css +++ b/sparsezoo/_static/pygments.css @@ -1,7 +1,7 @@ pre { line-height: 125%; } -td.linenos pre { color: #000000; background-color: #f0f0f0; padding-left: 5px; padding-right: 5px; } -span.linenos { color: #000000; background-color: #f0f0f0; padding-left: 5px; padding-right: 5px; } -td.linenos pre.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } +td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } +span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } +td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } .highlight .hll { background-color: #ffffcc } .highlight { background: #eeffcc; } diff --git a/sparsezoo/_static/searchtools.js b/sparsezoo/_static/searchtools.js index 6fc9e7f3338..1a90152eb0e 100644 --- a/sparsezoo/_static/searchtools.js +++ b/sparsezoo/_static/searchtools.js @@ -248,7 +248,7 @@ var Search = { // results left, load the summary and display it if (results.length) { var item = results.pop(); - var listItem = $('
                                                                                                                                  • '); + var listItem = $('
                                                                                                                                  • '); var requestUrl = ""; var linkUrl = ""; if (DOCUMENTATION_OPTIONS.BUILDER === 'dirhtml') { @@ -273,9 +273,9 @@ var Search = { if (item[3]) { listItem.append($(' (' + item[3] + ')')); Search.output.append(listItem); - listItem.slideDown(5, function() { + setTimeout(function() { displayNextItem(); - }); + }, 5); } else if (DOCUMENTATION_OPTIONS.HAS_SOURCE) { $.ajax({url: requestUrl, dataType: "text", @@ -285,16 +285,16 @@ var Search = { listItem.append(Search.makeSearchSummary(data, searchterms, hlterms)); } Search.output.append(listItem); - listItem.slideDown(5, function() { + setTimeout(function() { displayNextItem(); - }); + }, 5); }}); } else { // no source available, just display title Search.output.append(listItem); - listItem.slideDown(5, function() { + setTimeout(function() { displayNextItem(); - }); + }, 5); } } // search finished, update title and status message @@ -379,6 +379,13 @@ var Search = { return results; }, + /** + * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions + */ + escapeRegExp : function(string) { + return string.replace(/[.*+\-?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string + }, + /** * search for full-text terms in the index */ @@ -402,13 +409,14 @@ var Search = { ]; // add support for partial matches if (word.length > 2) { + var word_regex = this.escapeRegExp(word); for (var w in terms) { - if (w.match(word) && !terms[word]) { + if (w.match(word_regex) && !terms[word]) { _o.push({files: terms[w], score: Scorer.partialTerm}) } } for (var w in titleterms) { - if (w.match(word) && !titleterms[word]) { + if (w.match(word_regex) && !titleterms[word]) { _o.push({files: titleterms[w], score: Scorer.partialTitle}) } } diff --git a/sparsezoo/_static/underscore-1.12.0.js b/sparsezoo/_static/underscore-1.12.0.js new file mode 100644 index 00000000000..3af6352e613 --- /dev/null +++ b/sparsezoo/_static/underscore-1.12.0.js @@ -0,0 +1,2027 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : + typeof define === 'function' && define.amd ? define('underscore', factory) : + (global = global || self, (function () { + var current = global._; + var exports = global._ = factory(); + exports.noConflict = function () { global._ = current; return exports; }; + }())); +}(this, (function () { + // Underscore.js 1.12.0 + // https://underscorejs.org + // (c) 2009-2020 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors + // Underscore may be freely distributed under the MIT license. + + // Current version. + var VERSION = '1.12.0'; + + // Establish the root object, `window` (`self`) in the browser, `global` + // on the server, or `this` in some virtual machines. We use `self` + // instead of `window` for `WebWorker` support. + var root = typeof self == 'object' && self.self === self && self || + typeof global == 'object' && global.global === global && global || + Function('return this')() || + {}; + + // Save bytes in the minified (but not gzipped) version: + var ArrayProto = Array.prototype, ObjProto = Object.prototype; + var SymbolProto = typeof Symbol !== 'undefined' ? Symbol.prototype : null; + + // Create quick reference variables for speed access to core prototypes. + var push = ArrayProto.push, + slice = ArrayProto.slice, + toString = ObjProto.toString, + hasOwnProperty = ObjProto.hasOwnProperty; + + // Modern feature detection. + var supportsArrayBuffer = typeof ArrayBuffer !== 'undefined', + supportsDataView = typeof DataView !== 'undefined'; + + // All **ECMAScript 5+** native function implementations that we hope to use + // are declared here. + var nativeIsArray = Array.isArray, + nativeKeys = Object.keys, + nativeCreate = Object.create, + nativeIsView = supportsArrayBuffer && ArrayBuffer.isView; + + // Create references to these builtin functions because we override them. + var _isNaN = isNaN, + _isFinite = isFinite; + + // Keys in IE < 9 that won't be iterated by `for key in ...` and thus missed. + var hasEnumBug = !{toString: null}.propertyIsEnumerable('toString'); + var nonEnumerableProps = ['valueOf', 'isPrototypeOf', 'toString', + 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString']; + + // The largest integer that can be represented exactly. + var MAX_ARRAY_INDEX = Math.pow(2, 53) - 1; + + // Some functions take a variable number of arguments, or a few expected + // arguments at the beginning and then a variable number of values to operate + // on. This helper accumulates all remaining arguments past the function’s + // argument length (or an explicit `startIndex`), into an array that becomes + // the last argument. Similar to ES6’s "rest parameter". + function restArguments(func, startIndex) { + startIndex = startIndex == null ? func.length - 1 : +startIndex; + return function() { + var length = Math.max(arguments.length - startIndex, 0), + rest = Array(length), + index = 0; + for (; index < length; index++) { + rest[index] = arguments[index + startIndex]; + } + switch (startIndex) { + case 0: return func.call(this, rest); + case 1: return func.call(this, arguments[0], rest); + case 2: return func.call(this, arguments[0], arguments[1], rest); + } + var args = Array(startIndex + 1); + for (index = 0; index < startIndex; index++) { + args[index] = arguments[index]; + } + args[startIndex] = rest; + return func.apply(this, args); + }; + } + + // Is a given variable an object? + function isObject(obj) { + var type = typeof obj; + return type === 'function' || type === 'object' && !!obj; + } + + // Is a given value equal to null? + function isNull(obj) { + return obj === null; + } + + // Is a given variable undefined? + function isUndefined(obj) { + return obj === void 0; + } + + // Is a given value a boolean? + function isBoolean(obj) { + return obj === true || obj === false || toString.call(obj) === '[object Boolean]'; + } + + // Is a given value a DOM element? + function isElement(obj) { + return !!(obj && obj.nodeType === 1); + } + + // Internal function for creating a `toString`-based type tester. + function tagTester(name) { + var tag = '[object ' + name + ']'; + return function(obj) { + return toString.call(obj) === tag; + }; + } + + var isString = tagTester('String'); + + var isNumber = tagTester('Number'); + + var isDate = tagTester('Date'); + + var isRegExp = tagTester('RegExp'); + + var isError = tagTester('Error'); + + var isSymbol = tagTester('Symbol'); + + var isArrayBuffer = tagTester('ArrayBuffer'); + + var isFunction = tagTester('Function'); + + // Optimize `isFunction` if appropriate. Work around some `typeof` bugs in old + // v8, IE 11 (#1621), Safari 8 (#1929), and PhantomJS (#2236). + var nodelist = root.document && root.document.childNodes; + if (typeof /./ != 'function' && typeof Int8Array != 'object' && typeof nodelist != 'function') { + isFunction = function(obj) { + return typeof obj == 'function' || false; + }; + } + + var isFunction$1 = isFunction; + + var hasObjectTag = tagTester('Object'); + + // In IE 10 - Edge 13, `DataView` has string tag `'[object Object]'`. + // In IE 11, the most common among them, this problem also applies to + // `Map`, `WeakMap` and `Set`. + var hasStringTagBug = ( + supportsDataView && hasObjectTag(new DataView(new ArrayBuffer(8))) + ), + isIE11 = (typeof Map !== 'undefined' && hasObjectTag(new Map)); + + var isDataView = tagTester('DataView'); + + // In IE 10 - Edge 13, we need a different heuristic + // to determine whether an object is a `DataView`. + function ie10IsDataView(obj) { + return obj != null && isFunction$1(obj.getInt8) && isArrayBuffer(obj.buffer); + } + + var isDataView$1 = (hasStringTagBug ? ie10IsDataView : isDataView); + + // Is a given value an array? + // Delegates to ECMA5's native `Array.isArray`. + var isArray = nativeIsArray || tagTester('Array'); + + // Internal function to check whether `key` is an own property name of `obj`. + function has(obj, key) { + return obj != null && hasOwnProperty.call(obj, key); + } + + var isArguments = tagTester('Arguments'); + + // Define a fallback version of the method in browsers (ahem, IE < 9), where + // there isn't any inspectable "Arguments" type. + (function() { + if (!isArguments(arguments)) { + isArguments = function(obj) { + return has(obj, 'callee'); + }; + } + }()); + + var isArguments$1 = isArguments; + + // Is a given object a finite number? + function isFinite$1(obj) { + return !isSymbol(obj) && _isFinite(obj) && !isNaN(parseFloat(obj)); + } + + // Is the given value `NaN`? + function isNaN$1(obj) { + return isNumber(obj) && _isNaN(obj); + } + + // Predicate-generating function. Often useful outside of Underscore. + function constant(value) { + return function() { + return value; + }; + } + + // Common internal logic for `isArrayLike` and `isBufferLike`. + function createSizePropertyCheck(getSizeProperty) { + return function(collection) { + var sizeProperty = getSizeProperty(collection); + return typeof sizeProperty == 'number' && sizeProperty >= 0 && sizeProperty <= MAX_ARRAY_INDEX; + } + } + + // Internal helper to generate a function to obtain property `key` from `obj`. + function shallowProperty(key) { + return function(obj) { + return obj == null ? void 0 : obj[key]; + }; + } + + // Internal helper to obtain the `byteLength` property of an object. + var getByteLength = shallowProperty('byteLength'); + + // Internal helper to determine whether we should spend extensive checks against + // `ArrayBuffer` et al. + var isBufferLike = createSizePropertyCheck(getByteLength); + + // Is a given value a typed array? + var typedArrayPattern = /\[object ((I|Ui)nt(8|16|32)|Float(32|64)|Uint8Clamped|Big(I|Ui)nt64)Array\]/; + function isTypedArray(obj) { + // `ArrayBuffer.isView` is the most future-proof, so use it when available. + // Otherwise, fall back on the above regular expression. + return nativeIsView ? (nativeIsView(obj) && !isDataView$1(obj)) : + isBufferLike(obj) && typedArrayPattern.test(toString.call(obj)); + } + + var isTypedArray$1 = supportsArrayBuffer ? isTypedArray : constant(false); + + // Internal helper to obtain the `length` property of an object. + var getLength = shallowProperty('length'); + + // Internal helper to create a simple lookup structure. + // `collectNonEnumProps` used to depend on `_.contains`, but this led to + // circular imports. `emulatedSet` is a one-off solution that only works for + // arrays of strings. + function emulatedSet(keys) { + var hash = {}; + for (var l = keys.length, i = 0; i < l; ++i) hash[keys[i]] = true; + return { + contains: function(key) { return hash[key]; }, + push: function(key) { + hash[key] = true; + return keys.push(key); + } + }; + } + + // Internal helper. Checks `keys` for the presence of keys in IE < 9 that won't + // be iterated by `for key in ...` and thus missed. Extends `keys` in place if + // needed. + function collectNonEnumProps(obj, keys) { + keys = emulatedSet(keys); + var nonEnumIdx = nonEnumerableProps.length; + var constructor = obj.constructor; + var proto = isFunction$1(constructor) && constructor.prototype || ObjProto; + + // Constructor is a special case. + var prop = 'constructor'; + if (has(obj, prop) && !keys.contains(prop)) keys.push(prop); + + while (nonEnumIdx--) { + prop = nonEnumerableProps[nonEnumIdx]; + if (prop in obj && obj[prop] !== proto[prop] && !keys.contains(prop)) { + keys.push(prop); + } + } + } + + // Retrieve the names of an object's own properties. + // Delegates to **ECMAScript 5**'s native `Object.keys`. + function keys(obj) { + if (!isObject(obj)) return []; + if (nativeKeys) return nativeKeys(obj); + var keys = []; + for (var key in obj) if (has(obj, key)) keys.push(key); + // Ahem, IE < 9. + if (hasEnumBug) collectNonEnumProps(obj, keys); + return keys; + } + + // Is a given array, string, or object empty? + // An "empty" object has no enumerable own-properties. + function isEmpty(obj) { + if (obj == null) return true; + // Skip the more expensive `toString`-based type checks if `obj` has no + // `.length`. + var length = getLength(obj); + if (typeof length == 'number' && ( + isArray(obj) || isString(obj) || isArguments$1(obj) + )) return length === 0; + return getLength(keys(obj)) === 0; + } + + // Returns whether an object has a given set of `key:value` pairs. + function isMatch(object, attrs) { + var _keys = keys(attrs), length = _keys.length; + if (object == null) return !length; + var obj = Object(object); + for (var i = 0; i < length; i++) { + var key = _keys[i]; + if (attrs[key] !== obj[key] || !(key in obj)) return false; + } + return true; + } + + // If Underscore is called as a function, it returns a wrapped object that can + // be used OO-style. This wrapper holds altered versions of all functions added + // through `_.mixin`. Wrapped objects may be chained. + function _(obj) { + if (obj instanceof _) return obj; + if (!(this instanceof _)) return new _(obj); + this._wrapped = obj; + } + + _.VERSION = VERSION; + + // Extracts the result from a wrapped and chained object. + _.prototype.value = function() { + return this._wrapped; + }; + + // Provide unwrapping proxies for some methods used in engine operations + // such as arithmetic and JSON stringification. + _.prototype.valueOf = _.prototype.toJSON = _.prototype.value; + + _.prototype.toString = function() { + return String(this._wrapped); + }; + + // Internal function to wrap or shallow-copy an ArrayBuffer, + // typed array or DataView to a new view, reusing the buffer. + function toBufferView(bufferSource) { + return new Uint8Array( + bufferSource.buffer || bufferSource, + bufferSource.byteOffset || 0, + getByteLength(bufferSource) + ); + } + + // We use this string twice, so give it a name for minification. + var tagDataView = '[object DataView]'; + + // Internal recursive comparison function for `_.isEqual`. + function eq(a, b, aStack, bStack) { + // Identical objects are equal. `0 === -0`, but they aren't identical. + // See the [Harmony `egal` proposal](https://wiki.ecmascript.org/doku.php?id=harmony:egal). + if (a === b) return a !== 0 || 1 / a === 1 / b; + // `null` or `undefined` only equal to itself (strict comparison). + if (a == null || b == null) return false; + // `NaN`s are equivalent, but non-reflexive. + if (a !== a) return b !== b; + // Exhaust primitive checks + var type = typeof a; + if (type !== 'function' && type !== 'object' && typeof b != 'object') return false; + return deepEq(a, b, aStack, bStack); + } + + // Internal recursive comparison function for `_.isEqual`. + function deepEq(a, b, aStack, bStack) { + // Unwrap any wrapped objects. + if (a instanceof _) a = a._wrapped; + if (b instanceof _) b = b._wrapped; + // Compare `[[Class]]` names. + var className = toString.call(a); + if (className !== toString.call(b)) return false; + // Work around a bug in IE 10 - Edge 13. + if (hasStringTagBug && className == '[object Object]' && isDataView$1(a)) { + if (!isDataView$1(b)) return false; + className = tagDataView; + } + switch (className) { + // These types are compared by value. + case '[object RegExp]': + // RegExps are coerced to strings for comparison (Note: '' + /a/i === '/a/i') + case '[object String]': + // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is + // equivalent to `new String("5")`. + return '' + a === '' + b; + case '[object Number]': + // `NaN`s are equivalent, but non-reflexive. + // Object(NaN) is equivalent to NaN. + if (+a !== +a) return +b !== +b; + // An `egal` comparison is performed for other numeric values. + return +a === 0 ? 1 / +a === 1 / b : +a === +b; + case '[object Date]': + case '[object Boolean]': + // Coerce dates and booleans to numeric primitive values. Dates are compared by their + // millisecond representations. Note that invalid dates with millisecond representations + // of `NaN` are not equivalent. + return +a === +b; + case '[object Symbol]': + return SymbolProto.valueOf.call(a) === SymbolProto.valueOf.call(b); + case '[object ArrayBuffer]': + case tagDataView: + // Coerce to typed array so we can fall through. + return deepEq(toBufferView(a), toBufferView(b), aStack, bStack); + } + + var areArrays = className === '[object Array]'; + if (!areArrays && isTypedArray$1(a)) { + var byteLength = getByteLength(a); + if (byteLength !== getByteLength(b)) return false; + if (a.buffer === b.buffer && a.byteOffset === b.byteOffset) return true; + areArrays = true; + } + if (!areArrays) { + if (typeof a != 'object' || typeof b != 'object') return false; + + // Objects with different constructors are not equivalent, but `Object`s or `Array`s + // from different frames are. + var aCtor = a.constructor, bCtor = b.constructor; + if (aCtor !== bCtor && !(isFunction$1(aCtor) && aCtor instanceof aCtor && + isFunction$1(bCtor) && bCtor instanceof bCtor) + && ('constructor' in a && 'constructor' in b)) { + return false; + } + } + // Assume equality for cyclic structures. The algorithm for detecting cyclic + // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`. + + // Initializing stack of traversed objects. + // It's done here since we only need them for objects and arrays comparison. + aStack = aStack || []; + bStack = bStack || []; + var length = aStack.length; + while (length--) { + // Linear search. Performance is inversely proportional to the number of + // unique nested structures. + if (aStack[length] === a) return bStack[length] === b; + } + + // Add the first object to the stack of traversed objects. + aStack.push(a); + bStack.push(b); + + // Recursively compare objects and arrays. + if (areArrays) { + // Compare array lengths to determine if a deep comparison is necessary. + length = a.length; + if (length !== b.length) return false; + // Deep compare the contents, ignoring non-numeric properties. + while (length--) { + if (!eq(a[length], b[length], aStack, bStack)) return false; + } + } else { + // Deep compare objects. + var _keys = keys(a), key; + length = _keys.length; + // Ensure that both objects contain the same number of properties before comparing deep equality. + if (keys(b).length !== length) return false; + while (length--) { + // Deep compare each member + key = _keys[length]; + if (!(has(b, key) && eq(a[key], b[key], aStack, bStack))) return false; + } + } + // Remove the first object from the stack of traversed objects. + aStack.pop(); + bStack.pop(); + return true; + } + + // Perform a deep comparison to check if two objects are equal. + function isEqual(a, b) { + return eq(a, b); + } + + // Retrieve all the enumerable property names of an object. + function allKeys(obj) { + if (!isObject(obj)) return []; + var keys = []; + for (var key in obj) keys.push(key); + // Ahem, IE < 9. + if (hasEnumBug) collectNonEnumProps(obj, keys); + return keys; + } + + // Since the regular `Object.prototype.toString` type tests don't work for + // some types in IE 11, we use a fingerprinting heuristic instead, based + // on the methods. It's not great, but it's the best we got. + // The fingerprint method lists are defined below. + function ie11fingerprint(methods) { + var length = getLength(methods); + return function(obj) { + if (obj == null) return false; + // `Map`, `WeakMap` and `Set` have no enumerable keys. + var keys = allKeys(obj); + if (getLength(keys)) return false; + for (var i = 0; i < length; i++) { + if (!isFunction$1(obj[methods[i]])) return false; + } + // If we are testing against `WeakMap`, we need to ensure that + // `obj` doesn't have a `forEach` method in order to distinguish + // it from a regular `Map`. + return methods !== weakMapMethods || !isFunction$1(obj[forEachName]); + }; + } + + // In the interest of compact minification, we write + // each string in the fingerprints only once. + var forEachName = 'forEach', + hasName = 'has', + commonInit = ['clear', 'delete'], + mapTail = ['get', hasName, 'set']; + + // `Map`, `WeakMap` and `Set` each have slightly different + // combinations of the above sublists. + var mapMethods = commonInit.concat(forEachName, mapTail), + weakMapMethods = commonInit.concat(mapTail), + setMethods = ['add'].concat(commonInit, forEachName, hasName); + + var isMap = isIE11 ? ie11fingerprint(mapMethods) : tagTester('Map'); + + var isWeakMap = isIE11 ? ie11fingerprint(weakMapMethods) : tagTester('WeakMap'); + + var isSet = isIE11 ? ie11fingerprint(setMethods) : tagTester('Set'); + + var isWeakSet = tagTester('WeakSet'); + + // Retrieve the values of an object's properties. + function values(obj) { + var _keys = keys(obj); + var length = _keys.length; + var values = Array(length); + for (var i = 0; i < length; i++) { + values[i] = obj[_keys[i]]; + } + return values; + } + + // Convert an object into a list of `[key, value]` pairs. + // The opposite of `_.object` with one argument. + function pairs(obj) { + var _keys = keys(obj); + var length = _keys.length; + var pairs = Array(length); + for (var i = 0; i < length; i++) { + pairs[i] = [_keys[i], obj[_keys[i]]]; + } + return pairs; + } + + // Invert the keys and values of an object. The values must be serializable. + function invert(obj) { + var result = {}; + var _keys = keys(obj); + for (var i = 0, length = _keys.length; i < length; i++) { + result[obj[_keys[i]]] = _keys[i]; + } + return result; + } + + // Return a sorted list of the function names available on the object. + function functions(obj) { + var names = []; + for (var key in obj) { + if (isFunction$1(obj[key])) names.push(key); + } + return names.sort(); + } + + // An internal function for creating assigner functions. + function createAssigner(keysFunc, defaults) { + return function(obj) { + var length = arguments.length; + if (defaults) obj = Object(obj); + if (length < 2 || obj == null) return obj; + for (var index = 1; index < length; index++) { + var source = arguments[index], + keys = keysFunc(source), + l = keys.length; + for (var i = 0; i < l; i++) { + var key = keys[i]; + if (!defaults || obj[key] === void 0) obj[key] = source[key]; + } + } + return obj; + }; + } + + // Extend a given object with all the properties in passed-in object(s). + var extend = createAssigner(allKeys); + + // Assigns a given object with all the own properties in the passed-in + // object(s). + // (https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) + var extendOwn = createAssigner(keys); + + // Fill in a given object with default properties. + var defaults = createAssigner(allKeys, true); + + // Create a naked function reference for surrogate-prototype-swapping. + function ctor() { + return function(){}; + } + + // An internal function for creating a new object that inherits from another. + function baseCreate(prototype) { + if (!isObject(prototype)) return {}; + if (nativeCreate) return nativeCreate(prototype); + var Ctor = ctor(); + Ctor.prototype = prototype; + var result = new Ctor; + Ctor.prototype = null; + return result; + } + + // Creates an object that inherits from the given prototype object. + // If additional properties are provided then they will be added to the + // created object. + function create(prototype, props) { + var result = baseCreate(prototype); + if (props) extendOwn(result, props); + return result; + } + + // Create a (shallow-cloned) duplicate of an object. + function clone(obj) { + if (!isObject(obj)) return obj; + return isArray(obj) ? obj.slice() : extend({}, obj); + } + + // Invokes `interceptor` with the `obj` and then returns `obj`. + // The primary purpose of this method is to "tap into" a method chain, in + // order to perform operations on intermediate results within the chain. + function tap(obj, interceptor) { + interceptor(obj); + return obj; + } + + // Normalize a (deep) property `path` to array. + // Like `_.iteratee`, this function can be customized. + function toPath(path) { + return isArray(path) ? path : [path]; + } + _.toPath = toPath; + + // Internal wrapper for `_.toPath` to enable minification. + // Similar to `cb` for `_.iteratee`. + function toPath$1(path) { + return _.toPath(path); + } + + // Internal function to obtain a nested property in `obj` along `path`. + function deepGet(obj, path) { + var length = path.length; + for (var i = 0; i < length; i++) { + if (obj == null) return void 0; + obj = obj[path[i]]; + } + return length ? obj : void 0; + } + + // Get the value of the (deep) property on `path` from `object`. + // If any property in `path` does not exist or if the value is + // `undefined`, return `defaultValue` instead. + // The `path` is normalized through `_.toPath`. + function get(object, path, defaultValue) { + var value = deepGet(object, toPath$1(path)); + return isUndefined(value) ? defaultValue : value; + } + + // Shortcut function for checking if an object has a given property directly on + // itself (in other words, not on a prototype). Unlike the internal `has` + // function, this public version can also traverse nested properties. + function has$1(obj, path) { + path = toPath$1(path); + var length = path.length; + for (var i = 0; i < length; i++) { + var key = path[i]; + if (!has(obj, key)) return false; + obj = obj[key]; + } + return !!length; + } + + // Keep the identity function around for default iteratees. + function identity(value) { + return value; + } + + // Returns a predicate for checking whether an object has a given set of + // `key:value` pairs. + function matcher(attrs) { + attrs = extendOwn({}, attrs); + return function(obj) { + return isMatch(obj, attrs); + }; + } + + // Creates a function that, when passed an object, will traverse that object’s + // properties down the given `path`, specified as an array of keys or indices. + function property(path) { + path = toPath$1(path); + return function(obj) { + return deepGet(obj, path); + }; + } + + // Internal function that returns an efficient (for current engines) version + // of the passed-in callback, to be repeatedly applied in other Underscore + // functions. + function optimizeCb(func, context, argCount) { + if (context === void 0) return func; + switch (argCount == null ? 3 : argCount) { + case 1: return function(value) { + return func.call(context, value); + }; + // The 2-argument case is omitted because we’re not using it. + case 3: return function(value, index, collection) { + return func.call(context, value, index, collection); + }; + case 4: return function(accumulator, value, index, collection) { + return func.call(context, accumulator, value, index, collection); + }; + } + return function() { + return func.apply(context, arguments); + }; + } + + // An internal function to generate callbacks that can be applied to each + // element in a collection, returning the desired result — either `_.identity`, + // an arbitrary callback, a property matcher, or a property accessor. + function baseIteratee(value, context, argCount) { + if (value == null) return identity; + if (isFunction$1(value)) return optimizeCb(value, context, argCount); + if (isObject(value) && !isArray(value)) return matcher(value); + return property(value); + } + + // External wrapper for our callback generator. Users may customize + // `_.iteratee` if they want additional predicate/iteratee shorthand styles. + // This abstraction hides the internal-only `argCount` argument. + function iteratee(value, context) { + return baseIteratee(value, context, Infinity); + } + _.iteratee = iteratee; + + // The function we call internally to generate a callback. It invokes + // `_.iteratee` if overridden, otherwise `baseIteratee`. + function cb(value, context, argCount) { + if (_.iteratee !== iteratee) return _.iteratee(value, context); + return baseIteratee(value, context, argCount); + } + + // Returns the results of applying the `iteratee` to each element of `obj`. + // In contrast to `_.map` it returns an object. + function mapObject(obj, iteratee, context) { + iteratee = cb(iteratee, context); + var _keys = keys(obj), + length = _keys.length, + results = {}; + for (var index = 0; index < length; index++) { + var currentKey = _keys[index]; + results[currentKey] = iteratee(obj[currentKey], currentKey, obj); + } + return results; + } + + // Predicate-generating function. Often useful outside of Underscore. + function noop(){} + + // Generates a function for a given object that returns a given property. + function propertyOf(obj) { + if (obj == null) return noop; + return function(path) { + return get(obj, path); + }; + } + + // Run a function **n** times. + function times(n, iteratee, context) { + var accum = Array(Math.max(0, n)); + iteratee = optimizeCb(iteratee, context, 1); + for (var i = 0; i < n; i++) accum[i] = iteratee(i); + return accum; + } + + // Return a random integer between `min` and `max` (inclusive). + function random(min, max) { + if (max == null) { + max = min; + min = 0; + } + return min + Math.floor(Math.random() * (max - min + 1)); + } + + // A (possibly faster) way to get the current timestamp as an integer. + var now = Date.now || function() { + return new Date().getTime(); + }; + + // Internal helper to generate functions for escaping and unescaping strings + // to/from HTML interpolation. + function createEscaper(map) { + var escaper = function(match) { + return map[match]; + }; + // Regexes for identifying a key that needs to be escaped. + var source = '(?:' + keys(map).join('|') + ')'; + var testRegexp = RegExp(source); + var replaceRegexp = RegExp(source, 'g'); + return function(string) { + string = string == null ? '' : '' + string; + return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string; + }; + } + + // Internal list of HTML entities for escaping. + var escapeMap = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + "'": ''', + '`': '`' + }; + + // Function for escaping strings to HTML interpolation. + var _escape = createEscaper(escapeMap); + + // Internal list of HTML entities for unescaping. + var unescapeMap = invert(escapeMap); + + // Function for unescaping strings from HTML interpolation. + var _unescape = createEscaper(unescapeMap); + + // By default, Underscore uses ERB-style template delimiters. Change the + // following template settings to use alternative delimiters. + var templateSettings = _.templateSettings = { + evaluate: /<%([\s\S]+?)%>/g, + interpolate: /<%=([\s\S]+?)%>/g, + escape: /<%-([\s\S]+?)%>/g + }; + + // When customizing `_.templateSettings`, if you don't want to define an + // interpolation, evaluation or escaping regex, we need one that is + // guaranteed not to match. + var noMatch = /(.)^/; + + // Certain characters need to be escaped so that they can be put into a + // string literal. + var escapes = { + "'": "'", + '\\': '\\', + '\r': 'r', + '\n': 'n', + '\u2028': 'u2028', + '\u2029': 'u2029' + }; + + var escapeRegExp = /\\|'|\r|\n|\u2028|\u2029/g; + + function escapeChar(match) { + return '\\' + escapes[match]; + } + + // JavaScript micro-templating, similar to John Resig's implementation. + // Underscore templating handles arbitrary delimiters, preserves whitespace, + // and correctly escapes quotes within interpolated code. + // NB: `oldSettings` only exists for backwards compatibility. + function template(text, settings, oldSettings) { + if (!settings && oldSettings) settings = oldSettings; + settings = defaults({}, settings, _.templateSettings); + + // Combine delimiters into one regular expression via alternation. + var matcher = RegExp([ + (settings.escape || noMatch).source, + (settings.interpolate || noMatch).source, + (settings.evaluate || noMatch).source + ].join('|') + '|$', 'g'); + + // Compile the template source, escaping string literals appropriately. + var index = 0; + var source = "__p+='"; + text.replace(matcher, function(match, escape, interpolate, evaluate, offset) { + source += text.slice(index, offset).replace(escapeRegExp, escapeChar); + index = offset + match.length; + + if (escape) { + source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'"; + } else if (interpolate) { + source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'"; + } else if (evaluate) { + source += "';\n" + evaluate + "\n__p+='"; + } + + // Adobe VMs need the match returned to produce the correct offset. + return match; + }); + source += "';\n"; + + // If a variable is not specified, place data values in local scope. + if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n'; + + source = "var __t,__p='',__j=Array.prototype.join," + + "print=function(){__p+=__j.call(arguments,'');};\n" + + source + 'return __p;\n'; + + var render; + try { + render = new Function(settings.variable || 'obj', '_', source); + } catch (e) { + e.source = source; + throw e; + } + + var template = function(data) { + return render.call(this, data, _); + }; + + // Provide the compiled source as a convenience for precompilation. + var argument = settings.variable || 'obj'; + template.source = 'function(' + argument + '){\n' + source + '}'; + + return template; + } + + // Traverses the children of `obj` along `path`. If a child is a function, it + // is invoked with its parent as context. Returns the value of the final + // child, or `fallback` if any child is undefined. + function result(obj, path, fallback) { + path = toPath$1(path); + var length = path.length; + if (!length) { + return isFunction$1(fallback) ? fallback.call(obj) : fallback; + } + for (var i = 0; i < length; i++) { + var prop = obj == null ? void 0 : obj[path[i]]; + if (prop === void 0) { + prop = fallback; + i = length; // Ensure we don't continue iterating. + } + obj = isFunction$1(prop) ? prop.call(obj) : prop; + } + return obj; + } + + // Generate a unique integer id (unique within the entire client session). + // Useful for temporary DOM ids. + var idCounter = 0; + function uniqueId(prefix) { + var id = ++idCounter + ''; + return prefix ? prefix + id : id; + } + + // Start chaining a wrapped Underscore object. + function chain(obj) { + var instance = _(obj); + instance._chain = true; + return instance; + } + + // Internal function to execute `sourceFunc` bound to `context` with optional + // `args`. Determines whether to execute a function as a constructor or as a + // normal function. + function executeBound(sourceFunc, boundFunc, context, callingContext, args) { + if (!(callingContext instanceof boundFunc)) return sourceFunc.apply(context, args); + var self = baseCreate(sourceFunc.prototype); + var result = sourceFunc.apply(self, args); + if (isObject(result)) return result; + return self; + } + + // Partially apply a function by creating a version that has had some of its + // arguments pre-filled, without changing its dynamic `this` context. `_` acts + // as a placeholder by default, allowing any combination of arguments to be + // pre-filled. Set `_.partial.placeholder` for a custom placeholder argument. + var partial = restArguments(function(func, boundArgs) { + var placeholder = partial.placeholder; + var bound = function() { + var position = 0, length = boundArgs.length; + var args = Array(length); + for (var i = 0; i < length; i++) { + args[i] = boundArgs[i] === placeholder ? arguments[position++] : boundArgs[i]; + } + while (position < arguments.length) args.push(arguments[position++]); + return executeBound(func, bound, this, this, args); + }; + return bound; + }); + + partial.placeholder = _; + + // Create a function bound to a given object (assigning `this`, and arguments, + // optionally). + var bind = restArguments(function(func, context, args) { + if (!isFunction$1(func)) throw new TypeError('Bind must be called on a function'); + var bound = restArguments(function(callArgs) { + return executeBound(func, bound, context, this, args.concat(callArgs)); + }); + return bound; + }); + + // Internal helper for collection methods to determine whether a collection + // should be iterated as an array or as an object. + // Related: https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength + // Avoids a very nasty iOS 8 JIT bug on ARM-64. #2094 + var isArrayLike = createSizePropertyCheck(getLength); + + // Internal implementation of a recursive `flatten` function. + function flatten(input, depth, strict, output) { + output = output || []; + if (!depth && depth !== 0) { + depth = Infinity; + } else if (depth <= 0) { + return output.concat(input); + } + var idx = output.length; + for (var i = 0, length = getLength(input); i < length; i++) { + var value = input[i]; + if (isArrayLike(value) && (isArray(value) || isArguments$1(value))) { + // Flatten current level of array or arguments object. + if (depth > 1) { + flatten(value, depth - 1, strict, output); + idx = output.length; + } else { + var j = 0, len = value.length; + while (j < len) output[idx++] = value[j++]; + } + } else if (!strict) { + output[idx++] = value; + } + } + return output; + } + + // Bind a number of an object's methods to that object. Remaining arguments + // are the method names to be bound. Useful for ensuring that all callbacks + // defined on an object belong to it. + var bindAll = restArguments(function(obj, keys) { + keys = flatten(keys, false, false); + var index = keys.length; + if (index < 1) throw new Error('bindAll must be passed function names'); + while (index--) { + var key = keys[index]; + obj[key] = bind(obj[key], obj); + } + return obj; + }); + + // Memoize an expensive function by storing its results. + function memoize(func, hasher) { + var memoize = function(key) { + var cache = memoize.cache; + var address = '' + (hasher ? hasher.apply(this, arguments) : key); + if (!has(cache, address)) cache[address] = func.apply(this, arguments); + return cache[address]; + }; + memoize.cache = {}; + return memoize; + } + + // Delays a function for the given number of milliseconds, and then calls + // it with the arguments supplied. + var delay = restArguments(function(func, wait, args) { + return setTimeout(function() { + return func.apply(null, args); + }, wait); + }); + + // Defers a function, scheduling it to run after the current call stack has + // cleared. + var defer = partial(delay, _, 1); + + // Returns a function, that, when invoked, will only be triggered at most once + // during a given window of time. Normally, the throttled function will run + // as much as it can, without ever going more than once per `wait` duration; + // but if you'd like to disable the execution on the leading edge, pass + // `{leading: false}`. To disable execution on the trailing edge, ditto. + function throttle(func, wait, options) { + var timeout, context, args, result; + var previous = 0; + if (!options) options = {}; + + var later = function() { + previous = options.leading === false ? 0 : now(); + timeout = null; + result = func.apply(context, args); + if (!timeout) context = args = null; + }; + + var throttled = function() { + var _now = now(); + if (!previous && options.leading === false) previous = _now; + var remaining = wait - (_now - previous); + context = this; + args = arguments; + if (remaining <= 0 || remaining > wait) { + if (timeout) { + clearTimeout(timeout); + timeout = null; + } + previous = _now; + result = func.apply(context, args); + if (!timeout) context = args = null; + } else if (!timeout && options.trailing !== false) { + timeout = setTimeout(later, remaining); + } + return result; + }; + + throttled.cancel = function() { + clearTimeout(timeout); + previous = 0; + timeout = context = args = null; + }; + + return throttled; + } + + // When a sequence of calls of the returned function ends, the argument + // function is triggered. The end of a sequence is defined by the `wait` + // parameter. If `immediate` is passed, the argument function will be + // triggered at the beginning of the sequence instead of at the end. + function debounce(func, wait, immediate) { + var timeout, previous, args, result, context; + + var later = function() { + var passed = now() - previous; + if (wait > passed) { + timeout = setTimeout(later, wait - passed); + } else { + timeout = null; + if (!immediate) result = func.apply(context, args); + // This check is needed because `func` can recursively invoke `debounced`. + if (!timeout) args = context = null; + } + }; + + var debounced = restArguments(function(_args) { + context = this; + args = _args; + previous = now(); + if (!timeout) { + timeout = setTimeout(later, wait); + if (immediate) result = func.apply(context, args); + } + return result; + }); + + debounced.cancel = function() { + clearTimeout(timeout); + timeout = args = context = null; + }; + + return debounced; + } + + // Returns the first function passed as an argument to the second, + // allowing you to adjust arguments, run code before and after, and + // conditionally execute the original function. + function wrap(func, wrapper) { + return partial(wrapper, func); + } + + // Returns a negated version of the passed-in predicate. + function negate(predicate) { + return function() { + return !predicate.apply(this, arguments); + }; + } + + // Returns a function that is the composition of a list of functions, each + // consuming the return value of the function that follows. + function compose() { + var args = arguments; + var start = args.length - 1; + return function() { + var i = start; + var result = args[start].apply(this, arguments); + while (i--) result = args[i].call(this, result); + return result; + }; + } + + // Returns a function that will only be executed on and after the Nth call. + function after(times, func) { + return function() { + if (--times < 1) { + return func.apply(this, arguments); + } + }; + } + + // Returns a function that will only be executed up to (but not including) the + // Nth call. + function before(times, func) { + var memo; + return function() { + if (--times > 0) { + memo = func.apply(this, arguments); + } + if (times <= 1) func = null; + return memo; + }; + } + + // Returns a function that will be executed at most one time, no matter how + // often you call it. Useful for lazy initialization. + var once = partial(before, 2); + + // Returns the first key on an object that passes a truth test. + function findKey(obj, predicate, context) { + predicate = cb(predicate, context); + var _keys = keys(obj), key; + for (var i = 0, length = _keys.length; i < length; i++) { + key = _keys[i]; + if (predicate(obj[key], key, obj)) return key; + } + } + + // Internal function to generate `_.findIndex` and `_.findLastIndex`. + function createPredicateIndexFinder(dir) { + return function(array, predicate, context) { + predicate = cb(predicate, context); + var length = getLength(array); + var index = dir > 0 ? 0 : length - 1; + for (; index >= 0 && index < length; index += dir) { + if (predicate(array[index], index, array)) return index; + } + return -1; + }; + } + + // Returns the first index on an array-like that passes a truth test. + var findIndex = createPredicateIndexFinder(1); + + // Returns the last index on an array-like that passes a truth test. + var findLastIndex = createPredicateIndexFinder(-1); + + // Use a comparator function to figure out the smallest index at which + // an object should be inserted so as to maintain order. Uses binary search. + function sortedIndex(array, obj, iteratee, context) { + iteratee = cb(iteratee, context, 1); + var value = iteratee(obj); + var low = 0, high = getLength(array); + while (low < high) { + var mid = Math.floor((low + high) / 2); + if (iteratee(array[mid]) < value) low = mid + 1; else high = mid; + } + return low; + } + + // Internal function to generate the `_.indexOf` and `_.lastIndexOf` functions. + function createIndexFinder(dir, predicateFind, sortedIndex) { + return function(array, item, idx) { + var i = 0, length = getLength(array); + if (typeof idx == 'number') { + if (dir > 0) { + i = idx >= 0 ? idx : Math.max(idx + length, i); + } else { + length = idx >= 0 ? Math.min(idx + 1, length) : idx + length + 1; + } + } else if (sortedIndex && idx && length) { + idx = sortedIndex(array, item); + return array[idx] === item ? idx : -1; + } + if (item !== item) { + idx = predicateFind(slice.call(array, i, length), isNaN$1); + return idx >= 0 ? idx + i : -1; + } + for (idx = dir > 0 ? i : length - 1; idx >= 0 && idx < length; idx += dir) { + if (array[idx] === item) return idx; + } + return -1; + }; + } + + // Return the position of the first occurrence of an item in an array, + // or -1 if the item is not included in the array. + // If the array is large and already in sort order, pass `true` + // for **isSorted** to use binary search. + var indexOf = createIndexFinder(1, findIndex, sortedIndex); + + // Return the position of the last occurrence of an item in an array, + // or -1 if the item is not included in the array. + var lastIndexOf = createIndexFinder(-1, findLastIndex); + + // Return the first value which passes a truth test. + function find(obj, predicate, context) { + var keyFinder = isArrayLike(obj) ? findIndex : findKey; + var key = keyFinder(obj, predicate, context); + if (key !== void 0 && key !== -1) return obj[key]; + } + + // Convenience version of a common use case of `_.find`: getting the first + // object containing specific `key:value` pairs. + function findWhere(obj, attrs) { + return find(obj, matcher(attrs)); + } + + // The cornerstone for collection functions, an `each` + // implementation, aka `forEach`. + // Handles raw objects in addition to array-likes. Treats all + // sparse array-likes as if they were dense. + function each(obj, iteratee, context) { + iteratee = optimizeCb(iteratee, context); + var i, length; + if (isArrayLike(obj)) { + for (i = 0, length = obj.length; i < length; i++) { + iteratee(obj[i], i, obj); + } + } else { + var _keys = keys(obj); + for (i = 0, length = _keys.length; i < length; i++) { + iteratee(obj[_keys[i]], _keys[i], obj); + } + } + return obj; + } + + // Return the results of applying the iteratee to each element. + function map(obj, iteratee, context) { + iteratee = cb(iteratee, context); + var _keys = !isArrayLike(obj) && keys(obj), + length = (_keys || obj).length, + results = Array(length); + for (var index = 0; index < length; index++) { + var currentKey = _keys ? _keys[index] : index; + results[index] = iteratee(obj[currentKey], currentKey, obj); + } + return results; + } + + // Internal helper to create a reducing function, iterating left or right. + function createReduce(dir) { + // Wrap code that reassigns argument variables in a separate function than + // the one that accesses `arguments.length` to avoid a perf hit. (#1991) + var reducer = function(obj, iteratee, memo, initial) { + var _keys = !isArrayLike(obj) && keys(obj), + length = (_keys || obj).length, + index = dir > 0 ? 0 : length - 1; + if (!initial) { + memo = obj[_keys ? _keys[index] : index]; + index += dir; + } + for (; index >= 0 && index < length; index += dir) { + var currentKey = _keys ? _keys[index] : index; + memo = iteratee(memo, obj[currentKey], currentKey, obj); + } + return memo; + }; + + return function(obj, iteratee, memo, context) { + var initial = arguments.length >= 3; + return reducer(obj, optimizeCb(iteratee, context, 4), memo, initial); + }; + } + + // **Reduce** builds up a single result from a list of values, aka `inject`, + // or `foldl`. + var reduce = createReduce(1); + + // The right-associative version of reduce, also known as `foldr`. + var reduceRight = createReduce(-1); + + // Return all the elements that pass a truth test. + function filter(obj, predicate, context) { + var results = []; + predicate = cb(predicate, context); + each(obj, function(value, index, list) { + if (predicate(value, index, list)) results.push(value); + }); + return results; + } + + // Return all the elements for which a truth test fails. + function reject(obj, predicate, context) { + return filter(obj, negate(cb(predicate)), context); + } + + // Determine whether all of the elements pass a truth test. + function every(obj, predicate, context) { + predicate = cb(predicate, context); + var _keys = !isArrayLike(obj) && keys(obj), + length = (_keys || obj).length; + for (var index = 0; index < length; index++) { + var currentKey = _keys ? _keys[index] : index; + if (!predicate(obj[currentKey], currentKey, obj)) return false; + } + return true; + } + + // Determine if at least one element in the object passes a truth test. + function some(obj, predicate, context) { + predicate = cb(predicate, context); + var _keys = !isArrayLike(obj) && keys(obj), + length = (_keys || obj).length; + for (var index = 0; index < length; index++) { + var currentKey = _keys ? _keys[index] : index; + if (predicate(obj[currentKey], currentKey, obj)) return true; + } + return false; + } + + // Determine if the array or object contains a given item (using `===`). + function contains(obj, item, fromIndex, guard) { + if (!isArrayLike(obj)) obj = values(obj); + if (typeof fromIndex != 'number' || guard) fromIndex = 0; + return indexOf(obj, item, fromIndex) >= 0; + } + + // Invoke a method (with arguments) on every item in a collection. + var invoke = restArguments(function(obj, path, args) { + var contextPath, func; + if (isFunction$1(path)) { + func = path; + } else { + path = toPath$1(path); + contextPath = path.slice(0, -1); + path = path[path.length - 1]; + } + return map(obj, function(context) { + var method = func; + if (!method) { + if (contextPath && contextPath.length) { + context = deepGet(context, contextPath); + } + if (context == null) return void 0; + method = context[path]; + } + return method == null ? method : method.apply(context, args); + }); + }); + + // Convenience version of a common use case of `_.map`: fetching a property. + function pluck(obj, key) { + return map(obj, property(key)); + } + + // Convenience version of a common use case of `_.filter`: selecting only + // objects containing specific `key:value` pairs. + function where(obj, attrs) { + return filter(obj, matcher(attrs)); + } + + // Return the maximum element (or element-based computation). + function max(obj, iteratee, context) { + var result = -Infinity, lastComputed = -Infinity, + value, computed; + if (iteratee == null || typeof iteratee == 'number' && typeof obj[0] != 'object' && obj != null) { + obj = isArrayLike(obj) ? obj : values(obj); + for (var i = 0, length = obj.length; i < length; i++) { + value = obj[i]; + if (value != null && value > result) { + result = value; + } + } + } else { + iteratee = cb(iteratee, context); + each(obj, function(v, index, list) { + computed = iteratee(v, index, list); + if (computed > lastComputed || computed === -Infinity && result === -Infinity) { + result = v; + lastComputed = computed; + } + }); + } + return result; + } + + // Return the minimum element (or element-based computation). + function min(obj, iteratee, context) { + var result = Infinity, lastComputed = Infinity, + value, computed; + if (iteratee == null || typeof iteratee == 'number' && typeof obj[0] != 'object' && obj != null) { + obj = isArrayLike(obj) ? obj : values(obj); + for (var i = 0, length = obj.length; i < length; i++) { + value = obj[i]; + if (value != null && value < result) { + result = value; + } + } + } else { + iteratee = cb(iteratee, context); + each(obj, function(v, index, list) { + computed = iteratee(v, index, list); + if (computed < lastComputed || computed === Infinity && result === Infinity) { + result = v; + lastComputed = computed; + } + }); + } + return result; + } + + // Sample **n** random values from a collection using the modern version of the + // [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher–Yates_shuffle). + // If **n** is not specified, returns a single random element. + // The internal `guard` argument allows it to work with `_.map`. + function sample(obj, n, guard) { + if (n == null || guard) { + if (!isArrayLike(obj)) obj = values(obj); + return obj[random(obj.length - 1)]; + } + var sample = isArrayLike(obj) ? clone(obj) : values(obj); + var length = getLength(sample); + n = Math.max(Math.min(n, length), 0); + var last = length - 1; + for (var index = 0; index < n; index++) { + var rand = random(index, last); + var temp = sample[index]; + sample[index] = sample[rand]; + sample[rand] = temp; + } + return sample.slice(0, n); + } + + // Shuffle a collection. + function shuffle(obj) { + return sample(obj, Infinity); + } + + // Sort the object's values by a criterion produced by an iteratee. + function sortBy(obj, iteratee, context) { + var index = 0; + iteratee = cb(iteratee, context); + return pluck(map(obj, function(value, key, list) { + return { + value: value, + index: index++, + criteria: iteratee(value, key, list) + }; + }).sort(function(left, right) { + var a = left.criteria; + var b = right.criteria; + if (a !== b) { + if (a > b || a === void 0) return 1; + if (a < b || b === void 0) return -1; + } + return left.index - right.index; + }), 'value'); + } + + // An internal function used for aggregate "group by" operations. + function group(behavior, partition) { + return function(obj, iteratee, context) { + var result = partition ? [[], []] : {}; + iteratee = cb(iteratee, context); + each(obj, function(value, index) { + var key = iteratee(value, index, obj); + behavior(result, value, key); + }); + return result; + }; + } + + // Groups the object's values by a criterion. Pass either a string attribute + // to group by, or a function that returns the criterion. + var groupBy = group(function(result, value, key) { + if (has(result, key)) result[key].push(value); else result[key] = [value]; + }); + + // Indexes the object's values by a criterion, similar to `_.groupBy`, but for + // when you know that your index values will be unique. + var indexBy = group(function(result, value, key) { + result[key] = value; + }); + + // Counts instances of an object that group by a certain criterion. Pass + // either a string attribute to count by, or a function that returns the + // criterion. + var countBy = group(function(result, value, key) { + if (has(result, key)) result[key]++; else result[key] = 1; + }); + + // Split a collection into two arrays: one whose elements all pass the given + // truth test, and one whose elements all do not pass the truth test. + var partition = group(function(result, value, pass) { + result[pass ? 0 : 1].push(value); + }, true); + + // Safely create a real, live array from anything iterable. + var reStrSymbol = /[^\ud800-\udfff]|[\ud800-\udbff][\udc00-\udfff]|[\ud800-\udfff]/g; + function toArray(obj) { + if (!obj) return []; + if (isArray(obj)) return slice.call(obj); + if (isString(obj)) { + // Keep surrogate pair characters together. + return obj.match(reStrSymbol); + } + if (isArrayLike(obj)) return map(obj, identity); + return values(obj); + } + + // Return the number of elements in a collection. + function size(obj) { + if (obj == null) return 0; + return isArrayLike(obj) ? obj.length : keys(obj).length; + } + + // Internal `_.pick` helper function to determine whether `key` is an enumerable + // property name of `obj`. + function keyInObj(value, key, obj) { + return key in obj; + } + + // Return a copy of the object only containing the allowed properties. + var pick = restArguments(function(obj, keys) { + var result = {}, iteratee = keys[0]; + if (obj == null) return result; + if (isFunction$1(iteratee)) { + if (keys.length > 1) iteratee = optimizeCb(iteratee, keys[1]); + keys = allKeys(obj); + } else { + iteratee = keyInObj; + keys = flatten(keys, false, false); + obj = Object(obj); + } + for (var i = 0, length = keys.length; i < length; i++) { + var key = keys[i]; + var value = obj[key]; + if (iteratee(value, key, obj)) result[key] = value; + } + return result; + }); + + // Return a copy of the object without the disallowed properties. + var omit = restArguments(function(obj, keys) { + var iteratee = keys[0], context; + if (isFunction$1(iteratee)) { + iteratee = negate(iteratee); + if (keys.length > 1) context = keys[1]; + } else { + keys = map(flatten(keys, false, false), String); + iteratee = function(value, key) { + return !contains(keys, key); + }; + } + return pick(obj, iteratee, context); + }); + + // Returns everything but the last entry of the array. Especially useful on + // the arguments object. Passing **n** will return all the values in + // the array, excluding the last N. + function initial(array, n, guard) { + return slice.call(array, 0, Math.max(0, array.length - (n == null || guard ? 1 : n))); + } + + // Get the first element of an array. Passing **n** will return the first N + // values in the array. The **guard** check allows it to work with `_.map`. + function first(array, n, guard) { + if (array == null || array.length < 1) return n == null || guard ? void 0 : []; + if (n == null || guard) return array[0]; + return initial(array, array.length - n); + } + + // Returns everything but the first entry of the `array`. Especially useful on + // the `arguments` object. Passing an **n** will return the rest N values in the + // `array`. + function rest(array, n, guard) { + return slice.call(array, n == null || guard ? 1 : n); + } + + // Get the last element of an array. Passing **n** will return the last N + // values in the array. + function last(array, n, guard) { + if (array == null || array.length < 1) return n == null || guard ? void 0 : []; + if (n == null || guard) return array[array.length - 1]; + return rest(array, Math.max(0, array.length - n)); + } + + // Trim out all falsy values from an array. + function compact(array) { + return filter(array, Boolean); + } + + // Flatten out an array, either recursively (by default), or up to `depth`. + // Passing `true` or `false` as `depth` means `1` or `Infinity`, respectively. + function flatten$1(array, depth) { + return flatten(array, depth, false); + } + + // Take the difference between one array and a number of other arrays. + // Only the elements present in just the first array will remain. + var difference = restArguments(function(array, rest) { + rest = flatten(rest, true, true); + return filter(array, function(value){ + return !contains(rest, value); + }); + }); + + // Return a version of the array that does not contain the specified value(s). + var without = restArguments(function(array, otherArrays) { + return difference(array, otherArrays); + }); + + // Produce a duplicate-free version of the array. If the array has already + // been sorted, you have the option of using a faster algorithm. + // The faster algorithm will not work with an iteratee if the iteratee + // is not a one-to-one function, so providing an iteratee will disable + // the faster algorithm. + function uniq(array, isSorted, iteratee, context) { + if (!isBoolean(isSorted)) { + context = iteratee; + iteratee = isSorted; + isSorted = false; + } + if (iteratee != null) iteratee = cb(iteratee, context); + var result = []; + var seen = []; + for (var i = 0, length = getLength(array); i < length; i++) { + var value = array[i], + computed = iteratee ? iteratee(value, i, array) : value; + if (isSorted && !iteratee) { + if (!i || seen !== computed) result.push(value); + seen = computed; + } else if (iteratee) { + if (!contains(seen, computed)) { + seen.push(computed); + result.push(value); + } + } else if (!contains(result, value)) { + result.push(value); + } + } + return result; + } + + // Produce an array that contains the union: each distinct element from all of + // the passed-in arrays. + var union = restArguments(function(arrays) { + return uniq(flatten(arrays, true, true)); + }); + + // Produce an array that contains every item shared between all the + // passed-in arrays. + function intersection(array) { + var result = []; + var argsLength = arguments.length; + for (var i = 0, length = getLength(array); i < length; i++) { + var item = array[i]; + if (contains(result, item)) continue; + var j; + for (j = 1; j < argsLength; j++) { + if (!contains(arguments[j], item)) break; + } + if (j === argsLength) result.push(item); + } + return result; + } + + // Complement of zip. Unzip accepts an array of arrays and groups + // each array's elements on shared indices. + function unzip(array) { + var length = array && max(array, getLength).length || 0; + var result = Array(length); + + for (var index = 0; index < length; index++) { + result[index] = pluck(array, index); + } + return result; + } + + // Zip together multiple lists into a single array -- elements that share + // an index go together. + var zip = restArguments(unzip); + + // Converts lists into objects. Pass either a single array of `[key, value]` + // pairs, or two parallel arrays of the same length -- one of keys, and one of + // the corresponding values. Passing by pairs is the reverse of `_.pairs`. + function object(list, values) { + var result = {}; + for (var i = 0, length = getLength(list); i < length; i++) { + if (values) { + result[list[i]] = values[i]; + } else { + result[list[i][0]] = list[i][1]; + } + } + return result; + } + + // Generate an integer Array containing an arithmetic progression. A port of + // the native Python `range()` function. See + // [the Python documentation](https://docs.python.org/library/functions.html#range). + function range(start, stop, step) { + if (stop == null) { + stop = start || 0; + start = 0; + } + if (!step) { + step = stop < start ? -1 : 1; + } + + var length = Math.max(Math.ceil((stop - start) / step), 0); + var range = Array(length); + + for (var idx = 0; idx < length; idx++, start += step) { + range[idx] = start; + } + + return range; + } + + // Chunk a single array into multiple arrays, each containing `count` or fewer + // items. + function chunk(array, count) { + if (count == null || count < 1) return []; + var result = []; + var i = 0, length = array.length; + while (i < length) { + result.push(slice.call(array, i, i += count)); + } + return result; + } + + // Helper function to continue chaining intermediate results. + function chainResult(instance, obj) { + return instance._chain ? _(obj).chain() : obj; + } + + // Add your own custom functions to the Underscore object. + function mixin(obj) { + each(functions(obj), function(name) { + var func = _[name] = obj[name]; + _.prototype[name] = function() { + var args = [this._wrapped]; + push.apply(args, arguments); + return chainResult(this, func.apply(_, args)); + }; + }); + return _; + } + + // Add all mutator `Array` functions to the wrapper. + each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) { + var method = ArrayProto[name]; + _.prototype[name] = function() { + var obj = this._wrapped; + if (obj != null) { + method.apply(obj, arguments); + if ((name === 'shift' || name === 'splice') && obj.length === 0) { + delete obj[0]; + } + } + return chainResult(this, obj); + }; + }); + + // Add all accessor `Array` functions to the wrapper. + each(['concat', 'join', 'slice'], function(name) { + var method = ArrayProto[name]; + _.prototype[name] = function() { + var obj = this._wrapped; + if (obj != null) obj = method.apply(obj, arguments); + return chainResult(this, obj); + }; + }); + + // Named Exports + + var allExports = { + __proto__: null, + VERSION: VERSION, + restArguments: restArguments, + isObject: isObject, + isNull: isNull, + isUndefined: isUndefined, + isBoolean: isBoolean, + isElement: isElement, + isString: isString, + isNumber: isNumber, + isDate: isDate, + isRegExp: isRegExp, + isError: isError, + isSymbol: isSymbol, + isArrayBuffer: isArrayBuffer, + isDataView: isDataView$1, + isArray: isArray, + isFunction: isFunction$1, + isArguments: isArguments$1, + isFinite: isFinite$1, + isNaN: isNaN$1, + isTypedArray: isTypedArray$1, + isEmpty: isEmpty, + isMatch: isMatch, + isEqual: isEqual, + isMap: isMap, + isWeakMap: isWeakMap, + isSet: isSet, + isWeakSet: isWeakSet, + keys: keys, + allKeys: allKeys, + values: values, + pairs: pairs, + invert: invert, + functions: functions, + methods: functions, + extend: extend, + extendOwn: extendOwn, + assign: extendOwn, + defaults: defaults, + create: create, + clone: clone, + tap: tap, + get: get, + has: has$1, + mapObject: mapObject, + identity: identity, + constant: constant, + noop: noop, + toPath: toPath, + property: property, + propertyOf: propertyOf, + matcher: matcher, + matches: matcher, + times: times, + random: random, + now: now, + escape: _escape, + unescape: _unescape, + templateSettings: templateSettings, + template: template, + result: result, + uniqueId: uniqueId, + chain: chain, + iteratee: iteratee, + partial: partial, + bind: bind, + bindAll: bindAll, + memoize: memoize, + delay: delay, + defer: defer, + throttle: throttle, + debounce: debounce, + wrap: wrap, + negate: negate, + compose: compose, + after: after, + before: before, + once: once, + findKey: findKey, + findIndex: findIndex, + findLastIndex: findLastIndex, + sortedIndex: sortedIndex, + indexOf: indexOf, + lastIndexOf: lastIndexOf, + find: find, + detect: find, + findWhere: findWhere, + each: each, + forEach: each, + map: map, + collect: map, + reduce: reduce, + foldl: reduce, + inject: reduce, + reduceRight: reduceRight, + foldr: reduceRight, + filter: filter, + select: filter, + reject: reject, + every: every, + all: every, + some: some, + any: some, + contains: contains, + includes: contains, + include: contains, + invoke: invoke, + pluck: pluck, + where: where, + max: max, + min: min, + shuffle: shuffle, + sample: sample, + sortBy: sortBy, + groupBy: groupBy, + indexBy: indexBy, + countBy: countBy, + partition: partition, + toArray: toArray, + size: size, + pick: pick, + omit: omit, + first: first, + head: first, + take: first, + initial: initial, + last: last, + rest: rest, + tail: rest, + drop: rest, + compact: compact, + flatten: flatten$1, + without: without, + uniq: uniq, + unique: uniq, + union: union, + intersection: intersection, + difference: difference, + unzip: unzip, + transpose: unzip, + zip: zip, + object: object, + range: range, + chunk: chunk, + mixin: mixin, + 'default': _ + }; + + // Default Export + + // Add all of the Underscore functions to the wrapper object. + var _$1 = mixin(allExports); + // Legacy Node.js API. + _$1._ = _$1; + + return _$1; + +}))); +//# sourceMappingURL=underscore.js.map diff --git a/sparsezoo/_static/underscore.js b/sparsezoo/_static/underscore.js index 5b55f32beac..166240ef2dd 100644 --- a/sparsezoo/_static/underscore.js +++ b/sparsezoo/_static/underscore.js @@ -1,31 +1,6 @@ -// Underscore.js 1.3.1 -// (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc. -// Underscore is freely distributable under the MIT license. -// Portions of Underscore are inspired or borrowed from Prototype, -// Oliver Steele's Functional, and John Resig's Micro-Templating. -// For all details and documentation: -// http://documentcloud.github.com/underscore -(function(){function q(a,c,d){if(a===c)return a!==0||1/a==1/c;if(a==null||c==null)return a===c;if(a._chain)a=a._wrapped;if(c._chain)c=c._wrapped;if(a.isEqual&&b.isFunction(a.isEqual))return a.isEqual(c);if(c.isEqual&&b.isFunction(c.isEqual))return c.isEqual(a);var e=l.call(a);if(e!=l.call(c))return false;switch(e){case "[object String]":return a==String(c);case "[object Number]":return a!=+a?c!=+c:a==0?1/a==1/c:a==+c;case "[object Date]":case "[object Boolean]":return+a==+c;case "[object RegExp]":return a.source== -c.source&&a.global==c.global&&a.multiline==c.multiline&&a.ignoreCase==c.ignoreCase}if(typeof a!="object"||typeof c!="object")return false;for(var f=d.length;f--;)if(d[f]==a)return true;d.push(a);var f=0,g=true;if(e=="[object Array]"){if(f=a.length,g=f==c.length)for(;f--;)if(!(g=f in a==f in c&&q(a[f],c[f],d)))break}else{if("constructor"in a!="constructor"in c||a.constructor!=c.constructor)return false;for(var h in a)if(b.has(a,h)&&(f++,!(g=b.has(c,h)&&q(a[h],c[h],d))))break;if(g){for(h in c)if(b.has(c, -h)&&!f--)break;g=!f}}d.pop();return g}var r=this,G=r._,n={},k=Array.prototype,o=Object.prototype,i=k.slice,H=k.unshift,l=o.toString,I=o.hasOwnProperty,w=k.forEach,x=k.map,y=k.reduce,z=k.reduceRight,A=k.filter,B=k.every,C=k.some,p=k.indexOf,D=k.lastIndexOf,o=Array.isArray,J=Object.keys,s=Function.prototype.bind,b=function(a){return new m(a)};if(typeof exports!=="undefined"){if(typeof module!=="undefined"&&module.exports)exports=module.exports=b;exports._=b}else r._=b;b.VERSION="1.3.1";var j=b.each= -b.forEach=function(a,c,d){if(a!=null)if(w&&a.forEach===w)a.forEach(c,d);else if(a.length===+a.length)for(var e=0,f=a.length;e2;a== -null&&(a=[]);if(y&&a.reduce===y)return e&&(c=b.bind(c,e)),f?a.reduce(c,d):a.reduce(c);j(a,function(a,b,i){f?d=c.call(e,d,a,b,i):(d=a,f=true)});if(!f)throw new TypeError("Reduce of empty array with no initial value");return d};b.reduceRight=b.foldr=function(a,c,d,e){var f=arguments.length>2;a==null&&(a=[]);if(z&&a.reduceRight===z)return e&&(c=b.bind(c,e)),f?a.reduceRight(c,d):a.reduceRight(c);var g=b.toArray(a).reverse();e&&!f&&(c=b.bind(c,e));return f?b.reduce(g,c,d,e):b.reduce(g,c)};b.find=b.detect= -function(a,c,b){var e;E(a,function(a,g,h){if(c.call(b,a,g,h))return e=a,true});return e};b.filter=b.select=function(a,c,b){var e=[];if(a==null)return e;if(A&&a.filter===A)return a.filter(c,b);j(a,function(a,g,h){c.call(b,a,g,h)&&(e[e.length]=a)});return e};b.reject=function(a,c,b){var e=[];if(a==null)return e;j(a,function(a,g,h){c.call(b,a,g,h)||(e[e.length]=a)});return e};b.every=b.all=function(a,c,b){var e=true;if(a==null)return e;if(B&&a.every===B)return a.every(c,b);j(a,function(a,g,h){if(!(e= -e&&c.call(b,a,g,h)))return n});return e};var E=b.some=b.any=function(a,c,d){c||(c=b.identity);var e=false;if(a==null)return e;if(C&&a.some===C)return a.some(c,d);j(a,function(a,b,h){if(e||(e=c.call(d,a,b,h)))return n});return!!e};b.include=b.contains=function(a,c){var b=false;if(a==null)return b;return p&&a.indexOf===p?a.indexOf(c)!=-1:b=E(a,function(a){return a===c})};b.invoke=function(a,c){var d=i.call(arguments,2);return b.map(a,function(a){return(b.isFunction(c)?c||a:a[c]).apply(a,d)})};b.pluck= -function(a,c){return b.map(a,function(a){return a[c]})};b.max=function(a,c,d){if(!c&&b.isArray(a))return Math.max.apply(Math,a);if(!c&&b.isEmpty(a))return-Infinity;var e={computed:-Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b>=e.computed&&(e={value:a,computed:b})});return e.value};b.min=function(a,c,d){if(!c&&b.isArray(a))return Math.min.apply(Math,a);if(!c&&b.isEmpty(a))return Infinity;var e={computed:Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;bd?1:0}),"value")};b.groupBy=function(a,c){var d={},e=b.isFunction(c)?c:function(a){return a[c]};j(a,function(a,b){var c=e(a,b);(d[c]||(d[c]=[])).push(a)});return d};b.sortedIndex=function(a, -c,d){d||(d=b.identity);for(var e=0,f=a.length;e>1;d(a[g])=0})})};b.difference=function(a){var c=b.flatten(i.call(arguments,1));return b.filter(a,function(a){return!b.include(c,a)})};b.zip=function(){for(var a=i.call(arguments),c=b.max(b.pluck(a,"length")),d=Array(c),e=0;e=0;d--)b=[a[d].apply(this,b)];return b[0]}}; -b.after=function(a,b){return a<=0?b():function(){if(--a<1)return b.apply(this,arguments)}};b.keys=J||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var c=[],d;for(d in a)b.has(a,d)&&(c[c.length]=d);return c};b.values=function(a){return b.map(a,b.identity)};b.functions=b.methods=function(a){var c=[],d;for(d in a)b.isFunction(a[d])&&c.push(d);return c.sort()};b.extend=function(a){j(i.call(arguments,1),function(b){for(var d in b)a[d]=b[d]});return a};b.defaults=function(a){j(i.call(arguments, -1),function(b){for(var d in b)a[d]==null&&(a[d]=b[d])});return a};b.clone=function(a){return!b.isObject(a)?a:b.isArray(a)?a.slice():b.extend({},a)};b.tap=function(a,b){b(a);return a};b.isEqual=function(a,b){return q(a,b,[])};b.isEmpty=function(a){if(b.isArray(a)||b.isString(a))return a.length===0;for(var c in a)if(b.has(a,c))return false;return true};b.isElement=function(a){return!!(a&&a.nodeType==1)};b.isArray=o||function(a){return l.call(a)=="[object Array]"};b.isObject=function(a){return a===Object(a)}; -b.isArguments=function(a){return l.call(a)=="[object Arguments]"};if(!b.isArguments(arguments))b.isArguments=function(a){return!(!a||!b.has(a,"callee"))};b.isFunction=function(a){return l.call(a)=="[object Function]"};b.isString=function(a){return l.call(a)=="[object String]"};b.isNumber=function(a){return l.call(a)=="[object Number]"};b.isNaN=function(a){return a!==a};b.isBoolean=function(a){return a===true||a===false||l.call(a)=="[object Boolean]"};b.isDate=function(a){return l.call(a)=="[object Date]"}; -b.isRegExp=function(a){return l.call(a)=="[object RegExp]"};b.isNull=function(a){return a===null};b.isUndefined=function(a){return a===void 0};b.has=function(a,b){return I.call(a,b)};b.noConflict=function(){r._=G;return this};b.identity=function(a){return a};b.times=function(a,b,d){for(var e=0;e/g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")};b.mixin=function(a){j(b.functions(a), -function(c){K(c,b[c]=a[c])})};var L=0;b.uniqueId=function(a){var b=L++;return a?a+b:b};b.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var t=/.^/,u=function(a){return a.replace(/\\\\/g,"\\").replace(/\\'/g,"'")};b.template=function(a,c){var d=b.templateSettings,d="var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('"+a.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(d.escape||t,function(a,b){return"',_.escape("+ -u(b)+"),'"}).replace(d.interpolate||t,function(a,b){return"',"+u(b)+",'"}).replace(d.evaluate||t,function(a,b){return"');"+u(b).replace(/[\r\n\t]/g," ")+";__p.push('"}).replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t")+"');}return __p.join('');",e=new Function("obj","_",d);return c?e(c,b):function(a){return e.call(this,a,b)}};b.chain=function(a){return b(a).chain()};var m=function(a){this._wrapped=a};b.prototype=m.prototype;var v=function(a,c){return c?b(a).chain():a},K=function(a,c){m.prototype[a]= -function(){var a=i.call(arguments);H.call(a,this._wrapped);return v(c.apply(b,a),this._chain)}};b.mixin(b);j("pop,push,reverse,shift,sort,splice,unshift".split(","),function(a){var b=k[a];m.prototype[a]=function(){var d=this._wrapped;b.apply(d,arguments);var e=d.length;(a=="shift"||a=="splice")&&e===0&&delete d[0];return v(d,this._chain)}});j(["concat","join","slice"],function(a){var b=k[a];m.prototype[a]=function(){return v(b.apply(this._wrapped,arguments),this._chain)}});m.prototype.chain=function(){this._chain= -true;return this};m.prototype.value=function(){return this._wrapped}}).call(this); +!function(n,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define("underscore",r):(n=n||self,function(){var t=n._,e=n._=r();e.noConflict=function(){return n._=t,e}}())}(this,(function(){ +// Underscore.js 1.12.0 +// https://underscorejs.org +// (c) 2009-2020 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors +// Underscore may be freely distributed under the MIT license. +var n="1.12.0",r="object"==typeof self&&self.self===self&&self||"object"==typeof global&&global.global===global&&global||Function("return this")()||{},t=Array.prototype,e=Object.prototype,u="undefined"!=typeof Symbol?Symbol.prototype:null,o=t.push,i=t.slice,a=e.toString,f=e.hasOwnProperty,c="undefined"!=typeof ArrayBuffer,l="undefined"!=typeof DataView,s=Array.isArray,p=Object.keys,v=Object.create,h=c&&ArrayBuffer.isView,y=isNaN,g=isFinite,d=!{toString:null}.propertyIsEnumerable("toString"),b=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],m=Math.pow(2,53)-1;function j(n,r){return r=null==r?n.length-1:+r,function(){for(var t=Math.max(arguments.length-r,0),e=Array(t),u=0;u=0&&t<=m}}function $(n){return function(r){return null==r?void 0:r[n]}}var G=$("byteLength"),H=J(G),Q=/\[object ((I|Ui)nt(8|16|32)|Float(32|64)|Uint8Clamped|Big(I|Ui)nt64)Array\]/;var X=c?function(n){return h?h(n)&&!q(n):H(n)&&Q.test(a.call(n))}:K(!1),Y=$("length");function Z(n,r){r=function(n){for(var r={},t=n.length,e=0;e":">",'"':""","'":"'","`":"`"},Kn=Ln(Cn),Jn=Ln(_n(Cn)),$n=tn.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g},Gn=/(.)^/,Hn={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},Qn=/\\|'|\r|\n|\u2028|\u2029/g;function Xn(n){return"\\"+Hn[n]}var Yn=0;function Zn(n,r,t,e,u){if(!(e instanceof r))return n.apply(t,u);var o=Mn(n.prototype),i=n.apply(o,u);return _(i)?i:o}var nr=j((function(n,r){var t=nr.placeholder,e=function(){for(var u=0,o=r.length,i=Array(o),a=0;a1)er(a,r-1,t,e),u=e.length;else for(var f=0,c=a.length;f0&&(t=r.apply(this,arguments)),n<=1&&(r=null),t}}var cr=nr(fr,2);function lr(n,r,t){r=qn(r,t);for(var e,u=nn(n),o=0,i=u.length;o0?0:u-1;o>=0&&o0?a=o>=0?o:Math.max(o+f,a):f=o>=0?Math.min(o+1,f):o+f+1;else if(t&&o&&f)return e[o=t(e,u)]===u?o:-1;if(u!=u)return(o=r(i.call(e,a,f),C))>=0?o+a:-1;for(o=n>0?a:f-1;o>=0&&o0?0:i-1;for(u||(e=r[o?o[a]:a],a+=n);a>=0&&a=3;return r(n,Fn(t,u,4),e,o)}}var wr=_r(1),Ar=_r(-1);function xr(n,r,t){var e=[];return r=qn(r,t),mr(n,(function(n,t,u){r(n,t,u)&&e.push(n)})),e}function Sr(n,r,t){r=qn(r,t);for(var e=!tr(n)&&nn(n),u=(e||n).length,o=0;o=0}var Er=j((function(n,r,t){var e,u;return D(r)?u=r:(r=Nn(r),e=r.slice(0,-1),r=r[r.length-1]),jr(n,(function(n){var o=u;if(!o){if(e&&e.length&&(n=In(n,e)),null==n)return;o=n[r]}return null==o?o:o.apply(n,t)}))}));function Br(n,r){return jr(n,Rn(r))}function Nr(n,r,t){var e,u,o=-1/0,i=-1/0;if(null==r||"number"==typeof r&&"object"!=typeof n[0]&&null!=n)for(var a=0,f=(n=tr(n)?n:jn(n)).length;ao&&(o=e);else r=qn(r,t),mr(n,(function(n,t,e){((u=r(n,t,e))>i||u===-1/0&&o===-1/0)&&(o=n,i=u)}));return o}function Ir(n,r,t){if(null==r||t)return tr(n)||(n=jn(n)),n[Wn(n.length-1)];var e=tr(n)?En(n):jn(n),u=Y(e);r=Math.max(Math.min(r,u),0);for(var o=u-1,i=0;i1&&(e=Fn(e,r[1])),r=an(n)):(e=Pr,r=er(r,!1,!1),n=Object(n));for(var u=0,o=r.length;u1&&(t=r[1])):(r=jr(er(r,!1,!1),String),e=function(n,t){return!Mr(r,t)}),qr(n,e,t)}));function Wr(n,r,t){return i.call(n,0,Math.max(0,n.length-(null==r||t?1:r)))}function zr(n,r,t){return null==n||n.length<1?null==r||t?void 0:[]:null==r||t?n[0]:Wr(n,n.length-r)}function Lr(n,r,t){return i.call(n,null==r||t?1:r)}var Cr=j((function(n,r){return r=er(r,!0,!0),xr(n,(function(n){return!Mr(r,n)}))})),Kr=j((function(n,r){return Cr(n,r)}));function Jr(n,r,t,e){A(r)||(e=t,t=r,r=!1),null!=t&&(t=qn(t,e));for(var u=[],o=[],i=0,a=Y(n);ir?(e&&(clearTimeout(e),e=null),a=c,i=n.apply(u,o),e||(u=o=null)):e||!1===t.trailing||(e=setTimeout(f,l)),i};return c.cancel=function(){clearTimeout(e),a=0,e=u=o=null},c},debounce:function(n,r,t){var e,u,o=function(r,t){e=null,t&&(u=n.apply(r,t))},i=j((function(i){if(e&&clearTimeout(e),t){var a=!e;e=setTimeout(o,r),a&&(u=n.apply(this,i))}else e=or(o,r,this,i);return u}));return i.cancel=function(){clearTimeout(e),e=null},i},wrap:function(n,r){return nr(r,n)},negate:ar,compose:function(){var n=arguments,r=n.length-1;return function(){for(var t=r,e=n[r].apply(this,arguments);t--;)e=n[t].call(this,e);return e}},after:function(n,r){return function(){if(--n<1)return r.apply(this,arguments)}},before:fr,once:cr,findKey:lr,findIndex:pr,findLastIndex:vr,sortedIndex:hr,indexOf:gr,lastIndexOf:dr,find:br,detect:br,findWhere:function(n,r){return br(n,Dn(r))},each:mr,forEach:mr,map:jr,collect:jr,reduce:wr,foldl:wr,inject:wr,reduceRight:Ar,foldr:Ar,filter:xr,select:xr,reject:function(n,r,t){return xr(n,ar(qn(r)),t)},every:Sr,all:Sr,some:Or,any:Or,contains:Mr,includes:Mr,include:Mr,invoke:Er,pluck:Br,where:function(n,r){return xr(n,Dn(r))},max:Nr,min:function(n,r,t){var e,u,o=1/0,i=1/0;if(null==r||"number"==typeof r&&"object"!=typeof n[0]&&null!=n)for(var a=0,f=(n=tr(n)?n:jn(n)).length;ae||void 0===t)return 1;if(tsparsezoosparsezoo.nbutils package
                                                                                                                                  • sparsezoo.objects package

                                                                                                                                diff --git a/sparsezoo/api/sparsezoo.models.classification.html b/sparsezoo/api/sparsezoo.models.classification.html index d299131e5a3..78a9cdd87d7 100644 --- a/sparsezoo/api/sparsezoo.models.classification.html +++ b/sparsezoo/api/sparsezoo.models.classification.html @@ -215,7 +215,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparsezoo.models.classification.efficientnet.efficientnet_b0(framework: str = 'pytorch', repo: str = 'sparseml', dataset: str = 'imagenet', training_scheme: Optional[str] = None, optim_name: str = 'base', optim_category: str = 'none', optim_target: Optional[str] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, force_token_refresh: bool = False)sparsezoo.objects.model.Model[source]
                                                                                                                                +sparsezoo.models.classification.efficientnet.efficientnet_b0(framework: str = 'pytorch', repo: str = 'sparseml', dataset: str = 'imagenet', training_scheme: Optional[str] = None, optim_name: str = 'base', optim_category: str = 'none', optim_target: Optional[str] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, force_token_refresh: bool = False)sparsezoo.objects.model.Model[source]

                                                                                                                                Convenience function for getting an efficientnet b0 model

                                                                                                                                Parameters
                                                                                                                                @@ -250,7 +250,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparsezoo.models.classification.efficientnet.efficientnet_b4(framework: str = 'pytorch', repo: str = 'sparseml', dataset: str = 'imagenet', training_scheme: Optional[str] = None, optim_name: str = 'base', optim_category: str = 'none', optim_target: Optional[str] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, force_token_refresh: bool = False)sparsezoo.objects.model.Model[source]
                                                                                                                                +sparsezoo.models.classification.efficientnet.efficientnet_b4(framework: str = 'pytorch', repo: str = 'sparseml', dataset: str = 'imagenet', training_scheme: Optional[str] = None, optim_name: str = 'base', optim_category: str = 'none', optim_target: Optional[str] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, force_token_refresh: bool = False)sparsezoo.objects.model.Model[source]

                                                                                                                                Convenience function for getting an efficientnet b0 model

                                                                                                                                Parameters
                                                                                                                                @@ -292,7 +292,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparsezoo.models.classification.inception.inception_v3(framework: str = 'pytorch', repo: str = 'sparseml', dataset: str = 'imagenet', training_scheme: Optional[str] = None, optim_name: str = 'base', optim_category: str = 'none', optim_target: Optional[str] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, force_token_refresh: bool = False)sparsezoo.objects.model.Model[source]
                                                                                                                                +sparsezoo.models.classification.inception.inception_v3(framework: str = 'pytorch', repo: str = 'sparseml', dataset: str = 'imagenet', training_scheme: Optional[str] = None, optim_name: str = 'base', optim_category: str = 'none', optim_target: Optional[str] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, force_token_refresh: bool = False)sparsezoo.objects.model.Model[source]

                                                                                                                                Convenience function for getting an inception_v3 model

                                                                                                                                Parameters
                                                                                                                                @@ -335,7 +335,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparsezoo.models.classification.mobilenet.mobilenet_v1(framework: str = 'pytorch', repo: str = 'sparseml', dataset: str = 'imagenet', training_scheme: Optional[str] = None, optim_name: str = 'base', optim_category: str = 'none', optim_target: Optional[str] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, force_token_refresh: bool = False)sparsezoo.objects.model.Model[source]
                                                                                                                                +sparsezoo.models.classification.mobilenet.mobilenet_v1(framework: str = 'pytorch', repo: str = 'sparseml', dataset: str = 'imagenet', training_scheme: Optional[str] = None, optim_name: str = 'base', optim_category: str = 'none', optim_target: Optional[str] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, force_token_refresh: bool = False)sparsezoo.objects.model.Model[source]

                                                                                                                                Convenience function for getting a mobilenet_v1 model

                                                                                                                                Parameters
                                                                                                                                @@ -370,7 +370,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparsezoo.models.classification.mobilenet.mobilenet_v2(framework: str = 'pytorch', repo: str = 'sparseml', dataset: str = 'imagenet', training_scheme: Optional[str] = None, optim_name: str = 'base', optim_category: str = 'none', optim_target: Optional[str] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, force_token_refresh: bool = False)sparsezoo.objects.model.Model[source]
                                                                                                                                +sparsezoo.models.classification.mobilenet.mobilenet_v2(framework: str = 'pytorch', repo: str = 'sparseml', dataset: str = 'imagenet', training_scheme: Optional[str] = None, optim_name: str = 'base', optim_category: str = 'none', optim_target: Optional[str] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, force_token_refresh: bool = False)sparsezoo.objects.model.Model[source]

                                                                                                                                Convenience function for getting a mobilenet_v2 model

                                                                                                                                Parameters
                                                                                                                                @@ -412,7 +412,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparsezoo.models.classification.resnet.resnet_101(framework: str = 'pytorch', repo: str = 'sparseml', dataset: str = 'imagenet', training_scheme: Optional[str] = None, optim_name: str = 'base', optim_category: str = 'none', optim_target: Optional[str] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, force_token_refresh: bool = False)sparsezoo.objects.model.Model[source]
                                                                                                                                +sparsezoo.models.classification.resnet.resnet_101(framework: str = 'pytorch', repo: str = 'sparseml', dataset: str = 'imagenet', training_scheme: Optional[str] = None, optim_name: str = 'base', optim_category: str = 'none', optim_target: Optional[str] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, force_token_refresh: bool = False)sparsezoo.objects.model.Model[source]

                                                                                                                                Convenience function for getting a resnet 101 model

                                                                                                                                Parameters
                                                                                                                                @@ -447,7 +447,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparsezoo.models.classification.resnet.resnet_101_2x(framework: str = 'pytorch', repo: str = 'sparseml', dataset: str = 'imagenet', training_scheme: Optional[str] = None, optim_name: str = 'base', optim_category: str = 'none', optim_target: Optional[str] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, force_token_refresh: bool = False)sparsezoo.objects.model.Model[source]
                                                                                                                                +sparsezoo.models.classification.resnet.resnet_101_2x(framework: str = 'pytorch', repo: str = 'sparseml', dataset: str = 'imagenet', training_scheme: Optional[str] = None, optim_name: str = 'base', optim_category: str = 'none', optim_target: Optional[str] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, force_token_refresh: bool = False)sparsezoo.objects.model.Model[source]

                                                                                                                                Convenience function for getting a resnet 101 2x width model

                                                                                                                                Parameters
                                                                                                                                @@ -482,7 +482,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparsezoo.models.classification.resnet.resnet_152(framework: str = 'pytorch', repo: str = 'sparseml', dataset: str = 'imagenet', training_scheme: Optional[str] = None, optim_name: str = 'base', optim_category: str = 'none', optim_target: Optional[str] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, force_token_refresh: bool = False)sparsezoo.objects.model.Model[source]
                                                                                                                                +sparsezoo.models.classification.resnet.resnet_152(framework: str = 'pytorch', repo: str = 'sparseml', dataset: str = 'imagenet', training_scheme: Optional[str] = None, optim_name: str = 'base', optim_category: str = 'none', optim_target: Optional[str] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, force_token_refresh: bool = False)sparsezoo.objects.model.Model[source]

                                                                                                                                Convenience function for getting a resnet 152 model

                                                                                                                                Parameters
                                                                                                                                @@ -517,7 +517,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparsezoo.models.classification.resnet.resnet_18(framework: str = 'pytorch', repo: str = 'sparseml', dataset: str = 'imagenet', training_scheme: Optional[str] = None, optim_name: str = 'base', optim_category: str = 'none', optim_target: Optional[str] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, force_token_refresh: bool = False)sparsezoo.objects.model.Model[source]
                                                                                                                                +sparsezoo.models.classification.resnet.resnet_18(framework: str = 'pytorch', repo: str = 'sparseml', dataset: str = 'imagenet', training_scheme: Optional[str] = None, optim_name: str = 'base', optim_category: str = 'none', optim_target: Optional[str] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, force_token_refresh: bool = False)sparsezoo.objects.model.Model[source]

                                                                                                                                Convenience function for getting a resnet 18 model

                                                                                                                                Parameters
                                                                                                                                @@ -552,7 +552,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparsezoo.models.classification.resnet.resnet_34(framework: str = 'pytorch', repo: str = 'sparseml', dataset: str = 'imagenet', training_scheme: Optional[str] = None, optim_name: str = 'base', optim_category: str = 'none', optim_target: Optional[str] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, force_token_refresh: bool = False)sparsezoo.objects.model.Model[source]
                                                                                                                                +sparsezoo.models.classification.resnet.resnet_34(framework: str = 'pytorch', repo: str = 'sparseml', dataset: str = 'imagenet', training_scheme: Optional[str] = None, optim_name: str = 'base', optim_category: str = 'none', optim_target: Optional[str] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, force_token_refresh: bool = False)sparsezoo.objects.model.Model[source]

                                                                                                                                Convenience function for getting a resnet 34 model

                                                                                                                                Parameters
                                                                                                                                @@ -587,7 +587,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparsezoo.models.classification.resnet.resnet_50(framework: str = 'pytorch', repo: str = 'sparseml', dataset: str = 'imagenet', training_scheme: Optional[str] = None, optim_name: str = 'base', optim_category: str = 'none', optim_target: Optional[str] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, force_token_refresh: bool = False)sparsezoo.objects.model.Model[source]
                                                                                                                                +sparsezoo.models.classification.resnet.resnet_50(framework: str = 'pytorch', repo: str = 'sparseml', dataset: str = 'imagenet', training_scheme: Optional[str] = None, optim_name: str = 'base', optim_category: str = 'none', optim_target: Optional[str] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, force_token_refresh: bool = False)sparsezoo.objects.model.Model[source]

                                                                                                                                Convenience function for getting a resnet 50 model

                                                                                                                                Parameters
                                                                                                                                @@ -622,7 +622,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparsezoo.models.classification.resnet.resnet_50_2x(framework: str = 'pytorch', repo: str = 'sparseml', dataset: str = 'imagenet', training_scheme: Optional[str] = None, optim_name: str = 'base', optim_category: str = 'none', optim_target: Optional[str] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, force_token_refresh: bool = False)sparsezoo.objects.model.Model[source]
                                                                                                                                +sparsezoo.models.classification.resnet.resnet_50_2x(framework: str = 'pytorch', repo: str = 'sparseml', dataset: str = 'imagenet', training_scheme: Optional[str] = None, optim_name: str = 'base', optim_category: str = 'none', optim_target: Optional[str] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, force_token_refresh: bool = False)sparsezoo.objects.model.Model[source]

                                                                                                                                Convenience function for getting a resnet 50 2x width model

                                                                                                                                Parameters
                                                                                                                                @@ -664,7 +664,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparsezoo.models.classification.vgg.vgg_11(framework: str = 'pytorch', repo: str = 'sparseml', dataset: str = 'imagenet', training_scheme: Optional[str] = None, optim_name: str = 'base', optim_category: str = 'none', optim_target: Optional[str] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, force_token_refresh: bool = False)sparsezoo.objects.model.Model[source]
                                                                                                                                +sparsezoo.models.classification.vgg.vgg_11(framework: str = 'pytorch', repo: str = 'sparseml', dataset: str = 'imagenet', training_scheme: Optional[str] = None, optim_name: str = 'base', optim_category: str = 'none', optim_target: Optional[str] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, force_token_refresh: bool = False)sparsezoo.objects.model.Model[source]

                                                                                                                                Convenience function for getting a vgg 11 model

                                                                                                                                Parameters
                                                                                                                                @@ -699,7 +699,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparsezoo.models.classification.vgg.vgg_11bn(framework: str = 'pytorch', repo: str = 'sparseml', dataset: str = 'imagenet', training_scheme: Optional[str] = None, optim_name: str = 'base', optim_category: str = 'none', optim_target: Optional[str] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, force_token_refresh: bool = False)sparsezoo.objects.model.Model[source]
                                                                                                                                +sparsezoo.models.classification.vgg.vgg_11bn(framework: str = 'pytorch', repo: str = 'sparseml', dataset: str = 'imagenet', training_scheme: Optional[str] = None, optim_name: str = 'base', optim_category: str = 'none', optim_target: Optional[str] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, force_token_refresh: bool = False)sparsezoo.objects.model.Model[source]

                                                                                                                                Convenience function for getting a batch normalized vgg 11 model

                                                                                                                                Parameters
                                                                                                                                @@ -734,7 +734,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparsezoo.models.classification.vgg.vgg_13(framework: str = 'pytorch', repo: str = 'sparseml', dataset: str = 'imagenet', training_scheme: Optional[str] = None, optim_name: str = 'base', optim_category: str = 'none', optim_target: Optional[str] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, force_token_refresh: bool = False)sparsezoo.objects.model.Model[source]
                                                                                                                                +sparsezoo.models.classification.vgg.vgg_13(framework: str = 'pytorch', repo: str = 'sparseml', dataset: str = 'imagenet', training_scheme: Optional[str] = None, optim_name: str = 'base', optim_category: str = 'none', optim_target: Optional[str] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, force_token_refresh: bool = False)sparsezoo.objects.model.Model[source]

                                                                                                                                Convenience function for getting a vgg 13 model

                                                                                                                                Parameters
                                                                                                                                @@ -769,7 +769,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparsezoo.models.classification.vgg.vgg_13bn(framework: str = 'pytorch', repo: str = 'sparseml', dataset: str = 'imagenet', training_scheme: Optional[str] = None, optim_name: str = 'base', optim_category: str = 'none', optim_target: Optional[str] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, force_token_refresh: bool = False)sparsezoo.objects.model.Model[source]
                                                                                                                                +sparsezoo.models.classification.vgg.vgg_13bn(framework: str = 'pytorch', repo: str = 'sparseml', dataset: str = 'imagenet', training_scheme: Optional[str] = None, optim_name: str = 'base', optim_category: str = 'none', optim_target: Optional[str] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, force_token_refresh: bool = False)sparsezoo.objects.model.Model[source]

                                                                                                                                Convenience function for getting a batch normalized vgg 13 model

                                                                                                                                Parameters
                                                                                                                                @@ -804,7 +804,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparsezoo.models.classification.vgg.vgg_16(framework: str = 'pytorch', repo: str = 'sparseml', dataset: str = 'imagenet', training_scheme: Optional[str] = None, optim_name: str = 'base', optim_category: str = 'none', optim_target: Optional[str] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, force_token_refresh: bool = False)sparsezoo.objects.model.Model[source]
                                                                                                                                +sparsezoo.models.classification.vgg.vgg_16(framework: str = 'pytorch', repo: str = 'sparseml', dataset: str = 'imagenet', training_scheme: Optional[str] = None, optim_name: str = 'base', optim_category: str = 'none', optim_target: Optional[str] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, force_token_refresh: bool = False)sparsezoo.objects.model.Model[source]

                                                                                                                                Convenience function for getting a vgg 16 model

                                                                                                                                Parameters
                                                                                                                                @@ -839,7 +839,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparsezoo.models.classification.vgg.vgg_16bn(framework: str = 'pytorch', repo: str = 'sparseml', dataset: str = 'imagenet', training_scheme: Optional[str] = None, optim_name: str = 'base', optim_category: str = 'none', optim_target: Optional[str] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, force_token_refresh: bool = False)sparsezoo.objects.model.Model[source]
                                                                                                                                +sparsezoo.models.classification.vgg.vgg_16bn(framework: str = 'pytorch', repo: str = 'sparseml', dataset: str = 'imagenet', training_scheme: Optional[str] = None, optim_name: str = 'base', optim_category: str = 'none', optim_target: Optional[str] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, force_token_refresh: bool = False)sparsezoo.objects.model.Model[source]

                                                                                                                                Convenience function for getting a batch normalized vgg 16 model

                                                                                                                                Parameters
                                                                                                                                @@ -874,7 +874,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparsezoo.models.classification.vgg.vgg_19(framework: str = 'pytorch', repo: str = 'sparseml', dataset: str = 'imagenet', training_scheme: Optional[str] = None, optim_name: str = 'base', optim_category: str = 'none', optim_target: Optional[str] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, force_token_refresh: bool = False)sparsezoo.objects.model.Model[source]
                                                                                                                                +sparsezoo.models.classification.vgg.vgg_19(framework: str = 'pytorch', repo: str = 'sparseml', dataset: str = 'imagenet', training_scheme: Optional[str] = None, optim_name: str = 'base', optim_category: str = 'none', optim_target: Optional[str] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, force_token_refresh: bool = False)sparsezoo.objects.model.Model[source]

                                                                                                                                Convenience function for getting a vgg 19 model

                                                                                                                                Parameters
                                                                                                                                @@ -909,7 +909,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparsezoo.models.classification.vgg.vgg_19bn(framework: str = 'pytorch', repo: str = 'sparseml', dataset: str = 'imagenet', training_scheme: Optional[str] = None, optim_name: str = 'base', optim_category: str = 'none', optim_target: Optional[str] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, force_token_refresh: bool = False)sparsezoo.objects.model.Model[source]
                                                                                                                                +sparsezoo.models.classification.vgg.vgg_19bn(framework: str = 'pytorch', repo: str = 'sparseml', dataset: str = 'imagenet', training_scheme: Optional[str] = None, optim_name: str = 'base', optim_category: str = 'none', optim_target: Optional[str] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, force_token_refresh: bool = False)sparsezoo.objects.model.Model[source]

                                                                                                                                Convenience function for getting a batch normalized vgg 19 model

                                                                                                                                Parameters
                                                                                                                                diff --git a/sparsezoo/api/sparsezoo.models.detection.html b/sparsezoo/api/sparsezoo.models.detection.html index f8e75cb0b96..e4f036cc182 100644 --- a/sparsezoo/api/sparsezoo.models.detection.html +++ b/sparsezoo/api/sparsezoo.models.detection.html @@ -215,7 +215,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparsezoo.models.detection.ssd.ssd_resnet50_300(framework: str = 'pytorch', repo: str = 'sparseml', dataset: str = 'coco', training_scheme: Optional[str] = None, optim_name: str = 'base', optim_category: str = 'none', optim_target: Optional[str] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, force_token_refresh: bool = False)sparsezoo.objects.model.Model[source]
                                                                                                                                +sparsezoo.models.detection.ssd.ssd_resnet50_300(framework: str = 'pytorch', repo: str = 'sparseml', dataset: str = 'coco', training_scheme: Optional[str] = None, optim_name: str = 'base', optim_category: str = 'none', optim_target: Optional[str] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, force_token_refresh: bool = False)sparsezoo.objects.model.Model[source]

                                                                                                                                Convenience function for getting an ssd resnet50 300 model

                                                                                                                                Parameters
                                                                                                                                @@ -257,7 +257,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparsezoo.models.detection.yolo.yolo_v3(sub_architecture: str = 'spp', framework: str = 'pytorch', repo: str = 'ultralytics', dataset: str = 'coco', training_scheme: Optional[str] = None, optim_name: str = 'base', optim_category: str = 'none', optim_target: Optional[str] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, force_token_refresh: bool = False)sparsezoo.objects.model.Model[source]
                                                                                                                                +sparsezoo.models.detection.yolo.yolo_v3(sub_architecture: str = 'spp', framework: str = 'pytorch', repo: str = 'ultralytics', dataset: str = 'coco', training_scheme: Optional[str] = None, optim_name: str = 'base', optim_category: str = 'none', optim_target: Optional[str] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, force_token_refresh: bool = False)sparsezoo.objects.model.Model[source]

                                                                                                                                Convenience function for getting an ssd resnet50 300 model

                                                                                                                                Parameters
                                                                                                                                diff --git a/sparsezoo/api/sparsezoo.models.html b/sparsezoo/api/sparsezoo.models.html index 796b6353a30..52a8f1a4e30 100644 --- a/sparsezoo/api/sparsezoo.models.html +++ b/sparsezoo/api/sparsezoo.models.html @@ -234,12 +234,12 @@

                                                                                                                                Submodules
                                                                                                                                -class sparsezoo.models.zoo.Zoo[source]
                                                                                                                                +class sparsezoo.models.zoo.Zoo[source]

                                                                                                                                Bases: object

                                                                                                                                Provides static functions for loading and searching SparseZoo models and recipes

                                                                                                                                -static download_recipe_base_framework_files(stub: str, extensions: Optional[List[str]] = None) → List[str][source]
                                                                                                                                +static download_recipe_base_framework_files(stub: str, extensions: Optional[List[str]] = None)List[str][source]
                                                                                                                                Parameters

                                                                                                                                -
                                                                                                                                -

                                                                                                                                sparsezoo.nbutils.utils module

                                                                                                                                -

                                                                                                                                Code related to model repo selection display in a jupyter notebook using ipywidgets

                                                                                                                                -
                                                                                                                                -
                                                                                                                                -class sparsezoo.nbutils.utils.ModelSelectWidgetContainer(models: List[sparsezoo.objects.model.Model])[source]
                                                                                                                                -

                                                                                                                                Bases: object

                                                                                                                                -

                                                                                                                                Widget used in model download notebooks for selecting a model for download

                                                                                                                                -
                                                                                                                                -
                                                                                                                                Parameters
                                                                                                                                -
                                                                                                                                  -
                                                                                                                                • filter_frameworks – if provided, will force all models -to be one of these frameworks

                                                                                                                                • -
                                                                                                                                • filter_datasets – if provided, will force all models -to be trained on one of these datasets

                                                                                                                                • -
                                                                                                                                -
                                                                                                                                -
                                                                                                                                -
                                                                                                                                -
                                                                                                                                -create()[source]
                                                                                                                                -
                                                                                                                                -
                                                                                                                                Returns
                                                                                                                                -

                                                                                                                                a created ipywidget that allows selection of models

                                                                                                                                -
                                                                                                                                -
                                                                                                                                -
                                                                                                                                - -
                                                                                                                                -
                                                                                                                                -property selected_framework
                                                                                                                                -

                                                                                                                                the selected framework in the widget

                                                                                                                                -
                                                                                                                                -
                                                                                                                                Type
                                                                                                                                -

                                                                                                                                return

                                                                                                                                -
                                                                                                                                -
                                                                                                                                -
                                                                                                                                - -
                                                                                                                                -
                                                                                                                                -property selected_model
                                                                                                                                -

                                                                                                                                the selected model in the widget

                                                                                                                                -
                                                                                                                                -
                                                                                                                                Type
                                                                                                                                -

                                                                                                                                return

                                                                                                                                -
                                                                                                                                -
                                                                                                                                -
                                                                                                                                - -
                                                                                                                                - -
                                                                                                                                -
                                                                                                                                -class sparsezoo.nbutils.utils.SelectDomainWidgetContainer(domains: List[str] = ['cv'], sub_domains: Dict[str, List[str]] = {'cv': ['classification']})[source]
                                                                                                                                -

                                                                                                                                Bases: object

                                                                                                                                -
                                                                                                                                -
                                                                                                                                Widget used in model repo notebooks for selecting domain and subdomain to

                                                                                                                                search within

                                                                                                                                -
                                                                                                                                -
                                                                                                                                -
                                                                                                                                -
                                                                                                                                Parameters
                                                                                                                                -
                                                                                                                                  -
                                                                                                                                • domains – list of domains to look through

                                                                                                                                • -
                                                                                                                                • sub_domain – a map of sub domains for each domain

                                                                                                                                • -
                                                                                                                                -
                                                                                                                                -
                                                                                                                                -
                                                                                                                                -
                                                                                                                                -create()[source]
                                                                                                                                -
                                                                                                                                - -
                                                                                                                                -
                                                                                                                                -property selected_domain_info
                                                                                                                                -
                                                                                                                                - -
                                                                                                                                - +
                                                                                                                                +

                                                                                                                                sparsezoo.nbutils.utils module

                                                                                                                                -
                                                                                                                                -

                                                                                                                                Module contents

                                                                                                                                -

                                                                                                                                Notebook utils

                                                                                                                                +
                                                                                                                                +

                                                                                                                                Module contents

                                                                                                                                diff --git a/sparsezoo/api/sparsezoo.objects.html b/sparsezoo/api/sparsezoo.objects.html index da897c1c8ab..ac297878768 100644 --- a/sparsezoo/api/sparsezoo.objects.html +++ b/sparsezoo/api/sparsezoo.objects.html @@ -219,7 +219,7 @@

                                                                                                                                Submodules
                                                                                                                                -class sparsezoo.objects.base.BaseObject(created: Optional[str] = None, modified: Optional[str] = None, **kwargs)[source]
                                                                                                                                +class sparsezoo.objects.base.BaseObject(created: Optional[str] = None, modified: Optional[str] = None, **kwargs)[source]

                                                                                                                                Bases: object

                                                                                                                                A sparse zoo base object

                                                                                                                                @@ -232,7 +232,7 @@

                                                                                                                                Submodules
                                                                                                                                -property created
                                                                                                                                +property created

                                                                                                                                the date created

                                                                                                                                Type
                                                                                                                                @@ -243,7 +243,7 @@

                                                                                                                                Submodules
                                                                                                                                -dict() → Dict[source]
                                                                                                                                +dict()Dict[source]
                                                                                                                                Returns

                                                                                                                                The object as a dictionary

                                                                                                                                @@ -253,7 +253,7 @@

                                                                                                                                Submodules
                                                                                                                                -property modified
                                                                                                                                +property modified

                                                                                                                                the date modifed

                                                                                                                                Type
                                                                                                                                @@ -270,7 +270,7 @@

                                                                                                                                Submodules
                                                                                                                                -class sparsezoo.objects.data.Data(name: str, model_metadata: sparsezoo.objects.metadata.ModelMetadata, **kwargs)[source]
                                                                                                                                +class sparsezoo.objects.data.Data(name: str, model_metadata: sparsezoo.objects.metadata.ModelMetadata, **kwargs)[source]

                                                                                                                                Bases: sparsezoo.objects.file.File

                                                                                                                                Sample data for a given model

                                                                                                                                @@ -283,7 +283,7 @@

                                                                                                                                Submodules
                                                                                                                                -dataset()sparsezoo.utils.data.Dataset[source]
                                                                                                                                +dataset()sparsezoo.utils.data.Dataset[source]

                                                                                                                                A dataset for interacting with the sample data. If the data is not found on the local disk, will automatically download.

                                                                                                                                @@ -295,7 +295,7 @@

                                                                                                                                Submodules
                                                                                                                                -loader(batch_size: int = 1, iter_steps: int = 0, batch_as_list: bool = True)sparsezoo.utils.data.DataLoader[source]
                                                                                                                                +loader(batch_size: int = 1, iter_steps: int = 0, batch_as_list: bool = True)sparsezoo.utils.data.DataLoader[source]

                                                                                                                                A dataloader for interfacing with the sample data in a batched format.

                                                                                                                                Parameters
                                                                                                                                @@ -316,7 +316,7 @@

                                                                                                                                Submodules
                                                                                                                                -property name
                                                                                                                                +property name

                                                                                                                                The name/type of sample data

                                                                                                                                Type
                                                                                                                                @@ -327,7 +327,7 @@

                                                                                                                                Submodules
                                                                                                                                -sample_batch(batch_index: int = 0, batch_size: int = 1, batch_as_list: bool = True) → Union[List[numpy.ndarray], Dict[str, numpy.ndarray]][source]
                                                                                                                                +sample_batch(batch_index: int = 0, batch_size: int = 1, batch_as_list: bool = True)Union[List[numpy.ndarray], Dict[str, numpy.ndarray]][source]

                                                                                                                                Get a sample batch of data from the data loader

                                                                                                                                Parameters
                                                                                                                                @@ -352,7 +352,7 @@

                                                                                                                                Submodules
                                                                                                                                -class sparsezoo.objects.downloadable.Downloadable(folder_name: str, override_parent_path: Optional[str] = None, **kwargs)[source]
                                                                                                                                +class sparsezoo.objects.downloadable.Downloadable(folder_name: str, override_parent_path: Optional[str] = None, **kwargs)[source]

                                                                                                                                Bases: object

                                                                                                                                Downloadable interface with a default folder and file name

                                                                                                                                @@ -366,7 +366,7 @@

                                                                                                                                Submodules
                                                                                                                                -property dir_path
                                                                                                                                +property dir_path

                                                                                                                                The local path to download files into. Appends the folder_name to one of the following in order of resolution: [override_parent_path, SPARSEZOO_MODELS_PATH env variable, @@ -380,12 +380,12 @@

                                                                                                                                Submodules
                                                                                                                                -download(overwrite: bool = False, refresh_token: bool = False, show_progress: bool = True)[source]
                                                                                                                                +download(overwrite: bool = False, refresh_token: bool = False, show_progress: bool = True)[source]

                                                                                                                                -property folder_name
                                                                                                                                +property folder_name

                                                                                                                                Name of the folder to save the downloads under

                                                                                                                                Type
                                                                                                                                @@ -396,7 +396,7 @@

                                                                                                                                Submodules
                                                                                                                                -property override_parent_path
                                                                                                                                +property override_parent_path

                                                                                                                                Path to override the default save path for where to save the folder and downloads at

                                                                                                                                @@ -415,7 +415,7 @@

                                                                                                                                Submodules
                                                                                                                                -class sparsezoo.objects.file.File(model_metadata: sparsezoo.objects.metadata.ModelMetadata, file_id: str, display_name: str, file_type: str, operator_version: Optional[str], checkpoint: bool, md5: str, file_size: int, downloads: int, url: Optional[str] = None, child_folder_name: Optional[str] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, **kwargs)[source]
                                                                                                                                +class sparsezoo.objects.file.File(model_metadata: sparsezoo.objects.metadata.ModelMetadata, file_id: str, display_name: str, file_type: str, operator_version: Optional[str], checkpoint: bool, md5: str, file_size: int, downloads: int, url: Optional[str] = None, child_folder_name: Optional[str] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, **kwargs)[source]

                                                                                                                                Bases: sparsezoo.objects.base.BaseObject, sparsezoo.objects.downloadable.Downloadable

                                                                                                                                A model repo file.

                                                                                                                                @@ -443,7 +443,7 @@

                                                                                                                                Submodules
                                                                                                                                -check_download(overwrite: bool = False, refresh_token: bool = False, show_progress: bool = True)[source]
                                                                                                                                +check_download(overwrite: bool = False, refresh_token: bool = False, show_progress: bool = True)[source]

                                                                                                                                Check if the file has been downloaded, if not then call download()

                                                                                                                                Parameters
                                                                                                                                @@ -458,7 +458,7 @@

                                                                                                                                Submodules
                                                                                                                                -property checkpoint
                                                                                                                                +property checkpoint

                                                                                                                                True if the model is a checkpoint file (for use with transfer learning flows), False otherwise

                                                                                                                                @@ -470,7 +470,7 @@

                                                                                                                                Submodules
                                                                                                                                -property display_name
                                                                                                                                +property display_name

                                                                                                                                The file name and extension

                                                                                                                                Type
                                                                                                                                @@ -481,7 +481,7 @@

                                                                                                                                Submodules
                                                                                                                                -download(overwrite: bool = False, refresh_token: bool = False, show_progress: bool = True)[source]
                                                                                                                                +download(overwrite: bool = False, refresh_token: bool = False, show_progress: bool = True)[source]

                                                                                                                                Downloads a sparsezoo file.

                                                                                                                                Parameters
                                                                                                                                @@ -496,7 +496,7 @@

                                                                                                                                Submodules
                                                                                                                                -property downloaded
                                                                                                                                +property downloaded

                                                                                                                                True if the file has already been downloaded, False otherwise

                                                                                                                                Type
                                                                                                                                @@ -507,7 +507,7 @@

                                                                                                                                Submodules
                                                                                                                                -downloaded_path() → str[source]
                                                                                                                                +downloaded_path()str[source]
                                                                                                                                Returns

                                                                                                                                The local path to the downloaded file. @@ -519,7 +519,7 @@

                                                                                                                                Submodules
                                                                                                                                -property downloads
                                                                                                                                +property downloads

                                                                                                                                The amount of times a download has been requested for this file

                                                                                                                                Type
                                                                                                                                @@ -530,7 +530,7 @@

                                                                                                                                Submodules
                                                                                                                                -property file_id
                                                                                                                                +property file_id

                                                                                                                                Id of the file as stored in the cloud

                                                                                                                                Type
                                                                                                                                @@ -541,7 +541,7 @@

                                                                                                                                Submodules
                                                                                                                                -property file_size
                                                                                                                                +property file_size

                                                                                                                                The size of the file as stored in the cloud

                                                                                                                                Type
                                                                                                                                @@ -552,7 +552,7 @@

                                                                                                                                Submodules
                                                                                                                                -property file_type
                                                                                                                                +property file_type

                                                                                                                                The type of file the object represents

                                                                                                                                Type
                                                                                                                                @@ -563,7 +563,7 @@

                                                                                                                                Submodules
                                                                                                                                -property file_type_card
                                                                                                                                +property file_type_card

                                                                                                                                True if the file type is a card, False otherwise

                                                                                                                                Type
                                                                                                                                @@ -574,7 +574,7 @@

                                                                                                                                Submodules
                                                                                                                                -property file_type_data
                                                                                                                                +property file_type_data

                                                                                                                                True if the file type is sample data, False otherwise

                                                                                                                                Type
                                                                                                                                @@ -585,7 +585,7 @@

                                                                                                                                Submodules
                                                                                                                                -property file_type_data_inputs
                                                                                                                                +property file_type_data_inputs

                                                                                                                                True if the file type is the input sample data, False otherwise

                                                                                                                                Type
                                                                                                                                @@ -596,7 +596,7 @@

                                                                                                                                Submodules
                                                                                                                                -property file_type_data_labels
                                                                                                                                +property file_type_data_labels

                                                                                                                                True if the file type is the labels sample data, False otherwise

                                                                                                                                Type
                                                                                                                                @@ -607,7 +607,7 @@

                                                                                                                                Submodules
                                                                                                                                -property file_type_data_originals
                                                                                                                                +property file_type_data_originals

                                                                                                                                True if the file type is the original sample data, False otherwise

                                                                                                                                Type
                                                                                                                                @@ -618,7 +618,7 @@

                                                                                                                                Submodules
                                                                                                                                -property file_type_data_outputs
                                                                                                                                +property file_type_data_outputs

                                                                                                                                True if the file type is the output sample data, False otherwise

                                                                                                                                Type
                                                                                                                                @@ -629,7 +629,7 @@

                                                                                                                                Submodules
                                                                                                                                -property file_type_framework
                                                                                                                                +property file_type_framework

                                                                                                                                True if the file type is a framework file, False otherwise

                                                                                                                                Type
                                                                                                                                @@ -640,7 +640,7 @@

                                                                                                                                Submodules
                                                                                                                                -property file_type_onnx
                                                                                                                                +property file_type_onnx

                                                                                                                                True if the file type is onnx, False otherwise

                                                                                                                                Type
                                                                                                                                @@ -651,7 +651,7 @@

                                                                                                                                Submodules
                                                                                                                                -property file_type_onnx_gz
                                                                                                                                +property file_type_onnx_gz

                                                                                                                                True if the file type is a gzipped onnx, False otherwise

                                                                                                                                Type
                                                                                                                                @@ -662,7 +662,7 @@

                                                                                                                                Submodules
                                                                                                                                -property file_type_recipe
                                                                                                                                +property file_type_recipe

                                                                                                                                True if the file type is a recipe, False otherwise

                                                                                                                                Type
                                                                                                                                @@ -673,7 +673,7 @@

                                                                                                                                Submodules
                                                                                                                                -property md5
                                                                                                                                +property md5

                                                                                                                                The md5 hash for the file as stored in the cloud

                                                                                                                                Type
                                                                                                                                @@ -684,7 +684,7 @@

                                                                                                                                Submodules
                                                                                                                                -property model_metadata
                                                                                                                                +property model_metadata

                                                                                                                                The metadata of the model the file belongs to

                                                                                                                                Type
                                                                                                                                @@ -695,7 +695,7 @@

                                                                                                                                Submodules
                                                                                                                                -property operator_version
                                                                                                                                +property operator_version

                                                                                                                                Version of the file such as onnx OPSET for onnx files

                                                                                                                                Type
                                                                                                                                @@ -706,7 +706,7 @@

                                                                                                                                Submodules
                                                                                                                                -property path
                                                                                                                                +property path

                                                                                                                                The path for where this file is (or can be) downloaded to

                                                                                                                                Type
                                                                                                                                @@ -717,7 +717,7 @@

                                                                                                                                Submodules
                                                                                                                                -property url
                                                                                                                                +property url

                                                                                                                                The signed url to retrieve the file.

                                                                                                                                Type
                                                                                                                                @@ -730,52 +730,52 @@

                                                                                                                                Submodules
                                                                                                                                -class sparsezoo.objects.file.FileTypes(value)[source]
                                                                                                                                +class sparsezoo.objects.file.FileTypes(value)[source]

                                                                                                                                Bases: enum.Enum

                                                                                                                                Types of files available in the sparsezoo

                                                                                                                                -CARD = 'card'
                                                                                                                                +CARD = 'card'
                                                                                                                                -DATA_INPUTS = 'inputs'
                                                                                                                                +DATA_INPUTS = 'inputs'
                                                                                                                                -DATA_LABELS = 'labels'
                                                                                                                                +DATA_LABELS = 'labels'
                                                                                                                                -DATA_ORIGINALS = 'originals'
                                                                                                                                +DATA_ORIGINALS = 'originals'
                                                                                                                                -DATA_OUTPUTS = 'outputs'
                                                                                                                                +DATA_OUTPUTS = 'outputs'
                                                                                                                                -FRAMEWORK = 'framework'
                                                                                                                                +FRAMEWORK = 'framework'
                                                                                                                                -ONNX = 'onnx'
                                                                                                                                +ONNX = 'onnx'
                                                                                                                                -ONNX_GZ = 'onnx_gz'
                                                                                                                                +ONNX_GZ = 'onnx_gz'
                                                                                                                                -RECIPE = 'recipe'
                                                                                                                                +RECIPE = 'recipe'

                                                                                                                                @@ -786,7 +786,7 @@

                                                                                                                                Submodules
                                                                                                                                -class sparsezoo.objects.metadata.ModelMetadata(domain: str, sub_domain: str, architecture: str, sub_architecture: Optional[str], framework: str, repo: str, dataset: str, training_scheme: Optional[str], optim_name: str, optim_category: str, optim_target: Optional[str], release_version: sparsezoo.objects.release_version.ReleaseVersion, model_id: str, base_model: str, user_id: str, **kwargs)[source]
                                                                                                                                +class sparsezoo.objects.metadata.ModelMetadata(domain: str, sub_domain: str, architecture: str, sub_architecture: Optional[str], framework: str, repo: str, dataset: str, training_scheme: Optional[str], optim_name: str, optim_category: str, optim_target: Optional[str], release_version: sparsezoo.objects.release_version.ReleaseVersion, model_id: str, base_model: str, user_id: str, **kwargs)[source]

                                                                                                                                Bases: sparsezoo.objects.base.BaseObject, sparsezoo.requests.base.ModelArgs

                                                                                                                                Metadata to describe a model as stored in the sparsezoo

                                                                                                                                @@ -824,7 +824,7 @@

                                                                                                                                Submodules
                                                                                                                                -property base_model
                                                                                                                                +property base_model

                                                                                                                                The id of the base model as stored in the cloud

                                                                                                                                Type
                                                                                                                                @@ -835,7 +835,7 @@

                                                                                                                                Submodules
                                                                                                                                -property model_id
                                                                                                                                +property model_id

                                                                                                                                The id for the model as stored in the cloud

                                                                                                                                Type
                                                                                                                                @@ -846,7 +846,7 @@

                                                                                                                                Submodules
                                                                                                                                -property user_id
                                                                                                                                +property user_id

                                                                                                                                The id of the user who uploaded the model as stored in the cloud

                                                                                                                                Type
                                                                                                                                @@ -863,7 +863,7 @@

                                                                                                                                Submodules
                                                                                                                                -class sparsezoo.objects.model.Model(display_name: str, display_description: str, files: Optional[List[Dict[str, Any]]] = None, recipes: Optional[List[Dict[str, Any]]] = None, results: Optional[List[Dict[str, Any]]] = None, tags: Optional[List[Dict[str, Any]]] = None, user: Optional[Dict[str, Any]] = None, release_version: Optional[Dict[str, Any]] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, **kwargs)[source]
                                                                                                                                +class sparsezoo.objects.model.Model(display_name: str, display_description: str, files: Optional[List[Dict[str, Any]]] = None, recipes: Optional[List[Dict[str, Any]]] = None, results: Optional[List[Dict[str, Any]]] = None, tags: Optional[List[Dict[str, Any]]] = None, user: Optional[Dict[str, Any]] = None, release_version: Optional[Dict[str, Any]] = None, override_folder_name: Optional[str] = None, override_parent_path: Optional[str] = None, **kwargs)[source]

                                                                                                                                Bases: sparsezoo.objects.downloadable.Downloadable, sparsezoo.objects.metadata.ModelMetadata

                                                                                                                                A model repo model

                                                                                                                                @@ -886,7 +886,7 @@

                                                                                                                                Submodules
                                                                                                                                -property card_file
                                                                                                                                +property card_file

                                                                                                                                The markdown card representing info about the model

                                                                                                                                Type
                                                                                                                                @@ -897,7 +897,7 @@

                                                                                                                                Submodules
                                                                                                                                -property data
                                                                                                                                +property data

                                                                                                                                A dictionary containing all of the Data objects for this model

                                                                                                                                Type
                                                                                                                                @@ -908,7 +908,7 @@

                                                                                                                                Submodules
                                                                                                                                -property data_inputs
                                                                                                                                +property data_inputs

                                                                                                                                sample numpy data for inputs into the model

                                                                                                                                Type
                                                                                                                                @@ -919,7 +919,7 @@

                                                                                                                                Submodules
                                                                                                                                -property data_labels
                                                                                                                                +property data_labels

                                                                                                                                sample numpy data for labels for a given input

                                                                                                                                Type
                                                                                                                                @@ -930,7 +930,7 @@

                                                                                                                                Submodules
                                                                                                                                -data_loader(batch_size: int = 1, iter_steps: int = 0, batch_as_list: bool = True)sparsezoo.utils.data.DataLoader[source]
                                                                                                                                +data_loader(batch_size: int = 1, iter_steps: int = 0, batch_as_list: bool = True)sparsezoo.utils.data.DataLoader[source]

                                                                                                                                Create a data loader containing all of the available data for this model

                                                                                                                                Parameters
                                                                                                                                @@ -951,7 +951,7 @@

                                                                                                                                Submodules
                                                                                                                                -property data_originals
                                                                                                                                +property data_originals

                                                                                                                                sample numpy data as originals before any pre processing is applied to the data to create the inputs for the model

                                                                                                                                @@ -963,7 +963,7 @@

                                                                                                                                Submodules
                                                                                                                                -property data_outputs
                                                                                                                                +property data_outputs

                                                                                                                                sample numpy data recorded as outputs from the model for a given input

                                                                                                                                Type
                                                                                                                                @@ -974,7 +974,7 @@

                                                                                                                                Submodules
                                                                                                                                -property display_description
                                                                                                                                +property display_description

                                                                                                                                the description for the model

                                                                                                                                Type
                                                                                                                                @@ -985,7 +985,7 @@

                                                                                                                                Submodules
                                                                                                                                -property display_name
                                                                                                                                +property display_name

                                                                                                                                the display name for the model

                                                                                                                                Type
                                                                                                                                @@ -996,7 +996,7 @@

                                                                                                                                Submodules
                                                                                                                                -download(overwrite: bool = False, refresh_token: bool = False, show_progress: bool = True)[source]
                                                                                                                                +download(overwrite: bool = False, refresh_token: bool = False, show_progress: bool = True)[source]

                                                                                                                                Downloads a model repo file.

                                                                                                                                Parameters
                                                                                                                                @@ -1011,7 +1011,7 @@

                                                                                                                                Submodules
                                                                                                                                -download_framework_files(overwrite: bool = False, refresh_token: bool = False, show_progress: bool = True, extensions: Optional[List[str]] = None) → List[str][source]
                                                                                                                                +download_framework_files(overwrite: bool = False, refresh_token: bool = False, show_progress: bool = True, extensions: Optional[List[str]] = None)List[str][source]

                                                                                                                                Downloads the framework file(s) for this model.

                                                                                                                                Parameters
                                                                                                                                @@ -1032,7 +1032,7 @@

                                                                                                                                Submodules
                                                                                                                                -property framework_files
                                                                                                                                +property framework_files

                                                                                                                                list of Files that are of type framework

                                                                                                                                Type
                                                                                                                                @@ -1043,7 +1043,7 @@

                                                                                                                                Submodules
                                                                                                                                -property onnx_file
                                                                                                                                +property onnx_file

                                                                                                                                The latest converted onnx file for the model

                                                                                                                                Type
                                                                                                                                @@ -1054,7 +1054,7 @@

                                                                                                                                Submodules
                                                                                                                                -property onnx_file_gz
                                                                                                                                +property onnx_file_gz

                                                                                                                                The latest converted gziped onnx file for the model

                                                                                                                                Type
                                                                                                                                @@ -1065,7 +1065,7 @@

                                                                                                                                Submodules
                                                                                                                                -property onnx_files
                                                                                                                                +property onnx_files

                                                                                                                                list of Files that are of type onnx

                                                                                                                                Type
                                                                                                                                @@ -1076,7 +1076,7 @@

                                                                                                                                Submodules
                                                                                                                                -property original_recipe
                                                                                                                                +property original_recipe

                                                                                                                                the original optimization recipe used to create the model

                                                                                                                                Type
                                                                                                                                @@ -1087,7 +1087,7 @@

                                                                                                                                Submodules
                                                                                                                                -property recipes
                                                                                                                                +property recipes

                                                                                                                                list of optimization recipes for the model

                                                                                                                                Type
                                                                                                                                @@ -1098,7 +1098,7 @@

                                                                                                                                Submodules
                                                                                                                                -property release_version
                                                                                                                                +property release_version

                                                                                                                                a model repo release version this model was released with

                                                                                                                                Type
                                                                                                                                @@ -1109,7 +1109,7 @@

                                                                                                                                Submodules
                                                                                                                                -property results
                                                                                                                                +property results

                                                                                                                                a list of model repo results for this model

                                                                                                                                Type
                                                                                                                                @@ -1120,7 +1120,7 @@

                                                                                                                                Submodules
                                                                                                                                -sample_batch(batch_index: int = 0, batch_size: int = 1, batch_as_list: bool = True) → Union[List[numpy.ndarray], Dict[str, numpy.ndarray]][source]
                                                                                                                                +sample_batch(batch_index: int = 0, batch_size: int = 1, batch_as_list: bool = True)Union[List[numpy.ndarray], Dict[str, numpy.ndarray]][source]

                                                                                                                                Get a sample batch of data from the data loader

                                                                                                                                Parameters
                                                                                                                                @@ -1139,7 +1139,7 @@

                                                                                                                                Submodules
                                                                                                                                -property tags
                                                                                                                                +property tags

                                                                                                                                a list of model repo tags for this model

                                                                                                                                Type
                                                                                                                                @@ -1150,7 +1150,7 @@

                                                                                                                                Submodules
                                                                                                                                -property transfer_learning_recipe
                                                                                                                                +property transfer_learning_recipe

                                                                                                                                the optimization recipe to use for transfer learning from the model

                                                                                                                                Type
                                                                                                                                @@ -1161,7 +1161,7 @@

                                                                                                                                Submodules
                                                                                                                                -property user
                                                                                                                                +property user

                                                                                                                                the model repo user who uploaded this model

                                                                                                                                Type
                                                                                                                                @@ -1178,7 +1178,7 @@

                                                                                                                                Submodules
                                                                                                                                -class sparsezoo.objects.optimization_recipe.OptimizationRecipe(model_metadata: sparsezoo.objects.metadata.ModelMetadata, recipe_id: str, recipe_type: str, display_description: str, **kwargs)[source]
                                                                                                                                +class sparsezoo.objects.optimization_recipe.OptimizationRecipe(model_metadata: sparsezoo.objects.metadata.ModelMetadata, recipe_id: str, recipe_type: str, display_description: str, **kwargs)[source]

                                                                                                                                Bases: sparsezoo.objects.file.File

                                                                                                                                A model repo optimization recipe.

                                                                                                                                @@ -1193,7 +1193,7 @@

                                                                                                                                Submodules
                                                                                                                                -property display_description
                                                                                                                                +property display_description

                                                                                                                                the display description for the optimization

                                                                                                                                Type
                                                                                                                                @@ -1204,7 +1204,7 @@

                                                                                                                                Submodules
                                                                                                                                -property display_name
                                                                                                                                +property display_name

                                                                                                                                the display name for the optimization

                                                                                                                                Type
                                                                                                                                @@ -1215,7 +1215,7 @@

                                                                                                                                Submodules
                                                                                                                                -property recipe_id
                                                                                                                                +property recipe_id

                                                                                                                                the optimization id

                                                                                                                                Type
                                                                                                                                @@ -1226,7 +1226,7 @@

                                                                                                                                Submodules
                                                                                                                                -property recipe_type
                                                                                                                                +property recipe_type

                                                                                                                                the type of optimizations

                                                                                                                                Type
                                                                                                                                @@ -1237,7 +1237,7 @@

                                                                                                                                Submodules
                                                                                                                                -property recipe_type_original
                                                                                                                                +property recipe_type_original

                                                                                                                                True if this is the original optimization recipe that created the model, False otherwise

                                                                                                                                @@ -1249,7 +1249,7 @@

                                                                                                                                Submodules
                                                                                                                                -property recipe_type_transfer_learn
                                                                                                                                +property recipe_type_transfer_learn

                                                                                                                                True if this is an optimization recipe for transfer learning from the created model, False otherwise

                                                                                                                                @@ -1263,17 +1263,17 @@

                                                                                                                                Submodules
                                                                                                                                -class sparsezoo.objects.optimization_recipe.OptimizationRecipeTypes(value)[source]
                                                                                                                                +class sparsezoo.objects.optimization_recipe.OptimizationRecipeTypes(value)[source]

                                                                                                                                Bases: enum.Enum

                                                                                                                                Types of recipes available in the sparsezoo

                                                                                                                                -ORIGINAL = 'original'
                                                                                                                                +ORIGINAL = 'original'
                                                                                                                                -TRANSFER_LEARN = 'transfer_learn'
                                                                                                                                +TRANSFER_LEARN = 'transfer_learn'

                                                                                                                                @@ -1284,7 +1284,7 @@

                                                                                                                                Submodules
                                                                                                                                -class sparsezoo.objects.release_version.ReleaseVersion(release_version_id: str, major_version: str, minor_version: str, patch_version: str, published: bool, **kwargs)[source]
                                                                                                                                +class sparsezoo.objects.release_version.ReleaseVersion(release_version_id: str, major_version: str, minor_version: str, patch_version: str, published: bool, **kwargs)[source]

                                                                                                                                Bases: sparsezoo.objects.base.BaseObject

                                                                                                                                A model repo semantic release version. Will represent a version in the format

                                                                                                                                MAJOR.MINOR.PATCH

                                                                                                                                @@ -1301,7 +1301,7 @@

                                                                                                                                Submodules
                                                                                                                                -property major_version
                                                                                                                                +property major_version

                                                                                                                                the major version of the release

                                                                                                                                Type
                                                                                                                                @@ -1312,7 +1312,7 @@

                                                                                                                                Submodules
                                                                                                                                -property minor_version
                                                                                                                                +property minor_version

                                                                                                                                the minor version of the release

                                                                                                                                Type
                                                                                                                                @@ -1323,7 +1323,7 @@

                                                                                                                                Submodules
                                                                                                                                -property patch_version
                                                                                                                                +property patch_version

                                                                                                                                the patchversion of the release

                                                                                                                                Type
                                                                                                                                @@ -1334,7 +1334,7 @@

                                                                                                                                Submodules
                                                                                                                                -property published
                                                                                                                                +property published

                                                                                                                                whether the release has been officially published

                                                                                                                                Type
                                                                                                                                @@ -1345,7 +1345,7 @@

                                                                                                                                Submodules
                                                                                                                                -property release_version_id
                                                                                                                                +property release_version_id

                                                                                                                                the release version id

                                                                                                                                Type
                                                                                                                                @@ -1362,7 +1362,7 @@

                                                                                                                                Submodules
                                                                                                                                -class sparsezoo.objects.result.Result(result_id: str, display_name: str, result_type: str, result_category: str, model_id: str, recorded_value: float, recorded_units: str, recorded_format: str, **kwargs)[source]
                                                                                                                                +class sparsezoo.objects.result.Result(result_id: str, display_name: str, result_type: str, result_category: str, model_id: str, recorded_value: float, recorded_units: str, recorded_format: str, **kwargs)[source]

                                                                                                                                Bases: sparsezoo.objects.base.BaseObject

                                                                                                                                A model repo metric result such as for performance, accuracy, etc

                                                                                                                                @@ -1381,7 +1381,7 @@

                                                                                                                                Submodules
                                                                                                                                -property display_name
                                                                                                                                +property display_name

                                                                                                                                the display name for the result

                                                                                                                                Type
                                                                                                                                @@ -1392,7 +1392,7 @@

                                                                                                                                Submodules
                                                                                                                                -property model_id
                                                                                                                                +property model_id

                                                                                                                                the model id of the model the result is for

                                                                                                                                Type
                                                                                                                                @@ -1403,7 +1403,7 @@

                                                                                                                                Submodules
                                                                                                                                -property recorded_format
                                                                                                                                +property recorded_format

                                                                                                                                any information of recorded format

                                                                                                                                Type
                                                                                                                                @@ -1414,7 +1414,7 @@

                                                                                                                                Submodules
                                                                                                                                -property recorded_units
                                                                                                                                +property recorded_units

                                                                                                                                the units the recorded value was in

                                                                                                                                Type
                                                                                                                                @@ -1425,7 +1425,7 @@

                                                                                                                                Submodules
                                                                                                                                -property recorded_value
                                                                                                                                +property recorded_value

                                                                                                                                the recorded value of the result

                                                                                                                                Type
                                                                                                                                @@ -1436,7 +1436,7 @@

                                                                                                                                Submodules
                                                                                                                                -property result_category
                                                                                                                                +property result_category

                                                                                                                                the result category e.g. cpu or gpu

                                                                                                                                Type
                                                                                                                                @@ -1447,7 +1447,7 @@

                                                                                                                                Submodules
                                                                                                                                -property result_id
                                                                                                                                +property result_id

                                                                                                                                the result id

                                                                                                                                Type
                                                                                                                                @@ -1458,7 +1458,7 @@

                                                                                                                                Submodules
                                                                                                                                -property result_type
                                                                                                                                +property result_type

                                                                                                                                the result type e.g. benchmark or performance

                                                                                                                                Type
                                                                                                                                @@ -1475,7 +1475,7 @@

                                                                                                                                Submodules
                                                                                                                                -class sparsezoo.objects.tag.Tag(tag_id: str, display_name: str, model_id: str, recipe_id: str, name: str, **kwargs)[source]
                                                                                                                                +class sparsezoo.objects.tag.Tag(tag_id: str, display_name: str, model_id: str, recipe_id: str, name: str, **kwargs)[source]

                                                                                                                                Bases: sparsezoo.objects.base.BaseObject

                                                                                                                                A tag for a Model or OptimizationRecipe

                                                                                                                                @@ -1492,7 +1492,7 @@

                                                                                                                                Submodules
                                                                                                                                -property display_name
                                                                                                                                +property display_name

                                                                                                                                the display name for tag

                                                                                                                                Type
                                                                                                                                @@ -1503,7 +1503,7 @@

                                                                                                                                Submodules
                                                                                                                                -property model_id
                                                                                                                                +property model_id

                                                                                                                                the model id of the model the tag is associated with

                                                                                                                                Type
                                                                                                                                @@ -1514,7 +1514,7 @@

                                                                                                                                Submodules
                                                                                                                                -property name
                                                                                                                                +property name

                                                                                                                                the name for the tag

                                                                                                                                Type
                                                                                                                                @@ -1525,7 +1525,7 @@

                                                                                                                                Submodules
                                                                                                                                -property recipe_id
                                                                                                                                +property recipe_id

                                                                                                                                the optimization id if tag is associated with an OptimizationRecipe

                                                                                                                                Type
                                                                                                                                @@ -1536,7 +1536,7 @@

                                                                                                                                Submodules
                                                                                                                                -property tag_id
                                                                                                                                +property tag_id

                                                                                                                                the tag id

                                                                                                                                Type
                                                                                                                                @@ -1553,7 +1553,7 @@

                                                                                                                                Submodules
                                                                                                                                -class sparsezoo.objects.user.User(email: str, name: str, user_id: str, trusted: bool, **kwargs)[source]
                                                                                                                                +class sparsezoo.objects.user.User(email: str, name: str, user_id: str, trusted: bool, **kwargs)[source]

                                                                                                                                Bases: sparsezoo.objects.base.BaseObject

                                                                                                                                A model repo user

                                                                                                                                @@ -1568,7 +1568,7 @@

                                                                                                                                Submodules
                                                                                                                                -property email
                                                                                                                                +property email

                                                                                                                                contact email

                                                                                                                                Type
                                                                                                                                @@ -1579,7 +1579,7 @@

                                                                                                                                Submodules
                                                                                                                                -property name
                                                                                                                                +property name

                                                                                                                                name of user

                                                                                                                                Type
                                                                                                                                @@ -1590,7 +1590,7 @@

                                                                                                                                Submodules
                                                                                                                                -property trusted
                                                                                                                                +property trusted

                                                                                                                                Whether the user is a trusted source

                                                                                                                                Type
                                                                                                                                @@ -1601,7 +1601,7 @@

                                                                                                                                Submodules
                                                                                                                                -property user_id
                                                                                                                                +property user_id

                                                                                                                                user id

                                                                                                                                Type
                                                                                                                                diff --git a/sparsezoo/api/sparsezoo.requests.html b/sparsezoo/api/sparsezoo.requests.html index 84dec86bb74..421f4833bf2 100644 --- a/sparsezoo/api/sparsezoo.requests.html +++ b/sparsezoo/api/sparsezoo.requests.html @@ -212,7 +212,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparsezoo.requests.authentication.get_auth_header(authentication_type: str = 'public', user_id: Optional[str] = None, app_id: Optional[str] = None, force_token_refresh: bool = False) → Dict[source]
                                                                                                                                +sparsezoo.requests.authentication.get_auth_header(authentication_type: str = 'public', user_id: Optional[str] = None, app_id: Optional[str] = None, force_token_refresh: bool = False)Dict[source]

                                                                                                                                Obtain an authentication header token from either credentials file or from APIs if token is over 1 day old. Location of credentials file can be changed by setting the environment variable NM_SPARSE_ZOO_CREDENTIALS.

                                                                                                                                @@ -239,7 +239,7 @@

                                                                                                                                Submodules
                                                                                                                                -class sparsezoo.requests.base.ModelArgs(domain: Optional[str] = None, sub_domain: Optional[str] = None, architecture: Optional[Union[str, List[str]]] = None, sub_architecture: Optional[Union[str, List[str]]] = None, framework: Optional[Union[str, List[str]]] = None, repo: Optional[Union[str, List[str]]] = None, dataset: Optional[Union[str, List[str]]] = None, training_scheme: Optional[Union[str, List[str]]] = None, optim_name: Optional[Union[str, List[str]]] = None, optim_category: Optional[Union[str, List[str]]] = None, optim_target: Optional[Union[str, List[str]]] = None, release_version: Optional[Union[str, Any]] = None, **kwargs)[source]
                                                                                                                                +class sparsezoo.requests.base.ModelArgs(domain: Optional[str] = None, sub_domain: Optional[str] = None, architecture: Optional[Union[str, List[str]]] = None, sub_architecture: Optional[Union[str, List[str]]] = None, framework: Optional[Union[str, List[str]]] = None, repo: Optional[Union[str, List[str]]] = None, dataset: Optional[Union[str, List[str]]] = None, training_scheme: Optional[Union[str, List[str]]] = None, optim_name: Optional[Union[str, List[str]]] = None, optim_category: Optional[Union[str, List[str]]] = None, optim_target: Optional[Union[str, List[str]]] = None, release_version: Optional[Union[str, Any]] = None, **kwargs)[source]

                                                                                                                                Bases: object

                                                                                                                                Arguments for making requests into the sparsezoo

                                                                                                                                @@ -274,7 +274,7 @@

                                                                                                                                Submodules
                                                                                                                                -property architecture
                                                                                                                                +property architecture

                                                                                                                                The architecture of the model the object belongs to; e.g. resnet_v1, mobilenet_v1

                                                                                                                                @@ -286,7 +286,7 @@

                                                                                                                                Submodules
                                                                                                                                -property architecture_id
                                                                                                                                +property architecture_id

                                                                                                                                Unique id for the model architecture containing both the architecture and sub_architecture

                                                                                                                                @@ -298,7 +298,7 @@

                                                                                                                                Submodules
                                                                                                                                -property dataset
                                                                                                                                +property dataset

                                                                                                                                The dataset the model the object belongs to was trained on; e.g. imagenet, cifar10

                                                                                                                                @@ -310,7 +310,7 @@

                                                                                                                                Submodules
                                                                                                                                -property domain
                                                                                                                                +property domain

                                                                                                                                The domain of the model the object belongs to; e.g. cv, nlp

                                                                                                                                @@ -322,7 +322,7 @@

                                                                                                                                Submodules
                                                                                                                                -property framework
                                                                                                                                +property framework

                                                                                                                                The framework the model the object belongs to was trained on; e.g. pytorch, tensorflow

                                                                                                                                @@ -334,7 +334,7 @@

                                                                                                                                Submodules
                                                                                                                                -property model_url_args
                                                                                                                                +property model_url_args

                                                                                                                                arguments for searching in the sparsezoo

                                                                                                                                Type
                                                                                                                                @@ -345,7 +345,7 @@

                                                                                                                                Submodules
                                                                                                                                -property model_url_root
                                                                                                                                +property model_url_root

                                                                                                                                root path for where the model is located in the sparsezoo

                                                                                                                                Type
                                                                                                                                @@ -356,7 +356,7 @@

                                                                                                                                Submodules
                                                                                                                                -property optim_category
                                                                                                                                +property optim_category

                                                                                                                                The degree of optimization of the model the object belongs to; e.g. none, conservative (~100% baseline metric), moderate (>=99% baseline metric), aggressive (<99% baseline metric)

                                                                                                                                @@ -369,7 +369,7 @@

                                                                                                                                Submodules
                                                                                                                                -property optim_name
                                                                                                                                +property optim_name

                                                                                                                                The name describing the optimization of the model the object belongs to, e.g. base, pruned, pruned_quant

                                                                                                                                @@ -381,7 +381,7 @@

                                                                                                                                Submodules
                                                                                                                                -property optim_target
                                                                                                                                +property optim_target

                                                                                                                                The deployment target of optimization of the model the object belongs to; e.g. edge, deepsparse, deepsparse_throughput, gpu

                                                                                                                                @@ -393,7 +393,7 @@

                                                                                                                                Submodules
                                                                                                                                -property optimization_id
                                                                                                                                +property optimization_id

                                                                                                                                Unique id for how the model was optimized containing the optim_name, optim_category, optim_target

                                                                                                                                @@ -405,7 +405,7 @@

                                                                                                                                Submodules
                                                                                                                                -property release_version
                                                                                                                                +property release_version

                                                                                                                                The sparsezoo release version for the model

                                                                                                                                Type
                                                                                                                                @@ -416,7 +416,7 @@

                                                                                                                                Submodules
                                                                                                                                -property repo
                                                                                                                                +property repo

                                                                                                                                the source repo for the model the object belongs to; e.g. sparseml, torchvision

                                                                                                                                @@ -428,7 +428,7 @@

                                                                                                                                Submodules
                                                                                                                                -property stub
                                                                                                                                +property stub

                                                                                                                                full path for where the model is located in the sparsezoo

                                                                                                                                Type
                                                                                                                                @@ -439,7 +439,7 @@

                                                                                                                                Submodules
                                                                                                                                -property sub_architecture
                                                                                                                                +property sub_architecture

                                                                                                                                The sub architecture (scaling factor) of the model the object belongs to; e.g. 50, 101, 152

                                                                                                                                @@ -451,7 +451,7 @@

                                                                                                                                Submodules
                                                                                                                                -property sub_domain
                                                                                                                                +property sub_domain

                                                                                                                                The sub domain of the model the object belongs to; e.g. classification, segmentation

                                                                                                                                @@ -463,7 +463,7 @@

                                                                                                                                Submodules
                                                                                                                                -property training_id
                                                                                                                                +property training_id

                                                                                                                                Unique id for how the model was trained containing both the dataset and training_scheme

                                                                                                                                @@ -475,7 +475,7 @@

                                                                                                                                Submodules
                                                                                                                                -property training_scheme
                                                                                                                                +property training_scheme

                                                                                                                                The training scheme used on the model the object belongs to if any; e.g. augmented

                                                                                                                                @@ -493,7 +493,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparsezoo.requests.download.download_get_request(args: Union[sparsezoo.requests.base.ModelArgs, str], file_name: Optional[str] = None, force_token_refresh: bool = False) → Dict[source]
                                                                                                                                +sparsezoo.requests.download.download_get_request(args: Union[sparsezoo.requests.base.ModelArgs, str], file_name: Optional[str] = None, force_token_refresh: bool = False)Dict[source]

                                                                                                                                Get a downloadable model from the sparsezoo for any objects matching the args

                                                                                                                                Parameters
                                                                                                                                @@ -515,7 +515,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparsezoo.requests.search.search_get_request(args: sparsezoo.requests.base.ModelArgs, page: int = 1, page_length: int = 20, force_token_refresh: bool = False) → Dict[source]
                                                                                                                                +sparsezoo.requests.search.search_get_request(args: sparsezoo.requests.base.ModelArgs, page: int = 1, page_length: int = 20, force_token_refresh: bool = False)Dict[source]

                                                                                                                                Search the sparsezoo for any objects matching the args

                                                                                                                                Parameters
                                                                                                                                diff --git a/sparsezoo/api/sparsezoo.utils.html b/sparsezoo/api/sparsezoo.utils.html index 12f1d830a9b..f9e88f92165 100644 --- a/sparsezoo/api/sparsezoo.utils.html +++ b/sparsezoo/api/sparsezoo.utils.html @@ -211,7 +211,7 @@

                                                                                                                                Submodules
                                                                                                                                -class sparsezoo.utils.data.DataLoader(*datasets: sparsezoo.utils.data.Dataset, batch_size: int, iter_steps: int = 0, batch_as_list: bool = False)[source]
                                                                                                                                +class sparsezoo.utils.data.DataLoader(*datasets: sparsezoo.utils.data.Dataset, batch_size: int, iter_steps: int = 0, batch_as_list: bool = False)[source]

                                                                                                                                Bases: Iterable

                                                                                                                                Data loader instance that supports loading numpy arrays from file or memory and creating an iterator to go through batches of that data. @@ -231,7 +231,7 @@

                                                                                                                                Submodules
                                                                                                                                -property batch_as_list
                                                                                                                                +property batch_as_list

                                                                                                                                True to create the items from each dataset as a list, False for an ordereddict

                                                                                                                                @@ -243,7 +243,7 @@

                                                                                                                                Submodules
                                                                                                                                -property batch_size
                                                                                                                                +property batch_size

                                                                                                                                the size of batches to create for the iterator

                                                                                                                                Type
                                                                                                                                @@ -254,7 +254,7 @@

                                                                                                                                Submodules
                                                                                                                                -property datasets
                                                                                                                                +property datasets

                                                                                                                                any number of datasets to load for the dataloader

                                                                                                                                Type
                                                                                                                                @@ -265,7 +265,7 @@

                                                                                                                                Submodules
                                                                                                                                -get_batch(bath_index: int) → Union[Dict[str, Union[List[numpy.ndarray], Dict[str, numpy.ndarray]]], List[numpy.ndarray], Dict[str, numpy.ndarray]][source]
                                                                                                                                +get_batch(bath_index: int)Union[Dict[str, Union[List[numpy.ndarray], Dict[str, numpy.ndarray]]], List[numpy.ndarray], Dict[str, numpy.ndarray]][source]

                                                                                                                                Get a batch from the data at the given index

                                                                                                                                Parameters
                                                                                                                                @@ -279,7 +279,7 @@

                                                                                                                                Submodules
                                                                                                                                -property infinite
                                                                                                                                +property infinite

                                                                                                                                True if the loader instance is setup to continually create batches, False otherwise

                                                                                                                                @@ -291,7 +291,7 @@

                                                                                                                                Submodules
                                                                                                                                -property iter_steps
                                                                                                                                +property iter_steps

                                                                                                                                the number of steps (batches) to create. Set to -1 for infinite, 0 for running through the loaded data once, or a positive integer for the desired number of steps

                                                                                                                                @@ -304,7 +304,7 @@

                                                                                                                                Submodules
                                                                                                                                -property num_items
                                                                                                                                +property num_items

                                                                                                                                the number of items in each dataset

                                                                                                                                Type
                                                                                                                                @@ -317,7 +317,7 @@

                                                                                                                                Submodules
                                                                                                                                -class sparsezoo.utils.data.Dataset(name: str, data: Union[str, Iterable[Union[str, numpy.ndarray, Dict[str, numpy.ndarray]]]])[source]
                                                                                                                                +class sparsezoo.utils.data.Dataset(name: str, data: Union[str, Iterable[Union[str, numpy.ndarray, Dict[str, numpy.ndarray]]]])[source]

                                                                                                                                Bases: Iterable

                                                                                                                                A numpy dataset implementation

                                                                                                                                @@ -334,7 +334,7 @@

                                                                                                                                Submodules
                                                                                                                                -property data
                                                                                                                                +property data

                                                                                                                                The list of data items for the dataset.

                                                                                                                                Type
                                                                                                                                @@ -345,7 +345,7 @@

                                                                                                                                Submodules
                                                                                                                                -property name
                                                                                                                                +property name

                                                                                                                                The name for the dataset

                                                                                                                                Type
                                                                                                                                @@ -358,7 +358,7 @@

                                                                                                                                Submodules
                                                                                                                                -class sparsezoo.utils.data.RandomDataset(name: str, typed_shapes: Dict[str, Tuple[Iterable[int], Optional[numpy.dtype]]], num_samples: int = 20)[source]
                                                                                                                                +class sparsezoo.utils.data.RandomDataset(name: str, typed_shapes: Dict[str, Tuple[Iterable[int], Optional[numpy.dtype]]], num_samples: int = 20)[source]

                                                                                                                                Bases: sparsezoo.utils.data.Dataset

                                                                                                                                A numpy dataset created from random data

                                                                                                                                @@ -381,29 +381,29 @@

                                                                                                                                Submodules
                                                                                                                                -class sparsezoo.utils.downloader.DownloadProgress(chunk_size, downloaded, content_length, path)
                                                                                                                                +class sparsezoo.utils.downloader.DownloadProgress(chunk_size, downloaded, content_length, path)

                                                                                                                                Bases: tuple

                                                                                                                                -property chunk_size
                                                                                                                                +property chunk_size

                                                                                                                                Alias for field number 0

                                                                                                                                -property content_length
                                                                                                                                +property content_length

                                                                                                                                Alias for field number 2

                                                                                                                                -property downloaded
                                                                                                                                +property downloaded

                                                                                                                                Alias for field number 1

                                                                                                                                -property path
                                                                                                                                +property path

                                                                                                                                Alias for field number 3

                                                                                                                                @@ -411,14 +411,14 @@

                                                                                                                                Submodules
                                                                                                                                -exception sparsezoo.utils.downloader.PreviouslyDownloadedError(*args: object)[source]
                                                                                                                                +exception sparsezoo.utils.downloader.PreviouslyDownloadedError(*args: object)[source]

                                                                                                                                Bases: Exception

                                                                                                                                Error raised when a file has already been downloaded and overwrite is False

                                                                                                                                -sparsezoo.utils.downloader.download_file(url_path: str, dest_path: str, overwrite: bool, num_retries: int = 3, show_progress: bool = True, progress_title: Optional[str] = None)[source]
                                                                                                                                +sparsezoo.utils.downloader.download_file(url_path: str, dest_path: str, overwrite: bool, num_retries: int = 3, show_progress: bool = True, progress_title: Optional[str] = None)[source]

                                                                                                                                Download a file from the given url to the desired local path

                                                                                                                                Parameters
                                                                                                                                @@ -442,7 +442,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparsezoo.utils.downloader.download_file_iter(url_path: str, dest_path: str, overwrite: bool, num_retries: int = 3) → Iterator[sparsezoo.utils.downloader.DownloadProgress][source]
                                                                                                                                +sparsezoo.utils.downloader.download_file_iter(url_path: str, dest_path: str, overwrite: bool, num_retries: int = 3)Iterator[sparsezoo.utils.downloader.DownloadProgress][source]

                                                                                                                                Download a file from the given url to the desired local path

                                                                                                                                Parameters
                                                                                                                                @@ -470,7 +470,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparsezoo.utils.helpers.clean_path(path: str) → str[source]
                                                                                                                                +sparsezoo.utils.helpers.clean_path(path: str)str[source]
                                                                                                                                Parameters

                                                                                                                                path – the directory or file path to clean

                                                                                                                                @@ -483,7 +483,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparsezoo.utils.helpers.create_dirs(path: str)[source]
                                                                                                                                +sparsezoo.utils.helpers.create_dirs(path: str)[source]
                                                                                                                                Parameters

                                                                                                                                path – the directory path to try and create

                                                                                                                                @@ -493,7 +493,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparsezoo.utils.helpers.create_parent_dirs(path: str)[source]
                                                                                                                                +sparsezoo.utils.helpers.create_parent_dirs(path: str)[source]
                                                                                                                                Parameters

                                                                                                                                path – the file path to try to create the parent directories for

                                                                                                                                @@ -503,7 +503,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparsezoo.utils.helpers.create_tqdm_auto_constructor() → Union[tqdm.std.tqdm, tqdm.tqdm_notebook][source]
                                                                                                                                +sparsezoo.utils.helpers.create_tqdm_auto_constructor()Union[tqdm.std.tqdm, tqdm.tqdm_notebook][source]
                                                                                                                                Returns

                                                                                                                                the tqdm instance to use for progress. @@ -515,8 +515,8 @@

                                                                                                                                Submodules
                                                                                                                                -sparsezoo.utils.helpers.tqdm_auto
                                                                                                                                -

                                                                                                                                alias of tqdm.asyncio.tqdm_asyncio

                                                                                                                                +sparsezoo.utils.helpers.tqdm_auto +

                                                                                                                                alias of tqdm.std.tqdm

                                                                                                                                @@ -525,14 +525,14 @@

                                                                                                                                Submodules
                                                                                                                                -class sparsezoo.utils.numpy.NumpyArrayBatcher[source]
                                                                                                                                +class sparsezoo.utils.numpy.NumpyArrayBatcher[source]

                                                                                                                                Bases: object

                                                                                                                                Batcher instance to handle taking in dictionaries of numpy arrays, appending multiple items to them to increase their batch size, and then stack them into a single batched numpy array for all keys in the dicts.

                                                                                                                                -append(item: Union[numpy.ndarray, Dict[str, numpy.ndarray]])[source]
                                                                                                                                +append(item: Union[numpy.ndarray, Dict[str, numpy.ndarray]])[source]

                                                                                                                                Append a new item into the current batch. All keys and shapes must match the current state.

                                                                                                                                @@ -544,7 +544,7 @@

                                                                                                                                Submodules
                                                                                                                                -stack(as_list: bool = False) → Union[List[numpy.ndarray], Dict[str, numpy.ndarray]][source]
                                                                                                                                +stack(as_list: bool = False)Union[List[numpy.ndarray], Dict[str, numpy.ndarray]][source]

                                                                                                                                Stack the current items into a batch along a new, zeroed dimension

                                                                                                                                Parameters
                                                                                                                                @@ -561,7 +561,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparsezoo.utils.numpy.load_numpy(file_path: str) → Union[numpy.ndarray, Dict[str, numpy.ndarray]][source]
                                                                                                                                +sparsezoo.utils.numpy.load_numpy(file_path: str)Union[numpy.ndarray, Dict[str, numpy.ndarray]][source]

                                                                                                                                Load a numpy file into either an ndarray or an OrderedDict representing what was in the npz file :param file_path: the file_path to load @@ -570,7 +570,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparsezoo.utils.numpy.load_numpy_list(data: Union[str, Iterable[Union[str, numpy.ndarray, Dict[str, numpy.ndarray]]]]) → List[Union[numpy.ndarray, Dict[str, numpy.ndarray]]][source]
                                                                                                                                +sparsezoo.utils.numpy.load_numpy_list(data: Union[str, Iterable[Union[str, numpy.ndarray, Dict[str, numpy.ndarray]]]])List[Union[numpy.ndarray, Dict[str, numpy.ndarray]]][source]

                                                                                                                                Load numpy data into a list

                                                                                                                                Parameters
                                                                                                                                @@ -585,7 +585,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparsezoo.utils.numpy.save_numpy(array: Union[numpy.ndarray, Dict[str, numpy.ndarray], Iterable[numpy.ndarray]], export_dir: str, name: str, npz: bool = True)[source]
                                                                                                                                +sparsezoo.utils.numpy.save_numpy(array: Union[numpy.ndarray, Dict[str, numpy.ndarray], Iterable[numpy.ndarray]], export_dir: str, name: str, npz: bool = True)[source]

                                                                                                                                Save a numpy array or collection of numpy arrays to disk

                                                                                                                                Parameters
                                                                                                                                @@ -605,7 +605,7 @@

                                                                                                                                Submodules
                                                                                                                                -sparsezoo.utils.numpy.tensor_export(tensor: Union[numpy.ndarray, Dict[str, numpy.ndarray], Iterable[numpy.ndarray]], export_dir: str, name: str, npz: bool = True) → str[source]
                                                                                                                                +sparsezoo.utils.numpy.tensor_export(tensor: Union[numpy.ndarray, Dict[str, numpy.ndarray], Iterable[numpy.ndarray]], export_dir: str, name: str, npz: bool = True)str[source]
                                                                                                                                Parameters
                                                                                                                                -
                                                                                                                                • sparsezoo.objects.data @@ -912,6 +876,8 @@

                                                                                                                                  S

                                                                                                                                • module
                                                                                                                                +

                                                                                                                              +
                                                                                                                              • sparsezoo.objects.file diff --git a/sparsezoo/objects.inv b/sparsezoo/objects.inv index 399b653110d..2f1de0f98b2 100644 Binary files a/sparsezoo/objects.inv and b/sparsezoo/objects.inv differ diff --git a/sparsezoo/py-modindex.html b/sparsezoo/py-modindex.html index ec1fd5ed72b..88d45f0d10c 100644 --- a/sparsezoo/py-modindex.html +++ b/sparsezoo/py-modindex.html @@ -253,16 +253,6 @@

                                                                                                                                Python Module Index

                                                                                                                                    sparsezoo.models.zoo - - -     - sparsezoo.nbutils - - - -     - sparsezoo.nbutils.utils -     diff --git a/sparsezoo/searchindex.js b/sparsezoo/searchindex.js index 6ecff9526c3..d9533acacb4 100644 --- a/sparsezoo/searchindex.js +++ b/sparsezoo/searchindex.js @@ -1 +1 @@ -Search.setIndex({docnames:["api/modules","api/sparsezoo","api/sparsezoo.models","api/sparsezoo.models.classification","api/sparsezoo.models.detection","api/sparsezoo.nbutils","api/sparsezoo.objects","api/sparsezoo.requests","api/sparsezoo.utils","index","installation","models","quicktour","recipes"],envversion:{"sphinx.domains.c":2,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":3,"sphinx.domains.index":1,"sphinx.domains.javascript":2,"sphinx.domains.math":2,"sphinx.domains.python":2,"sphinx.domains.rst":2,"sphinx.domains.std":1,"sphinx.ext.intersphinx":1,"sphinx.ext.viewcode":1,sphinx:56},filenames:["api/modules.rst","api/sparsezoo.rst","api/sparsezoo.models.rst","api/sparsezoo.models.classification.rst","api/sparsezoo.models.detection.rst","api/sparsezoo.nbutils.rst","api/sparsezoo.objects.rst","api/sparsezoo.requests.rst","api/sparsezoo.utils.rst","index.rst","installation.md","models.md","quicktour.md","recipes.md"],objects:{"":{sparsezoo:[1,0,0,"-"]},"sparsezoo.main":{main:[1,1,1,""]},"sparsezoo.models":{classification:[3,0,0,"-"],detection:[4,0,0,"-"],zoo:[2,0,0,"-"]},"sparsezoo.models.classification":{efficientnet:[3,0,0,"-"],inception:[3,0,0,"-"],mobilenet:[3,0,0,"-"],resnet:[3,0,0,"-"],vgg:[3,0,0,"-"]},"sparsezoo.models.classification.efficientnet":{efficientnet_b0:[3,1,1,""],efficientnet_b4:[3,1,1,""]},"sparsezoo.models.classification.inception":{inception_v3:[3,1,1,""]},"sparsezoo.models.classification.mobilenet":{mobilenet_v1:[3,1,1,""],mobilenet_v2:[3,1,1,""]},"sparsezoo.models.classification.resnet":{resnet_101:[3,1,1,""],resnet_101_2x:[3,1,1,""],resnet_152:[3,1,1,""],resnet_18:[3,1,1,""],resnet_34:[3,1,1,""],resnet_50:[3,1,1,""],resnet_50_2x:[3,1,1,""]},"sparsezoo.models.classification.vgg":{vgg_11:[3,1,1,""],vgg_11bn:[3,1,1,""],vgg_13:[3,1,1,""],vgg_13bn:[3,1,1,""],vgg_16:[3,1,1,""],vgg_16bn:[3,1,1,""],vgg_19:[3,1,1,""],vgg_19bn:[3,1,1,""]},"sparsezoo.models.detection":{ssd:[4,0,0,"-"],yolo:[4,0,0,"-"]},"sparsezoo.models.detection.ssd":{ssd_resnet50_300:[4,1,1,""]},"sparsezoo.models.detection.yolo":{yolo_v3:[4,1,1,""]},"sparsezoo.models.zoo":{Zoo:[2,2,1,""],parse_zoo_stub:[2,1,1,""]},"sparsezoo.models.zoo.Zoo":{download_recipe_base_framework_files:[2,3,1,""],download_recipe_from_stub:[2,3,1,""],load_model:[2,3,1,""],load_model_from_stub:[2,3,1,""],search_models:[2,3,1,""],search_optimized_models:[2,3,1,""],search_optimized_recipes:[2,3,1,""],search_recipes:[2,3,1,""],search_similar_models:[2,3,1,""]},"sparsezoo.nbutils":{utils:[5,0,0,"-"]},"sparsezoo.nbutils.utils":{ModelSelectWidgetContainer:[5,2,1,""],SelectDomainWidgetContainer:[5,2,1,""]},"sparsezoo.nbutils.utils.ModelSelectWidgetContainer":{create:[5,3,1,""],selected_framework:[5,3,1,""],selected_model:[5,3,1,""]},"sparsezoo.nbutils.utils.SelectDomainWidgetContainer":{create:[5,3,1,""],selected_domain_info:[5,3,1,""]},"sparsezoo.objects":{base:[6,0,0,"-"],data:[6,0,0,"-"],downloadable:[6,0,0,"-"],file:[6,0,0,"-"],metadata:[6,0,0,"-"],model:[6,0,0,"-"],optimization_recipe:[6,0,0,"-"],release_version:[6,0,0,"-"],result:[6,0,0,"-"],tag:[6,0,0,"-"],user:[6,0,0,"-"]},"sparsezoo.objects.base":{BaseObject:[6,2,1,""]},"sparsezoo.objects.base.BaseObject":{created:[6,3,1,""],dict:[6,3,1,""],modified:[6,3,1,""]},"sparsezoo.objects.data":{Data:[6,2,1,""]},"sparsezoo.objects.data.Data":{dataset:[6,3,1,""],loader:[6,3,1,""],name:[6,3,1,""],sample_batch:[6,3,1,""]},"sparsezoo.objects.downloadable":{Downloadable:[6,2,1,""]},"sparsezoo.objects.downloadable.Downloadable":{dir_path:[6,3,1,""],download:[6,3,1,""],folder_name:[6,3,1,""],override_parent_path:[6,3,1,""]},"sparsezoo.objects.file":{File:[6,2,1,""],FileTypes:[6,2,1,""]},"sparsezoo.objects.file.File":{check_download:[6,3,1,""],checkpoint:[6,3,1,""],display_name:[6,3,1,""],download:[6,3,1,""],downloaded:[6,3,1,""],downloaded_path:[6,3,1,""],downloads:[6,3,1,""],file_id:[6,3,1,""],file_size:[6,3,1,""],file_type:[6,3,1,""],file_type_card:[6,3,1,""],file_type_data:[6,3,1,""],file_type_data_inputs:[6,3,1,""],file_type_data_labels:[6,3,1,""],file_type_data_originals:[6,3,1,""],file_type_data_outputs:[6,3,1,""],file_type_framework:[6,3,1,""],file_type_onnx:[6,3,1,""],file_type_onnx_gz:[6,3,1,""],file_type_recipe:[6,3,1,""],md5:[6,3,1,""],model_metadata:[6,3,1,""],operator_version:[6,3,1,""],path:[6,3,1,""],url:[6,3,1,""]},"sparsezoo.objects.file.FileTypes":{CARD:[6,4,1,""],DATA_INPUTS:[6,4,1,""],DATA_LABELS:[6,4,1,""],DATA_ORIGINALS:[6,4,1,""],DATA_OUTPUTS:[6,4,1,""],FRAMEWORK:[6,4,1,""],ONNX:[6,4,1,""],ONNX_GZ:[6,4,1,""],RECIPE:[6,4,1,""]},"sparsezoo.objects.metadata":{ModelMetadata:[6,2,1,""]},"sparsezoo.objects.metadata.ModelMetadata":{base_model:[6,3,1,""],model_id:[6,3,1,""],user_id:[6,3,1,""]},"sparsezoo.objects.model":{Model:[6,2,1,""]},"sparsezoo.objects.model.Model":{card_file:[6,3,1,""],data:[6,3,1,""],data_inputs:[6,3,1,""],data_labels:[6,3,1,""],data_loader:[6,3,1,""],data_originals:[6,3,1,""],data_outputs:[6,3,1,""],display_description:[6,3,1,""],display_name:[6,3,1,""],download:[6,3,1,""],download_framework_files:[6,3,1,""],framework_files:[6,3,1,""],onnx_file:[6,3,1,""],onnx_file_gz:[6,3,1,""],onnx_files:[6,3,1,""],original_recipe:[6,3,1,""],recipes:[6,3,1,""],release_version:[6,3,1,""],results:[6,3,1,""],sample_batch:[6,3,1,""],tags:[6,3,1,""],transfer_learning_recipe:[6,3,1,""],user:[6,3,1,""]},"sparsezoo.objects.optimization_recipe":{OptimizationRecipe:[6,2,1,""],OptimizationRecipeTypes:[6,2,1,""]},"sparsezoo.objects.optimization_recipe.OptimizationRecipe":{display_description:[6,3,1,""],display_name:[6,3,1,""],recipe_id:[6,3,1,""],recipe_type:[6,3,1,""],recipe_type_original:[6,3,1,""],recipe_type_transfer_learn:[6,3,1,""]},"sparsezoo.objects.optimization_recipe.OptimizationRecipeTypes":{ORIGINAL:[6,4,1,""],TRANSFER_LEARN:[6,4,1,""]},"sparsezoo.objects.release_version":{ReleaseVersion:[6,2,1,""]},"sparsezoo.objects.release_version.ReleaseVersion":{major_version:[6,3,1,""],minor_version:[6,3,1,""],patch_version:[6,3,1,""],published:[6,3,1,""],release_version_id:[6,3,1,""]},"sparsezoo.objects.result":{Result:[6,2,1,""]},"sparsezoo.objects.result.Result":{display_name:[6,3,1,""],model_id:[6,3,1,""],recorded_format:[6,3,1,""],recorded_units:[6,3,1,""],recorded_value:[6,3,1,""],result_category:[6,3,1,""],result_id:[6,3,1,""],result_type:[6,3,1,""]},"sparsezoo.objects.tag":{Tag:[6,2,1,""]},"sparsezoo.objects.tag.Tag":{display_name:[6,3,1,""],model_id:[6,3,1,""],name:[6,3,1,""],recipe_id:[6,3,1,""],tag_id:[6,3,1,""]},"sparsezoo.objects.user":{User:[6,2,1,""]},"sparsezoo.objects.user.User":{email:[6,3,1,""],name:[6,3,1,""],trusted:[6,3,1,""],user_id:[6,3,1,""]},"sparsezoo.requests":{authentication:[7,0,0,"-"],base:[7,0,0,"-"],download:[7,0,0,"-"],search:[7,0,0,"-"]},"sparsezoo.requests.authentication":{get_auth_header:[7,1,1,""]},"sparsezoo.requests.base":{ModelArgs:[7,2,1,""]},"sparsezoo.requests.base.ModelArgs":{architecture:[7,3,1,""],architecture_id:[7,3,1,""],dataset:[7,3,1,""],domain:[7,3,1,""],framework:[7,3,1,""],model_url_args:[7,3,1,""],model_url_root:[7,3,1,""],optim_category:[7,3,1,""],optim_name:[7,3,1,""],optim_target:[7,3,1,""],optimization_id:[7,3,1,""],release_version:[7,3,1,""],repo:[7,3,1,""],stub:[7,3,1,""],sub_architecture:[7,3,1,""],sub_domain:[7,3,1,""],training_id:[7,3,1,""],training_scheme:[7,3,1,""]},"sparsezoo.requests.download":{download_get_request:[7,1,1,""]},"sparsezoo.requests.search":{search_get_request:[7,1,1,""]},"sparsezoo.utils":{data:[8,0,0,"-"],downloader:[8,0,0,"-"],helpers:[8,0,0,"-"],numpy:[8,0,0,"-"]},"sparsezoo.utils.data":{DataLoader:[8,2,1,""],Dataset:[8,2,1,""],RandomDataset:[8,2,1,""]},"sparsezoo.utils.data.DataLoader":{batch_as_list:[8,3,1,""],batch_size:[8,3,1,""],datasets:[8,3,1,""],get_batch:[8,3,1,""],infinite:[8,3,1,""],iter_steps:[8,3,1,""],num_items:[8,3,1,""]},"sparsezoo.utils.data.Dataset":{data:[8,3,1,""],name:[8,3,1,""]},"sparsezoo.utils.downloader":{DownloadProgress:[8,2,1,""],PreviouslyDownloadedError:[8,5,1,""],download_file:[8,1,1,""],download_file_iter:[8,1,1,""]},"sparsezoo.utils.downloader.DownloadProgress":{chunk_size:[8,3,1,""],content_length:[8,3,1,""],downloaded:[8,3,1,""],path:[8,3,1,""]},"sparsezoo.utils.helpers":{clean_path:[8,1,1,""],create_dirs:[8,1,1,""],create_parent_dirs:[8,1,1,""],create_tqdm_auto_constructor:[8,1,1,""],tqdm_auto:[8,4,1,""]},"sparsezoo.utils.numpy":{NumpyArrayBatcher:[8,2,1,""],load_numpy:[8,1,1,""],load_numpy_list:[8,1,1,""],save_numpy:[8,1,1,""],tensor_export:[8,1,1,""],tensors_export:[8,1,1,""]},"sparsezoo.utils.numpy.NumpyArrayBatcher":{append:[8,3,1,""],stack:[8,3,1,""]},sparsezoo:{main:[1,0,0,"-"],models:[2,0,0,"-"],nbutils:[5,0,0,"-"],objects:[6,0,0,"-"],requests:[7,0,0,"-"],utils:[8,0,0,"-"]}},objnames:{"0":["py","module","Python module"],"1":["py","function","Python function"],"2":["py","class","Python class"],"3":["py","method","Python method"],"4":["py","attribute","Python attribute"],"5":["py","exception","Python exception"]},objtypes:{"0":"py:module","1":"py:function","2":"py:class","3":"py:method","4":"py:attribute","5":"py:exception"},terms:{"00567":3,"02325":4,"02767":4,"03385":3,"04381":3,"04861":3,"100":[1,2,3,4,6,7,11,12,13],"101":[1,2,3,6,7,11,12,13],"101_2x":11,"11946":3,"11_bn":11,"13_bn":11,"1409":3,"1512":[3,4],"152":[1,2,3,6,7,11,12,13],"1556":3,"16_bn":11,"1704":3,"1801":3,"1804":4,"1905":3,"19_bn":11,"224":8,"300":4,"50_2x":11,"break":8,"class":[2,5,6,7,8],"default":[1,2,3,4,6,8],"enum":6,"export":8,"final":9,"float":6,"function":[2,3,4,7,8],"import":12,"int":[2,6,7,8],"new":[7,8],"public":7,"return":[2,3,4,5,6,7,8],"static":2,"true":[2,3,4,6,7,8],"try":8,"while":9,For:9,Such:[11,12],The:[1,2,3,4,6,7,8,9,11,12,13],Then:10,Will:[2,6],about:[6,8],abs:[3,4],absolut:8,acceler:9,accuraci:[6,9,11,13],activ:9,add:8,added:2,addit:[8,10,11,12],addition:9,after:[11,12],aggress:[1,2,3,4,6,7,11,12,13],algorithm:9,alia:8,all:[2,5,6,8,9,12],allow:[5,9],along:8,alreadi:[6,8],altern:9,amount:[1,6],ani:[1,2,3,4,6,7,8,10,11,12],apart:8,api:[7,9],app:7,app_id:7,append:[6,8],appli:[6,9],approach:9,arch:[11,12,13],architect:[11,12,13],architectur:[1,2,4,6,7,9,11,12,13],architecture_id:7,arg:[7,8],argument:[1,7],around:[7,9],arrai:8,arxiv:[3,4],as_list:8,associ:6,asyncio:8,augment:[1,2,3,4,6,7,11,12,13],auth:[2,3,4,6,7],authent:[0,1,9],authentication_typ:7,auto:8,automat:6,avail:[2,6,9,12],bar:8,base:[0,1,2,3,4,5,8,11,12,13],base_model:6,baselin:[1,2,3,4,6,7,9,11,12,13],baseobject:6,batch:[3,6,8],batch_as_list:[6,8],batch_index:6,batch_siz:[6,8],batcher:8,bath_index:8,been:[6,8],befor:6,belong:[1,2,3,4,6,7],below:12,benchmark:6,blob:12,blog:9,bool:[2,3,4,6,7,8],both:[7,9],break_batch:8,bug:9,build:9,built:9,cach:6,call:[6,7],can:[2,6,7,8,9,11,12],cannot:12,card:[6,11,12],card_fil:6,categori:[1,6,12],chang:7,check:6,check_download:6,checkpoint:[2,6],child:6,child_folder_nam:6,chunk_siz:8,cifar10:[1,2,3,4,6,7,11,12,13],classif:[1,2,5,6,7,9,12],classifi:[11,12],clean:8,clean_path:8,clone:10,cloud:[6,7,9],coco:[4,11,13],code:[2,5,6,7,8,9,12],collect:[8,9],com:[7,12],command:12,common:[2,9],compar:[11,12,13],compress:[8,11,12],comput:12,connect:9,conserv:[1,2,3,4,6,7,11,12,13],consol:9,constantli:9,constructor:2,contact:6,contain:[6,7,8,9,11,12],content:[0,9,11,12],content_length:8,continu:8,conveni:[2,3,4],convert:6,correctli:9,counter:8,cpu:[6,9],creat:[3,4,5,6,8,9,11,12,13],create_dir:8,create_parent_dir:8,create_tqdm_auto_constructor:8,creation:2,credenti:7,current:[2,7,8,11,12],cwd:1,dai:7,data:[0,1,11,12],data_input:6,data_label:6,data_load:6,data_origin:6,data_output:6,dataload:[6,8],dataset:[1,2,3,4,5,6,7,8,9,11,12,13],date:6,debian:10,deep:9,deepspars:[1,2,3,4,6,7,9,11,12,13],deepsparse_throughput:[1,2,3,4,6,7],defin:[11,12,13],definit:[11,12,13],degre:[1,2,3,4,6,7,9,11,12,13],depend:10,deploi:9,deploy:[1,2,3,4,6,7],depth:[11,12,13],describ:[1,2,3,4,6,7],descript:[1,6,11,12,13],descriptor:[11,12,13],desir:[6,8],dest_path:8,detect:[1,2,9],dev:9,dict:[2,5,6,7,8],dictionari:[2,6,8],differ:[2,9],dimens:8,dir:1,dir_path:6,direct:9,directori:[1,8],disk:[6,8,11,12,13],displai:[5,6],display_descript:6,display_nam:6,doc:9,document:9,doe:[11,12],domain:[1,2,5,6,7,11,12,13],done:[11,12,13],download:[0,1,2,5,9],download_fil:8,download_file_it:8,download_framework_fil:6,download_get_request:7,download_recipe_base_framework_fil:2,download_recipe_from_stub:2,downloaded_path:[6,12],downloadprogress:8,driven:9,dtype:8,each:[5,6,8,11,12,13],easi:12,easili:9,edg:[1,2,3,4,6,7,11,12,13],edit:9,effect:9,effici:8,efficientnet:[1,2,11,13],efficientnet_b0:3,efficientnet_b4:3,either:[7,8],email:6,empti:[2,6],enabl:[9,12],encod:[2,9],encompass:9,engin:9,entri:12,env:6,environ:[7,10,11,12,13],error:8,etc:6,everyth:9,exampl:[9,11,12,13],except:8,exist:[6,8],exit:1,expand:8,expect:2,explor:10,export_dir:8,extens:[2,6,8,11,12],factor:[1,2,6,7],fail:8,fals:[2,3,4,6,7,8],faster:9,featur:9,few:9,fft:9,field:8,file:[0,1,2,3,4,7,8,11,12],file_id:6,file_nam:7,file_path:8,file_s:6,file_typ:6,file_type_card:6,file_type_data:6,file_type_data_input:6,file_type_data_label:6,file_type_data_origin:6,file_type_data_output:6,file_type_framework:6,file_type_onnx:6,file_type_onnx_gz:6,file_type_recip:6,filetyp:6,filter:[2,6],filter_dataset:5,filter_framework:5,float32:8,flow:[6,9],folder:[1,2,3,4,6,8],folder_nam:6,follow:[6,11,12,13],forc:[5,7],force_token_refresh:[2,3,4,7],format:[1,6,8,9,11,12],found:[6,9],framework:[1,2,3,4,5,6,7,11,12,13],framework_fil:6,from:[1,2,6,7,8,9,11,12,13],full:[7,9],gener:[7,9],get:[2,3,4,6,7,8],get_auth_head:7,get_batch:8,github:[9,12],give:9,given:[2,6,8,9,12],gpu:[1,2,3,4,6,7,9,11,12,13],graph:[11,12,13],grow:9,guid:[11,12,13],gzip:6,gzipe:6,handl:[8,9],happen:12,has:[6,8,11,12,13],hash:6,hasn:6,header:7,help:[1,9,12],helper:[0,1],highli:9,host:9,how:[7,9,11,12,13],http:[3,4,12],identifi:[11,12,13],imag:[3,4,9],imagenet:[1,2,3,4,6,7,11,12,13],imagenett:[11,13],implement:[8,9],improv:9,incept:[1,2],inception_v3:[3,11,13],includ:9,increas:8,index:[6,8],induc:9,infer:9,infinit:[6,8],info:[6,7,8],inform:[6,9,11,12],inp:8,input:[6,11,12],instal:[8,9,12],instanc:[2,8],integ:[6,8],interact:[6,12],interfac:6,ipywidget:[5,8],item:[6,8],iter:[6,8],iter_step:[6,8],its:12,json:7,jupyt:5,keep:10,kei:[7,8],kera:[11,12],kwarg:[6,7],label:[6,11,12],latest:6,learn:[6,11,12,13],leav:2,length:[1,2,7],level:9,like:10,limit:9,line:9,linux:10,list:[2,5,6,7,8],load:[2,6,8],load_model:2,load_model_from_stub:2,load_numpi:8,load_numpy_list:8,loader:[6,8],local:[6,8],locat:7,look:5,loss:9,lower_lr:[11,12,13],machin:[11,12,13],made:[11,12,13],magic:9,mai:[2,12],main:[0,9,12],major:6,major_vers:6,make:7,manag:2,map:[5,8,11,13],markdown:6,match:[2,6,7,8,9],match_architectur:2,match_dataset:2,match_domain:2,match_framework:2,match_optim_categori:2,match_optim_nam:2,match_optim_target:2,match_repo:2,match_sub_architectur:2,match_sub_domain:2,match_training_schem:2,max:1,md5:6,memori:8,messag:1,metadata:[0,1,11,12],metric:[1,2,3,4,6,7,9,11,12,13],minor:6,minor_vers:6,mnist:11,mnistnet:11,mobilenet:[1,2],mobilenet_v1:[1,2,3,6,7,11,12,13],mobilenet_v2:[3,11],model:[0,1,5,7,8,9,13],model_id:6,model_metadata:6,model_url_arg:7,model_url_root:7,modelarg:[2,6,7],modelmetadata:6,modelselectwidgetcontain:5,moder:[1,2,3,4,6,7,11,12,13],modif:6,modifi:[6,11,12,13],modul:[0,9],multipl:[6,8],must:8,nad:8,name:[1,2,3,4,6,7,8,11,12,13],name_prefix:8,nativ:[11,12],natur:9,nbutil:[0,1],ndarrai:[6,8],nearli:9,network:[9,11,12,13],neural:9,neuralmag:[7,12],nightli:9,nlp:[1,2,6,7,11,12,13],nm_sparse_zoo_credenti:7,none:[1,2,3,4,6,7,8,11,12,13],normal:3,note:[8,12],notebook:[5,8,10],notic:9,npy:8,npz:8,num_item:8,num_retri:8,num_sampl:8,number:[6,8],numpi:[0,1,6],numpyarraybatch:8,object:[0,1,2,3,4,5,7,8,9],obtain:[2,7],occur:9,off:2,offici:[6,9],old:7,onc:[6,8],one:[2,5,6,8],onli:[7,8,9],onnx:[6,8,11,12],onnx_fil:[6,12],onnx_file_gz:6,onnx_gz:6,onto:9,operator_vers:6,opset:6,optim:[1,2,3,4,6,7,9],optim_categori:[1,2,3,4,6,7],optim_nam:[1,2,3,4,6,7],optim_target:[1,2,3,4,6,7],optimization_id:7,optimization_recip:[0,1,2],optimizationrecip:[2,6],optimizationrecipetyp:6,optimized_model:12,option:[1,2,3,4,6,7,8,11,12,13],order:[6,10],ordereddict:[6,8],org:[3,4],origin:[2,6,8,11,12,13],original_recip:6,otherwis:[2,3,4,6,7,8],output:[6,11,12],over:[7,9],overprecis:9,overrid:[2,3,4,6],override_folder_nam:[2,3,4,6],override_parent_path:[2,3,4,6],overview:[11,12,13],overwrit:[6,8],packag:[0,9,12],page:[1,2,7],page_length:[1,2,7],parallel:8,param1:2,param2:2,param:[2,8],paramet:[2,3,4,5,6,7,8],parameter:9,parent:[2,3,4,6,8],pars:2,parse_zoo_stub:2,patch:6,patch_vers:6,patchvers:6,path:[2,3,4,6,7,8],per:1,perform:[6,9],pip:10,place:12,plu:9,point:[2,12],posit:[1,6,8],pre:[6,11,12],prefix:8,preprocess:[11,12],previou:[6,8],previouslydownloadederror:8,print:[6,12],privat:9,process:[6,9,11,12],product:9,progress:[6,8],progress_titl:8,properli:12,properti:[5,6,7,8,11,12,13],prototyp:9,provid:[2,5],prune:[1,2,3,4,6,7,9,11,12,13],pruned_qu:[1,2,3,4,6,7,11,12,13],ptc:[2,6],pth:[2,6],publish:6,pypi:9,python:[9,10],pytorch:[1,2,3,4,6,7,11,12,13],quant:[11,12,13],quantiz:[9,11,12,13],quick:9,rais:[2,8],random:8,randomdataset:8,recip:[2,6,9,11,12],recipe_id:6,recipe_typ:[2,6,13],recipe_type_origin:6,recipe_type_transfer_learn:6,recommend:10,record:6,recorded_format:6,recorded_unit:6,recorded_valu:6,recov:9,recoveri:9,redund:9,refresh:[2,3,4,6,7],refresh_token:6,relat:[5,6,7,8],releas:[1,2,6,7],release_vers:[0,1,2,7],release_version_id:6,releasevers:6,remov:9,repo:[1,2,3,4,5,6,7,11,12,13],repositori:[9,10,11,12,13],repres:[2,6,8],represent:[11,12],request:[0,1,2,6,9],requir:[7,10],resnet50:4,resnet50_300:[11,13],resnet:[1,2,12],resnet_101:3,resnet_101_2x:3,resnet_152:3,resnet_18:3,resnet_34:3,resnet_50:[3,12],resnet_50_2x:3,resnet_v1:[1,2,6,7,11,12,13],resolut:6,respect:12,respons:7,result:[0,1,9],result_categori:6,result_id:6,result_typ:6,retri:8,retriev:6,root:7,run:[6,8,11,12],same:[6,9],sampl:[6,8,11,12],sample_batch:6,save:[1,2,3,4,6,8],save_dir:1,save_numpi:8,scale:[1,2,6,7,11,12,13],scheme:[1,2,3,4,6,7,12],script:[1,9,10],search:[0,1,2,5,9],search_get_request:7,search_model:[2,12],search_optimized_model:[2,12],search_optimized_recip:2,search_recip:2,search_similar_model:2,segment:[1,2,6,7,11,12,13],select:5,selectdomainwidgetcontain:5,selected_domain_info:5,selected_framework:5,selected_model:5,semant:[1,6],set:[6,7,8],setup:[8,11,12,13],shape:8,should:7,show:[1,6,8],show_progress:[6,8],sign:[2,6],signifi:13,significantli:9,similar:2,simpl:9,simplifi:9,singl:8,size:[6,8],smaller:9,solut:[11,12,13],some:12,sourc:[1,2,3,4,5,6,7,8],spars:[1,6,9,11,12],sparse_categori:[11,12,13],sparse_nam:[11,12,13],sparse_target:[11,12,13],sparseml:[1,2,3,4,6,7,9,11,12,13],sparsezoo:[10,11,12,13],sparsezoo_models_path:6,sparsif:[11,12],sparsifi:[9,11,12,13],sparsiti:9,sparszoo:6,specif:[1,11,12,13],spp:[4,11,13],ssd:[1,2,11,13],ssd_resnet50_300:4,stabl:9,stack:8,standard:8,state:8,std:8,step:[6,8],store:[6,13],str:[2,3,4,5,6,7,8],straight:12,string:2,structur:[11,12,13],stub:[2,7,11,12,13],sub:[1,2,4,5,6,7,11,12,13],sub_architectur:[1,2,4,6,7,11,12,13],sub_domain:[1,2,5,6,7,11,12,13],subdomain:5,submodul:[0,9],subpackag:[0,9],suit:9,support:[7,8,9,11,12],system:[8,10,12],tag:[0,1,11,13],tag_id:6,take:[8,9],tar:[11,12],target:[1,2,3,4,6,7,11,12,13],techniqu:9,tensor:[8,11,12],tensor_export:8,tensorflow:[1,2,3,4,6,7,11,12],tensorflow_v1:[11,12,13],tensors_export:8,termin:12,test:10,thei:8,them:[6,8],thi:[1,2,3,4,6,9,10,12],through:[5,6,8,11,12],time:[6,8,9],titl:8,token:[2,3,4,6,7],top1:[11,13],top:9,torchvis:[1,2,3,4,6,7,11,12,13],tour:9,tqdm:[6,8],tqdm_asyncio:8,tqdm_auto:8,tqdm_notebook:8,train:[1,2,3,4,5,6,7,9,11,12,13],training_id:7,training_schem:[1,2,3,4,6,7,11,12,13],transfer:[2,6,9,11,12],transfer_learn:[6,13],transfer_learning_recip:6,treat:8,trust:6,tupl:[2,8],type:[5,6,7,8,11,12,13],typed_shap:8,ultralyt:[4,11,13],under:[2,3,4,6,7,13],unexpect:2,union:[2,6,7,8],uniqu:7,unit:6,upload:6,url:[6,8],url_path:8,use:[6,8,11,12],used:[1,2,3,4,5,6,7,8,11,12],user:[0,1,7,8],user_id:[6,7],using:[5,9,10],util:[0,1,6],valid:[11,13],valid_param:2,valu:[2,6,7,8,9],value1:2,value2:2,variabl:[6,7],version:[1,2,6,7,8,9,11,13],vgg:[1,2,11,13],vgg_11:3,vgg_11bn:3,vgg_13:3,vgg_13bn:3,vgg_16:3,vgg_16bn:3,vgg_19:3,vgg_19bn:3,via:9,view:1,virtual:10,vision:12,voc:[11,13],warn:2,websit:9,weight:[2,11,12,13],well:[6,11,12],what:[7,8,11,12,13],when:[8,9],where:[2,3,4,6,7],whether:6,which:[11,12,13],who:6,widget:5,width:[3,11,12,13],winograd:9,within:[5,6,11,12,13],without:[8,11,12],work:[6,8],worker:8,would:10,wrap:7,yaml:[11,12],yolo:[1,2],yolo_v3:[4,11,13],you:[9,10,12],your:[9,10,12],zero:8,zoo:[0,1,6,8,9]},titles:["sparsezoo","sparsezoo package","sparsezoo.models package","sparsezoo.models.classification package","sparsezoo.models.detection package","sparsezoo.nbutils package","sparsezoo.objects package","sparsezoo.requests package","sparsezoo.utils package","SparseZoo 0.1","Installation","Models","Quick Tour","Recipes"],titleterms:{api:12,authent:7,base:[6,7],classif:[3,11,13],common:12,consol:12,content:[1,2,3,4,5,6,7,8],data:[6,8],detect:[4,11,13],download:[6,7,8,12],efficientnet:3,file:6,helper:8,histori:9,imag:[11,13],incept:3,instal:10,learn:9,main:1,metadata:6,mobilenet:3,model:[2,3,4,6,11,12],modul:[1,2,3,4,5,6,7,8],more:9,nbutil:5,numpi:8,object:[6,11,13],optim:12,optimization_recip:6,overview:9,packag:[1,2,3,4,5,6,7,8],python:12,quick:12,recip:13,releas:9,release_vers:6,request:7,resnet:3,resourc:9,result:6,script:12,search:[7,12],sparsezoo:[0,1,2,3,4,5,6,7,8,9],sparsif:9,ssd:4,submodul:[1,2,3,4,5,6,7,8],subpackag:[1,2],tag:6,tour:12,user:6,util:[5,8],version:12,vgg:3,yolo:4,zoo:[2,12]}}) \ No newline at end of file +Search.setIndex({docnames:["api/modules","api/sparsezoo","api/sparsezoo.models","api/sparsezoo.models.classification","api/sparsezoo.models.detection","api/sparsezoo.nbutils","api/sparsezoo.objects","api/sparsezoo.requests","api/sparsezoo.utils","index","installation","models","quicktour","recipes"],envversion:{"sphinx.domains.c":2,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":3,"sphinx.domains.index":1,"sphinx.domains.javascript":2,"sphinx.domains.math":2,"sphinx.domains.python":2,"sphinx.domains.rst":2,"sphinx.domains.std":2,"sphinx.ext.intersphinx":1,"sphinx.ext.viewcode":1,sphinx:56},filenames:["api/modules.rst","api/sparsezoo.rst","api/sparsezoo.models.rst","api/sparsezoo.models.classification.rst","api/sparsezoo.models.detection.rst","api/sparsezoo.nbutils.rst","api/sparsezoo.objects.rst","api/sparsezoo.requests.rst","api/sparsezoo.utils.rst","index.rst","installation.md","models.md","quicktour.md","recipes.md"],objects:{"":{sparsezoo:[1,0,0,"-"]},"sparsezoo.main":{main:[1,1,1,""]},"sparsezoo.models":{classification:[3,0,0,"-"],detection:[4,0,0,"-"],zoo:[2,0,0,"-"]},"sparsezoo.models.classification":{efficientnet:[3,0,0,"-"],inception:[3,0,0,"-"],mobilenet:[3,0,0,"-"],resnet:[3,0,0,"-"],vgg:[3,0,0,"-"]},"sparsezoo.models.classification.efficientnet":{efficientnet_b0:[3,1,1,""],efficientnet_b4:[3,1,1,""]},"sparsezoo.models.classification.inception":{inception_v3:[3,1,1,""]},"sparsezoo.models.classification.mobilenet":{mobilenet_v1:[3,1,1,""],mobilenet_v2:[3,1,1,""]},"sparsezoo.models.classification.resnet":{resnet_101:[3,1,1,""],resnet_101_2x:[3,1,1,""],resnet_152:[3,1,1,""],resnet_18:[3,1,1,""],resnet_34:[3,1,1,""],resnet_50:[3,1,1,""],resnet_50_2x:[3,1,1,""]},"sparsezoo.models.classification.vgg":{vgg_11:[3,1,1,""],vgg_11bn:[3,1,1,""],vgg_13:[3,1,1,""],vgg_13bn:[3,1,1,""],vgg_16:[3,1,1,""],vgg_16bn:[3,1,1,""],vgg_19:[3,1,1,""],vgg_19bn:[3,1,1,""]},"sparsezoo.models.detection":{ssd:[4,0,0,"-"],yolo:[4,0,0,"-"]},"sparsezoo.models.detection.ssd":{ssd_resnet50_300:[4,1,1,""]},"sparsezoo.models.detection.yolo":{yolo_v3:[4,1,1,""]},"sparsezoo.models.zoo":{Zoo:[2,2,1,""],parse_zoo_stub:[2,1,1,""]},"sparsezoo.models.zoo.Zoo":{download_recipe_base_framework_files:[2,3,1,""],download_recipe_from_stub:[2,3,1,""],load_model:[2,3,1,""],load_model_from_stub:[2,3,1,""],search_models:[2,3,1,""],search_optimized_models:[2,3,1,""],search_optimized_recipes:[2,3,1,""],search_recipes:[2,3,1,""],search_similar_models:[2,3,1,""]},"sparsezoo.objects":{base:[6,0,0,"-"],data:[6,0,0,"-"],downloadable:[6,0,0,"-"],file:[6,0,0,"-"],metadata:[6,0,0,"-"],model:[6,0,0,"-"],optimization_recipe:[6,0,0,"-"],release_version:[6,0,0,"-"],result:[6,0,0,"-"],tag:[6,0,0,"-"],user:[6,0,0,"-"]},"sparsezoo.objects.base":{BaseObject:[6,2,1,""]},"sparsezoo.objects.base.BaseObject":{created:[6,3,1,""],dict:[6,3,1,""],modified:[6,3,1,""]},"sparsezoo.objects.data":{Data:[6,2,1,""]},"sparsezoo.objects.data.Data":{dataset:[6,3,1,""],loader:[6,3,1,""],name:[6,3,1,""],sample_batch:[6,3,1,""]},"sparsezoo.objects.downloadable":{Downloadable:[6,2,1,""]},"sparsezoo.objects.downloadable.Downloadable":{dir_path:[6,3,1,""],download:[6,3,1,""],folder_name:[6,3,1,""],override_parent_path:[6,3,1,""]},"sparsezoo.objects.file":{File:[6,2,1,""],FileTypes:[6,2,1,""]},"sparsezoo.objects.file.File":{check_download:[6,3,1,""],checkpoint:[6,3,1,""],display_name:[6,3,1,""],download:[6,3,1,""],downloaded:[6,3,1,""],downloaded_path:[6,3,1,""],downloads:[6,3,1,""],file_id:[6,3,1,""],file_size:[6,3,1,""],file_type:[6,3,1,""],file_type_card:[6,3,1,""],file_type_data:[6,3,1,""],file_type_data_inputs:[6,3,1,""],file_type_data_labels:[6,3,1,""],file_type_data_originals:[6,3,1,""],file_type_data_outputs:[6,3,1,""],file_type_framework:[6,3,1,""],file_type_onnx:[6,3,1,""],file_type_onnx_gz:[6,3,1,""],file_type_recipe:[6,3,1,""],md5:[6,3,1,""],model_metadata:[6,3,1,""],operator_version:[6,3,1,""],path:[6,3,1,""],url:[6,3,1,""]},"sparsezoo.objects.file.FileTypes":{CARD:[6,4,1,""],DATA_INPUTS:[6,4,1,""],DATA_LABELS:[6,4,1,""],DATA_ORIGINALS:[6,4,1,""],DATA_OUTPUTS:[6,4,1,""],FRAMEWORK:[6,4,1,""],ONNX:[6,4,1,""],ONNX_GZ:[6,4,1,""],RECIPE:[6,4,1,""]},"sparsezoo.objects.metadata":{ModelMetadata:[6,2,1,""]},"sparsezoo.objects.metadata.ModelMetadata":{base_model:[6,3,1,""],model_id:[6,3,1,""],user_id:[6,3,1,""]},"sparsezoo.objects.model":{Model:[6,2,1,""]},"sparsezoo.objects.model.Model":{card_file:[6,3,1,""],data:[6,3,1,""],data_inputs:[6,3,1,""],data_labels:[6,3,1,""],data_loader:[6,3,1,""],data_originals:[6,3,1,""],data_outputs:[6,3,1,""],display_description:[6,3,1,""],display_name:[6,3,1,""],download:[6,3,1,""],download_framework_files:[6,3,1,""],framework_files:[6,3,1,""],onnx_file:[6,3,1,""],onnx_file_gz:[6,3,1,""],onnx_files:[6,3,1,""],original_recipe:[6,3,1,""],recipes:[6,3,1,""],release_version:[6,3,1,""],results:[6,3,1,""],sample_batch:[6,3,1,""],tags:[6,3,1,""],transfer_learning_recipe:[6,3,1,""],user:[6,3,1,""]},"sparsezoo.objects.optimization_recipe":{OptimizationRecipe:[6,2,1,""],OptimizationRecipeTypes:[6,2,1,""]},"sparsezoo.objects.optimization_recipe.OptimizationRecipe":{display_description:[6,3,1,""],display_name:[6,3,1,""],recipe_id:[6,3,1,""],recipe_type:[6,3,1,""],recipe_type_original:[6,3,1,""],recipe_type_transfer_learn:[6,3,1,""]},"sparsezoo.objects.optimization_recipe.OptimizationRecipeTypes":{ORIGINAL:[6,4,1,""],TRANSFER_LEARN:[6,4,1,""]},"sparsezoo.objects.release_version":{ReleaseVersion:[6,2,1,""]},"sparsezoo.objects.release_version.ReleaseVersion":{major_version:[6,3,1,""],minor_version:[6,3,1,""],patch_version:[6,3,1,""],published:[6,3,1,""],release_version_id:[6,3,1,""]},"sparsezoo.objects.result":{Result:[6,2,1,""]},"sparsezoo.objects.result.Result":{display_name:[6,3,1,""],model_id:[6,3,1,""],recorded_format:[6,3,1,""],recorded_units:[6,3,1,""],recorded_value:[6,3,1,""],result_category:[6,3,1,""],result_id:[6,3,1,""],result_type:[6,3,1,""]},"sparsezoo.objects.tag":{Tag:[6,2,1,""]},"sparsezoo.objects.tag.Tag":{display_name:[6,3,1,""],model_id:[6,3,1,""],name:[6,3,1,""],recipe_id:[6,3,1,""],tag_id:[6,3,1,""]},"sparsezoo.objects.user":{User:[6,2,1,""]},"sparsezoo.objects.user.User":{email:[6,3,1,""],name:[6,3,1,""],trusted:[6,3,1,""],user_id:[6,3,1,""]},"sparsezoo.requests":{authentication:[7,0,0,"-"],base:[7,0,0,"-"],download:[7,0,0,"-"],search:[7,0,0,"-"]},"sparsezoo.requests.authentication":{get_auth_header:[7,1,1,""]},"sparsezoo.requests.base":{ModelArgs:[7,2,1,""]},"sparsezoo.requests.base.ModelArgs":{architecture:[7,3,1,""],architecture_id:[7,3,1,""],dataset:[7,3,1,""],domain:[7,3,1,""],framework:[7,3,1,""],model_url_args:[7,3,1,""],model_url_root:[7,3,1,""],optim_category:[7,3,1,""],optim_name:[7,3,1,""],optim_target:[7,3,1,""],optimization_id:[7,3,1,""],release_version:[7,3,1,""],repo:[7,3,1,""],stub:[7,3,1,""],sub_architecture:[7,3,1,""],sub_domain:[7,3,1,""],training_id:[7,3,1,""],training_scheme:[7,3,1,""]},"sparsezoo.requests.download":{download_get_request:[7,1,1,""]},"sparsezoo.requests.search":{search_get_request:[7,1,1,""]},"sparsezoo.utils":{data:[8,0,0,"-"],downloader:[8,0,0,"-"],helpers:[8,0,0,"-"],numpy:[8,0,0,"-"]},"sparsezoo.utils.data":{DataLoader:[8,2,1,""],Dataset:[8,2,1,""],RandomDataset:[8,2,1,""]},"sparsezoo.utils.data.DataLoader":{batch_as_list:[8,3,1,""],batch_size:[8,3,1,""],datasets:[8,3,1,""],get_batch:[8,3,1,""],infinite:[8,3,1,""],iter_steps:[8,3,1,""],num_items:[8,3,1,""]},"sparsezoo.utils.data.Dataset":{data:[8,3,1,""],name:[8,3,1,""]},"sparsezoo.utils.downloader":{DownloadProgress:[8,2,1,""],PreviouslyDownloadedError:[8,5,1,""],download_file:[8,1,1,""],download_file_iter:[8,1,1,""]},"sparsezoo.utils.downloader.DownloadProgress":{chunk_size:[8,3,1,""],content_length:[8,3,1,""],downloaded:[8,3,1,""],path:[8,3,1,""]},"sparsezoo.utils.helpers":{clean_path:[8,1,1,""],create_dirs:[8,1,1,""],create_parent_dirs:[8,1,1,""],create_tqdm_auto_constructor:[8,1,1,""],tqdm_auto:[8,4,1,""]},"sparsezoo.utils.numpy":{NumpyArrayBatcher:[8,2,1,""],load_numpy:[8,1,1,""],load_numpy_list:[8,1,1,""],save_numpy:[8,1,1,""],tensor_export:[8,1,1,""],tensors_export:[8,1,1,""]},"sparsezoo.utils.numpy.NumpyArrayBatcher":{append:[8,3,1,""],stack:[8,3,1,""]},sparsezoo:{main:[1,0,0,"-"],models:[2,0,0,"-"],objects:[6,0,0,"-"],requests:[7,0,0,"-"],utils:[8,0,0,"-"]}},objnames:{"0":["py","module","Python module"],"1":["py","function","Python function"],"2":["py","class","Python class"],"3":["py","method","Python method"],"4":["py","attribute","Python attribute"],"5":["py","exception","Python exception"]},objtypes:{"0":"py:module","1":"py:function","2":"py:class","3":"py:method","4":"py:attribute","5":"py:exception"},terms:{"00567":3,"02325":4,"02767":4,"03385":3,"04381":3,"04861":3,"100":[1,2,3,4,6,7,11,12,13],"101":[1,2,3,6,7,11,12,13],"101_2x":11,"11946":3,"11_bn":11,"13_bn":11,"1409":3,"1512":[3,4],"152":[1,2,3,6,7,11,12,13],"1556":3,"16_bn":11,"1704":3,"1801":3,"1804":4,"1905":3,"19_bn":11,"224":8,"300":4,"50_2x":11,"break":8,"class":[2,6,7,8],"default":[1,2,3,4,6,8],"enum":6,"export":8,"final":9,"float":6,"function":[2,3,4,7,8],"import":12,"int":[2,6,7,8],"new":[7,8],"public":7,"return":[2,3,4,6,7,8],"static":2,"true":[2,3,4,6,7,8],"try":8,"while":9,For:9,Such:[11,12],The:[1,2,3,4,6,7,8,9,11,12,13],Then:10,Will:[2,6],about:[6,8],abs:[3,4],absolut:8,acceler:9,accuraci:[6,9,11,13],activ:9,add:8,added:2,addit:[8,10,11,12],addition:9,after:[11,12],aggress:[1,2,3,4,6,7,11,12,13],algorithm:9,alia:8,all:[2,6,8,9,12],allow:9,along:8,alreadi:[6,8],altern:9,amount:[1,6],ani:[1,2,3,4,6,7,8,10,11,12],apart:8,api:[7,9],app:7,app_id:7,append:[6,8],appli:[6,9],approach:9,arch:[11,12,13],architect:[11,12,13],architectur:[1,2,4,6,7,9,11,12,13],architecture_id:7,arg:[7,8],argument:[1,7],around:[7,9],arrai:8,arxiv:[3,4],as_list:8,associ:6,augment:[1,2,3,4,6,7,11,12,13],auth:[2,3,4,6,7],authent:[0,1,9],authentication_typ:7,auto:8,automat:6,avail:[2,6,9,12],bar:8,base:[0,1,2,3,4,8,11,12,13],base_model:6,baselin:[1,2,3,4,6,7,9,11,12,13],baseobject:6,batch:[3,6,8],batch_as_list:[6,8],batch_index:6,batch_siz:[6,8],batcher:8,bath_index:8,been:[6,8],befor:6,belong:[1,2,3,4,6,7],below:12,benchmark:6,blob:12,blog:9,bool:[2,3,4,6,7,8],both:[7,9],break_batch:8,bug:9,build:9,built:9,cach:6,call:[6,7],can:[2,6,7,8,9,11,12],cannot:12,card:[6,11,12],card_fil:6,categori:[1,6,12],chang:7,check:6,check_download:6,checkpoint:[2,6],child:6,child_folder_nam:6,chunk_siz:8,cifar10:[1,2,3,4,6,7,11,12,13],classif:[1,2,6,7,9,12],classifi:[11,12],clean:8,clean_path:8,clone:10,cloud:[6,7,9],coco:[4,11,13],code:[2,6,7,8,9,12],collect:[8,9],com:[7,12],command:12,common:[2,9],compar:[11,12,13],compress:[8,11,12],comput:12,connect:9,conserv:[1,2,3,4,6,7,11,12,13],consol:9,constantli:9,constructor:2,contact:6,contain:[6,7,8,9,11,12],content:[0,9,11,12],content_length:8,continu:8,conveni:[2,3,4],convert:6,correctli:9,counter:8,cpu:[6,9],creat:[3,4,6,8,9,11,12,13],create_dir:8,create_parent_dir:8,create_tqdm_auto_constructor:8,creation:2,credenti:7,current:[2,7,8,11,12],cwd:1,dai:7,data:[0,1,11,12],data_input:6,data_label:6,data_load:6,data_origin:6,data_output:6,dataload:[6,8],dataset:[1,2,3,4,6,7,8,9,11,12,13],date:6,debian:10,deep:9,deepspars:[1,2,3,4,6,7,9,11,12,13],deepsparse_throughput:[1,2,3,4,6,7],defin:[11,12,13],definit:[11,12,13],degre:[1,2,3,4,6,7,9,11,12,13],depend:10,deploi:9,deploy:[1,2,3,4,6,7],depth:[11,12,13],describ:[1,2,3,4,6,7],descript:[1,6,11,12,13],descriptor:[11,12,13],desir:[6,8],dest_path:8,detect:[1,2,9],dev:9,dict:[2,6,7,8],dictionari:[2,6,8],differ:[2,9],dimens:8,dir:1,dir_path:6,direct:9,directori:[1,8],disk:[6,8,11,12,13],displai:6,display_descript:6,display_nam:6,doc:9,document:9,doe:[11,12],domain:[1,2,6,7,11,12,13],done:[11,12,13],download:[0,1,2,9],download_fil:8,download_file_it:8,download_framework_fil:6,download_get_request:7,download_recipe_base_framework_fil:2,download_recipe_from_stub:2,downloaded_path:[6,12],downloadprogress:8,driven:9,dtype:8,each:[6,8,11,12,13],easi:12,easili:9,edg:[1,2,3,4,6,7,11,12,13],edit:9,effect:9,effici:8,efficientnet:[1,2,11,13],efficientnet_b0:3,efficientnet_b4:3,either:[7,8],email:6,empti:[2,6],enabl:[9,12],encod:[2,9],encompass:9,engin:9,entri:12,env:6,environ:[7,10,11,12,13],error:8,etc:6,everyth:9,exampl:[9,11,12,13],except:8,exist:[6,8],exit:1,expand:8,expect:2,explor:10,export_dir:8,extens:[2,6,8,11,12],factor:[1,2,6,7],fail:8,fals:[2,3,4,6,7,8],faster:9,featur:9,few:9,fft:9,field:8,file:[0,1,2,3,4,7,8,11,12],file_id:6,file_nam:7,file_path:8,file_s:6,file_typ:6,file_type_card:6,file_type_data:6,file_type_data_input:6,file_type_data_label:6,file_type_data_origin:6,file_type_data_output:6,file_type_framework:6,file_type_onnx:6,file_type_onnx_gz:6,file_type_recip:6,filetyp:6,filter:[2,6],float32:8,flow:[6,9],folder:[1,2,3,4,6,8],folder_nam:6,follow:[6,11,12,13],forc:7,force_token_refresh:[2,3,4,7],format:[1,6,8,9,11,12],found:[6,9],framework:[1,2,3,4,6,7,11,12,13],framework_fil:6,from:[1,2,6,7,8,9,11,12,13],full:[7,9],gener:[7,9],get:[2,3,4,6,7,8],get_auth_head:7,get_batch:8,github:[9,12],give:9,given:[2,6,8,9,12],gpu:[1,2,3,4,6,7,9,11,12,13],graph:[11,12,13],grow:9,guid:[11,12,13],gzip:6,gzipe:6,handl:[8,9],happen:12,has:[6,8,11,12,13],hash:6,hasn:6,header:7,help:[1,9,12],helper:[0,1],highli:9,host:9,how:[7,9,11,12,13],http:[3,4,12],identifi:[11,12,13],imag:[3,4,9],imagenet:[1,2,3,4,6,7,11,12,13],imagenett:[11,13],implement:[8,9],improv:9,incept:[1,2],inception_v3:[3,11,13],includ:9,increas:8,index:[6,8],induc:9,infer:9,infinit:[6,8],info:[6,7,8],inform:[6,9,11,12],inp:8,input:[6,11,12],instal:[8,9,12],instanc:[2,8],integ:[6,8],interact:[6,12],interfac:6,ipywidget:8,item:[6,8],iter:[6,8],iter_step:[6,8],its:12,json:7,keep:10,kei:[7,8],kera:[11,12],kwarg:[6,7],label:[6,11,12],latest:6,learn:[6,11,12,13],leav:2,length:[1,2,7],level:9,like:10,limit:9,line:9,linux:10,list:[2,6,7,8],load:[2,6,8],load_model:2,load_model_from_stub:2,load_numpi:8,load_numpy_list:8,loader:[6,8],local:[6,8],locat:7,loss:9,lower_lr:[11,12,13],machin:[11,12,13],made:[11,12,13],magic:9,mai:[2,12],main:[0,9,12],major:6,major_vers:6,make:7,manag:2,map:[8,11,13],markdown:6,match:[2,6,7,8,9],match_architectur:2,match_dataset:2,match_domain:2,match_framework:2,match_optim_categori:2,match_optim_nam:2,match_optim_target:2,match_repo:2,match_sub_architectur:2,match_sub_domain:2,match_training_schem:2,max:1,md5:6,memori:8,messag:1,metadata:[0,1,11,12],metric:[1,2,3,4,6,7,9,11,12,13],minor:6,minor_vers:6,mnist:11,mnistnet:11,mobilenet:[1,2],mobilenet_v1:[1,2,3,6,7,11,12,13],mobilenet_v2:[3,11],model:[0,1,7,8,9,13],model_id:6,model_metadata:6,model_url_arg:7,model_url_root:7,modelarg:[2,6,7],modelmetadata:6,moder:[1,2,3,4,6,7,11,12,13],modif:6,modifi:[6,11,12,13],modul:[0,9],multipl:[6,8],must:8,nad:8,name:[1,2,3,4,6,7,8,11,12,13],name_prefix:8,nativ:[11,12],natur:9,nbutil:[0,1],ndarrai:[6,8],nearli:9,network:[9,11,12,13],neural:9,neuralmag:[7,12],nightli:9,nlp:[1,2,6,7,11,12,13],nm_sparse_zoo_credenti:7,none:[1,2,3,4,6,7,8,11,12,13],normal:3,note:[8,12],notebook:[8,10],notic:9,npy:8,npz:8,num_item:8,num_retri:8,num_sampl:8,number:[6,8],numpi:[0,1,6],numpyarraybatch:8,object:[0,1,2,3,4,7,8,9],obtain:[2,7],occur:9,off:2,offici:[6,9],old:7,onc:[6,8],one:[2,6,8],onli:[7,8,9],onnx:[6,8,11,12],onnx_fil:[6,12],onnx_file_gz:6,onnx_gz:6,onto:9,operator_vers:6,opset:6,optim:[1,2,3,4,6,7,9],optim_categori:[1,2,3,4,6,7],optim_nam:[1,2,3,4,6,7],optim_target:[1,2,3,4,6,7],optimization_id:7,optimization_recip:[0,1,2],optimizationrecip:[2,6],optimizationrecipetyp:6,optimized_model:12,option:[1,2,3,4,6,7,8,11,12,13],order:[6,10],ordereddict:[6,8],org:[3,4],origin:[2,6,8,11,12,13],original_recip:6,otherwis:[2,3,4,6,7,8],output:[6,11,12],over:[7,9],overprecis:9,overrid:[2,3,4,6],override_folder_nam:[2,3,4,6],override_parent_path:[2,3,4,6],overview:[11,12,13],overwrit:[6,8],packag:[0,9,12],page:[1,2,7],page_length:[1,2,7],parallel:8,param1:2,param2:2,param:[2,8],paramet:[2,3,4,6,7,8],parameter:9,parent:[2,3,4,6,8],pars:2,parse_zoo_stub:2,patch:6,patch_vers:6,patchvers:6,path:[2,3,4,6,7,8],per:1,perform:[6,9],pip:10,place:12,plu:9,point:[2,12],posit:[1,6,8],pre:[6,11,12],prefix:8,preprocess:[11,12],previou:[6,8],previouslydownloadederror:8,print:[6,12],privat:9,process:[6,9,11,12],product:9,progress:[6,8],progress_titl:8,properli:12,properti:[6,7,8,11,12,13],prototyp:9,provid:2,prune:[1,2,3,4,6,7,9,11,12,13],pruned_qu:[1,2,3,4,6,7,11,12,13],ptc:[2,6],pth:[2,6],publish:6,pypi:9,python:[9,10],pytorch:[1,2,3,4,6,7,11,12,13],quant:[11,12,13],quantiz:[9,11,12,13],quick:9,rais:[2,8],random:8,randomdataset:8,recip:[2,6,9,11,12],recipe_id:6,recipe_typ:[2,6,13],recipe_type_origin:6,recipe_type_transfer_learn:6,recommend:10,record:6,recorded_format:6,recorded_unit:6,recorded_valu:6,recov:9,recoveri:9,redund:9,refresh:[2,3,4,6,7],refresh_token:6,relat:[6,7,8],releas:[1,2,6,7],release_vers:[0,1,2,7],release_version_id:6,releasevers:6,remov:9,repo:[1,2,3,4,6,7,11,12,13],repositori:[9,10,11,12,13],repres:[2,6,8],represent:[11,12],request:[0,1,2,6,9],requir:[7,10],resnet50:4,resnet50_300:[11,13],resnet:[1,2,12],resnet_101:3,resnet_101_2x:3,resnet_152:3,resnet_18:3,resnet_34:3,resnet_50:[3,12],resnet_50_2x:3,resnet_v1:[1,2,6,7,11,12,13],resolut:6,respect:12,respons:7,result:[0,1,9],result_categori:6,result_id:6,result_typ:6,retri:8,retriev:6,root:7,run:[6,8,11,12],same:[6,9],sampl:[6,8,11,12],sample_batch:6,save:[1,2,3,4,6,8],save_dir:1,save_numpi:8,scale:[1,2,6,7,11,12,13],scheme:[1,2,3,4,6,7,12],script:[1,9,10],search:[0,1,2,9],search_get_request:7,search_model:[2,12],search_optimized_model:[2,12],search_optimized_recip:2,search_recip:2,search_similar_model:2,segment:[1,2,6,7,11,12,13],semant:[1,6],set:[6,7,8],setup:[8,11,12,13],shape:8,should:7,show:[1,6,8],show_progress:[6,8],sign:[2,6],signifi:13,significantli:9,similar:2,simpl:9,simplifi:9,singl:8,size:[6,8],smaller:9,solut:[11,12,13],some:12,sourc:[1,2,3,4,6,7,8],spars:[1,6,9,11,12],sparse_categori:[11,12,13],sparse_nam:[11,12,13],sparse_target:[11,12,13],sparseml:[1,2,3,4,6,7,9,11,12,13],sparsezoo:[10,11,12,13],sparsezoo_models_path:6,sparsif:[11,12],sparsifi:[9,11,12,13],sparsiti:9,sparszoo:6,specif:[1,11,12,13],spp:[4,11,13],ssd:[1,2,11,13],ssd_resnet50_300:4,stabl:9,stack:8,standard:8,state:8,std:8,step:[6,8],store:[6,13],str:[2,3,4,6,7,8],straight:12,string:2,structur:[11,12,13],stub:[2,7,11,12,13],sub:[1,2,4,6,7,11,12,13],sub_architectur:[1,2,4,6,7,11,12,13],sub_domain:[1,2,6,7,11,12,13],submodul:[0,9],subpackag:[0,9],suit:9,support:[7,8,9,11,12],system:[8,10,12],tag:[0,1,11,13],tag_id:6,take:[8,9],tar:[11,12],target:[1,2,3,4,6,7,11,12,13],techniqu:9,tensor:[8,11,12],tensor_export:8,tensorflow:[1,2,3,4,6,7,11,12],tensorflow_v1:[11,12,13],tensors_export:8,termin:12,test:10,thei:8,them:[6,8],thi:[1,2,3,4,6,9,10,12],through:[6,8,11,12],time:[6,8,9],titl:8,token:[2,3,4,6,7],top1:[11,13],top:9,torchvis:[1,2,3,4,6,7,11,12,13],tour:9,tqdm:[6,8],tqdm_auto:8,tqdm_notebook:8,train:[1,2,3,4,6,7,9,11,12,13],training_id:7,training_schem:[1,2,3,4,6,7,11,12,13],transfer:[2,6,9,11,12],transfer_learn:[6,13],transfer_learning_recip:6,treat:8,trust:6,tupl:[2,8],type:[6,7,8,11,12,13],typed_shap:8,ultralyt:[4,11,13],under:[2,3,4,6,7,13],unexpect:2,union:[2,6,7,8],uniqu:7,unit:6,upload:6,url:[6,8],url_path:8,use:[6,8,11,12],used:[1,2,3,4,6,7,8,11,12],user:[0,1,7,8],user_id:[6,7],using:[9,10],util:[0,1,6],valid:[11,13],valid_param:2,valu:[2,6,7,8,9],value1:2,value2:2,variabl:[6,7],version:[1,2,6,7,8,9,11,13],vgg:[1,2,11,13],vgg_11:3,vgg_11bn:3,vgg_13:3,vgg_13bn:3,vgg_16:3,vgg_16bn:3,vgg_19:3,vgg_19bn:3,via:9,view:1,virtual:10,vision:12,voc:[11,13],warn:2,websit:9,weight:[2,11,12,13],well:[6,11,12],what:[7,8,11,12,13],when:[8,9],where:[2,3,4,6,7],whether:6,which:[11,12,13],who:6,width:[3,11,12,13],winograd:9,within:[6,11,12,13],without:[8,11,12],work:[6,8],worker:8,would:10,wrap:7,yaml:[11,12],yolo:[1,2],yolo_v3:[4,11,13],you:[9,10,12],your:[9,10,12],zero:8,zoo:[0,1,6,8,9]},titles:["sparsezoo","sparsezoo package","sparsezoo.models package","sparsezoo.models.classification package","sparsezoo.models.detection package","sparsezoo.nbutils package","sparsezoo.objects package","sparsezoo.requests package","sparsezoo.utils package","SparseZoo 0.1","Installation","Models","Quick Tour","Recipes"],titleterms:{api:12,authent:7,base:[6,7],classif:[3,11,13],common:12,consol:12,content:[1,2,3,4,5,6,7,8],data:[6,8],detect:[4,11,13],download:[6,7,8,12],efficientnet:3,file:6,helper:8,histori:9,imag:[11,13],incept:3,instal:10,learn:9,main:1,metadata:6,mobilenet:3,model:[2,3,4,6,11,12],modul:[1,2,3,4,5,6,7,8],more:9,nbutil:5,numpi:8,object:[6,11,13],optim:12,optimization_recip:6,overview:9,packag:[1,2,3,4,5,6,7,8],python:12,quick:12,recip:13,releas:9,release_vers:6,request:7,resnet:3,resourc:9,result:6,script:12,search:[7,12],sparsezoo:[0,1,2,3,4,5,6,7,8,9],sparsif:9,ssd:4,submodul:[1,2,3,4,5,6,7,8],subpackag:[1,2],tag:6,tour:12,user:6,util:[5,8],version:12,vgg:3,yolo:4,zoo:[2,12]}}) \ No newline at end of file diff --git a/sparsify/.buildinfo b/sparsify/.buildinfo index 636037ed56f..c3ec77a0265 100644 --- a/sparsify/.buildinfo +++ b/sparsify/.buildinfo @@ -1,4 +1,4 @@ # Sphinx build info version 1 # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. -config: 1c59754a360c99e5ecdcbf7e391c9f66 +config: cd6aecb3959fbdcdc01354dd6c526f1d tags: 645f666f9bcd5a90fca523b33c5a78b7 diff --git a/sparsify/_images/image_0.jpg b/sparsify/_images/images/image_0.jpg similarity index 100% rename from sparsify/_images/image_0.jpg rename to sparsify/_images/images/image_0.jpg diff --git a/sparsify/_images/image_1.jpg b/sparsify/_images/images/image_1.jpg similarity index 100% rename from sparsify/_images/image_1.jpg rename to sparsify/_images/images/image_1.jpg diff --git a/sparsify/_images/image_10.jpg b/sparsify/_images/images/image_10.jpg similarity index 100% rename from sparsify/_images/image_10.jpg rename to sparsify/_images/images/image_10.jpg diff --git a/sparsify/_images/image_11.jpg b/sparsify/_images/images/image_11.jpg similarity index 100% rename from sparsify/_images/image_11.jpg rename to sparsify/_images/images/image_11.jpg diff --git a/sparsify/_images/image_12.jpg b/sparsify/_images/images/image_12.jpg similarity index 100% rename from sparsify/_images/image_12.jpg rename to sparsify/_images/images/image_12.jpg diff --git a/sparsify/_images/image_13.jpg b/sparsify/_images/images/image_13.jpg similarity index 100% rename from sparsify/_images/image_13.jpg rename to sparsify/_images/images/image_13.jpg diff --git a/sparsify/_images/image_14.jpg b/sparsify/_images/images/image_14.jpg similarity index 100% rename from sparsify/_images/image_14.jpg rename to sparsify/_images/images/image_14.jpg diff --git a/sparsify/_images/image_15.jpg b/sparsify/_images/images/image_15.jpg similarity index 100% rename from sparsify/_images/image_15.jpg rename to sparsify/_images/images/image_15.jpg diff --git a/sparsify/_images/image_15a.jpg b/sparsify/_images/images/image_15a.jpg similarity index 100% rename from sparsify/_images/image_15a.jpg rename to sparsify/_images/images/image_15a.jpg diff --git a/sparsify/_images/image_15b.jpg b/sparsify/_images/images/image_15b.jpg similarity index 100% rename from sparsify/_images/image_15b.jpg rename to sparsify/_images/images/image_15b.jpg diff --git a/sparsify/_images/image_16.jpg b/sparsify/_images/images/image_16.jpg similarity index 100% rename from sparsify/_images/image_16.jpg rename to sparsify/_images/images/image_16.jpg diff --git a/sparsify/_images/image_17.jpg b/sparsify/_images/images/image_17.jpg similarity index 100% rename from sparsify/_images/image_17.jpg rename to sparsify/_images/images/image_17.jpg diff --git a/sparsify/_images/image_18.jpg b/sparsify/_images/images/image_18.jpg similarity index 100% rename from sparsify/_images/image_18.jpg rename to sparsify/_images/images/image_18.jpg diff --git a/sparsify/_images/image_19.jpg b/sparsify/_images/images/image_19.jpg similarity index 100% rename from sparsify/_images/image_19.jpg rename to sparsify/_images/images/image_19.jpg diff --git a/sparsify/_images/image_2.jpg b/sparsify/_images/images/image_2.jpg similarity index 100% rename from sparsify/_images/image_2.jpg rename to sparsify/_images/images/image_2.jpg diff --git a/sparsify/_images/image_20.jpg b/sparsify/_images/images/image_20.jpg similarity index 100% rename from sparsify/_images/image_20.jpg rename to sparsify/_images/images/image_20.jpg diff --git a/sparsify/_images/image_21.jpg b/sparsify/_images/images/image_21.jpg similarity index 100% rename from sparsify/_images/image_21.jpg rename to sparsify/_images/images/image_21.jpg diff --git a/sparsify/_images/image_21a.jpg b/sparsify/_images/images/image_21a.jpg similarity index 100% rename from sparsify/_images/image_21a.jpg rename to sparsify/_images/images/image_21a.jpg diff --git a/sparsify/_images/image_21b.jpg b/sparsify/_images/images/image_21b.jpg similarity index 100% rename from sparsify/_images/image_21b.jpg rename to sparsify/_images/images/image_21b.jpg diff --git a/sparsify/_images/image_22.jpg b/sparsify/_images/images/image_22.jpg similarity index 100% rename from sparsify/_images/image_22.jpg rename to sparsify/_images/images/image_22.jpg diff --git a/sparsify/_images/image_23.jpg b/sparsify/_images/images/image_23.jpg similarity index 100% rename from sparsify/_images/image_23.jpg rename to sparsify/_images/images/image_23.jpg diff --git a/sparsify/_images/image_24.jpg b/sparsify/_images/images/image_24.jpg similarity index 100% rename from sparsify/_images/image_24.jpg rename to sparsify/_images/images/image_24.jpg diff --git a/sparsify/_images/image_25.jpg b/sparsify/_images/images/image_25.jpg similarity index 100% rename from sparsify/_images/image_25.jpg rename to sparsify/_images/images/image_25.jpg diff --git a/sparsify/_images/image_26.jpg b/sparsify/_images/images/image_26.jpg similarity index 100% rename from sparsify/_images/image_26.jpg rename to sparsify/_images/images/image_26.jpg diff --git a/sparsify/_images/image_27.jpg b/sparsify/_images/images/image_27.jpg similarity index 100% rename from sparsify/_images/image_27.jpg rename to sparsify/_images/images/image_27.jpg diff --git a/sparsify/_images/image_28.jpg b/sparsify/_images/images/image_28.jpg similarity index 100% rename from sparsify/_images/image_28.jpg rename to sparsify/_images/images/image_28.jpg diff --git a/sparsify/_images/image_29.jpg b/sparsify/_images/images/image_29.jpg similarity index 100% rename from sparsify/_images/image_29.jpg rename to sparsify/_images/images/image_29.jpg diff --git a/sparsify/_images/image_29a.jpg b/sparsify/_images/images/image_29a.jpg similarity index 100% rename from sparsify/_images/image_29a.jpg rename to sparsify/_images/images/image_29a.jpg diff --git a/sparsify/_images/image_29b.jpg b/sparsify/_images/images/image_29b.jpg similarity index 100% rename from sparsify/_images/image_29b.jpg rename to sparsify/_images/images/image_29b.jpg diff --git a/sparsify/_images/image_29c.jpg b/sparsify/_images/images/image_29c.jpg similarity index 100% rename from sparsify/_images/image_29c.jpg rename to sparsify/_images/images/image_29c.jpg diff --git a/sparsify/_images/image_29d.jpg b/sparsify/_images/images/image_29d.jpg similarity index 100% rename from sparsify/_images/image_29d.jpg rename to sparsify/_images/images/image_29d.jpg diff --git a/sparsify/_images/image_29e.jpg b/sparsify/_images/images/image_29e.jpg similarity index 100% rename from sparsify/_images/image_29e.jpg rename to sparsify/_images/images/image_29e.jpg diff --git a/sparsify/_images/image_3.jpg b/sparsify/_images/images/image_3.jpg similarity index 100% rename from sparsify/_images/image_3.jpg rename to sparsify/_images/images/image_3.jpg diff --git a/sparsify/_images/image_30.jpg b/sparsify/_images/images/image_30.jpg similarity index 100% rename from sparsify/_images/image_30.jpg rename to sparsify/_images/images/image_30.jpg diff --git a/sparsify/_images/image_31.jpg b/sparsify/_images/images/image_31.jpg similarity index 100% rename from sparsify/_images/image_31.jpg rename to sparsify/_images/images/image_31.jpg diff --git a/sparsify/_images/image_31a.jpg b/sparsify/_images/images/image_31a.jpg similarity index 100% rename from sparsify/_images/image_31a.jpg rename to sparsify/_images/images/image_31a.jpg diff --git a/sparsify/_images/image_32.jpg b/sparsify/_images/images/image_32.jpg similarity index 100% rename from sparsify/_images/image_32.jpg rename to sparsify/_images/images/image_32.jpg diff --git a/sparsify/_images/image_33.jpg b/sparsify/_images/images/image_33.jpg similarity index 100% rename from sparsify/_images/image_33.jpg rename to sparsify/_images/images/image_33.jpg diff --git a/sparsify/_images/images/image_34.jpg b/sparsify/_images/images/image_34.jpg new file mode 100644 index 00000000000..4880a6cf717 Binary files /dev/null and b/sparsify/_images/images/image_34.jpg differ diff --git a/sparsify/_images/image_35.jpg b/sparsify/_images/images/image_35.jpg similarity index 100% rename from sparsify/_images/image_35.jpg rename to sparsify/_images/images/image_35.jpg diff --git a/sparsify/_images/image_36.jpg b/sparsify/_images/images/image_36.jpg similarity index 100% rename from sparsify/_images/image_36.jpg rename to sparsify/_images/images/image_36.jpg diff --git a/sparsify/_images/image_36a.jpg b/sparsify/_images/images/image_36a.jpg similarity index 100% rename from sparsify/_images/image_36a.jpg rename to sparsify/_images/images/image_36a.jpg diff --git a/sparsify/_images/image_37.jpg b/sparsify/_images/images/image_37.jpg similarity index 100% rename from sparsify/_images/image_37.jpg rename to sparsify/_images/images/image_37.jpg diff --git a/sparsify/_images/image_38.jpg b/sparsify/_images/images/image_38.jpg similarity index 100% rename from sparsify/_images/image_38.jpg rename to sparsify/_images/images/image_38.jpg diff --git a/sparsify/_images/image_39.jpg b/sparsify/_images/images/image_39.jpg similarity index 100% rename from sparsify/_images/image_39.jpg rename to sparsify/_images/images/image_39.jpg diff --git a/sparsify/_images/image_4.jpg b/sparsify/_images/images/image_4.jpg similarity index 100% rename from sparsify/_images/image_4.jpg rename to sparsify/_images/images/image_4.jpg diff --git a/sparsify/_images/image_40.jpg b/sparsify/_images/images/image_40.jpg similarity index 100% rename from sparsify/_images/image_40.jpg rename to sparsify/_images/images/image_40.jpg diff --git a/sparsify/_images/image_41.jpg b/sparsify/_images/images/image_41.jpg similarity index 100% rename from sparsify/_images/image_41.jpg rename to sparsify/_images/images/image_41.jpg diff --git a/sparsify/_images/image_42.jpg b/sparsify/_images/images/image_42.jpg similarity index 100% rename from sparsify/_images/image_42.jpg rename to sparsify/_images/images/image_42.jpg diff --git a/sparsify/_images/image_43.jpg b/sparsify/_images/images/image_43.jpg similarity index 100% rename from sparsify/_images/image_43.jpg rename to sparsify/_images/images/image_43.jpg diff --git a/sparsify/_images/image_44.jpg b/sparsify/_images/images/image_44.jpg similarity index 100% rename from sparsify/_images/image_44.jpg rename to sparsify/_images/images/image_44.jpg diff --git a/sparsify/_images/image_45.jpg b/sparsify/_images/images/image_45.jpg similarity index 100% rename from sparsify/_images/image_45.jpg rename to sparsify/_images/images/image_45.jpg diff --git a/sparsify/_images/image_46.jpg b/sparsify/_images/images/image_46.jpg similarity index 100% rename from sparsify/_images/image_46.jpg rename to sparsify/_images/images/image_46.jpg diff --git a/sparsify/_images/image_47.jpg b/sparsify/_images/images/image_47.jpg similarity index 100% rename from sparsify/_images/image_47.jpg rename to sparsify/_images/images/image_47.jpg diff --git a/sparsify/_images/image_48.jpg b/sparsify/_images/images/image_48.jpg similarity index 100% rename from sparsify/_images/image_48.jpg rename to sparsify/_images/images/image_48.jpg diff --git a/sparsify/_images/image_49.jpg b/sparsify/_images/images/image_49.jpg similarity index 100% rename from sparsify/_images/image_49.jpg rename to sparsify/_images/images/image_49.jpg diff --git a/sparsify/_images/image_5.jpg b/sparsify/_images/images/image_5.jpg similarity index 100% rename from sparsify/_images/image_5.jpg rename to sparsify/_images/images/image_5.jpg diff --git a/sparsify/_images/image_50.jpg b/sparsify/_images/images/image_50.jpg similarity index 100% rename from sparsify/_images/image_50.jpg rename to sparsify/_images/images/image_50.jpg diff --git a/sparsify/_images/image_51.jpg b/sparsify/_images/images/image_51.jpg similarity index 100% rename from sparsify/_images/image_51.jpg rename to sparsify/_images/images/image_51.jpg diff --git a/sparsify/_images/image_52.jpg b/sparsify/_images/images/image_52.jpg similarity index 100% rename from sparsify/_images/image_52.jpg rename to sparsify/_images/images/image_52.jpg diff --git a/sparsify/_images/image_53.jpg b/sparsify/_images/images/image_53.jpg similarity index 100% rename from sparsify/_images/image_53.jpg rename to sparsify/_images/images/image_53.jpg diff --git a/sparsify/_images/image_54.jpg b/sparsify/_images/images/image_54.jpg similarity index 100% rename from sparsify/_images/image_54.jpg rename to sparsify/_images/images/image_54.jpg diff --git a/sparsify/_images/image_55.jpg b/sparsify/_images/images/image_55.jpg similarity index 100% rename from sparsify/_images/image_55.jpg rename to sparsify/_images/images/image_55.jpg diff --git a/sparsify/_images/image_56.jpg b/sparsify/_images/images/image_56.jpg similarity index 100% rename from sparsify/_images/image_56.jpg rename to sparsify/_images/images/image_56.jpg diff --git a/sparsify/_images/image_57.jpg b/sparsify/_images/images/image_57.jpg similarity index 100% rename from sparsify/_images/image_57.jpg rename to sparsify/_images/images/image_57.jpg diff --git a/sparsify/_images/image_58.jpg b/sparsify/_images/images/image_58.jpg similarity index 100% rename from sparsify/_images/image_58.jpg rename to sparsify/_images/images/image_58.jpg diff --git a/sparsify/_images/image_59.jpg b/sparsify/_images/images/image_59.jpg similarity index 100% rename from sparsify/_images/image_59.jpg rename to sparsify/_images/images/image_59.jpg diff --git a/sparsify/_images/image_6.jpg b/sparsify/_images/images/image_6.jpg similarity index 100% rename from sparsify/_images/image_6.jpg rename to sparsify/_images/images/image_6.jpg diff --git a/sparsify/_images/image_60.jpg b/sparsify/_images/images/image_60.jpg similarity index 100% rename from sparsify/_images/image_60.jpg rename to sparsify/_images/images/image_60.jpg diff --git a/sparsify/_images/image_61.jpg b/sparsify/_images/images/image_61.jpg similarity index 100% rename from sparsify/_images/image_61.jpg rename to sparsify/_images/images/image_61.jpg diff --git a/sparsify/_images/image_62.jpg b/sparsify/_images/images/image_62.jpg similarity index 100% rename from sparsify/_images/image_62.jpg rename to sparsify/_images/images/image_62.jpg diff --git a/sparsify/_images/image_63.jpg b/sparsify/_images/images/image_63.jpg similarity index 100% rename from sparsify/_images/image_63.jpg rename to sparsify/_images/images/image_63.jpg diff --git a/sparsify/_images/image_64.jpg b/sparsify/_images/images/image_64.jpg similarity index 100% rename from sparsify/_images/image_64.jpg rename to sparsify/_images/images/image_64.jpg diff --git a/sparsify/_images/image_65.jpg b/sparsify/_images/images/image_65.jpg similarity index 100% rename from sparsify/_images/image_65.jpg rename to sparsify/_images/images/image_65.jpg diff --git a/sparsify/_images/image_7.jpg b/sparsify/_images/images/image_7.jpg similarity index 100% rename from sparsify/_images/image_7.jpg rename to sparsify/_images/images/image_7.jpg diff --git a/sparsify/_images/image_8.jpg b/sparsify/_images/images/image_8.jpg similarity index 100% rename from sparsify/_images/image_8.jpg rename to sparsify/_images/images/image_8.jpg diff --git a/sparsify/_images/image_9.jpg b/sparsify/_images/images/image_9.jpg similarity index 100% rename from sparsify/_images/image_9.jpg rename to sparsify/_images/images/image_9.jpg diff --git a/sparsify/_modules/index.html b/sparsify/_modules/index.html index 2413d853a07..293748636e8 100644 --- a/sparsify/_modules/index.html +++ b/sparsify/_modules/index.html @@ -173,10 +173,7 @@

                                                                                                                                All modules for which code is available

                                                                                                                                -
                                                                                                                                • marshmallow.schema
                                                                                                                                • -
                                                                                                                                • peewee
                                                                                                                                • -
                                                                                                                                • playhouse.sqlite_ext
                                                                                                                                • -
                                                                                                                                • sparsify.app
                                                                                                                                • +
                                                                                                                                  • sparsify.app
                                                                                                                                  • sparsify.blueprints.code_samples.pytorch__training
                                                                                                                                  • sparsify.blueprints.utils.helpers
                                                                                                                                  • sparsify.blueprints.utils.projects
                                                                                                                                  • diff --git a/sparsify/_modules/marshmallow/schema.html b/sparsify/_modules/marshmallow/schema.html deleted file mode 100644 index dcb1bd5f4b3..00000000000 --- a/sparsify/_modules/marshmallow/schema.html +++ /dev/null @@ -1,1467 +0,0 @@ - - - - - - - - - - marshmallow.schema — Sparsify 0.1.0 documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                                                                                                                                    - - - -
                                                                                                                                    - - - - - -
                                                                                                                                    - -
                                                                                                                                    - - - - - - - - - - - - - - - - - - - -
                                                                                                                                    - -
                                                                                                                                      - -
                                                                                                                                    • »
                                                                                                                                    • - -
                                                                                                                                    • Module code »
                                                                                                                                    • - -
                                                                                                                                    • marshmallow.schema
                                                                                                                                    • - - -
                                                                                                                                    • - -
                                                                                                                                    • - -
                                                                                                                                    - - -
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    - -

                                                                                                                                    Source code for marshmallow.schema

                                                                                                                                    -"""The :class:`Schema` class, including its metaclass and options (class Meta)."""
                                                                                                                                    -from collections import defaultdict, OrderedDict
                                                                                                                                    -from collections.abc import Mapping
                                                                                                                                    -from functools import lru_cache
                                                                                                                                    -import datetime as dt
                                                                                                                                    -import uuid
                                                                                                                                    -import decimal
                                                                                                                                    -import copy
                                                                                                                                    -import inspect
                                                                                                                                    -import json
                                                                                                                                    -import typing
                                                                                                                                    -import warnings
                                                                                                                                    -
                                                                                                                                    -from marshmallow import base, fields as ma_fields, class_registry, types
                                                                                                                                    -from marshmallow.error_store import ErrorStore
                                                                                                                                    -from marshmallow.exceptions import ValidationError, StringNotCollectionError
                                                                                                                                    -from marshmallow.orderedset import OrderedSet
                                                                                                                                    -from marshmallow.decorators import (
                                                                                                                                    -    POST_DUMP,
                                                                                                                                    -    POST_LOAD,
                                                                                                                                    -    PRE_DUMP,
                                                                                                                                    -    PRE_LOAD,
                                                                                                                                    -    VALIDATES,
                                                                                                                                    -    VALIDATES_SCHEMA,
                                                                                                                                    -)
                                                                                                                                    -from marshmallow.utils import (
                                                                                                                                    -    RAISE,
                                                                                                                                    -    EXCLUDE,
                                                                                                                                    -    INCLUDE,
                                                                                                                                    -    missing,
                                                                                                                                    -    set_value,
                                                                                                                                    -    get_value,
                                                                                                                                    -    is_collection,
                                                                                                                                    -    is_instance_or_subclass,
                                                                                                                                    -    is_iterable_but_not_string,
                                                                                                                                    -)
                                                                                                                                    -from marshmallow.warnings import RemovedInMarshmallow4Warning
                                                                                                                                    -
                                                                                                                                    -_T = typing.TypeVar("_T")
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -def _get_fields(attrs, field_class, pop=False, ordered=False):
                                                                                                                                    -    """Get fields from a class. If ordered=True, fields will sorted by creation index.
                                                                                                                                    -
                                                                                                                                    -    :param attrs: Mapping of class attributes
                                                                                                                                    -    :param type field_class: Base field class
                                                                                                                                    -    :param bool pop: Remove matching fields
                                                                                                                                    -    """
                                                                                                                                    -    fields = [
                                                                                                                                    -        (field_name, field_value)
                                                                                                                                    -        for field_name, field_value in attrs.items()
                                                                                                                                    -        if is_instance_or_subclass(field_value, field_class)
                                                                                                                                    -    ]
                                                                                                                                    -    if pop:
                                                                                                                                    -        for field_name, _ in fields:
                                                                                                                                    -            del attrs[field_name]
                                                                                                                                    -    if ordered:
                                                                                                                                    -        fields.sort(key=lambda pair: pair[1]._creation_index)
                                                                                                                                    -    return fields
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -# This function allows Schemas to inherit from non-Schema classes and ensures
                                                                                                                                    -#   inheritance according to the MRO
                                                                                                                                    -def _get_fields_by_mro(klass, field_class, ordered=False):
                                                                                                                                    -    """Collect fields from a class, following its method resolution order. The
                                                                                                                                    -    class itself is excluded from the search; only its parents are checked. Get
                                                                                                                                    -    fields from ``_declared_fields`` if available, else use ``__dict__``.
                                                                                                                                    -
                                                                                                                                    -    :param type klass: Class whose fields to retrieve
                                                                                                                                    -    :param type field_class: Base field class
                                                                                                                                    -    """
                                                                                                                                    -    mro = inspect.getmro(klass)
                                                                                                                                    -    # Loop over mro in reverse to maintain correct order of fields
                                                                                                                                    -    return sum(
                                                                                                                                    -        (
                                                                                                                                    -            _get_fields(
                                                                                                                                    -                getattr(base, "_declared_fields", base.__dict__),
                                                                                                                                    -                field_class,
                                                                                                                                    -                ordered=ordered,
                                                                                                                                    -            )
                                                                                                                                    -            for base in mro[:0:-1]
                                                                                                                                    -        ),
                                                                                                                                    -        [],
                                                                                                                                    -    )
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class SchemaMeta(type):
                                                                                                                                    -    """Metaclass for the Schema class. Binds the declared fields to
                                                                                                                                    -    a ``_declared_fields`` attribute, which is a dictionary mapping attribute
                                                                                                                                    -    names to field objects. Also sets the ``opts`` class attribute, which is
                                                                                                                                    -    the Schema class's ``class Meta`` options.
                                                                                                                                    -    """
                                                                                                                                    -
                                                                                                                                    -    def __new__(mcs, name, bases, attrs):
                                                                                                                                    -        meta = attrs.get("Meta")
                                                                                                                                    -        ordered = getattr(meta, "ordered", False)
                                                                                                                                    -        if not ordered:
                                                                                                                                    -            # Inherit 'ordered' option
                                                                                                                                    -            # Warning: We loop through bases instead of MRO because we don't
                                                                                                                                    -            # yet have access to the class object
                                                                                                                                    -            # (i.e. can't call super before we have fields)
                                                                                                                                    -            for base_ in bases:
                                                                                                                                    -                if hasattr(base_, "Meta") and hasattr(base_.Meta, "ordered"):
                                                                                                                                    -                    ordered = base_.Meta.ordered
                                                                                                                                    -                    break
                                                                                                                                    -            else:
                                                                                                                                    -                ordered = False
                                                                                                                                    -        cls_fields = _get_fields(attrs, base.FieldABC, pop=True, ordered=ordered)
                                                                                                                                    -        klass = super().__new__(mcs, name, bases, attrs)
                                                                                                                                    -        inherited_fields = _get_fields_by_mro(klass, base.FieldABC, ordered=ordered)
                                                                                                                                    -
                                                                                                                                    -        meta = klass.Meta
                                                                                                                                    -        # Set klass.opts in __new__ rather than __init__ so that it is accessible in
                                                                                                                                    -        # get_declared_fields
                                                                                                                                    -        klass.opts = klass.OPTIONS_CLASS(meta, ordered=ordered)
                                                                                                                                    -        # Add fields specified in the `include` class Meta option
                                                                                                                                    -        cls_fields += list(klass.opts.include.items())
                                                                                                                                    -
                                                                                                                                    -        dict_cls = OrderedDict if ordered else dict
                                                                                                                                    -        # Assign _declared_fields on class
                                                                                                                                    -        klass._declared_fields = mcs.get_declared_fields(
                                                                                                                                    -            klass=klass,
                                                                                                                                    -            cls_fields=cls_fields,
                                                                                                                                    -            inherited_fields=inherited_fields,
                                                                                                                                    -            dict_cls=dict_cls,
                                                                                                                                    -        )
                                                                                                                                    -        return klass
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def get_declared_fields(
                                                                                                                                    -        mcs,
                                                                                                                                    -        klass: type,
                                                                                                                                    -        cls_fields: typing.List,
                                                                                                                                    -        inherited_fields: typing.List,
                                                                                                                                    -        dict_cls: type,
                                                                                                                                    -    ):
                                                                                                                                    -        """Returns a dictionary of field_name => `Field` pairs declared on the class.
                                                                                                                                    -        This is exposed mainly so that plugins can add additional fields, e.g. fields
                                                                                                                                    -        computed from class Meta options.
                                                                                                                                    -
                                                                                                                                    -        :param klass: The class object.
                                                                                                                                    -        :param cls_fields: The fields declared on the class, including those added
                                                                                                                                    -            by the ``include`` class Meta option.
                                                                                                                                    -        :param inherited_fields: Inherited fields.
                                                                                                                                    -        :param dict_class: Either `dict` or `OrderedDict`, depending on the whether
                                                                                                                                    -            the user specified `ordered=True`.
                                                                                                                                    -        """
                                                                                                                                    -        return dict_cls(inherited_fields + cls_fields)
                                                                                                                                    -
                                                                                                                                    -    def __init__(cls, name, bases, attrs):
                                                                                                                                    -        super().__init__(name, bases, attrs)
                                                                                                                                    -        if name and cls.opts.register:
                                                                                                                                    -            class_registry.register(name, cls)
                                                                                                                                    -        cls._hooks = cls.resolve_hooks()
                                                                                                                                    -
                                                                                                                                    -    def resolve_hooks(cls) -> typing.Dict[types.Tag, typing.List[str]]:
                                                                                                                                    -        """Add in the decorated processors
                                                                                                                                    -
                                                                                                                                    -        By doing this after constructing the class, we let standard inheritance
                                                                                                                                    -        do all the hard work.
                                                                                                                                    -        """
                                                                                                                                    -        mro = inspect.getmro(cls)
                                                                                                                                    -
                                                                                                                                    -        hooks = defaultdict(list)  # type: typing.Dict[types.Tag, typing.List[str]]
                                                                                                                                    -
                                                                                                                                    -        for attr_name in dir(cls):
                                                                                                                                    -            # Need to look up the actual descriptor, not whatever might be
                                                                                                                                    -            # bound to the class. This needs to come from the __dict__ of the
                                                                                                                                    -            # declaring class.
                                                                                                                                    -            for parent in mro:
                                                                                                                                    -                try:
                                                                                                                                    -                    attr = parent.__dict__[attr_name]
                                                                                                                                    -                except KeyError:
                                                                                                                                    -                    continue
                                                                                                                                    -                else:
                                                                                                                                    -                    break
                                                                                                                                    -            else:
                                                                                                                                    -                # In case we didn't find the attribute and didn't break above.
                                                                                                                                    -                # We should never hit this - it's just here for completeness
                                                                                                                                    -                # to exclude the possibility of attr being undefined.
                                                                                                                                    -                continue
                                                                                                                                    -
                                                                                                                                    -            try:
                                                                                                                                    -                hook_config = attr.__marshmallow_hook__
                                                                                                                                    -            except AttributeError:
                                                                                                                                    -                pass
                                                                                                                                    -            else:
                                                                                                                                    -                for key in hook_config.keys():
                                                                                                                                    -                    # Use name here so we can get the bound method later, in
                                                                                                                                    -                    # case the processor was a descriptor or something.
                                                                                                                                    -                    hooks[key].append(attr_name)
                                                                                                                                    -
                                                                                                                                    -        return hooks
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class SchemaOpts:
                                                                                                                                    -    """class Meta options for the :class:`Schema`. Defines defaults."""
                                                                                                                                    -
                                                                                                                                    -    def __init__(self, meta, ordered: bool = False):
                                                                                                                                    -        self.fields = getattr(meta, "fields", ())
                                                                                                                                    -        if not isinstance(self.fields, (list, tuple)):
                                                                                                                                    -            raise ValueError("`fields` option must be a list or tuple.")
                                                                                                                                    -        self.additional = getattr(meta, "additional", ())
                                                                                                                                    -        if not isinstance(self.additional, (list, tuple)):
                                                                                                                                    -            raise ValueError("`additional` option must be a list or tuple.")
                                                                                                                                    -        if self.fields and self.additional:
                                                                                                                                    -            raise ValueError(
                                                                                                                                    -                "Cannot set both `fields` and `additional` options"
                                                                                                                                    -                " for the same Schema."
                                                                                                                                    -            )
                                                                                                                                    -        self.exclude = getattr(meta, "exclude", ())
                                                                                                                                    -        if not isinstance(self.exclude, (list, tuple)):
                                                                                                                                    -            raise ValueError("`exclude` must be a list or tuple.")
                                                                                                                                    -        self.dateformat = getattr(meta, "dateformat", None)
                                                                                                                                    -        self.datetimeformat = getattr(meta, "datetimeformat", None)
                                                                                                                                    -        self.timeformat = getattr(meta, "timeformat", None)
                                                                                                                                    -        if hasattr(meta, "json_module"):
                                                                                                                                    -            warnings.warn(
                                                                                                                                    -                "The json_module class Meta option is deprecated. Use render_module instead.",
                                                                                                                                    -                RemovedInMarshmallow4Warning,
                                                                                                                                    -            )
                                                                                                                                    -            render_module = getattr(meta, "json_module", json)
                                                                                                                                    -        else:
                                                                                                                                    -            render_module = json
                                                                                                                                    -        self.render_module = getattr(meta, "render_module", render_module)
                                                                                                                                    -        self.ordered = getattr(meta, "ordered", ordered)
                                                                                                                                    -        self.index_errors = getattr(meta, "index_errors", True)
                                                                                                                                    -        self.include = getattr(meta, "include", {})
                                                                                                                                    -        self.load_only = getattr(meta, "load_only", ())
                                                                                                                                    -        self.dump_only = getattr(meta, "dump_only", ())
                                                                                                                                    -        self.unknown = getattr(meta, "unknown", RAISE)
                                                                                                                                    -        self.register = getattr(meta, "register", True)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class Schema(base.SchemaABC, metaclass=SchemaMeta):
                                                                                                                                    -    """Base schema class with which to define custom schemas.
                                                                                                                                    -
                                                                                                                                    -    Example usage:
                                                                                                                                    -
                                                                                                                                    -    .. code-block:: python
                                                                                                                                    -
                                                                                                                                    -        import datetime as dt
                                                                                                                                    -        from dataclasses import dataclass
                                                                                                                                    -
                                                                                                                                    -        from marshmallow import Schema, fields
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -        @dataclass
                                                                                                                                    -        class Album:
                                                                                                                                    -            title: str
                                                                                                                                    -            release_date: dt.date
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -        class AlbumSchema(Schema):
                                                                                                                                    -            title = fields.Str()
                                                                                                                                    -            release_date = fields.Date()
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -        album = Album("Beggars Banquet", dt.date(1968, 12, 6))
                                                                                                                                    -        schema = AlbumSchema()
                                                                                                                                    -        data = schema.dump(album)
                                                                                                                                    -        data  # {'release_date': '1968-12-06', 'title': 'Beggars Banquet'}
                                                                                                                                    -
                                                                                                                                    -    :param only: Whitelist of the declared fields to select when
                                                                                                                                    -        instantiating the Schema. If None, all fields are used. Nested fields
                                                                                                                                    -        can be represented with dot delimiters.
                                                                                                                                    -    :param exclude: Blacklist of the declared fields to exclude
                                                                                                                                    -        when instantiating the Schema. If a field appears in both `only` and
                                                                                                                                    -        `exclude`, it is not used. Nested fields can be represented with dot
                                                                                                                                    -        delimiters.
                                                                                                                                    -    :param many: Should be set to `True` if ``obj`` is a collection
                                                                                                                                    -        so that the object will be serialized to a list.
                                                                                                                                    -    :param context: Optional context passed to :class:`fields.Method` and
                                                                                                                                    -        :class:`fields.Function` fields.
                                                                                                                                    -    :param load_only: Fields to skip during serialization (write-only fields)
                                                                                                                                    -    :param dump_only: Fields to skip during deserialization (read-only fields)
                                                                                                                                    -    :param partial: Whether to ignore missing fields and not require
                                                                                                                                    -        any fields declared. Propagates down to ``Nested`` fields as well. If
                                                                                                                                    -        its value is an iterable, only missing fields listed in that iterable
                                                                                                                                    -        will be ignored. Use dot delimiters to specify nested fields.
                                                                                                                                    -    :param unknown: Whether to exclude, include, or raise an error for unknown
                                                                                                                                    -        fields in the data. Use `EXCLUDE`, `INCLUDE` or `RAISE`.
                                                                                                                                    -
                                                                                                                                    -    .. versionchanged:: 3.0.0
                                                                                                                                    -        `prefix` parameter removed.
                                                                                                                                    -
                                                                                                                                    -    .. versionchanged:: 2.0.0
                                                                                                                                    -        `__validators__`, `__preprocessors__`, and `__data_handlers__` are removed in favor of
                                                                                                                                    -        `marshmallow.decorators.validates_schema`,
                                                                                                                                    -        `marshmallow.decorators.pre_load` and `marshmallow.decorators.post_dump`.
                                                                                                                                    -        `__accessor__` and `__error_handler__` are deprecated. Implement the
                                                                                                                                    -        `handle_error` and `get_attribute` methods instead.
                                                                                                                                    -    """
                                                                                                                                    -
                                                                                                                                    -    TYPE_MAPPING = {
                                                                                                                                    -        str: ma_fields.String,
                                                                                                                                    -        bytes: ma_fields.String,
                                                                                                                                    -        dt.datetime: ma_fields.DateTime,
                                                                                                                                    -        float: ma_fields.Float,
                                                                                                                                    -        bool: ma_fields.Boolean,
                                                                                                                                    -        tuple: ma_fields.Raw,
                                                                                                                                    -        list: ma_fields.Raw,
                                                                                                                                    -        set: ma_fields.Raw,
                                                                                                                                    -        int: ma_fields.Integer,
                                                                                                                                    -        uuid.UUID: ma_fields.UUID,
                                                                                                                                    -        dt.time: ma_fields.Time,
                                                                                                                                    -        dt.date: ma_fields.Date,
                                                                                                                                    -        dt.timedelta: ma_fields.TimeDelta,
                                                                                                                                    -        decimal.Decimal: ma_fields.Decimal,
                                                                                                                                    -    }  # type: typing.Dict[type, typing.Type[ma_fields.Field]]
                                                                                                                                    -    #: Overrides for default schema-level error messages
                                                                                                                                    -    error_messages = {}  # type: typing.Dict[str, str]
                                                                                                                                    -
                                                                                                                                    -    _default_error_messages = {
                                                                                                                                    -        "type": "Invalid input type.",
                                                                                                                                    -        "unknown": "Unknown field.",
                                                                                                                                    -    }  # type: typing.Dict[str, str]
                                                                                                                                    -
                                                                                                                                    -    OPTIONS_CLASS = SchemaOpts  # type: type
                                                                                                                                    -
                                                                                                                                    -    # These get set by SchemaMeta
                                                                                                                                    -    opts = None  # type: SchemaOpts
                                                                                                                                    -    _declared_fields = {}  # type: typing.Dict[str, ma_fields.Field]
                                                                                                                                    -    _hooks = {}  # type: typing.Dict[types.Tag, typing.List[str]]
                                                                                                                                    -
                                                                                                                                    -    class Meta:
                                                                                                                                    -        """Options object for a Schema.
                                                                                                                                    -
                                                                                                                                    -        Example usage: ::
                                                                                                                                    -
                                                                                                                                    -            class Meta:
                                                                                                                                    -                fields = ("id", "email", "date_created")
                                                                                                                                    -                exclude = ("password", "secret_attribute")
                                                                                                                                    -
                                                                                                                                    -        Available options:
                                                                                                                                    -
                                                                                                                                    -        - ``fields``: Tuple or list of fields to include in the serialized result.
                                                                                                                                    -        - ``additional``: Tuple or list of fields to include *in addition* to the
                                                                                                                                    -            explicitly declared fields. ``additional`` and ``fields`` are
                                                                                                                                    -            mutually-exclusive options.
                                                                                                                                    -        - ``include``: Dictionary of additional fields to include in the schema. It is
                                                                                                                                    -            usually better to define fields as class variables, but you may need to
                                                                                                                                    -            use this option, e.g., if your fields are Python keywords. May be an
                                                                                                                                    -            `OrderedDict`.
                                                                                                                                    -        - ``exclude``: Tuple or list of fields to exclude in the serialized result.
                                                                                                                                    -            Nested fields can be represented with dot delimiters.
                                                                                                                                    -        - ``dateformat``: Default format for `Date <fields.Date>` fields.
                                                                                                                                    -        - ``datetimeformat``: Default format for `DateTime <fields.DateTime>` fields.
                                                                                                                                    -        - ``timeformat``: Default format for `Time <fields.Time>` fields.
                                                                                                                                    -        - ``render_module``: Module to use for `loads <Schema.loads>` and `dumps <Schema.dumps>`.
                                                                                                                                    -            Defaults to `json` from the standard library.
                                                                                                                                    -        - ``ordered``: If `True`, order serialization output according to the
                                                                                                                                    -            order in which fields were declared. Output of `Schema.dump` will be a
                                                                                                                                    -            `collections.OrderedDict`.
                                                                                                                                    -        - ``index_errors``: If `True`, errors dictionaries will include the index
                                                                                                                                    -            of invalid items in a collection.
                                                                                                                                    -        - ``load_only``: Tuple or list of fields to exclude from serialized results.
                                                                                                                                    -        - ``dump_only``: Tuple or list of fields to exclude from deserialization
                                                                                                                                    -        - ``unknown``: Whether to exclude, include, or raise an error for unknown
                                                                                                                                    -            fields in the data. Use `EXCLUDE`, `INCLUDE` or `RAISE`.
                                                                                                                                    -        - ``register``: Whether to register the `Schema` with marshmallow's internal
                                                                                                                                    -            class registry. Must be `True` if you intend to refer to this `Schema`
                                                                                                                                    -            by class name in `Nested` fields. Only set this to `False` when memory
                                                                                                                                    -            usage is critical. Defaults to `True`.
                                                                                                                                    -        """
                                                                                                                                    -
                                                                                                                                    -    def __init__(
                                                                                                                                    -        self,
                                                                                                                                    -        *,
                                                                                                                                    -        only: typing.Optional[types.StrSequenceOrSet] = None,
                                                                                                                                    -        exclude: types.StrSequenceOrSet = (),
                                                                                                                                    -        many: bool = False,
                                                                                                                                    -        context: typing.Optional[typing.Dict] = None,
                                                                                                                                    -        load_only: types.StrSequenceOrSet = (),
                                                                                                                                    -        dump_only: types.StrSequenceOrSet = (),
                                                                                                                                    -        partial: typing.Union[bool, types.StrSequenceOrSet] = False,
                                                                                                                                    -        unknown: typing.Optional[str] = None
                                                                                                                                    -    ):
                                                                                                                                    -        # Raise error if only or exclude is passed as string, not list of strings
                                                                                                                                    -        if only is not None and not is_collection(only):
                                                                                                                                    -            raise StringNotCollectionError('"only" should be a list of strings')
                                                                                                                                    -        if not is_collection(exclude):
                                                                                                                                    -            raise StringNotCollectionError('"exclude" should be a list of strings')
                                                                                                                                    -        # copy declared fields from metaclass
                                                                                                                                    -        self.declared_fields = copy.deepcopy(self._declared_fields)
                                                                                                                                    -        self.many = many
                                                                                                                                    -        self.only = only
                                                                                                                                    -        self.exclude = set(self.opts.exclude) | set(exclude)
                                                                                                                                    -        self.ordered = self.opts.ordered
                                                                                                                                    -        self.load_only = set(load_only) or set(self.opts.load_only)
                                                                                                                                    -        self.dump_only = set(dump_only) or set(self.opts.dump_only)
                                                                                                                                    -        self.partial = partial
                                                                                                                                    -        self.unknown = unknown or self.opts.unknown
                                                                                                                                    -        self.context = context or {}
                                                                                                                                    -        self._normalize_nested_options()
                                                                                                                                    -        #: Dictionary mapping field_names -> :class:`Field` objects
                                                                                                                                    -        self.fields = {}  # type: typing.Dict[str, ma_fields.Field]
                                                                                                                                    -        self.load_fields = {}  # type: typing.Dict[str, ma_fields.Field]
                                                                                                                                    -        self.dump_fields = {}  # type: typing.Dict[str, ma_fields.Field]
                                                                                                                                    -        self._init_fields()
                                                                                                                                    -        messages = {}
                                                                                                                                    -        messages.update(self._default_error_messages)
                                                                                                                                    -        for cls in reversed(self.__class__.__mro__):
                                                                                                                                    -            messages.update(getattr(cls, "error_messages", {}))
                                                                                                                                    -        messages.update(self.error_messages or {})
                                                                                                                                    -        self.error_messages = messages
                                                                                                                                    -
                                                                                                                                    -    def __repr__(self) -> str:
                                                                                                                                    -        return "<{ClassName}(many={self.many})>".format(
                                                                                                                                    -            ClassName=self.__class__.__name__, self=self
                                                                                                                                    -        )
                                                                                                                                    -
                                                                                                                                    -    @property
                                                                                                                                    -    def dict_class(self) -> type:
                                                                                                                                    -        return OrderedDict if self.ordered else dict
                                                                                                                                    -
                                                                                                                                    -    @property
                                                                                                                                    -    def set_class(self) -> type:
                                                                                                                                    -        return OrderedSet if self.ordered else set
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def from_dict(
                                                                                                                                    -        cls,
                                                                                                                                    -        fields: typing.Dict[str, typing.Union[ma_fields.Field, type]],
                                                                                                                                    -        *,
                                                                                                                                    -        name: str = "GeneratedSchema"
                                                                                                                                    -    ) -> type:
                                                                                                                                    -        """Generate a `Schema` class given a dictionary of fields.
                                                                                                                                    -
                                                                                                                                    -        .. code-block:: python
                                                                                                                                    -
                                                                                                                                    -            from marshmallow import Schema, fields
                                                                                                                                    -
                                                                                                                                    -            PersonSchema = Schema.from_dict({"name": fields.Str()})
                                                                                                                                    -            print(PersonSchema().load({"name": "David"}))  # => {'name': 'David'}
                                                                                                                                    -
                                                                                                                                    -        Generated schemas are not added to the class registry and therefore cannot
                                                                                                                                    -        be referred to by name in `Nested` fields.
                                                                                                                                    -
                                                                                                                                    -        :param dict fields: Dictionary mapping field names to field instances.
                                                                                                                                    -        :param str name: Optional name for the class, which will appear in
                                                                                                                                    -            the ``repr`` for the class.
                                                                                                                                    -
                                                                                                                                    -        .. versionadded:: 3.0.0
                                                                                                                                    -        """
                                                                                                                                    -        attrs = fields.copy()
                                                                                                                                    -        attrs["Meta"] = type(
                                                                                                                                    -            "GeneratedMeta", (getattr(cls, "Meta", object),), {"register": False}
                                                                                                                                    -        )
                                                                                                                                    -        schema_cls = type(name, (cls,), attrs)
                                                                                                                                    -        return schema_cls
                                                                                                                                    -
                                                                                                                                    -    ##### Override-able methods #####
                                                                                                                                    -
                                                                                                                                    -    def handle_error(
                                                                                                                                    -        self, error: ValidationError, data: typing.Any, *, many: bool, **kwargs
                                                                                                                                    -    ):
                                                                                                                                    -        """Custom error handler function for the schema.
                                                                                                                                    -
                                                                                                                                    -        :param error: The `ValidationError` raised during (de)serialization.
                                                                                                                                    -        :param data: The original input data.
                                                                                                                                    -        :param many: Value of ``many`` on dump or load.
                                                                                                                                    -        :param partial: Value of ``partial`` on load.
                                                                                                                                    -
                                                                                                                                    -        .. versionadded:: 2.0.0
                                                                                                                                    -
                                                                                                                                    -        .. versionchanged:: 3.0.0rc9
                                                                                                                                    -            Receives `many` and `partial` (on deserialization) as keyword arguments.
                                                                                                                                    -        """
                                                                                                                                    -        pass
                                                                                                                                    -
                                                                                                                                    -    def get_attribute(self, obj: typing.Any, attr: str, default: typing.Any):
                                                                                                                                    -        """Defines how to pull values from an object to serialize.
                                                                                                                                    -
                                                                                                                                    -        .. versionadded:: 2.0.0
                                                                                                                                    -
                                                                                                                                    -        .. versionchanged:: 3.0.0a1
                                                                                                                                    -            Changed position of ``obj`` and ``attr``.
                                                                                                                                    -        """
                                                                                                                                    -        return get_value(obj, attr, default)
                                                                                                                                    -
                                                                                                                                    -    ##### Serialization/Deserialization API #####
                                                                                                                                    -
                                                                                                                                    -    @staticmethod
                                                                                                                                    -    def _call_and_store(getter_func, data, *, field_name, error_store, index=None):
                                                                                                                                    -        """Call ``getter_func`` with ``data`` as its argument, and store any `ValidationErrors`.
                                                                                                                                    -
                                                                                                                                    -        :param callable getter_func: Function for getting the serialized/deserialized
                                                                                                                                    -            value from ``data``.
                                                                                                                                    -        :param data: The data passed to ``getter_func``.
                                                                                                                                    -        :param str field_name: Field name.
                                                                                                                                    -        :param int index: Index of the item being validated, if validating a collection,
                                                                                                                                    -            otherwise `None`.
                                                                                                                                    -        """
                                                                                                                                    -        try:
                                                                                                                                    -            value = getter_func(data)
                                                                                                                                    -        except ValidationError as error:
                                                                                                                                    -            error_store.store_error(error.messages, field_name, index=index)
                                                                                                                                    -            # When a Nested field fails validation, the marshalled data is stored
                                                                                                                                    -            # on the ValidationError's valid_data attribute
                                                                                                                                    -            return error.valid_data or missing
                                                                                                                                    -        return value
                                                                                                                                    -
                                                                                                                                    -    def _serialize(
                                                                                                                                    -        self, obj: typing.Union[_T, typing.Iterable[_T]], *, many: bool = False
                                                                                                                                    -    ):
                                                                                                                                    -        """Serialize ``obj``.
                                                                                                                                    -
                                                                                                                                    -        :param obj: The object(s) to serialize.
                                                                                                                                    -        :param bool many: `True` if ``data`` should be serialized as a collection.
                                                                                                                                    -        :return: A dictionary of the serialized data
                                                                                                                                    -
                                                                                                                                    -        .. versionchanged:: 1.0.0
                                                                                                                                    -            Renamed from ``marshal``.
                                                                                                                                    -        """
                                                                                                                                    -        if many and obj is not None:
                                                                                                                                    -            return [
                                                                                                                                    -                self._serialize(d, many=False)
                                                                                                                                    -                for d in typing.cast(typing.Iterable[_T], obj)
                                                                                                                                    -            ]
                                                                                                                                    -        ret = self.dict_class()
                                                                                                                                    -        for attr_name, field_obj in self.dump_fields.items():
                                                                                                                                    -            value = field_obj.serialize(attr_name, obj, accessor=self.get_attribute)
                                                                                                                                    -            if value is missing:
                                                                                                                                    -                continue
                                                                                                                                    -            key = field_obj.data_key if field_obj.data_key is not None else attr_name
                                                                                                                                    -            ret[key] = value
                                                                                                                                    -        return ret
                                                                                                                                    -
                                                                                                                                    -    def dump(self, obj: typing.Any, *, many: typing.Optional[bool] = None):
                                                                                                                                    -        """Serialize an object to native Python data types according to this
                                                                                                                                    -        Schema's fields.
                                                                                                                                    -
                                                                                                                                    -        :param obj: The object to serialize.
                                                                                                                                    -        :param many: Whether to serialize `obj` as a collection. If `None`, the value
                                                                                                                                    -            for `self.many` is used.
                                                                                                                                    -        :return: A dict of serialized data
                                                                                                                                    -        :rtype: dict
                                                                                                                                    -
                                                                                                                                    -        .. versionadded:: 1.0.0
                                                                                                                                    -        .. versionchanged:: 3.0.0b7
                                                                                                                                    -            This method returns the serialized data rather than a ``(data, errors)`` duple.
                                                                                                                                    -            A :exc:`ValidationError <marshmallow.exceptions.ValidationError>` is raised
                                                                                                                                    -            if ``obj`` is invalid.
                                                                                                                                    -        .. versionchanged:: 3.0.0rc9
                                                                                                                                    -            Validation no longer occurs upon serialization.
                                                                                                                                    -        """
                                                                                                                                    -        many = self.many if many is None else bool(many)
                                                                                                                                    -        if many and is_iterable_but_not_string(obj):
                                                                                                                                    -            obj = list(obj)
                                                                                                                                    -
                                                                                                                                    -        if self._has_processors(PRE_DUMP):
                                                                                                                                    -            processed_obj = self._invoke_dump_processors(
                                                                                                                                    -                PRE_DUMP, obj, many=many, original_data=obj
                                                                                                                                    -            )
                                                                                                                                    -        else:
                                                                                                                                    -            processed_obj = obj
                                                                                                                                    -
                                                                                                                                    -        result = self._serialize(processed_obj, many=many)
                                                                                                                                    -
                                                                                                                                    -        if self._has_processors(POST_DUMP):
                                                                                                                                    -            result = self._invoke_dump_processors(
                                                                                                                                    -                POST_DUMP, result, many=many, original_data=obj
                                                                                                                                    -            )
                                                                                                                                    -
                                                                                                                                    -        return result
                                                                                                                                    -
                                                                                                                                    -    def dumps(
                                                                                                                                    -        self, obj: typing.Any, *args, many: typing.Optional[bool] = None, **kwargs
                                                                                                                                    -    ):
                                                                                                                                    -        """Same as :meth:`dump`, except return a JSON-encoded string.
                                                                                                                                    -
                                                                                                                                    -        :param obj: The object to serialize.
                                                                                                                                    -        :param many: Whether to serialize `obj` as a collection. If `None`, the value
                                                                                                                                    -            for `self.many` is used.
                                                                                                                                    -        :return: A ``json`` string
                                                                                                                                    -        :rtype: str
                                                                                                                                    -
                                                                                                                                    -        .. versionadded:: 1.0.0
                                                                                                                                    -        .. versionchanged:: 3.0.0b7
                                                                                                                                    -            This method returns the serialized data rather than a ``(data, errors)`` duple.
                                                                                                                                    -            A :exc:`ValidationError <marshmallow.exceptions.ValidationError>` is raised
                                                                                                                                    -            if ``obj`` is invalid.
                                                                                                                                    -        """
                                                                                                                                    -        serialized = self.dump(obj, many=many)
                                                                                                                                    -        return self.opts.render_module.dumps(serialized, *args, **kwargs)
                                                                                                                                    -
                                                                                                                                    -    def _deserialize(
                                                                                                                                    -        self,
                                                                                                                                    -        data: typing.Union[
                                                                                                                                    -            typing.Mapping[str, typing.Any],
                                                                                                                                    -            typing.Iterable[typing.Mapping[str, typing.Any]],
                                                                                                                                    -        ],
                                                                                                                                    -        *,
                                                                                                                                    -        error_store: ErrorStore,
                                                                                                                                    -        many: bool = False,
                                                                                                                                    -        partial=False,
                                                                                                                                    -        unknown=RAISE,
                                                                                                                                    -        index=None
                                                                                                                                    -    ) -> typing.Union[_T, typing.List[_T]]:
                                                                                                                                    -        """Deserialize ``data``.
                                                                                                                                    -
                                                                                                                                    -        :param dict data: The data to deserialize.
                                                                                                                                    -        :param ErrorStore error_store: Structure to store errors.
                                                                                                                                    -        :param bool many: `True` if ``data`` should be deserialized as a collection.
                                                                                                                                    -        :param bool|tuple partial: Whether to ignore missing fields and not require
                                                                                                                                    -            any fields declared. Propagates down to ``Nested`` fields as well. If
                                                                                                                                    -            its value is an iterable, only missing fields listed in that iterable
                                                                                                                                    -            will be ignored. Use dot delimiters to specify nested fields.
                                                                                                                                    -        :param unknown: Whether to exclude, include, or raise an error for unknown
                                                                                                                                    -            fields in the data. Use `EXCLUDE`, `INCLUDE` or `RAISE`.
                                                                                                                                    -        :param int index: Index of the item being serialized (for storing errors) if
                                                                                                                                    -            serializing a collection, otherwise `None`.
                                                                                                                                    -        :return: A dictionary of the deserialized data.
                                                                                                                                    -        """
                                                                                                                                    -        index_errors = self.opts.index_errors
                                                                                                                                    -        index = index if index_errors else None
                                                                                                                                    -        if many:
                                                                                                                                    -            if not is_collection(data):
                                                                                                                                    -                error_store.store_error([self.error_messages["type"]], index=index)
                                                                                                                                    -                ret = []  # type: typing.List[_T]
                                                                                                                                    -            else:
                                                                                                                                    -                ret = [
                                                                                                                                    -                    typing.cast(
                                                                                                                                    -                        _T,
                                                                                                                                    -                        self._deserialize(
                                                                                                                                    -                            typing.cast(typing.Mapping[str, typing.Any], d),
                                                                                                                                    -                            error_store=error_store,
                                                                                                                                    -                            many=False,
                                                                                                                                    -                            partial=partial,
                                                                                                                                    -                            unknown=unknown,
                                                                                                                                    -                            index=idx,
                                                                                                                                    -                        ),
                                                                                                                                    -                    )
                                                                                                                                    -                    for idx, d in enumerate(data)
                                                                                                                                    -                ]
                                                                                                                                    -            return ret
                                                                                                                                    -        ret = self.dict_class()
                                                                                                                                    -        # Check data is a dict
                                                                                                                                    -        if not isinstance(data, Mapping):
                                                                                                                                    -            error_store.store_error([self.error_messages["type"]], index=index)
                                                                                                                                    -        else:
                                                                                                                                    -            partial_is_collection = is_collection(partial)
                                                                                                                                    -            for attr_name, field_obj in self.load_fields.items():
                                                                                                                                    -                field_name = (
                                                                                                                                    -                    field_obj.data_key if field_obj.data_key is not None else attr_name
                                                                                                                                    -                )
                                                                                                                                    -                raw_value = data.get(field_name, missing)
                                                                                                                                    -                if raw_value is missing:
                                                                                                                                    -                    # Ignore missing field if we're allowed to.
                                                                                                                                    -                    if partial is True or (
                                                                                                                                    -                        partial_is_collection and attr_name in partial
                                                                                                                                    -                    ):
                                                                                                                                    -                        continue
                                                                                                                                    -                d_kwargs = {}
                                                                                                                                    -                # Allow partial loading of nested schemas.
                                                                                                                                    -                if partial_is_collection:
                                                                                                                                    -                    prefix = field_name + "."
                                                                                                                                    -                    len_prefix = len(prefix)
                                                                                                                                    -                    sub_partial = [
                                                                                                                                    -                        f[len_prefix:] for f in partial if f.startswith(prefix)
                                                                                                                                    -                    ]
                                                                                                                                    -                    d_kwargs["partial"] = sub_partial
                                                                                                                                    -                else:
                                                                                                                                    -                    d_kwargs["partial"] = partial
                                                                                                                                    -                getter = lambda val: field_obj.deserialize(
                                                                                                                                    -                    val, field_name, data, **d_kwargs
                                                                                                                                    -                )
                                                                                                                                    -                value = self._call_and_store(
                                                                                                                                    -                    getter_func=getter,
                                                                                                                                    -                    data=raw_value,
                                                                                                                                    -                    field_name=field_name,
                                                                                                                                    -                    error_store=error_store,
                                                                                                                                    -                    index=index,
                                                                                                                                    -                )
                                                                                                                                    -                if value is not missing:
                                                                                                                                    -                    key = field_obj.attribute or attr_name
                                                                                                                                    -                    set_value(typing.cast(typing.Dict, ret), key, value)
                                                                                                                                    -            if unknown != EXCLUDE:
                                                                                                                                    -                fields = {
                                                                                                                                    -                    field_obj.data_key if field_obj.data_key is not None else field_name
                                                                                                                                    -                    for field_name, field_obj in self.load_fields.items()
                                                                                                                                    -                }
                                                                                                                                    -                for key in set(data) - fields:
                                                                                                                                    -                    value = data[key]
                                                                                                                                    -                    if unknown == INCLUDE:
                                                                                                                                    -                        set_value(typing.cast(typing.Dict, ret), key, value)
                                                                                                                                    -                    elif unknown == RAISE:
                                                                                                                                    -                        error_store.store_error(
                                                                                                                                    -                            [self.error_messages["unknown"]],
                                                                                                                                    -                            key,
                                                                                                                                    -                            (index if index_errors else None),
                                                                                                                                    -                        )
                                                                                                                                    -        return ret
                                                                                                                                    -
                                                                                                                                    -    def load(
                                                                                                                                    -        self,
                                                                                                                                    -        data: typing.Union[
                                                                                                                                    -            typing.Mapping[str, typing.Any],
                                                                                                                                    -            typing.Iterable[typing.Mapping[str, typing.Any]],
                                                                                                                                    -        ],
                                                                                                                                    -        *,
                                                                                                                                    -        many: typing.Optional[bool] = None,
                                                                                                                                    -        partial: typing.Optional[typing.Union[bool, types.StrSequenceOrSet]] = None,
                                                                                                                                    -        unknown: typing.Optional[str] = None
                                                                                                                                    -    ):
                                                                                                                                    -        """Deserialize a data structure to an object defined by this Schema's fields.
                                                                                                                                    -
                                                                                                                                    -        :param data: The data to deserialize.
                                                                                                                                    -        :param many: Whether to deserialize `data` as a collection. If `None`, the
                                                                                                                                    -            value for `self.many` is used.
                                                                                                                                    -        :param partial: Whether to ignore missing fields and not require
                                                                                                                                    -            any fields declared. Propagates down to ``Nested`` fields as well. If
                                                                                                                                    -            its value is an iterable, only missing fields listed in that iterable
                                                                                                                                    -            will be ignored. Use dot delimiters to specify nested fields.
                                                                                                                                    -        :param unknown: Whether to exclude, include, or raise an error for unknown
                                                                                                                                    -            fields in the data. Use `EXCLUDE`, `INCLUDE` or `RAISE`.
                                                                                                                                    -            If `None`, the value for `self.unknown` is used.
                                                                                                                                    -        :return: Deserialized data
                                                                                                                                    -
                                                                                                                                    -        .. versionadded:: 1.0.0
                                                                                                                                    -        .. versionchanged:: 3.0.0b7
                                                                                                                                    -            This method returns the deserialized data rather than a ``(data, errors)`` duple.
                                                                                                                                    -            A :exc:`ValidationError <marshmallow.exceptions.ValidationError>` is raised
                                                                                                                                    -            if invalid data are passed.
                                                                                                                                    -        """
                                                                                                                                    -        return self._do_load(
                                                                                                                                    -            data, many=many, partial=partial, unknown=unknown, postprocess=True
                                                                                                                                    -        )
                                                                                                                                    -
                                                                                                                                    -    def loads(
                                                                                                                                    -        self,
                                                                                                                                    -        json_data: str,
                                                                                                                                    -        *,
                                                                                                                                    -        many: typing.Optional[bool] = None,
                                                                                                                                    -        partial: typing.Optional[typing.Union[bool, types.StrSequenceOrSet]] = None,
                                                                                                                                    -        unknown: typing.Optional[str] = None,
                                                                                                                                    -        **kwargs
                                                                                                                                    -    ):
                                                                                                                                    -        """Same as :meth:`load`, except it takes a JSON string as input.
                                                                                                                                    -
                                                                                                                                    -        :param json_data: A JSON string of the data to deserialize.
                                                                                                                                    -        :param many: Whether to deserialize `obj` as a collection. If `None`, the
                                                                                                                                    -            value for `self.many` is used.
                                                                                                                                    -        :param partial: Whether to ignore missing fields and not require
                                                                                                                                    -            any fields declared. Propagates down to ``Nested`` fields as well. If
                                                                                                                                    -            its value is an iterable, only missing fields listed in that iterable
                                                                                                                                    -            will be ignored. Use dot delimiters to specify nested fields.
                                                                                                                                    -        :param unknown: Whether to exclude, include, or raise an error for unknown
                                                                                                                                    -            fields in the data. Use `EXCLUDE`, `INCLUDE` or `RAISE`.
                                                                                                                                    -            If `None`, the value for `self.unknown` is used.
                                                                                                                                    -        :return: Deserialized data
                                                                                                                                    -
                                                                                                                                    -        .. versionadded:: 1.0.0
                                                                                                                                    -        .. versionchanged:: 3.0.0b7
                                                                                                                                    -            This method returns the deserialized data rather than a ``(data, errors)`` duple.
                                                                                                                                    -            A :exc:`ValidationError <marshmallow.exceptions.ValidationError>` is raised
                                                                                                                                    -            if invalid data are passed.
                                                                                                                                    -        """
                                                                                                                                    -        data = self.opts.render_module.loads(json_data, **kwargs)
                                                                                                                                    -        return self.load(data, many=many, partial=partial, unknown=unknown)
                                                                                                                                    -
                                                                                                                                    -    def _run_validator(
                                                                                                                                    -        self,
                                                                                                                                    -        validator_func,
                                                                                                                                    -        output,
                                                                                                                                    -        *,
                                                                                                                                    -        original_data,
                                                                                                                                    -        error_store,
                                                                                                                                    -        many,
                                                                                                                                    -        partial,
                                                                                                                                    -        pass_original,
                                                                                                                                    -        index=None
                                                                                                                                    -    ):
                                                                                                                                    -        try:
                                                                                                                                    -            if pass_original:  # Pass original, raw data (before unmarshalling)
                                                                                                                                    -                validator_func(output, original_data, partial=partial, many=many)
                                                                                                                                    -            else:
                                                                                                                                    -                validator_func(output, partial=partial, many=many)
                                                                                                                                    -        except ValidationError as err:
                                                                                                                                    -            error_store.store_error(err.messages, err.field_name, index=index)
                                                                                                                                    -
                                                                                                                                    -    def validate(
                                                                                                                                    -        self,
                                                                                                                                    -        data: typing.Mapping,
                                                                                                                                    -        *,
                                                                                                                                    -        many: typing.Optional[bool] = None,
                                                                                                                                    -        partial: typing.Optional[typing.Union[bool, types.StrSequenceOrSet]] = None
                                                                                                                                    -    ) -> typing.Dict[str, typing.List[str]]:
                                                                                                                                    -        """Validate `data` against the schema, returning a dictionary of
                                                                                                                                    -        validation errors.
                                                                                                                                    -
                                                                                                                                    -        :param data: The data to validate.
                                                                                                                                    -        :param many: Whether to validate `data` as a collection. If `None`, the
                                                                                                                                    -            value for `self.many` is used.
                                                                                                                                    -        :param partial: Whether to ignore missing fields and not require
                                                                                                                                    -            any fields declared. Propagates down to ``Nested`` fields as well. If
                                                                                                                                    -            its value is an iterable, only missing fields listed in that iterable
                                                                                                                                    -            will be ignored. Use dot delimiters to specify nested fields.
                                                                                                                                    -        :return: A dictionary of validation errors.
                                                                                                                                    -
                                                                                                                                    -        .. versionadded:: 1.1.0
                                                                                                                                    -        """
                                                                                                                                    -        try:
                                                                                                                                    -            self._do_load(data, many=many, partial=partial, postprocess=False)
                                                                                                                                    -        except ValidationError as exc:
                                                                                                                                    -            return typing.cast(typing.Dict[str, typing.List[str]], exc.messages)
                                                                                                                                    -        return {}
                                                                                                                                    -
                                                                                                                                    -    ##### Private Helpers #####
                                                                                                                                    -
                                                                                                                                    -    def _do_load(
                                                                                                                                    -        self,
                                                                                                                                    -        data: typing.Union[
                                                                                                                                    -            typing.Mapping[str, typing.Any],
                                                                                                                                    -            typing.Iterable[typing.Mapping[str, typing.Any]],
                                                                                                                                    -        ],
                                                                                                                                    -        *,
                                                                                                                                    -        many: typing.Optional[bool] = None,
                                                                                                                                    -        partial: typing.Optional[typing.Union[bool, types.StrSequenceOrSet]] = None,
                                                                                                                                    -        unknown: typing.Optional[str] = None,
                                                                                                                                    -        postprocess: bool = True
                                                                                                                                    -    ):
                                                                                                                                    -        """Deserialize `data`, returning the deserialized result.
                                                                                                                                    -        This method is private API.
                                                                                                                                    -
                                                                                                                                    -        :param data: The data to deserialize.
                                                                                                                                    -        :param many: Whether to deserialize `data` as a collection. If `None`, the
                                                                                                                                    -            value for `self.many` is used.
                                                                                                                                    -        :param partial: Whether to validate required fields. If its
                                                                                                                                    -            value is an iterable, only fields listed in that iterable will be
                                                                                                                                    -            ignored will be allowed missing. If `True`, all fields will be allowed missing.
                                                                                                                                    -            If `None`, the value for `self.partial` is used.
                                                                                                                                    -        :param unknown: Whether to exclude, include, or raise an error for unknown
                                                                                                                                    -            fields in the data. Use `EXCLUDE`, `INCLUDE` or `RAISE`.
                                                                                                                                    -            If `None`, the value for `self.unknown` is used.
                                                                                                                                    -        :param postprocess: Whether to run post_load methods..
                                                                                                                                    -        :return: Deserialized data
                                                                                                                                    -        """
                                                                                                                                    -        error_store = ErrorStore()
                                                                                                                                    -        errors = {}  # type: typing.Dict[str, typing.List[str]]
                                                                                                                                    -        many = self.many if many is None else bool(many)
                                                                                                                                    -        unknown = unknown or self.unknown
                                                                                                                                    -        if partial is None:
                                                                                                                                    -            partial = self.partial
                                                                                                                                    -        # Run preprocessors
                                                                                                                                    -        if self._has_processors(PRE_LOAD):
                                                                                                                                    -            try:
                                                                                                                                    -                processed_data = self._invoke_load_processors(
                                                                                                                                    -                    PRE_LOAD, data, many=many, original_data=data, partial=partial
                                                                                                                                    -                )
                                                                                                                                    -            except ValidationError as err:
                                                                                                                                    -                errors = err.normalized_messages()
                                                                                                                                    -                result = (
                                                                                                                                    -                    None
                                                                                                                                    -                )  # type: typing.Optional[typing.Union[typing.List, typing.Dict]]
                                                                                                                                    -        else:
                                                                                                                                    -            processed_data = data
                                                                                                                                    -        if not errors:
                                                                                                                                    -            # Deserialize data
                                                                                                                                    -            result = self._deserialize(
                                                                                                                                    -                processed_data,
                                                                                                                                    -                error_store=error_store,
                                                                                                                                    -                many=many,
                                                                                                                                    -                partial=partial,
                                                                                                                                    -                unknown=unknown,
                                                                                                                                    -            )
                                                                                                                                    -            # Run field-level validation
                                                                                                                                    -            self._invoke_field_validators(
                                                                                                                                    -                error_store=error_store, data=result, many=many
                                                                                                                                    -            )
                                                                                                                                    -            # Run schema-level validation
                                                                                                                                    -            if self._has_processors(VALIDATES_SCHEMA):
                                                                                                                                    -                field_errors = bool(error_store.errors)
                                                                                                                                    -                self._invoke_schema_validators(
                                                                                                                                    -                    error_store=error_store,
                                                                                                                                    -                    pass_many=True,
                                                                                                                                    -                    data=result,
                                                                                                                                    -                    original_data=data,
                                                                                                                                    -                    many=many,
                                                                                                                                    -                    partial=partial,
                                                                                                                                    -                    field_errors=field_errors,
                                                                                                                                    -                )
                                                                                                                                    -                self._invoke_schema_validators(
                                                                                                                                    -                    error_store=error_store,
                                                                                                                                    -                    pass_many=False,
                                                                                                                                    -                    data=result,
                                                                                                                                    -                    original_data=data,
                                                                                                                                    -                    many=many,
                                                                                                                                    -                    partial=partial,
                                                                                                                                    -                    field_errors=field_errors,
                                                                                                                                    -                )
                                                                                                                                    -            errors = error_store.errors
                                                                                                                                    -            # Run post processors
                                                                                                                                    -            if not errors and postprocess and self._has_processors(POST_LOAD):
                                                                                                                                    -                try:
                                                                                                                                    -                    result = self._invoke_load_processors(
                                                                                                                                    -                        POST_LOAD,
                                                                                                                                    -                        result,
                                                                                                                                    -                        many=many,
                                                                                                                                    -                        original_data=data,
                                                                                                                                    -                        partial=partial,
                                                                                                                                    -                    )
                                                                                                                                    -                except ValidationError as err:
                                                                                                                                    -                    errors = err.normalized_messages()
                                                                                                                                    -        if errors:
                                                                                                                                    -            exc = ValidationError(errors, data=data, valid_data=result)
                                                                                                                                    -            self.handle_error(exc, data, many=many, partial=partial)
                                                                                                                                    -            raise exc
                                                                                                                                    -
                                                                                                                                    -        return result
                                                                                                                                    -
                                                                                                                                    -    def _normalize_nested_options(self) -> None:
                                                                                                                                    -        """Apply then flatten nested schema options.
                                                                                                                                    -        This method is private API.
                                                                                                                                    -        """
                                                                                                                                    -        if self.only is not None:
                                                                                                                                    -            # Apply the only option to nested fields.
                                                                                                                                    -            self.__apply_nested_option("only", self.only, "intersection")
                                                                                                                                    -            # Remove the child field names from the only option.
                                                                                                                                    -            self.only = self.set_class([field.split(".", 1)[0] for field in self.only])
                                                                                                                                    -        if self.exclude:
                                                                                                                                    -            # Apply the exclude option to nested fields.
                                                                                                                                    -            self.__apply_nested_option("exclude", self.exclude, "union")
                                                                                                                                    -            # Remove the parent field names from the exclude option.
                                                                                                                                    -            self.exclude = self.set_class(
                                                                                                                                    -                [field for field in self.exclude if "." not in field]
                                                                                                                                    -            )
                                                                                                                                    -
                                                                                                                                    -    def __apply_nested_option(self, option_name, field_names, set_operation) -> None:
                                                                                                                                    -        """Apply nested options to nested fields"""
                                                                                                                                    -        # Split nested field names on the first dot.
                                                                                                                                    -        nested_fields = [name.split(".", 1) for name in field_names if "." in name]
                                                                                                                                    -        # Partition the nested field names by parent field.
                                                                                                                                    -        nested_options = defaultdict(list)  # type: defaultdict
                                                                                                                                    -        for parent, nested_names in nested_fields:
                                                                                                                                    -            nested_options[parent].append(nested_names)
                                                                                                                                    -        # Apply the nested field options.
                                                                                                                                    -        for key, options in iter(nested_options.items()):
                                                                                                                                    -            new_options = self.set_class(options)
                                                                                                                                    -            original_options = getattr(self.declared_fields[key], option_name, ())
                                                                                                                                    -            if original_options:
                                                                                                                                    -                if set_operation == "union":
                                                                                                                                    -                    new_options |= self.set_class(original_options)
                                                                                                                                    -                if set_operation == "intersection":
                                                                                                                                    -                    new_options &= self.set_class(original_options)
                                                                                                                                    -            setattr(self.declared_fields[key], option_name, new_options)
                                                                                                                                    -
                                                                                                                                    -    def _init_fields(self) -> None:
                                                                                                                                    -        """Update self.fields, self.load_fields, and self.dump_fields based on schema options.
                                                                                                                                    -        This method is private API.
                                                                                                                                    -        """
                                                                                                                                    -        if self.opts.fields:
                                                                                                                                    -            available_field_names = self.set_class(self.opts.fields)
                                                                                                                                    -        else:
                                                                                                                                    -            available_field_names = self.set_class(self.declared_fields.keys())
                                                                                                                                    -            if self.opts.additional:
                                                                                                                                    -                available_field_names |= self.set_class(self.opts.additional)
                                                                                                                                    -
                                                                                                                                    -        invalid_fields = self.set_class()
                                                                                                                                    -
                                                                                                                                    -        if self.only is not None:
                                                                                                                                    -            # Return only fields specified in only option
                                                                                                                                    -            field_names = self.set_class(self.only)
                                                                                                                                    -
                                                                                                                                    -            invalid_fields |= field_names - available_field_names
                                                                                                                                    -        else:
                                                                                                                                    -            field_names = available_field_names
                                                                                                                                    -
                                                                                                                                    -        # If "exclude" option or param is specified, remove those fields.
                                                                                                                                    -        if self.exclude:
                                                                                                                                    -            # Note that this isn't available_field_names, since we want to
                                                                                                                                    -            # apply "only" for the actual calculation.
                                                                                                                                    -            field_names = field_names - self.exclude
                                                                                                                                    -            invalid_fields |= self.exclude - available_field_names
                                                                                                                                    -
                                                                                                                                    -        if invalid_fields:
                                                                                                                                    -            message = "Invalid fields for {}: {}.".format(self, invalid_fields)
                                                                                                                                    -            raise ValueError(message)
                                                                                                                                    -
                                                                                                                                    -        fields_dict = self.dict_class()
                                                                                                                                    -        for field_name in field_names:
                                                                                                                                    -            field_obj = self.declared_fields.get(field_name, ma_fields.Inferred())
                                                                                                                                    -            self._bind_field(field_name, field_obj)
                                                                                                                                    -            fields_dict[field_name] = field_obj
                                                                                                                                    -
                                                                                                                                    -        load_fields, dump_fields = self.dict_class(), self.dict_class()
                                                                                                                                    -        for field_name, field_obj in fields_dict.items():
                                                                                                                                    -            if not field_obj.dump_only:
                                                                                                                                    -                load_fields[field_name] = field_obj
                                                                                                                                    -            if not field_obj.load_only:
                                                                                                                                    -                dump_fields[field_name] = field_obj
                                                                                                                                    -
                                                                                                                                    -        dump_data_keys = [
                                                                                                                                    -            field_obj.data_key if field_obj.data_key is not None else name
                                                                                                                                    -            for name, field_obj in dump_fields.items()
                                                                                                                                    -        ]
                                                                                                                                    -        if len(dump_data_keys) != len(set(dump_data_keys)):
                                                                                                                                    -            data_keys_duplicates = {
                                                                                                                                    -                x for x in dump_data_keys if dump_data_keys.count(x) > 1
                                                                                                                                    -            }
                                                                                                                                    -            raise ValueError(
                                                                                                                                    -                "The data_key argument for one or more fields collides "
                                                                                                                                    -                "with another field's name or data_key argument. "
                                                                                                                                    -                "Check the following field names and "
                                                                                                                                    -                "data_key arguments: {}".format(list(data_keys_duplicates))
                                                                                                                                    -            )
                                                                                                                                    -        load_attributes = [obj.attribute or name for name, obj in load_fields.items()]
                                                                                                                                    -        if len(load_attributes) != len(set(load_attributes)):
                                                                                                                                    -            attributes_duplicates = {
                                                                                                                                    -                x for x in load_attributes if load_attributes.count(x) > 1
                                                                                                                                    -            }
                                                                                                                                    -            raise ValueError(
                                                                                                                                    -                "The attribute argument for one or more fields collides "
                                                                                                                                    -                "with another field's name or attribute argument. "
                                                                                                                                    -                "Check the following field names and "
                                                                                                                                    -                "attribute arguments: {}".format(list(attributes_duplicates))
                                                                                                                                    -            )
                                                                                                                                    -
                                                                                                                                    -        self.fields = fields_dict
                                                                                                                                    -        self.dump_fields = dump_fields
                                                                                                                                    -        self.load_fields = load_fields
                                                                                                                                    -
                                                                                                                                    -    def on_bind_field(self, field_name: str, field_obj: ma_fields.Field) -> None:
                                                                                                                                    -        """Hook to modify a field when it is bound to the `Schema`.
                                                                                                                                    -
                                                                                                                                    -        No-op by default.
                                                                                                                                    -        """
                                                                                                                                    -        return None
                                                                                                                                    -
                                                                                                                                    -    def _bind_field(self, field_name: str, field_obj: ma_fields.Field) -> None:
                                                                                                                                    -        """Bind field to the schema, setting any necessary attributes on the
                                                                                                                                    -        field (e.g. parent and name).
                                                                                                                                    -
                                                                                                                                    -        Also set field load_only and dump_only values if field_name was
                                                                                                                                    -        specified in ``class Meta``.
                                                                                                                                    -        """
                                                                                                                                    -        if field_name in self.load_only:
                                                                                                                                    -            field_obj.load_only = True
                                                                                                                                    -        if field_name in self.dump_only:
                                                                                                                                    -            field_obj.dump_only = True
                                                                                                                                    -        try:
                                                                                                                                    -            field_obj._bind_to_schema(field_name, self)
                                                                                                                                    -        except TypeError as error:
                                                                                                                                    -            # Field declared as a class, not an instance. Ignore type checking because
                                                                                                                                    -            # we handle unsupported arg types, i.e. this is dead code from
                                                                                                                                    -            # the type checker's perspective.
                                                                                                                                    -            if isinstance(field_obj, type) and issubclass(field_obj, base.FieldABC):
                                                                                                                                    -                msg = (
                                                                                                                                    -                    'Field for "{}" must be declared as a '
                                                                                                                                    -                    "Field instance, not a class. "
                                                                                                                                    -                    'Did you mean "fields.{}()"?'.format(field_name, field_obj.__name__)
                                                                                                                                    -                )
                                                                                                                                    -                raise TypeError(msg) from error
                                                                                                                                    -            raise error
                                                                                                                                    -        self.on_bind_field(field_name, field_obj)
                                                                                                                                    -
                                                                                                                                    -    @lru_cache(maxsize=8)
                                                                                                                                    -    def _has_processors(self, tag) -> bool:
                                                                                                                                    -        return bool(self._hooks[(tag, True)] or self._hooks[(tag, False)])
                                                                                                                                    -
                                                                                                                                    -    def _invoke_dump_processors(
                                                                                                                                    -        self, tag: str, data, *, many: bool, original_data=None
                                                                                                                                    -    ):
                                                                                                                                    -        # The pass_many post-dump processors may do things like add an envelope, so
                                                                                                                                    -        # invoke those after invoking the non-pass_many processors which will expect
                                                                                                                                    -        # to get a list of items.
                                                                                                                                    -        data = self._invoke_processors(
                                                                                                                                    -            tag, pass_many=False, data=data, many=many, original_data=original_data
                                                                                                                                    -        )
                                                                                                                                    -        data = self._invoke_processors(
                                                                                                                                    -            tag, pass_many=True, data=data, many=many, original_data=original_data
                                                                                                                                    -        )
                                                                                                                                    -        return data
                                                                                                                                    -
                                                                                                                                    -    def _invoke_load_processors(
                                                                                                                                    -        self,
                                                                                                                                    -        tag: str,
                                                                                                                                    -        data,
                                                                                                                                    -        *,
                                                                                                                                    -        many: bool,
                                                                                                                                    -        original_data,
                                                                                                                                    -        partial: typing.Union[bool, types.StrSequenceOrSet]
                                                                                                                                    -    ):
                                                                                                                                    -        # This has to invert the order of the dump processors, so run the pass_many
                                                                                                                                    -        # processors first.
                                                                                                                                    -        data = self._invoke_processors(
                                                                                                                                    -            tag,
                                                                                                                                    -            pass_many=True,
                                                                                                                                    -            data=data,
                                                                                                                                    -            many=many,
                                                                                                                                    -            original_data=original_data,
                                                                                                                                    -            partial=partial,
                                                                                                                                    -        )
                                                                                                                                    -        data = self._invoke_processors(
                                                                                                                                    -            tag,
                                                                                                                                    -            pass_many=False,
                                                                                                                                    -            data=data,
                                                                                                                                    -            many=many,
                                                                                                                                    -            original_data=original_data,
                                                                                                                                    -            partial=partial,
                                                                                                                                    -        )
                                                                                                                                    -        return data
                                                                                                                                    -
                                                                                                                                    -    def _invoke_field_validators(self, *, error_store: ErrorStore, data, many: bool):
                                                                                                                                    -        for attr_name in self._hooks[VALIDATES]:
                                                                                                                                    -            validator = getattr(self, attr_name)
                                                                                                                                    -            validator_kwargs = validator.__marshmallow_hook__[VALIDATES]
                                                                                                                                    -            field_name = validator_kwargs["field_name"]
                                                                                                                                    -
                                                                                                                                    -            try:
                                                                                                                                    -                field_obj = self.fields[field_name]
                                                                                                                                    -            except KeyError as error:
                                                                                                                                    -                if field_name in self.declared_fields:
                                                                                                                                    -                    continue
                                                                                                                                    -                raise ValueError(
                                                                                                                                    -                    '"{}" field does not exist.'.format(field_name)
                                                                                                                                    -                ) from error
                                                                                                                                    -
                                                                                                                                    -            data_key = (
                                                                                                                                    -                field_obj.data_key if field_obj.data_key is not None else field_name
                                                                                                                                    -            )
                                                                                                                                    -            if many:
                                                                                                                                    -                for idx, item in enumerate(data):
                                                                                                                                    -                    try:
                                                                                                                                    -                        value = item[field_obj.attribute or field_name]
                                                                                                                                    -                    except KeyError:
                                                                                                                                    -                        pass
                                                                                                                                    -                    else:
                                                                                                                                    -                        validated_value = self._call_and_store(
                                                                                                                                    -                            getter_func=validator,
                                                                                                                                    -                            data=value,
                                                                                                                                    -                            field_name=data_key,
                                                                                                                                    -                            error_store=error_store,
                                                                                                                                    -                            index=(idx if self.opts.index_errors else None),
                                                                                                                                    -                        )
                                                                                                                                    -                        if validated_value is missing:
                                                                                                                                    -                            data[idx].pop(field_name, None)
                                                                                                                                    -            else:
                                                                                                                                    -                try:
                                                                                                                                    -                    value = data[field_obj.attribute or field_name]
                                                                                                                                    -                except KeyError:
                                                                                                                                    -                    pass
                                                                                                                                    -                else:
                                                                                                                                    -                    validated_value = self._call_and_store(
                                                                                                                                    -                        getter_func=validator,
                                                                                                                                    -                        data=value,
                                                                                                                                    -                        field_name=data_key,
                                                                                                                                    -                        error_store=error_store,
                                                                                                                                    -                    )
                                                                                                                                    -                    if validated_value is missing:
                                                                                                                                    -                        data.pop(field_name, None)
                                                                                                                                    -
                                                                                                                                    -    def _invoke_schema_validators(
                                                                                                                                    -        self,
                                                                                                                                    -        *,
                                                                                                                                    -        error_store: ErrorStore,
                                                                                                                                    -        pass_many: bool,
                                                                                                                                    -        data,
                                                                                                                                    -        original_data,
                                                                                                                                    -        many: bool,
                                                                                                                                    -        partial: typing.Union[bool, types.StrSequenceOrSet],
                                                                                                                                    -        field_errors: bool = False
                                                                                                                                    -    ):
                                                                                                                                    -        for attr_name in self._hooks[(VALIDATES_SCHEMA, pass_many)]:
                                                                                                                                    -            validator = getattr(self, attr_name)
                                                                                                                                    -            validator_kwargs = validator.__marshmallow_hook__[
                                                                                                                                    -                (VALIDATES_SCHEMA, pass_many)
                                                                                                                                    -            ]
                                                                                                                                    -            if field_errors and validator_kwargs["skip_on_field_errors"]:
                                                                                                                                    -                continue
                                                                                                                                    -            pass_original = validator_kwargs.get("pass_original", False)
                                                                                                                                    -
                                                                                                                                    -            if many and not pass_many:
                                                                                                                                    -                for idx, (item, orig) in enumerate(zip(data, original_data)):
                                                                                                                                    -                    self._run_validator(
                                                                                                                                    -                        validator,
                                                                                                                                    -                        item,
                                                                                                                                    -                        original_data=orig,
                                                                                                                                    -                        error_store=error_store,
                                                                                                                                    -                        many=many,
                                                                                                                                    -                        partial=partial,
                                                                                                                                    -                        index=idx,
                                                                                                                                    -                        pass_original=pass_original,
                                                                                                                                    -                    )
                                                                                                                                    -            else:
                                                                                                                                    -                self._run_validator(
                                                                                                                                    -                    validator,
                                                                                                                                    -                    data,
                                                                                                                                    -                    original_data=original_data,
                                                                                                                                    -                    error_store=error_store,
                                                                                                                                    -                    many=many,
                                                                                                                                    -                    pass_original=pass_original,
                                                                                                                                    -                    partial=partial,
                                                                                                                                    -                )
                                                                                                                                    -
                                                                                                                                    -    def _invoke_processors(
                                                                                                                                    -        self,
                                                                                                                                    -        tag: str,
                                                                                                                                    -        *,
                                                                                                                                    -        pass_many: bool,
                                                                                                                                    -        data,
                                                                                                                                    -        many: bool,
                                                                                                                                    -        original_data=None,
                                                                                                                                    -        **kwargs
                                                                                                                                    -    ):
                                                                                                                                    -        key = (tag, pass_many)
                                                                                                                                    -        for attr_name in self._hooks[key]:
                                                                                                                                    -            # This will be a bound method.
                                                                                                                                    -            processor = getattr(self, attr_name)
                                                                                                                                    -
                                                                                                                                    -            processor_kwargs = processor.__marshmallow_hook__[key]
                                                                                                                                    -            pass_original = processor_kwargs.get("pass_original", False)
                                                                                                                                    -
                                                                                                                                    -            if many and not pass_many:
                                                                                                                                    -                if pass_original:
                                                                                                                                    -                    data = [
                                                                                                                                    -                        processor(item, original, many=many, **kwargs)
                                                                                                                                    -                        for item, original in zip(data, original_data)
                                                                                                                                    -                    ]
                                                                                                                                    -                else:
                                                                                                                                    -                    data = [processor(item, many=many, **kwargs) for item in data]
                                                                                                                                    -            else:
                                                                                                                                    -                if pass_original:
                                                                                                                                    -                    data = processor(data, original_data, many=many, **kwargs)
                                                                                                                                    -                else:
                                                                                                                                    -                    data = processor(data, many=many, **kwargs)
                                                                                                                                    -        return data
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -BaseSchema = Schema  # for backwards compatibility
                                                                                                                                    -
                                                                                                                                    - -
                                                                                                                                    - -
                                                                                                                                    -
                                                                                                                                    - -
                                                                                                                                    - -
                                                                                                                                    -

                                                                                                                                    - © Copyright 2021 - present / Neuralmagic, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"). - -

                                                                                                                                    -
                                                                                                                                    - - - - Built with Sphinx using a - - theme - - provided by Read the Docs. - -
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    - -
                                                                                                                                    - -
                                                                                                                                    - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sparsify/_modules/peewee.html b/sparsify/_modules/peewee.html deleted file mode 100644 index 9b2b7eb8b65..00000000000 --- a/sparsify/_modules/peewee.html +++ /dev/null @@ -1,7954 +0,0 @@ - - - - - - - - - - peewee — Sparsify 0.1.0 documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                                                                                                                                    - - - -
                                                                                                                                    - - - - - -
                                                                                                                                    - -
                                                                                                                                    - - - - - - - - - - - - - - - - - - - -
                                                                                                                                    - - - - -
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    - -

                                                                                                                                    Source code for peewee

                                                                                                                                    -from bisect import bisect_left
                                                                                                                                    -from bisect import bisect_right
                                                                                                                                    -from contextlib import contextmanager
                                                                                                                                    -from copy import deepcopy
                                                                                                                                    -from functools import wraps
                                                                                                                                    -from inspect import isclass
                                                                                                                                    -import calendar
                                                                                                                                    -import collections
                                                                                                                                    -import datetime
                                                                                                                                    -import decimal
                                                                                                                                    -import hashlib
                                                                                                                                    -import itertools
                                                                                                                                    -import logging
                                                                                                                                    -import operator
                                                                                                                                    -import re
                                                                                                                                    -import socket
                                                                                                                                    -import struct
                                                                                                                                    -import sys
                                                                                                                                    -import threading
                                                                                                                                    -import time
                                                                                                                                    -import uuid
                                                                                                                                    -import warnings
                                                                                                                                    -try:
                                                                                                                                    -    from collections.abc import Mapping
                                                                                                                                    -except ImportError:
                                                                                                                                    -    from collections import Mapping
                                                                                                                                    -
                                                                                                                                    -try:
                                                                                                                                    -    from pysqlite3 import dbapi2 as pysq3
                                                                                                                                    -except ImportError:
                                                                                                                                    -    try:
                                                                                                                                    -        from pysqlite2 import dbapi2 as pysq3
                                                                                                                                    -    except ImportError:
                                                                                                                                    -        pysq3 = None
                                                                                                                                    -try:
                                                                                                                                    -    import sqlite3
                                                                                                                                    -except ImportError:
                                                                                                                                    -    sqlite3 = pysq3
                                                                                                                                    -else:
                                                                                                                                    -    if pysq3 and pysq3.sqlite_version_info >= sqlite3.sqlite_version_info:
                                                                                                                                    -        sqlite3 = pysq3
                                                                                                                                    -try:
                                                                                                                                    -    from psycopg2cffi import compat
                                                                                                                                    -    compat.register()
                                                                                                                                    -except ImportError:
                                                                                                                                    -    pass
                                                                                                                                    -try:
                                                                                                                                    -    import psycopg2
                                                                                                                                    -    from psycopg2 import extensions as pg_extensions
                                                                                                                                    -    try:
                                                                                                                                    -        from psycopg2 import errors as pg_errors
                                                                                                                                    -    except ImportError:
                                                                                                                                    -        pg_errors = None
                                                                                                                                    -except ImportError:
                                                                                                                                    -    psycopg2 = pg_errors = None
                                                                                                                                    -
                                                                                                                                    -mysql_passwd = False
                                                                                                                                    -try:
                                                                                                                                    -    import pymysql as mysql
                                                                                                                                    -except ImportError:
                                                                                                                                    -    try:
                                                                                                                                    -        import MySQLdb as mysql
                                                                                                                                    -        mysql_passwd = True
                                                                                                                                    -    except ImportError:
                                                                                                                                    -        mysql = None
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -__version__ = '3.14.0'
                                                                                                                                    -__all__ = [
                                                                                                                                    -    'AsIs',
                                                                                                                                    -    'AutoField',
                                                                                                                                    -    'BareField',
                                                                                                                                    -    'BigAutoField',
                                                                                                                                    -    'BigBitField',
                                                                                                                                    -    'BigIntegerField',
                                                                                                                                    -    'BinaryUUIDField',
                                                                                                                                    -    'BitField',
                                                                                                                                    -    'BlobField',
                                                                                                                                    -    'BooleanField',
                                                                                                                                    -    'Case',
                                                                                                                                    -    'Cast',
                                                                                                                                    -    'CharField',
                                                                                                                                    -    'Check',
                                                                                                                                    -    'chunked',
                                                                                                                                    -    'Column',
                                                                                                                                    -    'CompositeKey',
                                                                                                                                    -    'Context',
                                                                                                                                    -    'Database',
                                                                                                                                    -    'DatabaseError',
                                                                                                                                    -    'DatabaseProxy',
                                                                                                                                    -    'DataError',
                                                                                                                                    -    'DateField',
                                                                                                                                    -    'DateTimeField',
                                                                                                                                    -    'DecimalField',
                                                                                                                                    -    'DeferredForeignKey',
                                                                                                                                    -    'DeferredThroughModel',
                                                                                                                                    -    'DJANGO_MAP',
                                                                                                                                    -    'DoesNotExist',
                                                                                                                                    -    'DoubleField',
                                                                                                                                    -    'DQ',
                                                                                                                                    -    'EXCLUDED',
                                                                                                                                    -    'Field',
                                                                                                                                    -    'FixedCharField',
                                                                                                                                    -    'FloatField',
                                                                                                                                    -    'fn',
                                                                                                                                    -    'ForeignKeyField',
                                                                                                                                    -    'IdentityField',
                                                                                                                                    -    'ImproperlyConfigured',
                                                                                                                                    -    'Index',
                                                                                                                                    -    'IntegerField',
                                                                                                                                    -    'IntegrityError',
                                                                                                                                    -    'InterfaceError',
                                                                                                                                    -    'InternalError',
                                                                                                                                    -    'IPField',
                                                                                                                                    -    'JOIN',
                                                                                                                                    -    'ManyToManyField',
                                                                                                                                    -    'Model',
                                                                                                                                    -    'ModelIndex',
                                                                                                                                    -    'MySQLDatabase',
                                                                                                                                    -    'NotSupportedError',
                                                                                                                                    -    'OP',
                                                                                                                                    -    'OperationalError',
                                                                                                                                    -    'PostgresqlDatabase',
                                                                                                                                    -    'PrimaryKeyField',  # XXX: Deprecated, change to AutoField.
                                                                                                                                    -    'prefetch',
                                                                                                                                    -    'ProgrammingError',
                                                                                                                                    -    'Proxy',
                                                                                                                                    -    'QualifiedNames',
                                                                                                                                    -    'SchemaManager',
                                                                                                                                    -    'SmallIntegerField',
                                                                                                                                    -    'Select',
                                                                                                                                    -    'SQL',
                                                                                                                                    -    'SqliteDatabase',
                                                                                                                                    -    'Table',
                                                                                                                                    -    'TextField',
                                                                                                                                    -    'TimeField',
                                                                                                                                    -    'TimestampField',
                                                                                                                                    -    'Tuple',
                                                                                                                                    -    'UUIDField',
                                                                                                                                    -    'Value',
                                                                                                                                    -    'ValuesList',
                                                                                                                                    -    'Window',
                                                                                                                                    -]
                                                                                                                                    -
                                                                                                                                    -try:  # Python 2.7+
                                                                                                                                    -    from logging import NullHandler
                                                                                                                                    -except ImportError:
                                                                                                                                    -    class NullHandler(logging.Handler):
                                                                                                                                    -        def emit(self, record):
                                                                                                                                    -            pass
                                                                                                                                    -
                                                                                                                                    -logger = logging.getLogger('peewee')
                                                                                                                                    -logger.addHandler(NullHandler())
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -if sys.version_info[0] == 2:
                                                                                                                                    -    text_type = unicode
                                                                                                                                    -    bytes_type = str
                                                                                                                                    -    buffer_type = buffer
                                                                                                                                    -    izip_longest = itertools.izip_longest
                                                                                                                                    -    callable_ = callable
                                                                                                                                    -    multi_types = (list, tuple, frozenset, set)
                                                                                                                                    -    exec('def reraise(tp, value, tb=None): raise tp, value, tb')
                                                                                                                                    -    def print_(s):
                                                                                                                                    -        sys.stdout.write(s)
                                                                                                                                    -        sys.stdout.write('\n')
                                                                                                                                    -else:
                                                                                                                                    -    import builtins
                                                                                                                                    -    try:
                                                                                                                                    -        from collections.abc import Callable
                                                                                                                                    -    except ImportError:
                                                                                                                                    -        from collections import Callable
                                                                                                                                    -    from functools import reduce
                                                                                                                                    -    callable_ = lambda c: isinstance(c, Callable)
                                                                                                                                    -    text_type = str
                                                                                                                                    -    bytes_type = bytes
                                                                                                                                    -    buffer_type = memoryview
                                                                                                                                    -    basestring = str
                                                                                                                                    -    long = int
                                                                                                                                    -    multi_types = (list, tuple, frozenset, set, range)
                                                                                                                                    -    print_ = getattr(builtins, 'print')
                                                                                                                                    -    izip_longest = itertools.zip_longest
                                                                                                                                    -    def reraise(tp, value, tb=None):
                                                                                                                                    -        if value.__traceback__ is not tb:
                                                                                                                                    -            raise value.with_traceback(tb)
                                                                                                                                    -        raise value
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -if sqlite3:
                                                                                                                                    -    sqlite3.register_adapter(decimal.Decimal, str)
                                                                                                                                    -    sqlite3.register_adapter(datetime.date, str)
                                                                                                                                    -    sqlite3.register_adapter(datetime.time, str)
                                                                                                                                    -    __sqlite_version__ = sqlite3.sqlite_version_info
                                                                                                                                    -else:
                                                                                                                                    -    __sqlite_version__ = (0, 0, 0)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -__date_parts__ = set(('year', 'month', 'day', 'hour', 'minute', 'second'))
                                                                                                                                    -
                                                                                                                                    -# Sqlite does not support the `date_part` SQL function, so we will define an
                                                                                                                                    -# implementation in python.
                                                                                                                                    -__sqlite_datetime_formats__ = (
                                                                                                                                    -    '%Y-%m-%d %H:%M:%S',
                                                                                                                                    -    '%Y-%m-%d %H:%M:%S.%f',
                                                                                                                                    -    '%Y-%m-%d',
                                                                                                                                    -    '%H:%M:%S',
                                                                                                                                    -    '%H:%M:%S.%f',
                                                                                                                                    -    '%H:%M')
                                                                                                                                    -
                                                                                                                                    -__sqlite_date_trunc__ = {
                                                                                                                                    -    'year': '%Y-01-01 00:00:00',
                                                                                                                                    -    'month': '%Y-%m-01 00:00:00',
                                                                                                                                    -    'day': '%Y-%m-%d 00:00:00',
                                                                                                                                    -    'hour': '%Y-%m-%d %H:00:00',
                                                                                                                                    -    'minute': '%Y-%m-%d %H:%M:00',
                                                                                                                                    -    'second': '%Y-%m-%d %H:%M:%S'}
                                                                                                                                    -
                                                                                                                                    -__mysql_date_trunc__ = __sqlite_date_trunc__.copy()
                                                                                                                                    -__mysql_date_trunc__['minute'] = '%Y-%m-%d %H:%i:00'
                                                                                                                                    -__mysql_date_trunc__['second'] = '%Y-%m-%d %H:%i:%S'
                                                                                                                                    -
                                                                                                                                    -def _sqlite_date_part(lookup_type, datetime_string):
                                                                                                                                    -    assert lookup_type in __date_parts__
                                                                                                                                    -    if not datetime_string:
                                                                                                                                    -        return
                                                                                                                                    -    dt = format_date_time(datetime_string, __sqlite_datetime_formats__)
                                                                                                                                    -    return getattr(dt, lookup_type)
                                                                                                                                    -
                                                                                                                                    -def _sqlite_date_trunc(lookup_type, datetime_string):
                                                                                                                                    -    assert lookup_type in __sqlite_date_trunc__
                                                                                                                                    -    if not datetime_string:
                                                                                                                                    -        return
                                                                                                                                    -    dt = format_date_time(datetime_string, __sqlite_datetime_formats__)
                                                                                                                                    -    return dt.strftime(__sqlite_date_trunc__[lookup_type])
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -def __deprecated__(s):
                                                                                                                                    -    warnings.warn(s, DeprecationWarning)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class attrdict(dict):
                                                                                                                                    -    def __getattr__(self, attr):
                                                                                                                                    -        try:
                                                                                                                                    -            return self[attr]
                                                                                                                                    -        except KeyError:
                                                                                                                                    -            raise AttributeError(attr)
                                                                                                                                    -    def __setattr__(self, attr, value): self[attr] = value
                                                                                                                                    -    def __iadd__(self, rhs): self.update(rhs); return self
                                                                                                                                    -    def __add__(self, rhs): d = attrdict(self); d.update(rhs); return d
                                                                                                                                    -
                                                                                                                                    -SENTINEL = object()
                                                                                                                                    -
                                                                                                                                    -#: Operations for use in SQL expressions.
                                                                                                                                    -OP = attrdict(
                                                                                                                                    -    AND='AND',
                                                                                                                                    -    OR='OR',
                                                                                                                                    -    ADD='+',
                                                                                                                                    -    SUB='-',
                                                                                                                                    -    MUL='*',
                                                                                                                                    -    DIV='/',
                                                                                                                                    -    BIN_AND='&',
                                                                                                                                    -    BIN_OR='|',
                                                                                                                                    -    XOR='#',
                                                                                                                                    -    MOD='%',
                                                                                                                                    -    EQ='=',
                                                                                                                                    -    LT='<',
                                                                                                                                    -    LTE='<=',
                                                                                                                                    -    GT='>',
                                                                                                                                    -    GTE='>=',
                                                                                                                                    -    NE='!=',
                                                                                                                                    -    IN='IN',
                                                                                                                                    -    NOT_IN='NOT IN',
                                                                                                                                    -    IS='IS',
                                                                                                                                    -    IS_NOT='IS NOT',
                                                                                                                                    -    LIKE='LIKE',
                                                                                                                                    -    ILIKE='ILIKE',
                                                                                                                                    -    BETWEEN='BETWEEN',
                                                                                                                                    -    REGEXP='REGEXP',
                                                                                                                                    -    IREGEXP='IREGEXP',
                                                                                                                                    -    CONCAT='||',
                                                                                                                                    -    BITWISE_NEGATION='~')
                                                                                                                                    -
                                                                                                                                    -# To support "django-style" double-underscore filters, create a mapping between
                                                                                                                                    -# operation name and operation code, e.g. "__eq" == OP.EQ.
                                                                                                                                    -DJANGO_MAP = attrdict({
                                                                                                                                    -    'eq': operator.eq,
                                                                                                                                    -    'lt': operator.lt,
                                                                                                                                    -    'lte': operator.le,
                                                                                                                                    -    'gt': operator.gt,
                                                                                                                                    -    'gte': operator.ge,
                                                                                                                                    -    'ne': operator.ne,
                                                                                                                                    -    'in': operator.lshift,
                                                                                                                                    -    'is': lambda l, r: Expression(l, OP.IS, r),
                                                                                                                                    -    'like': lambda l, r: Expression(l, OP.LIKE, r),
                                                                                                                                    -    'ilike': lambda l, r: Expression(l, OP.ILIKE, r),
                                                                                                                                    -    'regexp': lambda l, r: Expression(l, OP.REGEXP, r),
                                                                                                                                    -})
                                                                                                                                    -
                                                                                                                                    -#: Mapping of field type to the data-type supported by the database. Databases
                                                                                                                                    -#: may override or add to this list.
                                                                                                                                    -FIELD = attrdict(
                                                                                                                                    -    AUTO='INTEGER',
                                                                                                                                    -    BIGAUTO='BIGINT',
                                                                                                                                    -    BIGINT='BIGINT',
                                                                                                                                    -    BLOB='BLOB',
                                                                                                                                    -    BOOL='SMALLINT',
                                                                                                                                    -    CHAR='CHAR',
                                                                                                                                    -    DATE='DATE',
                                                                                                                                    -    DATETIME='DATETIME',
                                                                                                                                    -    DECIMAL='DECIMAL',
                                                                                                                                    -    DEFAULT='',
                                                                                                                                    -    DOUBLE='REAL',
                                                                                                                                    -    FLOAT='REAL',
                                                                                                                                    -    INT='INTEGER',
                                                                                                                                    -    SMALLINT='SMALLINT',
                                                                                                                                    -    TEXT='TEXT',
                                                                                                                                    -    TIME='TIME',
                                                                                                                                    -    UUID='TEXT',
                                                                                                                                    -    UUIDB='BLOB',
                                                                                                                                    -    VARCHAR='VARCHAR')
                                                                                                                                    -
                                                                                                                                    -#: Join helpers (for convenience) -- all join types are supported, this object
                                                                                                                                    -#: is just to help avoid introducing errors by using strings everywhere.
                                                                                                                                    -JOIN = attrdict(
                                                                                                                                    -    INNER='INNER JOIN',
                                                                                                                                    -    LEFT_OUTER='LEFT OUTER JOIN',
                                                                                                                                    -    RIGHT_OUTER='RIGHT OUTER JOIN',
                                                                                                                                    -    FULL='FULL JOIN',
                                                                                                                                    -    FULL_OUTER='FULL OUTER JOIN',
                                                                                                                                    -    CROSS='CROSS JOIN',
                                                                                                                                    -    NATURAL='NATURAL JOIN',
                                                                                                                                    -    LATERAL='LATERAL',
                                                                                                                                    -    LEFT_LATERAL='LEFT JOIN LATERAL')
                                                                                                                                    -
                                                                                                                                    -# Row representations.
                                                                                                                                    -ROW = attrdict(
                                                                                                                                    -    TUPLE=1,
                                                                                                                                    -    DICT=2,
                                                                                                                                    -    NAMED_TUPLE=3,
                                                                                                                                    -    CONSTRUCTOR=4,
                                                                                                                                    -    MODEL=5)
                                                                                                                                    -
                                                                                                                                    -SCOPE_NORMAL = 1
                                                                                                                                    -SCOPE_SOURCE = 2
                                                                                                                                    -SCOPE_VALUES = 4
                                                                                                                                    -SCOPE_CTE = 8
                                                                                                                                    -SCOPE_COLUMN = 16
                                                                                                                                    -
                                                                                                                                    -# Rules for parentheses around subqueries in compound select.
                                                                                                                                    -CSQ_PARENTHESES_NEVER = 0
                                                                                                                                    -CSQ_PARENTHESES_ALWAYS = 1
                                                                                                                                    -CSQ_PARENTHESES_UNNESTED = 2
                                                                                                                                    -
                                                                                                                                    -# Regular expressions used to convert class names to snake-case table names.
                                                                                                                                    -# First regex handles acronym followed by word or initial lower-word followed
                                                                                                                                    -# by a capitalized word. e.g. APIResponse -> API_Response / fooBar -> foo_Bar.
                                                                                                                                    -# Second regex handles the normal case of two title-cased words.
                                                                                                                                    -SNAKE_CASE_STEP1 = re.compile('(.)_*([A-Z][a-z]+)')
                                                                                                                                    -SNAKE_CASE_STEP2 = re.compile('([a-z0-9])_*([A-Z])')
                                                                                                                                    -
                                                                                                                                    -# Helper functions that are used in various parts of the codebase.
                                                                                                                                    -MODEL_BASE = '_metaclass_helper_'
                                                                                                                                    -
                                                                                                                                    -def with_metaclass(meta, base=object):
                                                                                                                                    -    return meta(MODEL_BASE, (base,), {})
                                                                                                                                    -
                                                                                                                                    -def merge_dict(source, overrides):
                                                                                                                                    -    merged = source.copy()
                                                                                                                                    -    if overrides:
                                                                                                                                    -        merged.update(overrides)
                                                                                                                                    -    return merged
                                                                                                                                    -
                                                                                                                                    -def quote(path, quote_chars):
                                                                                                                                    -    if len(path) == 1:
                                                                                                                                    -        return path[0].join(quote_chars)
                                                                                                                                    -    return '.'.join([part.join(quote_chars) for part in path])
                                                                                                                                    -
                                                                                                                                    -is_model = lambda o: isclass(o) and issubclass(o, Model)
                                                                                                                                    -
                                                                                                                                    -def ensure_tuple(value):
                                                                                                                                    -    if value is not None:
                                                                                                                                    -        return value if isinstance(value, (list, tuple)) else (value,)
                                                                                                                                    -
                                                                                                                                    -def ensure_entity(value):
                                                                                                                                    -    if value is not None:
                                                                                                                                    -        return value if isinstance(value, Node) else Entity(value)
                                                                                                                                    -
                                                                                                                                    -def make_snake_case(s):
                                                                                                                                    -    first = SNAKE_CASE_STEP1.sub(r'\1_\2', s)
                                                                                                                                    -    return SNAKE_CASE_STEP2.sub(r'\1_\2', first).lower()
                                                                                                                                    -
                                                                                                                                    -def chunked(it, n):
                                                                                                                                    -    marker = object()
                                                                                                                                    -    for group in (list(g) for g in izip_longest(*[iter(it)] * n,
                                                                                                                                    -                                                fillvalue=marker)):
                                                                                                                                    -        if group[-1] is marker:
                                                                                                                                    -            del group[group.index(marker):]
                                                                                                                                    -        yield group
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class _callable_context_manager(object):
                                                                                                                                    -    def __call__(self, fn):
                                                                                                                                    -        @wraps(fn)
                                                                                                                                    -        def inner(*args, **kwargs):
                                                                                                                                    -            with self:
                                                                                                                                    -                return fn(*args, **kwargs)
                                                                                                                                    -        return inner
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class Proxy(object):
                                                                                                                                    -    """
                                                                                                                                    -    Create a proxy or placeholder for another object.
                                                                                                                                    -    """
                                                                                                                                    -    __slots__ = ('obj', '_callbacks')
                                                                                                                                    -
                                                                                                                                    -    def __init__(self):
                                                                                                                                    -        self._callbacks = []
                                                                                                                                    -        self.initialize(None)
                                                                                                                                    -
                                                                                                                                    -    def initialize(self, obj):
                                                                                                                                    -        self.obj = obj
                                                                                                                                    -        for callback in self._callbacks:
                                                                                                                                    -            callback(obj)
                                                                                                                                    -
                                                                                                                                    -    def attach_callback(self, callback):
                                                                                                                                    -        self._callbacks.append(callback)
                                                                                                                                    -        return callback
                                                                                                                                    -
                                                                                                                                    -    def passthrough(method):
                                                                                                                                    -        def inner(self, *args, **kwargs):
                                                                                                                                    -            if self.obj is None:
                                                                                                                                    -                raise AttributeError('Cannot use uninitialized Proxy.')
                                                                                                                                    -            return getattr(self.obj, method)(*args, **kwargs)
                                                                                                                                    -        return inner
                                                                                                                                    -
                                                                                                                                    -    # Allow proxy to be used as a context-manager.
                                                                                                                                    -    __enter__ = passthrough('__enter__')
                                                                                                                                    -    __exit__ = passthrough('__exit__')
                                                                                                                                    -
                                                                                                                                    -    def __getattr__(self, attr):
                                                                                                                                    -        if self.obj is None:
                                                                                                                                    -            raise AttributeError('Cannot use uninitialized Proxy.')
                                                                                                                                    -        return getattr(self.obj, attr)
                                                                                                                                    -
                                                                                                                                    -    def __setattr__(self, attr, value):
                                                                                                                                    -        if attr not in self.__slots__:
                                                                                                                                    -            raise AttributeError('Cannot set attribute on proxy.')
                                                                                                                                    -        return super(Proxy, self).__setattr__(attr, value)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class DatabaseProxy(Proxy):
                                                                                                                                    -    """
                                                                                                                                    -    Proxy implementation specifically for proxying `Database` objects.
                                                                                                                                    -    """
                                                                                                                                    -    def connection_context(self):
                                                                                                                                    -        return ConnectionContext(self)
                                                                                                                                    -    def atomic(self, *args, **kwargs):
                                                                                                                                    -        return _atomic(self, *args, **kwargs)
                                                                                                                                    -    def manual_commit(self):
                                                                                                                                    -        return _manual(self)
                                                                                                                                    -    def transaction(self, *args, **kwargs):
                                                                                                                                    -        return _transaction(self, *args, **kwargs)
                                                                                                                                    -    def savepoint(self):
                                                                                                                                    -        return _savepoint(self)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class ModelDescriptor(object): pass
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -# SQL Generation.
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class AliasManager(object):
                                                                                                                                    -    __slots__ = ('_counter', '_current_index', '_mapping')
                                                                                                                                    -
                                                                                                                                    -    def __init__(self):
                                                                                                                                    -        # A list of dictionaries containing mappings at various depths.
                                                                                                                                    -        self._counter = 0
                                                                                                                                    -        self._current_index = 0
                                                                                                                                    -        self._mapping = []
                                                                                                                                    -        self.push()
                                                                                                                                    -
                                                                                                                                    -    @property
                                                                                                                                    -    def mapping(self):
                                                                                                                                    -        return self._mapping[self._current_index - 1]
                                                                                                                                    -
                                                                                                                                    -    def add(self, source):
                                                                                                                                    -        if source not in self.mapping:
                                                                                                                                    -            self._counter += 1
                                                                                                                                    -            self[source] = 't%d' % self._counter
                                                                                                                                    -        return self.mapping[source]
                                                                                                                                    -
                                                                                                                                    -    def get(self, source, any_depth=False):
                                                                                                                                    -        if any_depth:
                                                                                                                                    -            for idx in reversed(range(self._current_index)):
                                                                                                                                    -                if source in self._mapping[idx]:
                                                                                                                                    -                    return self._mapping[idx][source]
                                                                                                                                    -        return self.add(source)
                                                                                                                                    -
                                                                                                                                    -    def __getitem__(self, source):
                                                                                                                                    -        return self.get(source)
                                                                                                                                    -
                                                                                                                                    -    def __setitem__(self, source, alias):
                                                                                                                                    -        self.mapping[source] = alias
                                                                                                                                    -
                                                                                                                                    -    def push(self):
                                                                                                                                    -        self._current_index += 1
                                                                                                                                    -        if self._current_index > len(self._mapping):
                                                                                                                                    -            self._mapping.append({})
                                                                                                                                    -
                                                                                                                                    -    def pop(self):
                                                                                                                                    -        if self._current_index == 1:
                                                                                                                                    -            raise ValueError('Cannot pop() from empty alias manager.')
                                                                                                                                    -        self._current_index -= 1
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class State(collections.namedtuple('_State', ('scope', 'parentheses',
                                                                                                                                    -                                              'settings'))):
                                                                                                                                    -    def __new__(cls, scope=SCOPE_NORMAL, parentheses=False, **kwargs):
                                                                                                                                    -        return super(State, cls).__new__(cls, scope, parentheses, kwargs)
                                                                                                                                    -
                                                                                                                                    -    def __call__(self, scope=None, parentheses=None, **kwargs):
                                                                                                                                    -        # Scope and settings are "inherited" (parentheses is not, however).
                                                                                                                                    -        scope = self.scope if scope is None else scope
                                                                                                                                    -
                                                                                                                                    -        # Try to avoid unnecessary dict copying.
                                                                                                                                    -        if kwargs and self.settings:
                                                                                                                                    -            settings = self.settings.copy()  # Copy original settings dict.
                                                                                                                                    -            settings.update(kwargs)  # Update copy with overrides.
                                                                                                                                    -        elif kwargs:
                                                                                                                                    -            settings = kwargs
                                                                                                                                    -        else:
                                                                                                                                    -            settings = self.settings
                                                                                                                                    -        return State(scope, parentheses, **settings)
                                                                                                                                    -
                                                                                                                                    -    def __getattr__(self, attr_name):
                                                                                                                                    -        return self.settings.get(attr_name)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -def __scope_context__(scope):
                                                                                                                                    -    @contextmanager
                                                                                                                                    -    def inner(self, **kwargs):
                                                                                                                                    -        with self(scope=scope, **kwargs):
                                                                                                                                    -            yield self
                                                                                                                                    -    return inner
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class Context(object):
                                                                                                                                    -    __slots__ = ('stack', '_sql', '_values', 'alias_manager', 'state')
                                                                                                                                    -
                                                                                                                                    -    def __init__(self, **settings):
                                                                                                                                    -        self.stack = []
                                                                                                                                    -        self._sql = []
                                                                                                                                    -        self._values = []
                                                                                                                                    -        self.alias_manager = AliasManager()
                                                                                                                                    -        self.state = State(**settings)
                                                                                                                                    -
                                                                                                                                    -    def as_new(self):
                                                                                                                                    -        return Context(**self.state.settings)
                                                                                                                                    -
                                                                                                                                    -    def column_sort_key(self, item):
                                                                                                                                    -        return item[0].get_sort_key(self)
                                                                                                                                    -
                                                                                                                                    -    @property
                                                                                                                                    -    def scope(self):
                                                                                                                                    -        return self.state.scope
                                                                                                                                    -
                                                                                                                                    -    @property
                                                                                                                                    -    def parentheses(self):
                                                                                                                                    -        return self.state.parentheses
                                                                                                                                    -
                                                                                                                                    -    @property
                                                                                                                                    -    def subquery(self):
                                                                                                                                    -        return self.state.subquery
                                                                                                                                    -
                                                                                                                                    -    def __call__(self, **overrides):
                                                                                                                                    -        if overrides and overrides.get('scope') == self.scope:
                                                                                                                                    -            del overrides['scope']
                                                                                                                                    -
                                                                                                                                    -        self.stack.append(self.state)
                                                                                                                                    -        self.state = self.state(**overrides)
                                                                                                                                    -        return self
                                                                                                                                    -
                                                                                                                                    -    scope_normal = __scope_context__(SCOPE_NORMAL)
                                                                                                                                    -    scope_source = __scope_context__(SCOPE_SOURCE)
                                                                                                                                    -    scope_values = __scope_context__(SCOPE_VALUES)
                                                                                                                                    -    scope_cte = __scope_context__(SCOPE_CTE)
                                                                                                                                    -    scope_column = __scope_context__(SCOPE_COLUMN)
                                                                                                                                    -
                                                                                                                                    -    def __enter__(self):
                                                                                                                                    -        if self.parentheses:
                                                                                                                                    -            self.literal('(')
                                                                                                                                    -        return self
                                                                                                                                    -
                                                                                                                                    -    def __exit__(self, exc_type, exc_val, exc_tb):
                                                                                                                                    -        if self.parentheses:
                                                                                                                                    -            self.literal(')')
                                                                                                                                    -        self.state = self.stack.pop()
                                                                                                                                    -
                                                                                                                                    -    @contextmanager
                                                                                                                                    -    def push_alias(self):
                                                                                                                                    -        self.alias_manager.push()
                                                                                                                                    -        yield
                                                                                                                                    -        self.alias_manager.pop()
                                                                                                                                    -
                                                                                                                                    -    def sql(self, obj):
                                                                                                                                    -        if isinstance(obj, (Node, Context)):
                                                                                                                                    -            return obj.__sql__(self)
                                                                                                                                    -        elif is_model(obj):
                                                                                                                                    -            return obj._meta.table.__sql__(self)
                                                                                                                                    -        else:
                                                                                                                                    -            return self.sql(Value(obj))
                                                                                                                                    -
                                                                                                                                    -    def literal(self, keyword):
                                                                                                                                    -        self._sql.append(keyword)
                                                                                                                                    -        return self
                                                                                                                                    -
                                                                                                                                    -    def value(self, value, converter=None, add_param=True):
                                                                                                                                    -        if converter:
                                                                                                                                    -            value = converter(value)
                                                                                                                                    -        elif converter is None and self.state.converter:
                                                                                                                                    -            # Explicitly check for None so that "False" can be used to signify
                                                                                                                                    -            # that no conversion should be applied.
                                                                                                                                    -            value = self.state.converter(value)
                                                                                                                                    -
                                                                                                                                    -        if isinstance(value, Node):
                                                                                                                                    -            with self(converter=None):
                                                                                                                                    -                return self.sql(value)
                                                                                                                                    -        elif is_model(value):
                                                                                                                                    -            # Under certain circumstances, we could end-up treating a model-
                                                                                                                                    -            # class itself as a value. This check ensures that we drop the
                                                                                                                                    -            # table alias into the query instead of trying to parameterize a
                                                                                                                                    -            # model (for instance, passing a model as a function argument).
                                                                                                                                    -            with self.scope_column():
                                                                                                                                    -                return self.sql(value)
                                                                                                                                    -
                                                                                                                                    -        self._values.append(value)
                                                                                                                                    -        return self.literal(self.state.param or '?') if add_param else self
                                                                                                                                    -
                                                                                                                                    -    def __sql__(self, ctx):
                                                                                                                                    -        ctx._sql.extend(self._sql)
                                                                                                                                    -        ctx._values.extend(self._values)
                                                                                                                                    -        return ctx
                                                                                                                                    -
                                                                                                                                    -    def parse(self, node):
                                                                                                                                    -        return self.sql(node).query()
                                                                                                                                    -
                                                                                                                                    -    def query(self):
                                                                                                                                    -        return ''.join(self._sql), self._values
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -def query_to_string(query):
                                                                                                                                    -    # NOTE: this function is not exported by default as it might be misused --
                                                                                                                                    -    # and this misuse could lead to sql injection vulnerabilities. This
                                                                                                                                    -    # function is intended for debugging or logging purposes ONLY.
                                                                                                                                    -    db = getattr(query, '_database', None)
                                                                                                                                    -    if db is not None:
                                                                                                                                    -        ctx = db.get_sql_context()
                                                                                                                                    -    else:
                                                                                                                                    -        ctx = Context()
                                                                                                                                    -
                                                                                                                                    -    sql, params = ctx.sql(query).query()
                                                                                                                                    -    if not params:
                                                                                                                                    -        return sql
                                                                                                                                    -
                                                                                                                                    -    param = ctx.state.param or '?'
                                                                                                                                    -    if param == '?':
                                                                                                                                    -        sql = sql.replace('?', '%s')
                                                                                                                                    -
                                                                                                                                    -    return sql % tuple(map(_query_val_transform, params))
                                                                                                                                    -
                                                                                                                                    -def _query_val_transform(v):
                                                                                                                                    -    # Interpolate parameters.
                                                                                                                                    -    if isinstance(v, (text_type, datetime.datetime, datetime.date,
                                                                                                                                    -                      datetime.time)):
                                                                                                                                    -        v = "'%s'" % v
                                                                                                                                    -    elif isinstance(v, bytes_type):
                                                                                                                                    -        try:
                                                                                                                                    -            v = v.decode('utf8')
                                                                                                                                    -        except UnicodeDecodeError:
                                                                                                                                    -            v = v.decode('raw_unicode_escape')
                                                                                                                                    -        v = "'%s'" % v
                                                                                                                                    -    elif isinstance(v, int):
                                                                                                                                    -        v = '%s' % int(v)  # Also handles booleans -> 1 or 0.
                                                                                                                                    -    elif v is None:
                                                                                                                                    -        v = 'NULL'
                                                                                                                                    -    else:
                                                                                                                                    -        v = str(v)
                                                                                                                                    -    return v
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -# AST.
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class Node(object):
                                                                                                                                    -    _coerce = True
                                                                                                                                    -
                                                                                                                                    -    def clone(self):
                                                                                                                                    -        obj = self.__class__.__new__(self.__class__)
                                                                                                                                    -        obj.__dict__ = self.__dict__.copy()
                                                                                                                                    -        return obj
                                                                                                                                    -
                                                                                                                                    -    def __sql__(self, ctx):
                                                                                                                                    -        raise NotImplementedError
                                                                                                                                    -
                                                                                                                                    -    @staticmethod
                                                                                                                                    -    def copy(method):
                                                                                                                                    -        def inner(self, *args, **kwargs):
                                                                                                                                    -            clone = self.clone()
                                                                                                                                    -            method(clone, *args, **kwargs)
                                                                                                                                    -            return clone
                                                                                                                                    -        return inner
                                                                                                                                    -
                                                                                                                                    -    def coerce(self, _coerce=True):
                                                                                                                                    -        if _coerce != self._coerce:
                                                                                                                                    -            clone = self.clone()
                                                                                                                                    -            clone._coerce = _coerce
                                                                                                                                    -            return clone
                                                                                                                                    -        return self
                                                                                                                                    -
                                                                                                                                    -    def is_alias(self):
                                                                                                                                    -        return False
                                                                                                                                    -
                                                                                                                                    -    def unwrap(self):
                                                                                                                                    -        return self
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class ColumnFactory(object):
                                                                                                                                    -    __slots__ = ('node',)
                                                                                                                                    -
                                                                                                                                    -    def __init__(self, node):
                                                                                                                                    -        self.node = node
                                                                                                                                    -
                                                                                                                                    -    def __getattr__(self, attr):
                                                                                                                                    -        return Column(self.node, attr)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class _DynamicColumn(object):
                                                                                                                                    -    __slots__ = ()
                                                                                                                                    -
                                                                                                                                    -    def __get__(self, instance, instance_type=None):
                                                                                                                                    -        if instance is not None:
                                                                                                                                    -            return ColumnFactory(instance)  # Implements __getattr__().
                                                                                                                                    -        return self
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class _ExplicitColumn(object):
                                                                                                                                    -    __slots__ = ()
                                                                                                                                    -
                                                                                                                                    -    def __get__(self, instance, instance_type=None):
                                                                                                                                    -        if instance is not None:
                                                                                                                                    -            raise AttributeError(
                                                                                                                                    -                '%s specifies columns explicitly, and does not support '
                                                                                                                                    -                'dynamic column lookups.' % instance)
                                                                                                                                    -        return self
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class Source(Node):
                                                                                                                                    -    c = _DynamicColumn()
                                                                                                                                    -
                                                                                                                                    -    def __init__(self, alias=None):
                                                                                                                                    -        super(Source, self).__init__()
                                                                                                                                    -        self._alias = alias
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def alias(self, name):
                                                                                                                                    -        self._alias = name
                                                                                                                                    -
                                                                                                                                    -    def select(self, *columns):
                                                                                                                                    -        if not columns:
                                                                                                                                    -            columns = (SQL('*'),)
                                                                                                                                    -        return Select((self,), columns)
                                                                                                                                    -
                                                                                                                                    -    def join(self, dest, join_type=JOIN.INNER, on=None):
                                                                                                                                    -        return Join(self, dest, join_type, on)
                                                                                                                                    -
                                                                                                                                    -    def left_outer_join(self, dest, on=None):
                                                                                                                                    -        return Join(self, dest, JOIN.LEFT_OUTER, on)
                                                                                                                                    -
                                                                                                                                    -    def cte(self, name, recursive=False, columns=None, materialized=None):
                                                                                                                                    -        return CTE(name, self, recursive=recursive, columns=columns,
                                                                                                                                    -                   materialized=materialized)
                                                                                                                                    -
                                                                                                                                    -    def get_sort_key(self, ctx):
                                                                                                                                    -        if self._alias:
                                                                                                                                    -            return (self._alias,)
                                                                                                                                    -        return (ctx.alias_manager[self],)
                                                                                                                                    -
                                                                                                                                    -    def apply_alias(self, ctx):
                                                                                                                                    -        # If we are defining the source, include the "AS alias" declaration. An
                                                                                                                                    -        # alias is created for the source if one is not already defined.
                                                                                                                                    -        if ctx.scope == SCOPE_SOURCE:
                                                                                                                                    -            if self._alias:
                                                                                                                                    -                ctx.alias_manager[self] = self._alias
                                                                                                                                    -            ctx.literal(' AS ').sql(Entity(ctx.alias_manager[self]))
                                                                                                                                    -        return ctx
                                                                                                                                    -
                                                                                                                                    -    def apply_column(self, ctx):
                                                                                                                                    -        if self._alias:
                                                                                                                                    -            ctx.alias_manager[self] = self._alias
                                                                                                                                    -        return ctx.sql(Entity(ctx.alias_manager[self]))
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class _HashableSource(object):
                                                                                                                                    -    def __init__(self, *args, **kwargs):
                                                                                                                                    -        super(_HashableSource, self).__init__(*args, **kwargs)
                                                                                                                                    -        self._update_hash()
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def alias(self, name):
                                                                                                                                    -        self._alias = name
                                                                                                                                    -        self._update_hash()
                                                                                                                                    -
                                                                                                                                    -    def _update_hash(self):
                                                                                                                                    -        self._hash = self._get_hash()
                                                                                                                                    -
                                                                                                                                    -    def _get_hash(self):
                                                                                                                                    -        return hash((self.__class__, self._path, self._alias))
                                                                                                                                    -
                                                                                                                                    -    def __hash__(self):
                                                                                                                                    -        return self._hash
                                                                                                                                    -
                                                                                                                                    -    def __eq__(self, other):
                                                                                                                                    -        if isinstance(other, _HashableSource):
                                                                                                                                    -            return self._hash == other._hash
                                                                                                                                    -        return Expression(self, OP.EQ, other)
                                                                                                                                    -
                                                                                                                                    -    def __ne__(self, other):
                                                                                                                                    -        if isinstance(other, _HashableSource):
                                                                                                                                    -            return self._hash != other._hash
                                                                                                                                    -        return Expression(self, OP.NE, other)
                                                                                                                                    -
                                                                                                                                    -    def _e(op):
                                                                                                                                    -        def inner(self, rhs):
                                                                                                                                    -            return Expression(self, op, rhs)
                                                                                                                                    -        return inner
                                                                                                                                    -    __lt__ = _e(OP.LT)
                                                                                                                                    -    __le__ = _e(OP.LTE)
                                                                                                                                    -    __gt__ = _e(OP.GT)
                                                                                                                                    -    __ge__ = _e(OP.GTE)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -def __bind_database__(meth):
                                                                                                                                    -    @wraps(meth)
                                                                                                                                    -    def inner(self, *args, **kwargs):
                                                                                                                                    -        result = meth(self, *args, **kwargs)
                                                                                                                                    -        if self._database:
                                                                                                                                    -            return result.bind(self._database)
                                                                                                                                    -        return result
                                                                                                                                    -    return inner
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -def __join__(join_type=JOIN.INNER, inverted=False):
                                                                                                                                    -    def method(self, other):
                                                                                                                                    -        if inverted:
                                                                                                                                    -            self, other = other, self
                                                                                                                                    -        return Join(self, other, join_type=join_type)
                                                                                                                                    -    return method
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class BaseTable(Source):
                                                                                                                                    -    __and__ = __join__(JOIN.INNER)
                                                                                                                                    -    __add__ = __join__(JOIN.LEFT_OUTER)
                                                                                                                                    -    __sub__ = __join__(JOIN.RIGHT_OUTER)
                                                                                                                                    -    __or__ = __join__(JOIN.FULL_OUTER)
                                                                                                                                    -    __mul__ = __join__(JOIN.CROSS)
                                                                                                                                    -    __rand__ = __join__(JOIN.INNER, inverted=True)
                                                                                                                                    -    __radd__ = __join__(JOIN.LEFT_OUTER, inverted=True)
                                                                                                                                    -    __rsub__ = __join__(JOIN.RIGHT_OUTER, inverted=True)
                                                                                                                                    -    __ror__ = __join__(JOIN.FULL_OUTER, inverted=True)
                                                                                                                                    -    __rmul__ = __join__(JOIN.CROSS, inverted=True)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class _BoundTableContext(_callable_context_manager):
                                                                                                                                    -    def __init__(self, table, database):
                                                                                                                                    -        self.table = table
                                                                                                                                    -        self.database = database
                                                                                                                                    -
                                                                                                                                    -    def __enter__(self):
                                                                                                                                    -        self._orig_database = self.table._database
                                                                                                                                    -        self.table.bind(self.database)
                                                                                                                                    -        if self.table._model is not None:
                                                                                                                                    -            self.table._model.bind(self.database)
                                                                                                                                    -        return self.table
                                                                                                                                    -
                                                                                                                                    -    def __exit__(self, exc_type, exc_val, exc_tb):
                                                                                                                                    -        self.table.bind(self._orig_database)
                                                                                                                                    -        if self.table._model is not None:
                                                                                                                                    -            self.table._model.bind(self._orig_database)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class Table(_HashableSource, BaseTable):
                                                                                                                                    -    def __init__(self, name, columns=None, primary_key=None, schema=None,
                                                                                                                                    -                 alias=None, _model=None, _database=None):
                                                                                                                                    -        self.__name__ = name
                                                                                                                                    -        self._columns = columns
                                                                                                                                    -        self._primary_key = primary_key
                                                                                                                                    -        self._schema = schema
                                                                                                                                    -        self._path = (schema, name) if schema else (name,)
                                                                                                                                    -        self._model = _model
                                                                                                                                    -        self._database = _database
                                                                                                                                    -        super(Table, self).__init__(alias=alias)
                                                                                                                                    -
                                                                                                                                    -        # Allow tables to restrict what columns are available.
                                                                                                                                    -        if columns is not None:
                                                                                                                                    -            self.c = _ExplicitColumn()
                                                                                                                                    -            for column in columns:
                                                                                                                                    -                setattr(self, column, Column(self, column))
                                                                                                                                    -
                                                                                                                                    -        if primary_key:
                                                                                                                                    -            col_src = self if self._columns else self.c
                                                                                                                                    -            self.primary_key = getattr(col_src, primary_key)
                                                                                                                                    -        else:
                                                                                                                                    -            self.primary_key = None
                                                                                                                                    -
                                                                                                                                    -    def clone(self):
                                                                                                                                    -        # Ensure a deep copy of the column instances.
                                                                                                                                    -        return Table(
                                                                                                                                    -            self.__name__,
                                                                                                                                    -            columns=self._columns,
                                                                                                                                    -            primary_key=self._primary_key,
                                                                                                                                    -            schema=self._schema,
                                                                                                                                    -            alias=self._alias,
                                                                                                                                    -            _model=self._model,
                                                                                                                                    -            _database=self._database)
                                                                                                                                    -
                                                                                                                                    -    def bind(self, database=None):
                                                                                                                                    -        self._database = database
                                                                                                                                    -        return self
                                                                                                                                    -
                                                                                                                                    -    def bind_ctx(self, database=None):
                                                                                                                                    -        return _BoundTableContext(self, database)
                                                                                                                                    -
                                                                                                                                    -    def _get_hash(self):
                                                                                                                                    -        return hash((self.__class__, self._path, self._alias, self._model))
                                                                                                                                    -
                                                                                                                                    -    @__bind_database__
                                                                                                                                    -    def select(self, *columns):
                                                                                                                                    -        if not columns and self._columns:
                                                                                                                                    -            columns = [Column(self, column) for column in self._columns]
                                                                                                                                    -        return Select((self,), columns)
                                                                                                                                    -
                                                                                                                                    -    @__bind_database__
                                                                                                                                    -    def insert(self, insert=None, columns=None, **kwargs):
                                                                                                                                    -        if kwargs:
                                                                                                                                    -            insert = {} if insert is None else insert
                                                                                                                                    -            src = self if self._columns else self.c
                                                                                                                                    -            for key, value in kwargs.items():
                                                                                                                                    -                insert[getattr(src, key)] = value
                                                                                                                                    -        return Insert(self, insert=insert, columns=columns)
                                                                                                                                    -
                                                                                                                                    -    @__bind_database__
                                                                                                                                    -    def replace(self, insert=None, columns=None, **kwargs):
                                                                                                                                    -        return (self
                                                                                                                                    -                .insert(insert=insert, columns=columns)
                                                                                                                                    -                .on_conflict('REPLACE'))
                                                                                                                                    -
                                                                                                                                    -    @__bind_database__
                                                                                                                                    -    def update(self, update=None, **kwargs):
                                                                                                                                    -        if kwargs:
                                                                                                                                    -            update = {} if update is None else update
                                                                                                                                    -            for key, value in kwargs.items():
                                                                                                                                    -                src = self if self._columns else self.c
                                                                                                                                    -                update[getattr(src, key)] = value
                                                                                                                                    -        return Update(self, update=update)
                                                                                                                                    -
                                                                                                                                    -    @__bind_database__
                                                                                                                                    -    def delete(self):
                                                                                                                                    -        return Delete(self)
                                                                                                                                    -
                                                                                                                                    -    def __sql__(self, ctx):
                                                                                                                                    -        if ctx.scope == SCOPE_VALUES:
                                                                                                                                    -            # Return the quoted table name.
                                                                                                                                    -            return ctx.sql(Entity(*self._path))
                                                                                                                                    -
                                                                                                                                    -        if self._alias:
                                                                                                                                    -            ctx.alias_manager[self] = self._alias
                                                                                                                                    -
                                                                                                                                    -        if ctx.scope == SCOPE_SOURCE:
                                                                                                                                    -            # Define the table and its alias.
                                                                                                                                    -            return self.apply_alias(ctx.sql(Entity(*self._path)))
                                                                                                                                    -        else:
                                                                                                                                    -            # Refer to the table using the alias.
                                                                                                                                    -            return self.apply_column(ctx)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class Join(BaseTable):
                                                                                                                                    -    def __init__(self, lhs, rhs, join_type=JOIN.INNER, on=None, alias=None):
                                                                                                                                    -        super(Join, self).__init__(alias=alias)
                                                                                                                                    -        self.lhs = lhs
                                                                                                                                    -        self.rhs = rhs
                                                                                                                                    -        self.join_type = join_type
                                                                                                                                    -        self._on = on
                                                                                                                                    -
                                                                                                                                    -    def on(self, predicate):
                                                                                                                                    -        self._on = predicate
                                                                                                                                    -        return self
                                                                                                                                    -
                                                                                                                                    -    def __sql__(self, ctx):
                                                                                                                                    -        (ctx
                                                                                                                                    -         .sql(self.lhs)
                                                                                                                                    -         .literal(' %s ' % self.join_type)
                                                                                                                                    -         .sql(self.rhs))
                                                                                                                                    -        if self._on is not None:
                                                                                                                                    -            ctx.literal(' ON ').sql(self._on)
                                                                                                                                    -        return ctx
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class ValuesList(_HashableSource, BaseTable):
                                                                                                                                    -    def __init__(self, values, columns=None, alias=None):
                                                                                                                                    -        self._values = values
                                                                                                                                    -        self._columns = columns
                                                                                                                                    -        super(ValuesList, self).__init__(alias=alias)
                                                                                                                                    -
                                                                                                                                    -    def _get_hash(self):
                                                                                                                                    -        return hash((self.__class__, id(self._values), self._alias))
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def columns(self, *names):
                                                                                                                                    -        self._columns = names
                                                                                                                                    -
                                                                                                                                    -    def __sql__(self, ctx):
                                                                                                                                    -        if self._alias:
                                                                                                                                    -            ctx.alias_manager[self] = self._alias
                                                                                                                                    -
                                                                                                                                    -        if ctx.scope == SCOPE_SOURCE or ctx.scope == SCOPE_NORMAL:
                                                                                                                                    -            with ctx(parentheses=not ctx.parentheses):
                                                                                                                                    -                ctx = (ctx
                                                                                                                                    -                       .literal('VALUES ')
                                                                                                                                    -                       .sql(CommaNodeList([
                                                                                                                                    -                           EnclosedNodeList(row) for row in self._values])))
                                                                                                                                    -
                                                                                                                                    -            if ctx.scope == SCOPE_SOURCE:
                                                                                                                                    -                ctx.literal(' AS ').sql(Entity(ctx.alias_manager[self]))
                                                                                                                                    -                if self._columns:
                                                                                                                                    -                    entities = [Entity(c) for c in self._columns]
                                                                                                                                    -                    ctx.sql(EnclosedNodeList(entities))
                                                                                                                                    -        else:
                                                                                                                                    -            ctx.sql(Entity(ctx.alias_manager[self]))
                                                                                                                                    -
                                                                                                                                    -        return ctx
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class CTE(_HashableSource, Source):
                                                                                                                                    -    def __init__(self, name, query, recursive=False, columns=None,
                                                                                                                                    -                 materialized=None):
                                                                                                                                    -        self._alias = name
                                                                                                                                    -        self._query = query
                                                                                                                                    -        self._recursive = recursive
                                                                                                                                    -        self._materialized = materialized
                                                                                                                                    -        if columns is not None:
                                                                                                                                    -            columns = [Entity(c) if isinstance(c, basestring) else c
                                                                                                                                    -                       for c in columns]
                                                                                                                                    -        self._columns = columns
                                                                                                                                    -        query._cte_list = ()
                                                                                                                                    -        super(CTE, self).__init__(alias=name)
                                                                                                                                    -
                                                                                                                                    -    def select_from(self, *columns):
                                                                                                                                    -        if not columns:
                                                                                                                                    -            raise ValueError('select_from() must specify one or more columns '
                                                                                                                                    -                             'from the CTE to select.')
                                                                                                                                    -
                                                                                                                                    -        query = (Select((self,), columns)
                                                                                                                                    -                 .with_cte(self)
                                                                                                                                    -                 .bind(self._query._database))
                                                                                                                                    -        try:
                                                                                                                                    -            query = query.objects(self._query.model)
                                                                                                                                    -        except AttributeError:
                                                                                                                                    -            pass
                                                                                                                                    -        return query
                                                                                                                                    -
                                                                                                                                    -    def _get_hash(self):
                                                                                                                                    -        return hash((self.__class__, self._alias, id(self._query)))
                                                                                                                                    -
                                                                                                                                    -    def union_all(self, rhs):
                                                                                                                                    -        clone = self._query.clone()
                                                                                                                                    -        return CTE(self._alias, clone + rhs, self._recursive, self._columns)
                                                                                                                                    -    __add__ = union_all
                                                                                                                                    -
                                                                                                                                    -    def union(self, rhs):
                                                                                                                                    -        clone = self._query.clone()
                                                                                                                                    -        return CTE(self._alias, clone | rhs, self._recursive, self._columns)
                                                                                                                                    -    __or__ = union
                                                                                                                                    -
                                                                                                                                    -    def __sql__(self, ctx):
                                                                                                                                    -        if ctx.scope != SCOPE_CTE:
                                                                                                                                    -            return ctx.sql(Entity(self._alias))
                                                                                                                                    -
                                                                                                                                    -        with ctx.push_alias():
                                                                                                                                    -            ctx.alias_manager[self] = self._alias
                                                                                                                                    -            ctx.sql(Entity(self._alias))
                                                                                                                                    -
                                                                                                                                    -            if self._columns:
                                                                                                                                    -                ctx.literal(' ').sql(EnclosedNodeList(self._columns))
                                                                                                                                    -            ctx.literal(' AS ')
                                                                                                                                    -
                                                                                                                                    -            if self._materialized:
                                                                                                                                    -                ctx.literal('MATERIALIZED ')
                                                                                                                                    -            elif self._materialized is False:
                                                                                                                                    -                ctx.literal('NOT MATERIALIZED ')
                                                                                                                                    -
                                                                                                                                    -            with ctx.scope_normal(parentheses=True):
                                                                                                                                    -                ctx.sql(self._query)
                                                                                                                                    -        return ctx
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class ColumnBase(Node):
                                                                                                                                    -    _converter = None
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def converter(self, converter=None):
                                                                                                                                    -        self._converter = converter
                                                                                                                                    -
                                                                                                                                    -    def alias(self, alias):
                                                                                                                                    -        if alias:
                                                                                                                                    -            return Alias(self, alias)
                                                                                                                                    -        return self
                                                                                                                                    -
                                                                                                                                    -    def unalias(self):
                                                                                                                                    -        return self
                                                                                                                                    -
                                                                                                                                    -    def cast(self, as_type):
                                                                                                                                    -        return Cast(self, as_type)
                                                                                                                                    -
                                                                                                                                    -    def asc(self, collation=None, nulls=None):
                                                                                                                                    -        return Asc(self, collation=collation, nulls=nulls)
                                                                                                                                    -    __pos__ = asc
                                                                                                                                    -
                                                                                                                                    -    def desc(self, collation=None, nulls=None):
                                                                                                                                    -        return Desc(self, collation=collation, nulls=nulls)
                                                                                                                                    -    __neg__ = desc
                                                                                                                                    -
                                                                                                                                    -    def __invert__(self):
                                                                                                                                    -        return Negated(self)
                                                                                                                                    -
                                                                                                                                    -    def _e(op, inv=False):
                                                                                                                                    -        """
                                                                                                                                    -        Lightweight factory which returns a method that builds an Expression
                                                                                                                                    -        consisting of the left-hand and right-hand operands, using `op`.
                                                                                                                                    -        """
                                                                                                                                    -        def inner(self, rhs):
                                                                                                                                    -            if inv:
                                                                                                                                    -                return Expression(rhs, op, self)
                                                                                                                                    -            return Expression(self, op, rhs)
                                                                                                                                    -        return inner
                                                                                                                                    -    __and__ = _e(OP.AND)
                                                                                                                                    -    __or__ = _e(OP.OR)
                                                                                                                                    -
                                                                                                                                    -    __add__ = _e(OP.ADD)
                                                                                                                                    -    __sub__ = _e(OP.SUB)
                                                                                                                                    -    __mul__ = _e(OP.MUL)
                                                                                                                                    -    __div__ = __truediv__ = _e(OP.DIV)
                                                                                                                                    -    __xor__ = _e(OP.XOR)
                                                                                                                                    -    __radd__ = _e(OP.ADD, inv=True)
                                                                                                                                    -    __rsub__ = _e(OP.SUB, inv=True)
                                                                                                                                    -    __rmul__ = _e(OP.MUL, inv=True)
                                                                                                                                    -    __rdiv__ = __rtruediv__ = _e(OP.DIV, inv=True)
                                                                                                                                    -    __rand__ = _e(OP.AND, inv=True)
                                                                                                                                    -    __ror__ = _e(OP.OR, inv=True)
                                                                                                                                    -    __rxor__ = _e(OP.XOR, inv=True)
                                                                                                                                    -
                                                                                                                                    -    def __eq__(self, rhs):
                                                                                                                                    -        op = OP.IS if rhs is None else OP.EQ
                                                                                                                                    -        return Expression(self, op, rhs)
                                                                                                                                    -    def __ne__(self, rhs):
                                                                                                                                    -        op = OP.IS_NOT if rhs is None else OP.NE
                                                                                                                                    -        return Expression(self, op, rhs)
                                                                                                                                    -
                                                                                                                                    -    __lt__ = _e(OP.LT)
                                                                                                                                    -    __le__ = _e(OP.LTE)
                                                                                                                                    -    __gt__ = _e(OP.GT)
                                                                                                                                    -    __ge__ = _e(OP.GTE)
                                                                                                                                    -    __lshift__ = _e(OP.IN)
                                                                                                                                    -    __rshift__ = _e(OP.IS)
                                                                                                                                    -    __mod__ = _e(OP.LIKE)
                                                                                                                                    -    __pow__ = _e(OP.ILIKE)
                                                                                                                                    -
                                                                                                                                    -    bin_and = _e(OP.BIN_AND)
                                                                                                                                    -    bin_or = _e(OP.BIN_OR)
                                                                                                                                    -    in_ = _e(OP.IN)
                                                                                                                                    -    not_in = _e(OP.NOT_IN)
                                                                                                                                    -    regexp = _e(OP.REGEXP)
                                                                                                                                    -
                                                                                                                                    -    # Special expressions.
                                                                                                                                    -    def is_null(self, is_null=True):
                                                                                                                                    -        op = OP.IS if is_null else OP.IS_NOT
                                                                                                                                    -        return Expression(self, op, None)
                                                                                                                                    -
                                                                                                                                    -    def _escape_like_expr(self, s, template):
                                                                                                                                    -        if s.find('_') >= 0 or s.find('%') >= 0 or s.find('\\') >= 0:
                                                                                                                                    -            s = s.replace('\\', '\\\\').replace('_', '\\_').replace('%', '\\%')
                                                                                                                                    -            return NodeList((template % s, SQL('ESCAPE'), '\\'))
                                                                                                                                    -        return template % s
                                                                                                                                    -    def contains(self, rhs):
                                                                                                                                    -        if isinstance(rhs, Node):
                                                                                                                                    -            rhs = Expression('%', OP.CONCAT,
                                                                                                                                    -                             Expression(rhs, OP.CONCAT, '%'))
                                                                                                                                    -        else:
                                                                                                                                    -            rhs = self._escape_like_expr(rhs, '%%%s%%')
                                                                                                                                    -        return Expression(self, OP.ILIKE, rhs)
                                                                                                                                    -    def startswith(self, rhs):
                                                                                                                                    -        if isinstance(rhs, Node):
                                                                                                                                    -            rhs = Expression(rhs, OP.CONCAT, '%')
                                                                                                                                    -        else:
                                                                                                                                    -            rhs = self._escape_like_expr(rhs, '%s%%')
                                                                                                                                    -        return Expression(self, OP.ILIKE, rhs)
                                                                                                                                    -    def endswith(self, rhs):
                                                                                                                                    -        if isinstance(rhs, Node):
                                                                                                                                    -            rhs = Expression('%', OP.CONCAT, rhs)
                                                                                                                                    -        else:
                                                                                                                                    -            rhs = self._escape_like_expr(rhs, '%%%s')
                                                                                                                                    -        return Expression(self, OP.ILIKE, rhs)
                                                                                                                                    -    def between(self, lo, hi):
                                                                                                                                    -        return Expression(self, OP.BETWEEN, NodeList((lo, SQL('AND'), hi)))
                                                                                                                                    -    def concat(self, rhs):
                                                                                                                                    -        return StringExpression(self, OP.CONCAT, rhs)
                                                                                                                                    -    def regexp(self, rhs):
                                                                                                                                    -        return Expression(self, OP.REGEXP, rhs)
                                                                                                                                    -    def iregexp(self, rhs):
                                                                                                                                    -        return Expression(self, OP.IREGEXP, rhs)
                                                                                                                                    -    def __getitem__(self, item):
                                                                                                                                    -        if isinstance(item, slice):
                                                                                                                                    -            if item.start is None or item.stop is None:
                                                                                                                                    -                raise ValueError('BETWEEN range must have both a start- and '
                                                                                                                                    -                                 'end-point.')
                                                                                                                                    -            return self.between(item.start, item.stop)
                                                                                                                                    -        return self == item
                                                                                                                                    -
                                                                                                                                    -    def distinct(self):
                                                                                                                                    -        return NodeList((SQL('DISTINCT'), self))
                                                                                                                                    -
                                                                                                                                    -    def collate(self, collation):
                                                                                                                                    -        return NodeList((self, SQL('COLLATE %s' % collation)))
                                                                                                                                    -
                                                                                                                                    -    def get_sort_key(self, ctx):
                                                                                                                                    -        return ()
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class Column(ColumnBase):
                                                                                                                                    -    def __init__(self, source, name):
                                                                                                                                    -        self.source = source
                                                                                                                                    -        self.name = name
                                                                                                                                    -
                                                                                                                                    -    def get_sort_key(self, ctx):
                                                                                                                                    -        if ctx.scope == SCOPE_VALUES:
                                                                                                                                    -            return (self.name,)
                                                                                                                                    -        else:
                                                                                                                                    -            return self.source.get_sort_key(ctx) + (self.name,)
                                                                                                                                    -
                                                                                                                                    -    def __hash__(self):
                                                                                                                                    -        return hash((self.source, self.name))
                                                                                                                                    -
                                                                                                                                    -    def __sql__(self, ctx):
                                                                                                                                    -        if ctx.scope == SCOPE_VALUES:
                                                                                                                                    -            return ctx.sql(Entity(self.name))
                                                                                                                                    -        else:
                                                                                                                                    -            with ctx.scope_column():
                                                                                                                                    -                return ctx.sql(self.source).literal('.').sql(Entity(self.name))
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class WrappedNode(ColumnBase):
                                                                                                                                    -    def __init__(self, node):
                                                                                                                                    -        self.node = node
                                                                                                                                    -        self._coerce = getattr(node, '_coerce', True)
                                                                                                                                    -        self._converter = getattr(node, '_converter', None)
                                                                                                                                    -
                                                                                                                                    -    def is_alias(self):
                                                                                                                                    -        return self.node.is_alias()
                                                                                                                                    -
                                                                                                                                    -    def unwrap(self):
                                                                                                                                    -        return self.node.unwrap()
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class EntityFactory(object):
                                                                                                                                    -    __slots__ = ('node',)
                                                                                                                                    -    def __init__(self, node):
                                                                                                                                    -        self.node = node
                                                                                                                                    -    def __getattr__(self, attr):
                                                                                                                                    -        return Entity(self.node, attr)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class _DynamicEntity(object):
                                                                                                                                    -    __slots__ = ()
                                                                                                                                    -    def __get__(self, instance, instance_type=None):
                                                                                                                                    -        if instance is not None:
                                                                                                                                    -            return EntityFactory(instance._alias)  # Implements __getattr__().
                                                                                                                                    -        return self
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class Alias(WrappedNode):
                                                                                                                                    -    c = _DynamicEntity()
                                                                                                                                    -
                                                                                                                                    -    def __init__(self, node, alias):
                                                                                                                                    -        super(Alias, self).__init__(node)
                                                                                                                                    -        self._alias = alias
                                                                                                                                    -
                                                                                                                                    -    def __hash__(self):
                                                                                                                                    -        return hash(self._alias)
                                                                                                                                    -
                                                                                                                                    -    def alias(self, alias=None):
                                                                                                                                    -        if alias is None:
                                                                                                                                    -            return self.node
                                                                                                                                    -        else:
                                                                                                                                    -            return Alias(self.node, alias)
                                                                                                                                    -
                                                                                                                                    -    def unalias(self):
                                                                                                                                    -        return self.node
                                                                                                                                    -
                                                                                                                                    -    def is_alias(self):
                                                                                                                                    -        return True
                                                                                                                                    -
                                                                                                                                    -    def __sql__(self, ctx):
                                                                                                                                    -        if ctx.scope == SCOPE_SOURCE:
                                                                                                                                    -            return (ctx
                                                                                                                                    -                    .sql(self.node)
                                                                                                                                    -                    .literal(' AS ')
                                                                                                                                    -                    .sql(Entity(self._alias)))
                                                                                                                                    -        else:
                                                                                                                                    -            return ctx.sql(Entity(self._alias))
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class Negated(WrappedNode):
                                                                                                                                    -    def __invert__(self):
                                                                                                                                    -        return self.node
                                                                                                                                    -
                                                                                                                                    -    def __sql__(self, ctx):
                                                                                                                                    -        return ctx.literal('NOT ').sql(self.node)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class BitwiseMixin(object):
                                                                                                                                    -    def __and__(self, other):
                                                                                                                                    -        return self.bin_and(other)
                                                                                                                                    -
                                                                                                                                    -    def __or__(self, other):
                                                                                                                                    -        return self.bin_or(other)
                                                                                                                                    -
                                                                                                                                    -    def __sub__(self, other):
                                                                                                                                    -        return self.bin_and(other.bin_negated())
                                                                                                                                    -
                                                                                                                                    -    def __invert__(self):
                                                                                                                                    -        return BitwiseNegated(self)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class BitwiseNegated(BitwiseMixin, WrappedNode):
                                                                                                                                    -    def __invert__(self):
                                                                                                                                    -        return self.node
                                                                                                                                    -
                                                                                                                                    -    def __sql__(self, ctx):
                                                                                                                                    -        if ctx.state.operations:
                                                                                                                                    -            op_sql = ctx.state.operations.get(self.op, self.op)
                                                                                                                                    -        else:
                                                                                                                                    -            op_sql = self.op
                                                                                                                                    -        return ctx.literal(op_sql).sql(self.node)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class Value(ColumnBase):
                                                                                                                                    -    def __init__(self, value, converter=None, unpack=True):
                                                                                                                                    -        self.value = value
                                                                                                                                    -        self.converter = converter
                                                                                                                                    -        self.multi = unpack and isinstance(self.value, multi_types)
                                                                                                                                    -        if self.multi:
                                                                                                                                    -            self.values = []
                                                                                                                                    -            for item in self.value:
                                                                                                                                    -                if isinstance(item, Node):
                                                                                                                                    -                    self.values.append(item)
                                                                                                                                    -                else:
                                                                                                                                    -                    self.values.append(Value(item, self.converter))
                                                                                                                                    -
                                                                                                                                    -    def __sql__(self, ctx):
                                                                                                                                    -        if self.multi:
                                                                                                                                    -            # For multi-part values (e.g. lists of IDs).
                                                                                                                                    -            return ctx.sql(EnclosedNodeList(self.values))
                                                                                                                                    -
                                                                                                                                    -        return ctx.value(self.value, self.converter)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -def AsIs(value):
                                                                                                                                    -    return Value(value, unpack=False)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class Cast(WrappedNode):
                                                                                                                                    -    def __init__(self, node, cast):
                                                                                                                                    -        super(Cast, self).__init__(node)
                                                                                                                                    -        self._cast = cast
                                                                                                                                    -        self._coerce = False
                                                                                                                                    -
                                                                                                                                    -    def __sql__(self, ctx):
                                                                                                                                    -        return (ctx
                                                                                                                                    -                .literal('CAST(')
                                                                                                                                    -                .sql(self.node)
                                                                                                                                    -                .literal(' AS %s)' % self._cast))
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class Ordering(WrappedNode):
                                                                                                                                    -    def __init__(self, node, direction, collation=None, nulls=None):
                                                                                                                                    -        super(Ordering, self).__init__(node)
                                                                                                                                    -        self.direction = direction
                                                                                                                                    -        self.collation = collation
                                                                                                                                    -        self.nulls = nulls
                                                                                                                                    -        if nulls and nulls.lower() not in ('first', 'last'):
                                                                                                                                    -            raise ValueError('Ordering nulls= parameter must be "first" or '
                                                                                                                                    -                             '"last", got: %s' % nulls)
                                                                                                                                    -
                                                                                                                                    -    def collate(self, collation=None):
                                                                                                                                    -        return Ordering(self.node, self.direction, collation)
                                                                                                                                    -
                                                                                                                                    -    def _null_ordering_case(self, nulls):
                                                                                                                                    -        if nulls.lower() == 'last':
                                                                                                                                    -            ifnull, notnull = 1, 0
                                                                                                                                    -        elif nulls.lower() == 'first':
                                                                                                                                    -            ifnull, notnull = 0, 1
                                                                                                                                    -        else:
                                                                                                                                    -            raise ValueError('unsupported value for nulls= ordering.')
                                                                                                                                    -        return Case(None, ((self.node.is_null(), ifnull),), notnull)
                                                                                                                                    -
                                                                                                                                    -    def __sql__(self, ctx):
                                                                                                                                    -        if self.nulls and not ctx.state.nulls_ordering:
                                                                                                                                    -            ctx.sql(self._null_ordering_case(self.nulls)).literal(', ')
                                                                                                                                    -
                                                                                                                                    -        ctx.sql(self.node).literal(' %s' % self.direction)
                                                                                                                                    -        if self.collation:
                                                                                                                                    -            ctx.literal(' COLLATE %s' % self.collation)
                                                                                                                                    -        if self.nulls and ctx.state.nulls_ordering:
                                                                                                                                    -            ctx.literal(' NULLS %s' % self.nulls)
                                                                                                                                    -        return ctx
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -def Asc(node, collation=None, nulls=None):
                                                                                                                                    -    return Ordering(node, 'ASC', collation, nulls)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -def Desc(node, collation=None, nulls=None):
                                                                                                                                    -    return Ordering(node, 'DESC', collation, nulls)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class Expression(ColumnBase):
                                                                                                                                    -    def __init__(self, lhs, op, rhs, flat=False):
                                                                                                                                    -        self.lhs = lhs
                                                                                                                                    -        self.op = op
                                                                                                                                    -        self.rhs = rhs
                                                                                                                                    -        self.flat = flat
                                                                                                                                    -
                                                                                                                                    -    def __sql__(self, ctx):
                                                                                                                                    -        overrides = {'parentheses': not self.flat, 'in_expr': True}
                                                                                                                                    -
                                                                                                                                    -        # First attempt to unwrap the node on the left-hand-side, so that we
                                                                                                                                    -        # can get at the underlying Field if one is present.
                                                                                                                                    -        node = raw_node = self.lhs
                                                                                                                                    -        if isinstance(raw_node, WrappedNode):
                                                                                                                                    -            node = raw_node.unwrap()
                                                                                                                                    -
                                                                                                                                    -        # Set up the appropriate converter if we have a field on the left side.
                                                                                                                                    -        if isinstance(node, Field) and raw_node._coerce:
                                                                                                                                    -            overrides['converter'] = node.db_value
                                                                                                                                    -        else:
                                                                                                                                    -            overrides['converter'] = None
                                                                                                                                    -
                                                                                                                                    -        if ctx.state.operations:
                                                                                                                                    -            op_sql = ctx.state.operations.get(self.op, self.op)
                                                                                                                                    -        else:
                                                                                                                                    -            op_sql = self.op
                                                                                                                                    -
                                                                                                                                    -        with ctx(**overrides):
                                                                                                                                    -            # Postgresql reports an error for IN/NOT IN (), so convert to
                                                                                                                                    -            # the equivalent boolean expression.
                                                                                                                                    -            op_in = self.op == OP.IN or self.op == OP.NOT_IN
                                                                                                                                    -            if op_in and ctx.as_new().parse(self.rhs)[0] == '()':
                                                                                                                                    -                return ctx.literal('0 = 1' if self.op == OP.IN else '1 = 1')
                                                                                                                                    -
                                                                                                                                    -            return (ctx
                                                                                                                                    -                    .sql(self.lhs)
                                                                                                                                    -                    .literal(' %s ' % op_sql)
                                                                                                                                    -                    .sql(self.rhs))
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class StringExpression(Expression):
                                                                                                                                    -    def __add__(self, rhs):
                                                                                                                                    -        return self.concat(rhs)
                                                                                                                                    -    def __radd__(self, lhs):
                                                                                                                                    -        return StringExpression(lhs, OP.CONCAT, self)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class Entity(ColumnBase):
                                                                                                                                    -    def __init__(self, *path):
                                                                                                                                    -        self._path = [part.replace('"', '""') for part in path if part]
                                                                                                                                    -
                                                                                                                                    -    def __getattr__(self, attr):
                                                                                                                                    -        return Entity(*self._path + [attr])
                                                                                                                                    -
                                                                                                                                    -    def get_sort_key(self, ctx):
                                                                                                                                    -        return tuple(self._path)
                                                                                                                                    -
                                                                                                                                    -    def __hash__(self):
                                                                                                                                    -        return hash((self.__class__.__name__, tuple(self._path)))
                                                                                                                                    -
                                                                                                                                    -    def __sql__(self, ctx):
                                                                                                                                    -        return ctx.literal(quote(self._path, ctx.state.quote or '""'))
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class SQL(ColumnBase):
                                                                                                                                    -    def __init__(self, sql, params=None):
                                                                                                                                    -        self.sql = sql
                                                                                                                                    -        self.params = params
                                                                                                                                    -
                                                                                                                                    -    def __sql__(self, ctx):
                                                                                                                                    -        ctx.literal(self.sql)
                                                                                                                                    -        if self.params:
                                                                                                                                    -            for param in self.params:
                                                                                                                                    -                ctx.value(param, False, add_param=False)
                                                                                                                                    -        return ctx
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -def Check(constraint):
                                                                                                                                    -    return SQL('CHECK (%s)' % constraint)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class Function(ColumnBase):
                                                                                                                                    -    def __init__(self, name, arguments, coerce=True, python_value=None):
                                                                                                                                    -        self.name = name
                                                                                                                                    -        self.arguments = arguments
                                                                                                                                    -        self._filter = None
                                                                                                                                    -        self._order_by = None
                                                                                                                                    -        self._python_value = python_value
                                                                                                                                    -        if name and name.lower() in ('sum', 'count', 'cast'):
                                                                                                                                    -            self._coerce = False
                                                                                                                                    -        else:
                                                                                                                                    -            self._coerce = coerce
                                                                                                                                    -
                                                                                                                                    -    def __getattr__(self, attr):
                                                                                                                                    -        def decorator(*args, **kwargs):
                                                                                                                                    -            return Function(attr, args, **kwargs)
                                                                                                                                    -        return decorator
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def filter(self, where=None):
                                                                                                                                    -        self._filter = where
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def order_by(self, *ordering):
                                                                                                                                    -        self._order_by = ordering
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def python_value(self, func=None):
                                                                                                                                    -        self._python_value = func
                                                                                                                                    -
                                                                                                                                    -    def over(self, partition_by=None, order_by=None, start=None, end=None,
                                                                                                                                    -             frame_type=None, window=None, exclude=None):
                                                                                                                                    -        if isinstance(partition_by, Window) and window is None:
                                                                                                                                    -            window = partition_by
                                                                                                                                    -
                                                                                                                                    -        if window is not None:
                                                                                                                                    -            node = WindowAlias(window)
                                                                                                                                    -        else:
                                                                                                                                    -            node = Window(partition_by=partition_by, order_by=order_by,
                                                                                                                                    -                          start=start, end=end, frame_type=frame_type,
                                                                                                                                    -                          exclude=exclude, _inline=True)
                                                                                                                                    -        return NodeList((self, SQL('OVER'), node))
                                                                                                                                    -
                                                                                                                                    -    def __sql__(self, ctx):
                                                                                                                                    -        ctx.literal(self.name)
                                                                                                                                    -        if not len(self.arguments):
                                                                                                                                    -            ctx.literal('()')
                                                                                                                                    -        else:
                                                                                                                                    -            args = self.arguments
                                                                                                                                    -
                                                                                                                                    -            # If this is an ordered aggregate, then we will modify the last
                                                                                                                                    -            # argument to append the ORDER BY ... clause. We do this to avoid
                                                                                                                                    -            # double-wrapping any expression args in parentheses, as NodeList
                                                                                                                                    -            # has a special check (hack) in place to work around this.
                                                                                                                                    -            if self._order_by:
                                                                                                                                    -                args = list(args)
                                                                                                                                    -                args[-1] = NodeList((args[-1], SQL('ORDER BY'),
                                                                                                                                    -                                     CommaNodeList(self._order_by)))
                                                                                                                                    -
                                                                                                                                    -            with ctx(in_function=True, function_arg_count=len(self.arguments)):
                                                                                                                                    -                ctx.sql(EnclosedNodeList([
                                                                                                                                    -                    (arg if isinstance(arg, Node) else Value(arg, False))
                                                                                                                                    -                    for arg in args]))
                                                                                                                                    -
                                                                                                                                    -        if self._filter:
                                                                                                                                    -            ctx.literal(' FILTER (WHERE ').sql(self._filter).literal(')')
                                                                                                                                    -        return ctx
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -fn = Function(None, None)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class Window(Node):
                                                                                                                                    -    # Frame start/end and frame exclusion.
                                                                                                                                    -    CURRENT_ROW = SQL('CURRENT ROW')
                                                                                                                                    -    GROUP = SQL('GROUP')
                                                                                                                                    -    TIES = SQL('TIES')
                                                                                                                                    -    NO_OTHERS = SQL('NO OTHERS')
                                                                                                                                    -
                                                                                                                                    -    # Frame types.
                                                                                                                                    -    GROUPS = 'GROUPS'
                                                                                                                                    -    RANGE = 'RANGE'
                                                                                                                                    -    ROWS = 'ROWS'
                                                                                                                                    -
                                                                                                                                    -    def __init__(self, partition_by=None, order_by=None, start=None, end=None,
                                                                                                                                    -                 frame_type=None, extends=None, exclude=None, alias=None,
                                                                                                                                    -                 _inline=False):
                                                                                                                                    -        super(Window, self).__init__()
                                                                                                                                    -        if start is not None and not isinstance(start, SQL):
                                                                                                                                    -            start = SQL(start)
                                                                                                                                    -        if end is not None and not isinstance(end, SQL):
                                                                                                                                    -            end = SQL(end)
                                                                                                                                    -
                                                                                                                                    -        self.partition_by = ensure_tuple(partition_by)
                                                                                                                                    -        self.order_by = ensure_tuple(order_by)
                                                                                                                                    -        self.start = start
                                                                                                                                    -        self.end = end
                                                                                                                                    -        if self.start is None and self.end is not None:
                                                                                                                                    -            raise ValueError('Cannot specify WINDOW end without start.')
                                                                                                                                    -        self._alias = alias or 'w'
                                                                                                                                    -        self._inline = _inline
                                                                                                                                    -        self.frame_type = frame_type
                                                                                                                                    -        self._extends = extends
                                                                                                                                    -        self._exclude = exclude
                                                                                                                                    -
                                                                                                                                    -    def alias(self, alias=None):
                                                                                                                                    -        self._alias = alias or 'w'
                                                                                                                                    -        return self
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def as_range(self):
                                                                                                                                    -        self.frame_type = Window.RANGE
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def as_rows(self):
                                                                                                                                    -        self.frame_type = Window.ROWS
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def as_groups(self):
                                                                                                                                    -        self.frame_type = Window.GROUPS
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def extends(self, window=None):
                                                                                                                                    -        self._extends = window
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def exclude(self, frame_exclusion=None):
                                                                                                                                    -        if isinstance(frame_exclusion, basestring):
                                                                                                                                    -            frame_exclusion = SQL(frame_exclusion)
                                                                                                                                    -        self._exclude = frame_exclusion
                                                                                                                                    -
                                                                                                                                    -    @staticmethod
                                                                                                                                    -    def following(value=None):
                                                                                                                                    -        if value is None:
                                                                                                                                    -            return SQL('UNBOUNDED FOLLOWING')
                                                                                                                                    -        return SQL('%d FOLLOWING' % value)
                                                                                                                                    -
                                                                                                                                    -    @staticmethod
                                                                                                                                    -    def preceding(value=None):
                                                                                                                                    -        if value is None:
                                                                                                                                    -            return SQL('UNBOUNDED PRECEDING')
                                                                                                                                    -        return SQL('%d PRECEDING' % value)
                                                                                                                                    -
                                                                                                                                    -    def __sql__(self, ctx):
                                                                                                                                    -        if ctx.scope != SCOPE_SOURCE and not self._inline:
                                                                                                                                    -            ctx.literal(self._alias)
                                                                                                                                    -            ctx.literal(' AS ')
                                                                                                                                    -
                                                                                                                                    -        with ctx(parentheses=True):
                                                                                                                                    -            parts = []
                                                                                                                                    -            if self._extends is not None:
                                                                                                                                    -                ext = self._extends
                                                                                                                                    -                if isinstance(ext, Window):
                                                                                                                                    -                    ext = SQL(ext._alias)
                                                                                                                                    -                elif isinstance(ext, basestring):
                                                                                                                                    -                    ext = SQL(ext)
                                                                                                                                    -                parts.append(ext)
                                                                                                                                    -            if self.partition_by:
                                                                                                                                    -                parts.extend((
                                                                                                                                    -                    SQL('PARTITION BY'),
                                                                                                                                    -                    CommaNodeList(self.partition_by)))
                                                                                                                                    -            if self.order_by:
                                                                                                                                    -                parts.extend((
                                                                                                                                    -                    SQL('ORDER BY'),
                                                                                                                                    -                    CommaNodeList(self.order_by)))
                                                                                                                                    -            if self.start is not None and self.end is not None:
                                                                                                                                    -                frame = self.frame_type or 'ROWS'
                                                                                                                                    -                parts.extend((
                                                                                                                                    -                    SQL('%s BETWEEN' % frame),
                                                                                                                                    -                    self.start,
                                                                                                                                    -                    SQL('AND'),
                                                                                                                                    -                    self.end))
                                                                                                                                    -            elif self.start is not None:
                                                                                                                                    -                parts.extend((SQL(self.frame_type or 'ROWS'), self.start))
                                                                                                                                    -            elif self.frame_type is not None:
                                                                                                                                    -                parts.append(SQL('%s UNBOUNDED PRECEDING' % self.frame_type))
                                                                                                                                    -            if self._exclude is not None:
                                                                                                                                    -                parts.extend((SQL('EXCLUDE'), self._exclude))
                                                                                                                                    -            ctx.sql(NodeList(parts))
                                                                                                                                    -        return ctx
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class WindowAlias(Node):
                                                                                                                                    -    def __init__(self, window):
                                                                                                                                    -        self.window = window
                                                                                                                                    -
                                                                                                                                    -    def alias(self, window_alias):
                                                                                                                                    -        self.window._alias = window_alias
                                                                                                                                    -        return self
                                                                                                                                    -
                                                                                                                                    -    def __sql__(self, ctx):
                                                                                                                                    -        return ctx.literal(self.window._alias or 'w')
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class ForUpdate(Node):
                                                                                                                                    -    def __init__(self, expr, of=None, nowait=None):
                                                                                                                                    -        expr = 'FOR UPDATE' if expr is True else expr
                                                                                                                                    -        if expr.lower().endswith('nowait'):
                                                                                                                                    -            expr = expr[:-7]  # Strip off the "nowait" bit.
                                                                                                                                    -            nowait = True
                                                                                                                                    -
                                                                                                                                    -        self._expr = expr
                                                                                                                                    -        if of is not None and not isinstance(of, (list, set, tuple)):
                                                                                                                                    -            of = (of,)
                                                                                                                                    -        self._of = of
                                                                                                                                    -        self._nowait = nowait
                                                                                                                                    -
                                                                                                                                    -    def __sql__(self, ctx):
                                                                                                                                    -        ctx.literal(self._expr)
                                                                                                                                    -        if self._of is not None:
                                                                                                                                    -            ctx.literal(' OF ').sql(CommaNodeList(self._of))
                                                                                                                                    -        if self._nowait:
                                                                                                                                    -            ctx.literal(' NOWAIT')
                                                                                                                                    -        return ctx
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -def Case(predicate, expression_tuples, default=None):
                                                                                                                                    -    clauses = [SQL('CASE')]
                                                                                                                                    -    if predicate is not None:
                                                                                                                                    -        clauses.append(predicate)
                                                                                                                                    -    for expr, value in expression_tuples:
                                                                                                                                    -        clauses.extend((SQL('WHEN'), expr, SQL('THEN'), value))
                                                                                                                                    -    if default is not None:
                                                                                                                                    -        clauses.extend((SQL('ELSE'), default))
                                                                                                                                    -    clauses.append(SQL('END'))
                                                                                                                                    -    return NodeList(clauses)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class NodeList(ColumnBase):
                                                                                                                                    -    def __init__(self, nodes, glue=' ', parens=False):
                                                                                                                                    -        self.nodes = nodes
                                                                                                                                    -        self.glue = glue
                                                                                                                                    -        self.parens = parens
                                                                                                                                    -        if parens and len(self.nodes) == 1 and \
                                                                                                                                    -           isinstance(self.nodes[0], Expression) and \
                                                                                                                                    -           not self.nodes[0].flat:
                                                                                                                                    -            # Hack to avoid double-parentheses.
                                                                                                                                    -            self.nodes = (self.nodes[0].clone(),)
                                                                                                                                    -            self.nodes[0].flat = True
                                                                                                                                    -
                                                                                                                                    -    def __sql__(self, ctx):
                                                                                                                                    -        n_nodes = len(self.nodes)
                                                                                                                                    -        if n_nodes == 0:
                                                                                                                                    -            return ctx.literal('()') if self.parens else ctx
                                                                                                                                    -        with ctx(parentheses=self.parens):
                                                                                                                                    -            for i in range(n_nodes - 1):
                                                                                                                                    -                ctx.sql(self.nodes[i])
                                                                                                                                    -                ctx.literal(self.glue)
                                                                                                                                    -            ctx.sql(self.nodes[n_nodes - 1])
                                                                                                                                    -        return ctx
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -def CommaNodeList(nodes):
                                                                                                                                    -    return NodeList(nodes, ', ')
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -def EnclosedNodeList(nodes):
                                                                                                                                    -    return NodeList(nodes, ', ', True)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class _Namespace(Node):
                                                                                                                                    -    __slots__ = ('_name',)
                                                                                                                                    -    def __init__(self, name):
                                                                                                                                    -        self._name = name
                                                                                                                                    -    def __getattr__(self, attr):
                                                                                                                                    -        return NamespaceAttribute(self, attr)
                                                                                                                                    -    __getitem__ = __getattr__
                                                                                                                                    -
                                                                                                                                    -class NamespaceAttribute(ColumnBase):
                                                                                                                                    -    def __init__(self, namespace, attribute):
                                                                                                                                    -        self._namespace = namespace
                                                                                                                                    -        self._attribute = attribute
                                                                                                                                    -
                                                                                                                                    -    def __sql__(self, ctx):
                                                                                                                                    -        return (ctx
                                                                                                                                    -                .literal(self._namespace._name + '.')
                                                                                                                                    -                .sql(Entity(self._attribute)))
                                                                                                                                    -
                                                                                                                                    -EXCLUDED = _Namespace('EXCLUDED')
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class DQ(ColumnBase):
                                                                                                                                    -    def __init__(self, **query):
                                                                                                                                    -        super(DQ, self).__init__()
                                                                                                                                    -        self.query = query
                                                                                                                                    -        self._negated = False
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def __invert__(self):
                                                                                                                                    -        self._negated = not self._negated
                                                                                                                                    -
                                                                                                                                    -    def clone(self):
                                                                                                                                    -        node = DQ(**self.query)
                                                                                                                                    -        node._negated = self._negated
                                                                                                                                    -        return node
                                                                                                                                    -
                                                                                                                                    -#: Represent a row tuple.
                                                                                                                                    -Tuple = lambda *a: EnclosedNodeList(a)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class QualifiedNames(WrappedNode):
                                                                                                                                    -    def __sql__(self, ctx):
                                                                                                                                    -        with ctx.scope_column():
                                                                                                                                    -            return ctx.sql(self.node)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -def qualify_names(node):
                                                                                                                                    -    # Search a node heirarchy to ensure that any column-like objects are
                                                                                                                                    -    # referenced using fully-qualified names.
                                                                                                                                    -    if isinstance(node, Expression):
                                                                                                                                    -        return node.__class__(qualify_names(node.lhs), node.op,
                                                                                                                                    -                              qualify_names(node.rhs), node.flat)
                                                                                                                                    -    elif isinstance(node, ColumnBase):
                                                                                                                                    -        return QualifiedNames(node)
                                                                                                                                    -    return node
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class OnConflict(Node):
                                                                                                                                    -    def __init__(self, action=None, update=None, preserve=None, where=None,
                                                                                                                                    -                 conflict_target=None, conflict_where=None,
                                                                                                                                    -                 conflict_constraint=None):
                                                                                                                                    -        self._action = action
                                                                                                                                    -        self._update = update
                                                                                                                                    -        self._preserve = ensure_tuple(preserve)
                                                                                                                                    -        self._where = where
                                                                                                                                    -        if conflict_target is not None and conflict_constraint is not None:
                                                                                                                                    -            raise ValueError('only one of "conflict_target" and '
                                                                                                                                    -                             '"conflict_constraint" may be specified.')
                                                                                                                                    -        self._conflict_target = ensure_tuple(conflict_target)
                                                                                                                                    -        self._conflict_where = conflict_where
                                                                                                                                    -        self._conflict_constraint = conflict_constraint
                                                                                                                                    -
                                                                                                                                    -    def get_conflict_statement(self, ctx, query):
                                                                                                                                    -        return ctx.state.conflict_statement(self, query)
                                                                                                                                    -
                                                                                                                                    -    def get_conflict_update(self, ctx, query):
                                                                                                                                    -        return ctx.state.conflict_update(self, query)
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def preserve(self, *columns):
                                                                                                                                    -        self._preserve = columns
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def update(self, _data=None, **kwargs):
                                                                                                                                    -        if _data and kwargs and not isinstance(_data, dict):
                                                                                                                                    -            raise ValueError('Cannot mix data with keyword arguments in the '
                                                                                                                                    -                             'OnConflict update method.')
                                                                                                                                    -        _data = _data or {}
                                                                                                                                    -        if kwargs:
                                                                                                                                    -            _data.update(kwargs)
                                                                                                                                    -        self._update = _data
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def where(self, *expressions):
                                                                                                                                    -        if self._where is not None:
                                                                                                                                    -            expressions = (self._where,) + expressions
                                                                                                                                    -        self._where = reduce(operator.and_, expressions)
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def conflict_target(self, *constraints):
                                                                                                                                    -        self._conflict_constraint = None
                                                                                                                                    -        self._conflict_target = constraints
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def conflict_where(self, *expressions):
                                                                                                                                    -        if self._conflict_where is not None:
                                                                                                                                    -            expressions = (self._conflict_where,) + expressions
                                                                                                                                    -        self._conflict_where = reduce(operator.and_, expressions)
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def conflict_constraint(self, constraint):
                                                                                                                                    -        self._conflict_constraint = constraint
                                                                                                                                    -        self._conflict_target = None
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -def database_required(method):
                                                                                                                                    -    @wraps(method)
                                                                                                                                    -    def inner(self, database=None, *args, **kwargs):
                                                                                                                                    -        database = self._database if database is None else database
                                                                                                                                    -        if not database:
                                                                                                                                    -            raise InterfaceError('Query must be bound to a database in order '
                                                                                                                                    -                                 'to call "%s".' % method.__name__)
                                                                                                                                    -        return method(self, database, *args, **kwargs)
                                                                                                                                    -    return inner
                                                                                                                                    -
                                                                                                                                    -# BASE QUERY INTERFACE.
                                                                                                                                    -
                                                                                                                                    -class BaseQuery(Node):
                                                                                                                                    -    default_row_type = ROW.DICT
                                                                                                                                    -
                                                                                                                                    -    def __init__(self, _database=None, **kwargs):
                                                                                                                                    -        self._database = _database
                                                                                                                                    -        self._cursor_wrapper = None
                                                                                                                                    -        self._row_type = None
                                                                                                                                    -        self._constructor = None
                                                                                                                                    -        super(BaseQuery, self).__init__(**kwargs)
                                                                                                                                    -
                                                                                                                                    -    def bind(self, database=None):
                                                                                                                                    -        self._database = database
                                                                                                                                    -        return self
                                                                                                                                    -
                                                                                                                                    -    def clone(self):
                                                                                                                                    -        query = super(BaseQuery, self).clone()
                                                                                                                                    -        query._cursor_wrapper = None
                                                                                                                                    -        return query
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def dicts(self, as_dict=True):
                                                                                                                                    -        self._row_type = ROW.DICT if as_dict else None
                                                                                                                                    -        return self
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def tuples(self, as_tuple=True):
                                                                                                                                    -        self._row_type = ROW.TUPLE if as_tuple else None
                                                                                                                                    -        return self
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def namedtuples(self, as_namedtuple=True):
                                                                                                                                    -        self._row_type = ROW.NAMED_TUPLE if as_namedtuple else None
                                                                                                                                    -        return self
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def objects(self, constructor=None):
                                                                                                                                    -        self._row_type = ROW.CONSTRUCTOR if constructor else None
                                                                                                                                    -        self._constructor = constructor
                                                                                                                                    -        return self
                                                                                                                                    -
                                                                                                                                    -    def _get_cursor_wrapper(self, cursor):
                                                                                                                                    -        row_type = self._row_type or self.default_row_type
                                                                                                                                    -
                                                                                                                                    -        if row_type == ROW.DICT:
                                                                                                                                    -            return DictCursorWrapper(cursor)
                                                                                                                                    -        elif row_type == ROW.TUPLE:
                                                                                                                                    -            return CursorWrapper(cursor)
                                                                                                                                    -        elif row_type == ROW.NAMED_TUPLE:
                                                                                                                                    -            return NamedTupleCursorWrapper(cursor)
                                                                                                                                    -        elif row_type == ROW.CONSTRUCTOR:
                                                                                                                                    -            return ObjectCursorWrapper(cursor, self._constructor)
                                                                                                                                    -        else:
                                                                                                                                    -            raise ValueError('Unrecognized row type: "%s".' % row_type)
                                                                                                                                    -
                                                                                                                                    -    def __sql__(self, ctx):
                                                                                                                                    -        raise NotImplementedError
                                                                                                                                    -
                                                                                                                                    -    def sql(self):
                                                                                                                                    -        if self._database:
                                                                                                                                    -            context = self._database.get_sql_context()
                                                                                                                                    -        else:
                                                                                                                                    -            context = Context()
                                                                                                                                    -        return context.parse(self)
                                                                                                                                    -
                                                                                                                                    -    @database_required
                                                                                                                                    -    def execute(self, database):
                                                                                                                                    -        return self._execute(database)
                                                                                                                                    -
                                                                                                                                    -    def _execute(self, database):
                                                                                                                                    -        raise NotImplementedError
                                                                                                                                    -
                                                                                                                                    -    def iterator(self, database=None):
                                                                                                                                    -        return iter(self.execute(database).iterator())
                                                                                                                                    -
                                                                                                                                    -    def _ensure_execution(self):
                                                                                                                                    -        if not self._cursor_wrapper:
                                                                                                                                    -            if not self._database:
                                                                                                                                    -                raise ValueError('Query has not been executed.')
                                                                                                                                    -            self.execute()
                                                                                                                                    -
                                                                                                                                    -    def __iter__(self):
                                                                                                                                    -        self._ensure_execution()
                                                                                                                                    -        return iter(self._cursor_wrapper)
                                                                                                                                    -
                                                                                                                                    -    def __getitem__(self, value):
                                                                                                                                    -        self._ensure_execution()
                                                                                                                                    -        if isinstance(value, slice):
                                                                                                                                    -            index = value.stop
                                                                                                                                    -        else:
                                                                                                                                    -            index = value
                                                                                                                                    -        if index is not None:
                                                                                                                                    -            index = index + 1 if index >= 0 else 0
                                                                                                                                    -        self._cursor_wrapper.fill_cache(index)
                                                                                                                                    -        return self._cursor_wrapper.row_cache[value]
                                                                                                                                    -
                                                                                                                                    -    def __len__(self):
                                                                                                                                    -        self._ensure_execution()
                                                                                                                                    -        return len(self._cursor_wrapper)
                                                                                                                                    -
                                                                                                                                    -    def __str__(self):
                                                                                                                                    -        return query_to_string(self)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class RawQuery(BaseQuery):
                                                                                                                                    -    def __init__(self, sql=None, params=None, **kwargs):
                                                                                                                                    -        super(RawQuery, self).__init__(**kwargs)
                                                                                                                                    -        self._sql = sql
                                                                                                                                    -        self._params = params
                                                                                                                                    -
                                                                                                                                    -    def __sql__(self, ctx):
                                                                                                                                    -        ctx.literal(self._sql)
                                                                                                                                    -        if self._params:
                                                                                                                                    -            for param in self._params:
                                                                                                                                    -                ctx.value(param, add_param=False)
                                                                                                                                    -        return ctx
                                                                                                                                    -
                                                                                                                                    -    def _execute(self, database):
                                                                                                                                    -        if self._cursor_wrapper is None:
                                                                                                                                    -            cursor = database.execute(self)
                                                                                                                                    -            self._cursor_wrapper = self._get_cursor_wrapper(cursor)
                                                                                                                                    -        return self._cursor_wrapper
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class Query(BaseQuery):
                                                                                                                                    -    def __init__(self, where=None, order_by=None, limit=None, offset=None,
                                                                                                                                    -                 **kwargs):
                                                                                                                                    -        super(Query, self).__init__(**kwargs)
                                                                                                                                    -        self._where = where
                                                                                                                                    -        self._order_by = order_by
                                                                                                                                    -        self._limit = limit
                                                                                                                                    -        self._offset = offset
                                                                                                                                    -
                                                                                                                                    -        self._cte_list = None
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def with_cte(self, *cte_list):
                                                                                                                                    -        self._cte_list = cte_list
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def where(self, *expressions):
                                                                                                                                    -        if self._where is not None:
                                                                                                                                    -            expressions = (self._where,) + expressions
                                                                                                                                    -        self._where = reduce(operator.and_, expressions)
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def orwhere(self, *expressions):
                                                                                                                                    -        if self._where is not None:
                                                                                                                                    -            expressions = (self._where,) + expressions
                                                                                                                                    -        self._where = reduce(operator.or_, expressions)
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def order_by(self, *values):
                                                                                                                                    -        self._order_by = values
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def order_by_extend(self, *values):
                                                                                                                                    -        self._order_by = ((self._order_by or ()) + values) or None
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def limit(self, value=None):
                                                                                                                                    -        self._limit = value
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def offset(self, value=None):
                                                                                                                                    -        self._offset = value
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def paginate(self, page, paginate_by=20):
                                                                                                                                    -        if page > 0:
                                                                                                                                    -            page -= 1
                                                                                                                                    -        self._limit = paginate_by
                                                                                                                                    -        self._offset = page * paginate_by
                                                                                                                                    -
                                                                                                                                    -    def _apply_ordering(self, ctx):
                                                                                                                                    -        if self._order_by:
                                                                                                                                    -            (ctx
                                                                                                                                    -             .literal(' ORDER BY ')
                                                                                                                                    -             .sql(CommaNodeList(self._order_by)))
                                                                                                                                    -        if self._limit is not None or (self._offset is not None and
                                                                                                                                    -                                       ctx.state.limit_max):
                                                                                                                                    -            limit = ctx.state.limit_max if self._limit is None else self._limit
                                                                                                                                    -            ctx.literal(' LIMIT ').sql(limit)
                                                                                                                                    -        if self._offset is not None:
                                                                                                                                    -            ctx.literal(' OFFSET ').sql(self._offset)
                                                                                                                                    -        return ctx
                                                                                                                                    -
                                                                                                                                    -    def __sql__(self, ctx):
                                                                                                                                    -        if self._cte_list:
                                                                                                                                    -            # The CTE scope is only used at the very beginning of the query,
                                                                                                                                    -            # when we are describing the various CTEs we will be using.
                                                                                                                                    -            recursive = any(cte._recursive for cte in self._cte_list)
                                                                                                                                    -
                                                                                                                                    -            # Explicitly disable the "subquery" flag here, so as to avoid
                                                                                                                                    -            # unnecessary parentheses around subsequent selects.
                                                                                                                                    -            with ctx.scope_cte(subquery=False):
                                                                                                                                    -                (ctx
                                                                                                                                    -                 .literal('WITH RECURSIVE ' if recursive else 'WITH ')
                                                                                                                                    -                 .sql(CommaNodeList(self._cte_list))
                                                                                                                                    -                 .literal(' '))
                                                                                                                                    -        return ctx
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -def __compound_select__(operation, inverted=False):
                                                                                                                                    -    def method(self, other):
                                                                                                                                    -        if inverted:
                                                                                                                                    -            self, other = other, self
                                                                                                                                    -        return CompoundSelectQuery(self, operation, other)
                                                                                                                                    -    return method
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class SelectQuery(Query):
                                                                                                                                    -    union_all = __add__ = __compound_select__('UNION ALL')
                                                                                                                                    -    union = __or__ = __compound_select__('UNION')
                                                                                                                                    -    intersect = __and__ = __compound_select__('INTERSECT')
                                                                                                                                    -    except_ = __sub__ = __compound_select__('EXCEPT')
                                                                                                                                    -    __radd__ = __compound_select__('UNION ALL', inverted=True)
                                                                                                                                    -    __ror__ = __compound_select__('UNION', inverted=True)
                                                                                                                                    -    __rand__ = __compound_select__('INTERSECT', inverted=True)
                                                                                                                                    -    __rsub__ = __compound_select__('EXCEPT', inverted=True)
                                                                                                                                    -
                                                                                                                                    -    def select_from(self, *columns):
                                                                                                                                    -        if not columns:
                                                                                                                                    -            raise ValueError('select_from() must specify one or more columns.')
                                                                                                                                    -
                                                                                                                                    -        query = (Select((self,), columns)
                                                                                                                                    -                 .bind(self._database))
                                                                                                                                    -        if getattr(self, 'model', None) is not None:
                                                                                                                                    -            # Bind to the sub-select's model type, if defined.
                                                                                                                                    -            query = query.objects(self.model)
                                                                                                                                    -        return query
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class SelectBase(_HashableSource, Source, SelectQuery):
                                                                                                                                    -    def _get_hash(self):
                                                                                                                                    -        return hash((self.__class__, self._alias or id(self)))
                                                                                                                                    -
                                                                                                                                    -    def _execute(self, database):
                                                                                                                                    -        if self._cursor_wrapper is None:
                                                                                                                                    -            cursor = database.execute(self)
                                                                                                                                    -            self._cursor_wrapper = self._get_cursor_wrapper(cursor)
                                                                                                                                    -        return self._cursor_wrapper
                                                                                                                                    -
                                                                                                                                    -    @database_required
                                                                                                                                    -    def peek(self, database, n=1):
                                                                                                                                    -        rows = self.execute(database)[:n]
                                                                                                                                    -        if rows:
                                                                                                                                    -            return rows[0] if n == 1 else rows
                                                                                                                                    -
                                                                                                                                    -    @database_required
                                                                                                                                    -    def first(self, database, n=1):
                                                                                                                                    -        if self._limit != n:
                                                                                                                                    -            self._limit = n
                                                                                                                                    -            self._cursor_wrapper = None
                                                                                                                                    -        return self.peek(database, n=n)
                                                                                                                                    -
                                                                                                                                    -    @database_required
                                                                                                                                    -    def scalar(self, database, as_tuple=False):
                                                                                                                                    -        row = self.tuples().peek(database)
                                                                                                                                    -        return row[0] if row and not as_tuple else row
                                                                                                                                    -
                                                                                                                                    -    @database_required
                                                                                                                                    -    def count(self, database, clear_limit=False):
                                                                                                                                    -        clone = self.order_by().alias('_wrapped')
                                                                                                                                    -        if clear_limit:
                                                                                                                                    -            clone._limit = clone._offset = None
                                                                                                                                    -        try:
                                                                                                                                    -            if clone._having is None and clone._group_by is None and \
                                                                                                                                    -               clone._windows is None and clone._distinct is None and \
                                                                                                                                    -               clone._simple_distinct is not True:
                                                                                                                                    -                clone = clone.select(SQL('1'))
                                                                                                                                    -        except AttributeError:
                                                                                                                                    -            pass
                                                                                                                                    -        return Select([clone], [fn.COUNT(SQL('1'))]).scalar(database)
                                                                                                                                    -
                                                                                                                                    -    @database_required
                                                                                                                                    -    def exists(self, database):
                                                                                                                                    -        clone = self.columns(SQL('1'))
                                                                                                                                    -        clone._limit = 1
                                                                                                                                    -        clone._offset = None
                                                                                                                                    -        return bool(clone.scalar())
                                                                                                                                    -
                                                                                                                                    -    @database_required
                                                                                                                                    -    def get(self, database):
                                                                                                                                    -        self._cursor_wrapper = None
                                                                                                                                    -        try:
                                                                                                                                    -            return self.execute(database)[0]
                                                                                                                                    -        except IndexError:
                                                                                                                                    -            pass
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -# QUERY IMPLEMENTATIONS.
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class CompoundSelectQuery(SelectBase):
                                                                                                                                    -    def __init__(self, lhs, op, rhs):
                                                                                                                                    -        super(CompoundSelectQuery, self).__init__()
                                                                                                                                    -        self.lhs = lhs
                                                                                                                                    -        self.op = op
                                                                                                                                    -        self.rhs = rhs
                                                                                                                                    -
                                                                                                                                    -    @property
                                                                                                                                    -    def _returning(self):
                                                                                                                                    -        return self.lhs._returning
                                                                                                                                    -
                                                                                                                                    -    @database_required
                                                                                                                                    -    def exists(self, database):
                                                                                                                                    -        query = Select((self.limit(1),), (SQL('1'),)).bind(database)
                                                                                                                                    -        return bool(query.scalar())
                                                                                                                                    -
                                                                                                                                    -    def _get_query_key(self):
                                                                                                                                    -        return (self.lhs.get_query_key(), self.rhs.get_query_key())
                                                                                                                                    -
                                                                                                                                    -    def _wrap_parens(self, ctx, subq):
                                                                                                                                    -        csq_setting = ctx.state.compound_select_parentheses
                                                                                                                                    -
                                                                                                                                    -        if not csq_setting or csq_setting == CSQ_PARENTHESES_NEVER:
                                                                                                                                    -            return False
                                                                                                                                    -        elif csq_setting == CSQ_PARENTHESES_ALWAYS:
                                                                                                                                    -            return True
                                                                                                                                    -        elif csq_setting == CSQ_PARENTHESES_UNNESTED:
                                                                                                                                    -            if ctx.state.in_expr or ctx.state.in_function:
                                                                                                                                    -                # If this compound select query is being used inside an
                                                                                                                                    -                # expression, e.g., an IN or EXISTS().
                                                                                                                                    -                return False
                                                                                                                                    -
                                                                                                                                    -            # If the query on the left or right is itself a compound select
                                                                                                                                    -            # query, then we do not apply parentheses. However, if it is a
                                                                                                                                    -            # regular SELECT query, we will apply parentheses.
                                                                                                                                    -            return not isinstance(subq, CompoundSelectQuery)
                                                                                                                                    -
                                                                                                                                    -    def __sql__(self, ctx):
                                                                                                                                    -        if ctx.scope == SCOPE_COLUMN:
                                                                                                                                    -            return self.apply_column(ctx)
                                                                                                                                    -
                                                                                                                                    -        # Call parent method to handle any CTEs.
                                                                                                                                    -        super(CompoundSelectQuery, self).__sql__(ctx)
                                                                                                                                    -
                                                                                                                                    -        outer_parens = ctx.subquery or (ctx.scope == SCOPE_SOURCE)
                                                                                                                                    -        with ctx(parentheses=outer_parens):
                                                                                                                                    -            # Should the left-hand query be wrapped in parentheses?
                                                                                                                                    -            lhs_parens = self._wrap_parens(ctx, self.lhs)
                                                                                                                                    -            with ctx.scope_normal(parentheses=lhs_parens, subquery=False):
                                                                                                                                    -                ctx.sql(self.lhs)
                                                                                                                                    -            ctx.literal(' %s ' % self.op)
                                                                                                                                    -            with ctx.push_alias():
                                                                                                                                    -                # Should the right-hand query be wrapped in parentheses?
                                                                                                                                    -                rhs_parens = self._wrap_parens(ctx, self.rhs)
                                                                                                                                    -                with ctx.scope_normal(parentheses=rhs_parens, subquery=False):
                                                                                                                                    -                    ctx.sql(self.rhs)
                                                                                                                                    -
                                                                                                                                    -            # Apply ORDER BY, LIMIT, OFFSET. We use the "values" scope so that
                                                                                                                                    -            # entity names are not fully-qualified. This is a bit of a hack, as
                                                                                                                                    -            # we're relying on the logic in Column.__sql__() to not fully
                                                                                                                                    -            # qualify column names.
                                                                                                                                    -            with ctx.scope_values():
                                                                                                                                    -                self._apply_ordering(ctx)
                                                                                                                                    -
                                                                                                                                    -        return self.apply_alias(ctx)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class Select(SelectBase):
                                                                                                                                    -    def __init__(self, from_list=None, columns=None, group_by=None,
                                                                                                                                    -                 having=None, distinct=None, windows=None, for_update=None,
                                                                                                                                    -                 for_update_of=None, nowait=None, lateral=None, **kwargs):
                                                                                                                                    -        super(Select, self).__init__(**kwargs)
                                                                                                                                    -        self._from_list = (list(from_list) if isinstance(from_list, tuple)
                                                                                                                                    -                           else from_list) or []
                                                                                                                                    -        self._returning = columns
                                                                                                                                    -        self._group_by = group_by
                                                                                                                                    -        self._having = having
                                                                                                                                    -        self._windows = None
                                                                                                                                    -        self._for_update = for_update  # XXX: consider reorganizing.
                                                                                                                                    -        self._for_update_of = for_update_of
                                                                                                                                    -        self._for_update_nowait = nowait
                                                                                                                                    -        self._lateral = lateral
                                                                                                                                    -
                                                                                                                                    -        self._distinct = self._simple_distinct = None
                                                                                                                                    -        if distinct:
                                                                                                                                    -            if isinstance(distinct, bool):
                                                                                                                                    -                self._simple_distinct = distinct
                                                                                                                                    -            else:
                                                                                                                                    -                self._distinct = distinct
                                                                                                                                    -
                                                                                                                                    -        self._cursor_wrapper = None
                                                                                                                                    -
                                                                                                                                    -    def clone(self):
                                                                                                                                    -        clone = super(Select, self).clone()
                                                                                                                                    -        if clone._from_list:
                                                                                                                                    -            clone._from_list = list(clone._from_list)
                                                                                                                                    -        return clone
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def columns(self, *columns, **kwargs):
                                                                                                                                    -        self._returning = columns
                                                                                                                                    -    select = columns
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def select_extend(self, *columns):
                                                                                                                                    -        self._returning = tuple(self._returning) + columns
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def from_(self, *sources):
                                                                                                                                    -        self._from_list = list(sources)
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def join(self, dest, join_type=JOIN.INNER, on=None):
                                                                                                                                    -        if not self._from_list:
                                                                                                                                    -            raise ValueError('No sources to join on.')
                                                                                                                                    -        item = self._from_list.pop()
                                                                                                                                    -        self._from_list.append(Join(item, dest, join_type, on))
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def group_by(self, *columns):
                                                                                                                                    -        grouping = []
                                                                                                                                    -        for column in columns:
                                                                                                                                    -            if isinstance(column, Table):
                                                                                                                                    -                if not column._columns:
                                                                                                                                    -                    raise ValueError('Cannot pass a table to group_by() that '
                                                                                                                                    -                                     'does not have columns explicitly '
                                                                                                                                    -                                     'declared.')
                                                                                                                                    -                grouping.extend([getattr(column, col_name)
                                                                                                                                    -                                 for col_name in column._columns])
                                                                                                                                    -            else:
                                                                                                                                    -                grouping.append(column)
                                                                                                                                    -        self._group_by = grouping
                                                                                                                                    -
                                                                                                                                    -    def group_by_extend(self, *values):
                                                                                                                                    -        """@Node.copy used from group_by() call"""
                                                                                                                                    -        group_by = tuple(self._group_by or ()) + values
                                                                                                                                    -        return self.group_by(*group_by)
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def having(self, *expressions):
                                                                                                                                    -        if self._having is not None:
                                                                                                                                    -            expressions = (self._having,) + expressions
                                                                                                                                    -        self._having = reduce(operator.and_, expressions)
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def distinct(self, *columns):
                                                                                                                                    -        if len(columns) == 1 and (columns[0] is True or columns[0] is False):
                                                                                                                                    -            self._simple_distinct = columns[0]
                                                                                                                                    -        else:
                                                                                                                                    -            self._simple_distinct = False
                                                                                                                                    -            self._distinct = columns
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def window(self, *windows):
                                                                                                                                    -        self._windows = windows if windows else None
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def for_update(self, for_update=True, of=None, nowait=None):
                                                                                                                                    -        if not for_update and (of is not None or nowait):
                                                                                                                                    -            for_update = True
                                                                                                                                    -        self._for_update = for_update
                                                                                                                                    -        self._for_update_of = of
                                                                                                                                    -        self._for_update_nowait = nowait
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def lateral(self, lateral=True):
                                                                                                                                    -        self._lateral = lateral
                                                                                                                                    -
                                                                                                                                    -    def _get_query_key(self):
                                                                                                                                    -        return self._alias
                                                                                                                                    -
                                                                                                                                    -    def __sql_selection__(self, ctx, is_subquery=False):
                                                                                                                                    -        return ctx.sql(CommaNodeList(self._returning))
                                                                                                                                    -
                                                                                                                                    -    def __sql__(self, ctx):
                                                                                                                                    -        if ctx.scope == SCOPE_COLUMN:
                                                                                                                                    -            return self.apply_column(ctx)
                                                                                                                                    -
                                                                                                                                    -        if self._lateral and ctx.scope == SCOPE_SOURCE:
                                                                                                                                    -            ctx.literal('LATERAL ')
                                                                                                                                    -
                                                                                                                                    -        is_subquery = ctx.subquery
                                                                                                                                    -        state = {
                                                                                                                                    -            'converter': None,
                                                                                                                                    -            'in_function': False,
                                                                                                                                    -            'parentheses': is_subquery or (ctx.scope == SCOPE_SOURCE),
                                                                                                                                    -            'subquery': True,
                                                                                                                                    -        }
                                                                                                                                    -        if ctx.state.in_function and ctx.state.function_arg_count == 1:
                                                                                                                                    -            state['parentheses'] = False
                                                                                                                                    -
                                                                                                                                    -        with ctx.scope_normal(**state):
                                                                                                                                    -            # Defer calling parent SQL until here. This ensures that any CTEs
                                                                                                                                    -            # for this query will be properly nested if this query is a
                                                                                                                                    -            # sub-select or is used in an expression. See GH#1809 for example.
                                                                                                                                    -            super(Select, self).__sql__(ctx)
                                                                                                                                    -
                                                                                                                                    -            ctx.literal('SELECT ')
                                                                                                                                    -            if self._simple_distinct or self._distinct is not None:
                                                                                                                                    -                ctx.literal('DISTINCT ')
                                                                                                                                    -                if self._distinct:
                                                                                                                                    -                    (ctx
                                                                                                                                    -                     .literal('ON ')
                                                                                                                                    -                     .sql(EnclosedNodeList(self._distinct))
                                                                                                                                    -                     .literal(' '))
                                                                                                                                    -
                                                                                                                                    -            with ctx.scope_source():
                                                                                                                                    -                ctx = self.__sql_selection__(ctx, is_subquery)
                                                                                                                                    -
                                                                                                                                    -            if self._from_list:
                                                                                                                                    -                with ctx.scope_source(parentheses=False):
                                                                                                                                    -                    ctx.literal(' FROM ').sql(CommaNodeList(self._from_list))
                                                                                                                                    -
                                                                                                                                    -            if self._where is not None:
                                                                                                                                    -                ctx.literal(' WHERE ').sql(self._where)
                                                                                                                                    -
                                                                                                                                    -            if self._group_by:
                                                                                                                                    -                ctx.literal(' GROUP BY ').sql(CommaNodeList(self._group_by))
                                                                                                                                    -
                                                                                                                                    -            if self._having is not None:
                                                                                                                                    -                ctx.literal(' HAVING ').sql(self._having)
                                                                                                                                    -
                                                                                                                                    -            if self._windows is not None:
                                                                                                                                    -                ctx.literal(' WINDOW ')
                                                                                                                                    -                ctx.sql(CommaNodeList(self._windows))
                                                                                                                                    -
                                                                                                                                    -            # Apply ORDER BY, LIMIT, OFFSET.
                                                                                                                                    -            self._apply_ordering(ctx)
                                                                                                                                    -
                                                                                                                                    -            if self._for_update:
                                                                                                                                    -                if not ctx.state.for_update:
                                                                                                                                    -                    raise ValueError('FOR UPDATE specified but not supported '
                                                                                                                                    -                                     'by database.')
                                                                                                                                    -                ctx.literal(' ')
                                                                                                                                    -                ctx.sql(ForUpdate(self._for_update, self._for_update_of,
                                                                                                                                    -                                  self._for_update_nowait))
                                                                                                                                    -
                                                                                                                                    -        # If the subquery is inside a function -or- we are evaluating a
                                                                                                                                    -        # subquery on either side of an expression w/o an explicit alias, do
                                                                                                                                    -        # not generate an alias + AS clause.
                                                                                                                                    -        if ctx.state.in_function or (ctx.state.in_expr and
                                                                                                                                    -                                     self._alias is None):
                                                                                                                                    -            return ctx
                                                                                                                                    -
                                                                                                                                    -        return self.apply_alias(ctx)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class _WriteQuery(Query):
                                                                                                                                    -    def __init__(self, table, returning=None, **kwargs):
                                                                                                                                    -        self.table = table
                                                                                                                                    -        self._returning = returning
                                                                                                                                    -        self._return_cursor = True if returning else False
                                                                                                                                    -        super(_WriteQuery, self).__init__(**kwargs)
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def returning(self, *returning):
                                                                                                                                    -        self._returning = returning
                                                                                                                                    -        self._return_cursor = True if returning else False
                                                                                                                                    -
                                                                                                                                    -    def apply_returning(self, ctx):
                                                                                                                                    -        if self._returning:
                                                                                                                                    -            with ctx.scope_source():
                                                                                                                                    -                ctx.literal(' RETURNING ').sql(CommaNodeList(self._returning))
                                                                                                                                    -        return ctx
                                                                                                                                    -
                                                                                                                                    -    def _execute(self, database):
                                                                                                                                    -        if self._returning:
                                                                                                                                    -            cursor = self.execute_returning(database)
                                                                                                                                    -        else:
                                                                                                                                    -            cursor = database.execute(self)
                                                                                                                                    -        return self.handle_result(database, cursor)
                                                                                                                                    -
                                                                                                                                    -    def execute_returning(self, database):
                                                                                                                                    -        if self._cursor_wrapper is None:
                                                                                                                                    -            cursor = database.execute(self)
                                                                                                                                    -            self._cursor_wrapper = self._get_cursor_wrapper(cursor)
                                                                                                                                    -        return self._cursor_wrapper
                                                                                                                                    -
                                                                                                                                    -    def handle_result(self, database, cursor):
                                                                                                                                    -        if self._return_cursor:
                                                                                                                                    -            return cursor
                                                                                                                                    -        return database.rows_affected(cursor)
                                                                                                                                    -
                                                                                                                                    -    def _set_table_alias(self, ctx):
                                                                                                                                    -        ctx.alias_manager[self.table] = self.table.__name__
                                                                                                                                    -
                                                                                                                                    -    def __sql__(self, ctx):
                                                                                                                                    -        super(_WriteQuery, self).__sql__(ctx)
                                                                                                                                    -        # We explicitly set the table alias to the table's name, which ensures
                                                                                                                                    -        # that if a sub-select references a column on the outer table, we won't
                                                                                                                                    -        # assign it a new alias (e.g. t2) but will refer to it as table.column.
                                                                                                                                    -        self._set_table_alias(ctx)
                                                                                                                                    -        return ctx
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class Update(_WriteQuery):
                                                                                                                                    -    def __init__(self, table, update=None, **kwargs):
                                                                                                                                    -        super(Update, self).__init__(table, **kwargs)
                                                                                                                                    -        self._update = update
                                                                                                                                    -        self._from = None
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def from_(self, *sources):
                                                                                                                                    -        self._from = sources
                                                                                                                                    -
                                                                                                                                    -    def __sql__(self, ctx):
                                                                                                                                    -        super(Update, self).__sql__(ctx)
                                                                                                                                    -
                                                                                                                                    -        with ctx.scope_values(subquery=True):
                                                                                                                                    -            ctx.literal('UPDATE ')
                                                                                                                                    -
                                                                                                                                    -            expressions = []
                                                                                                                                    -            for k, v in sorted(self._update.items(), key=ctx.column_sort_key):
                                                                                                                                    -                if not isinstance(v, Node):
                                                                                                                                    -                    if isinstance(k, Field):
                                                                                                                                    -                        v = k.to_value(v)
                                                                                                                                    -                    else:
                                                                                                                                    -                        v = Value(v, unpack=False)
                                                                                                                                    -                if not isinstance(v, Value):
                                                                                                                                    -                    v = qualify_names(v)
                                                                                                                                    -                expressions.append(NodeList((k, SQL('='), v)))
                                                                                                                                    -
                                                                                                                                    -            (ctx
                                                                                                                                    -             .sql(self.table)
                                                                                                                                    -             .literal(' SET ')
                                                                                                                                    -             .sql(CommaNodeList(expressions)))
                                                                                                                                    -
                                                                                                                                    -            if self._from:
                                                                                                                                    -                with ctx.scope_source(parentheses=False):
                                                                                                                                    -                    ctx.literal(' FROM ').sql(CommaNodeList(self._from))
                                                                                                                                    -
                                                                                                                                    -            if self._where:
                                                                                                                                    -                with ctx.scope_normal():
                                                                                                                                    -                    ctx.literal(' WHERE ').sql(self._where)
                                                                                                                                    -            self._apply_ordering(ctx)
                                                                                                                                    -            return self.apply_returning(ctx)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class Insert(_WriteQuery):
                                                                                                                                    -    SIMPLE = 0
                                                                                                                                    -    QUERY = 1
                                                                                                                                    -    MULTI = 2
                                                                                                                                    -    class DefaultValuesException(Exception): pass
                                                                                                                                    -
                                                                                                                                    -    def __init__(self, table, insert=None, columns=None, on_conflict=None,
                                                                                                                                    -                 **kwargs):
                                                                                                                                    -        super(Insert, self).__init__(table, **kwargs)
                                                                                                                                    -        self._insert = insert
                                                                                                                                    -        self._columns = columns
                                                                                                                                    -        self._on_conflict = on_conflict
                                                                                                                                    -        self._query_type = None
                                                                                                                                    -
                                                                                                                                    -    def where(self, *expressions):
                                                                                                                                    -        raise NotImplementedError('INSERT queries cannot have a WHERE clause.')
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def on_conflict_ignore(self, ignore=True):
                                                                                                                                    -        self._on_conflict = OnConflict('IGNORE') if ignore else None
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def on_conflict_replace(self, replace=True):
                                                                                                                                    -        self._on_conflict = OnConflict('REPLACE') if replace else None
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def on_conflict(self, *args, **kwargs):
                                                                                                                                    -        self._on_conflict = (OnConflict(*args, **kwargs) if (args or kwargs)
                                                                                                                                    -                             else None)
                                                                                                                                    -
                                                                                                                                    -    def _simple_insert(self, ctx):
                                                                                                                                    -        if not self._insert:
                                                                                                                                    -            raise self.DefaultValuesException('Error: no data to insert.')
                                                                                                                                    -        return self._generate_insert((self._insert,), ctx)
                                                                                                                                    -
                                                                                                                                    -    def get_default_data(self):
                                                                                                                                    -        return {}
                                                                                                                                    -
                                                                                                                                    -    def get_default_columns(self):
                                                                                                                                    -        if self.table._columns:
                                                                                                                                    -            return [getattr(self.table, col) for col in self.table._columns
                                                                                                                                    -                    if col != self.table._primary_key]
                                                                                                                                    -
                                                                                                                                    -    def _generate_insert(self, insert, ctx):
                                                                                                                                    -        rows_iter = iter(insert)
                                                                                                                                    -        columns = self._columns
                                                                                                                                    -
                                                                                                                                    -        # Load and organize column defaults (if provided).
                                                                                                                                    -        defaults = self.get_default_data()
                                                                                                                                    -
                                                                                                                                    -        # First figure out what columns are being inserted (if they weren't
                                                                                                                                    -        # specified explicitly). Resulting columns are normalized and ordered.
                                                                                                                                    -        if not columns:
                                                                                                                                    -            try:
                                                                                                                                    -                row = next(rows_iter)
                                                                                                                                    -            except StopIteration:
                                                                                                                                    -                raise self.DefaultValuesException('Error: no rows to insert.')
                                                                                                                                    -
                                                                                                                                    -            if not isinstance(row, Mapping):
                                                                                                                                    -                columns = self.get_default_columns()
                                                                                                                                    -                if columns is None:
                                                                                                                                    -                    raise ValueError('Bulk insert must specify columns.')
                                                                                                                                    -            else:
                                                                                                                                    -                # Infer column names from the dict of data being inserted.
                                                                                                                                    -                accum = []
                                                                                                                                    -                for column in row:
                                                                                                                                    -                    if isinstance(column, basestring):
                                                                                                                                    -                        column = getattr(self.table, column)
                                                                                                                                    -                    accum.append(column)
                                                                                                                                    -
                                                                                                                                    -                # Add any columns present in the default data that are not
                                                                                                                                    -                # accounted for by the dictionary of row data.
                                                                                                                                    -                column_set = set(accum)
                                                                                                                                    -                for col in (set(defaults) - column_set):
                                                                                                                                    -                    accum.append(col)
                                                                                                                                    -
                                                                                                                                    -                columns = sorted(accum, key=lambda obj: obj.get_sort_key(ctx))
                                                                                                                                    -            rows_iter = itertools.chain(iter((row,)), rows_iter)
                                                                                                                                    -        else:
                                                                                                                                    -            clean_columns = []
                                                                                                                                    -            seen = set()
                                                                                                                                    -            for column in columns:
                                                                                                                                    -                if isinstance(column, basestring):
                                                                                                                                    -                    column_obj = getattr(self.table, column)
                                                                                                                                    -                else:
                                                                                                                                    -                    column_obj = column
                                                                                                                                    -                clean_columns.append(column_obj)
                                                                                                                                    -                seen.add(column_obj)
                                                                                                                                    -
                                                                                                                                    -            columns = clean_columns
                                                                                                                                    -            for col in sorted(defaults, key=lambda obj: obj.get_sort_key(ctx)):
                                                                                                                                    -                if col not in seen:
                                                                                                                                    -                    columns.append(col)
                                                                                                                                    -
                                                                                                                                    -        value_lookups = {}
                                                                                                                                    -        for column in columns:
                                                                                                                                    -            lookups = [column, column.name]
                                                                                                                                    -            if isinstance(column, Field) and column.name != column.column_name:
                                                                                                                                    -                lookups.append(column.column_name)
                                                                                                                                    -            value_lookups[column] = lookups
                                                                                                                                    -
                                                                                                                                    -        ctx.sql(EnclosedNodeList(columns)).literal(' VALUES ')
                                                                                                                                    -        columns_converters = [
                                                                                                                                    -            (column, column.db_value if isinstance(column, Field) else None)
                                                                                                                                    -            for column in columns]
                                                                                                                                    -
                                                                                                                                    -        all_values = []
                                                                                                                                    -        for row in rows_iter:
                                                                                                                                    -            values = []
                                                                                                                                    -            is_dict = isinstance(row, Mapping)
                                                                                                                                    -            for i, (column, converter) in enumerate(columns_converters):
                                                                                                                                    -                try:
                                                                                                                                    -                    if is_dict:
                                                                                                                                    -                        # The logic is a bit convoluted, but in order to be
                                                                                                                                    -                        # flexible in what we accept (dict keyed by
                                                                                                                                    -                        # column/field, field name, or underlying column name),
                                                                                                                                    -                        # we try accessing the row data dict using each
                                                                                                                                    -                        # possible key. If no match is found, throw an error.
                                                                                                                                    -                        for lookup in value_lookups[column]:
                                                                                                                                    -                            try:
                                                                                                                                    -                                val = row[lookup]
                                                                                                                                    -                            except KeyError: pass
                                                                                                                                    -                            else: break
                                                                                                                                    -                        else:
                                                                                                                                    -                            raise KeyError
                                                                                                                                    -                    else:
                                                                                                                                    -                        val = row[i]
                                                                                                                                    -                except (KeyError, IndexError):
                                                                                                                                    -                    if column in defaults:
                                                                                                                                    -                        val = defaults[column]
                                                                                                                                    -                        if callable_(val):
                                                                                                                                    -                            val = val()
                                                                                                                                    -                    else:
                                                                                                                                    -                        raise ValueError('Missing value for %s.' % column.name)
                                                                                                                                    -
                                                                                                                                    -                if not isinstance(val, Node):
                                                                                                                                    -                    val = Value(val, converter=converter, unpack=False)
                                                                                                                                    -                values.append(val)
                                                                                                                                    -
                                                                                                                                    -            all_values.append(EnclosedNodeList(values))
                                                                                                                                    -
                                                                                                                                    -        if not all_values:
                                                                                                                                    -            raise self.DefaultValuesException('Error: no data to insert.')
                                                                                                                                    -
                                                                                                                                    -        with ctx.scope_values(subquery=True):
                                                                                                                                    -            return ctx.sql(CommaNodeList(all_values))
                                                                                                                                    -
                                                                                                                                    -    def _query_insert(self, ctx):
                                                                                                                                    -        return (ctx
                                                                                                                                    -                .sql(EnclosedNodeList(self._columns))
                                                                                                                                    -                .literal(' ')
                                                                                                                                    -                .sql(self._insert))
                                                                                                                                    -
                                                                                                                                    -    def _default_values(self, ctx):
                                                                                                                                    -        if not self._database:
                                                                                                                                    -            return ctx.literal('DEFAULT VALUES')
                                                                                                                                    -        return self._database.default_values_insert(ctx)
                                                                                                                                    -
                                                                                                                                    -    def __sql__(self, ctx):
                                                                                                                                    -        super(Insert, self).__sql__(ctx)
                                                                                                                                    -        with ctx.scope_values():
                                                                                                                                    -            stmt = None
                                                                                                                                    -            if self._on_conflict is not None:
                                                                                                                                    -                stmt = self._on_conflict.get_conflict_statement(ctx, self)
                                                                                                                                    -
                                                                                                                                    -            (ctx
                                                                                                                                    -             .sql(stmt or SQL('INSERT'))
                                                                                                                                    -             .literal(' INTO ')
                                                                                                                                    -             .sql(self.table)
                                                                                                                                    -             .literal(' '))
                                                                                                                                    -
                                                                                                                                    -            if isinstance(self._insert, Mapping) and not self._columns:
                                                                                                                                    -                try:
                                                                                                                                    -                    self._simple_insert(ctx)
                                                                                                                                    -                except self.DefaultValuesException:
                                                                                                                                    -                    self._default_values(ctx)
                                                                                                                                    -                self._query_type = Insert.SIMPLE
                                                                                                                                    -            elif isinstance(self._insert, (SelectQuery, SQL)):
                                                                                                                                    -                self._query_insert(ctx)
                                                                                                                                    -                self._query_type = Insert.QUERY
                                                                                                                                    -            else:
                                                                                                                                    -                self._generate_insert(self._insert, ctx)
                                                                                                                                    -                self._query_type = Insert.MULTI
                                                                                                                                    -
                                                                                                                                    -            if self._on_conflict is not None:
                                                                                                                                    -                update = self._on_conflict.get_conflict_update(ctx, self)
                                                                                                                                    -                if update is not None:
                                                                                                                                    -                    ctx.literal(' ').sql(update)
                                                                                                                                    -
                                                                                                                                    -            return self.apply_returning(ctx)
                                                                                                                                    -
                                                                                                                                    -    def _execute(self, database):
                                                                                                                                    -        if self._returning is None and database.returning_clause \
                                                                                                                                    -           and self.table._primary_key:
                                                                                                                                    -            self._returning = (self.table._primary_key,)
                                                                                                                                    -        try:
                                                                                                                                    -            return super(Insert, self)._execute(database)
                                                                                                                                    -        except self.DefaultValuesException:
                                                                                                                                    -            pass
                                                                                                                                    -
                                                                                                                                    -    def handle_result(self, database, cursor):
                                                                                                                                    -        if self._return_cursor:
                                                                                                                                    -            return cursor
                                                                                                                                    -        if self._query_type != Insert.SIMPLE and not self._returning:
                                                                                                                                    -            return database.rows_affected(cursor)
                                                                                                                                    -        return database.last_insert_id(cursor, self._query_type)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class Delete(_WriteQuery):
                                                                                                                                    -    def __sql__(self, ctx):
                                                                                                                                    -        super(Delete, self).__sql__(ctx)
                                                                                                                                    -
                                                                                                                                    -        with ctx.scope_values(subquery=True):
                                                                                                                                    -            ctx.literal('DELETE FROM ').sql(self.table)
                                                                                                                                    -            if self._where is not None:
                                                                                                                                    -                with ctx.scope_normal():
                                                                                                                                    -                    ctx.literal(' WHERE ').sql(self._where)
                                                                                                                                    -
                                                                                                                                    -            self._apply_ordering(ctx)
                                                                                                                                    -            return self.apply_returning(ctx)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class Index(Node):
                                                                                                                                    -    def __init__(self, name, table, expressions, unique=False, safe=False,
                                                                                                                                    -                 where=None, using=None):
                                                                                                                                    -        self._name = name
                                                                                                                                    -        self._table = Entity(table) if not isinstance(table, Table) else table
                                                                                                                                    -        self._expressions = expressions
                                                                                                                                    -        self._where = where
                                                                                                                                    -        self._unique = unique
                                                                                                                                    -        self._safe = safe
                                                                                                                                    -        self._using = using
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def safe(self, _safe=True):
                                                                                                                                    -        self._safe = _safe
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def where(self, *expressions):
                                                                                                                                    -        if self._where is not None:
                                                                                                                                    -            expressions = (self._where,) + expressions
                                                                                                                                    -        self._where = reduce(operator.and_, expressions)
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def using(self, _using=None):
                                                                                                                                    -        self._using = _using
                                                                                                                                    -
                                                                                                                                    -    def __sql__(self, ctx):
                                                                                                                                    -        statement = 'CREATE UNIQUE INDEX ' if self._unique else 'CREATE INDEX '
                                                                                                                                    -        with ctx.scope_values(subquery=True):
                                                                                                                                    -            ctx.literal(statement)
                                                                                                                                    -            if self._safe:
                                                                                                                                    -                ctx.literal('IF NOT EXISTS ')
                                                                                                                                    -
                                                                                                                                    -            # Sqlite uses CREATE INDEX <schema>.<name> ON <table>, whereas most
                                                                                                                                    -            # others use: CREATE INDEX <name> ON <schema>.<table>.
                                                                                                                                    -            if ctx.state.index_schema_prefix and \
                                                                                                                                    -               isinstance(self._table, Table) and self._table._schema:
                                                                                                                                    -                index_name = Entity(self._table._schema, self._name)
                                                                                                                                    -                table_name = Entity(self._table.__name__)
                                                                                                                                    -            else:
                                                                                                                                    -                index_name = Entity(self._name)
                                                                                                                                    -                table_name = self._table
                                                                                                                                    -
                                                                                                                                    -            ctx.sql(index_name)
                                                                                                                                    -            if self._using is not None and \
                                                                                                                                    -               ctx.state.index_using_precedes_table:
                                                                                                                                    -                ctx.literal(' USING %s' % self._using)  # MySQL style.
                                                                                                                                    -
                                                                                                                                    -            (ctx
                                                                                                                                    -             .literal(' ON ')
                                                                                                                                    -             .sql(table_name)
                                                                                                                                    -             .literal(' '))
                                                                                                                                    -
                                                                                                                                    -            if self._using is not None and not \
                                                                                                                                    -               ctx.state.index_using_precedes_table:
                                                                                                                                    -                ctx.literal('USING %s ' % self._using)  # Postgres/default.
                                                                                                                                    -
                                                                                                                                    -            ctx.sql(EnclosedNodeList([
                                                                                                                                    -                SQL(expr) if isinstance(expr, basestring) else expr
                                                                                                                                    -                for expr in self._expressions]))
                                                                                                                                    -            if self._where is not None:
                                                                                                                                    -                ctx.literal(' WHERE ').sql(self._where)
                                                                                                                                    -
                                                                                                                                    -        return ctx
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class ModelIndex(Index):
                                                                                                                                    -    def __init__(self, model, fields, unique=False, safe=True, where=None,
                                                                                                                                    -                 using=None, name=None):
                                                                                                                                    -        self._model = model
                                                                                                                                    -        if name is None:
                                                                                                                                    -            name = self._generate_name_from_fields(model, fields)
                                                                                                                                    -        if using is None:
                                                                                                                                    -            for field in fields:
                                                                                                                                    -                if isinstance(field, Field) and hasattr(field, 'index_type'):
                                                                                                                                    -                    using = field.index_type
                                                                                                                                    -        super(ModelIndex, self).__init__(
                                                                                                                                    -            name=name,
                                                                                                                                    -            table=model._meta.table,
                                                                                                                                    -            expressions=fields,
                                                                                                                                    -            unique=unique,
                                                                                                                                    -            safe=safe,
                                                                                                                                    -            where=where,
                                                                                                                                    -            using=using)
                                                                                                                                    -
                                                                                                                                    -    def _generate_name_from_fields(self, model, fields):
                                                                                                                                    -        accum = []
                                                                                                                                    -        for field in fields:
                                                                                                                                    -            if isinstance(field, basestring):
                                                                                                                                    -                accum.append(field.split()[0])
                                                                                                                                    -            else:
                                                                                                                                    -                if isinstance(field, Node) and not isinstance(field, Field):
                                                                                                                                    -                    field = field.unwrap()
                                                                                                                                    -                if isinstance(field, Field):
                                                                                                                                    -                    accum.append(field.column_name)
                                                                                                                                    -
                                                                                                                                    -        if not accum:
                                                                                                                                    -            raise ValueError('Unable to generate a name for the index, please '
                                                                                                                                    -                             'explicitly specify a name.')
                                                                                                                                    -
                                                                                                                                    -        clean_field_names = re.sub(r'[^\w]+', '', '_'.join(accum))
                                                                                                                                    -        meta = model._meta
                                                                                                                                    -        prefix = meta.name if meta.legacy_table_names else meta.table_name
                                                                                                                                    -        return _truncate_constraint_name('_'.join((prefix, clean_field_names)))
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -def _truncate_constraint_name(constraint, maxlen=64):
                                                                                                                                    -    if len(constraint) > maxlen:
                                                                                                                                    -        name_hash = hashlib.md5(constraint.encode('utf-8')).hexdigest()
                                                                                                                                    -        constraint = '%s_%s' % (constraint[:(maxlen - 8)], name_hash[:7])
                                                                                                                                    -    return constraint
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -# DB-API 2.0 EXCEPTIONS.
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class PeeweeException(Exception):
                                                                                                                                    -    def __init__(self, *args):
                                                                                                                                    -        if args and isinstance(args[0], Exception):
                                                                                                                                    -            self.orig, args = args[0], args[1:]
                                                                                                                                    -        super(PeeweeException, self).__init__(*args)
                                                                                                                                    -class ImproperlyConfigured(PeeweeException): pass
                                                                                                                                    -class DatabaseError(PeeweeException): pass
                                                                                                                                    -class DataError(DatabaseError): pass
                                                                                                                                    -class IntegrityError(DatabaseError): pass
                                                                                                                                    -class InterfaceError(PeeweeException): pass
                                                                                                                                    -class InternalError(DatabaseError): pass
                                                                                                                                    -class NotSupportedError(DatabaseError): pass
                                                                                                                                    -class OperationalError(DatabaseError): pass
                                                                                                                                    -class ProgrammingError(DatabaseError): pass
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class ExceptionWrapper(object):
                                                                                                                                    -    __slots__ = ('exceptions',)
                                                                                                                                    -    def __init__(self, exceptions):
                                                                                                                                    -        self.exceptions = exceptions
                                                                                                                                    -    def __enter__(self): pass
                                                                                                                                    -    def __exit__(self, exc_type, exc_value, traceback):
                                                                                                                                    -        if exc_type is None:
                                                                                                                                    -            return
                                                                                                                                    -        # psycopg2.8 shits out a million cute error types. Try to catch em all.
                                                                                                                                    -        if pg_errors is not None and exc_type.__name__ not in self.exceptions \
                                                                                                                                    -           and issubclass(exc_type, pg_errors.Error):
                                                                                                                                    -            exc_type = exc_type.__bases__[0]
                                                                                                                                    -        if exc_type.__name__ in self.exceptions:
                                                                                                                                    -            new_type = self.exceptions[exc_type.__name__]
                                                                                                                                    -            exc_args = exc_value.args
                                                                                                                                    -            reraise(new_type, new_type(exc_value, *exc_args), traceback)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -EXCEPTIONS = {
                                                                                                                                    -    'ConstraintError': IntegrityError,
                                                                                                                                    -    'DatabaseError': DatabaseError,
                                                                                                                                    -    'DataError': DataError,
                                                                                                                                    -    'IntegrityError': IntegrityError,
                                                                                                                                    -    'InterfaceError': InterfaceError,
                                                                                                                                    -    'InternalError': InternalError,
                                                                                                                                    -    'NotSupportedError': NotSupportedError,
                                                                                                                                    -    'OperationalError': OperationalError,
                                                                                                                                    -    'ProgrammingError': ProgrammingError,
                                                                                                                                    -    'TransactionRollbackError': OperationalError}
                                                                                                                                    -
                                                                                                                                    -__exception_wrapper__ = ExceptionWrapper(EXCEPTIONS)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -# DATABASE INTERFACE AND CONNECTION MANAGEMENT.
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -IndexMetadata = collections.namedtuple(
                                                                                                                                    -    'IndexMetadata',
                                                                                                                                    -    ('name', 'sql', 'columns', 'unique', 'table'))
                                                                                                                                    -ColumnMetadata = collections.namedtuple(
                                                                                                                                    -    'ColumnMetadata',
                                                                                                                                    -    ('name', 'data_type', 'null', 'primary_key', 'table', 'default'))
                                                                                                                                    -ForeignKeyMetadata = collections.namedtuple(
                                                                                                                                    -    'ForeignKeyMetadata',
                                                                                                                                    -    ('column', 'dest_table', 'dest_column', 'table'))
                                                                                                                                    -ViewMetadata = collections.namedtuple('ViewMetadata', ('name', 'sql'))
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class _ConnectionState(object):
                                                                                                                                    -    def __init__(self, **kwargs):
                                                                                                                                    -        super(_ConnectionState, self).__init__(**kwargs)
                                                                                                                                    -        self.reset()
                                                                                                                                    -
                                                                                                                                    -    def reset(self):
                                                                                                                                    -        self.closed = True
                                                                                                                                    -        self.conn = None
                                                                                                                                    -        self.ctx = []
                                                                                                                                    -        self.transactions = []
                                                                                                                                    -
                                                                                                                                    -    def set_connection(self, conn):
                                                                                                                                    -        self.conn = conn
                                                                                                                                    -        self.closed = False
                                                                                                                                    -        self.ctx = []
                                                                                                                                    -        self.transactions = []
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class _ConnectionLocal(_ConnectionState, threading.local): pass
                                                                                                                                    -class _NoopLock(object):
                                                                                                                                    -    __slots__ = ()
                                                                                                                                    -    def __enter__(self): return self
                                                                                                                                    -    def __exit__(self, exc_type, exc_val, exc_tb): pass
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class ConnectionContext(_callable_context_manager):
                                                                                                                                    -    __slots__ = ('db',)
                                                                                                                                    -    def __init__(self, db): self.db = db
                                                                                                                                    -    def __enter__(self):
                                                                                                                                    -        if self.db.is_closed():
                                                                                                                                    -            self.db.connect()
                                                                                                                                    -    def __exit__(self, exc_type, exc_val, exc_tb): self.db.close()
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class Database(_callable_context_manager):
                                                                                                                                    -    context_class = Context
                                                                                                                                    -    field_types = {}
                                                                                                                                    -    operations = {}
                                                                                                                                    -    param = '?'
                                                                                                                                    -    quote = '""'
                                                                                                                                    -    server_version = None
                                                                                                                                    -
                                                                                                                                    -    # Feature toggles.
                                                                                                                                    -    commit_select = False
                                                                                                                                    -    compound_select_parentheses = CSQ_PARENTHESES_NEVER
                                                                                                                                    -    for_update = False
                                                                                                                                    -    index_schema_prefix = False
                                                                                                                                    -    index_using_precedes_table = False
                                                                                                                                    -    limit_max = None
                                                                                                                                    -    nulls_ordering = False
                                                                                                                                    -    returning_clause = False
                                                                                                                                    -    safe_create_index = True
                                                                                                                                    -    safe_drop_index = True
                                                                                                                                    -    sequences = False
                                                                                                                                    -    truncate_table = True
                                                                                                                                    -
                                                                                                                                    -    def __init__(self, database, thread_safe=True, autorollback=False,
                                                                                                                                    -                 field_types=None, operations=None, autocommit=None,
                                                                                                                                    -                 autoconnect=True, **kwargs):
                                                                                                                                    -        self._field_types = merge_dict(FIELD, self.field_types)
                                                                                                                                    -        self._operations = merge_dict(OP, self.operations)
                                                                                                                                    -        if field_types:
                                                                                                                                    -            self._field_types.update(field_types)
                                                                                                                                    -        if operations:
                                                                                                                                    -            self._operations.update(operations)
                                                                                                                                    -
                                                                                                                                    -        self.autoconnect = autoconnect
                                                                                                                                    -        self.autorollback = autorollback
                                                                                                                                    -        self.thread_safe = thread_safe
                                                                                                                                    -        if thread_safe:
                                                                                                                                    -            self._state = _ConnectionLocal()
                                                                                                                                    -            self._lock = threading.RLock()
                                                                                                                                    -        else:
                                                                                                                                    -            self._state = _ConnectionState()
                                                                                                                                    -            self._lock = _NoopLock()
                                                                                                                                    -
                                                                                                                                    -        if autocommit is not None:
                                                                                                                                    -            __deprecated__('Peewee no longer uses the "autocommit" option, as '
                                                                                                                                    -                           'the semantics now require it to always be True. '
                                                                                                                                    -                           'Because some database-drivers also use the '
                                                                                                                                    -                           '"autocommit" parameter, you are receiving a '
                                                                                                                                    -                           'warning so you may update your code and remove '
                                                                                                                                    -                           'the parameter, as in the future, specifying '
                                                                                                                                    -                           'autocommit could impact the behavior of the '
                                                                                                                                    -                           'database driver you are using.')
                                                                                                                                    -
                                                                                                                                    -        self.connect_params = {}
                                                                                                                                    -        self.init(database, **kwargs)
                                                                                                                                    -
                                                                                                                                    -    def init(self, database, **kwargs):
                                                                                                                                    -        if not self.is_closed():
                                                                                                                                    -            self.close()
                                                                                                                                    -        self.database = database
                                                                                                                                    -        self.connect_params.update(kwargs)
                                                                                                                                    -        self.deferred = not bool(database)
                                                                                                                                    -
                                                                                                                                    -    def __enter__(self):
                                                                                                                                    -        if self.is_closed():
                                                                                                                                    -            self.connect()
                                                                                                                                    -        ctx = self.atomic()
                                                                                                                                    -        self._state.ctx.append(ctx)
                                                                                                                                    -        ctx.__enter__()
                                                                                                                                    -        return self
                                                                                                                                    -
                                                                                                                                    -    def __exit__(self, exc_type, exc_val, exc_tb):
                                                                                                                                    -        ctx = self._state.ctx.pop()
                                                                                                                                    -        try:
                                                                                                                                    -            ctx.__exit__(exc_type, exc_val, exc_tb)
                                                                                                                                    -        finally:
                                                                                                                                    -            if not self._state.ctx:
                                                                                                                                    -                self.close()
                                                                                                                                    -
                                                                                                                                    -    def connection_context(self):
                                                                                                                                    -        return ConnectionContext(self)
                                                                                                                                    -
                                                                                                                                    -    def _connect(self):
                                                                                                                                    -        raise NotImplementedError
                                                                                                                                    -
                                                                                                                                    -    def connect(self, reuse_if_open=False):
                                                                                                                                    -        with self._lock:
                                                                                                                                    -            if self.deferred:
                                                                                                                                    -                raise InterfaceError('Error, database must be initialized '
                                                                                                                                    -                                     'before opening a connection.')
                                                                                                                                    -            if not self._state.closed:
                                                                                                                                    -                if reuse_if_open:
                                                                                                                                    -                    return False
                                                                                                                                    -                raise OperationalError('Connection already opened.')
                                                                                                                                    -
                                                                                                                                    -            self._state.reset()
                                                                                                                                    -            with __exception_wrapper__:
                                                                                                                                    -                self._state.set_connection(self._connect())
                                                                                                                                    -                if self.server_version is None:
                                                                                                                                    -                    self._set_server_version(self._state.conn)
                                                                                                                                    -                self._initialize_connection(self._state.conn)
                                                                                                                                    -        return True
                                                                                                                                    -
                                                                                                                                    -    def _initialize_connection(self, conn):
                                                                                                                                    -        pass
                                                                                                                                    -
                                                                                                                                    -    def _set_server_version(self, conn):
                                                                                                                                    -        self.server_version = 0
                                                                                                                                    -
                                                                                                                                    -    def close(self):
                                                                                                                                    -        with self._lock:
                                                                                                                                    -            if self.deferred:
                                                                                                                                    -                raise InterfaceError('Error, database must be initialized '
                                                                                                                                    -                                     'before opening a connection.')
                                                                                                                                    -            if self.in_transaction():
                                                                                                                                    -                raise OperationalError('Attempting to close database while '
                                                                                                                                    -                                       'transaction is open.')
                                                                                                                                    -            is_open = not self._state.closed
                                                                                                                                    -            try:
                                                                                                                                    -                if is_open:
                                                                                                                                    -                    with __exception_wrapper__:
                                                                                                                                    -                        self._close(self._state.conn)
                                                                                                                                    -            finally:
                                                                                                                                    -                self._state.reset()
                                                                                                                                    -            return is_open
                                                                                                                                    -
                                                                                                                                    -    def _close(self, conn):
                                                                                                                                    -        conn.close()
                                                                                                                                    -
                                                                                                                                    -    def is_closed(self):
                                                                                                                                    -        return self._state.closed
                                                                                                                                    -
                                                                                                                                    -    def is_connection_usable(self):
                                                                                                                                    -        return not self._state.closed
                                                                                                                                    -
                                                                                                                                    -    def connection(self):
                                                                                                                                    -        if self.is_closed():
                                                                                                                                    -            self.connect()
                                                                                                                                    -        return self._state.conn
                                                                                                                                    -
                                                                                                                                    -    def cursor(self, commit=None):
                                                                                                                                    -        if self.is_closed():
                                                                                                                                    -            if self.autoconnect:
                                                                                                                                    -                self.connect()
                                                                                                                                    -            else:
                                                                                                                                    -                raise InterfaceError('Error, database connection not opened.')
                                                                                                                                    -        return self._state.conn.cursor()
                                                                                                                                    -
                                                                                                                                    -    def execute_sql(self, sql, params=None, commit=SENTINEL):
                                                                                                                                    -        logger.debug((sql, params))
                                                                                                                                    -        if commit is SENTINEL:
                                                                                                                                    -            if self.in_transaction():
                                                                                                                                    -                commit = False
                                                                                                                                    -            elif self.commit_select:
                                                                                                                                    -                commit = True
                                                                                                                                    -            else:
                                                                                                                                    -                commit = not sql[:6].lower().startswith('select')
                                                                                                                                    -
                                                                                                                                    -        with __exception_wrapper__:
                                                                                                                                    -            cursor = self.cursor(commit)
                                                                                                                                    -            try:
                                                                                                                                    -                cursor.execute(sql, params or ())
                                                                                                                                    -            except Exception:
                                                                                                                                    -                if self.autorollback and not self.in_transaction():
                                                                                                                                    -                    self.rollback()
                                                                                                                                    -                raise
                                                                                                                                    -            else:
                                                                                                                                    -                if commit and not self.in_transaction():
                                                                                                                                    -                    self.commit()
                                                                                                                                    -        return cursor
                                                                                                                                    -
                                                                                                                                    -    def execute(self, query, commit=SENTINEL, **context_options):
                                                                                                                                    -        ctx = self.get_sql_context(**context_options)
                                                                                                                                    -        sql, params = ctx.sql(query).query()
                                                                                                                                    -        return self.execute_sql(sql, params, commit=commit)
                                                                                                                                    -
                                                                                                                                    -    def get_context_options(self):
                                                                                                                                    -        return {
                                                                                                                                    -            'field_types': self._field_types,
                                                                                                                                    -            'operations': self._operations,
                                                                                                                                    -            'param': self.param,
                                                                                                                                    -            'quote': self.quote,
                                                                                                                                    -            'compound_select_parentheses': self.compound_select_parentheses,
                                                                                                                                    -            'conflict_statement': self.conflict_statement,
                                                                                                                                    -            'conflict_update': self.conflict_update,
                                                                                                                                    -            'for_update': self.for_update,
                                                                                                                                    -            'index_schema_prefix': self.index_schema_prefix,
                                                                                                                                    -            'index_using_precedes_table': self.index_using_precedes_table,
                                                                                                                                    -            'limit_max': self.limit_max,
                                                                                                                                    -            'nulls_ordering': self.nulls_ordering,
                                                                                                                                    -        }
                                                                                                                                    -
                                                                                                                                    -    def get_sql_context(self, **context_options):
                                                                                                                                    -        context = self.get_context_options()
                                                                                                                                    -        if context_options:
                                                                                                                                    -            context.update(context_options)
                                                                                                                                    -        return self.context_class(**context)
                                                                                                                                    -
                                                                                                                                    -    def conflict_statement(self, on_conflict, query):
                                                                                                                                    -        raise NotImplementedError
                                                                                                                                    -
                                                                                                                                    -    def conflict_update(self, on_conflict, query):
                                                                                                                                    -        raise NotImplementedError
                                                                                                                                    -
                                                                                                                                    -    def _build_on_conflict_update(self, on_conflict, query):
                                                                                                                                    -        if on_conflict._conflict_target:
                                                                                                                                    -            stmt = SQL('ON CONFLICT')
                                                                                                                                    -            target = EnclosedNodeList([
                                                                                                                                    -                Entity(col) if isinstance(col, basestring) else col
                                                                                                                                    -                for col in on_conflict._conflict_target])
                                                                                                                                    -            if on_conflict._conflict_where is not None:
                                                                                                                                    -                target = NodeList([target, SQL('WHERE'),
                                                                                                                                    -                                   on_conflict._conflict_where])
                                                                                                                                    -        else:
                                                                                                                                    -            stmt = SQL('ON CONFLICT ON CONSTRAINT')
                                                                                                                                    -            target = on_conflict._conflict_constraint
                                                                                                                                    -            if isinstance(target, basestring):
                                                                                                                                    -                target = Entity(target)
                                                                                                                                    -
                                                                                                                                    -        updates = []
                                                                                                                                    -        if on_conflict._preserve:
                                                                                                                                    -            for column in on_conflict._preserve:
                                                                                                                                    -                excluded = NodeList((SQL('EXCLUDED'), ensure_entity(column)),
                                                                                                                                    -                                    glue='.')
                                                                                                                                    -                expression = NodeList((ensure_entity(column), SQL('='),
                                                                                                                                    -                                       excluded))
                                                                                                                                    -                updates.append(expression)
                                                                                                                                    -
                                                                                                                                    -        if on_conflict._update:
                                                                                                                                    -            for k, v in on_conflict._update.items():
                                                                                                                                    -                if not isinstance(v, Node):
                                                                                                                                    -                    # Attempt to resolve string field-names to their respective
                                                                                                                                    -                    # field object, to apply data-type conversions.
                                                                                                                                    -                    if isinstance(k, basestring):
                                                                                                                                    -                        k = getattr(query.table, k)
                                                                                                                                    -                    if isinstance(k, Field):
                                                                                                                                    -                        v = k.to_value(v)
                                                                                                                                    -                    else:
                                                                                                                                    -                        v = Value(v, unpack=False)
                                                                                                                                    -                else:
                                                                                                                                    -                    v = QualifiedNames(v)
                                                                                                                                    -                updates.append(NodeList((ensure_entity(k), SQL('='), v)))
                                                                                                                                    -
                                                                                                                                    -        parts = [stmt, target, SQL('DO UPDATE SET'), CommaNodeList(updates)]
                                                                                                                                    -        if on_conflict._where:
                                                                                                                                    -            parts.extend((SQL('WHERE'), QualifiedNames(on_conflict._where)))
                                                                                                                                    -
                                                                                                                                    -        return NodeList(parts)
                                                                                                                                    -
                                                                                                                                    -    def last_insert_id(self, cursor, query_type=None):
                                                                                                                                    -        return cursor.lastrowid
                                                                                                                                    -
                                                                                                                                    -    def rows_affected(self, cursor):
                                                                                                                                    -        return cursor.rowcount
                                                                                                                                    -
                                                                                                                                    -    def default_values_insert(self, ctx):
                                                                                                                                    -        return ctx.literal('DEFAULT VALUES')
                                                                                                                                    -
                                                                                                                                    -    def session_start(self):
                                                                                                                                    -        with self._lock:
                                                                                                                                    -            return self.transaction().__enter__()
                                                                                                                                    -
                                                                                                                                    -    def session_commit(self):
                                                                                                                                    -        with self._lock:
                                                                                                                                    -            try:
                                                                                                                                    -                txn = self.pop_transaction()
                                                                                                                                    -            except IndexError:
                                                                                                                                    -                return False
                                                                                                                                    -            txn.commit(begin=self.in_transaction())
                                                                                                                                    -            return True
                                                                                                                                    -
                                                                                                                                    -    def session_rollback(self):
                                                                                                                                    -        with self._lock:
                                                                                                                                    -            try:
                                                                                                                                    -                txn = self.pop_transaction()
                                                                                                                                    -            except IndexError:
                                                                                                                                    -                return False
                                                                                                                                    -            txn.rollback(begin=self.in_transaction())
                                                                                                                                    -            return True
                                                                                                                                    -
                                                                                                                                    -    def in_transaction(self):
                                                                                                                                    -        return bool(self._state.transactions)
                                                                                                                                    -
                                                                                                                                    -    def push_transaction(self, transaction):
                                                                                                                                    -        self._state.transactions.append(transaction)
                                                                                                                                    -
                                                                                                                                    -    def pop_transaction(self):
                                                                                                                                    -        return self._state.transactions.pop()
                                                                                                                                    -
                                                                                                                                    -    def transaction_depth(self):
                                                                                                                                    -        return len(self._state.transactions)
                                                                                                                                    -
                                                                                                                                    -    def top_transaction(self):
                                                                                                                                    -        if self._state.transactions:
                                                                                                                                    -            return self._state.transactions[-1]
                                                                                                                                    -
                                                                                                                                    -    def atomic(self, *args, **kwargs):
                                                                                                                                    -        return _atomic(self, *args, **kwargs)
                                                                                                                                    -
                                                                                                                                    -    def manual_commit(self):
                                                                                                                                    -        return _manual(self)
                                                                                                                                    -
                                                                                                                                    -    def transaction(self, *args, **kwargs):
                                                                                                                                    -        return _transaction(self, *args, **kwargs)
                                                                                                                                    -
                                                                                                                                    -    def savepoint(self):
                                                                                                                                    -        return _savepoint(self)
                                                                                                                                    -
                                                                                                                                    -    def begin(self):
                                                                                                                                    -        if self.is_closed():
                                                                                                                                    -            self.connect()
                                                                                                                                    -
                                                                                                                                    -    def commit(self):
                                                                                                                                    -        with __exception_wrapper__:
                                                                                                                                    -            return self._state.conn.commit()
                                                                                                                                    -
                                                                                                                                    -    def rollback(self):
                                                                                                                                    -        with __exception_wrapper__:
                                                                                                                                    -            return self._state.conn.rollback()
                                                                                                                                    -
                                                                                                                                    -    def batch_commit(self, it, n):
                                                                                                                                    -        for group in chunked(it, n):
                                                                                                                                    -            with self.atomic():
                                                                                                                                    -                for obj in group:
                                                                                                                                    -                    yield obj
                                                                                                                                    -
                                                                                                                                    -    def table_exists(self, table_name, schema=None):
                                                                                                                                    -        return table_name in self.get_tables(schema=schema)
                                                                                                                                    -
                                                                                                                                    -    def get_tables(self, schema=None):
                                                                                                                                    -        raise NotImplementedError
                                                                                                                                    -
                                                                                                                                    -    def get_indexes(self, table, schema=None):
                                                                                                                                    -        raise NotImplementedError
                                                                                                                                    -
                                                                                                                                    -    def get_columns(self, table, schema=None):
                                                                                                                                    -        raise NotImplementedError
                                                                                                                                    -
                                                                                                                                    -    def get_primary_keys(self, table, schema=None):
                                                                                                                                    -        raise NotImplementedError
                                                                                                                                    -
                                                                                                                                    -    def get_foreign_keys(self, table, schema=None):
                                                                                                                                    -        raise NotImplementedError
                                                                                                                                    -
                                                                                                                                    -    def sequence_exists(self, seq):
                                                                                                                                    -        raise NotImplementedError
                                                                                                                                    -
                                                                                                                                    -    def create_tables(self, models, **options):
                                                                                                                                    -        for model in sort_models(models):
                                                                                                                                    -            model.create_table(**options)
                                                                                                                                    -
                                                                                                                                    -    def drop_tables(self, models, **kwargs):
                                                                                                                                    -        for model in reversed(sort_models(models)):
                                                                                                                                    -            model.drop_table(**kwargs)
                                                                                                                                    -
                                                                                                                                    -    def extract_date(self, date_part, date_field):
                                                                                                                                    -        raise NotImplementedError
                                                                                                                                    -
                                                                                                                                    -    def truncate_date(self, date_part, date_field):
                                                                                                                                    -        raise NotImplementedError
                                                                                                                                    -
                                                                                                                                    -    def to_timestamp(self, date_field):
                                                                                                                                    -        raise NotImplementedError
                                                                                                                                    -
                                                                                                                                    -    def from_timestamp(self, date_field):
                                                                                                                                    -        raise NotImplementedError
                                                                                                                                    -
                                                                                                                                    -    def random(self):
                                                                                                                                    -        return fn.random()
                                                                                                                                    -
                                                                                                                                    -    def bind(self, models, bind_refs=True, bind_backrefs=True):
                                                                                                                                    -        for model in models:
                                                                                                                                    -            model.bind(self, bind_refs=bind_refs, bind_backrefs=bind_backrefs)
                                                                                                                                    -
                                                                                                                                    -    def bind_ctx(self, models, bind_refs=True, bind_backrefs=True):
                                                                                                                                    -        return _BoundModelsContext(models, self, bind_refs, bind_backrefs)
                                                                                                                                    -
                                                                                                                                    -    def get_noop_select(self, ctx):
                                                                                                                                    -        return ctx.sql(Select().columns(SQL('0')).where(SQL('0')))
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -def __pragma__(name):
                                                                                                                                    -    def __get__(self):
                                                                                                                                    -        return self.pragma(name)
                                                                                                                                    -    def __set__(self, value):
                                                                                                                                    -        return self.pragma(name, value)
                                                                                                                                    -    return property(__get__, __set__)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class SqliteDatabase(Database):
                                                                                                                                    -    field_types = {
                                                                                                                                    -        'BIGAUTO': FIELD.AUTO,
                                                                                                                                    -        'BIGINT': FIELD.INT,
                                                                                                                                    -        'BOOL': FIELD.INT,
                                                                                                                                    -        'DOUBLE': FIELD.FLOAT,
                                                                                                                                    -        'SMALLINT': FIELD.INT,
                                                                                                                                    -        'UUID': FIELD.TEXT}
                                                                                                                                    -    operations = {
                                                                                                                                    -        'LIKE': 'GLOB',
                                                                                                                                    -        'ILIKE': 'LIKE'}
                                                                                                                                    -    index_schema_prefix = True
                                                                                                                                    -    limit_max = -1
                                                                                                                                    -    server_version = __sqlite_version__
                                                                                                                                    -    truncate_table = False
                                                                                                                                    -
                                                                                                                                    -    def __init__(self, database, *args, **kwargs):
                                                                                                                                    -        self._pragmas = kwargs.pop('pragmas', ())
                                                                                                                                    -        super(SqliteDatabase, self).__init__(database, *args, **kwargs)
                                                                                                                                    -        self._aggregates = {}
                                                                                                                                    -        self._collations = {}
                                                                                                                                    -        self._functions = {}
                                                                                                                                    -        self._window_functions = {}
                                                                                                                                    -        self._table_functions = []
                                                                                                                                    -        self._extensions = set()
                                                                                                                                    -        self._attached = {}
                                                                                                                                    -        self.register_function(_sqlite_date_part, 'date_part', 2)
                                                                                                                                    -        self.register_function(_sqlite_date_trunc, 'date_trunc', 2)
                                                                                                                                    -        self.nulls_ordering = self.server_version >= (3, 30, 0)
                                                                                                                                    -
                                                                                                                                    -    def init(self, database, pragmas=None, timeout=5, **kwargs):
                                                                                                                                    -        if pragmas is not None:
                                                                                                                                    -            self._pragmas = pragmas
                                                                                                                                    -        if isinstance(self._pragmas, dict):
                                                                                                                                    -            self._pragmas = list(self._pragmas.items())
                                                                                                                                    -        self._timeout = timeout
                                                                                                                                    -        super(SqliteDatabase, self).init(database, **kwargs)
                                                                                                                                    -
                                                                                                                                    -    def _set_server_version(self, conn):
                                                                                                                                    -        pass
                                                                                                                                    -
                                                                                                                                    -    def _connect(self):
                                                                                                                                    -        if sqlite3 is None:
                                                                                                                                    -            raise ImproperlyConfigured('SQLite driver not installed!')
                                                                                                                                    -        conn = sqlite3.connect(self.database, timeout=self._timeout,
                                                                                                                                    -                               isolation_level=None, **self.connect_params)
                                                                                                                                    -        try:
                                                                                                                                    -            self._add_conn_hooks(conn)
                                                                                                                                    -        except:
                                                                                                                                    -            conn.close()
                                                                                                                                    -            raise
                                                                                                                                    -        return conn
                                                                                                                                    -
                                                                                                                                    -    def _add_conn_hooks(self, conn):
                                                                                                                                    -        if self._attached:
                                                                                                                                    -            self._attach_databases(conn)
                                                                                                                                    -        if self._pragmas:
                                                                                                                                    -            self._set_pragmas(conn)
                                                                                                                                    -        self._load_aggregates(conn)
                                                                                                                                    -        self._load_collations(conn)
                                                                                                                                    -        self._load_functions(conn)
                                                                                                                                    -        if self.server_version >= (3, 25, 0):
                                                                                                                                    -            self._load_window_functions(conn)
                                                                                                                                    -        if self._table_functions:
                                                                                                                                    -            for table_function in self._table_functions:
                                                                                                                                    -                table_function.register(conn)
                                                                                                                                    -        if self._extensions:
                                                                                                                                    -            self._load_extensions(conn)
                                                                                                                                    -
                                                                                                                                    -    def _set_pragmas(self, conn):
                                                                                                                                    -        cursor = conn.cursor()
                                                                                                                                    -        for pragma, value in self._pragmas:
                                                                                                                                    -            cursor.execute('PRAGMA %s = %s;' % (pragma, value))
                                                                                                                                    -        cursor.close()
                                                                                                                                    -
                                                                                                                                    -    def _attach_databases(self, conn):
                                                                                                                                    -        cursor = conn.cursor()
                                                                                                                                    -        for name, db in self._attached.items():
                                                                                                                                    -            cursor.execute('ATTACH DATABASE "%s" AS "%s"' % (db, name))
                                                                                                                                    -        cursor.close()
                                                                                                                                    -
                                                                                                                                    -    def pragma(self, key, value=SENTINEL, permanent=False, schema=None):
                                                                                                                                    -        if schema is not None:
                                                                                                                                    -            key = '"%s".%s' % (schema, key)
                                                                                                                                    -        sql = 'PRAGMA %s' % key
                                                                                                                                    -        if value is not SENTINEL:
                                                                                                                                    -            sql += ' = %s' % (value or 0)
                                                                                                                                    -            if permanent:
                                                                                                                                    -                pragmas = dict(self._pragmas or ())
                                                                                                                                    -                pragmas[key] = value
                                                                                                                                    -                self._pragmas = list(pragmas.items())
                                                                                                                                    -        elif permanent:
                                                                                                                                    -            raise ValueError('Cannot specify a permanent pragma without value')
                                                                                                                                    -        row = self.execute_sql(sql).fetchone()
                                                                                                                                    -        if row:
                                                                                                                                    -            return row[0]
                                                                                                                                    -
                                                                                                                                    -    cache_size = __pragma__('cache_size')
                                                                                                                                    -    foreign_keys = __pragma__('foreign_keys')
                                                                                                                                    -    journal_mode = __pragma__('journal_mode')
                                                                                                                                    -    journal_size_limit = __pragma__('journal_size_limit')
                                                                                                                                    -    mmap_size = __pragma__('mmap_size')
                                                                                                                                    -    page_size = __pragma__('page_size')
                                                                                                                                    -    read_uncommitted = __pragma__('read_uncommitted')
                                                                                                                                    -    synchronous = __pragma__('synchronous')
                                                                                                                                    -    wal_autocheckpoint = __pragma__('wal_autocheckpoint')
                                                                                                                                    -
                                                                                                                                    -    @property
                                                                                                                                    -    def timeout(self):
                                                                                                                                    -        return self._timeout
                                                                                                                                    -
                                                                                                                                    -    @timeout.setter
                                                                                                                                    -    def timeout(self, seconds):
                                                                                                                                    -        if self._timeout == seconds:
                                                                                                                                    -            return
                                                                                                                                    -
                                                                                                                                    -        self._timeout = seconds
                                                                                                                                    -        if not self.is_closed():
                                                                                                                                    -            # PySQLite multiplies user timeout by 1000, but the unit of the
                                                                                                                                    -            # timeout PRAGMA is actually milliseconds.
                                                                                                                                    -            self.execute_sql('PRAGMA busy_timeout=%d;' % (seconds * 1000))
                                                                                                                                    -
                                                                                                                                    -    def _load_aggregates(self, conn):
                                                                                                                                    -        for name, (klass, num_params) in self._aggregates.items():
                                                                                                                                    -            conn.create_aggregate(name, num_params, klass)
                                                                                                                                    -
                                                                                                                                    -    def _load_collations(self, conn):
                                                                                                                                    -        for name, fn in self._collations.items():
                                                                                                                                    -            conn.create_collation(name, fn)
                                                                                                                                    -
                                                                                                                                    -    def _load_functions(self, conn):
                                                                                                                                    -        for name, (fn, num_params) in self._functions.items():
                                                                                                                                    -            conn.create_function(name, num_params, fn)
                                                                                                                                    -
                                                                                                                                    -    def _load_window_functions(self, conn):
                                                                                                                                    -        for name, (klass, num_params) in self._window_functions.items():
                                                                                                                                    -            conn.create_window_function(name, num_params, klass)
                                                                                                                                    -
                                                                                                                                    -    def register_aggregate(self, klass, name=None, num_params=-1):
                                                                                                                                    -        self._aggregates[name or klass.__name__.lower()] = (klass, num_params)
                                                                                                                                    -        if not self.is_closed():
                                                                                                                                    -            self._load_aggregates(self.connection())
                                                                                                                                    -
                                                                                                                                    -    def aggregate(self, name=None, num_params=-1):
                                                                                                                                    -        def decorator(klass):
                                                                                                                                    -            self.register_aggregate(klass, name, num_params)
                                                                                                                                    -            return klass
                                                                                                                                    -        return decorator
                                                                                                                                    -
                                                                                                                                    -    def register_collation(self, fn, name=None):
                                                                                                                                    -        name = name or fn.__name__
                                                                                                                                    -        def _collation(*args):
                                                                                                                                    -            expressions = args + (SQL('collate %s' % name),)
                                                                                                                                    -            return NodeList(expressions)
                                                                                                                                    -        fn.collation = _collation
                                                                                                                                    -        self._collations[name] = fn
                                                                                                                                    -        if not self.is_closed():
                                                                                                                                    -            self._load_collations(self.connection())
                                                                                                                                    -
                                                                                                                                    -    def collation(self, name=None):
                                                                                                                                    -        def decorator(fn):
                                                                                                                                    -            self.register_collation(fn, name)
                                                                                                                                    -            return fn
                                                                                                                                    -        return decorator
                                                                                                                                    -
                                                                                                                                    -    def register_function(self, fn, name=None, num_params=-1):
                                                                                                                                    -        self._functions[name or fn.__name__] = (fn, num_params)
                                                                                                                                    -        if not self.is_closed():
                                                                                                                                    -            self._load_functions(self.connection())
                                                                                                                                    -
                                                                                                                                    -    def func(self, name=None, num_params=-1):
                                                                                                                                    -        def decorator(fn):
                                                                                                                                    -            self.register_function(fn, name, num_params)
                                                                                                                                    -            return fn
                                                                                                                                    -        return decorator
                                                                                                                                    -
                                                                                                                                    -    def register_window_function(self, klass, name=None, num_params=-1):
                                                                                                                                    -        name = name or klass.__name__.lower()
                                                                                                                                    -        self._window_functions[name] = (klass, num_params)
                                                                                                                                    -        if not self.is_closed():
                                                                                                                                    -            self._load_window_functions(self.connection())
                                                                                                                                    -
                                                                                                                                    -    def window_function(self, name=None, num_params=-1):
                                                                                                                                    -        def decorator(klass):
                                                                                                                                    -            self.register_window_function(klass, name, num_params)
                                                                                                                                    -            return klass
                                                                                                                                    -        return decorator
                                                                                                                                    -
                                                                                                                                    -    def register_table_function(self, klass, name=None):
                                                                                                                                    -        if name is not None:
                                                                                                                                    -            klass.name = name
                                                                                                                                    -        self._table_functions.append(klass)
                                                                                                                                    -        if not self.is_closed():
                                                                                                                                    -            klass.register(self.connection())
                                                                                                                                    -
                                                                                                                                    -    def table_function(self, name=None):
                                                                                                                                    -        def decorator(klass):
                                                                                                                                    -            self.register_table_function(klass, name)
                                                                                                                                    -            return klass
                                                                                                                                    -        return decorator
                                                                                                                                    -
                                                                                                                                    -    def unregister_aggregate(self, name):
                                                                                                                                    -        del(self._aggregates[name])
                                                                                                                                    -
                                                                                                                                    -    def unregister_collation(self, name):
                                                                                                                                    -        del(self._collations[name])
                                                                                                                                    -
                                                                                                                                    -    def unregister_function(self, name):
                                                                                                                                    -        del(self._functions[name])
                                                                                                                                    -
                                                                                                                                    -    def unregister_window_function(self, name):
                                                                                                                                    -        del(self._window_functions[name])
                                                                                                                                    -
                                                                                                                                    -    def unregister_table_function(self, name):
                                                                                                                                    -        for idx, klass in enumerate(self._table_functions):
                                                                                                                                    -            if klass.name == name:
                                                                                                                                    -                break
                                                                                                                                    -        else:
                                                                                                                                    -            return False
                                                                                                                                    -        self._table_functions.pop(idx)
                                                                                                                                    -        return True
                                                                                                                                    -
                                                                                                                                    -    def _load_extensions(self, conn):
                                                                                                                                    -        conn.enable_load_extension(True)
                                                                                                                                    -        for extension in self._extensions:
                                                                                                                                    -            conn.load_extension(extension)
                                                                                                                                    -
                                                                                                                                    -    def load_extension(self, extension):
                                                                                                                                    -        self._extensions.add(extension)
                                                                                                                                    -        if not self.is_closed():
                                                                                                                                    -            conn = self.connection()
                                                                                                                                    -            conn.enable_load_extension(True)
                                                                                                                                    -            conn.load_extension(extension)
                                                                                                                                    -
                                                                                                                                    -    def unload_extension(self, extension):
                                                                                                                                    -        self._extensions.remove(extension)
                                                                                                                                    -
                                                                                                                                    -    def attach(self, filename, name):
                                                                                                                                    -        if name in self._attached:
                                                                                                                                    -            if self._attached[name] == filename:
                                                                                                                                    -                return False
                                                                                                                                    -            raise OperationalError('schema "%s" already attached.' % name)
                                                                                                                                    -
                                                                                                                                    -        self._attached[name] = filename
                                                                                                                                    -        if not self.is_closed():
                                                                                                                                    -            self.execute_sql('ATTACH DATABASE "%s" AS "%s"' % (filename, name))
                                                                                                                                    -        return True
                                                                                                                                    -
                                                                                                                                    -    def detach(self, name):
                                                                                                                                    -        if name not in self._attached:
                                                                                                                                    -            return False
                                                                                                                                    -
                                                                                                                                    -        del self._attached[name]
                                                                                                                                    -        if not self.is_closed():
                                                                                                                                    -            self.execute_sql('DETACH DATABASE "%s"' % name)
                                                                                                                                    -        return True
                                                                                                                                    -
                                                                                                                                    -    def begin(self, lock_type=None):
                                                                                                                                    -        statement = 'BEGIN %s' % lock_type if lock_type else 'BEGIN'
                                                                                                                                    -        self.execute_sql(statement, commit=False)
                                                                                                                                    -
                                                                                                                                    -    def get_tables(self, schema=None):
                                                                                                                                    -        schema = schema or 'main'
                                                                                                                                    -        cursor = self.execute_sql('SELECT name FROM "%s".sqlite_master WHERE '
                                                                                                                                    -                                  'type=? ORDER BY name' % schema, ('table',))
                                                                                                                                    -        return [row for row, in cursor.fetchall()]
                                                                                                                                    -
                                                                                                                                    -    def get_views(self, schema=None):
                                                                                                                                    -        sql = ('SELECT name, sql FROM "%s".sqlite_master WHERE type=? '
                                                                                                                                    -               'ORDER BY name') % (schema or 'main')
                                                                                                                                    -        return [ViewMetadata(*row) for row in self.execute_sql(sql, ('view',))]
                                                                                                                                    -
                                                                                                                                    -    def get_indexes(self, table, schema=None):
                                                                                                                                    -        schema = schema or 'main'
                                                                                                                                    -        query = ('SELECT name, sql FROM "%s".sqlite_master '
                                                                                                                                    -                 'WHERE tbl_name = ? AND type = ? ORDER BY name') % schema
                                                                                                                                    -        cursor = self.execute_sql(query, (table, 'index'))
                                                                                                                                    -        index_to_sql = dict(cursor.fetchall())
                                                                                                                                    -
                                                                                                                                    -        # Determine which indexes have a unique constraint.
                                                                                                                                    -        unique_indexes = set()
                                                                                                                                    -        cursor = self.execute_sql('PRAGMA "%s".index_list("%s")' %
                                                                                                                                    -                                  (schema, table))
                                                                                                                                    -        for row in cursor.fetchall():
                                                                                                                                    -            name = row[1]
                                                                                                                                    -            is_unique = int(row[2]) == 1
                                                                                                                                    -            if is_unique:
                                                                                                                                    -                unique_indexes.add(name)
                                                                                                                                    -
                                                                                                                                    -        # Retrieve the indexed columns.
                                                                                                                                    -        index_columns = {}
                                                                                                                                    -        for index_name in sorted(index_to_sql):
                                                                                                                                    -            cursor = self.execute_sql('PRAGMA "%s".index_info("%s")' %
                                                                                                                                    -                                      (schema, index_name))
                                                                                                                                    -            index_columns[index_name] = [row[2] for row in cursor.fetchall()]
                                                                                                                                    -
                                                                                                                                    -        return [
                                                                                                                                    -            IndexMetadata(
                                                                                                                                    -                name,
                                                                                                                                    -                index_to_sql[name],
                                                                                                                                    -                index_columns[name],
                                                                                                                                    -                name in unique_indexes,
                                                                                                                                    -                table)
                                                                                                                                    -            for name in sorted(index_to_sql)]
                                                                                                                                    -
                                                                                                                                    -    def get_columns(self, table, schema=None):
                                                                                                                                    -        cursor = self.execute_sql('PRAGMA "%s".table_info("%s")' %
                                                                                                                                    -                                  (schema or 'main', table))
                                                                                                                                    -        return [ColumnMetadata(r[1], r[2], not r[3], bool(r[5]), table, r[4])
                                                                                                                                    -                for r in cursor.fetchall()]
                                                                                                                                    -
                                                                                                                                    -    def get_primary_keys(self, table, schema=None):
                                                                                                                                    -        cursor = self.execute_sql('PRAGMA "%s".table_info("%s")' %
                                                                                                                                    -                                  (schema or 'main', table))
                                                                                                                                    -        return [row[1] for row in filter(lambda r: r[-1], cursor.fetchall())]
                                                                                                                                    -
                                                                                                                                    -    def get_foreign_keys(self, table, schema=None):
                                                                                                                                    -        cursor = self.execute_sql('PRAGMA "%s".foreign_key_list("%s")' %
                                                                                                                                    -                                  (schema or 'main', table))
                                                                                                                                    -        return [ForeignKeyMetadata(row[3], row[2], row[4], table)
                                                                                                                                    -                for row in cursor.fetchall()]
                                                                                                                                    -
                                                                                                                                    -    def get_binary_type(self):
                                                                                                                                    -        return sqlite3.Binary
                                                                                                                                    -
                                                                                                                                    -    def conflict_statement(self, on_conflict, query):
                                                                                                                                    -        action = on_conflict._action.lower() if on_conflict._action else ''
                                                                                                                                    -        if action and action not in ('nothing', 'update'):
                                                                                                                                    -            return SQL('INSERT OR %s' % on_conflict._action.upper())
                                                                                                                                    -
                                                                                                                                    -    def conflict_update(self, oc, query):
                                                                                                                                    -        # Sqlite prior to 3.24.0 does not support Postgres-style upsert.
                                                                                                                                    -        if self.server_version < (3, 24, 0) and \
                                                                                                                                    -           any((oc._preserve, oc._update, oc._where, oc._conflict_target,
                                                                                                                                    -                oc._conflict_constraint)):
                                                                                                                                    -            raise ValueError('SQLite does not support specifying which values '
                                                                                                                                    -                             'to preserve or update.')
                                                                                                                                    -
                                                                                                                                    -        action = oc._action.lower() if oc._action else ''
                                                                                                                                    -        if action and action not in ('nothing', 'update', ''):
                                                                                                                                    -            return
                                                                                                                                    -
                                                                                                                                    -        if action == 'nothing':
                                                                                                                                    -            return SQL('ON CONFLICT DO NOTHING')
                                                                                                                                    -        elif not oc._update and not oc._preserve:
                                                                                                                                    -            raise ValueError('If you are not performing any updates (or '
                                                                                                                                    -                             'preserving any INSERTed values), then the '
                                                                                                                                    -                             'conflict resolution action should be set to '
                                                                                                                                    -                             '"NOTHING".')
                                                                                                                                    -        elif oc._conflict_constraint:
                                                                                                                                    -            raise ValueError('SQLite does not support specifying named '
                                                                                                                                    -                             'constraints for conflict resolution.')
                                                                                                                                    -        elif not oc._conflict_target:
                                                                                                                                    -            raise ValueError('SQLite requires that a conflict target be '
                                                                                                                                    -                             'specified when doing an upsert.')
                                                                                                                                    -
                                                                                                                                    -        return self._build_on_conflict_update(oc, query)
                                                                                                                                    -
                                                                                                                                    -    def extract_date(self, date_part, date_field):
                                                                                                                                    -        return fn.date_part(date_part, date_field, python_value=int)
                                                                                                                                    -
                                                                                                                                    -    def truncate_date(self, date_part, date_field):
                                                                                                                                    -        return fn.date_trunc(date_part, date_field,
                                                                                                                                    -                             python_value=simple_date_time)
                                                                                                                                    -
                                                                                                                                    -    def to_timestamp(self, date_field):
                                                                                                                                    -        return fn.strftime('%s', date_field).cast('integer')
                                                                                                                                    -
                                                                                                                                    -    def from_timestamp(self, date_field):
                                                                                                                                    -        return fn.datetime(date_field, 'unixepoch')
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class PostgresqlDatabase(Database):
                                                                                                                                    -    field_types = {
                                                                                                                                    -        'AUTO': 'SERIAL',
                                                                                                                                    -        'BIGAUTO': 'BIGSERIAL',
                                                                                                                                    -        'BLOB': 'BYTEA',
                                                                                                                                    -        'BOOL': 'BOOLEAN',
                                                                                                                                    -        'DATETIME': 'TIMESTAMP',
                                                                                                                                    -        'DECIMAL': 'NUMERIC',
                                                                                                                                    -        'DOUBLE': 'DOUBLE PRECISION',
                                                                                                                                    -        'UUID': 'UUID',
                                                                                                                                    -        'UUIDB': 'BYTEA'}
                                                                                                                                    -    operations = {'REGEXP': '~', 'IREGEXP': '~*'}
                                                                                                                                    -    param = '%s'
                                                                                                                                    -
                                                                                                                                    -    commit_select = True
                                                                                                                                    -    compound_select_parentheses = CSQ_PARENTHESES_ALWAYS
                                                                                                                                    -    for_update = True
                                                                                                                                    -    nulls_ordering = True
                                                                                                                                    -    returning_clause = True
                                                                                                                                    -    safe_create_index = False
                                                                                                                                    -    sequences = True
                                                                                                                                    -
                                                                                                                                    -    def init(self, database, register_unicode=True, encoding=None,
                                                                                                                                    -             isolation_level=None, **kwargs):
                                                                                                                                    -        self._register_unicode = register_unicode
                                                                                                                                    -        self._encoding = encoding
                                                                                                                                    -        self._isolation_level = isolation_level
                                                                                                                                    -        super(PostgresqlDatabase, self).init(database, **kwargs)
                                                                                                                                    -
                                                                                                                                    -    def _connect(self):
                                                                                                                                    -        if psycopg2 is None:
                                                                                                                                    -            raise ImproperlyConfigured('Postgres driver not installed!')
                                                                                                                                    -        conn = psycopg2.connect(database=self.database, **self.connect_params)
                                                                                                                                    -        if self._register_unicode:
                                                                                                                                    -            pg_extensions.register_type(pg_extensions.UNICODE, conn)
                                                                                                                                    -            pg_extensions.register_type(pg_extensions.UNICODEARRAY, conn)
                                                                                                                                    -        if self._encoding:
                                                                                                                                    -            conn.set_client_encoding(self._encoding)
                                                                                                                                    -        if self._isolation_level:
                                                                                                                                    -            conn.set_isolation_level(self._isolation_level)
                                                                                                                                    -        return conn
                                                                                                                                    -
                                                                                                                                    -    def _set_server_version(self, conn):
                                                                                                                                    -        self.server_version = conn.server_version
                                                                                                                                    -        if self.server_version >= 90600:
                                                                                                                                    -            self.safe_create_index = True
                                                                                                                                    -
                                                                                                                                    -    def is_connection_usable(self):
                                                                                                                                    -        if self._state.closed:
                                                                                                                                    -            return False
                                                                                                                                    -
                                                                                                                                    -        # Returns True if we are idle, running a command, or in an active
                                                                                                                                    -        # connection. If the connection is in an error state or the connection
                                                                                                                                    -        # is otherwise unusable, return False.
                                                                                                                                    -        txn_status = self._state.conn.get_transaction_status()
                                                                                                                                    -        return txn_status < pg_extensions.TRANSACTION_STATUS_INERROR
                                                                                                                                    -
                                                                                                                                    -    def last_insert_id(self, cursor, query_type=None):
                                                                                                                                    -        try:
                                                                                                                                    -            return cursor if query_type != Insert.SIMPLE else cursor[0][0]
                                                                                                                                    -        except (IndexError, KeyError, TypeError):
                                                                                                                                    -            pass
                                                                                                                                    -
                                                                                                                                    -    def get_tables(self, schema=None):
                                                                                                                                    -        query = ('SELECT tablename FROM pg_catalog.pg_tables '
                                                                                                                                    -                 'WHERE schemaname = %s ORDER BY tablename')
                                                                                                                                    -        cursor = self.execute_sql(query, (schema or 'public',))
                                                                                                                                    -        return [table for table, in cursor.fetchall()]
                                                                                                                                    -
                                                                                                                                    -    def get_views(self, schema=None):
                                                                                                                                    -        query = ('SELECT viewname, definition FROM pg_catalog.pg_views '
                                                                                                                                    -                 'WHERE schemaname = %s ORDER BY viewname')
                                                                                                                                    -        cursor = self.execute_sql(query, (schema or 'public',))
                                                                                                                                    -        return [ViewMetadata(view_name, sql.strip(' \t;'))
                                                                                                                                    -                for (view_name, sql) in cursor.fetchall()]
                                                                                                                                    -
                                                                                                                                    -    def get_indexes(self, table, schema=None):
                                                                                                                                    -        query = """
                                                                                                                                    -            SELECT
                                                                                                                                    -                i.relname, idxs.indexdef, idx.indisunique,
                                                                                                                                    -                array_to_string(ARRAY(
                                                                                                                                    -                    SELECT pg_get_indexdef(idx.indexrelid, k + 1, TRUE)
                                                                                                                                    -                    FROM generate_subscripts(idx.indkey, 1) AS k
                                                                                                                                    -                    ORDER BY k), ',')
                                                                                                                                    -            FROM pg_catalog.pg_class AS t
                                                                                                                                    -            INNER JOIN pg_catalog.pg_index AS idx ON t.oid = idx.indrelid
                                                                                                                                    -            INNER JOIN pg_catalog.pg_class AS i ON idx.indexrelid = i.oid
                                                                                                                                    -            INNER JOIN pg_catalog.pg_indexes AS idxs ON
                                                                                                                                    -                (idxs.tablename = t.relname AND idxs.indexname = i.relname)
                                                                                                                                    -            WHERE t.relname = %s AND t.relkind = %s AND idxs.schemaname = %s
                                                                                                                                    -            ORDER BY idx.indisunique DESC, i.relname;"""
                                                                                                                                    -        cursor = self.execute_sql(query, (table, 'r', schema or 'public'))
                                                                                                                                    -        return [IndexMetadata(name, sql.rstrip(' ;'), columns.split(','),
                                                                                                                                    -                              is_unique, table)
                                                                                                                                    -                for name, sql, is_unique, columns in cursor.fetchall()]
                                                                                                                                    -
                                                                                                                                    -    def get_columns(self, table, schema=None):
                                                                                                                                    -        query = """
                                                                                                                                    -            SELECT column_name, is_nullable, data_type, column_default
                                                                                                                                    -            FROM information_schema.columns
                                                                                                                                    -            WHERE table_name = %s AND table_schema = %s
                                                                                                                                    -            ORDER BY ordinal_position"""
                                                                                                                                    -        cursor = self.execute_sql(query, (table, schema or 'public'))
                                                                                                                                    -        pks = set(self.get_primary_keys(table, schema))
                                                                                                                                    -        return [ColumnMetadata(name, dt, null == 'YES', name in pks, table, df)
                                                                                                                                    -                for name, null, dt, df in cursor.fetchall()]
                                                                                                                                    -
                                                                                                                                    -    def get_primary_keys(self, table, schema=None):
                                                                                                                                    -        query = """
                                                                                                                                    -            SELECT kc.column_name
                                                                                                                                    -            FROM information_schema.table_constraints AS tc
                                                                                                                                    -            INNER JOIN information_schema.key_column_usage AS kc ON (
                                                                                                                                    -                tc.table_name = kc.table_name AND
                                                                                                                                    -                tc.table_schema = kc.table_schema AND
                                                                                                                                    -                tc.constraint_name = kc.constraint_name)
                                                                                                                                    -            WHERE
                                                                                                                                    -                tc.constraint_type = %s AND
                                                                                                                                    -                tc.table_name = %s AND
                                                                                                                                    -                tc.table_schema = %s"""
                                                                                                                                    -        ctype = 'PRIMARY KEY'
                                                                                                                                    -        cursor = self.execute_sql(query, (ctype, table, schema or 'public'))
                                                                                                                                    -        return [pk for pk, in cursor.fetchall()]
                                                                                                                                    -
                                                                                                                                    -    def get_foreign_keys(self, table, schema=None):
                                                                                                                                    -        sql = """
                                                                                                                                    -            SELECT DISTINCT
                                                                                                                                    -                kcu.column_name, ccu.table_name, ccu.column_name
                                                                                                                                    -            FROM information_schema.table_constraints AS tc
                                                                                                                                    -            JOIN information_schema.key_column_usage AS kcu
                                                                                                                                    -                ON (tc.constraint_name = kcu.constraint_name AND
                                                                                                                                    -                    tc.constraint_schema = kcu.constraint_schema)
                                                                                                                                    -            JOIN information_schema.constraint_column_usage AS ccu
                                                                                                                                    -                ON (ccu.constraint_name = tc.constraint_name AND
                                                                                                                                    -                    ccu.constraint_schema = tc.constraint_schema)
                                                                                                                                    -            WHERE
                                                                                                                                    -                tc.constraint_type = 'FOREIGN KEY' AND
                                                                                                                                    -                tc.table_name = %s AND
                                                                                                                                    -                tc.table_schema = %s"""
                                                                                                                                    -        cursor = self.execute_sql(sql, (table, schema or 'public'))
                                                                                                                                    -        return [ForeignKeyMetadata(row[0], row[1], row[2], table)
                                                                                                                                    -                for row in cursor.fetchall()]
                                                                                                                                    -
                                                                                                                                    -    def sequence_exists(self, sequence):
                                                                                                                                    -        res = self.execute_sql("""
                                                                                                                                    -            SELECT COUNT(*) FROM pg_class, pg_namespace
                                                                                                                                    -            WHERE relkind='S'
                                                                                                                                    -                AND pg_class.relnamespace = pg_namespace.oid
                                                                                                                                    -                AND relname=%s""", (sequence,))
                                                                                                                                    -        return bool(res.fetchone()[0])
                                                                                                                                    -
                                                                                                                                    -    def get_binary_type(self):
                                                                                                                                    -        return psycopg2.Binary
                                                                                                                                    -
                                                                                                                                    -    def conflict_statement(self, on_conflict, query):
                                                                                                                                    -        return
                                                                                                                                    -
                                                                                                                                    -    def conflict_update(self, oc, query):
                                                                                                                                    -        action = oc._action.lower() if oc._action else ''
                                                                                                                                    -        if action in ('ignore', 'nothing'):
                                                                                                                                    -            return SQL('ON CONFLICT DO NOTHING')
                                                                                                                                    -        elif action and action != 'update':
                                                                                                                                    -            raise ValueError('The only supported actions for conflict '
                                                                                                                                    -                             'resolution with Postgresql are "ignore" or '
                                                                                                                                    -                             '"update".')
                                                                                                                                    -        elif not oc._update and not oc._preserve:
                                                                                                                                    -            raise ValueError('If you are not performing any updates (or '
                                                                                                                                    -                             'preserving any INSERTed values), then the '
                                                                                                                                    -                             'conflict resolution action should be set to '
                                                                                                                                    -                             '"IGNORE".')
                                                                                                                                    -        elif not (oc._conflict_target or oc._conflict_constraint):
                                                                                                                                    -            raise ValueError('Postgres requires that a conflict target be '
                                                                                                                                    -                             'specified when doing an upsert.')
                                                                                                                                    -
                                                                                                                                    -        return self._build_on_conflict_update(oc, query)
                                                                                                                                    -
                                                                                                                                    -    def extract_date(self, date_part, date_field):
                                                                                                                                    -        return fn.EXTRACT(NodeList((date_part, SQL('FROM'), date_field)))
                                                                                                                                    -
                                                                                                                                    -    def truncate_date(self, date_part, date_field):
                                                                                                                                    -        return fn.DATE_TRUNC(date_part, date_field)
                                                                                                                                    -
                                                                                                                                    -    def to_timestamp(self, date_field):
                                                                                                                                    -        return self.extract_date('EPOCH', date_field)
                                                                                                                                    -
                                                                                                                                    -    def from_timestamp(self, date_field):
                                                                                                                                    -        # Ironically, here, Postgres means "to the Postgresql timestamp type".
                                                                                                                                    -        return fn.to_timestamp(date_field)
                                                                                                                                    -
                                                                                                                                    -    def get_noop_select(self, ctx):
                                                                                                                                    -        return ctx.sql(Select().columns(SQL('0')).where(SQL('false')))
                                                                                                                                    -
                                                                                                                                    -    def set_time_zone(self, timezone):
                                                                                                                                    -        self.execute_sql('set time zone "%s";' % timezone)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class MySQLDatabase(Database):
                                                                                                                                    -    field_types = {
                                                                                                                                    -        'AUTO': 'INTEGER AUTO_INCREMENT',
                                                                                                                                    -        'BIGAUTO': 'BIGINT AUTO_INCREMENT',
                                                                                                                                    -        'BOOL': 'BOOL',
                                                                                                                                    -        'DECIMAL': 'NUMERIC',
                                                                                                                                    -        'DOUBLE': 'DOUBLE PRECISION',
                                                                                                                                    -        'FLOAT': 'FLOAT',
                                                                                                                                    -        'UUID': 'VARCHAR(40)',
                                                                                                                                    -        'UUIDB': 'VARBINARY(16)'}
                                                                                                                                    -    operations = {
                                                                                                                                    -        'LIKE': 'LIKE BINARY',
                                                                                                                                    -        'ILIKE': 'LIKE',
                                                                                                                                    -        'REGEXP': 'REGEXP BINARY',
                                                                                                                                    -        'IREGEXP': 'REGEXP',
                                                                                                                                    -        'XOR': 'XOR'}
                                                                                                                                    -    param = '%s'
                                                                                                                                    -    quote = '``'
                                                                                                                                    -
                                                                                                                                    -    commit_select = True
                                                                                                                                    -    compound_select_parentheses = CSQ_PARENTHESES_UNNESTED
                                                                                                                                    -    for_update = True
                                                                                                                                    -    index_using_precedes_table = True
                                                                                                                                    -    limit_max = 2 ** 64 - 1
                                                                                                                                    -    safe_create_index = False
                                                                                                                                    -    safe_drop_index = False
                                                                                                                                    -    sql_mode = 'PIPES_AS_CONCAT'
                                                                                                                                    -
                                                                                                                                    -    def init(self, database, **kwargs):
                                                                                                                                    -        params = {
                                                                                                                                    -            'charset': 'utf8',
                                                                                                                                    -            'sql_mode': self.sql_mode,
                                                                                                                                    -            'use_unicode': True}
                                                                                                                                    -        params.update(kwargs)
                                                                                                                                    -        if 'password' in params and mysql_passwd:
                                                                                                                                    -            params['passwd'] = params.pop('password')
                                                                                                                                    -        super(MySQLDatabase, self).init(database, **params)
                                                                                                                                    -
                                                                                                                                    -    def _connect(self):
                                                                                                                                    -        if mysql is None:
                                                                                                                                    -            raise ImproperlyConfigured('MySQL driver not installed!')
                                                                                                                                    -        conn = mysql.connect(db=self.database, **self.connect_params)
                                                                                                                                    -        return conn
                                                                                                                                    -
                                                                                                                                    -    def _set_server_version(self, conn):
                                                                                                                                    -        try:
                                                                                                                                    -            version_raw = conn.server_version
                                                                                                                                    -        except AttributeError:
                                                                                                                                    -            version_raw = conn.get_server_info()
                                                                                                                                    -        self.server_version = self._extract_server_version(version_raw)
                                                                                                                                    -
                                                                                                                                    -    def _extract_server_version(self, version):
                                                                                                                                    -        version = version.lower()
                                                                                                                                    -        if 'maria' in version:
                                                                                                                                    -            match_obj = re.search(r'(1\d\.\d+\.\d+)', version)
                                                                                                                                    -        else:
                                                                                                                                    -            match_obj = re.search(r'(\d\.\d+\.\d+)', version)
                                                                                                                                    -        if match_obj is not None:
                                                                                                                                    -            return tuple(int(num) for num in match_obj.groups()[0].split('.'))
                                                                                                                                    -
                                                                                                                                    -        warnings.warn('Unable to determine MySQL version: "%s"' % version)
                                                                                                                                    -        return (0, 0, 0)  # Unable to determine version!
                                                                                                                                    -
                                                                                                                                    -    def default_values_insert(self, ctx):
                                                                                                                                    -        return ctx.literal('() VALUES ()')
                                                                                                                                    -
                                                                                                                                    -    def get_tables(self, schema=None):
                                                                                                                                    -        query = ('SELECT table_name FROM information_schema.tables '
                                                                                                                                    -                 'WHERE table_schema = DATABASE() AND table_type != %s '
                                                                                                                                    -                 'ORDER BY table_name')
                                                                                                                                    -        return [table for table, in self.execute_sql(query, ('VIEW',))]
                                                                                                                                    -
                                                                                                                                    -    def get_views(self, schema=None):
                                                                                                                                    -        query = ('SELECT table_name, view_definition '
                                                                                                                                    -                 'FROM information_schema.views '
                                                                                                                                    -                 'WHERE table_schema = DATABASE() ORDER BY table_name')
                                                                                                                                    -        cursor = self.execute_sql(query)
                                                                                                                                    -        return [ViewMetadata(*row) for row in cursor.fetchall()]
                                                                                                                                    -
                                                                                                                                    -    def get_indexes(self, table, schema=None):
                                                                                                                                    -        cursor = self.execute_sql('SHOW INDEX FROM `%s`' % table)
                                                                                                                                    -        unique = set()
                                                                                                                                    -        indexes = {}
                                                                                                                                    -        for row in cursor.fetchall():
                                                                                                                                    -            if not row[1]:
                                                                                                                                    -                unique.add(row[2])
                                                                                                                                    -            indexes.setdefault(row[2], [])
                                                                                                                                    -            indexes[row[2]].append(row[4])
                                                                                                                                    -        return [IndexMetadata(name, None, indexes[name], name in unique, table)
                                                                                                                                    -                for name in indexes]
                                                                                                                                    -
                                                                                                                                    -    def get_columns(self, table, schema=None):
                                                                                                                                    -        sql = """
                                                                                                                                    -            SELECT column_name, is_nullable, data_type, column_default
                                                                                                                                    -            FROM information_schema.columns
                                                                                                                                    -            WHERE table_name = %s AND table_schema = DATABASE()"""
                                                                                                                                    -        cursor = self.execute_sql(sql, (table,))
                                                                                                                                    -        pks = set(self.get_primary_keys(table))
                                                                                                                                    -        return [ColumnMetadata(name, dt, null == 'YES', name in pks, table, df)
                                                                                                                                    -                for name, null, dt, df in cursor.fetchall()]
                                                                                                                                    -
                                                                                                                                    -    def get_primary_keys(self, table, schema=None):
                                                                                                                                    -        cursor = self.execute_sql('SHOW INDEX FROM `%s`' % table)
                                                                                                                                    -        return [row[4] for row in
                                                                                                                                    -                filter(lambda row: row[2] == 'PRIMARY', cursor.fetchall())]
                                                                                                                                    -
                                                                                                                                    -    def get_foreign_keys(self, table, schema=None):
                                                                                                                                    -        query = """
                                                                                                                                    -            SELECT column_name, referenced_table_name, referenced_column_name
                                                                                                                                    -            FROM information_schema.key_column_usage
                                                                                                                                    -            WHERE table_name = %s
                                                                                                                                    -                AND table_schema = DATABASE()
                                                                                                                                    -                AND referenced_table_name IS NOT NULL
                                                                                                                                    -                AND referenced_column_name IS NOT NULL"""
                                                                                                                                    -        cursor = self.execute_sql(query, (table,))
                                                                                                                                    -        return [
                                                                                                                                    -            ForeignKeyMetadata(column, dest_table, dest_column, table)
                                                                                                                                    -            for column, dest_table, dest_column in cursor.fetchall()]
                                                                                                                                    -
                                                                                                                                    -    def get_binary_type(self):
                                                                                                                                    -        return mysql.Binary
                                                                                                                                    -
                                                                                                                                    -    def conflict_statement(self, on_conflict, query):
                                                                                                                                    -        if not on_conflict._action: return
                                                                                                                                    -
                                                                                                                                    -        action = on_conflict._action.lower()
                                                                                                                                    -        if action == 'replace':
                                                                                                                                    -            return SQL('REPLACE')
                                                                                                                                    -        elif action == 'ignore':
                                                                                                                                    -            return SQL('INSERT IGNORE')
                                                                                                                                    -        elif action != 'update':
                                                                                                                                    -            raise ValueError('Un-supported action for conflict resolution. '
                                                                                                                                    -                             'MySQL supports REPLACE, IGNORE and UPDATE.')
                                                                                                                                    -
                                                                                                                                    -    def conflict_update(self, on_conflict, query):
                                                                                                                                    -        if on_conflict._where or on_conflict._conflict_target or \
                                                                                                                                    -           on_conflict._conflict_constraint:
                                                                                                                                    -            raise ValueError('MySQL does not support the specification of '
                                                                                                                                    -                             'where clauses or conflict targets for conflict '
                                                                                                                                    -                             'resolution.')
                                                                                                                                    -
                                                                                                                                    -        updates = []
                                                                                                                                    -        if on_conflict._preserve:
                                                                                                                                    -            # Here we need to determine which function to use, which varies
                                                                                                                                    -            # depending on the MySQL server version. MySQL and MariaDB prior to
                                                                                                                                    -            # 10.3.3 use "VALUES", while MariaDB 10.3.3+ use "VALUE".
                                                                                                                                    -            version = self.server_version or (0,)
                                                                                                                                    -            if version[0] == 10 and version >= (10, 3, 3):
                                                                                                                                    -                VALUE_FN = fn.VALUE
                                                                                                                                    -            else:
                                                                                                                                    -                VALUE_FN = fn.VALUES
                                                                                                                                    -
                                                                                                                                    -            for column in on_conflict._preserve:
                                                                                                                                    -                entity = ensure_entity(column)
                                                                                                                                    -                expression = NodeList((
                                                                                                                                    -                    ensure_entity(column),
                                                                                                                                    -                    SQL('='),
                                                                                                                                    -                    VALUE_FN(entity)))
                                                                                                                                    -                updates.append(expression)
                                                                                                                                    -
                                                                                                                                    -        if on_conflict._update:
                                                                                                                                    -            for k, v in on_conflict._update.items():
                                                                                                                                    -                if not isinstance(v, Node):
                                                                                                                                    -                    # Attempt to resolve string field-names to their respective
                                                                                                                                    -                    # field object, to apply data-type conversions.
                                                                                                                                    -                    if isinstance(k, basestring):
                                                                                                                                    -                        k = getattr(query.table, k)
                                                                                                                                    -                    if isinstance(k, Field):
                                                                                                                                    -                        v = k.to_value(v)
                                                                                                                                    -                    else:
                                                                                                                                    -                        v = Value(v, unpack=False)
                                                                                                                                    -                updates.append(NodeList((ensure_entity(k), SQL('='), v)))
                                                                                                                                    -
                                                                                                                                    -        if updates:
                                                                                                                                    -            return NodeList((SQL('ON DUPLICATE KEY UPDATE'),
                                                                                                                                    -                             CommaNodeList(updates)))
                                                                                                                                    -
                                                                                                                                    -    def extract_date(self, date_part, date_field):
                                                                                                                                    -        return fn.EXTRACT(NodeList((SQL(date_part), SQL('FROM'), date_field)))
                                                                                                                                    -
                                                                                                                                    -    def truncate_date(self, date_part, date_field):
                                                                                                                                    -        return fn.DATE_FORMAT(date_field, __mysql_date_trunc__[date_part],
                                                                                                                                    -                              python_value=simple_date_time)
                                                                                                                                    -
                                                                                                                                    -    def to_timestamp(self, date_field):
                                                                                                                                    -        return fn.UNIX_TIMESTAMP(date_field)
                                                                                                                                    -
                                                                                                                                    -    def from_timestamp(self, date_field):
                                                                                                                                    -        return fn.FROM_UNIXTIME(date_field)
                                                                                                                                    -
                                                                                                                                    -    def random(self):
                                                                                                                                    -        return fn.rand()
                                                                                                                                    -
                                                                                                                                    -    def get_noop_select(self, ctx):
                                                                                                                                    -        return ctx.literal('DO 0')
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -# TRANSACTION CONTROL.
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class _manual(_callable_context_manager):
                                                                                                                                    -    def __init__(self, db):
                                                                                                                                    -        self.db = db
                                                                                                                                    -
                                                                                                                                    -    def __enter__(self):
                                                                                                                                    -        top = self.db.top_transaction()
                                                                                                                                    -        if top is not None and not isinstance(top, _manual):
                                                                                                                                    -            raise ValueError('Cannot enter manual commit block while a '
                                                                                                                                    -                             'transaction is active.')
                                                                                                                                    -        self.db.push_transaction(self)
                                                                                                                                    -
                                                                                                                                    -    def __exit__(self, exc_type, exc_val, exc_tb):
                                                                                                                                    -        if self.db.pop_transaction() is not self:
                                                                                                                                    -            raise ValueError('Transaction stack corrupted while exiting '
                                                                                                                                    -                             'manual commit block.')
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class _atomic(_callable_context_manager):
                                                                                                                                    -    def __init__(self, db, *args, **kwargs):
                                                                                                                                    -        self.db = db
                                                                                                                                    -        self._transaction_args = (args, kwargs)
                                                                                                                                    -
                                                                                                                                    -    def __enter__(self):
                                                                                                                                    -        if self.db.transaction_depth() == 0:
                                                                                                                                    -            args, kwargs = self._transaction_args
                                                                                                                                    -            self._helper = self.db.transaction(*args, **kwargs)
                                                                                                                                    -        elif isinstance(self.db.top_transaction(), _manual):
                                                                                                                                    -            raise ValueError('Cannot enter atomic commit block while in '
                                                                                                                                    -                             'manual commit mode.')
                                                                                                                                    -        else:
                                                                                                                                    -            self._helper = self.db.savepoint()
                                                                                                                                    -        return self._helper.__enter__()
                                                                                                                                    -
                                                                                                                                    -    def __exit__(self, exc_type, exc_val, exc_tb):
                                                                                                                                    -        return self._helper.__exit__(exc_type, exc_val, exc_tb)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class _transaction(_callable_context_manager):
                                                                                                                                    -    def __init__(self, db, *args, **kwargs):
                                                                                                                                    -        self.db = db
                                                                                                                                    -        self._begin_args = (args, kwargs)
                                                                                                                                    -
                                                                                                                                    -    def _begin(self):
                                                                                                                                    -        args, kwargs = self._begin_args
                                                                                                                                    -        self.db.begin(*args, **kwargs)
                                                                                                                                    -
                                                                                                                                    -    def commit(self, begin=True):
                                                                                                                                    -        self.db.commit()
                                                                                                                                    -        if begin:
                                                                                                                                    -            self._begin()
                                                                                                                                    -
                                                                                                                                    -    def rollback(self, begin=True):
                                                                                                                                    -        self.db.rollback()
                                                                                                                                    -        if begin:
                                                                                                                                    -            self._begin()
                                                                                                                                    -
                                                                                                                                    -    def __enter__(self):
                                                                                                                                    -        if self.db.transaction_depth() == 0:
                                                                                                                                    -            self._begin()
                                                                                                                                    -        self.db.push_transaction(self)
                                                                                                                                    -        return self
                                                                                                                                    -
                                                                                                                                    -    def __exit__(self, exc_type, exc_val, exc_tb):
                                                                                                                                    -        try:
                                                                                                                                    -            if exc_type:
                                                                                                                                    -                self.rollback(False)
                                                                                                                                    -            elif self.db.transaction_depth() == 1:
                                                                                                                                    -                try:
                                                                                                                                    -                    self.commit(False)
                                                                                                                                    -                except:
                                                                                                                                    -                    self.rollback(False)
                                                                                                                                    -                    raise
                                                                                                                                    -        finally:
                                                                                                                                    -            self.db.pop_transaction()
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class _savepoint(_callable_context_manager):
                                                                                                                                    -    def __init__(self, db, sid=None):
                                                                                                                                    -        self.db = db
                                                                                                                                    -        self.sid = sid or 's' + uuid.uuid4().hex
                                                                                                                                    -        self.quoted_sid = self.sid.join(self.db.quote)
                                                                                                                                    -
                                                                                                                                    -    def _begin(self):
                                                                                                                                    -        self.db.execute_sql('SAVEPOINT %s;' % self.quoted_sid)
                                                                                                                                    -
                                                                                                                                    -    def commit(self, begin=True):
                                                                                                                                    -        self.db.execute_sql('RELEASE SAVEPOINT %s;' % self.quoted_sid)
                                                                                                                                    -        if begin: self._begin()
                                                                                                                                    -
                                                                                                                                    -    def rollback(self):
                                                                                                                                    -        self.db.execute_sql('ROLLBACK TO SAVEPOINT %s;' % self.quoted_sid)
                                                                                                                                    -
                                                                                                                                    -    def __enter__(self):
                                                                                                                                    -        self._begin()
                                                                                                                                    -        return self
                                                                                                                                    -
                                                                                                                                    -    def __exit__(self, exc_type, exc_val, exc_tb):
                                                                                                                                    -        if exc_type:
                                                                                                                                    -            self.rollback()
                                                                                                                                    -        else:
                                                                                                                                    -            try:
                                                                                                                                    -                self.commit(begin=False)
                                                                                                                                    -            except:
                                                                                                                                    -                self.rollback()
                                                                                                                                    -                raise
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -# CURSOR REPRESENTATIONS.
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class CursorWrapper(object):
                                                                                                                                    -    def __init__(self, cursor):
                                                                                                                                    -        self.cursor = cursor
                                                                                                                                    -        self.count = 0
                                                                                                                                    -        self.index = 0
                                                                                                                                    -        self.initialized = False
                                                                                                                                    -        self.populated = False
                                                                                                                                    -        self.row_cache = []
                                                                                                                                    -
                                                                                                                                    -    def __iter__(self):
                                                                                                                                    -        if self.populated:
                                                                                                                                    -            return iter(self.row_cache)
                                                                                                                                    -        return ResultIterator(self)
                                                                                                                                    -
                                                                                                                                    -    def __getitem__(self, item):
                                                                                                                                    -        if isinstance(item, slice):
                                                                                                                                    -            stop = item.stop
                                                                                                                                    -            if stop is None or stop < 0:
                                                                                                                                    -                self.fill_cache()
                                                                                                                                    -            else:
                                                                                                                                    -                self.fill_cache(stop)
                                                                                                                                    -            return self.row_cache[item]
                                                                                                                                    -        elif isinstance(item, int):
                                                                                                                                    -            self.fill_cache(item if item > 0 else 0)
                                                                                                                                    -            return self.row_cache[item]
                                                                                                                                    -        else:
                                                                                                                                    -            raise ValueError('CursorWrapper only supports integer and slice '
                                                                                                                                    -                             'indexes.')
                                                                                                                                    -
                                                                                                                                    -    def __len__(self):
                                                                                                                                    -        self.fill_cache()
                                                                                                                                    -        return self.count
                                                                                                                                    -
                                                                                                                                    -    def initialize(self):
                                                                                                                                    -        pass
                                                                                                                                    -
                                                                                                                                    -    def iterate(self, cache=True):
                                                                                                                                    -        row = self.cursor.fetchone()
                                                                                                                                    -        if row is None:
                                                                                                                                    -            self.populated = True
                                                                                                                                    -            self.cursor.close()
                                                                                                                                    -            raise StopIteration
                                                                                                                                    -        elif not self.initialized:
                                                                                                                                    -            self.initialize()  # Lazy initialization.
                                                                                                                                    -            self.initialized = True
                                                                                                                                    -        self.count += 1
                                                                                                                                    -        result = self.process_row(row)
                                                                                                                                    -        if cache:
                                                                                                                                    -            self.row_cache.append(result)
                                                                                                                                    -        return result
                                                                                                                                    -
                                                                                                                                    -    def process_row(self, row):
                                                                                                                                    -        return row
                                                                                                                                    -
                                                                                                                                    -    def iterator(self):
                                                                                                                                    -        """Efficient one-pass iteration over the result set."""
                                                                                                                                    -        while True:
                                                                                                                                    -            try:
                                                                                                                                    -                yield self.iterate(False)
                                                                                                                                    -            except StopIteration:
                                                                                                                                    -                return
                                                                                                                                    -
                                                                                                                                    -    def fill_cache(self, n=0):
                                                                                                                                    -        n = n or float('Inf')
                                                                                                                                    -        if n < 0:
                                                                                                                                    -            raise ValueError('Negative values are not supported.')
                                                                                                                                    -
                                                                                                                                    -        iterator = ResultIterator(self)
                                                                                                                                    -        iterator.index = self.count
                                                                                                                                    -        while not self.populated and (n > self.count):
                                                                                                                                    -            try:
                                                                                                                                    -                iterator.next()
                                                                                                                                    -            except StopIteration:
                                                                                                                                    -                break
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class DictCursorWrapper(CursorWrapper):
                                                                                                                                    -    def _initialize_columns(self):
                                                                                                                                    -        description = self.cursor.description
                                                                                                                                    -        self.columns = [t[0][t[0].find('.') + 1:].strip('"')
                                                                                                                                    -                        for t in description]
                                                                                                                                    -        self.ncols = len(description)
                                                                                                                                    -
                                                                                                                                    -    initialize = _initialize_columns
                                                                                                                                    -
                                                                                                                                    -    def _row_to_dict(self, row):
                                                                                                                                    -        result = {}
                                                                                                                                    -        for i in range(self.ncols):
                                                                                                                                    -            result.setdefault(self.columns[i], row[i])  # Do not overwrite.
                                                                                                                                    -        return result
                                                                                                                                    -
                                                                                                                                    -    process_row = _row_to_dict
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class NamedTupleCursorWrapper(CursorWrapper):
                                                                                                                                    -    def initialize(self):
                                                                                                                                    -        description = self.cursor.description
                                                                                                                                    -        self.tuple_class = collections.namedtuple(
                                                                                                                                    -            'Row',
                                                                                                                                    -            [col[0][col[0].find('.') + 1:].strip('"') for col in description])
                                                                                                                                    -
                                                                                                                                    -    def process_row(self, row):
                                                                                                                                    -        return self.tuple_class(*row)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class ObjectCursorWrapper(DictCursorWrapper):
                                                                                                                                    -    def __init__(self, cursor, constructor):
                                                                                                                                    -        super(ObjectCursorWrapper, self).__init__(cursor)
                                                                                                                                    -        self.constructor = constructor
                                                                                                                                    -
                                                                                                                                    -    def process_row(self, row):
                                                                                                                                    -        row_dict = self._row_to_dict(row)
                                                                                                                                    -        return self.constructor(**row_dict)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class ResultIterator(object):
                                                                                                                                    -    def __init__(self, cursor_wrapper):
                                                                                                                                    -        self.cursor_wrapper = cursor_wrapper
                                                                                                                                    -        self.index = 0
                                                                                                                                    -
                                                                                                                                    -    def __iter__(self):
                                                                                                                                    -        return self
                                                                                                                                    -
                                                                                                                                    -    def next(self):
                                                                                                                                    -        if self.index < self.cursor_wrapper.count:
                                                                                                                                    -            obj = self.cursor_wrapper.row_cache[self.index]
                                                                                                                                    -        elif not self.cursor_wrapper.populated:
                                                                                                                                    -            self.cursor_wrapper.iterate()
                                                                                                                                    -            obj = self.cursor_wrapper.row_cache[self.index]
                                                                                                                                    -        else:
                                                                                                                                    -            raise StopIteration
                                                                                                                                    -        self.index += 1
                                                                                                                                    -        return obj
                                                                                                                                    -
                                                                                                                                    -    __next__ = next
                                                                                                                                    -
                                                                                                                                    -# FIELDS
                                                                                                                                    -
                                                                                                                                    -class FieldAccessor(object):
                                                                                                                                    -    def __init__(self, model, field, name):
                                                                                                                                    -        self.model = model
                                                                                                                                    -        self.field = field
                                                                                                                                    -        self.name = name
                                                                                                                                    -
                                                                                                                                    -    def __get__(self, instance, instance_type=None):
                                                                                                                                    -        if instance is not None:
                                                                                                                                    -            return instance.__data__.get(self.name)
                                                                                                                                    -        return self.field
                                                                                                                                    -
                                                                                                                                    -    def __set__(self, instance, value):
                                                                                                                                    -        instance.__data__[self.name] = value
                                                                                                                                    -        instance._dirty.add(self.name)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class ForeignKeyAccessor(FieldAccessor):
                                                                                                                                    -    def __init__(self, model, field, name):
                                                                                                                                    -        super(ForeignKeyAccessor, self).__init__(model, field, name)
                                                                                                                                    -        self.rel_model = field.rel_model
                                                                                                                                    -
                                                                                                                                    -    def get_rel_instance(self, instance):
                                                                                                                                    -        value = instance.__data__.get(self.name)
                                                                                                                                    -        if value is not None or self.name in instance.__rel__:
                                                                                                                                    -            if self.name not in instance.__rel__:
                                                                                                                                    -                obj = self.rel_model.get(self.field.rel_field == value)
                                                                                                                                    -                instance.__rel__[self.name] = obj
                                                                                                                                    -            return instance.__rel__[self.name]
                                                                                                                                    -        elif not self.field.null:
                                                                                                                                    -            raise self.rel_model.DoesNotExist
                                                                                                                                    -        return value
                                                                                                                                    -
                                                                                                                                    -    def __get__(self, instance, instance_type=None):
                                                                                                                                    -        if instance is not None:
                                                                                                                                    -            return self.get_rel_instance(instance)
                                                                                                                                    -        return self.field
                                                                                                                                    -
                                                                                                                                    -    def __set__(self, instance, obj):
                                                                                                                                    -        if isinstance(obj, self.rel_model):
                                                                                                                                    -            instance.__data__[self.name] = getattr(obj, self.field.rel_field.name)
                                                                                                                                    -            instance.__rel__[self.name] = obj
                                                                                                                                    -        else:
                                                                                                                                    -            fk_value = instance.__data__.get(self.name)
                                                                                                                                    -            instance.__data__[self.name] = obj
                                                                                                                                    -            if obj != fk_value and self.name in instance.__rel__:
                                                                                                                                    -                del instance.__rel__[self.name]
                                                                                                                                    -        instance._dirty.add(self.name)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class NoQueryForeignKeyAccessor(ForeignKeyAccessor):
                                                                                                                                    -    def get_rel_instance(self, instance):
                                                                                                                                    -        value = instance.__data__.get(self.name)
                                                                                                                                    -        if value is not None:
                                                                                                                                    -            return instance.__rel__.get(self.name, value)
                                                                                                                                    -        elif not self.field.null:
                                                                                                                                    -            raise self.rel_model.DoesNotExist
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class BackrefAccessor(object):
                                                                                                                                    -    def __init__(self, field):
                                                                                                                                    -        self.field = field
                                                                                                                                    -        self.model = field.rel_model
                                                                                                                                    -        self.rel_model = field.model
                                                                                                                                    -
                                                                                                                                    -    def __get__(self, instance, instance_type=None):
                                                                                                                                    -        if instance is not None:
                                                                                                                                    -            dest = self.field.rel_field.name
                                                                                                                                    -            return (self.rel_model
                                                                                                                                    -                    .select()
                                                                                                                                    -                    .where(self.field == getattr(instance, dest)))
                                                                                                                                    -        return self
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class ObjectIdAccessor(object):
                                                                                                                                    -    """Gives direct access to the underlying id"""
                                                                                                                                    -    def __init__(self, field):
                                                                                                                                    -        self.field = field
                                                                                                                                    -
                                                                                                                                    -    def __get__(self, instance, instance_type=None):
                                                                                                                                    -        if instance is not None:
                                                                                                                                    -            value = instance.__data__.get(self.field.name)
                                                                                                                                    -            # Pull the object-id from the related object if it is not set.
                                                                                                                                    -            if value is None and self.field.name in instance.__rel__:
                                                                                                                                    -                rel_obj = instance.__rel__[self.field.name]
                                                                                                                                    -                value = getattr(rel_obj, self.field.rel_field.name)
                                                                                                                                    -            return value
                                                                                                                                    -        return self.field
                                                                                                                                    -
                                                                                                                                    -    def __set__(self, instance, value):
                                                                                                                                    -        setattr(instance, self.field.name, value)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class Field(ColumnBase):
                                                                                                                                    -    _field_counter = 0
                                                                                                                                    -    _order = 0
                                                                                                                                    -    accessor_class = FieldAccessor
                                                                                                                                    -    auto_increment = False
                                                                                                                                    -    default_index_type = None
                                                                                                                                    -    field_type = 'DEFAULT'
                                                                                                                                    -    unpack = True
                                                                                                                                    -
                                                                                                                                    -    def __init__(self, null=False, index=False, unique=False, column_name=None,
                                                                                                                                    -                 default=None, primary_key=False, constraints=None,
                                                                                                                                    -                 sequence=None, collation=None, unindexed=False, choices=None,
                                                                                                                                    -                 help_text=None, verbose_name=None, index_type=None,
                                                                                                                                    -                 db_column=None, _hidden=False):
                                                                                                                                    -        if db_column is not None:
                                                                                                                                    -            __deprecated__('"db_column" has been deprecated in favor of '
                                                                                                                                    -                           '"column_name" for Field objects.')
                                                                                                                                    -            column_name = db_column
                                                                                                                                    -
                                                                                                                                    -        self.null = null
                                                                                                                                    -        self.index = index
                                                                                                                                    -        self.unique = unique
                                                                                                                                    -        self.column_name = column_name
                                                                                                                                    -        self.default = default
                                                                                                                                    -        self.primary_key = primary_key
                                                                                                                                    -        self.constraints = constraints  # List of column constraints.
                                                                                                                                    -        self.sequence = sequence  # Name of sequence, e.g. foo_id_seq.
                                                                                                                                    -        self.collation = collation
                                                                                                                                    -        self.unindexed = unindexed
                                                                                                                                    -        self.choices = choices
                                                                                                                                    -        self.help_text = help_text
                                                                                                                                    -        self.verbose_name = verbose_name
                                                                                                                                    -        self.index_type = index_type or self.default_index_type
                                                                                                                                    -        self._hidden = _hidden
                                                                                                                                    -
                                                                                                                                    -        # Used internally for recovering the order in which Fields were defined
                                                                                                                                    -        # on the Model class.
                                                                                                                                    -        Field._field_counter += 1
                                                                                                                                    -        self._order = Field._field_counter
                                                                                                                                    -        self._sort_key = (self.primary_key and 1 or 2), self._order
                                                                                                                                    -
                                                                                                                                    -    def __hash__(self):
                                                                                                                                    -        return hash(self.name + '.' + self.model.__name__)
                                                                                                                                    -
                                                                                                                                    -    def __repr__(self):
                                                                                                                                    -        if hasattr(self, 'model') and getattr(self, 'name', None):
                                                                                                                                    -            return '<%s: %s.%s>' % (type(self).__name__,
                                                                                                                                    -                                    self.model.__name__,
                                                                                                                                    -                                    self.name)
                                                                                                                                    -        return '<%s: (unbound)>' % type(self).__name__
                                                                                                                                    -
                                                                                                                                    -    def bind(self, model, name, set_attribute=True):
                                                                                                                                    -        self.model = model
                                                                                                                                    -        self.name = self.safe_name = name
                                                                                                                                    -        self.column_name = self.column_name or name
                                                                                                                                    -        if set_attribute:
                                                                                                                                    -            setattr(model, name, self.accessor_class(model, self, name))
                                                                                                                                    -
                                                                                                                                    -    @property
                                                                                                                                    -    def column(self):
                                                                                                                                    -        return Column(self.model._meta.table, self.column_name)
                                                                                                                                    -
                                                                                                                                    -    def adapt(self, value):
                                                                                                                                    -        return value
                                                                                                                                    -
                                                                                                                                    -    def db_value(self, value):
                                                                                                                                    -        return value if value is None else self.adapt(value)
                                                                                                                                    -
                                                                                                                                    -    def python_value(self, value):
                                                                                                                                    -        return value if value is None else self.adapt(value)
                                                                                                                                    -
                                                                                                                                    -    def to_value(self, value):
                                                                                                                                    -        return Value(value, self.db_value, unpack=False)
                                                                                                                                    -
                                                                                                                                    -    def get_sort_key(self, ctx):
                                                                                                                                    -        return self._sort_key
                                                                                                                                    -
                                                                                                                                    -    def __sql__(self, ctx):
                                                                                                                                    -        return ctx.sql(self.column)
                                                                                                                                    -
                                                                                                                                    -    def get_modifiers(self):
                                                                                                                                    -        pass
                                                                                                                                    -
                                                                                                                                    -    def ddl_datatype(self, ctx):
                                                                                                                                    -        if ctx and ctx.state.field_types:
                                                                                                                                    -            column_type = ctx.state.field_types.get(self.field_type,
                                                                                                                                    -                                                    self.field_type)
                                                                                                                                    -        else:
                                                                                                                                    -            column_type = self.field_type
                                                                                                                                    -
                                                                                                                                    -        modifiers = self.get_modifiers()
                                                                                                                                    -        if column_type and modifiers:
                                                                                                                                    -            modifier_literal = ', '.join([str(m) for m in modifiers])
                                                                                                                                    -            return SQL('%s(%s)' % (column_type, modifier_literal))
                                                                                                                                    -        else:
                                                                                                                                    -            return SQL(column_type)
                                                                                                                                    -
                                                                                                                                    -    def ddl(self, ctx):
                                                                                                                                    -        accum = [Entity(self.column_name)]
                                                                                                                                    -        data_type = self.ddl_datatype(ctx)
                                                                                                                                    -        if data_type:
                                                                                                                                    -            accum.append(data_type)
                                                                                                                                    -        if self.unindexed:
                                                                                                                                    -            accum.append(SQL('UNINDEXED'))
                                                                                                                                    -        if not self.null:
                                                                                                                                    -            accum.append(SQL('NOT NULL'))
                                                                                                                                    -        if self.primary_key:
                                                                                                                                    -            accum.append(SQL('PRIMARY KEY'))
                                                                                                                                    -        if self.sequence:
                                                                                                                                    -            accum.append(SQL("DEFAULT NEXTVAL('%s')" % self.sequence))
                                                                                                                                    -        if self.constraints:
                                                                                                                                    -            accum.extend(self.constraints)
                                                                                                                                    -        if self.collation:
                                                                                                                                    -            accum.append(SQL('COLLATE %s' % self.collation))
                                                                                                                                    -        return NodeList(accum)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class IntegerField(Field):
                                                                                                                                    -    field_type = 'INT'
                                                                                                                                    -
                                                                                                                                    -    def adapt(self, value):
                                                                                                                                    -        try:
                                                                                                                                    -            return int(value)
                                                                                                                                    -        except ValueError:
                                                                                                                                    -            return value
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class BigIntegerField(IntegerField):
                                                                                                                                    -    field_type = 'BIGINT'
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class SmallIntegerField(IntegerField):
                                                                                                                                    -    field_type = 'SMALLINT'
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class AutoField(IntegerField):
                                                                                                                                    -    auto_increment = True
                                                                                                                                    -    field_type = 'AUTO'
                                                                                                                                    -
                                                                                                                                    -    def __init__(self, *args, **kwargs):
                                                                                                                                    -        if kwargs.get('primary_key') is False:
                                                                                                                                    -            raise ValueError('%s must always be a primary key.' % type(self))
                                                                                                                                    -        kwargs['primary_key'] = True
                                                                                                                                    -        super(AutoField, self).__init__(*args, **kwargs)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class BigAutoField(AutoField):
                                                                                                                                    -    field_type = 'BIGAUTO'
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class IdentityField(AutoField):
                                                                                                                                    -    field_type = 'INT GENERATED BY DEFAULT AS IDENTITY'
                                                                                                                                    -
                                                                                                                                    -    def __init__(self, generate_always=False, **kwargs):
                                                                                                                                    -        if generate_always:
                                                                                                                                    -            self.field_type = 'INT GENERATED ALWAYS AS IDENTITY'
                                                                                                                                    -        super(IdentityField, self).__init__(**kwargs)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class PrimaryKeyField(AutoField):
                                                                                                                                    -    def __init__(self, *args, **kwargs):
                                                                                                                                    -        __deprecated__('"PrimaryKeyField" has been renamed to "AutoField". '
                                                                                                                                    -                       'Please update your code accordingly as this will be '
                                                                                                                                    -                       'completely removed in a subsequent release.')
                                                                                                                                    -        super(PrimaryKeyField, self).__init__(*args, **kwargs)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class FloatField(Field):
                                                                                                                                    -    field_type = 'FLOAT'
                                                                                                                                    -
                                                                                                                                    -    def adapt(self, value):
                                                                                                                                    -        try:
                                                                                                                                    -            return float(value)
                                                                                                                                    -        except ValueError:
                                                                                                                                    -            return value
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class DoubleField(FloatField):
                                                                                                                                    -    field_type = 'DOUBLE'
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class DecimalField(Field):
                                                                                                                                    -    field_type = 'DECIMAL'
                                                                                                                                    -
                                                                                                                                    -    def __init__(self, max_digits=10, decimal_places=5, auto_round=False,
                                                                                                                                    -                 rounding=None, *args, **kwargs):
                                                                                                                                    -        self.max_digits = max_digits
                                                                                                                                    -        self.decimal_places = decimal_places
                                                                                                                                    -        self.auto_round = auto_round
                                                                                                                                    -        self.rounding = rounding or decimal.DefaultContext.rounding
                                                                                                                                    -        self._exp = decimal.Decimal(10) ** (-self.decimal_places)
                                                                                                                                    -        super(DecimalField, self).__init__(*args, **kwargs)
                                                                                                                                    -
                                                                                                                                    -    def get_modifiers(self):
                                                                                                                                    -        return [self.max_digits, self.decimal_places]
                                                                                                                                    -
                                                                                                                                    -    def db_value(self, value):
                                                                                                                                    -        D = decimal.Decimal
                                                                                                                                    -        if not value:
                                                                                                                                    -            return value if value is None else D(0)
                                                                                                                                    -        if self.auto_round:
                                                                                                                                    -            decimal_value = D(text_type(value))
                                                                                                                                    -            return decimal_value.quantize(self._exp, rounding=self.rounding)
                                                                                                                                    -        return value
                                                                                                                                    -
                                                                                                                                    -    def python_value(self, value):
                                                                                                                                    -        if value is not None:
                                                                                                                                    -            if isinstance(value, decimal.Decimal):
                                                                                                                                    -                return value
                                                                                                                                    -            return decimal.Decimal(text_type(value))
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class _StringField(Field):
                                                                                                                                    -    def adapt(self, value):
                                                                                                                                    -        if isinstance(value, text_type):
                                                                                                                                    -            return value
                                                                                                                                    -        elif isinstance(value, bytes_type):
                                                                                                                                    -            return value.decode('utf-8')
                                                                                                                                    -        return text_type(value)
                                                                                                                                    -
                                                                                                                                    -    def __add__(self, other): return StringExpression(self, OP.CONCAT, other)
                                                                                                                                    -    def __radd__(self, other): return StringExpression(other, OP.CONCAT, self)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class CharField(_StringField):
                                                                                                                                    -    field_type = 'VARCHAR'
                                                                                                                                    -
                                                                                                                                    -    def __init__(self, max_length=255, *args, **kwargs):
                                                                                                                                    -        self.max_length = max_length
                                                                                                                                    -        super(CharField, self).__init__(*args, **kwargs)
                                                                                                                                    -
                                                                                                                                    -    def get_modifiers(self):
                                                                                                                                    -        return self.max_length and [self.max_length] or None
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class FixedCharField(CharField):
                                                                                                                                    -    field_type = 'CHAR'
                                                                                                                                    -
                                                                                                                                    -    def python_value(self, value):
                                                                                                                                    -        value = super(FixedCharField, self).python_value(value)
                                                                                                                                    -        if value:
                                                                                                                                    -            value = value.strip()
                                                                                                                                    -        return value
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class TextField(_StringField):
                                                                                                                                    -    field_type = 'TEXT'
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class BlobField(Field):
                                                                                                                                    -    field_type = 'BLOB'
                                                                                                                                    -
                                                                                                                                    -    def _db_hook(self, database):
                                                                                                                                    -        if database is None:
                                                                                                                                    -            self._constructor = bytearray
                                                                                                                                    -        else:
                                                                                                                                    -            self._constructor = database.get_binary_type()
                                                                                                                                    -
                                                                                                                                    -    def bind(self, model, name, set_attribute=True):
                                                                                                                                    -        self._constructor = bytearray
                                                                                                                                    -        if model._meta.database:
                                                                                                                                    -            if isinstance(model._meta.database, Proxy):
                                                                                                                                    -                model._meta.database.attach_callback(self._db_hook)
                                                                                                                                    -            else:
                                                                                                                                    -                self._db_hook(model._meta.database)
                                                                                                                                    -
                                                                                                                                    -        # Attach a hook to the model metadata; in the event the database is
                                                                                                                                    -        # changed or set at run-time, we will be sure to apply our callback and
                                                                                                                                    -        # use the proper data-type for our database driver.
                                                                                                                                    -        model._meta._db_hooks.append(self._db_hook)
                                                                                                                                    -        return super(BlobField, self).bind(model, name, set_attribute)
                                                                                                                                    -
                                                                                                                                    -    def db_value(self, value):
                                                                                                                                    -        if isinstance(value, text_type):
                                                                                                                                    -            value = value.encode('raw_unicode_escape')
                                                                                                                                    -        if isinstance(value, bytes_type):
                                                                                                                                    -            return self._constructor(value)
                                                                                                                                    -        return value
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class BitField(BitwiseMixin, BigIntegerField):
                                                                                                                                    -    def __init__(self, *args, **kwargs):
                                                                                                                                    -        kwargs.setdefault('default', 0)
                                                                                                                                    -        super(BitField, self).__init__(*args, **kwargs)
                                                                                                                                    -        self.__current_flag = 1
                                                                                                                                    -
                                                                                                                                    -    def flag(self, value=None):
                                                                                                                                    -        if value is None:
                                                                                                                                    -            value = self.__current_flag
                                                                                                                                    -            self.__current_flag <<= 1
                                                                                                                                    -        else:
                                                                                                                                    -            self.__current_flag = value << 1
                                                                                                                                    -
                                                                                                                                    -        class FlagDescriptor(ColumnBase):
                                                                                                                                    -            def __init__(self, field, value):
                                                                                                                                    -                self._field = field
                                                                                                                                    -                self._value = value
                                                                                                                                    -                super(FlagDescriptor, self).__init__()
                                                                                                                                    -            def clear(self):
                                                                                                                                    -                return self._field.bin_and(~self._value)
                                                                                                                                    -            def set(self):
                                                                                                                                    -                return self._field.bin_or(self._value)
                                                                                                                                    -            def __get__(self, instance, instance_type=None):
                                                                                                                                    -                if instance is None:
                                                                                                                                    -                    return self
                                                                                                                                    -                value = getattr(instance, self._field.name) or 0
                                                                                                                                    -                return (value & self._value) != 0
                                                                                                                                    -            def __set__(self, instance, is_set):
                                                                                                                                    -                if is_set not in (True, False):
                                                                                                                                    -                    raise ValueError('Value must be either True or False')
                                                                                                                                    -                value = getattr(instance, self._field.name) or 0
                                                                                                                                    -                if is_set:
                                                                                                                                    -                    value |= self._value
                                                                                                                                    -                else:
                                                                                                                                    -                    value &= ~self._value
                                                                                                                                    -                setattr(instance, self._field.name, value)
                                                                                                                                    -            def __sql__(self, ctx):
                                                                                                                                    -                return ctx.sql(self._field.bin_and(self._value) != 0)
                                                                                                                                    -        return FlagDescriptor(self, value)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class BigBitFieldData(object):
                                                                                                                                    -    def __init__(self, instance, name):
                                                                                                                                    -        self.instance = instance
                                                                                                                                    -        self.name = name
                                                                                                                                    -        value = self.instance.__data__.get(self.name)
                                                                                                                                    -        if not value:
                                                                                                                                    -            value = bytearray()
                                                                                                                                    -        elif not isinstance(value, bytearray):
                                                                                                                                    -            value = bytearray(value)
                                                                                                                                    -        self._buffer = self.instance.__data__[self.name] = value
                                                                                                                                    -
                                                                                                                                    -    def _ensure_length(self, idx):
                                                                                                                                    -        byte_num, byte_offset = divmod(idx, 8)
                                                                                                                                    -        cur_size = len(self._buffer)
                                                                                                                                    -        if cur_size <= byte_num:
                                                                                                                                    -            self._buffer.extend(b'\x00' * ((byte_num + 1) - cur_size))
                                                                                                                                    -        return byte_num, byte_offset
                                                                                                                                    -
                                                                                                                                    -    def set_bit(self, idx):
                                                                                                                                    -        byte_num, byte_offset = self._ensure_length(idx)
                                                                                                                                    -        self._buffer[byte_num] |= (1 << byte_offset)
                                                                                                                                    -
                                                                                                                                    -    def clear_bit(self, idx):
                                                                                                                                    -        byte_num, byte_offset = self._ensure_length(idx)
                                                                                                                                    -        self._buffer[byte_num] &= ~(1 << byte_offset)
                                                                                                                                    -
                                                                                                                                    -    def toggle_bit(self, idx):
                                                                                                                                    -        byte_num, byte_offset = self._ensure_length(idx)
                                                                                                                                    -        self._buffer[byte_num] ^= (1 << byte_offset)
                                                                                                                                    -        return bool(self._buffer[byte_num] & (1 << byte_offset))
                                                                                                                                    -
                                                                                                                                    -    def is_set(self, idx):
                                                                                                                                    -        byte_num, byte_offset = self._ensure_length(idx)
                                                                                                                                    -        return bool(self._buffer[byte_num] & (1 << byte_offset))
                                                                                                                                    -
                                                                                                                                    -    def __repr__(self):
                                                                                                                                    -        return repr(self._buffer)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class BigBitFieldAccessor(FieldAccessor):
                                                                                                                                    -    def __get__(self, instance, instance_type=None):
                                                                                                                                    -        if instance is None:
                                                                                                                                    -            return self.field
                                                                                                                                    -        return BigBitFieldData(instance, self.name)
                                                                                                                                    -    def __set__(self, instance, value):
                                                                                                                                    -        if isinstance(value, memoryview):
                                                                                                                                    -            value = value.tobytes()
                                                                                                                                    -        elif isinstance(value, buffer_type):
                                                                                                                                    -            value = bytes(value)
                                                                                                                                    -        elif isinstance(value, bytearray):
                                                                                                                                    -            value = bytes_type(value)
                                                                                                                                    -        elif isinstance(value, BigBitFieldData):
                                                                                                                                    -            value = bytes_type(value._buffer)
                                                                                                                                    -        elif isinstance(value, text_type):
                                                                                                                                    -            value = value.encode('utf-8')
                                                                                                                                    -        elif not isinstance(value, bytes_type):
                                                                                                                                    -            raise ValueError('Value must be either a bytes, memoryview or '
                                                                                                                                    -                             'BigBitFieldData instance.')
                                                                                                                                    -        super(BigBitFieldAccessor, self).__set__(instance, value)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class BigBitField(BlobField):
                                                                                                                                    -    accessor_class = BigBitFieldAccessor
                                                                                                                                    -
                                                                                                                                    -    def __init__(self, *args, **kwargs):
                                                                                                                                    -        kwargs.setdefault('default', bytes_type)
                                                                                                                                    -        super(BigBitField, self).__init__(*args, **kwargs)
                                                                                                                                    -
                                                                                                                                    -    def db_value(self, value):
                                                                                                                                    -        return bytes_type(value) if value is not None else value
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class UUIDField(Field):
                                                                                                                                    -    field_type = 'UUID'
                                                                                                                                    -
                                                                                                                                    -    def db_value(self, value):
                                                                                                                                    -        if isinstance(value, basestring) and len(value) == 32:
                                                                                                                                    -            # Hex string. No transformation is necessary.
                                                                                                                                    -            return value
                                                                                                                                    -        elif isinstance(value, bytes) and len(value) == 16:
                                                                                                                                    -            # Allow raw binary representation.
                                                                                                                                    -            value = uuid.UUID(bytes=value)
                                                                                                                                    -        if isinstance(value, uuid.UUID):
                                                                                                                                    -            return value.hex
                                                                                                                                    -        try:
                                                                                                                                    -            return uuid.UUID(value).hex
                                                                                                                                    -        except:
                                                                                                                                    -            return value
                                                                                                                                    -
                                                                                                                                    -    def python_value(self, value):
                                                                                                                                    -        if isinstance(value, uuid.UUID):
                                                                                                                                    -            return value
                                                                                                                                    -        return uuid.UUID(value) if value is not None else None
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class BinaryUUIDField(BlobField):
                                                                                                                                    -    field_type = 'UUIDB'
                                                                                                                                    -
                                                                                                                                    -    def db_value(self, value):
                                                                                                                                    -        if isinstance(value, bytes) and len(value) == 16:
                                                                                                                                    -            # Raw binary value. No transformation is necessary.
                                                                                                                                    -            return self._constructor(value)
                                                                                                                                    -        elif isinstance(value, basestring) and len(value) == 32:
                                                                                                                                    -            # Allow hex string representation.
                                                                                                                                    -            value = uuid.UUID(hex=value)
                                                                                                                                    -        if isinstance(value, uuid.UUID):
                                                                                                                                    -            return self._constructor(value.bytes)
                                                                                                                                    -        elif value is not None:
                                                                                                                                    -            raise ValueError('value for binary UUID field must be UUID(), '
                                                                                                                                    -                             'a hexadecimal string, or a bytes object.')
                                                                                                                                    -
                                                                                                                                    -    def python_value(self, value):
                                                                                                                                    -        if isinstance(value, uuid.UUID):
                                                                                                                                    -            return value
                                                                                                                                    -        elif isinstance(value, memoryview):
                                                                                                                                    -            value = value.tobytes()
                                                                                                                                    -        elif value and not isinstance(value, bytes):
                                                                                                                                    -            value = bytes(value)
                                                                                                                                    -        return uuid.UUID(bytes=value) if value is not None else None
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -def _date_part(date_part):
                                                                                                                                    -    def dec(self):
                                                                                                                                    -        return self.model._meta.database.extract_date(date_part, self)
                                                                                                                                    -    return dec
                                                                                                                                    -
                                                                                                                                    -def format_date_time(value, formats, post_process=None):
                                                                                                                                    -    post_process = post_process or (lambda x: x)
                                                                                                                                    -    for fmt in formats:
                                                                                                                                    -        try:
                                                                                                                                    -            return post_process(datetime.datetime.strptime(value, fmt))
                                                                                                                                    -        except ValueError:
                                                                                                                                    -            pass
                                                                                                                                    -    return value
                                                                                                                                    -
                                                                                                                                    -def simple_date_time(value):
                                                                                                                                    -    try:
                                                                                                                                    -        return datetime.datetime.strptime(value, '%Y-%m-%d %H:%M:%S')
                                                                                                                                    -    except (TypeError, ValueError):
                                                                                                                                    -        return value
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class _BaseFormattedField(Field):
                                                                                                                                    -    formats = None
                                                                                                                                    -
                                                                                                                                    -    def __init__(self, formats=None, *args, **kwargs):
                                                                                                                                    -        if formats is not None:
                                                                                                                                    -            self.formats = formats
                                                                                                                                    -        super(_BaseFormattedField, self).__init__(*args, **kwargs)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class DateTimeField(_BaseFormattedField):
                                                                                                                                    -    field_type = 'DATETIME'
                                                                                                                                    -    formats = [
                                                                                                                                    -        '%Y-%m-%d %H:%M:%S.%f',
                                                                                                                                    -        '%Y-%m-%d %H:%M:%S',
                                                                                                                                    -        '%Y-%m-%d',
                                                                                                                                    -    ]
                                                                                                                                    -
                                                                                                                                    -    def adapt(self, value):
                                                                                                                                    -        if value and isinstance(value, basestring):
                                                                                                                                    -            return format_date_time(value, self.formats)
                                                                                                                                    -        return value
                                                                                                                                    -
                                                                                                                                    -    def to_timestamp(self):
                                                                                                                                    -        return self.model._meta.database.to_timestamp(self)
                                                                                                                                    -
                                                                                                                                    -    def truncate(self, part):
                                                                                                                                    -        return self.model._meta.database.truncate_date(part, self)
                                                                                                                                    -
                                                                                                                                    -    year = property(_date_part('year'))
                                                                                                                                    -    month = property(_date_part('month'))
                                                                                                                                    -    day = property(_date_part('day'))
                                                                                                                                    -    hour = property(_date_part('hour'))
                                                                                                                                    -    minute = property(_date_part('minute'))
                                                                                                                                    -    second = property(_date_part('second'))
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class DateField(_BaseFormattedField):
                                                                                                                                    -    field_type = 'DATE'
                                                                                                                                    -    formats = [
                                                                                                                                    -        '%Y-%m-%d',
                                                                                                                                    -        '%Y-%m-%d %H:%M:%S',
                                                                                                                                    -        '%Y-%m-%d %H:%M:%S.%f',
                                                                                                                                    -    ]
                                                                                                                                    -
                                                                                                                                    -    def adapt(self, value):
                                                                                                                                    -        if value and isinstance(value, basestring):
                                                                                                                                    -            pp = lambda x: x.date()
                                                                                                                                    -            return format_date_time(value, self.formats, pp)
                                                                                                                                    -        elif value and isinstance(value, datetime.datetime):
                                                                                                                                    -            return value.date()
                                                                                                                                    -        return value
                                                                                                                                    -
                                                                                                                                    -    def to_timestamp(self):
                                                                                                                                    -        return self.model._meta.database.to_timestamp(self)
                                                                                                                                    -
                                                                                                                                    -    def truncate(self, part):
                                                                                                                                    -        return self.model._meta.database.truncate_date(part, self)
                                                                                                                                    -
                                                                                                                                    -    year = property(_date_part('year'))
                                                                                                                                    -    month = property(_date_part('month'))
                                                                                                                                    -    day = property(_date_part('day'))
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class TimeField(_BaseFormattedField):
                                                                                                                                    -    field_type = 'TIME'
                                                                                                                                    -    formats = [
                                                                                                                                    -        '%H:%M:%S.%f',
                                                                                                                                    -        '%H:%M:%S',
                                                                                                                                    -        '%H:%M',
                                                                                                                                    -        '%Y-%m-%d %H:%M:%S.%f',
                                                                                                                                    -        '%Y-%m-%d %H:%M:%S',
                                                                                                                                    -    ]
                                                                                                                                    -
                                                                                                                                    -    def adapt(self, value):
                                                                                                                                    -        if value:
                                                                                                                                    -            if isinstance(value, basestring):
                                                                                                                                    -                pp = lambda x: x.time()
                                                                                                                                    -                return format_date_time(value, self.formats, pp)
                                                                                                                                    -            elif isinstance(value, datetime.datetime):
                                                                                                                                    -                return value.time()
                                                                                                                                    -        if value is not None and isinstance(value, datetime.timedelta):
                                                                                                                                    -            return (datetime.datetime.min + value).time()
                                                                                                                                    -        return value
                                                                                                                                    -
                                                                                                                                    -    hour = property(_date_part('hour'))
                                                                                                                                    -    minute = property(_date_part('minute'))
                                                                                                                                    -    second = property(_date_part('second'))
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -def _timestamp_date_part(date_part):
                                                                                                                                    -    def dec(self):
                                                                                                                                    -        db = self.model._meta.database
                                                                                                                                    -        expr = ((self / Value(self.resolution, converter=False))
                                                                                                                                    -                if self.resolution > 1 else self)
                                                                                                                                    -        return db.extract_date(date_part, db.from_timestamp(expr))
                                                                                                                                    -    return dec
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class TimestampField(BigIntegerField):
                                                                                                                                    -    # Support second -> microsecond resolution.
                                                                                                                                    -    valid_resolutions = [10**i for i in range(7)]
                                                                                                                                    -
                                                                                                                                    -    def __init__(self, *args, **kwargs):
                                                                                                                                    -        self.resolution = kwargs.pop('resolution', None)
                                                                                                                                    -
                                                                                                                                    -        if not self.resolution:
                                                                                                                                    -            self.resolution = 1
                                                                                                                                    -        elif self.resolution in range(2, 7):
                                                                                                                                    -            self.resolution = 10 ** self.resolution
                                                                                                                                    -        elif self.resolution not in self.valid_resolutions:
                                                                                                                                    -            raise ValueError('TimestampField resolution must be one of: %s' %
                                                                                                                                    -                             ', '.join(str(i) for i in self.valid_resolutions))
                                                                                                                                    -        self.ticks_to_microsecond = 1000000 // self.resolution
                                                                                                                                    -
                                                                                                                                    -        self.utc = kwargs.pop('utc', False) or False
                                                                                                                                    -        dflt = datetime.datetime.utcnow if self.utc else datetime.datetime.now
                                                                                                                                    -        kwargs.setdefault('default', dflt)
                                                                                                                                    -        super(TimestampField, self).__init__(*args, **kwargs)
                                                                                                                                    -
                                                                                                                                    -    def local_to_utc(self, dt):
                                                                                                                                    -        # Convert naive local datetime into naive UTC, e.g.:
                                                                                                                                    -        # 2019-03-01T12:00:00 (local=US/Central) -> 2019-03-01T18:00:00.
                                                                                                                                    -        # 2019-05-01T12:00:00 (local=US/Central) -> 2019-05-01T17:00:00.
                                                                                                                                    -        # 2019-03-01T12:00:00 (local=UTC)        -> 2019-03-01T12:00:00.
                                                                                                                                    -        return datetime.datetime(*time.gmtime(time.mktime(dt.timetuple()))[:6])
                                                                                                                                    -
                                                                                                                                    -    def utc_to_local(self, dt):
                                                                                                                                    -        # Convert a naive UTC datetime into local time, e.g.:
                                                                                                                                    -        # 2019-03-01T18:00:00 (local=US/Central) -> 2019-03-01T12:00:00.
                                                                                                                                    -        # 2019-05-01T17:00:00 (local=US/Central) -> 2019-05-01T12:00:00.
                                                                                                                                    -        # 2019-03-01T12:00:00 (local=UTC)        -> 2019-03-01T12:00:00.
                                                                                                                                    -        ts = calendar.timegm(dt.utctimetuple())
                                                                                                                                    -        return datetime.datetime.fromtimestamp(ts)
                                                                                                                                    -
                                                                                                                                    -    def get_timestamp(self, value):
                                                                                                                                    -        if self.utc:
                                                                                                                                    -            # If utc-mode is on, then we assume all naive datetimes are in UTC.
                                                                                                                                    -            return calendar.timegm(value.utctimetuple())
                                                                                                                                    -        else:
                                                                                                                                    -            return time.mktime(value.timetuple())
                                                                                                                                    -
                                                                                                                                    -    def db_value(self, value):
                                                                                                                                    -        if value is None:
                                                                                                                                    -            return
                                                                                                                                    -
                                                                                                                                    -        if isinstance(value, datetime.datetime):
                                                                                                                                    -            pass
                                                                                                                                    -        elif isinstance(value, datetime.date):
                                                                                                                                    -            value = datetime.datetime(value.year, value.month, value.day)
                                                                                                                                    -        else:
                                                                                                                                    -            return int(round(value * self.resolution))
                                                                                                                                    -
                                                                                                                                    -        timestamp = self.get_timestamp(value)
                                                                                                                                    -        if self.resolution > 1:
                                                                                                                                    -            timestamp += (value.microsecond * .000001)
                                                                                                                                    -            timestamp *= self.resolution
                                                                                                                                    -        return int(round(timestamp))
                                                                                                                                    -
                                                                                                                                    -    def python_value(self, value):
                                                                                                                                    -        if value is not None and isinstance(value, (int, float, long)):
                                                                                                                                    -            if self.resolution > 1:
                                                                                                                                    -                value, ticks = divmod(value, self.resolution)
                                                                                                                                    -                microseconds = int(ticks * self.ticks_to_microsecond)
                                                                                                                                    -            else:
                                                                                                                                    -                microseconds = 0
                                                                                                                                    -
                                                                                                                                    -            if self.utc:
                                                                                                                                    -                value = datetime.datetime.utcfromtimestamp(value)
                                                                                                                                    -            else:
                                                                                                                                    -                value = datetime.datetime.fromtimestamp(value)
                                                                                                                                    -
                                                                                                                                    -            if microseconds:
                                                                                                                                    -                value = value.replace(microsecond=microseconds)
                                                                                                                                    -
                                                                                                                                    -        return value
                                                                                                                                    -
                                                                                                                                    -    def from_timestamp(self):
                                                                                                                                    -        expr = ((self / Value(self.resolution, converter=False))
                                                                                                                                    -                if self.resolution > 1 else self)
                                                                                                                                    -        return self.model._meta.database.from_timestamp(expr)
                                                                                                                                    -
                                                                                                                                    -    year = property(_timestamp_date_part('year'))
                                                                                                                                    -    month = property(_timestamp_date_part('month'))
                                                                                                                                    -    day = property(_timestamp_date_part('day'))
                                                                                                                                    -    hour = property(_timestamp_date_part('hour'))
                                                                                                                                    -    minute = property(_timestamp_date_part('minute'))
                                                                                                                                    -    second = property(_timestamp_date_part('second'))
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class IPField(BigIntegerField):
                                                                                                                                    -    def db_value(self, val):
                                                                                                                                    -        if val is not None:
                                                                                                                                    -            return struct.unpack('!I', socket.inet_aton(val))[0]
                                                                                                                                    -
                                                                                                                                    -    def python_value(self, val):
                                                                                                                                    -        if val is not None:
                                                                                                                                    -            return socket.inet_ntoa(struct.pack('!I', val))
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class BooleanField(Field):
                                                                                                                                    -    field_type = 'BOOL'
                                                                                                                                    -    adapt = bool
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class BareField(Field):
                                                                                                                                    -    def __init__(self, adapt=None, *args, **kwargs):
                                                                                                                                    -        super(BareField, self).__init__(*args, **kwargs)
                                                                                                                                    -        if adapt is not None:
                                                                                                                                    -            self.adapt = adapt
                                                                                                                                    -
                                                                                                                                    -    def ddl_datatype(self, ctx):
                                                                                                                                    -        return
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class ForeignKeyField(Field):
                                                                                                                                    -    accessor_class = ForeignKeyAccessor
                                                                                                                                    -
                                                                                                                                    -    def __init__(self, model, field=None, backref=None, on_delete=None,
                                                                                                                                    -                 on_update=None, deferrable=None, _deferred=None,
                                                                                                                                    -                 rel_model=None, to_field=None, object_id_name=None,
                                                                                                                                    -                 lazy_load=True, related_name=None, *args, **kwargs):
                                                                                                                                    -        kwargs.setdefault('index', True)
                                                                                                                                    -
                                                                                                                                    -        # If lazy_load is disable, we use a different descriptor/accessor that
                                                                                                                                    -        # will ensure we don't accidentally perform a query.
                                                                                                                                    -        if not lazy_load:
                                                                                                                                    -            self.accessor_class = NoQueryForeignKeyAccessor
                                                                                                                                    -
                                                                                                                                    -        super(ForeignKeyField, self).__init__(*args, **kwargs)
                                                                                                                                    -
                                                                                                                                    -        if rel_model is not None:
                                                                                                                                    -            __deprecated__('"rel_model" has been deprecated in favor of '
                                                                                                                                    -                           '"model" for ForeignKeyField objects.')
                                                                                                                                    -            model = rel_model
                                                                                                                                    -        if to_field is not None:
                                                                                                                                    -            __deprecated__('"to_field" has been deprecated in favor of '
                                                                                                                                    -                           '"field" for ForeignKeyField objects.')
                                                                                                                                    -            field = to_field
                                                                                                                                    -        if related_name is not None:
                                                                                                                                    -            __deprecated__('"related_name" has been deprecated in favor of '
                                                                                                                                    -                           '"backref" for Field objects.')
                                                                                                                                    -            backref = related_name
                                                                                                                                    -
                                                                                                                                    -        self._is_self_reference = model == 'self'
                                                                                                                                    -        self.rel_model = model
                                                                                                                                    -        self.rel_field = field
                                                                                                                                    -        self.declared_backref = backref
                                                                                                                                    -        self.backref = None
                                                                                                                                    -        self.on_delete = on_delete
                                                                                                                                    -        self.on_update = on_update
                                                                                                                                    -        self.deferrable = deferrable
                                                                                                                                    -        self.deferred = _deferred
                                                                                                                                    -        self.object_id_name = object_id_name
                                                                                                                                    -        self.lazy_load = lazy_load
                                                                                                                                    -
                                                                                                                                    -    @property
                                                                                                                                    -    def field_type(self):
                                                                                                                                    -        if not isinstance(self.rel_field, AutoField):
                                                                                                                                    -            return self.rel_field.field_type
                                                                                                                                    -        elif isinstance(self.rel_field, BigAutoField):
                                                                                                                                    -            return BigIntegerField.field_type
                                                                                                                                    -        return IntegerField.field_type
                                                                                                                                    -
                                                                                                                                    -    def get_modifiers(self):
                                                                                                                                    -        if not isinstance(self.rel_field, AutoField):
                                                                                                                                    -            return self.rel_field.get_modifiers()
                                                                                                                                    -        return super(ForeignKeyField, self).get_modifiers()
                                                                                                                                    -
                                                                                                                                    -    def adapt(self, value):
                                                                                                                                    -        return self.rel_field.adapt(value)
                                                                                                                                    -
                                                                                                                                    -    def db_value(self, value):
                                                                                                                                    -        if isinstance(value, self.rel_model):
                                                                                                                                    -            value = getattr(value, self.rel_field.name)
                                                                                                                                    -        return self.rel_field.db_value(value)
                                                                                                                                    -
                                                                                                                                    -    def python_value(self, value):
                                                                                                                                    -        if isinstance(value, self.rel_model):
                                                                                                                                    -            return value
                                                                                                                                    -        return self.rel_field.python_value(value)
                                                                                                                                    -
                                                                                                                                    -    def bind(self, model, name, set_attribute=True):
                                                                                                                                    -        if not self.column_name:
                                                                                                                                    -            self.column_name = name if name.endswith('_id') else name + '_id'
                                                                                                                                    -        if not self.object_id_name:
                                                                                                                                    -            self.object_id_name = self.column_name
                                                                                                                                    -            if self.object_id_name == name:
                                                                                                                                    -                self.object_id_name += '_id'
                                                                                                                                    -        elif self.object_id_name == name:
                                                                                                                                    -            raise ValueError('ForeignKeyField "%s"."%s" specifies an '
                                                                                                                                    -                             'object_id_name that conflicts with its field '
                                                                                                                                    -                             'name.' % (model._meta.name, name))
                                                                                                                                    -        if self._is_self_reference:
                                                                                                                                    -            self.rel_model = model
                                                                                                                                    -        if isinstance(self.rel_field, basestring):
                                                                                                                                    -            self.rel_field = getattr(self.rel_model, self.rel_field)
                                                                                                                                    -        elif self.rel_field is None:
                                                                                                                                    -            self.rel_field = self.rel_model._meta.primary_key
                                                                                                                                    -
                                                                                                                                    -        # Bind field before assigning backref, so field is bound when
                                                                                                                                    -        # calling declared_backref() (if callable).
                                                                                                                                    -        super(ForeignKeyField, self).bind(model, name, set_attribute)
                                                                                                                                    -        self.safe_name = self.object_id_name
                                                                                                                                    -
                                                                                                                                    -        if callable_(self.declared_backref):
                                                                                                                                    -            self.backref = self.declared_backref(self)
                                                                                                                                    -        else:
                                                                                                                                    -            self.backref, self.declared_backref = self.declared_backref, None
                                                                                                                                    -        if not self.backref:
                                                                                                                                    -            self.backref = '%s_set' % model._meta.name
                                                                                                                                    -
                                                                                                                                    -        if set_attribute:
                                                                                                                                    -            setattr(model, self.object_id_name, ObjectIdAccessor(self))
                                                                                                                                    -            if self.backref not in '!+':
                                                                                                                                    -                setattr(self.rel_model, self.backref, BackrefAccessor(self))
                                                                                                                                    -
                                                                                                                                    -    def foreign_key_constraint(self):
                                                                                                                                    -        parts = [
                                                                                                                                    -            SQL('FOREIGN KEY'),
                                                                                                                                    -            EnclosedNodeList((self,)),
                                                                                                                                    -            SQL('REFERENCES'),
                                                                                                                                    -            self.rel_model,
                                                                                                                                    -            EnclosedNodeList((self.rel_field,))]
                                                                                                                                    -        if self.on_delete:
                                                                                                                                    -            parts.append(SQL('ON DELETE %s' % self.on_delete))
                                                                                                                                    -        if self.on_update:
                                                                                                                                    -            parts.append(SQL('ON UPDATE %s' % self.on_update))
                                                                                                                                    -        if self.deferrable:
                                                                                                                                    -            parts.append(SQL('DEFERRABLE %s' % self.deferrable))
                                                                                                                                    -        return NodeList(parts)
                                                                                                                                    -
                                                                                                                                    -    def __getattr__(self, attr):
                                                                                                                                    -        if attr.startswith('__'):
                                                                                                                                    -            # Prevent recursion error when deep-copying.
                                                                                                                                    -            raise AttributeError('Cannot look-up non-existant "__" methods.')
                                                                                                                                    -        if attr in self.rel_model._meta.fields:
                                                                                                                                    -            return self.rel_model._meta.fields[attr]
                                                                                                                                    -        raise AttributeError('Foreign-key has no attribute %s, nor is it a '
                                                                                                                                    -                             'valid field on the related model.' % attr)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class DeferredForeignKey(Field):
                                                                                                                                    -    _unresolved = set()
                                                                                                                                    -
                                                                                                                                    -    def __init__(self, rel_model_name, **kwargs):
                                                                                                                                    -        self.field_kwargs = kwargs
                                                                                                                                    -        self.rel_model_name = rel_model_name.lower()
                                                                                                                                    -        DeferredForeignKey._unresolved.add(self)
                                                                                                                                    -        super(DeferredForeignKey, self).__init__(
                                                                                                                                    -            column_name=kwargs.get('column_name'),
                                                                                                                                    -            null=kwargs.get('null'))
                                                                                                                                    -
                                                                                                                                    -    __hash__ = object.__hash__
                                                                                                                                    -
                                                                                                                                    -    def __deepcopy__(self, memo=None):
                                                                                                                                    -        return DeferredForeignKey(self.rel_model_name, **self.field_kwargs)
                                                                                                                                    -
                                                                                                                                    -    def set_model(self, rel_model):
                                                                                                                                    -        field = ForeignKeyField(rel_model, _deferred=True, **self.field_kwargs)
                                                                                                                                    -        self.model._meta.add_field(self.name, field)
                                                                                                                                    -
                                                                                                                                    -    @staticmethod
                                                                                                                                    -    def resolve(model_cls):
                                                                                                                                    -        unresolved = sorted(DeferredForeignKey._unresolved,
                                                                                                                                    -                            key=operator.attrgetter('_order'))
                                                                                                                                    -        for dr in unresolved:
                                                                                                                                    -            if dr.rel_model_name == model_cls.__name__.lower():
                                                                                                                                    -                dr.set_model(model_cls)
                                                                                                                                    -                DeferredForeignKey._unresolved.discard(dr)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class DeferredThroughModel(object):
                                                                                                                                    -    def __init__(self):
                                                                                                                                    -        self._refs = []
                                                                                                                                    -
                                                                                                                                    -    def set_field(self, model, field, name):
                                                                                                                                    -        self._refs.append((model, field, name))
                                                                                                                                    -
                                                                                                                                    -    def set_model(self, through_model):
                                                                                                                                    -        for src_model, m2mfield, name in self._refs:
                                                                                                                                    -            m2mfield.through_model = through_model
                                                                                                                                    -            src_model._meta.add_field(name, m2mfield)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class MetaField(Field):
                                                                                                                                    -    column_name = default = model = name = None
                                                                                                                                    -    primary_key = False
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class ManyToManyFieldAccessor(FieldAccessor):
                                                                                                                                    -    def __init__(self, model, field, name):
                                                                                                                                    -        super(ManyToManyFieldAccessor, self).__init__(model, field, name)
                                                                                                                                    -        self.model = field.model
                                                                                                                                    -        self.rel_model = field.rel_model
                                                                                                                                    -        self.through_model = field.through_model
                                                                                                                                    -        src_fks = self.through_model._meta.model_refs[self.model]
                                                                                                                                    -        dest_fks = self.through_model._meta.model_refs[self.rel_model]
                                                                                                                                    -        if not src_fks:
                                                                                                                                    -            raise ValueError('Cannot find foreign-key to "%s" on "%s" model.' %
                                                                                                                                    -                             (self.model, self.through_model))
                                                                                                                                    -        elif not dest_fks:
                                                                                                                                    -            raise ValueError('Cannot find foreign-key to "%s" on "%s" model.' %
                                                                                                                                    -                             (self.rel_model, self.through_model))
                                                                                                                                    -        self.src_fk = src_fks[0]
                                                                                                                                    -        self.dest_fk = dest_fks[0]
                                                                                                                                    -
                                                                                                                                    -    def __get__(self, instance, instance_type=None, force_query=False):
                                                                                                                                    -        if instance is not None:
                                                                                                                                    -            if not force_query and self.src_fk.backref != '+':
                                                                                                                                    -                backref = getattr(instance, self.src_fk.backref)
                                                                                                                                    -                if isinstance(backref, list):
                                                                                                                                    -                    return [getattr(obj, self.dest_fk.name) for obj in backref]
                                                                                                                                    -
                                                                                                                                    -            src_id = getattr(instance, self.src_fk.rel_field.name)
                                                                                                                                    -            return (ManyToManyQuery(instance, self, self.rel_model)
                                                                                                                                    -                    .join(self.through_model)
                                                                                                                                    -                    .join(self.model)
                                                                                                                                    -                    .where(self.src_fk == src_id))
                                                                                                                                    -
                                                                                                                                    -        return self.field
                                                                                                                                    -
                                                                                                                                    -    def __set__(self, instance, value):
                                                                                                                                    -        query = self.__get__(instance, force_query=True)
                                                                                                                                    -        query.add(value, clear_existing=True)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class ManyToManyField(MetaField):
                                                                                                                                    -    accessor_class = ManyToManyFieldAccessor
                                                                                                                                    -
                                                                                                                                    -    def __init__(self, model, backref=None, through_model=None, on_delete=None,
                                                                                                                                    -                 on_update=None, _is_backref=False):
                                                                                                                                    -        if through_model is not None:
                                                                                                                                    -            if not (isinstance(through_model, DeferredThroughModel) or
                                                                                                                                    -                    is_model(through_model)):
                                                                                                                                    -                raise TypeError('Unexpected value for through_model. Expected '
                                                                                                                                    -                                'Model or DeferredThroughModel.')
                                                                                                                                    -            if not _is_backref and (on_delete is not None or on_update is not None):
                                                                                                                                    -                raise ValueError('Cannot specify on_delete or on_update when '
                                                                                                                                    -                                 'through_model is specified.')
                                                                                                                                    -        self.rel_model = model
                                                                                                                                    -        self.backref = backref
                                                                                                                                    -        self._through_model = through_model
                                                                                                                                    -        self._on_delete = on_delete
                                                                                                                                    -        self._on_update = on_update
                                                                                                                                    -        self._is_backref = _is_backref
                                                                                                                                    -
                                                                                                                                    -    def _get_descriptor(self):
                                                                                                                                    -        return ManyToManyFieldAccessor(self)
                                                                                                                                    -
                                                                                                                                    -    def bind(self, model, name, set_attribute=True):
                                                                                                                                    -        if isinstance(self._through_model, DeferredThroughModel):
                                                                                                                                    -            self._through_model.set_field(model, self, name)
                                                                                                                                    -            return
                                                                                                                                    -
                                                                                                                                    -        super(ManyToManyField, self).bind(model, name, set_attribute)
                                                                                                                                    -
                                                                                                                                    -        if not self._is_backref:
                                                                                                                                    -            many_to_many_field = ManyToManyField(
                                                                                                                                    -                self.model,
                                                                                                                                    -                backref=name,
                                                                                                                                    -                through_model=self.through_model,
                                                                                                                                    -                on_delete=self._on_delete,
                                                                                                                                    -                on_update=self._on_update,
                                                                                                                                    -                _is_backref=True)
                                                                                                                                    -            self.backref = self.backref or model._meta.name + 's'
                                                                                                                                    -            self.rel_model._meta.add_field(self.backref, many_to_many_field)
                                                                                                                                    -
                                                                                                                                    -    def get_models(self):
                                                                                                                                    -        return [model for _, model in sorted((
                                                                                                                                    -            (self._is_backref, self.model),
                                                                                                                                    -            (not self._is_backref, self.rel_model)))]
                                                                                                                                    -
                                                                                                                                    -    @property
                                                                                                                                    -    def through_model(self):
                                                                                                                                    -        if self._through_model is None:
                                                                                                                                    -            self._through_model = self._create_through_model()
                                                                                                                                    -        return self._through_model
                                                                                                                                    -
                                                                                                                                    -    @through_model.setter
                                                                                                                                    -    def through_model(self, value):
                                                                                                                                    -        self._through_model = value
                                                                                                                                    -
                                                                                                                                    -    def _create_through_model(self):
                                                                                                                                    -        lhs, rhs = self.get_models()
                                                                                                                                    -        tables = [model._meta.table_name for model in (lhs, rhs)]
                                                                                                                                    -
                                                                                                                                    -        class Meta:
                                                                                                                                    -            database = self.model._meta.database
                                                                                                                                    -            schema = self.model._meta.schema
                                                                                                                                    -            table_name = '%s_%s_through' % tuple(tables)
                                                                                                                                    -            indexes = (
                                                                                                                                    -                ((lhs._meta.name, rhs._meta.name),
                                                                                                                                    -                 True),)
                                                                                                                                    -
                                                                                                                                    -        params = {'on_delete': self._on_delete, 'on_update': self._on_update}
                                                                                                                                    -        attrs = {
                                                                                                                                    -            lhs._meta.name: ForeignKeyField(lhs, **params),
                                                                                                                                    -            rhs._meta.name: ForeignKeyField(rhs, **params),
                                                                                                                                    -            'Meta': Meta}
                                                                                                                                    -
                                                                                                                                    -        klass_name = '%s%sThrough' % (lhs.__name__, rhs.__name__)
                                                                                                                                    -        return type(klass_name, (Model,), attrs)
                                                                                                                                    -
                                                                                                                                    -    def get_through_model(self):
                                                                                                                                    -        # XXX: Deprecated. Just use the "through_model" property.
                                                                                                                                    -        return self.through_model
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class VirtualField(MetaField):
                                                                                                                                    -    field_class = None
                                                                                                                                    -
                                                                                                                                    -    def __init__(self, field_class=None, *args, **kwargs):
                                                                                                                                    -        Field = field_class if field_class is not None else self.field_class
                                                                                                                                    -        self.field_instance = Field() if Field is not None else None
                                                                                                                                    -        super(VirtualField, self).__init__(*args, **kwargs)
                                                                                                                                    -
                                                                                                                                    -    def db_value(self, value):
                                                                                                                                    -        if self.field_instance is not None:
                                                                                                                                    -            return self.field_instance.db_value(value)
                                                                                                                                    -        return value
                                                                                                                                    -
                                                                                                                                    -    def python_value(self, value):
                                                                                                                                    -        if self.field_instance is not None:
                                                                                                                                    -            return self.field_instance.python_value(value)
                                                                                                                                    -        return value
                                                                                                                                    -
                                                                                                                                    -    def bind(self, model, name, set_attribute=True):
                                                                                                                                    -        self.model = model
                                                                                                                                    -        self.column_name = self.name = self.safe_name = name
                                                                                                                                    -        setattr(model, name, self.accessor_class(model, self, name))
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class CompositeKey(MetaField):
                                                                                                                                    -    sequence = None
                                                                                                                                    -
                                                                                                                                    -    def __init__(self, *field_names):
                                                                                                                                    -        self.field_names = field_names
                                                                                                                                    -        self._safe_field_names = None
                                                                                                                                    -
                                                                                                                                    -    @property
                                                                                                                                    -    def safe_field_names(self):
                                                                                                                                    -        if self._safe_field_names is None:
                                                                                                                                    -            if self.model is None:
                                                                                                                                    -                return self.field_names
                                                                                                                                    -
                                                                                                                                    -            self._safe_field_names = [self.model._meta.fields[f].safe_name
                                                                                                                                    -                                      for f in self.field_names]
                                                                                                                                    -        return self._safe_field_names
                                                                                                                                    -
                                                                                                                                    -    def __get__(self, instance, instance_type=None):
                                                                                                                                    -        if instance is not None:
                                                                                                                                    -            return tuple([getattr(instance, f) for f in self.safe_field_names])
                                                                                                                                    -        return self
                                                                                                                                    -
                                                                                                                                    -    def __set__(self, instance, value):
                                                                                                                                    -        if not isinstance(value, (list, tuple)):
                                                                                                                                    -            raise TypeError('A list or tuple must be used to set the value of '
                                                                                                                                    -                            'a composite primary key.')
                                                                                                                                    -        if len(value) != len(self.field_names):
                                                                                                                                    -            raise ValueError('The length of the value must equal the number '
                                                                                                                                    -                             'of columns of the composite primary key.')
                                                                                                                                    -        for idx, field_value in enumerate(value):
                                                                                                                                    -            setattr(instance, self.field_names[idx], field_value)
                                                                                                                                    -
                                                                                                                                    -    def __eq__(self, other):
                                                                                                                                    -        expressions = [(self.model._meta.fields[field] == value)
                                                                                                                                    -                       for field, value in zip(self.field_names, other)]
                                                                                                                                    -        return reduce(operator.and_, expressions)
                                                                                                                                    -
                                                                                                                                    -    def __ne__(self, other):
                                                                                                                                    -        return ~(self == other)
                                                                                                                                    -
                                                                                                                                    -    def __hash__(self):
                                                                                                                                    -        return hash((self.model.__name__, self.field_names))
                                                                                                                                    -
                                                                                                                                    -    def __sql__(self, ctx):
                                                                                                                                    -        # If the composite PK is being selected, do not use parens. Elsewhere,
                                                                                                                                    -        # such as in an expression, we want to use parentheses and treat it as
                                                                                                                                    -        # a row value.
                                                                                                                                    -        parens = ctx.scope != SCOPE_SOURCE
                                                                                                                                    -        return ctx.sql(NodeList([self.model._meta.fields[field]
                                                                                                                                    -                                 for field in self.field_names], ', ', parens))
                                                                                                                                    -
                                                                                                                                    -    def bind(self, model, name, set_attribute=True):
                                                                                                                                    -        self.model = model
                                                                                                                                    -        self.column_name = self.name = self.safe_name = name
                                                                                                                                    -        setattr(model, self.name, self)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class _SortedFieldList(object):
                                                                                                                                    -    __slots__ = ('_keys', '_items')
                                                                                                                                    -
                                                                                                                                    -    def __init__(self):
                                                                                                                                    -        self._keys = []
                                                                                                                                    -        self._items = []
                                                                                                                                    -
                                                                                                                                    -    def __getitem__(self, i):
                                                                                                                                    -        return self._items[i]
                                                                                                                                    -
                                                                                                                                    -    def __iter__(self):
                                                                                                                                    -        return iter(self._items)
                                                                                                                                    -
                                                                                                                                    -    def __contains__(self, item):
                                                                                                                                    -        k = item._sort_key
                                                                                                                                    -        i = bisect_left(self._keys, k)
                                                                                                                                    -        j = bisect_right(self._keys, k)
                                                                                                                                    -        return item in self._items[i:j]
                                                                                                                                    -
                                                                                                                                    -    def index(self, field):
                                                                                                                                    -        return self._keys.index(field._sort_key)
                                                                                                                                    -
                                                                                                                                    -    def insert(self, item):
                                                                                                                                    -        k = item._sort_key
                                                                                                                                    -        i = bisect_left(self._keys, k)
                                                                                                                                    -        self._keys.insert(i, k)
                                                                                                                                    -        self._items.insert(i, item)
                                                                                                                                    -
                                                                                                                                    -    def remove(self, item):
                                                                                                                                    -        idx = self.index(item)
                                                                                                                                    -        del self._items[idx]
                                                                                                                                    -        del self._keys[idx]
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -# MODELS
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class SchemaManager(object):
                                                                                                                                    -    def __init__(self, model, database=None, **context_options):
                                                                                                                                    -        self.model = model
                                                                                                                                    -        self._database = database
                                                                                                                                    -        context_options.setdefault('scope', SCOPE_VALUES)
                                                                                                                                    -        self.context_options = context_options
                                                                                                                                    -
                                                                                                                                    -    @property
                                                                                                                                    -    def database(self):
                                                                                                                                    -        db = self._database or self.model._meta.database
                                                                                                                                    -        if db is None:
                                                                                                                                    -            raise ImproperlyConfigured('database attribute does not appear to '
                                                                                                                                    -                                       'be set on the model: %s' % self.model)
                                                                                                                                    -        return db
                                                                                                                                    -
                                                                                                                                    -    @database.setter
                                                                                                                                    -    def database(self, value):
                                                                                                                                    -        self._database = value
                                                                                                                                    -
                                                                                                                                    -    def _create_context(self):
                                                                                                                                    -        return self.database.get_sql_context(**self.context_options)
                                                                                                                                    -
                                                                                                                                    -    def _create_table(self, safe=True, **options):
                                                                                                                                    -        is_temp = options.pop('temporary', False)
                                                                                                                                    -        ctx = self._create_context()
                                                                                                                                    -        ctx.literal('CREATE TEMPORARY TABLE ' if is_temp else 'CREATE TABLE ')
                                                                                                                                    -        if safe:
                                                                                                                                    -            ctx.literal('IF NOT EXISTS ')
                                                                                                                                    -        ctx.sql(self.model).literal(' ')
                                                                                                                                    -
                                                                                                                                    -        columns = []
                                                                                                                                    -        constraints = []
                                                                                                                                    -        meta = self.model._meta
                                                                                                                                    -        if meta.composite_key:
                                                                                                                                    -            pk_columns = [meta.fields[field_name].column
                                                                                                                                    -                          for field_name in meta.primary_key.field_names]
                                                                                                                                    -            constraints.append(NodeList((SQL('PRIMARY KEY'),
                                                                                                                                    -                                         EnclosedNodeList(pk_columns))))
                                                                                                                                    -
                                                                                                                                    -        for field in meta.sorted_fields:
                                                                                                                                    -            columns.append(field.ddl(ctx))
                                                                                                                                    -            if isinstance(field, ForeignKeyField) and not field.deferred:
                                                                                                                                    -                constraints.append(field.foreign_key_constraint())
                                                                                                                                    -
                                                                                                                                    -        if meta.constraints:
                                                                                                                                    -            constraints.extend(meta.constraints)
                                                                                                                                    -
                                                                                                                                    -        constraints.extend(self._create_table_option_sql(options))
                                                                                                                                    -        ctx.sql(EnclosedNodeList(columns + constraints))
                                                                                                                                    -
                                                                                                                                    -        if meta.table_settings is not None:
                                                                                                                                    -            table_settings = ensure_tuple(meta.table_settings)
                                                                                                                                    -            for setting in table_settings:
                                                                                                                                    -                if not isinstance(setting, basestring):
                                                                                                                                    -                    raise ValueError('table_settings must be strings')
                                                                                                                                    -                ctx.literal(' ').literal(setting)
                                                                                                                                    -
                                                                                                                                    -        if meta.without_rowid:
                                                                                                                                    -            ctx.literal(' WITHOUT ROWID')
                                                                                                                                    -        return ctx
                                                                                                                                    -
                                                                                                                                    -    def _create_table_option_sql(self, options):
                                                                                                                                    -        accum = []
                                                                                                                                    -        options = merge_dict(self.model._meta.options or {}, options)
                                                                                                                                    -        if not options:
                                                                                                                                    -            return accum
                                                                                                                                    -
                                                                                                                                    -        for key, value in sorted(options.items()):
                                                                                                                                    -            if not isinstance(value, Node):
                                                                                                                                    -                if is_model(value):
                                                                                                                                    -                    value = value._meta.table
                                                                                                                                    -                else:
                                                                                                                                    -                    value = SQL(str(value))
                                                                                                                                    -            accum.append(NodeList((SQL(key), value), glue='='))
                                                                                                                                    -        return accum
                                                                                                                                    -
                                                                                                                                    -    def create_table(self, safe=True, **options):
                                                                                                                                    -        self.database.execute(self._create_table(safe=safe, **options))
                                                                                                                                    -
                                                                                                                                    -    def _create_table_as(self, table_name, query, safe=True, **meta):
                                                                                                                                    -        ctx = (self._create_context()
                                                                                                                                    -               .literal('CREATE TEMPORARY TABLE '
                                                                                                                                    -                        if meta.get('temporary') else 'CREATE TABLE '))
                                                                                                                                    -        if safe:
                                                                                                                                    -            ctx.literal('IF NOT EXISTS ')
                                                                                                                                    -        return (ctx
                                                                                                                                    -                .sql(Entity(table_name))
                                                                                                                                    -                .literal(' AS ')
                                                                                                                                    -                .sql(query))
                                                                                                                                    -
                                                                                                                                    -    def create_table_as(self, table_name, query, safe=True, **meta):
                                                                                                                                    -        ctx = self._create_table_as(table_name, query, safe=safe, **meta)
                                                                                                                                    -        self.database.execute(ctx)
                                                                                                                                    -
                                                                                                                                    -    def _drop_table(self, safe=True, **options):
                                                                                                                                    -        ctx = (self._create_context()
                                                                                                                                    -               .literal('DROP TABLE IF EXISTS ' if safe else 'DROP TABLE ')
                                                                                                                                    -               .sql(self.model))
                                                                                                                                    -        if options.get('cascade'):
                                                                                                                                    -            ctx = ctx.literal(' CASCADE')
                                                                                                                                    -        elif options.get('restrict'):
                                                                                                                                    -            ctx = ctx.literal(' RESTRICT')
                                                                                                                                    -        return ctx
                                                                                                                                    -
                                                                                                                                    -    def drop_table(self, safe=True, **options):
                                                                                                                                    -        self.database.execute(self._drop_table(safe=safe, **options))
                                                                                                                                    -
                                                                                                                                    -    def _truncate_table(self, restart_identity=False, cascade=False):
                                                                                                                                    -        db = self.database
                                                                                                                                    -        if not db.truncate_table:
                                                                                                                                    -            return (self._create_context()
                                                                                                                                    -                    .literal('DELETE FROM ').sql(self.model))
                                                                                                                                    -
                                                                                                                                    -        ctx = self._create_context().literal('TRUNCATE TABLE ').sql(self.model)
                                                                                                                                    -        if restart_identity:
                                                                                                                                    -            ctx = ctx.literal(' RESTART IDENTITY')
                                                                                                                                    -        if cascade:
                                                                                                                                    -            ctx = ctx.literal(' CASCADE')
                                                                                                                                    -        return ctx
                                                                                                                                    -
                                                                                                                                    -    def truncate_table(self, restart_identity=False, cascade=False):
                                                                                                                                    -        self.database.execute(self._truncate_table(restart_identity, cascade))
                                                                                                                                    -
                                                                                                                                    -    def _create_indexes(self, safe=True):
                                                                                                                                    -        return [self._create_index(index, safe)
                                                                                                                                    -                for index in self.model._meta.fields_to_index()]
                                                                                                                                    -
                                                                                                                                    -    def _create_index(self, index, safe=True):
                                                                                                                                    -        if isinstance(index, Index):
                                                                                                                                    -            if not self.database.safe_create_index:
                                                                                                                                    -                index = index.safe(False)
                                                                                                                                    -            elif index._safe != safe:
                                                                                                                                    -                index = index.safe(safe)
                                                                                                                                    -        return self._create_context().sql(index)
                                                                                                                                    -
                                                                                                                                    -    def create_indexes(self, safe=True):
                                                                                                                                    -        for query in self._create_indexes(safe=safe):
                                                                                                                                    -            self.database.execute(query)
                                                                                                                                    -
                                                                                                                                    -    def _drop_indexes(self, safe=True):
                                                                                                                                    -        return [self._drop_index(index, safe)
                                                                                                                                    -                for index in self.model._meta.fields_to_index()
                                                                                                                                    -                if isinstance(index, Index)]
                                                                                                                                    -
                                                                                                                                    -    def _drop_index(self, index, safe):
                                                                                                                                    -        statement = 'DROP INDEX '
                                                                                                                                    -        if safe and self.database.safe_drop_index:
                                                                                                                                    -            statement += 'IF EXISTS '
                                                                                                                                    -        if isinstance(index._table, Table) and index._table._schema:
                                                                                                                                    -            index_name = Entity(index._table._schema, index._name)
                                                                                                                                    -        else:
                                                                                                                                    -            index_name = Entity(index._name)
                                                                                                                                    -        return (self
                                                                                                                                    -                ._create_context()
                                                                                                                                    -                .literal(statement)
                                                                                                                                    -                .sql(index_name))
                                                                                                                                    -
                                                                                                                                    -    def drop_indexes(self, safe=True):
                                                                                                                                    -        for query in self._drop_indexes(safe=safe):
                                                                                                                                    -            self.database.execute(query)
                                                                                                                                    -
                                                                                                                                    -    def _check_sequences(self, field):
                                                                                                                                    -        if not field.sequence or not self.database.sequences:
                                                                                                                                    -            raise ValueError('Sequences are either not supported, or are not '
                                                                                                                                    -                             'defined for "%s".' % field.name)
                                                                                                                                    -
                                                                                                                                    -    def _sequence_for_field(self, field):
                                                                                                                                    -        if field.model._meta.schema:
                                                                                                                                    -            return Entity(field.model._meta.schema, field.sequence)
                                                                                                                                    -        else:
                                                                                                                                    -            return Entity(field.sequence)
                                                                                                                                    -
                                                                                                                                    -    def _create_sequence(self, field):
                                                                                                                                    -        self._check_sequences(field)
                                                                                                                                    -        if not self.database.sequence_exists(field.sequence):
                                                                                                                                    -            return (self
                                                                                                                                    -                    ._create_context()
                                                                                                                                    -                    .literal('CREATE SEQUENCE ')
                                                                                                                                    -                    .sql(self._sequence_for_field(field)))
                                                                                                                                    -
                                                                                                                                    -    def create_sequence(self, field):
                                                                                                                                    -        seq_ctx = self._create_sequence(field)
                                                                                                                                    -        if seq_ctx is not None:
                                                                                                                                    -            self.database.execute(seq_ctx)
                                                                                                                                    -
                                                                                                                                    -    def _drop_sequence(self, field):
                                                                                                                                    -        self._check_sequences(field)
                                                                                                                                    -        if self.database.sequence_exists(field.sequence):
                                                                                                                                    -            return (self
                                                                                                                                    -                    ._create_context()
                                                                                                                                    -                    .literal('DROP SEQUENCE ')
                                                                                                                                    -                    .sql(self._sequence_for_field(field)))
                                                                                                                                    -
                                                                                                                                    -    def drop_sequence(self, field):
                                                                                                                                    -        seq_ctx = self._drop_sequence(field)
                                                                                                                                    -        if seq_ctx is not None:
                                                                                                                                    -            self.database.execute(seq_ctx)
                                                                                                                                    -
                                                                                                                                    -    def _create_foreign_key(self, field):
                                                                                                                                    -        name = 'fk_%s_%s_refs_%s' % (field.model._meta.table_name,
                                                                                                                                    -                                     field.column_name,
                                                                                                                                    -                                     field.rel_model._meta.table_name)
                                                                                                                                    -        return (self
                                                                                                                                    -                ._create_context()
                                                                                                                                    -                .literal('ALTER TABLE ')
                                                                                                                                    -                .sql(field.model)
                                                                                                                                    -                .literal(' ADD CONSTRAINT ')
                                                                                                                                    -                .sql(Entity(_truncate_constraint_name(name)))
                                                                                                                                    -                .literal(' ')
                                                                                                                                    -                .sql(field.foreign_key_constraint()))
                                                                                                                                    -
                                                                                                                                    -    def create_foreign_key(self, field):
                                                                                                                                    -        self.database.execute(self._create_foreign_key(field))
                                                                                                                                    -
                                                                                                                                    -    def create_sequences(self):
                                                                                                                                    -        if self.database.sequences:
                                                                                                                                    -            for field in self.model._meta.sorted_fields:
                                                                                                                                    -                if field.sequence:
                                                                                                                                    -                    self.create_sequence(field)
                                                                                                                                    -
                                                                                                                                    -    def create_all(self, safe=True, **table_options):
                                                                                                                                    -        self.create_sequences()
                                                                                                                                    -        self.create_table(safe, **table_options)
                                                                                                                                    -        self.create_indexes(safe=safe)
                                                                                                                                    -
                                                                                                                                    -    def drop_sequences(self):
                                                                                                                                    -        if self.database.sequences:
                                                                                                                                    -            for field in self.model._meta.sorted_fields:
                                                                                                                                    -                if field.sequence:
                                                                                                                                    -                    self.drop_sequence(field)
                                                                                                                                    -
                                                                                                                                    -    def drop_all(self, safe=True, drop_sequences=True, **options):
                                                                                                                                    -        self.drop_table(safe, **options)
                                                                                                                                    -        if drop_sequences:
                                                                                                                                    -            self.drop_sequences()
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class Metadata(object):
                                                                                                                                    -    def __init__(self, model, database=None, table_name=None, indexes=None,
                                                                                                                                    -                 primary_key=None, constraints=None, schema=None,
                                                                                                                                    -                 only_save_dirty=False, depends_on=None, options=None,
                                                                                                                                    -                 db_table=None, table_function=None, table_settings=None,
                                                                                                                                    -                 without_rowid=False, temporary=False, legacy_table_names=True,
                                                                                                                                    -                 **kwargs):
                                                                                                                                    -        if db_table is not None:
                                                                                                                                    -            __deprecated__('"db_table" has been deprecated in favor of '
                                                                                                                                    -                           '"table_name" for Models.')
                                                                                                                                    -            table_name = db_table
                                                                                                                                    -        self.model = model
                                                                                                                                    -        self.database = database
                                                                                                                                    -
                                                                                                                                    -        self.fields = {}
                                                                                                                                    -        self.columns = {}
                                                                                                                                    -        self.combined = {}
                                                                                                                                    -
                                                                                                                                    -        self._sorted_field_list = _SortedFieldList()
                                                                                                                                    -        self.sorted_fields = []
                                                                                                                                    -        self.sorted_field_names = []
                                                                                                                                    -
                                                                                                                                    -        self.defaults = {}
                                                                                                                                    -        self._default_by_name = {}
                                                                                                                                    -        self._default_dict = {}
                                                                                                                                    -        self._default_callables = {}
                                                                                                                                    -        self._default_callable_list = []
                                                                                                                                    -
                                                                                                                                    -        self.name = model.__name__.lower()
                                                                                                                                    -        self.table_function = table_function
                                                                                                                                    -        self.legacy_table_names = legacy_table_names
                                                                                                                                    -        if not table_name:
                                                                                                                                    -            table_name = (self.table_function(model)
                                                                                                                                    -                          if self.table_function
                                                                                                                                    -                          else self.make_table_name())
                                                                                                                                    -        self.table_name = table_name
                                                                                                                                    -        self._table = None
                                                                                                                                    -
                                                                                                                                    -        self.indexes = list(indexes) if indexes else []
                                                                                                                                    -        self.constraints = constraints
                                                                                                                                    -        self._schema = schema
                                                                                                                                    -        self.primary_key = primary_key
                                                                                                                                    -        self.composite_key = self.auto_increment = None
                                                                                                                                    -        self.only_save_dirty = only_save_dirty
                                                                                                                                    -        self.depends_on = depends_on
                                                                                                                                    -        self.table_settings = table_settings
                                                                                                                                    -        self.without_rowid = without_rowid
                                                                                                                                    -        self.temporary = temporary
                                                                                                                                    -
                                                                                                                                    -        self.refs = {}
                                                                                                                                    -        self.backrefs = {}
                                                                                                                                    -        self.model_refs = collections.defaultdict(list)
                                                                                                                                    -        self.model_backrefs = collections.defaultdict(list)
                                                                                                                                    -        self.manytomany = {}
                                                                                                                                    -
                                                                                                                                    -        self.options = options or {}
                                                                                                                                    -        for key, value in kwargs.items():
                                                                                                                                    -            setattr(self, key, value)
                                                                                                                                    -        self._additional_keys = set(kwargs.keys())
                                                                                                                                    -
                                                                                                                                    -        # Allow objects to register hooks that are called if the model is bound
                                                                                                                                    -        # to a different database. For example, BlobField uses a different
                                                                                                                                    -        # Python data-type depending on the db driver / python version. When
                                                                                                                                    -        # the database changes, we need to update any BlobField so they can use
                                                                                                                                    -        # the appropriate data-type.
                                                                                                                                    -        self._db_hooks = []
                                                                                                                                    -
                                                                                                                                    -    def make_table_name(self):
                                                                                                                                    -        if self.legacy_table_names:
                                                                                                                                    -            return re.sub(r'[^\w]+', '_', self.name)
                                                                                                                                    -        return make_snake_case(self.model.__name__)
                                                                                                                                    -
                                                                                                                                    -    def model_graph(self, refs=True, backrefs=True, depth_first=True):
                                                                                                                                    -        if not refs and not backrefs:
                                                                                                                                    -            raise ValueError('One of `refs` or `backrefs` must be True.')
                                                                                                                                    -
                                                                                                                                    -        accum = [(None, self.model, None)]
                                                                                                                                    -        seen = set()
                                                                                                                                    -        queue = collections.deque((self,))
                                                                                                                                    -        method = queue.pop if depth_first else queue.popleft
                                                                                                                                    -
                                                                                                                                    -        while queue:
                                                                                                                                    -            curr = method()
                                                                                                                                    -            if curr in seen: continue
                                                                                                                                    -            seen.add(curr)
                                                                                                                                    -
                                                                                                                                    -            if refs:
                                                                                                                                    -                for fk, model in curr.refs.items():
                                                                                                                                    -                    accum.append((fk, model, False))
                                                                                                                                    -                    queue.append(model._meta)
                                                                                                                                    -            if backrefs:
                                                                                                                                    -                for fk, model in curr.backrefs.items():
                                                                                                                                    -                    accum.append((fk, model, True))
                                                                                                                                    -                    queue.append(model._meta)
                                                                                                                                    -
                                                                                                                                    -        return accum
                                                                                                                                    -
                                                                                                                                    -    def add_ref(self, field):
                                                                                                                                    -        rel = field.rel_model
                                                                                                                                    -        self.refs[field] = rel
                                                                                                                                    -        self.model_refs[rel].append(field)
                                                                                                                                    -        rel._meta.backrefs[field] = self.model
                                                                                                                                    -        rel._meta.model_backrefs[self.model].append(field)
                                                                                                                                    -
                                                                                                                                    -    def remove_ref(self, field):
                                                                                                                                    -        rel = field.rel_model
                                                                                                                                    -        del self.refs[field]
                                                                                                                                    -        self.model_refs[rel].remove(field)
                                                                                                                                    -        del rel._meta.backrefs[field]
                                                                                                                                    -        rel._meta.model_backrefs[self.model].remove(field)
                                                                                                                                    -
                                                                                                                                    -    def add_manytomany(self, field):
                                                                                                                                    -        self.manytomany[field.name] = field
                                                                                                                                    -
                                                                                                                                    -    def remove_manytomany(self, field):
                                                                                                                                    -        del self.manytomany[field.name]
                                                                                                                                    -
                                                                                                                                    -    @property
                                                                                                                                    -    def table(self):
                                                                                                                                    -        if self._table is None:
                                                                                                                                    -            self._table = Table(
                                                                                                                                    -                self.table_name,
                                                                                                                                    -                [field.column_name for field in self.sorted_fields],
                                                                                                                                    -                schema=self.schema,
                                                                                                                                    -                _model=self.model,
                                                                                                                                    -                _database=self.database)
                                                                                                                                    -        return self._table
                                                                                                                                    -
                                                                                                                                    -    @table.setter
                                                                                                                                    -    def table(self, value):
                                                                                                                                    -        raise AttributeError('Cannot set the "table".')
                                                                                                                                    -
                                                                                                                                    -    @table.deleter
                                                                                                                                    -    def table(self):
                                                                                                                                    -        self._table = None
                                                                                                                                    -
                                                                                                                                    -    @property
                                                                                                                                    -    def schema(self):
                                                                                                                                    -        return self._schema
                                                                                                                                    -
                                                                                                                                    -    @schema.setter
                                                                                                                                    -    def schema(self, value):
                                                                                                                                    -        self._schema = value
                                                                                                                                    -        del self.table
                                                                                                                                    -
                                                                                                                                    -    @property
                                                                                                                                    -    def entity(self):
                                                                                                                                    -        if self._schema:
                                                                                                                                    -            return Entity(self._schema, self.table_name)
                                                                                                                                    -        else:
                                                                                                                                    -            return Entity(self.table_name)
                                                                                                                                    -
                                                                                                                                    -    def _update_sorted_fields(self):
                                                                                                                                    -        self.sorted_fields = list(self._sorted_field_list)
                                                                                                                                    -        self.sorted_field_names = [f.name for f in self.sorted_fields]
                                                                                                                                    -
                                                                                                                                    -    def get_rel_for_model(self, model):
                                                                                                                                    -        if isinstance(model, ModelAlias):
                                                                                                                                    -            model = model.model
                                                                                                                                    -        forwardrefs = self.model_refs.get(model, [])
                                                                                                                                    -        backrefs = self.model_backrefs.get(model, [])
                                                                                                                                    -        return (forwardrefs, backrefs)
                                                                                                                                    -
                                                                                                                                    -    def add_field(self, field_name, field, set_attribute=True):
                                                                                                                                    -        if field_name in self.fields:
                                                                                                                                    -            self.remove_field(field_name)
                                                                                                                                    -        elif field_name in self.manytomany:
                                                                                                                                    -            self.remove_manytomany(self.manytomany[field_name])
                                                                                                                                    -
                                                                                                                                    -        if not isinstance(field, MetaField):
                                                                                                                                    -            del self.table
                                                                                                                                    -            field.bind(self.model, field_name, set_attribute)
                                                                                                                                    -            self.fields[field.name] = field
                                                                                                                                    -            self.columns[field.column_name] = field
                                                                                                                                    -            self.combined[field.name] = field
                                                                                                                                    -            self.combined[field.column_name] = field
                                                                                                                                    -
                                                                                                                                    -            self._sorted_field_list.insert(field)
                                                                                                                                    -            self._update_sorted_fields()
                                                                                                                                    -
                                                                                                                                    -            if field.default is not None:
                                                                                                                                    -                # This optimization helps speed up model instance construction.
                                                                                                                                    -                self.defaults[field] = field.default
                                                                                                                                    -                if callable_(field.default):
                                                                                                                                    -                    self._default_callables[field] = field.default
                                                                                                                                    -                    self._default_callable_list.append((field.name,
                                                                                                                                    -                                                        field.default))
                                                                                                                                    -                else:
                                                                                                                                    -                    self._default_dict[field] = field.default
                                                                                                                                    -                    self._default_by_name[field.name] = field.default
                                                                                                                                    -        else:
                                                                                                                                    -            field.bind(self.model, field_name, set_attribute)
                                                                                                                                    -
                                                                                                                                    -        if isinstance(field, ForeignKeyField):
                                                                                                                                    -            self.add_ref(field)
                                                                                                                                    -        elif isinstance(field, ManyToManyField) and field.name:
                                                                                                                                    -            self.add_manytomany(field)
                                                                                                                                    -
                                                                                                                                    -    def remove_field(self, field_name):
                                                                                                                                    -        if field_name not in self.fields:
                                                                                                                                    -            return
                                                                                                                                    -
                                                                                                                                    -        del self.table
                                                                                                                                    -        original = self.fields.pop(field_name)
                                                                                                                                    -        del self.columns[original.column_name]
                                                                                                                                    -        del self.combined[field_name]
                                                                                                                                    -        try:
                                                                                                                                    -            del self.combined[original.column_name]
                                                                                                                                    -        except KeyError:
                                                                                                                                    -            pass
                                                                                                                                    -        self._sorted_field_list.remove(original)
                                                                                                                                    -        self._update_sorted_fields()
                                                                                                                                    -
                                                                                                                                    -        if original.default is not None:
                                                                                                                                    -            del self.defaults[original]
                                                                                                                                    -            if self._default_callables.pop(original, None):
                                                                                                                                    -                for i, (name, _) in enumerate(self._default_callable_list):
                                                                                                                                    -                    if name == field_name:
                                                                                                                                    -                        self._default_callable_list.pop(i)
                                                                                                                                    -                        break
                                                                                                                                    -            else:
                                                                                                                                    -                self._default_dict.pop(original, None)
                                                                                                                                    -                self._default_by_name.pop(original.name, None)
                                                                                                                                    -
                                                                                                                                    -        if isinstance(original, ForeignKeyField):
                                                                                                                                    -            self.remove_ref(original)
                                                                                                                                    -
                                                                                                                                    -    def set_primary_key(self, name, field):
                                                                                                                                    -        self.composite_key = isinstance(field, CompositeKey)
                                                                                                                                    -        self.add_field(name, field)
                                                                                                                                    -        self.primary_key = field
                                                                                                                                    -        self.auto_increment = (
                                                                                                                                    -            field.auto_increment or
                                                                                                                                    -            bool(field.sequence))
                                                                                                                                    -
                                                                                                                                    -    def get_primary_keys(self):
                                                                                                                                    -        if self.composite_key:
                                                                                                                                    -            return tuple([self.fields[field_name]
                                                                                                                                    -                          for field_name in self.primary_key.field_names])
                                                                                                                                    -        else:
                                                                                                                                    -            return (self.primary_key,) if self.primary_key is not False else ()
                                                                                                                                    -
                                                                                                                                    -    def get_default_dict(self):
                                                                                                                                    -        dd = self._default_by_name.copy()
                                                                                                                                    -        for field_name, default in self._default_callable_list:
                                                                                                                                    -            dd[field_name] = default()
                                                                                                                                    -        return dd
                                                                                                                                    -
                                                                                                                                    -    def fields_to_index(self):
                                                                                                                                    -        indexes = []
                                                                                                                                    -        for f in self.sorted_fields:
                                                                                                                                    -            if f.primary_key:
                                                                                                                                    -                continue
                                                                                                                                    -            if f.index or f.unique:
                                                                                                                                    -                indexes.append(ModelIndex(self.model, (f,), unique=f.unique,
                                                                                                                                    -                                          using=f.index_type))
                                                                                                                                    -
                                                                                                                                    -        for index_obj in self.indexes:
                                                                                                                                    -            if isinstance(index_obj, Node):
                                                                                                                                    -                indexes.append(index_obj)
                                                                                                                                    -            elif isinstance(index_obj, (list, tuple)):
                                                                                                                                    -                index_parts, unique = index_obj
                                                                                                                                    -                fields = []
                                                                                                                                    -                for part in index_parts:
                                                                                                                                    -                    if isinstance(part, basestring):
                                                                                                                                    -                        fields.append(self.combined[part])
                                                                                                                                    -                    elif isinstance(part, Node):
                                                                                                                                    -                        fields.append(part)
                                                                                                                                    -                    else:
                                                                                                                                    -                        raise ValueError('Expected either a field name or a '
                                                                                                                                    -                                         'subclass of Node. Got: %s' % part)
                                                                                                                                    -                indexes.append(ModelIndex(self.model, fields, unique=unique))
                                                                                                                                    -
                                                                                                                                    -        return indexes
                                                                                                                                    -
                                                                                                                                    -    def set_database(self, database):
                                                                                                                                    -        self.database = database
                                                                                                                                    -        self.model._schema._database = database
                                                                                                                                    -        del self.table
                                                                                                                                    -
                                                                                                                                    -        # Apply any hooks that have been registered.
                                                                                                                                    -        for hook in self._db_hooks:
                                                                                                                                    -            hook(database)
                                                                                                                                    -
                                                                                                                                    -    def set_table_name(self, table_name):
                                                                                                                                    -        self.table_name = table_name
                                                                                                                                    -        del self.table
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class SubclassAwareMetadata(Metadata):
                                                                                                                                    -    models = []
                                                                                                                                    -
                                                                                                                                    -    def __init__(self, model, *args, **kwargs):
                                                                                                                                    -        super(SubclassAwareMetadata, self).__init__(model, *args, **kwargs)
                                                                                                                                    -        self.models.append(model)
                                                                                                                                    -
                                                                                                                                    -    def map_models(self, fn):
                                                                                                                                    -        for model in self.models:
                                                                                                                                    -            fn(model)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class DoesNotExist(Exception): pass
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class ModelBase(type):
                                                                                                                                    -    inheritable = set(['constraints', 'database', 'indexes', 'primary_key',
                                                                                                                                    -                       'options', 'schema', 'table_function', 'temporary',
                                                                                                                                    -                       'only_save_dirty', 'legacy_table_names',
                                                                                                                                    -                       'table_settings'])
                                                                                                                                    -
                                                                                                                                    -    def __new__(cls, name, bases, attrs):
                                                                                                                                    -        if name == MODEL_BASE or bases[0].__name__ == MODEL_BASE:
                                                                                                                                    -            return super(ModelBase, cls).__new__(cls, name, bases, attrs)
                                                                                                                                    -
                                                                                                                                    -        meta_options = {}
                                                                                                                                    -        meta = attrs.pop('Meta', None)
                                                                                                                                    -        if meta:
                                                                                                                                    -            for k, v in meta.__dict__.items():
                                                                                                                                    -                if not k.startswith('_'):
                                                                                                                                    -                    meta_options[k] = v
                                                                                                                                    -
                                                                                                                                    -        pk = getattr(meta, 'primary_key', None)
                                                                                                                                    -        pk_name = parent_pk = None
                                                                                                                                    -
                                                                                                                                    -        # Inherit any field descriptors by deep copying the underlying field
                                                                                                                                    -        # into the attrs of the new model, additionally see if the bases define
                                                                                                                                    -        # inheritable model options and swipe them.
                                                                                                                                    -        for b in bases:
                                                                                                                                    -            if not hasattr(b, '_meta'):
                                                                                                                                    -                continue
                                                                                                                                    -
                                                                                                                                    -            base_meta = b._meta
                                                                                                                                    -            if parent_pk is None:
                                                                                                                                    -                parent_pk = deepcopy(base_meta.primary_key)
                                                                                                                                    -            all_inheritable = cls.inheritable | base_meta._additional_keys
                                                                                                                                    -            for k in base_meta.__dict__:
                                                                                                                                    -                if k in all_inheritable and k not in meta_options:
                                                                                                                                    -                    meta_options[k] = base_meta.__dict__[k]
                                                                                                                                    -            meta_options.setdefault('schema', base_meta.schema)
                                                                                                                                    -
                                                                                                                                    -            for (k, v) in b.__dict__.items():
                                                                                                                                    -                if k in attrs: continue
                                                                                                                                    -
                                                                                                                                    -                if isinstance(v, FieldAccessor) and not v.field.primary_key:
                                                                                                                                    -                    attrs[k] = deepcopy(v.field)
                                                                                                                                    -
                                                                                                                                    -        sopts = meta_options.pop('schema_options', None) or {}
                                                                                                                                    -        Meta = meta_options.get('model_metadata_class', Metadata)
                                                                                                                                    -        Schema = meta_options.get('schema_manager_class', SchemaManager)
                                                                                                                                    -
                                                                                                                                    -        # Construct the new class.
                                                                                                                                    -        cls = super(ModelBase, cls).__new__(cls, name, bases, attrs)
                                                                                                                                    -        cls.__data__ = cls.__rel__ = None
                                                                                                                                    -
                                                                                                                                    -        cls._meta = Meta(cls, **meta_options)
                                                                                                                                    -        cls._schema = Schema(cls, **sopts)
                                                                                                                                    -
                                                                                                                                    -        fields = []
                                                                                                                                    -        for key, value in cls.__dict__.items():
                                                                                                                                    -            if isinstance(value, Field):
                                                                                                                                    -                if value.primary_key and pk:
                                                                                                                                    -                    raise ValueError('over-determined primary key %s.' % name)
                                                                                                                                    -                elif value.primary_key:
                                                                                                                                    -                    pk, pk_name = value, key
                                                                                                                                    -                else:
                                                                                                                                    -                    fields.append((key, value))
                                                                                                                                    -
                                                                                                                                    -        if pk is None:
                                                                                                                                    -            if parent_pk is not False:
                                                                                                                                    -                pk, pk_name = ((parent_pk, parent_pk.name)
                                                                                                                                    -                               if parent_pk is not None else
                                                                                                                                    -                               (AutoField(), 'id'))
                                                                                                                                    -            else:
                                                                                                                                    -                pk = False
                                                                                                                                    -        elif isinstance(pk, CompositeKey):
                                                                                                                                    -            pk_name = '__composite_key__'
                                                                                                                                    -            cls._meta.composite_key = True
                                                                                                                                    -
                                                                                                                                    -        if pk is not False:
                                                                                                                                    -            cls._meta.set_primary_key(pk_name, pk)
                                                                                                                                    -
                                                                                                                                    -        for name, field in fields:
                                                                                                                                    -            cls._meta.add_field(name, field)
                                                                                                                                    -
                                                                                                                                    -        # Create a repr and error class before finalizing.
                                                                                                                                    -        if hasattr(cls, '__str__') and '__repr__' not in attrs:
                                                                                                                                    -            setattr(cls, '__repr__', lambda self: '<%s: %s>' % (
                                                                                                                                    -                cls.__name__, self.__str__()))
                                                                                                                                    -
                                                                                                                                    -        exc_name = '%sDoesNotExist' % cls.__name__
                                                                                                                                    -        exc_attrs = {'__module__': cls.__module__}
                                                                                                                                    -        exception_class = type(exc_name, (DoesNotExist,), exc_attrs)
                                                                                                                                    -        cls.DoesNotExist = exception_class
                                                                                                                                    -
                                                                                                                                    -        # Call validation hook, allowing additional model validation.
                                                                                                                                    -        cls.validate_model()
                                                                                                                                    -        DeferredForeignKey.resolve(cls)
                                                                                                                                    -        return cls
                                                                                                                                    -
                                                                                                                                    -    def __repr__(self):
                                                                                                                                    -        return '<Model: %s>' % self.__name__
                                                                                                                                    -
                                                                                                                                    -    def __iter__(self):
                                                                                                                                    -        return iter(self.select())
                                                                                                                                    -
                                                                                                                                    -    def __getitem__(self, key):
                                                                                                                                    -        return self.get_by_id(key)
                                                                                                                                    -
                                                                                                                                    -    def __setitem__(self, key, value):
                                                                                                                                    -        self.set_by_id(key, value)
                                                                                                                                    -
                                                                                                                                    -    def __delitem__(self, key):
                                                                                                                                    -        self.delete_by_id(key)
                                                                                                                                    -
                                                                                                                                    -    def __contains__(self, key):
                                                                                                                                    -        try:
                                                                                                                                    -            self.get_by_id(key)
                                                                                                                                    -        except self.DoesNotExist:
                                                                                                                                    -            return False
                                                                                                                                    -        else:
                                                                                                                                    -            return True
                                                                                                                                    -
                                                                                                                                    -    def __len__(self):
                                                                                                                                    -        return self.select().count()
                                                                                                                                    -    def __bool__(self): return True
                                                                                                                                    -    __nonzero__ = __bool__  # Python 2.
                                                                                                                                    -
                                                                                                                                    -    def __sql__(self, ctx):
                                                                                                                                    -        return ctx.sql(self._meta.table)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class _BoundModelsContext(_callable_context_manager):
                                                                                                                                    -    def __init__(self, models, database, bind_refs, bind_backrefs):
                                                                                                                                    -        self.models = models
                                                                                                                                    -        self.database = database
                                                                                                                                    -        self.bind_refs = bind_refs
                                                                                                                                    -        self.bind_backrefs = bind_backrefs
                                                                                                                                    -
                                                                                                                                    -    def __enter__(self):
                                                                                                                                    -        self._orig_database = []
                                                                                                                                    -        for model in self.models:
                                                                                                                                    -            self._orig_database.append(model._meta.database)
                                                                                                                                    -            model.bind(self.database, self.bind_refs, self.bind_backrefs,
                                                                                                                                    -                       _exclude=set(self.models))
                                                                                                                                    -        return self.models
                                                                                                                                    -
                                                                                                                                    -    def __exit__(self, exc_type, exc_val, exc_tb):
                                                                                                                                    -        for model, db in zip(self.models, self._orig_database):
                                                                                                                                    -            model.bind(db, self.bind_refs, self.bind_backrefs,
                                                                                                                                    -                       _exclude=set(self.models))
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class Model(with_metaclass(ModelBase, Node)):
                                                                                                                                    -    def __init__(self, *args, **kwargs):
                                                                                                                                    -        if kwargs.pop('__no_default__', None):
                                                                                                                                    -            self.__data__ = {}
                                                                                                                                    -        else:
                                                                                                                                    -            self.__data__ = self._meta.get_default_dict()
                                                                                                                                    -        self._dirty = set(self.__data__)
                                                                                                                                    -        self.__rel__ = {}
                                                                                                                                    -
                                                                                                                                    -        for k in kwargs:
                                                                                                                                    -            setattr(self, k, kwargs[k])
                                                                                                                                    -
                                                                                                                                    -    def __str__(self):
                                                                                                                                    -        return str(self._pk) if self._meta.primary_key is not False else 'n/a'
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def validate_model(cls):
                                                                                                                                    -        pass
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def alias(cls, alias=None):
                                                                                                                                    -        return ModelAlias(cls, alias)
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def select(cls, *fields):
                                                                                                                                    -        is_default = not fields
                                                                                                                                    -        if not fields:
                                                                                                                                    -            fields = cls._meta.sorted_fields
                                                                                                                                    -        return ModelSelect(cls, fields, is_default=is_default)
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def _normalize_data(cls, data, kwargs):
                                                                                                                                    -        normalized = {}
                                                                                                                                    -        if data:
                                                                                                                                    -            if not isinstance(data, dict):
                                                                                                                                    -                if kwargs:
                                                                                                                                    -                    raise ValueError('Data cannot be mixed with keyword '
                                                                                                                                    -                                     'arguments: %s' % data)
                                                                                                                                    -                return data
                                                                                                                                    -            for key in data:
                                                                                                                                    -                try:
                                                                                                                                    -                    field = (key if isinstance(key, Field)
                                                                                                                                    -                             else cls._meta.combined[key])
                                                                                                                                    -                except KeyError:
                                                                                                                                    -                    if not isinstance(key, Node):
                                                                                                                                    -                        raise ValueError('Unrecognized field name: "%s" in %s.'
                                                                                                                                    -                                         % (key, data))
                                                                                                                                    -                    field = key
                                                                                                                                    -                normalized[field] = data[key]
                                                                                                                                    -        if kwargs:
                                                                                                                                    -            for key in kwargs:
                                                                                                                                    -                try:
                                                                                                                                    -                    normalized[cls._meta.combined[key]] = kwargs[key]
                                                                                                                                    -                except KeyError:
                                                                                                                                    -                    normalized[getattr(cls, key)] = kwargs[key]
                                                                                                                                    -        return normalized
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def update(cls, __data=None, **update):
                                                                                                                                    -        return ModelUpdate(cls, cls._normalize_data(__data, update))
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def insert(cls, __data=None, **insert):
                                                                                                                                    -        return ModelInsert(cls, cls._normalize_data(__data, insert))
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def insert_many(cls, rows, fields=None):
                                                                                                                                    -        return ModelInsert(cls, insert=rows, columns=fields)
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def insert_from(cls, query, fields):
                                                                                                                                    -        columns = [getattr(cls, field) if isinstance(field, basestring)
                                                                                                                                    -                   else field for field in fields]
                                                                                                                                    -        return ModelInsert(cls, insert=query, columns=columns)
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def replace(cls, __data=None, **insert):
                                                                                                                                    -        return cls.insert(__data, **insert).on_conflict('REPLACE')
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def replace_many(cls, rows, fields=None):
                                                                                                                                    -        return (cls
                                                                                                                                    -                .insert_many(rows=rows, fields=fields)
                                                                                                                                    -                .on_conflict('REPLACE'))
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def raw(cls, sql, *params):
                                                                                                                                    -        return ModelRaw(cls, sql, params)
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def delete(cls):
                                                                                                                                    -        return ModelDelete(cls)
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def create(cls, **query):
                                                                                                                                    -        inst = cls(**query)
                                                                                                                                    -        inst.save(force_insert=True)
                                                                                                                                    -        return inst
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def bulk_create(cls, model_list, batch_size=None):
                                                                                                                                    -        if batch_size is not None:
                                                                                                                                    -            batches = chunked(model_list, batch_size)
                                                                                                                                    -        else:
                                                                                                                                    -            batches = [model_list]
                                                                                                                                    -
                                                                                                                                    -        field_names = list(cls._meta.sorted_field_names)
                                                                                                                                    -        if cls._meta.auto_increment:
                                                                                                                                    -            pk_name = cls._meta.primary_key.name
                                                                                                                                    -            field_names.remove(pk_name)
                                                                                                                                    -
                                                                                                                                    -        if cls._meta.database.returning_clause and \
                                                                                                                                    -           cls._meta.primary_key is not False:
                                                                                                                                    -            pk_fields = cls._meta.get_primary_keys()
                                                                                                                                    -        else:
                                                                                                                                    -            pk_fields = None
                                                                                                                                    -
                                                                                                                                    -        fields = [cls._meta.fields[field_name] for field_name in field_names]
                                                                                                                                    -        attrs = []
                                                                                                                                    -        for field in fields:
                                                                                                                                    -            if isinstance(field, ForeignKeyField):
                                                                                                                                    -                attrs.append(field.object_id_name)
                                                                                                                                    -            else:
                                                                                                                                    -                attrs.append(field.name)
                                                                                                                                    -
                                                                                                                                    -        for batch in batches:
                                                                                                                                    -            accum = ([getattr(model, f) for f in attrs]
                                                                                                                                    -                     for model in batch)
                                                                                                                                    -            res = cls.insert_many(accum, fields=fields).execute()
                                                                                                                                    -            if pk_fields and res is not None:
                                                                                                                                    -                for row, model in zip(res, batch):
                                                                                                                                    -                    for (pk_field, obj_id) in zip(pk_fields, row):
                                                                                                                                    -                        setattr(model, pk_field.name, obj_id)
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def bulk_update(cls, model_list, fields, batch_size=None):
                                                                                                                                    -        if isinstance(cls._meta.primary_key, CompositeKey):
                                                                                                                                    -            raise ValueError('bulk_update() is not supported for models with '
                                                                                                                                    -                             'a composite primary key.')
                                                                                                                                    -
                                                                                                                                    -        # First normalize list of fields so all are field instances.
                                                                                                                                    -        fields = [cls._meta.fields[f] if isinstance(f, basestring) else f
                                                                                                                                    -                  for f in fields]
                                                                                                                                    -        # Now collect list of attribute names to use for values.
                                                                                                                                    -        attrs = [field.object_id_name if isinstance(field, ForeignKeyField)
                                                                                                                                    -                 else field.name for field in fields]
                                                                                                                                    -
                                                                                                                                    -        if batch_size is not None:
                                                                                                                                    -            batches = chunked(model_list, batch_size)
                                                                                                                                    -        else:
                                                                                                                                    -            batches = [model_list]
                                                                                                                                    -
                                                                                                                                    -        n = 0
                                                                                                                                    -        pk = cls._meta.primary_key
                                                                                                                                    -
                                                                                                                                    -        for batch in batches:
                                                                                                                                    -            id_list = [model._pk for model in batch]
                                                                                                                                    -            update = {}
                                                                                                                                    -            for field, attr in zip(fields, attrs):
                                                                                                                                    -                accum = []
                                                                                                                                    -                for model in batch:
                                                                                                                                    -                    value = getattr(model, attr)
                                                                                                                                    -                    if not isinstance(value, Node):
                                                                                                                                    -                        value = field.to_value(value)
                                                                                                                                    -                    accum.append((pk.to_value(model._pk), value))
                                                                                                                                    -                case = Case(pk, accum)
                                                                                                                                    -                update[field] = case
                                                                                                                                    -
                                                                                                                                    -            n += (cls.update(update)
                                                                                                                                    -                  .where(cls._meta.primary_key.in_(id_list))
                                                                                                                                    -                  .execute())
                                                                                                                                    -        return n
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def noop(cls):
                                                                                                                                    -        return NoopModelSelect(cls, ())
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def get(cls, *query, **filters):
                                                                                                                                    -        sq = cls.select()
                                                                                                                                    -        if query:
                                                                                                                                    -            # Handle simple lookup using just the primary key.
                                                                                                                                    -            if len(query) == 1 and isinstance(query[0], int):
                                                                                                                                    -                sq = sq.where(cls._meta.primary_key == query[0])
                                                                                                                                    -            else:
                                                                                                                                    -                sq = sq.where(*query)
                                                                                                                                    -        if filters:
                                                                                                                                    -            sq = sq.filter(**filters)
                                                                                                                                    -        return sq.get()
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def get_or_none(cls, *query, **filters):
                                                                                                                                    -        try:
                                                                                                                                    -            return cls.get(*query, **filters)
                                                                                                                                    -        except DoesNotExist:
                                                                                                                                    -            pass
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def get_by_id(cls, pk):
                                                                                                                                    -        return cls.get(cls._meta.primary_key == pk)
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def set_by_id(cls, key, value):
                                                                                                                                    -        if key is None:
                                                                                                                                    -            return cls.insert(value).execute()
                                                                                                                                    -        else:
                                                                                                                                    -            return (cls.update(value)
                                                                                                                                    -                    .where(cls._meta.primary_key == key).execute())
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def delete_by_id(cls, pk):
                                                                                                                                    -        return cls.delete().where(cls._meta.primary_key == pk).execute()
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def get_or_create(cls, **kwargs):
                                                                                                                                    -        defaults = kwargs.pop('defaults', {})
                                                                                                                                    -        query = cls.select()
                                                                                                                                    -        for field, value in kwargs.items():
                                                                                                                                    -            query = query.where(getattr(cls, field) == value)
                                                                                                                                    -
                                                                                                                                    -        try:
                                                                                                                                    -            return query.get(), False
                                                                                                                                    -        except cls.DoesNotExist:
                                                                                                                                    -            try:
                                                                                                                                    -                if defaults:
                                                                                                                                    -                    kwargs.update(defaults)
                                                                                                                                    -                with cls._meta.database.atomic():
                                                                                                                                    -                    return cls.create(**kwargs), True
                                                                                                                                    -            except IntegrityError as exc:
                                                                                                                                    -                try:
                                                                                                                                    -                    return query.get(), False
                                                                                                                                    -                except cls.DoesNotExist:
                                                                                                                                    -                    raise exc
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def filter(cls, *dq_nodes, **filters):
                                                                                                                                    -        return cls.select().filter(*dq_nodes, **filters)
                                                                                                                                    -
                                                                                                                                    -    def get_id(self):
                                                                                                                                    -        # Using getattr(self, pk-name) could accidentally trigger a query if
                                                                                                                                    -        # the primary-key is a foreign-key. So we use the safe_name attribute,
                                                                                                                                    -        # which defaults to the field-name, but will be the object_id_name for
                                                                                                                                    -        # foreign-key fields.
                                                                                                                                    -        if self._meta.primary_key is not False:
                                                                                                                                    -            return getattr(self, self._meta.primary_key.safe_name)
                                                                                                                                    -
                                                                                                                                    -    _pk = property(get_id)
                                                                                                                                    -
                                                                                                                                    -    @_pk.setter
                                                                                                                                    -    def _pk(self, value):
                                                                                                                                    -        setattr(self, self._meta.primary_key.name, value)
                                                                                                                                    -
                                                                                                                                    -    def _pk_expr(self):
                                                                                                                                    -        return self._meta.primary_key == self._pk
                                                                                                                                    -
                                                                                                                                    -    def _prune_fields(self, field_dict, only):
                                                                                                                                    -        new_data = {}
                                                                                                                                    -        for field in only:
                                                                                                                                    -            if isinstance(field, basestring):
                                                                                                                                    -                field = self._meta.combined[field]
                                                                                                                                    -            if field.name in field_dict:
                                                                                                                                    -                new_data[field.name] = field_dict[field.name]
                                                                                                                                    -        return new_data
                                                                                                                                    -
                                                                                                                                    -    def _populate_unsaved_relations(self, field_dict):
                                                                                                                                    -        for foreign_key_field in self._meta.refs:
                                                                                                                                    -            foreign_key = foreign_key_field.name
                                                                                                                                    -            conditions = (
                                                                                                                                    -                foreign_key in field_dict and
                                                                                                                                    -                field_dict[foreign_key] is None and
                                                                                                                                    -                self.__rel__.get(foreign_key) is not None)
                                                                                                                                    -            if conditions:
                                                                                                                                    -                setattr(self, foreign_key, getattr(self, foreign_key))
                                                                                                                                    -                field_dict[foreign_key] = self.__data__[foreign_key]
                                                                                                                                    -
                                                                                                                                    -    def save(self, force_insert=False, only=None):
                                                                                                                                    -        field_dict = self.__data__.copy()
                                                                                                                                    -        if self._meta.primary_key is not False:
                                                                                                                                    -            pk_field = self._meta.primary_key
                                                                                                                                    -            pk_value = self._pk
                                                                                                                                    -        else:
                                                                                                                                    -            pk_field = pk_value = None
                                                                                                                                    -        if only is not None:
                                                                                                                                    -            field_dict = self._prune_fields(field_dict, only)
                                                                                                                                    -        elif self._meta.only_save_dirty and not force_insert:
                                                                                                                                    -            field_dict = self._prune_fields(field_dict, self.dirty_fields)
                                                                                                                                    -            if not field_dict:
                                                                                                                                    -                self._dirty.clear()
                                                                                                                                    -                return False
                                                                                                                                    -
                                                                                                                                    -        self._populate_unsaved_relations(field_dict)
                                                                                                                                    -        rows = 1
                                                                                                                                    -
                                                                                                                                    -        if self._meta.auto_increment and pk_value is None:
                                                                                                                                    -            field_dict.pop(pk_field.name, None)
                                                                                                                                    -
                                                                                                                                    -        if pk_value is not None and not force_insert:
                                                                                                                                    -            if self._meta.composite_key:
                                                                                                                                    -                for pk_part_name in pk_field.field_names:
                                                                                                                                    -                    field_dict.pop(pk_part_name, None)
                                                                                                                                    -            else:
                                                                                                                                    -                field_dict.pop(pk_field.name, None)
                                                                                                                                    -            if not field_dict:
                                                                                                                                    -                raise ValueError('no data to save!')
                                                                                                                                    -            rows = self.update(**field_dict).where(self._pk_expr()).execute()
                                                                                                                                    -        elif pk_field is not None:
                                                                                                                                    -            pk = self.insert(**field_dict).execute()
                                                                                                                                    -            if pk is not None and (self._meta.auto_increment or
                                                                                                                                    -                                   pk_value is None):
                                                                                                                                    -                self._pk = pk
                                                                                                                                    -        else:
                                                                                                                                    -            self.insert(**field_dict).execute()
                                                                                                                                    -
                                                                                                                                    -        self._dirty.clear()
                                                                                                                                    -        return rows
                                                                                                                                    -
                                                                                                                                    -    def is_dirty(self):
                                                                                                                                    -        return bool(self._dirty)
                                                                                                                                    -
                                                                                                                                    -    @property
                                                                                                                                    -    def dirty_fields(self):
                                                                                                                                    -        return [f for f in self._meta.sorted_fields if f.name in self._dirty]
                                                                                                                                    -
                                                                                                                                    -    def dependencies(self, search_nullable=False):
                                                                                                                                    -        model_class = type(self)
                                                                                                                                    -        stack = [(type(self), None)]
                                                                                                                                    -        seen = set()
                                                                                                                                    -
                                                                                                                                    -        while stack:
                                                                                                                                    -            klass, query = stack.pop()
                                                                                                                                    -            if klass in seen:
                                                                                                                                    -                continue
                                                                                                                                    -            seen.add(klass)
                                                                                                                                    -            for fk, rel_model in klass._meta.backrefs.items():
                                                                                                                                    -                if rel_model is model_class or query is None:
                                                                                                                                    -                    node = (fk == self.__data__[fk.rel_field.name])
                                                                                                                                    -                else:
                                                                                                                                    -                    node = fk << query
                                                                                                                                    -                subquery = (rel_model.select(rel_model._meta.primary_key)
                                                                                                                                    -                            .where(node))
                                                                                                                                    -                if not fk.null or search_nullable:
                                                                                                                                    -                    stack.append((rel_model, subquery))
                                                                                                                                    -                yield (node, fk)
                                                                                                                                    -
                                                                                                                                    -    def delete_instance(self, recursive=False, delete_nullable=False):
                                                                                                                                    -        if recursive:
                                                                                                                                    -            dependencies = self.dependencies(delete_nullable)
                                                                                                                                    -            for query, fk in reversed(list(dependencies)):
                                                                                                                                    -                model = fk.model
                                                                                                                                    -                if fk.null and not delete_nullable:
                                                                                                                                    -                    model.update(**{fk.name: None}).where(query).execute()
                                                                                                                                    -                else:
                                                                                                                                    -                    model.delete().where(query).execute()
                                                                                                                                    -        return type(self).delete().where(self._pk_expr()).execute()
                                                                                                                                    -
                                                                                                                                    -    def __hash__(self):
                                                                                                                                    -        return hash((self.__class__, self._pk))
                                                                                                                                    -
                                                                                                                                    -    def __eq__(self, other):
                                                                                                                                    -        return (
                                                                                                                                    -            other.__class__ == self.__class__ and
                                                                                                                                    -            self._pk is not None and
                                                                                                                                    -            self._pk == other._pk)
                                                                                                                                    -
                                                                                                                                    -    def __ne__(self, other):
                                                                                                                                    -        return not self == other
                                                                                                                                    -
                                                                                                                                    -    def __sql__(self, ctx):
                                                                                                                                    -        return ctx.sql(Value(getattr(self, self._meta.primary_key.name),
                                                                                                                                    -                             converter=self._meta.primary_key.db_value))
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def bind(cls, database, bind_refs=True, bind_backrefs=True, _exclude=None):
                                                                                                                                    -        is_different = cls._meta.database is not database
                                                                                                                                    -        cls._meta.set_database(database)
                                                                                                                                    -        if bind_refs or bind_backrefs:
                                                                                                                                    -            if _exclude is None:
                                                                                                                                    -                _exclude = set()
                                                                                                                                    -            G = cls._meta.model_graph(refs=bind_refs, backrefs=bind_backrefs)
                                                                                                                                    -            for _, model, is_backref in G:
                                                                                                                                    -                if model not in _exclude:
                                                                                                                                    -                    model._meta.set_database(database)
                                                                                                                                    -                    _exclude.add(model)
                                                                                                                                    -        return is_different
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def bind_ctx(cls, database, bind_refs=True, bind_backrefs=True):
                                                                                                                                    -        return _BoundModelsContext((cls,), database, bind_refs, bind_backrefs)
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def table_exists(cls):
                                                                                                                                    -        M = cls._meta
                                                                                                                                    -        return cls._schema.database.table_exists(M.table.__name__, M.schema)
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def create_table(cls, safe=True, **options):
                                                                                                                                    -        if 'fail_silently' in options:
                                                                                                                                    -            __deprecated__('"fail_silently" has been deprecated in favor of '
                                                                                                                                    -                           '"safe" for the create_table() method.')
                                                                                                                                    -            safe = options.pop('fail_silently')
                                                                                                                                    -
                                                                                                                                    -        if safe and not cls._schema.database.safe_create_index \
                                                                                                                                    -           and cls.table_exists():
                                                                                                                                    -            return
                                                                                                                                    -        if cls._meta.temporary:
                                                                                                                                    -            options.setdefault('temporary', cls._meta.temporary)
                                                                                                                                    -        cls._schema.create_all(safe, **options)
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def drop_table(cls, safe=True, drop_sequences=True, **options):
                                                                                                                                    -        if safe and not cls._schema.database.safe_drop_index \
                                                                                                                                    -           and not cls.table_exists():
                                                                                                                                    -            return
                                                                                                                                    -        if cls._meta.temporary:
                                                                                                                                    -            options.setdefault('temporary', cls._meta.temporary)
                                                                                                                                    -        cls._schema.drop_all(safe, drop_sequences, **options)
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def truncate_table(cls, **options):
                                                                                                                                    -        cls._schema.truncate_table(**options)
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def index(cls, *fields, **kwargs):
                                                                                                                                    -        return ModelIndex(cls, fields, **kwargs)
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def add_index(cls, *fields, **kwargs):
                                                                                                                                    -        if len(fields) == 1 and isinstance(fields[0], (SQL, Index)):
                                                                                                                                    -            cls._meta.indexes.append(fields[0])
                                                                                                                                    -        else:
                                                                                                                                    -            cls._meta.indexes.append(ModelIndex(cls, fields, **kwargs))
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class ModelAlias(Node):
                                                                                                                                    -    """Provide a separate reference to a model in a query."""
                                                                                                                                    -    def __init__(self, model, alias=None):
                                                                                                                                    -        self.__dict__['model'] = model
                                                                                                                                    -        self.__dict__['alias'] = alias
                                                                                                                                    -
                                                                                                                                    -    def __getattr__(self, attr):
                                                                                                                                    -        # Hack to work-around the fact that properties or other objects
                                                                                                                                    -        # implementing the descriptor protocol (on the model being aliased),
                                                                                                                                    -        # will not work correctly when we use getattr(). So we explicitly pass
                                                                                                                                    -        # the model alias to the descriptor's getter.
                                                                                                                                    -        try:
                                                                                                                                    -            obj = self.model.__dict__[attr]
                                                                                                                                    -        except KeyError:
                                                                                                                                    -            pass
                                                                                                                                    -        else:
                                                                                                                                    -            if isinstance(obj, ModelDescriptor):
                                                                                                                                    -                return obj.__get__(None, self)
                                                                                                                                    -
                                                                                                                                    -        model_attr = getattr(self.model, attr)
                                                                                                                                    -        if isinstance(model_attr, Field):
                                                                                                                                    -            self.__dict__[attr] = FieldAlias.create(self, model_attr)
                                                                                                                                    -            return self.__dict__[attr]
                                                                                                                                    -        return model_attr
                                                                                                                                    -
                                                                                                                                    -    def __setattr__(self, attr, value):
                                                                                                                                    -        raise AttributeError('Cannot set attributes on model aliases.')
                                                                                                                                    -
                                                                                                                                    -    def get_field_aliases(self):
                                                                                                                                    -        return [getattr(self, n) for n in self.model._meta.sorted_field_names]
                                                                                                                                    -
                                                                                                                                    -    def select(self, *selection):
                                                                                                                                    -        if not selection:
                                                                                                                                    -            selection = self.get_field_aliases()
                                                                                                                                    -        return ModelSelect(self, selection)
                                                                                                                                    -
                                                                                                                                    -    def __call__(self, **kwargs):
                                                                                                                                    -        return self.model(**kwargs)
                                                                                                                                    -
                                                                                                                                    -    def __sql__(self, ctx):
                                                                                                                                    -        if ctx.scope == SCOPE_VALUES:
                                                                                                                                    -            # Return the quoted table name.
                                                                                                                                    -            return ctx.sql(self.model)
                                                                                                                                    -
                                                                                                                                    -        if self.alias:
                                                                                                                                    -            ctx.alias_manager[self] = self.alias
                                                                                                                                    -
                                                                                                                                    -        if ctx.scope == SCOPE_SOURCE:
                                                                                                                                    -            # Define the table and its alias.
                                                                                                                                    -            return (ctx
                                                                                                                                    -                    .sql(self.model._meta.entity)
                                                                                                                                    -                    .literal(' AS ')
                                                                                                                                    -                    .sql(Entity(ctx.alias_manager[self])))
                                                                                                                                    -        else:
                                                                                                                                    -            # Refer to the table using the alias.
                                                                                                                                    -            return ctx.sql(Entity(ctx.alias_manager[self]))
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class FieldAlias(Field):
                                                                                                                                    -    def __init__(self, source, field):
                                                                                                                                    -        self.source = source
                                                                                                                                    -        self.model = source.model
                                                                                                                                    -        self.field = field
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def create(cls, source, field):
                                                                                                                                    -        class _FieldAlias(cls, type(field)):
                                                                                                                                    -            pass
                                                                                                                                    -        return _FieldAlias(source, field)
                                                                                                                                    -
                                                                                                                                    -    def clone(self):
                                                                                                                                    -        return FieldAlias(self.source, self.field)
                                                                                                                                    -
                                                                                                                                    -    def adapt(self, value): return self.field.adapt(value)
                                                                                                                                    -    def python_value(self, value): return self.field.python_value(value)
                                                                                                                                    -    def db_value(self, value): return self.field.db_value(value)
                                                                                                                                    -    def __getattr__(self, attr):
                                                                                                                                    -        return self.source if attr == 'model' else getattr(self.field, attr)
                                                                                                                                    -
                                                                                                                                    -    def __sql__(self, ctx):
                                                                                                                                    -        return ctx.sql(Column(self.source, self.field.column_name))
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -def sort_models(models):
                                                                                                                                    -    models = set(models)
                                                                                                                                    -    seen = set()
                                                                                                                                    -    ordering = []
                                                                                                                                    -    def dfs(model):
                                                                                                                                    -        if model in models and model not in seen:
                                                                                                                                    -            seen.add(model)
                                                                                                                                    -            for foreign_key, rel_model in model._meta.refs.items():
                                                                                                                                    -                # Do not depth-first search deferred foreign-keys as this can
                                                                                                                                    -                # cause tables to be created in the incorrect order.
                                                                                                                                    -                if not foreign_key.deferred:
                                                                                                                                    -                    dfs(rel_model)
                                                                                                                                    -            if model._meta.depends_on:
                                                                                                                                    -                for dependency in model._meta.depends_on:
                                                                                                                                    -                    dfs(dependency)
                                                                                                                                    -            ordering.append(model)
                                                                                                                                    -
                                                                                                                                    -    names = lambda m: (m._meta.name, m._meta.table_name)
                                                                                                                                    -    for m in sorted(models, key=names):
                                                                                                                                    -        dfs(m)
                                                                                                                                    -    return ordering
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class _ModelQueryHelper(object):
                                                                                                                                    -    default_row_type = ROW.MODEL
                                                                                                                                    -
                                                                                                                                    -    def __init__(self, *args, **kwargs):
                                                                                                                                    -        super(_ModelQueryHelper, self).__init__(*args, **kwargs)
                                                                                                                                    -        if not self._database:
                                                                                                                                    -            self._database = self.model._meta.database
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def objects(self, constructor=None):
                                                                                                                                    -        self._row_type = ROW.CONSTRUCTOR
                                                                                                                                    -        self._constructor = self.model if constructor is None else constructor
                                                                                                                                    -
                                                                                                                                    -    def _get_cursor_wrapper(self, cursor):
                                                                                                                                    -        row_type = self._row_type or self.default_row_type
                                                                                                                                    -        if row_type == ROW.MODEL:
                                                                                                                                    -            return self._get_model_cursor_wrapper(cursor)
                                                                                                                                    -        elif row_type == ROW.DICT:
                                                                                                                                    -            return ModelDictCursorWrapper(cursor, self.model, self._returning)
                                                                                                                                    -        elif row_type == ROW.TUPLE:
                                                                                                                                    -            return ModelTupleCursorWrapper(cursor, self.model, self._returning)
                                                                                                                                    -        elif row_type == ROW.NAMED_TUPLE:
                                                                                                                                    -            return ModelNamedTupleCursorWrapper(cursor, self.model,
                                                                                                                                    -                                                self._returning)
                                                                                                                                    -        elif row_type == ROW.CONSTRUCTOR:
                                                                                                                                    -            return ModelObjectCursorWrapper(cursor, self.model,
                                                                                                                                    -                                            self._returning, self._constructor)
                                                                                                                                    -        else:
                                                                                                                                    -            raise ValueError('Unrecognized row type: "%s".' % row_type)
                                                                                                                                    -
                                                                                                                                    -    def _get_model_cursor_wrapper(self, cursor):
                                                                                                                                    -        return ModelObjectCursorWrapper(cursor, self.model, [], self.model)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class ModelRaw(_ModelQueryHelper, RawQuery):
                                                                                                                                    -    def __init__(self, model, sql, params, **kwargs):
                                                                                                                                    -        self.model = model
                                                                                                                                    -        self._returning = ()
                                                                                                                                    -        super(ModelRaw, self).__init__(sql=sql, params=params, **kwargs)
                                                                                                                                    -
                                                                                                                                    -    def get(self):
                                                                                                                                    -        try:
                                                                                                                                    -            return self.execute()[0]
                                                                                                                                    -        except IndexError:
                                                                                                                                    -            sql, params = self.sql()
                                                                                                                                    -            raise self.model.DoesNotExist('%s instance matching query does '
                                                                                                                                    -                                          'not exist:\nSQL: %s\nParams: %s' %
                                                                                                                                    -                                          (self.model, sql, params))
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class BaseModelSelect(_ModelQueryHelper):
                                                                                                                                    -    def union_all(self, rhs):
                                                                                                                                    -        return ModelCompoundSelectQuery(self.model, self, 'UNION ALL', rhs)
                                                                                                                                    -    __add__ = union_all
                                                                                                                                    -
                                                                                                                                    -    def union(self, rhs):
                                                                                                                                    -        return ModelCompoundSelectQuery(self.model, self, 'UNION', rhs)
                                                                                                                                    -    __or__ = union
                                                                                                                                    -
                                                                                                                                    -    def intersect(self, rhs):
                                                                                                                                    -        return ModelCompoundSelectQuery(self.model, self, 'INTERSECT', rhs)
                                                                                                                                    -    __and__ = intersect
                                                                                                                                    -
                                                                                                                                    -    def except_(self, rhs):
                                                                                                                                    -        return ModelCompoundSelectQuery(self.model, self, 'EXCEPT', rhs)
                                                                                                                                    -    __sub__ = except_
                                                                                                                                    -
                                                                                                                                    -    def __iter__(self):
                                                                                                                                    -        if not self._cursor_wrapper:
                                                                                                                                    -            self.execute()
                                                                                                                                    -        return iter(self._cursor_wrapper)
                                                                                                                                    -
                                                                                                                                    -    def prefetch(self, *subqueries):
                                                                                                                                    -        return prefetch(self, *subqueries)
                                                                                                                                    -
                                                                                                                                    -    def get(self, database=None):
                                                                                                                                    -        clone = self.paginate(1, 1)
                                                                                                                                    -        clone._cursor_wrapper = None
                                                                                                                                    -        try:
                                                                                                                                    -            return clone.execute(database)[0]
                                                                                                                                    -        except IndexError:
                                                                                                                                    -            sql, params = clone.sql()
                                                                                                                                    -            raise self.model.DoesNotExist('%s instance matching query does '
                                                                                                                                    -                                          'not exist:\nSQL: %s\nParams: %s' %
                                                                                                                                    -                                          (clone.model, sql, params))
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def group_by(self, *columns):
                                                                                                                                    -        grouping = []
                                                                                                                                    -        for column in columns:
                                                                                                                                    -            if is_model(column):
                                                                                                                                    -                grouping.extend(column._meta.sorted_fields)
                                                                                                                                    -            elif isinstance(column, Table):
                                                                                                                                    -                if not column._columns:
                                                                                                                                    -                    raise ValueError('Cannot pass a table to group_by() that '
                                                                                                                                    -                                     'does not have columns explicitly '
                                                                                                                                    -                                     'declared.')
                                                                                                                                    -                grouping.extend([getattr(column, col_name)
                                                                                                                                    -                                 for col_name in column._columns])
                                                                                                                                    -            else:
                                                                                                                                    -                grouping.append(column)
                                                                                                                                    -        self._group_by = grouping
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class ModelCompoundSelectQuery(BaseModelSelect, CompoundSelectQuery):
                                                                                                                                    -    def __init__(self, model, *args, **kwargs):
                                                                                                                                    -        self.model = model
                                                                                                                                    -        super(ModelCompoundSelectQuery, self).__init__(*args, **kwargs)
                                                                                                                                    -
                                                                                                                                    -    def _get_model_cursor_wrapper(self, cursor):
                                                                                                                                    -        return self.lhs._get_model_cursor_wrapper(cursor)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -def _normalize_model_select(fields_or_models):
                                                                                                                                    -    fields = []
                                                                                                                                    -    for fm in fields_or_models:
                                                                                                                                    -        if is_model(fm):
                                                                                                                                    -            fields.extend(fm._meta.sorted_fields)
                                                                                                                                    -        elif isinstance(fm, ModelAlias):
                                                                                                                                    -            fields.extend(fm.get_field_aliases())
                                                                                                                                    -        elif isinstance(fm, Table) and fm._columns:
                                                                                                                                    -            fields.extend([getattr(fm, col) for col in fm._columns])
                                                                                                                                    -        else:
                                                                                                                                    -            fields.append(fm)
                                                                                                                                    -    return fields
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class ModelSelect(BaseModelSelect, Select):
                                                                                                                                    -    def __init__(self, model, fields_or_models, is_default=False):
                                                                                                                                    -        self.model = self._join_ctx = model
                                                                                                                                    -        self._joins = {}
                                                                                                                                    -        self._is_default = is_default
                                                                                                                                    -        fields = _normalize_model_select(fields_or_models)
                                                                                                                                    -        super(ModelSelect, self).__init__([model], fields)
                                                                                                                                    -
                                                                                                                                    -    def clone(self):
                                                                                                                                    -        clone = super(ModelSelect, self).clone()
                                                                                                                                    -        if clone._joins:
                                                                                                                                    -            clone._joins = dict(clone._joins)
                                                                                                                                    -        return clone
                                                                                                                                    -
                                                                                                                                    -    def select(self, *fields_or_models):
                                                                                                                                    -        if fields_or_models or not self._is_default:
                                                                                                                                    -            self._is_default = False
                                                                                                                                    -            fields = _normalize_model_select(fields_or_models)
                                                                                                                                    -            return super(ModelSelect, self).select(*fields)
                                                                                                                                    -        return self
                                                                                                                                    -
                                                                                                                                    -    def switch(self, ctx=None):
                                                                                                                                    -        self._join_ctx = self.model if ctx is None else ctx
                                                                                                                                    -        return self
                                                                                                                                    -
                                                                                                                                    -    def _get_model(self, src):
                                                                                                                                    -        if is_model(src):
                                                                                                                                    -            return src, True
                                                                                                                                    -        elif isinstance(src, Table) and src._model:
                                                                                                                                    -            return src._model, False
                                                                                                                                    -        elif isinstance(src, ModelAlias):
                                                                                                                                    -            return src.model, False
                                                                                                                                    -        elif isinstance(src, ModelSelect):
                                                                                                                                    -            return src.model, False
                                                                                                                                    -        return None, False
                                                                                                                                    -
                                                                                                                                    -    def _normalize_join(self, src, dest, on, attr):
                                                                                                                                    -        # Allow "on" expression to have an alias that determines the
                                                                                                                                    -        # destination attribute for the joined data.
                                                                                                                                    -        on_alias = isinstance(on, Alias)
                                                                                                                                    -        if on_alias:
                                                                                                                                    -            attr = attr or on._alias
                                                                                                                                    -            on = on.alias()
                                                                                                                                    -
                                                                                                                                    -        # Obtain references to the source and destination models being joined.
                                                                                                                                    -        src_model, src_is_model = self._get_model(src)
                                                                                                                                    -        dest_model, dest_is_model = self._get_model(dest)
                                                                                                                                    -
                                                                                                                                    -        if src_model and dest_model:
                                                                                                                                    -            self._join_ctx = dest
                                                                                                                                    -            constructor = dest_model
                                                                                                                                    -
                                                                                                                                    -            # In the case where the "on" clause is a Column or Field, we will
                                                                                                                                    -            # convert that field into the appropriate predicate expression.
                                                                                                                                    -            if not (src_is_model and dest_is_model) and isinstance(on, Column):
                                                                                                                                    -                if on.source is src:
                                                                                                                                    -                    to_field = src_model._meta.columns[on.name]
                                                                                                                                    -                elif on.source is dest:
                                                                                                                                    -                    to_field = dest_model._meta.columns[on.name]
                                                                                                                                    -                else:
                                                                                                                                    -                    raise AttributeError('"on" clause Column %s does not '
                                                                                                                                    -                                         'belong to %s or %s.' %
                                                                                                                                    -                                         (on, src_model, dest_model))
                                                                                                                                    -                on = None
                                                                                                                                    -            elif isinstance(on, Field):
                                                                                                                                    -                to_field = on
                                                                                                                                    -                on = None
                                                                                                                                    -            else:
                                                                                                                                    -                to_field = None
                                                                                                                                    -
                                                                                                                                    -            fk_field, is_backref = self._generate_on_clause(
                                                                                                                                    -                src_model, dest_model, to_field, on)
                                                                                                                                    -
                                                                                                                                    -            if on is None:
                                                                                                                                    -                src_attr = 'name' if src_is_model else 'column_name'
                                                                                                                                    -                dest_attr = 'name' if dest_is_model else 'column_name'
                                                                                                                                    -                if is_backref:
                                                                                                                                    -                    lhs = getattr(dest, getattr(fk_field, dest_attr))
                                                                                                                                    -                    rhs = getattr(src, getattr(fk_field.rel_field, src_attr))
                                                                                                                                    -                else:
                                                                                                                                    -                    lhs = getattr(src, getattr(fk_field, src_attr))
                                                                                                                                    -                    rhs = getattr(dest, getattr(fk_field.rel_field, dest_attr))
                                                                                                                                    -                on = (lhs == rhs)
                                                                                                                                    -
                                                                                                                                    -            if not attr:
                                                                                                                                    -                if fk_field is not None and not is_backref:
                                                                                                                                    -                    attr = fk_field.name
                                                                                                                                    -                else:
                                                                                                                                    -                    attr = dest_model._meta.name
                                                                                                                                    -            elif on_alias and fk_field is not None and \
                                                                                                                                    -                    attr == fk_field.object_id_name and not is_backref:
                                                                                                                                    -                raise ValueError('Cannot assign join alias to "%s", as this '
                                                                                                                                    -                                 'attribute is the object_id_name for the '
                                                                                                                                    -                                 'foreign-key field "%s"' % (attr, fk_field))
                                                                                                                                    -
                                                                                                                                    -        elif isinstance(dest, Source):
                                                                                                                                    -            constructor = dict
                                                                                                                                    -            attr = attr or dest._alias
                                                                                                                                    -            if not attr and isinstance(dest, Table):
                                                                                                                                    -                attr = attr or dest.__name__
                                                                                                                                    -
                                                                                                                                    -        return (on, attr, constructor)
                                                                                                                                    -
                                                                                                                                    -    def _generate_on_clause(self, src, dest, to_field=None, on=None):
                                                                                                                                    -        meta = src._meta
                                                                                                                                    -        is_backref = fk_fields = False
                                                                                                                                    -
                                                                                                                                    -        # Get all the foreign keys between source and dest, and determine if
                                                                                                                                    -        # the join is via a back-reference.
                                                                                                                                    -        if dest in meta.model_refs:
                                                                                                                                    -            fk_fields = meta.model_refs[dest]
                                                                                                                                    -        elif dest in meta.model_backrefs:
                                                                                                                                    -            fk_fields = meta.model_backrefs[dest]
                                                                                                                                    -            is_backref = True
                                                                                                                                    -
                                                                                                                                    -        if not fk_fields:
                                                                                                                                    -            if on is not None:
                                                                                                                                    -                return None, False
                                                                                                                                    -            raise ValueError('Unable to find foreign key between %s and %s. '
                                                                                                                                    -                             'Please specify an explicit join condition.' %
                                                                                                                                    -                             (src, dest))
                                                                                                                                    -        elif to_field is not None:
                                                                                                                                    -            # If the foreign-key field was specified explicitly, remove all
                                                                                                                                    -            # other foreign-key fields from the list.
                                                                                                                                    -            target = (to_field.field if isinstance(to_field, FieldAlias)
                                                                                                                                    -                      else to_field)
                                                                                                                                    -            fk_fields = [f for f in fk_fields if (
                                                                                                                                    -                         (f is target) or
                                                                                                                                    -                         (is_backref and f.rel_field is to_field))]
                                                                                                                                    -
                                                                                                                                    -        if len(fk_fields) == 1:
                                                                                                                                    -            return fk_fields[0], is_backref
                                                                                                                                    -
                                                                                                                                    -        if on is None:
                                                                                                                                    -            # If multiple foreign-keys exist, try using the FK whose name
                                                                                                                                    -            # matches that of the related model. If not, raise an error as this
                                                                                                                                    -            # is ambiguous.
                                                                                                                                    -            for fk in fk_fields:
                                                                                                                                    -                if fk.name == dest._meta.name:
                                                                                                                                    -                    return fk, is_backref
                                                                                                                                    -
                                                                                                                                    -            raise ValueError('More than one foreign key between %s and %s.'
                                                                                                                                    -                             ' Please specify which you are joining on.' %
                                                                                                                                    -                             (src, dest))
                                                                                                                                    -
                                                                                                                                    -        # If there are multiple foreign-keys to choose from and the join
                                                                                                                                    -        # predicate is an expression, we'll try to figure out which
                                                                                                                                    -        # foreign-key field we're joining on so that we can assign to the
                                                                                                                                    -        # correct attribute when resolving the model graph.
                                                                                                                                    -        to_field = None
                                                                                                                                    -        if isinstance(on, Expression):
                                                                                                                                    -            lhs, rhs = on.lhs, on.rhs
                                                                                                                                    -            # Coerce to set() so that we force Python to compare using the
                                                                                                                                    -            # object's hash rather than equality test, which returns a
                                                                                                                                    -            # false-positive due to overriding __eq__.
                                                                                                                                    -            fk_set = set(fk_fields)
                                                                                                                                    -
                                                                                                                                    -            if isinstance(lhs, Field):
                                                                                                                                    -                lhs_f = lhs.field if isinstance(lhs, FieldAlias) else lhs
                                                                                                                                    -                if lhs_f in fk_set:
                                                                                                                                    -                    to_field = lhs_f
                                                                                                                                    -            elif isinstance(rhs, Field):
                                                                                                                                    -                rhs_f = rhs.field if isinstance(rhs, FieldAlias) else rhs
                                                                                                                                    -                if rhs_f in fk_set:
                                                                                                                                    -                    to_field = rhs_f
                                                                                                                                    -
                                                                                                                                    -        return to_field, False
                                                                                                                                    -
                                                                                                                                    -    @Node.copy
                                                                                                                                    -    def join(self, dest, join_type=JOIN.INNER, on=None, src=None, attr=None):
                                                                                                                                    -        src = self._join_ctx if src is None else src
                                                                                                                                    -
                                                                                                                                    -        if join_type == JOIN.LATERAL or join_type == JOIN.LEFT_LATERAL:
                                                                                                                                    -            on = True
                                                                                                                                    -        elif join_type != JOIN.CROSS:
                                                                                                                                    -            on, attr, constructor = self._normalize_join(src, dest, on, attr)
                                                                                                                                    -            if attr:
                                                                                                                                    -                self._joins.setdefault(src, [])
                                                                                                                                    -                self._joins[src].append((dest, attr, constructor, join_type))
                                                                                                                                    -        elif on is not None:
                                                                                                                                    -            raise ValueError('Cannot specify on clause with cross join.')
                                                                                                                                    -
                                                                                                                                    -        if not self._from_list:
                                                                                                                                    -            raise ValueError('No sources to join on.')
                                                                                                                                    -
                                                                                                                                    -        item = self._from_list.pop()
                                                                                                                                    -        self._from_list.append(Join(item, dest, join_type, on))
                                                                                                                                    -
                                                                                                                                    -    def join_from(self, src, dest, join_type=JOIN.INNER, on=None, attr=None):
                                                                                                                                    -        return self.join(dest, join_type, on, src, attr)
                                                                                                                                    -
                                                                                                                                    -    def _get_model_cursor_wrapper(self, cursor):
                                                                                                                                    -        if len(self._from_list) == 1 and not self._joins:
                                                                                                                                    -            return ModelObjectCursorWrapper(cursor, self.model,
                                                                                                                                    -                                            self._returning, self.model)
                                                                                                                                    -        return ModelCursorWrapper(cursor, self.model, self._returning,
                                                                                                                                    -                                  self._from_list, self._joins)
                                                                                                                                    -
                                                                                                                                    -    def ensure_join(self, lm, rm, on=None, **join_kwargs):
                                                                                                                                    -        join_ctx = self._join_ctx
                                                                                                                                    -        for dest, _, constructor, _ in self._joins.get(lm, []):
                                                                                                                                    -            if dest == rm:
                                                                                                                                    -                return self
                                                                                                                                    -        return self.switch(lm).join(rm, on=on, **join_kwargs).switch(join_ctx)
                                                                                                                                    -
                                                                                                                                    -    def convert_dict_to_node(self, qdict):
                                                                                                                                    -        accum = []
                                                                                                                                    -        joins = []
                                                                                                                                    -        fks = (ForeignKeyField, BackrefAccessor)
                                                                                                                                    -        for key, value in sorted(qdict.items()):
                                                                                                                                    -            curr = self.model
                                                                                                                                    -            if '__' in key and key.rsplit('__', 1)[1] in DJANGO_MAP:
                                                                                                                                    -                key, op = key.rsplit('__', 1)
                                                                                                                                    -                op = DJANGO_MAP[op]
                                                                                                                                    -            elif value is None:
                                                                                                                                    -                op = DJANGO_MAP['is']
                                                                                                                                    -            else:
                                                                                                                                    -                op = DJANGO_MAP['eq']
                                                                                                                                    -
                                                                                                                                    -            if '__' not in key:
                                                                                                                                    -                # Handle simplest case. This avoids joining over-eagerly when a
                                                                                                                                    -                # direct FK lookup is all that is required.
                                                                                                                                    -                model_attr = getattr(curr, key)
                                                                                                                                    -            else:
                                                                                                                                    -                for piece in key.split('__'):
                                                                                                                                    -                    for dest, attr, _, _ in self._joins.get(curr, ()):
                                                                                                                                    -                        if attr == piece or (isinstance(dest, ModelAlias) and
                                                                                                                                    -                                             dest.alias == piece):
                                                                                                                                    -                            curr = dest
                                                                                                                                    -                            break
                                                                                                                                    -                    else:
                                                                                                                                    -                        model_attr = getattr(curr, piece)
                                                                                                                                    -                        if value is not None and isinstance(model_attr, fks):
                                                                                                                                    -                            curr = model_attr.rel_model
                                                                                                                                    -                            joins.append(model_attr)
                                                                                                                                    -            accum.append(op(model_attr, value))
                                                                                                                                    -        return accum, joins
                                                                                                                                    -
                                                                                                                                    -    def filter(self, *args, **kwargs):
                                                                                                                                    -        # normalize args and kwargs into a new expression
                                                                                                                                    -        if args and kwargs:
                                                                                                                                    -            dq_node = (reduce(operator.and_, [a.clone() for a in args]) &
                                                                                                                                    -                       DQ(**kwargs))
                                                                                                                                    -        elif args:
                                                                                                                                    -            dq_node = (reduce(operator.and_, [a.clone() for a in args]) &
                                                                                                                                    -                       ColumnBase())
                                                                                                                                    -        elif kwargs:
                                                                                                                                    -            dq_node = DQ(**kwargs) & ColumnBase()
                                                                                                                                    -        else:
                                                                                                                                    -            return self.clone()
                                                                                                                                    -
                                                                                                                                    -        # dq_node should now be an Expression, lhs = Node(), rhs = ...
                                                                                                                                    -        q = collections.deque([dq_node])
                                                                                                                                    -        dq_joins = []
                                                                                                                                    -        seen_joins = set()
                                                                                                                                    -        while q:
                                                                                                                                    -            curr = q.popleft()
                                                                                                                                    -            if not isinstance(curr, Expression):
                                                                                                                                    -                continue
                                                                                                                                    -            for side, piece in (('lhs', curr.lhs), ('rhs', curr.rhs)):
                                                                                                                                    -                if isinstance(piece, DQ):
                                                                                                                                    -                    query, joins = self.convert_dict_to_node(piece.query)
                                                                                                                                    -                    for join in joins:
                                                                                                                                    -                        if join not in seen_joins:
                                                                                                                                    -                            dq_joins.append(join)
                                                                                                                                    -                            seen_joins.add(join)
                                                                                                                                    -                    expression = reduce(operator.and_, query)
                                                                                                                                    -                    # Apply values from the DQ object.
                                                                                                                                    -                    if piece._negated:
                                                                                                                                    -                        expression = Negated(expression)
                                                                                                                                    -                    #expression._alias = piece._alias
                                                                                                                                    -                    setattr(curr, side, expression)
                                                                                                                                    -                else:
                                                                                                                                    -                    q.append(piece)
                                                                                                                                    -
                                                                                                                                    -        if not args or not kwargs:
                                                                                                                                    -            dq_node = dq_node.lhs
                                                                                                                                    -
                                                                                                                                    -        query = self.clone()
                                                                                                                                    -        for field in dq_joins:
                                                                                                                                    -            if isinstance(field, ForeignKeyField):
                                                                                                                                    -                lm, rm = field.model, field.rel_model
                                                                                                                                    -                field_obj = field
                                                                                                                                    -            elif isinstance(field, BackrefAccessor):
                                                                                                                                    -                lm, rm = field.model, field.rel_model
                                                                                                                                    -                field_obj = field.field
                                                                                                                                    -            query = query.ensure_join(lm, rm, field_obj)
                                                                                                                                    -        return query.where(dq_node)
                                                                                                                                    -
                                                                                                                                    -    def create_table(self, name, safe=True, **meta):
                                                                                                                                    -        return self.model._schema.create_table_as(name, self, safe, **meta)
                                                                                                                                    -
                                                                                                                                    -    def __sql_selection__(self, ctx, is_subquery=False):
                                                                                                                                    -        if self._is_default and is_subquery and len(self._returning) > 1 and \
                                                                                                                                    -           self.model._meta.primary_key is not False:
                                                                                                                                    -            return ctx.sql(self.model._meta.primary_key)
                                                                                                                                    -
                                                                                                                                    -        return ctx.sql(CommaNodeList(self._returning))
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class NoopModelSelect(ModelSelect):
                                                                                                                                    -    def __sql__(self, ctx):
                                                                                                                                    -        return self.model._meta.database.get_noop_select(ctx)
                                                                                                                                    -
                                                                                                                                    -    def _get_cursor_wrapper(self, cursor):
                                                                                                                                    -        return CursorWrapper(cursor)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class _ModelWriteQueryHelper(_ModelQueryHelper):
                                                                                                                                    -    def __init__(self, model, *args, **kwargs):
                                                                                                                                    -        self.model = model
                                                                                                                                    -        super(_ModelWriteQueryHelper, self).__init__(model, *args, **kwargs)
                                                                                                                                    -
                                                                                                                                    -    def returning(self, *returning):
                                                                                                                                    -        accum = []
                                                                                                                                    -        for item in returning:
                                                                                                                                    -            if is_model(item):
                                                                                                                                    -                accum.extend(item._meta.sorted_fields)
                                                                                                                                    -            else:
                                                                                                                                    -                accum.append(item)
                                                                                                                                    -        return super(_ModelWriteQueryHelper, self).returning(*accum)
                                                                                                                                    -
                                                                                                                                    -    def _set_table_alias(self, ctx):
                                                                                                                                    -        table = self.model._meta.table
                                                                                                                                    -        ctx.alias_manager[table] = table.__name__
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class ModelUpdate(_ModelWriteQueryHelper, Update):
                                                                                                                                    -    pass
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class ModelInsert(_ModelWriteQueryHelper, Insert):
                                                                                                                                    -    default_row_type = ROW.TUPLE
                                                                                                                                    -
                                                                                                                                    -    def __init__(self, *args, **kwargs):
                                                                                                                                    -        super(ModelInsert, self).__init__(*args, **kwargs)
                                                                                                                                    -        if self._returning is None and self.model._meta.database is not None:
                                                                                                                                    -            if self.model._meta.database.returning_clause:
                                                                                                                                    -                self._returning = self.model._meta.get_primary_keys()
                                                                                                                                    -
                                                                                                                                    -    def returning(self, *returning):
                                                                                                                                    -        # By default ModelInsert will yield a `tuple` containing the
                                                                                                                                    -        # primary-key of the newly inserted row. But if we are explicitly
                                                                                                                                    -        # specifying a returning clause and have not set a row type, we will
                                                                                                                                    -        # default to returning model instances instead.
                                                                                                                                    -        if returning and self._row_type is None:
                                                                                                                                    -            self._row_type = ROW.MODEL
                                                                                                                                    -        return super(ModelInsert, self).returning(*returning)
                                                                                                                                    -
                                                                                                                                    -    def get_default_data(self):
                                                                                                                                    -        return self.model._meta.defaults
                                                                                                                                    -
                                                                                                                                    -    def get_default_columns(self):
                                                                                                                                    -        fields = self.model._meta.sorted_fields
                                                                                                                                    -        return fields[1:] if self.model._meta.auto_increment else fields
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class ModelDelete(_ModelWriteQueryHelper, Delete):
                                                                                                                                    -    pass
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class ManyToManyQuery(ModelSelect):
                                                                                                                                    -    def __init__(self, instance, accessor, rel, *args, **kwargs):
                                                                                                                                    -        self._instance = instance
                                                                                                                                    -        self._accessor = accessor
                                                                                                                                    -        self._src_attr = accessor.src_fk.rel_field.name
                                                                                                                                    -        self._dest_attr = accessor.dest_fk.rel_field.name
                                                                                                                                    -        super(ManyToManyQuery, self).__init__(rel, (rel,), *args, **kwargs)
                                                                                                                                    -
                                                                                                                                    -    def _id_list(self, model_or_id_list):
                                                                                                                                    -        if isinstance(model_or_id_list[0], Model):
                                                                                                                                    -            return [getattr(obj, self._dest_attr) for obj in model_or_id_list]
                                                                                                                                    -        return model_or_id_list
                                                                                                                                    -
                                                                                                                                    -    def add(self, value, clear_existing=False):
                                                                                                                                    -        if clear_existing:
                                                                                                                                    -            self.clear()
                                                                                                                                    -
                                                                                                                                    -        accessor = self._accessor
                                                                                                                                    -        src_id = getattr(self._instance, self._src_attr)
                                                                                                                                    -        if isinstance(value, SelectQuery):
                                                                                                                                    -            query = value.columns(
                                                                                                                                    -                Value(src_id),
                                                                                                                                    -                accessor.dest_fk.rel_field)
                                                                                                                                    -            accessor.through_model.insert_from(
                                                                                                                                    -                fields=[accessor.src_fk, accessor.dest_fk],
                                                                                                                                    -                query=query).execute()
                                                                                                                                    -        else:
                                                                                                                                    -            value = ensure_tuple(value)
                                                                                                                                    -            if not value: return
                                                                                                                                    -
                                                                                                                                    -            inserts = [{
                                                                                                                                    -                accessor.src_fk.name: src_id,
                                                                                                                                    -                accessor.dest_fk.name: rel_id}
                                                                                                                                    -                for rel_id in self._id_list(value)]
                                                                                                                                    -            accessor.through_model.insert_many(inserts).execute()
                                                                                                                                    -
                                                                                                                                    -    def remove(self, value):
                                                                                                                                    -        src_id = getattr(self._instance, self._src_attr)
                                                                                                                                    -        if isinstance(value, SelectQuery):
                                                                                                                                    -            column = getattr(value.model, self._dest_attr)
                                                                                                                                    -            subquery = value.columns(column)
                                                                                                                                    -            return (self._accessor.through_model
                                                                                                                                    -                    .delete()
                                                                                                                                    -                    .where(
                                                                                                                                    -                        (self._accessor.dest_fk << subquery) &
                                                                                                                                    -                        (self._accessor.src_fk == src_id))
                                                                                                                                    -                    .execute())
                                                                                                                                    -        else:
                                                                                                                                    -            value = ensure_tuple(value)
                                                                                                                                    -            if not value:
                                                                                                                                    -                return
                                                                                                                                    -            return (self._accessor.through_model
                                                                                                                                    -                    .delete()
                                                                                                                                    -                    .where(
                                                                                                                                    -                        (self._accessor.dest_fk << self._id_list(value)) &
                                                                                                                                    -                        (self._accessor.src_fk == src_id))
                                                                                                                                    -                    .execute())
                                                                                                                                    -
                                                                                                                                    -    def clear(self):
                                                                                                                                    -        src_id = getattr(self._instance, self._src_attr)
                                                                                                                                    -        return (self._accessor.through_model
                                                                                                                                    -                .delete()
                                                                                                                                    -                .where(self._accessor.src_fk == src_id)
                                                                                                                                    -                .execute())
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -def safe_python_value(conv_func):
                                                                                                                                    -    def validate(value):
                                                                                                                                    -        try:
                                                                                                                                    -            return conv_func(value)
                                                                                                                                    -        except (TypeError, ValueError):
                                                                                                                                    -            return value
                                                                                                                                    -    return validate
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class BaseModelCursorWrapper(DictCursorWrapper):
                                                                                                                                    -    def __init__(self, cursor, model, columns):
                                                                                                                                    -        super(BaseModelCursorWrapper, self).__init__(cursor)
                                                                                                                                    -        self.model = model
                                                                                                                                    -        self.select = columns or []
                                                                                                                                    -
                                                                                                                                    -    def _initialize_columns(self):
                                                                                                                                    -        combined = self.model._meta.combined
                                                                                                                                    -        table = self.model._meta.table
                                                                                                                                    -        description = self.cursor.description
                                                                                                                                    -
                                                                                                                                    -        self.ncols = len(self.cursor.description)
                                                                                                                                    -        self.columns = []
                                                                                                                                    -        self.converters = converters = [None] * self.ncols
                                                                                                                                    -        self.fields = fields = [None] * self.ncols
                                                                                                                                    -
                                                                                                                                    -        for idx, description_item in enumerate(description):
                                                                                                                                    -            column = description_item[0]
                                                                                                                                    -            dot_index = column.find('.')
                                                                                                                                    -            if dot_index != -1:
                                                                                                                                    -                column = column[dot_index + 1:]
                                                                                                                                    -
                                                                                                                                    -            column = column.strip('"')
                                                                                                                                    -            self.columns.append(column)
                                                                                                                                    -            try:
                                                                                                                                    -                raw_node = self.select[idx]
                                                                                                                                    -            except IndexError:
                                                                                                                                    -                if column in combined:
                                                                                                                                    -                    raw_node = node = combined[column]
                                                                                                                                    -                else:
                                                                                                                                    -                    continue
                                                                                                                                    -            else:
                                                                                                                                    -                node = raw_node.unwrap()
                                                                                                                                    -
                                                                                                                                    -            # Heuristics used to attempt to get the field associated with a
                                                                                                                                    -            # given SELECT column, so that we can accurately convert the value
                                                                                                                                    -            # returned by the database-cursor into a Python object.
                                                                                                                                    -            if isinstance(node, Field):
                                                                                                                                    -                if raw_node._coerce:
                                                                                                                                    -                    converters[idx] = node.python_value
                                                                                                                                    -                fields[idx] = node
                                                                                                                                    -                if not raw_node.is_alias():
                                                                                                                                    -                    self.columns[idx] = node.name
                                                                                                                                    -            elif isinstance(node, ColumnBase) and raw_node._converter:
                                                                                                                                    -                converters[idx] = raw_node._converter
                                                                                                                                    -            elif isinstance(node, Function) and node._coerce:
                                                                                                                                    -                if node._python_value is not None:
                                                                                                                                    -                    converters[idx] = node._python_value
                                                                                                                                    -                elif node.arguments and isinstance(node.arguments[0], Node):
                                                                                                                                    -                    # If the first argument is a field or references a column
                                                                                                                                    -                    # on a Model, try using that field's conversion function.
                                                                                                                                    -                    # This usually works, but we use "safe_python_value()" so
                                                                                                                                    -                    # that if a TypeError or ValueError occurs during
                                                                                                                                    -                    # conversion we can just fall-back to the raw cursor value.
                                                                                                                                    -                    first = node.arguments[0].unwrap()
                                                                                                                                    -                    if isinstance(first, Entity):
                                                                                                                                    -                        path = first._path[-1]  # Try to look-up by name.
                                                                                                                                    -                        first = combined.get(path)
                                                                                                                                    -                    if isinstance(first, Field):
                                                                                                                                    -                        converters[idx] = safe_python_value(first.python_value)
                                                                                                                                    -            elif column in combined:
                                                                                                                                    -                if node._coerce:
                                                                                                                                    -                    converters[idx] = combined[column].python_value
                                                                                                                                    -                if isinstance(node, Column) and node.source == table:
                                                                                                                                    -                    fields[idx] = combined[column]
                                                                                                                                    -
                                                                                                                                    -    initialize = _initialize_columns
                                                                                                                                    -
                                                                                                                                    -    def process_row(self, row):
                                                                                                                                    -        raise NotImplementedError
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class ModelDictCursorWrapper(BaseModelCursorWrapper):
                                                                                                                                    -    def process_row(self, row):
                                                                                                                                    -        result = {}
                                                                                                                                    -        columns, converters = self.columns, self.converters
                                                                                                                                    -        fields = self.fields
                                                                                                                                    -
                                                                                                                                    -        for i in range(self.ncols):
                                                                                                                                    -            attr = columns[i]
                                                                                                                                    -            if attr in result: continue  # Don't overwrite if we have dupes.
                                                                                                                                    -            if converters[i] is not None:
                                                                                                                                    -                result[attr] = converters[i](row[i])
                                                                                                                                    -            else:
                                                                                                                                    -                result[attr] = row[i]
                                                                                                                                    -
                                                                                                                                    -        return result
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class ModelTupleCursorWrapper(ModelDictCursorWrapper):
                                                                                                                                    -    constructor = tuple
                                                                                                                                    -
                                                                                                                                    -    def process_row(self, row):
                                                                                                                                    -        columns, converters = self.columns, self.converters
                                                                                                                                    -        return self.constructor([
                                                                                                                                    -            (converters[i](row[i]) if converters[i] is not None else row[i])
                                                                                                                                    -            for i in range(self.ncols)])
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class ModelNamedTupleCursorWrapper(ModelTupleCursorWrapper):
                                                                                                                                    -    def initialize(self):
                                                                                                                                    -        self._initialize_columns()
                                                                                                                                    -        attributes = []
                                                                                                                                    -        for i in range(self.ncols):
                                                                                                                                    -            attributes.append(self.columns[i])
                                                                                                                                    -        self.tuple_class = collections.namedtuple('Row', attributes)
                                                                                                                                    -        self.constructor = lambda row: self.tuple_class(*row)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class ModelObjectCursorWrapper(ModelDictCursorWrapper):
                                                                                                                                    -    def __init__(self, cursor, model, select, constructor):
                                                                                                                                    -        self.constructor = constructor
                                                                                                                                    -        self.is_model = is_model(constructor)
                                                                                                                                    -        super(ModelObjectCursorWrapper, self).__init__(cursor, model, select)
                                                                                                                                    -
                                                                                                                                    -    def process_row(self, row):
                                                                                                                                    -        data = super(ModelObjectCursorWrapper, self).process_row(row)
                                                                                                                                    -        if self.is_model:
                                                                                                                                    -            # Clear out any dirty fields before returning to the user.
                                                                                                                                    -            obj = self.constructor(__no_default__=1, **data)
                                                                                                                                    -            obj._dirty.clear()
                                                                                                                                    -            return obj
                                                                                                                                    -        else:
                                                                                                                                    -            return self.constructor(**data)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class ModelCursorWrapper(BaseModelCursorWrapper):
                                                                                                                                    -    def __init__(self, cursor, model, select, from_list, joins):
                                                                                                                                    -        super(ModelCursorWrapper, self).__init__(cursor, model, select)
                                                                                                                                    -        self.from_list = from_list
                                                                                                                                    -        self.joins = joins
                                                                                                                                    -
                                                                                                                                    -    def initialize(self):
                                                                                                                                    -        self._initialize_columns()
                                                                                                                                    -        selected_src = set([field.model for field in self.fields
                                                                                                                                    -                            if field is not None])
                                                                                                                                    -        select, columns = self.select, self.columns
                                                                                                                                    -
                                                                                                                                    -        self.key_to_constructor = {self.model: self.model}
                                                                                                                                    -        self.src_is_dest = {}
                                                                                                                                    -        self.src_to_dest = []
                                                                                                                                    -        accum = collections.deque(self.from_list)
                                                                                                                                    -        dests = set()
                                                                                                                                    -
                                                                                                                                    -        while accum:
                                                                                                                                    -            curr = accum.popleft()
                                                                                                                                    -            if isinstance(curr, Join):
                                                                                                                                    -                accum.append(curr.lhs)
                                                                                                                                    -                accum.append(curr.rhs)
                                                                                                                                    -                continue
                                                                                                                                    -
                                                                                                                                    -            if curr not in self.joins:
                                                                                                                                    -                continue
                                                                                                                                    -
                                                                                                                                    -            is_dict = isinstance(curr, dict)
                                                                                                                                    -            for key, attr, constructor, join_type in self.joins[curr]:
                                                                                                                                    -                if key not in self.key_to_constructor:
                                                                                                                                    -                    self.key_to_constructor[key] = constructor
                                                                                                                                    -
                                                                                                                                    -                    # (src, attr, dest, is_dict, join_type).
                                                                                                                                    -                    self.src_to_dest.append((curr, attr, key, is_dict,
                                                                                                                                    -                                             join_type))
                                                                                                                                    -                    dests.add(key)
                                                                                                                                    -                    accum.append(key)
                                                                                                                                    -
                                                                                                                                    -        # Ensure that we accommodate everything selected.
                                                                                                                                    -        for src in selected_src:
                                                                                                                                    -            if src not in self.key_to_constructor:
                                                                                                                                    -                if is_model(src):
                                                                                                                                    -                    self.key_to_constructor[src] = src
                                                                                                                                    -                elif isinstance(src, ModelAlias):
                                                                                                                                    -                    self.key_to_constructor[src] = src.model
                                                                                                                                    -
                                                                                                                                    -        # Indicate which sources are also dests.
                                                                                                                                    -        for src, _, dest, _, _ in self.src_to_dest:
                                                                                                                                    -            self.src_is_dest[src] = src in dests and (dest in selected_src
                                                                                                                                    -                                                      or src in selected_src)
                                                                                                                                    -
                                                                                                                                    -        self.column_keys = []
                                                                                                                                    -        for idx, node in enumerate(select):
                                                                                                                                    -            key = self.model
                                                                                                                                    -            field = self.fields[idx]
                                                                                                                                    -            if field is not None:
                                                                                                                                    -                if isinstance(field, FieldAlias):
                                                                                                                                    -                    key = field.source
                                                                                                                                    -                else:
                                                                                                                                    -                    key = field.model
                                                                                                                                    -            else:
                                                                                                                                    -                if isinstance(node, Node):
                                                                                                                                    -                    node = node.unwrap()
                                                                                                                                    -                if isinstance(node, Column):
                                                                                                                                    -                    key = node.source
                                                                                                                                    -
                                                                                                                                    -            self.column_keys.append(key)
                                                                                                                                    -
                                                                                                                                    -    def process_row(self, row):
                                                                                                                                    -        objects = {}
                                                                                                                                    -        object_list = []
                                                                                                                                    -        for key, constructor in self.key_to_constructor.items():
                                                                                                                                    -            objects[key] = constructor(__no_default__=True)
                                                                                                                                    -            object_list.append(objects[key])
                                                                                                                                    -
                                                                                                                                    -        set_keys = set()
                                                                                                                                    -        for idx, key in enumerate(self.column_keys):
                                                                                                                                    -            instance = objects[key]
                                                                                                                                    -            column = self.columns[idx]
                                                                                                                                    -            value = row[idx]
                                                                                                                                    -            if value is not None:
                                                                                                                                    -                set_keys.add(key)
                                                                                                                                    -            if self.converters[idx]:
                                                                                                                                    -                value = self.converters[idx](value)
                                                                                                                                    -
                                                                                                                                    -            if isinstance(instance, dict):
                                                                                                                                    -                instance[column] = value
                                                                                                                                    -            else:
                                                                                                                                    -                setattr(instance, column, value)
                                                                                                                                    -
                                                                                                                                    -        # Need to do some analysis on the joins before this.
                                                                                                                                    -        for (src, attr, dest, is_dict, join_type) in self.src_to_dest:
                                                                                                                                    -            instance = objects[src]
                                                                                                                                    -            try:
                                                                                                                                    -                joined_instance = objects[dest]
                                                                                                                                    -            except KeyError:
                                                                                                                                    -                continue
                                                                                                                                    -
                                                                                                                                    -            # If no fields were set on the destination instance then do not
                                                                                                                                    -            # assign an "empty" instance.
                                                                                                                                    -            if instance is None or dest is None or \
                                                                                                                                    -               (dest not in set_keys and not self.src_is_dest.get(dest)):
                                                                                                                                    -                continue
                                                                                                                                    -
                                                                                                                                    -            # If no fields were set on either the source or the destination,
                                                                                                                                    -            # then we have nothing to do here.
                                                                                                                                    -            if instance not in set_keys and dest not in set_keys \
                                                                                                                                    -               and join_type.endswith('OUTER JOIN'):
                                                                                                                                    -                continue
                                                                                                                                    -
                                                                                                                                    -            if is_dict:
                                                                                                                                    -                instance[attr] = joined_instance
                                                                                                                                    -            else:
                                                                                                                                    -                setattr(instance, attr, joined_instance)
                                                                                                                                    -
                                                                                                                                    -        # When instantiating models from a cursor, we clear the dirty fields.
                                                                                                                                    -        for instance in object_list:
                                                                                                                                    -            if isinstance(instance, Model):
                                                                                                                                    -                instance._dirty.clear()
                                                                                                                                    -
                                                                                                                                    -        return objects[self.model]
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class PrefetchQuery(collections.namedtuple('_PrefetchQuery', (
                                                                                                                                    -    'query', 'fields', 'is_backref', 'rel_models', 'field_to_name', 'model'))):
                                                                                                                                    -    def __new__(cls, query, fields=None, is_backref=None, rel_models=None,
                                                                                                                                    -                field_to_name=None, model=None):
                                                                                                                                    -        if fields:
                                                                                                                                    -            if is_backref:
                                                                                                                                    -                if rel_models is None:
                                                                                                                                    -                    rel_models = [field.model for field in fields]
                                                                                                                                    -                foreign_key_attrs = [field.rel_field.name for field in fields]
                                                                                                                                    -            else:
                                                                                                                                    -                if rel_models is None:
                                                                                                                                    -                    rel_models = [field.rel_model for field in fields]
                                                                                                                                    -                foreign_key_attrs = [field.name for field in fields]
                                                                                                                                    -            field_to_name = list(zip(fields, foreign_key_attrs))
                                                                                                                                    -        model = query.model
                                                                                                                                    -        return super(PrefetchQuery, cls).__new__(
                                                                                                                                    -            cls, query, fields, is_backref, rel_models, field_to_name, model)
                                                                                                                                    -
                                                                                                                                    -    def populate_instance(self, instance, id_map):
                                                                                                                                    -        if self.is_backref:
                                                                                                                                    -            for field in self.fields:
                                                                                                                                    -                identifier = instance.__data__[field.name]
                                                                                                                                    -                key = (field, identifier)
                                                                                                                                    -                if key in id_map:
                                                                                                                                    -                    setattr(instance, field.name, id_map[key])
                                                                                                                                    -        else:
                                                                                                                                    -            for field, attname in self.field_to_name:
                                                                                                                                    -                identifier = instance.__data__[field.rel_field.name]
                                                                                                                                    -                key = (field, identifier)
                                                                                                                                    -                rel_instances = id_map.get(key, [])
                                                                                                                                    -                for inst in rel_instances:
                                                                                                                                    -                    setattr(inst, attname, instance)
                                                                                                                                    -                    inst._dirty.clear()
                                                                                                                                    -                setattr(instance, field.backref, rel_instances)
                                                                                                                                    -
                                                                                                                                    -    def store_instance(self, instance, id_map):
                                                                                                                                    -        for field, attname in self.field_to_name:
                                                                                                                                    -            identity = field.rel_field.python_value(instance.__data__[attname])
                                                                                                                                    -            key = (field, identity)
                                                                                                                                    -            if self.is_backref:
                                                                                                                                    -                id_map[key] = instance
                                                                                                                                    -            else:
                                                                                                                                    -                id_map.setdefault(key, [])
                                                                                                                                    -                id_map[key].append(instance)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -def prefetch_add_subquery(sq, subqueries):
                                                                                                                                    -    fixed_queries = [PrefetchQuery(sq)]
                                                                                                                                    -    for i, subquery in enumerate(subqueries):
                                                                                                                                    -        if isinstance(subquery, tuple):
                                                                                                                                    -            subquery, target_model = subquery
                                                                                                                                    -        else:
                                                                                                                                    -            target_model = None
                                                                                                                                    -        if not isinstance(subquery, Query) and is_model(subquery) or \
                                                                                                                                    -           isinstance(subquery, ModelAlias):
                                                                                                                                    -            subquery = subquery.select()
                                                                                                                                    -        subquery_model = subquery.model
                                                                                                                                    -        fks = backrefs = None
                                                                                                                                    -        for j in reversed(range(i + 1)):
                                                                                                                                    -            fixed = fixed_queries[j]
                                                                                                                                    -            last_query = fixed.query
                                                                                                                                    -            last_model = last_obj = fixed.model
                                                                                                                                    -            if isinstance(last_model, ModelAlias):
                                                                                                                                    -                last_model = last_model.model
                                                                                                                                    -            rels = subquery_model._meta.model_refs.get(last_model, [])
                                                                                                                                    -            if rels:
                                                                                                                                    -                fks = [getattr(subquery_model, fk.name) for fk in rels]
                                                                                                                                    -                pks = [getattr(last_obj, fk.rel_field.name) for fk in rels]
                                                                                                                                    -            else:
                                                                                                                                    -                backrefs = subquery_model._meta.model_backrefs.get(last_model)
                                                                                                                                    -            if (fks or backrefs) and ((target_model is last_obj) or
                                                                                                                                    -                                      (target_model is None)):
                                                                                                                                    -                break
                                                                                                                                    -
                                                                                                                                    -        if not fks and not backrefs:
                                                                                                                                    -            tgt_err = ' using %s' % target_model if target_model else ''
                                                                                                                                    -            raise AttributeError('Error: unable to find foreign key for '
                                                                                                                                    -                                 'query: %s%s' % (subquery, tgt_err))
                                                                                                                                    -
                                                                                                                                    -        dest = (target_model,) if target_model else None
                                                                                                                                    -
                                                                                                                                    -        if fks:
                                                                                                                                    -            expr = reduce(operator.or_, [
                                                                                                                                    -                (fk << last_query.select(pk))
                                                                                                                                    -                for (fk, pk) in zip(fks, pks)])
                                                                                                                                    -            subquery = subquery.where(expr)
                                                                                                                                    -            fixed_queries.append(PrefetchQuery(subquery, fks, False, dest))
                                                                                                                                    -        elif backrefs:
                                                                                                                                    -            expressions = []
                                                                                                                                    -            for backref in backrefs:
                                                                                                                                    -                rel_field = getattr(subquery_model, backref.rel_field.name)
                                                                                                                                    -                fk_field = getattr(last_obj, backref.name)
                                                                                                                                    -                expressions.append(rel_field << last_query.select(fk_field))
                                                                                                                                    -            subquery = subquery.where(reduce(operator.or_, expressions))
                                                                                                                                    -            fixed_queries.append(PrefetchQuery(subquery, backrefs, True, dest))
                                                                                                                                    -
                                                                                                                                    -    return fixed_queries
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -def prefetch(sq, *subqueries):
                                                                                                                                    -    if not subqueries:
                                                                                                                                    -        return sq
                                                                                                                                    -
                                                                                                                                    -    fixed_queries = prefetch_add_subquery(sq, subqueries)
                                                                                                                                    -    deps = {}
                                                                                                                                    -    rel_map = {}
                                                                                                                                    -    for pq in reversed(fixed_queries):
                                                                                                                                    -        query_model = pq.model
                                                                                                                                    -        if pq.fields:
                                                                                                                                    -            for rel_model in pq.rel_models:
                                                                                                                                    -                rel_map.setdefault(rel_model, [])
                                                                                                                                    -                rel_map[rel_model].append(pq)
                                                                                                                                    -
                                                                                                                                    -        deps.setdefault(query_model, {})
                                                                                                                                    -        id_map = deps[query_model]
                                                                                                                                    -        has_relations = bool(rel_map.get(query_model))
                                                                                                                                    -
                                                                                                                                    -        for instance in pq.query:
                                                                                                                                    -            if pq.fields:
                                                                                                                                    -                pq.store_instance(instance, id_map)
                                                                                                                                    -            if has_relations:
                                                                                                                                    -                for rel in rel_map[query_model]:
                                                                                                                                    -                    rel.populate_instance(instance, deps[rel.model])
                                                                                                                                    -
                                                                                                                                    -    return list(pq.query)
                                                                                                                                    -
                                                                                                                                    - -
                                                                                                                                    - -
                                                                                                                                    -
                                                                                                                                    - -
                                                                                                                                    - -
                                                                                                                                    -

                                                                                                                                    - © Copyright 2021 - present / Neuralmagic, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"). - -

                                                                                                                                    -
                                                                                                                                    - - - - Built with Sphinx using a - - theme - - provided by Read the Docs. - -
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    - -
                                                                                                                                    - -
                                                                                                                                    - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sparsify/_modules/playhouse/sqlite_ext.html b/sparsify/_modules/playhouse/sqlite_ext.html deleted file mode 100644 index d84b29f09f8..00000000000 --- a/sparsify/_modules/playhouse/sqlite_ext.html +++ /dev/null @@ -1,1530 +0,0 @@ - - - - - - - - - - playhouse.sqlite_ext — Sparsify 0.1.0 documentation - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                                                                                                                                    - - - -
                                                                                                                                    - - - - - -
                                                                                                                                    - -
                                                                                                                                    - - - - - - - - - - - - - - - - - - - -
                                                                                                                                    - -
                                                                                                                                      - -
                                                                                                                                    • »
                                                                                                                                    • - -
                                                                                                                                    • Module code »
                                                                                                                                    • - -
                                                                                                                                    • playhouse.sqlite_ext
                                                                                                                                    • - - -
                                                                                                                                    • - -
                                                                                                                                    • - -
                                                                                                                                    - - -
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    - -

                                                                                                                                    Source code for playhouse.sqlite_ext

                                                                                                                                    -import json
                                                                                                                                    -import math
                                                                                                                                    -import re
                                                                                                                                    -import struct
                                                                                                                                    -import sys
                                                                                                                                    -
                                                                                                                                    -from peewee import *
                                                                                                                                    -from peewee import ColumnBase
                                                                                                                                    -from peewee import EnclosedNodeList
                                                                                                                                    -from peewee import Entity
                                                                                                                                    -from peewee import Expression
                                                                                                                                    -from peewee import Node
                                                                                                                                    -from peewee import NodeList
                                                                                                                                    -from peewee import OP
                                                                                                                                    -from peewee import VirtualField
                                                                                                                                    -from peewee import merge_dict
                                                                                                                                    -from peewee import sqlite3
                                                                                                                                    -try:
                                                                                                                                    -    from playhouse._sqlite_ext import (
                                                                                                                                    -        backup,
                                                                                                                                    -        backup_to_file,
                                                                                                                                    -        Blob,
                                                                                                                                    -        ConnectionHelper,
                                                                                                                                    -        register_bloomfilter,
                                                                                                                                    -        register_hash_functions,
                                                                                                                                    -        register_rank_functions,
                                                                                                                                    -        sqlite_get_db_status,
                                                                                                                                    -        sqlite_get_status,
                                                                                                                                    -        TableFunction,
                                                                                                                                    -        ZeroBlob,
                                                                                                                                    -    )
                                                                                                                                    -    CYTHON_SQLITE_EXTENSIONS = True
                                                                                                                                    -except ImportError:
                                                                                                                                    -    CYTHON_SQLITE_EXTENSIONS = False
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -if sys.version_info[0] == 3:
                                                                                                                                    -    basestring = str
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -FTS3_MATCHINFO = 'pcx'
                                                                                                                                    -FTS4_MATCHINFO = 'pcnalx'
                                                                                                                                    -if sqlite3 is not None:
                                                                                                                                    -    FTS_VERSION = 4 if sqlite3.sqlite_version_info[:3] >= (3, 7, 4) else 3
                                                                                                                                    -else:
                                                                                                                                    -    FTS_VERSION = 3
                                                                                                                                    -
                                                                                                                                    -FTS5_MIN_SQLITE_VERSION = (3, 9, 0)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class RowIDField(AutoField):
                                                                                                                                    -    auto_increment = True
                                                                                                                                    -    column_name = name = required_name = 'rowid'
                                                                                                                                    -
                                                                                                                                    -    def bind(self, model, name, *args):
                                                                                                                                    -        if name != self.required_name:
                                                                                                                                    -            raise ValueError('%s must be named "%s".' %
                                                                                                                                    -                             (type(self), self.required_name))
                                                                                                                                    -        super(RowIDField, self).bind(model, name, *args)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class DocIDField(RowIDField):
                                                                                                                                    -    column_name = name = required_name = 'docid'
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class AutoIncrementField(AutoField):
                                                                                                                                    -    def ddl(self, ctx):
                                                                                                                                    -        node_list = super(AutoIncrementField, self).ddl(ctx)
                                                                                                                                    -        return NodeList((node_list, SQL('AUTOINCREMENT')))
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class TDecimalField(DecimalField):
                                                                                                                                    -    field_type = 'TEXT'
                                                                                                                                    -    def get_modifiers(self): pass
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class JSONPath(ColumnBase):
                                                                                                                                    -    def __init__(self, field, path=None):
                                                                                                                                    -        super(JSONPath, self).__init__()
                                                                                                                                    -        self._field = field
                                                                                                                                    -        self._path = path or ()
                                                                                                                                    -
                                                                                                                                    -    @property
                                                                                                                                    -    def path(self):
                                                                                                                                    -        return Value('$%s' % ''.join(self._path))
                                                                                                                                    -
                                                                                                                                    -    def __getitem__(self, idx):
                                                                                                                                    -        if isinstance(idx, int):
                                                                                                                                    -            item = '[%s]' % idx
                                                                                                                                    -        else:
                                                                                                                                    -            item = '.%s' % idx
                                                                                                                                    -        return JSONPath(self._field, self._path + (item,))
                                                                                                                                    -
                                                                                                                                    -    def set(self, value, as_json=None):
                                                                                                                                    -        if as_json or isinstance(value, (list, dict)):
                                                                                                                                    -            value = fn.json(self._field._json_dumps(value))
                                                                                                                                    -        return fn.json_set(self._field, self.path, value)
                                                                                                                                    -
                                                                                                                                    -    def update(self, value):
                                                                                                                                    -        return self.set(fn.json_patch(self, self._field._json_dumps(value)))
                                                                                                                                    -
                                                                                                                                    -    def remove(self):
                                                                                                                                    -        return fn.json_remove(self._field, self.path)
                                                                                                                                    -
                                                                                                                                    -    def json_type(self):
                                                                                                                                    -        return fn.json_type(self._field, self.path)
                                                                                                                                    -
                                                                                                                                    -    def length(self):
                                                                                                                                    -        return fn.json_array_length(self._field, self.path)
                                                                                                                                    -
                                                                                                                                    -    def children(self):
                                                                                                                                    -        return fn.json_each(self._field, self.path)
                                                                                                                                    -
                                                                                                                                    -    def tree(self):
                                                                                                                                    -        return fn.json_tree(self._field, self.path)
                                                                                                                                    -
                                                                                                                                    -    def __sql__(self, ctx):
                                                                                                                                    -        return ctx.sql(fn.json_extract(self._field, self.path)
                                                                                                                                    -                       if self._path else self._field)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class JSONField(TextField):
                                                                                                                                    -    field_type = 'JSON'
                                                                                                                                    -    unpack = False
                                                                                                                                    -
                                                                                                                                    -    def __init__(self, json_dumps=None, json_loads=None, **kwargs):
                                                                                                                                    -        self._json_dumps = json_dumps or json.dumps
                                                                                                                                    -        self._json_loads = json_loads or json.loads
                                                                                                                                    -        super(JSONField, self).__init__(**kwargs)
                                                                                                                                    -
                                                                                                                                    -    def python_value(self, value):
                                                                                                                                    -        if value is not None:
                                                                                                                                    -            try:
                                                                                                                                    -                return self._json_loads(value)
                                                                                                                                    -            except (TypeError, ValueError):
                                                                                                                                    -                return value
                                                                                                                                    -
                                                                                                                                    -    def db_value(self, value):
                                                                                                                                    -        if value is not None:
                                                                                                                                    -            if not isinstance(value, Node):
                                                                                                                                    -                value = fn.json(self._json_dumps(value))
                                                                                                                                    -            return value
                                                                                                                                    -
                                                                                                                                    -    def _e(op):
                                                                                                                                    -        def inner(self, rhs):
                                                                                                                                    -            if isinstance(rhs, (list, dict)):
                                                                                                                                    -                rhs = Value(rhs, converter=self.db_value, unpack=False)
                                                                                                                                    -            return Expression(self, op, rhs)
                                                                                                                                    -        return inner
                                                                                                                                    -    __eq__ = _e(OP.EQ)
                                                                                                                                    -    __ne__ = _e(OP.NE)
                                                                                                                                    -    __gt__ = _e(OP.GT)
                                                                                                                                    -    __ge__ = _e(OP.GTE)
                                                                                                                                    -    __lt__ = _e(OP.LT)
                                                                                                                                    -    __le__ = _e(OP.LTE)
                                                                                                                                    -    __hash__ = Field.__hash__
                                                                                                                                    -
                                                                                                                                    -    def __getitem__(self, item):
                                                                                                                                    -        return JSONPath(self)[item]
                                                                                                                                    -
                                                                                                                                    -    def set(self, value, as_json=None):
                                                                                                                                    -        return JSONPath(self).set(value, as_json)
                                                                                                                                    -
                                                                                                                                    -    def update(self, data):
                                                                                                                                    -        return JSONPath(self).update(data)
                                                                                                                                    -
                                                                                                                                    -    def remove(self):
                                                                                                                                    -        return JSONPath(self).remove()
                                                                                                                                    -
                                                                                                                                    -    def json_type(self):
                                                                                                                                    -        return fn.json_type(self)
                                                                                                                                    -
                                                                                                                                    -    def length(self):
                                                                                                                                    -        return fn.json_array_length(self)
                                                                                                                                    -
                                                                                                                                    -    def children(self):
                                                                                                                                    -        """
                                                                                                                                    -        Schema of `json_each` and `json_tree`:
                                                                                                                                    -
                                                                                                                                    -        key,
                                                                                                                                    -        value,
                                                                                                                                    -        type TEXT (object, array, string, etc),
                                                                                                                                    -        atom (value for primitive/scalar types, NULL for array and object)
                                                                                                                                    -        id INTEGER (unique identifier for element)
                                                                                                                                    -        parent INTEGER (unique identifier of parent element or NULL)
                                                                                                                                    -        fullkey TEXT (full path describing element)
                                                                                                                                    -        path TEXT (path to the container of the current element)
                                                                                                                                    -        json JSON hidden (1st input parameter to function)
                                                                                                                                    -        root TEXT hidden (2nd input parameter, path at which to start)
                                                                                                                                    -        """
                                                                                                                                    -        return fn.json_each(self)
                                                                                                                                    -
                                                                                                                                    -    def tree(self):
                                                                                                                                    -        return fn.json_tree(self)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class SearchField(Field):
                                                                                                                                    -    def __init__(self, unindexed=False, column_name=None, **k):
                                                                                                                                    -        if k:
                                                                                                                                    -            raise ValueError('SearchField does not accept these keyword '
                                                                                                                                    -                             'arguments: %s.' % sorted(k))
                                                                                                                                    -        super(SearchField, self).__init__(unindexed=unindexed,
                                                                                                                                    -                                          column_name=column_name, null=True)
                                                                                                                                    -
                                                                                                                                    -    def match(self, term):
                                                                                                                                    -        return match(self, term)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class VirtualTableSchemaManager(SchemaManager):
                                                                                                                                    -    def _create_virtual_table(self, safe=True, **options):
                                                                                                                                    -        options = self.model.clean_options(
                                                                                                                                    -            merge_dict(self.model._meta.options, options))
                                                                                                                                    -
                                                                                                                                    -        # Structure:
                                                                                                                                    -        # CREATE VIRTUAL TABLE <model>
                                                                                                                                    -        # USING <extension_module>
                                                                                                                                    -        # ([prefix_arguments, ...] fields, ... [arguments, ...], [options...])
                                                                                                                                    -        ctx = self._create_context()
                                                                                                                                    -        ctx.literal('CREATE VIRTUAL TABLE ')
                                                                                                                                    -        if safe:
                                                                                                                                    -            ctx.literal('IF NOT EXISTS ')
                                                                                                                                    -        (ctx
                                                                                                                                    -         .sql(self.model)
                                                                                                                                    -         .literal(' USING '))
                                                                                                                                    -
                                                                                                                                    -        ext_module = self.model._meta.extension_module
                                                                                                                                    -        if isinstance(ext_module, Node):
                                                                                                                                    -            return ctx.sql(ext_module)
                                                                                                                                    -
                                                                                                                                    -        ctx.sql(SQL(ext_module)).literal(' ')
                                                                                                                                    -        arguments = []
                                                                                                                                    -        meta = self.model._meta
                                                                                                                                    -
                                                                                                                                    -        if meta.prefix_arguments:
                                                                                                                                    -            arguments.extend([SQL(a) for a in meta.prefix_arguments])
                                                                                                                                    -
                                                                                                                                    -        # Constraints, data-types, foreign and primary keys are all omitted.
                                                                                                                                    -        for field in meta.sorted_fields:
                                                                                                                                    -            if isinstance(field, (RowIDField)) or field._hidden:
                                                                                                                                    -                continue
                                                                                                                                    -            field_def = [Entity(field.column_name)]
                                                                                                                                    -            if field.unindexed:
                                                                                                                                    -                field_def.append(SQL('UNINDEXED'))
                                                                                                                                    -            arguments.append(NodeList(field_def))
                                                                                                                                    -
                                                                                                                                    -        if meta.arguments:
                                                                                                                                    -            arguments.extend([SQL(a) for a in meta.arguments])
                                                                                                                                    -
                                                                                                                                    -        if options:
                                                                                                                                    -            arguments.extend(self._create_table_option_sql(options))
                                                                                                                                    -        return ctx.sql(EnclosedNodeList(arguments))
                                                                                                                                    -
                                                                                                                                    -    def _create_table(self, safe=True, **options):
                                                                                                                                    -        if issubclass(self.model, VirtualModel):
                                                                                                                                    -            return self._create_virtual_table(safe, **options)
                                                                                                                                    -
                                                                                                                                    -        return super(VirtualTableSchemaManager, self)._create_table(
                                                                                                                                    -            safe, **options)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class VirtualModel(Model):
                                                                                                                                    -    class Meta:
                                                                                                                                    -        arguments = None
                                                                                                                                    -        extension_module = None
                                                                                                                                    -        prefix_arguments = None
                                                                                                                                    -        primary_key = False
                                                                                                                                    -        schema_manager_class = VirtualTableSchemaManager
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def clean_options(cls, options):
                                                                                                                                    -        return options
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class BaseFTSModel(VirtualModel):
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def clean_options(cls, options):
                                                                                                                                    -        content = options.get('content')
                                                                                                                                    -        prefix = options.get('prefix')
                                                                                                                                    -        tokenize = options.get('tokenize')
                                                                                                                                    -
                                                                                                                                    -        if isinstance(content, basestring) and content == '':
                                                                                                                                    -            # Special-case content-less full-text search tables.
                                                                                                                                    -            options['content'] = "''"
                                                                                                                                    -        elif isinstance(content, Field):
                                                                                                                                    -            # Special-case to ensure fields are fully-qualified.
                                                                                                                                    -            options['content'] = Entity(content.model._meta.table_name,
                                                                                                                                    -                                        content.column_name)
                                                                                                                                    -
                                                                                                                                    -        if prefix:
                                                                                                                                    -            if isinstance(prefix, (list, tuple)):
                                                                                                                                    -                prefix = ','.join([str(i) for i in prefix])
                                                                                                                                    -            options['prefix'] = "'%s'" % prefix.strip("' ")
                                                                                                                                    -
                                                                                                                                    -        if tokenize and cls._meta.extension_module.lower() == 'fts5':
                                                                                                                                    -            # Tokenizers need to be in quoted string for FTS5, but not for FTS3
                                                                                                                                    -            # or FTS4.
                                                                                                                                    -            options['tokenize'] = '"%s"' % tokenize
                                                                                                                                    -
                                                                                                                                    -        return options
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class FTSModel(BaseFTSModel):
                                                                                                                                    -    """
                                                                                                                                    -    VirtualModel class for creating tables that use either the FTS3 or FTS4
                                                                                                                                    -    search extensions. Peewee automatically determines which version of the
                                                                                                                                    -    FTS extension is supported and will use FTS4 if possible.
                                                                                                                                    -    """
                                                                                                                                    -    # FTS3/4 uses "docid" in the same way a normal table uses "rowid".
                                                                                                                                    -    docid = DocIDField()
                                                                                                                                    -
                                                                                                                                    -    class Meta:
                                                                                                                                    -        extension_module = 'FTS%s' % FTS_VERSION
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def _fts_cmd(cls, cmd):
                                                                                                                                    -        tbl = cls._meta.table_name
                                                                                                                                    -        res = cls._meta.database.execute_sql(
                                                                                                                                    -            "INSERT INTO %s(%s) VALUES('%s');" % (tbl, tbl, cmd))
                                                                                                                                    -        return res.fetchone()
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def optimize(cls):
                                                                                                                                    -        return cls._fts_cmd('optimize')
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def rebuild(cls):
                                                                                                                                    -        return cls._fts_cmd('rebuild')
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def integrity_check(cls):
                                                                                                                                    -        return cls._fts_cmd('integrity-check')
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def merge(cls, blocks=200, segments=8):
                                                                                                                                    -        return cls._fts_cmd('merge=%s,%s' % (blocks, segments))
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def automerge(cls, state=True):
                                                                                                                                    -        return cls._fts_cmd('automerge=%s' % (state and '1' or '0'))
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def match(cls, term):
                                                                                                                                    -        """
                                                                                                                                    -        Generate a `MATCH` expression appropriate for searching this table.
                                                                                                                                    -        """
                                                                                                                                    -        return match(cls._meta.entity, term)
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def rank(cls, *weights):
                                                                                                                                    -        matchinfo = fn.matchinfo(cls._meta.entity, FTS3_MATCHINFO)
                                                                                                                                    -        return fn.fts_rank(matchinfo, *weights)
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def bm25(cls, *weights):
                                                                                                                                    -        match_info = fn.matchinfo(cls._meta.entity, FTS4_MATCHINFO)
                                                                                                                                    -        return fn.fts_bm25(match_info, *weights)
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def bm25f(cls, *weights):
                                                                                                                                    -        match_info = fn.matchinfo(cls._meta.entity, FTS4_MATCHINFO)
                                                                                                                                    -        return fn.fts_bm25f(match_info, *weights)
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def lucene(cls, *weights):
                                                                                                                                    -        match_info = fn.matchinfo(cls._meta.entity, FTS4_MATCHINFO)
                                                                                                                                    -        return fn.fts_lucene(match_info, *weights)
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def _search(cls, term, weights, with_score, score_alias, score_fn,
                                                                                                                                    -                explicit_ordering):
                                                                                                                                    -        if not weights:
                                                                                                                                    -            rank = score_fn()
                                                                                                                                    -        elif isinstance(weights, dict):
                                                                                                                                    -            weight_args = []
                                                                                                                                    -            for field in cls._meta.sorted_fields:
                                                                                                                                    -                # Attempt to get the specified weight of the field by looking
                                                                                                                                    -                # it up using it's field instance followed by name.
                                                                                                                                    -                field_weight = weights.get(field, weights.get(field.name, 1.0))
                                                                                                                                    -                weight_args.append(field_weight)
                                                                                                                                    -            rank = score_fn(*weight_args)
                                                                                                                                    -        else:
                                                                                                                                    -            rank = score_fn(*weights)
                                                                                                                                    -
                                                                                                                                    -        selection = ()
                                                                                                                                    -        order_by = rank
                                                                                                                                    -        if with_score:
                                                                                                                                    -            selection = (cls, rank.alias(score_alias))
                                                                                                                                    -        if with_score and not explicit_ordering:
                                                                                                                                    -            order_by = SQL(score_alias)
                                                                                                                                    -
                                                                                                                                    -        return (cls
                                                                                                                                    -                .select(*selection)
                                                                                                                                    -                .where(cls.match(term))
                                                                                                                                    -                .order_by(order_by))
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def search(cls, term, weights=None, with_score=False, score_alias='score',
                                                                                                                                    -               explicit_ordering=False):
                                                                                                                                    -        """Full-text search using selected `term`."""
                                                                                                                                    -        return cls._search(
                                                                                                                                    -            term,
                                                                                                                                    -            weights,
                                                                                                                                    -            with_score,
                                                                                                                                    -            score_alias,
                                                                                                                                    -            cls.rank,
                                                                                                                                    -            explicit_ordering)
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def search_bm25(cls, term, weights=None, with_score=False,
                                                                                                                                    -                    score_alias='score', explicit_ordering=False):
                                                                                                                                    -        """Full-text search for selected `term` using BM25 algorithm."""
                                                                                                                                    -        return cls._search(
                                                                                                                                    -            term,
                                                                                                                                    -            weights,
                                                                                                                                    -            with_score,
                                                                                                                                    -            score_alias,
                                                                                                                                    -            cls.bm25,
                                                                                                                                    -            explicit_ordering)
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def search_bm25f(cls, term, weights=None, with_score=False,
                                                                                                                                    -                     score_alias='score', explicit_ordering=False):
                                                                                                                                    -        """Full-text search for selected `term` using BM25 algorithm."""
                                                                                                                                    -        return cls._search(
                                                                                                                                    -            term,
                                                                                                                                    -            weights,
                                                                                                                                    -            with_score,
                                                                                                                                    -            score_alias,
                                                                                                                                    -            cls.bm25f,
                                                                                                                                    -            explicit_ordering)
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def search_lucene(cls, term, weights=None, with_score=False,
                                                                                                                                    -                      score_alias='score', explicit_ordering=False):
                                                                                                                                    -        """Full-text search for selected `term` using BM25 algorithm."""
                                                                                                                                    -        return cls._search(
                                                                                                                                    -            term,
                                                                                                                                    -            weights,
                                                                                                                                    -            with_score,
                                                                                                                                    -            score_alias,
                                                                                                                                    -            cls.lucene,
                                                                                                                                    -            explicit_ordering)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -_alphabet = 'abcdefghijklmnopqrstuvwxyz'
                                                                                                                                    -_alphanum = (set('\t ,"(){}*:_+0123456789') |
                                                                                                                                    -             set(_alphabet) |
                                                                                                                                    -             set(_alphabet.upper()) |
                                                                                                                                    -             set((chr(26),)))
                                                                                                                                    -_invalid_ascii = set(chr(p) for p in range(128) if chr(p) not in _alphanum)
                                                                                                                                    -_quote_re = re.compile(r'(?:[^\s"]|"(?:\\.|[^"])*")+')
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class FTS5Model(BaseFTSModel):
                                                                                                                                    -    """
                                                                                                                                    -    Requires SQLite >= 3.9.0.
                                                                                                                                    -
                                                                                                                                    -    Table options:
                                                                                                                                    -
                                                                                                                                    -    content: table name of external content, or empty string for "contentless"
                                                                                                                                    -    content_rowid: column name of external content primary key
                                                                                                                                    -    prefix: integer(s). Ex: '2' or '2 3 4'
                                                                                                                                    -    tokenize: porter, unicode61, ascii. Ex: 'porter unicode61'
                                                                                                                                    -
                                                                                                                                    -    The unicode tokenizer supports the following parameters:
                                                                                                                                    -
                                                                                                                                    -    * remove_diacritics (1 or 0, default is 1)
                                                                                                                                    -    * tokenchars (string of characters, e.g. '-_'
                                                                                                                                    -    * separators (string of characters)
                                                                                                                                    -
                                                                                                                                    -    Parameters are passed as alternating parameter name and value, so:
                                                                                                                                    -
                                                                                                                                    -    {'tokenize': "unicode61 remove_diacritics 0 tokenchars '-_'"}
                                                                                                                                    -
                                                                                                                                    -    Content-less tables:
                                                                                                                                    -
                                                                                                                                    -    If you don't need the full-text content in it's original form, you can
                                                                                                                                    -    specify a content-less table. Searches and auxiliary functions will work
                                                                                                                                    -    as usual, but the only values returned when SELECT-ing can be rowid. Also
                                                                                                                                    -    content-less tables do not support UPDATE or DELETE.
                                                                                                                                    -
                                                                                                                                    -    External content tables:
                                                                                                                                    -
                                                                                                                                    -    You can set up triggers to sync these, e.g.
                                                                                                                                    -
                                                                                                                                    -    -- Create a table. And an external content fts5 table to index it.
                                                                                                                                    -    CREATE TABLE tbl(a INTEGER PRIMARY KEY, b);
                                                                                                                                    -    CREATE VIRTUAL TABLE ft USING fts5(b, content='tbl', content_rowid='a');
                                                                                                                                    -
                                                                                                                                    -    -- Triggers to keep the FTS index up to date.
                                                                                                                                    -    CREATE TRIGGER tbl_ai AFTER INSERT ON tbl BEGIN
                                                                                                                                    -      INSERT INTO ft(rowid, b) VALUES (new.a, new.b);
                                                                                                                                    -    END;
                                                                                                                                    -    CREATE TRIGGER tbl_ad AFTER DELETE ON tbl BEGIN
                                                                                                                                    -      INSERT INTO ft(fts_idx, rowid, b) VALUES('delete', old.a, old.b);
                                                                                                                                    -    END;
                                                                                                                                    -    CREATE TRIGGER tbl_au AFTER UPDATE ON tbl BEGIN
                                                                                                                                    -      INSERT INTO ft(fts_idx, rowid, b) VALUES('delete', old.a, old.b);
                                                                                                                                    -      INSERT INTO ft(rowid, b) VALUES (new.a, new.b);
                                                                                                                                    -    END;
                                                                                                                                    -
                                                                                                                                    -    Built-in auxiliary functions:
                                                                                                                                    -
                                                                                                                                    -    * bm25(tbl[, weight_0, ... weight_n])
                                                                                                                                    -    * highlight(tbl, col_idx, prefix, suffix)
                                                                                                                                    -    * snippet(tbl, col_idx, prefix, suffix, ?, max_tokens)
                                                                                                                                    -    """
                                                                                                                                    -    # FTS5 does not support declared primary keys, but we can use the
                                                                                                                                    -    # implicit rowid.
                                                                                                                                    -    rowid = RowIDField()
                                                                                                                                    -
                                                                                                                                    -    class Meta:
                                                                                                                                    -        extension_module = 'fts5'
                                                                                                                                    -
                                                                                                                                    -    _error_messages = {
                                                                                                                                    -        'field_type': ('Besides the implicit `rowid` column, all columns must '
                                                                                                                                    -                       'be instances of SearchField'),
                                                                                                                                    -        'index': 'Secondary indexes are not supported for FTS5 models',
                                                                                                                                    -        'pk': 'FTS5 models must use the default `rowid` primary key',
                                                                                                                                    -    }
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def validate_model(cls):
                                                                                                                                    -        # Perform FTS5-specific validation and options post-processing.
                                                                                                                                    -        if cls._meta.primary_key.name != 'rowid':
                                                                                                                                    -            raise ImproperlyConfigured(cls._error_messages['pk'])
                                                                                                                                    -        for field in cls._meta.fields.values():
                                                                                                                                    -            if not isinstance(field, (SearchField, RowIDField)):
                                                                                                                                    -                raise ImproperlyConfigured(cls._error_messages['field_type'])
                                                                                                                                    -        if cls._meta.indexes:
                                                                                                                                    -            raise ImproperlyConfigured(cls._error_messages['index'])
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def fts5_installed(cls):
                                                                                                                                    -        if sqlite3.sqlite_version_info[:3] < FTS5_MIN_SQLITE_VERSION:
                                                                                                                                    -            return False
                                                                                                                                    -
                                                                                                                                    -        # Test in-memory DB to determine if the FTS5 extension is installed.
                                                                                                                                    -        tmp_db = sqlite3.connect(':memory:')
                                                                                                                                    -        try:
                                                                                                                                    -            tmp_db.execute('CREATE VIRTUAL TABLE fts5test USING fts5 (data);')
                                                                                                                                    -        except:
                                                                                                                                    -            try:
                                                                                                                                    -                tmp_db.enable_load_extension(True)
                                                                                                                                    -                tmp_db.load_extension('fts5')
                                                                                                                                    -            except:
                                                                                                                                    -                return False
                                                                                                                                    -            else:
                                                                                                                                    -                cls._meta.database.load_extension('fts5')
                                                                                                                                    -        finally:
                                                                                                                                    -            tmp_db.close()
                                                                                                                                    -
                                                                                                                                    -        return True
                                                                                                                                    -
                                                                                                                                    -    @staticmethod
                                                                                                                                    -    def validate_query(query):
                                                                                                                                    -        """
                                                                                                                                    -        Simple helper function to indicate whether a search query is a
                                                                                                                                    -        valid FTS5 query. Note: this simply looks at the characters being
                                                                                                                                    -        used, and is not guaranteed to catch all problematic queries.
                                                                                                                                    -        """
                                                                                                                                    -        tokens = _quote_re.findall(query)
                                                                                                                                    -        for token in tokens:
                                                                                                                                    -            if token.startswith('"') and token.endswith('"'):
                                                                                                                                    -                continue
                                                                                                                                    -            if set(token) & _invalid_ascii:
                                                                                                                                    -                return False
                                                                                                                                    -        return True
                                                                                                                                    -
                                                                                                                                    -    @staticmethod
                                                                                                                                    -    def clean_query(query, replace=chr(26)):
                                                                                                                                    -        """
                                                                                                                                    -        Clean a query of invalid tokens.
                                                                                                                                    -        """
                                                                                                                                    -        accum = []
                                                                                                                                    -        any_invalid = False
                                                                                                                                    -        tokens = _quote_re.findall(query)
                                                                                                                                    -        for token in tokens:
                                                                                                                                    -            if token.startswith('"') and token.endswith('"'):
                                                                                                                                    -                accum.append(token)
                                                                                                                                    -                continue
                                                                                                                                    -            token_set = set(token)
                                                                                                                                    -            invalid_for_token = token_set & _invalid_ascii
                                                                                                                                    -            if invalid_for_token:
                                                                                                                                    -                any_invalid = True
                                                                                                                                    -                for c in invalid_for_token:
                                                                                                                                    -                    token = token.replace(c, replace)
                                                                                                                                    -            accum.append(token)
                                                                                                                                    -
                                                                                                                                    -        if any_invalid:
                                                                                                                                    -            return ' '.join(accum)
                                                                                                                                    -        return query
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def match(cls, term):
                                                                                                                                    -        """
                                                                                                                                    -        Generate a `MATCH` expression appropriate for searching this table.
                                                                                                                                    -        """
                                                                                                                                    -        return match(cls._meta.entity, term)
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def rank(cls, *args):
                                                                                                                                    -        return cls.bm25(*args) if args else SQL('rank')
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def bm25(cls, *weights):
                                                                                                                                    -        return fn.bm25(cls._meta.entity, *weights)
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def search(cls, term, weights=None, with_score=False, score_alias='score',
                                                                                                                                    -               explicit_ordering=False):
                                                                                                                                    -        """Full-text search using selected `term`."""
                                                                                                                                    -        return cls.search_bm25(
                                                                                                                                    -            FTS5Model.clean_query(term),
                                                                                                                                    -            weights,
                                                                                                                                    -            with_score,
                                                                                                                                    -            score_alias,
                                                                                                                                    -            explicit_ordering)
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def search_bm25(cls, term, weights=None, with_score=False,
                                                                                                                                    -                    score_alias='score', explicit_ordering=False):
                                                                                                                                    -        """Full-text search using selected `term`."""
                                                                                                                                    -        if not weights:
                                                                                                                                    -            rank = SQL('rank')
                                                                                                                                    -        elif isinstance(weights, dict):
                                                                                                                                    -            weight_args = []
                                                                                                                                    -            for field in cls._meta.sorted_fields:
                                                                                                                                    -                if isinstance(field, SearchField) and not field.unindexed:
                                                                                                                                    -                    weight_args.append(
                                                                                                                                    -                        weights.get(field, weights.get(field.name, 1.0)))
                                                                                                                                    -            rank = fn.bm25(cls._meta.entity, *weight_args)
                                                                                                                                    -        else:
                                                                                                                                    -            rank = fn.bm25(cls._meta.entity, *weights)
                                                                                                                                    -
                                                                                                                                    -        selection = ()
                                                                                                                                    -        order_by = rank
                                                                                                                                    -        if with_score:
                                                                                                                                    -            selection = (cls, rank.alias(score_alias))
                                                                                                                                    -        if with_score and not explicit_ordering:
                                                                                                                                    -            order_by = SQL(score_alias)
                                                                                                                                    -
                                                                                                                                    -        return (cls
                                                                                                                                    -                .select(*selection)
                                                                                                                                    -                .where(cls.match(FTS5Model.clean_query(term)))
                                                                                                                                    -                .order_by(order_by))
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def _fts_cmd_sql(cls, cmd, **extra_params):
                                                                                                                                    -        tbl = cls._meta.entity
                                                                                                                                    -        columns = [tbl]
                                                                                                                                    -        values = [cmd]
                                                                                                                                    -        for key, value in extra_params.items():
                                                                                                                                    -            columns.append(Entity(key))
                                                                                                                                    -            values.append(value)
                                                                                                                                    -
                                                                                                                                    -        return NodeList((
                                                                                                                                    -            SQL('INSERT INTO'),
                                                                                                                                    -            cls._meta.entity,
                                                                                                                                    -            EnclosedNodeList(columns),
                                                                                                                                    -            SQL('VALUES'),
                                                                                                                                    -            EnclosedNodeList(values)))
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def _fts_cmd(cls, cmd, **extra_params):
                                                                                                                                    -        query = cls._fts_cmd_sql(cmd, **extra_params)
                                                                                                                                    -        return cls._meta.database.execute(query)
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def automerge(cls, level):
                                                                                                                                    -        if not (0 <= level <= 16):
                                                                                                                                    -            raise ValueError('level must be between 0 and 16')
                                                                                                                                    -        return cls._fts_cmd('automerge', rank=level)
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def merge(cls, npages):
                                                                                                                                    -        return cls._fts_cmd('merge', rank=npages)
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def set_pgsz(cls, pgsz):
                                                                                                                                    -        return cls._fts_cmd('pgsz', rank=pgsz)
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def set_rank(cls, rank_expression):
                                                                                                                                    -        return cls._fts_cmd('rank', rank=rank_expression)
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def delete_all(cls):
                                                                                                                                    -        return cls._fts_cmd('delete-all')
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def VocabModel(cls, table_type='row', table=None):
                                                                                                                                    -        if table_type not in ('row', 'col', 'instance'):
                                                                                                                                    -            raise ValueError('table_type must be either "row", "col" or '
                                                                                                                                    -                             '"instance".')
                                                                                                                                    -
                                                                                                                                    -        attr = '_vocab_model_%s' % table_type
                                                                                                                                    -
                                                                                                                                    -        if not hasattr(cls, attr):
                                                                                                                                    -            class Meta:
                                                                                                                                    -                database = cls._meta.database
                                                                                                                                    -                table_name = table or cls._meta.table_name + '_v'
                                                                                                                                    -                extension_module = fn.fts5vocab(
                                                                                                                                    -                    cls._meta.entity,
                                                                                                                                    -                    SQL(table_type))
                                                                                                                                    -
                                                                                                                                    -            attrs = {
                                                                                                                                    -                'term': VirtualField(TextField),
                                                                                                                                    -                'doc': IntegerField(),
                                                                                                                                    -                'cnt': IntegerField(),
                                                                                                                                    -                'rowid': RowIDField(),
                                                                                                                                    -                'Meta': Meta,
                                                                                                                                    -            }
                                                                                                                                    -            if table_type == 'col':
                                                                                                                                    -                attrs['col'] = VirtualField(TextField)
                                                                                                                                    -            elif table_type == 'instance':
                                                                                                                                    -                attrs['offset'] = VirtualField(IntegerField)
                                                                                                                                    -
                                                                                                                                    -            class_name = '%sVocab' % cls.__name__
                                                                                                                                    -            setattr(cls, attr, type(class_name, (VirtualModel,), attrs))
                                                                                                                                    -
                                                                                                                                    -        return getattr(cls, attr)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -def ClosureTable(model_class, foreign_key=None, referencing_class=None,
                                                                                                                                    -                 referencing_key=None):
                                                                                                                                    -    """Model factory for the transitive closure extension."""
                                                                                                                                    -    if referencing_class is None:
                                                                                                                                    -        referencing_class = model_class
                                                                                                                                    -
                                                                                                                                    -    if foreign_key is None:
                                                                                                                                    -        for field_obj in model_class._meta.refs:
                                                                                                                                    -            if field_obj.rel_model is model_class:
                                                                                                                                    -                foreign_key = field_obj
                                                                                                                                    -                break
                                                                                                                                    -        else:
                                                                                                                                    -            raise ValueError('Unable to find self-referential foreign key.')
                                                                                                                                    -
                                                                                                                                    -    source_key = model_class._meta.primary_key
                                                                                                                                    -    if referencing_key is None:
                                                                                                                                    -        referencing_key = source_key
                                                                                                                                    -
                                                                                                                                    -    class BaseClosureTable(VirtualModel):
                                                                                                                                    -        depth = VirtualField(IntegerField)
                                                                                                                                    -        id = VirtualField(IntegerField)
                                                                                                                                    -        idcolumn = VirtualField(TextField)
                                                                                                                                    -        parentcolumn = VirtualField(TextField)
                                                                                                                                    -        root = VirtualField(IntegerField)
                                                                                                                                    -        tablename = VirtualField(TextField)
                                                                                                                                    -
                                                                                                                                    -        class Meta:
                                                                                                                                    -            extension_module = 'transitive_closure'
                                                                                                                                    -
                                                                                                                                    -        @classmethod
                                                                                                                                    -        def descendants(cls, node, depth=None, include_node=False):
                                                                                                                                    -            query = (model_class
                                                                                                                                    -                     .select(model_class, cls.depth.alias('depth'))
                                                                                                                                    -                     .join(cls, on=(source_key == cls.id))
                                                                                                                                    -                     .where(cls.root == node)
                                                                                                                                    -                     .objects())
                                                                                                                                    -            if depth is not None:
                                                                                                                                    -                query = query.where(cls.depth == depth)
                                                                                                                                    -            elif not include_node:
                                                                                                                                    -                query = query.where(cls.depth > 0)
                                                                                                                                    -            return query
                                                                                                                                    -
                                                                                                                                    -        @classmethod
                                                                                                                                    -        def ancestors(cls, node, depth=None, include_node=False):
                                                                                                                                    -            query = (model_class
                                                                                                                                    -                     .select(model_class, cls.depth.alias('depth'))
                                                                                                                                    -                     .join(cls, on=(source_key == cls.root))
                                                                                                                                    -                     .where(cls.id == node)
                                                                                                                                    -                     .objects())
                                                                                                                                    -            if depth:
                                                                                                                                    -                query = query.where(cls.depth == depth)
                                                                                                                                    -            elif not include_node:
                                                                                                                                    -                query = query.where(cls.depth > 0)
                                                                                                                                    -            return query
                                                                                                                                    -
                                                                                                                                    -        @classmethod
                                                                                                                                    -        def siblings(cls, node, include_node=False):
                                                                                                                                    -            if referencing_class is model_class:
                                                                                                                                    -                # self-join
                                                                                                                                    -                fk_value = node.__data__.get(foreign_key.name)
                                                                                                                                    -                query = model_class.select().where(foreign_key == fk_value)
                                                                                                                                    -            else:
                                                                                                                                    -                # siblings as given in reference_class
                                                                                                                                    -                siblings = (referencing_class
                                                                                                                                    -                            .select(referencing_key)
                                                                                                                                    -                            .join(cls, on=(foreign_key == cls.root))
                                                                                                                                    -                            .where((cls.id == node) & (cls.depth == 1)))
                                                                                                                                    -
                                                                                                                                    -                # the according models
                                                                                                                                    -                query = (model_class
                                                                                                                                    -                         .select()
                                                                                                                                    -                         .where(source_key << siblings)
                                                                                                                                    -                         .objects())
                                                                                                                                    -
                                                                                                                                    -            if not include_node:
                                                                                                                                    -                query = query.where(source_key != node)
                                                                                                                                    -
                                                                                                                                    -            return query
                                                                                                                                    -
                                                                                                                                    -    class Meta:
                                                                                                                                    -        database = referencing_class._meta.database
                                                                                                                                    -        options = {
                                                                                                                                    -            'tablename': referencing_class._meta.table_name,
                                                                                                                                    -            'idcolumn': referencing_key.column_name,
                                                                                                                                    -            'parentcolumn': foreign_key.column_name}
                                                                                                                                    -        primary_key = False
                                                                                                                                    -
                                                                                                                                    -    name = '%sClosure' % model_class.__name__
                                                                                                                                    -    return type(name, (BaseClosureTable,), {'Meta': Meta})
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class LSMTable(VirtualModel):
                                                                                                                                    -    class Meta:
                                                                                                                                    -        extension_module = 'lsm1'
                                                                                                                                    -        filename = None
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def clean_options(cls, options):
                                                                                                                                    -        filename = cls._meta.filename
                                                                                                                                    -        if not filename:
                                                                                                                                    -            raise ValueError('LSM1 extension requires that you specify a '
                                                                                                                                    -                             'filename for the LSM database.')
                                                                                                                                    -        else:
                                                                                                                                    -            if len(filename) >= 2 and filename[0] != '"':
                                                                                                                                    -                filename = '"%s"' % filename
                                                                                                                                    -        if not cls._meta.primary_key:
                                                                                                                                    -            raise ValueError('LSM1 models must specify a primary-key field.')
                                                                                                                                    -
                                                                                                                                    -        key = cls._meta.primary_key
                                                                                                                                    -        if isinstance(key, AutoField):
                                                                                                                                    -            raise ValueError('LSM1 models must explicitly declare a primary '
                                                                                                                                    -                             'key field.')
                                                                                                                                    -        if not isinstance(key, (TextField, BlobField, IntegerField)):
                                                                                                                                    -            raise ValueError('LSM1 key must be a TextField, BlobField, or '
                                                                                                                                    -                             'IntegerField.')
                                                                                                                                    -        key._hidden = True
                                                                                                                                    -        if isinstance(key, IntegerField):
                                                                                                                                    -            data_type = 'UINT'
                                                                                                                                    -        elif isinstance(key, BlobField):
                                                                                                                                    -            data_type = 'BLOB'
                                                                                                                                    -        else:
                                                                                                                                    -            data_type = 'TEXT'
                                                                                                                                    -        cls._meta.prefix_arguments = [filename, '"%s"' % key.name, data_type]
                                                                                                                                    -
                                                                                                                                    -        # Does the key map to a scalar value, or a tuple of values?
                                                                                                                                    -        if len(cls._meta.sorted_fields) == 2:
                                                                                                                                    -            cls._meta._value_field = cls._meta.sorted_fields[1]
                                                                                                                                    -        else:
                                                                                                                                    -            cls._meta._value_field = None
                                                                                                                                    -
                                                                                                                                    -        return options
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def load_extension(cls, path='lsm.so'):
                                                                                                                                    -        cls._meta.database.load_extension(path)
                                                                                                                                    -
                                                                                                                                    -    @staticmethod
                                                                                                                                    -    def slice_to_expr(key, idx):
                                                                                                                                    -        if idx.start is not None and idx.stop is not None:
                                                                                                                                    -            return key.between(idx.start, idx.stop)
                                                                                                                                    -        elif idx.start is not None:
                                                                                                                                    -            return key >= idx.start
                                                                                                                                    -        elif idx.stop is not None:
                                                                                                                                    -            return key <= idx.stop
                                                                                                                                    -
                                                                                                                                    -    @staticmethod
                                                                                                                                    -    def _apply_lookup_to_query(query, key, lookup):
                                                                                                                                    -        if isinstance(lookup, slice):
                                                                                                                                    -            expr = LSMTable.slice_to_expr(key, lookup)
                                                                                                                                    -            if expr is not None:
                                                                                                                                    -                query = query.where(expr)
                                                                                                                                    -            return query, False
                                                                                                                                    -        elif isinstance(lookup, Expression):
                                                                                                                                    -            return query.where(lookup), False
                                                                                                                                    -        else:
                                                                                                                                    -            return query.where(key == lookup), True
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def get_by_id(cls, pk):
                                                                                                                                    -        query, is_single = cls._apply_lookup_to_query(
                                                                                                                                    -            cls.select().namedtuples(),
                                                                                                                                    -            cls._meta.primary_key,
                                                                                                                                    -            pk)
                                                                                                                                    -
                                                                                                                                    -        if is_single:
                                                                                                                                    -            try:
                                                                                                                                    -                row = query.get()
                                                                                                                                    -            except cls.DoesNotExist:
                                                                                                                                    -                raise KeyError(pk)
                                                                                                                                    -            return row[1] if cls._meta._value_field is not None else row
                                                                                                                                    -        else:
                                                                                                                                    -            return query
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def set_by_id(cls, key, value):
                                                                                                                                    -        if cls._meta._value_field is not None:
                                                                                                                                    -            data = {cls._meta._value_field: value}
                                                                                                                                    -        elif isinstance(value, tuple):
                                                                                                                                    -            data = {}
                                                                                                                                    -            for field, fval in zip(cls._meta.sorted_fields[1:], value):
                                                                                                                                    -                data[field] = fval
                                                                                                                                    -        elif isinstance(value, dict):
                                                                                                                                    -            data = value
                                                                                                                                    -        elif isinstance(value, cls):
                                                                                                                                    -            data = value.__dict__
                                                                                                                                    -        data[cls._meta.primary_key] = key
                                                                                                                                    -        cls.replace(data).execute()
                                                                                                                                    -
                                                                                                                                    -    @classmethod
                                                                                                                                    -    def delete_by_id(cls, pk):
                                                                                                                                    -        query, is_single = cls._apply_lookup_to_query(
                                                                                                                                    -            cls.delete(),
                                                                                                                                    -            cls._meta.primary_key,
                                                                                                                                    -            pk)
                                                                                                                                    -        return query.execute()
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -OP.MATCH = 'MATCH'
                                                                                                                                    -
                                                                                                                                    -def _sqlite_regexp(regex, value):
                                                                                                                                    -    return re.search(regex, value) is not None
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -class SqliteExtDatabase(SqliteDatabase):
                                                                                                                                    -    def __init__(self, database, c_extensions=None, rank_functions=True,
                                                                                                                                    -                 hash_functions=False, regexp_function=False,
                                                                                                                                    -                 bloomfilter=False, json_contains=False, *args, **kwargs):
                                                                                                                                    -        super(SqliteExtDatabase, self).__init__(database, *args, **kwargs)
                                                                                                                                    -        self._row_factory = None
                                                                                                                                    -
                                                                                                                                    -        if c_extensions and not CYTHON_SQLITE_EXTENSIONS:
                                                                                                                                    -            raise ImproperlyConfigured('SqliteExtDatabase initialized with '
                                                                                                                                    -                                       'C extensions, but shared library was '
                                                                                                                                    -                                       'not found!')
                                                                                                                                    -        prefer_c = CYTHON_SQLITE_EXTENSIONS and (c_extensions is not False)
                                                                                                                                    -        if rank_functions:
                                                                                                                                    -            if prefer_c:
                                                                                                                                    -                register_rank_functions(self)
                                                                                                                                    -            else:
                                                                                                                                    -                self.register_function(bm25, 'fts_bm25')
                                                                                                                                    -                self.register_function(rank, 'fts_rank')
                                                                                                                                    -                self.register_function(bm25, 'fts_bm25f')  # Fall back to bm25.
                                                                                                                                    -                self.register_function(bm25, 'fts_lucene')
                                                                                                                                    -        if hash_functions:
                                                                                                                                    -            if not prefer_c:
                                                                                                                                    -                raise ValueError('C extension required to register hash '
                                                                                                                                    -                                 'functions.')
                                                                                                                                    -            register_hash_functions(self)
                                                                                                                                    -        if regexp_function:
                                                                                                                                    -            self.register_function(_sqlite_regexp, 'regexp', 2)
                                                                                                                                    -        if bloomfilter:
                                                                                                                                    -            if not prefer_c:
                                                                                                                                    -                raise ValueError('C extension required to use bloomfilter.')
                                                                                                                                    -            register_bloomfilter(self)
                                                                                                                                    -        if json_contains:
                                                                                                                                    -            self.register_function(_json_contains, 'json_contains')
                                                                                                                                    -
                                                                                                                                    -        self._c_extensions = prefer_c
                                                                                                                                    -
                                                                                                                                    -    def _add_conn_hooks(self, conn):
                                                                                                                                    -        super(SqliteExtDatabase, self)._add_conn_hooks(conn)
                                                                                                                                    -        if self._row_factory:
                                                                                                                                    -            conn.row_factory = self._row_factory
                                                                                                                                    -
                                                                                                                                    -    def row_factory(self, fn):
                                                                                                                                    -        self._row_factory = fn
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -if CYTHON_SQLITE_EXTENSIONS:
                                                                                                                                    -    SQLITE_STATUS_MEMORY_USED = 0
                                                                                                                                    -    SQLITE_STATUS_PAGECACHE_USED = 1
                                                                                                                                    -    SQLITE_STATUS_PAGECACHE_OVERFLOW = 2
                                                                                                                                    -    SQLITE_STATUS_SCRATCH_USED = 3
                                                                                                                                    -    SQLITE_STATUS_SCRATCH_OVERFLOW = 4
                                                                                                                                    -    SQLITE_STATUS_MALLOC_SIZE = 5
                                                                                                                                    -    SQLITE_STATUS_PARSER_STACK = 6
                                                                                                                                    -    SQLITE_STATUS_PAGECACHE_SIZE = 7
                                                                                                                                    -    SQLITE_STATUS_SCRATCH_SIZE = 8
                                                                                                                                    -    SQLITE_STATUS_MALLOC_COUNT = 9
                                                                                                                                    -    SQLITE_DBSTATUS_LOOKASIDE_USED = 0
                                                                                                                                    -    SQLITE_DBSTATUS_CACHE_USED = 1
                                                                                                                                    -    SQLITE_DBSTATUS_SCHEMA_USED = 2
                                                                                                                                    -    SQLITE_DBSTATUS_STMT_USED = 3
                                                                                                                                    -    SQLITE_DBSTATUS_LOOKASIDE_HIT = 4
                                                                                                                                    -    SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE = 5
                                                                                                                                    -    SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL = 6
                                                                                                                                    -    SQLITE_DBSTATUS_CACHE_HIT = 7
                                                                                                                                    -    SQLITE_DBSTATUS_CACHE_MISS = 8
                                                                                                                                    -    SQLITE_DBSTATUS_CACHE_WRITE = 9
                                                                                                                                    -    SQLITE_DBSTATUS_DEFERRED_FKS = 10
                                                                                                                                    -    #SQLITE_DBSTATUS_CACHE_USED_SHARED = 11
                                                                                                                                    -
                                                                                                                                    -    def __status__(flag, return_highwater=False):
                                                                                                                                    -        """
                                                                                                                                    -        Expose a sqlite3_status() call for a particular flag as a property of
                                                                                                                                    -        the Database object.
                                                                                                                                    -        """
                                                                                                                                    -        def getter(self):
                                                                                                                                    -            result = sqlite_get_status(flag)
                                                                                                                                    -            return result[1] if return_highwater else result
                                                                                                                                    -        return property(getter)
                                                                                                                                    -
                                                                                                                                    -    def __dbstatus__(flag, return_highwater=False, return_current=False):
                                                                                                                                    -        """
                                                                                                                                    -        Expose a sqlite3_dbstatus() call for a particular flag as a property of
                                                                                                                                    -        the Database instance. Unlike sqlite3_status(), the dbstatus properties
                                                                                                                                    -        pertain to the current connection.
                                                                                                                                    -        """
                                                                                                                                    -        def getter(self):
                                                                                                                                    -            if self._state.conn is None:
                                                                                                                                    -                raise ImproperlyConfigured('database connection not opened.')
                                                                                                                                    -            result = sqlite_get_db_status(self._state.conn, flag)
                                                                                                                                    -            if return_current:
                                                                                                                                    -                return result[0]
                                                                                                                                    -            return result[1] if return_highwater else result
                                                                                                                                    -        return property(getter)
                                                                                                                                    -
                                                                                                                                    -    class CSqliteExtDatabase(SqliteExtDatabase):
                                                                                                                                    -        def __init__(self, *args, **kwargs):
                                                                                                                                    -            self._conn_helper = None
                                                                                                                                    -            self._commit_hook = self._rollback_hook = self._update_hook = None
                                                                                                                                    -            self._replace_busy_handler = False
                                                                                                                                    -            super(CSqliteExtDatabase, self).__init__(*args, **kwargs)
                                                                                                                                    -
                                                                                                                                    -        def init(self, database, replace_busy_handler=False, **kwargs):
                                                                                                                                    -            super(CSqliteExtDatabase, self).init(database, **kwargs)
                                                                                                                                    -            self._replace_busy_handler = replace_busy_handler
                                                                                                                                    -
                                                                                                                                    -        def _close(self, conn):
                                                                                                                                    -            if self._commit_hook:
                                                                                                                                    -                self._conn_helper.set_commit_hook(None)
                                                                                                                                    -            if self._rollback_hook:
                                                                                                                                    -                self._conn_helper.set_rollback_hook(None)
                                                                                                                                    -            if self._update_hook:
                                                                                                                                    -                self._conn_helper.set_update_hook(None)
                                                                                                                                    -            return super(CSqliteExtDatabase, self)._close(conn)
                                                                                                                                    -
                                                                                                                                    -        def _add_conn_hooks(self, conn):
                                                                                                                                    -            super(CSqliteExtDatabase, self)._add_conn_hooks(conn)
                                                                                                                                    -            self._conn_helper = ConnectionHelper(conn)
                                                                                                                                    -            if self._commit_hook is not None:
                                                                                                                                    -                self._conn_helper.set_commit_hook(self._commit_hook)
                                                                                                                                    -            if self._rollback_hook is not None:
                                                                                                                                    -                self._conn_helper.set_rollback_hook(self._rollback_hook)
                                                                                                                                    -            if self._update_hook is not None:
                                                                                                                                    -                self._conn_helper.set_update_hook(self._update_hook)
                                                                                                                                    -            if self._replace_busy_handler:
                                                                                                                                    -                timeout = self._timeout or 5
                                                                                                                                    -                self._conn_helper.set_busy_handler(timeout * 1000)
                                                                                                                                    -
                                                                                                                                    -        def on_commit(self, fn):
                                                                                                                                    -            self._commit_hook = fn
                                                                                                                                    -            if not self.is_closed():
                                                                                                                                    -                self._conn_helper.set_commit_hook(fn)
                                                                                                                                    -            return fn
                                                                                                                                    -
                                                                                                                                    -        def on_rollback(self, fn):
                                                                                                                                    -            self._rollback_hook = fn
                                                                                                                                    -            if not self.is_closed():
                                                                                                                                    -                self._conn_helper.set_rollback_hook(fn)
                                                                                                                                    -            return fn
                                                                                                                                    -
                                                                                                                                    -        def on_update(self, fn):
                                                                                                                                    -            self._update_hook = fn
                                                                                                                                    -            if not self.is_closed():
                                                                                                                                    -                self._conn_helper.set_update_hook(fn)
                                                                                                                                    -            return fn
                                                                                                                                    -
                                                                                                                                    -        def changes(self):
                                                                                                                                    -            return self._conn_helper.changes()
                                                                                                                                    -
                                                                                                                                    -        @property
                                                                                                                                    -        def last_insert_rowid(self):
                                                                                                                                    -            return self._conn_helper.last_insert_rowid()
                                                                                                                                    -
                                                                                                                                    -        @property
                                                                                                                                    -        def autocommit(self):
                                                                                                                                    -            return self._conn_helper.autocommit()
                                                                                                                                    -
                                                                                                                                    -        def backup(self, destination, pages=None, name=None, progress=None):
                                                                                                                                    -            return backup(self.connection(), destination.connection(),
                                                                                                                                    -                          pages=pages, name=name, progress=progress)
                                                                                                                                    -
                                                                                                                                    -        def backup_to_file(self, filename, pages=None, name=None,
                                                                                                                                    -                           progress=None):
                                                                                                                                    -            return backup_to_file(self.connection(), filename, pages=pages,
                                                                                                                                    -                                  name=name, progress=progress)
                                                                                                                                    -
                                                                                                                                    -        def blob_open(self, table, column, rowid, read_only=False):
                                                                                                                                    -            return Blob(self, table, column, rowid, read_only)
                                                                                                                                    -
                                                                                                                                    -        # Status properties.
                                                                                                                                    -        memory_used = __status__(SQLITE_STATUS_MEMORY_USED)
                                                                                                                                    -        malloc_size = __status__(SQLITE_STATUS_MALLOC_SIZE, True)
                                                                                                                                    -        malloc_count = __status__(SQLITE_STATUS_MALLOC_COUNT)
                                                                                                                                    -        pagecache_used = __status__(SQLITE_STATUS_PAGECACHE_USED)
                                                                                                                                    -        pagecache_overflow = __status__(SQLITE_STATUS_PAGECACHE_OVERFLOW)
                                                                                                                                    -        pagecache_size = __status__(SQLITE_STATUS_PAGECACHE_SIZE, True)
                                                                                                                                    -        scratch_used = __status__(SQLITE_STATUS_SCRATCH_USED)
                                                                                                                                    -        scratch_overflow = __status__(SQLITE_STATUS_SCRATCH_OVERFLOW)
                                                                                                                                    -        scratch_size = __status__(SQLITE_STATUS_SCRATCH_SIZE, True)
                                                                                                                                    -
                                                                                                                                    -        # Connection status properties.
                                                                                                                                    -        lookaside_used = __dbstatus__(SQLITE_DBSTATUS_LOOKASIDE_USED)
                                                                                                                                    -        lookaside_hit = __dbstatus__(SQLITE_DBSTATUS_LOOKASIDE_HIT, True)
                                                                                                                                    -        lookaside_miss = __dbstatus__(SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE,
                                                                                                                                    -                                      True)
                                                                                                                                    -        lookaside_miss_full = __dbstatus__(SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL,
                                                                                                                                    -                                           True)
                                                                                                                                    -        cache_used = __dbstatus__(SQLITE_DBSTATUS_CACHE_USED, False, True)
                                                                                                                                    -        #cache_used_shared = __dbstatus__(SQLITE_DBSTATUS_CACHE_USED_SHARED,
                                                                                                                                    -        #                                 False, True)
                                                                                                                                    -        schema_used = __dbstatus__(SQLITE_DBSTATUS_SCHEMA_USED, False, True)
                                                                                                                                    -        statement_used = __dbstatus__(SQLITE_DBSTATUS_STMT_USED, False, True)
                                                                                                                                    -        cache_hit = __dbstatus__(SQLITE_DBSTATUS_CACHE_HIT, False, True)
                                                                                                                                    -        cache_miss = __dbstatus__(SQLITE_DBSTATUS_CACHE_MISS, False, True)
                                                                                                                                    -        cache_write = __dbstatus__(SQLITE_DBSTATUS_CACHE_WRITE, False, True)
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -def match(lhs, rhs):
                                                                                                                                    -    return Expression(lhs, OP.MATCH, rhs)
                                                                                                                                    -
                                                                                                                                    -def _parse_match_info(buf):
                                                                                                                                    -    # See http://sqlite.org/fts3.html#matchinfo
                                                                                                                                    -    bufsize = len(buf)  # Length in bytes.
                                                                                                                                    -    return [struct.unpack('@I', buf[i:i+4])[0] for i in range(0, bufsize, 4)]
                                                                                                                                    -
                                                                                                                                    -def get_weights(ncol, raw_weights):
                                                                                                                                    -    if not raw_weights:
                                                                                                                                    -        return [1] * ncol
                                                                                                                                    -    else:
                                                                                                                                    -        weights = [0] * ncol
                                                                                                                                    -        for i, weight in enumerate(raw_weights):
                                                                                                                                    -            weights[i] = weight
                                                                                                                                    -    return weights
                                                                                                                                    -
                                                                                                                                    -# Ranking implementation, which parse matchinfo.
                                                                                                                                    -def rank(raw_match_info, *raw_weights):
                                                                                                                                    -    # Handle match_info called w/default args 'pcx' - based on the example rank
                                                                                                                                    -    # function http://sqlite.org/fts3.html#appendix_a
                                                                                                                                    -    match_info = _parse_match_info(raw_match_info)
                                                                                                                                    -    score = 0.0
                                                                                                                                    -
                                                                                                                                    -    p, c = match_info[:2]
                                                                                                                                    -    weights = get_weights(c, raw_weights)
                                                                                                                                    -
                                                                                                                                    -    # matchinfo X value corresponds to, for each phrase in the search query, a
                                                                                                                                    -    # list of 3 values for each column in the search table.
                                                                                                                                    -    # So if we have a two-phrase search query and three columns of data, the
                                                                                                                                    -    # following would be the layout:
                                                                                                                                    -    # p0 : c0=[0, 1, 2],   c1=[3, 4, 5],    c2=[6, 7, 8]
                                                                                                                                    -    # p1 : c0=[9, 10, 11], c1=[12, 13, 14], c2=[15, 16, 17]
                                                                                                                                    -    for phrase_num in range(p):
                                                                                                                                    -        phrase_info_idx = 2 + (phrase_num * c * 3)
                                                                                                                                    -        for col_num in range(c):
                                                                                                                                    -            weight = weights[col_num]
                                                                                                                                    -            if not weight:
                                                                                                                                    -                continue
                                                                                                                                    -
                                                                                                                                    -            col_idx = phrase_info_idx + (col_num * 3)
                                                                                                                                    -
                                                                                                                                    -            # The idea is that we count the number of times the phrase appears
                                                                                                                                    -            # in this column of the current row, compared to how many times it
                                                                                                                                    -            # appears in this column across all rows. The ratio of these values
                                                                                                                                    -            # provides a rough way to score based on "high value" terms.
                                                                                                                                    -            row_hits = match_info[col_idx]
                                                                                                                                    -            all_rows_hits = match_info[col_idx + 1]
                                                                                                                                    -            if row_hits > 0:
                                                                                                                                    -                score += weight * (float(row_hits) / all_rows_hits)
                                                                                                                                    -
                                                                                                                                    -    return -score
                                                                                                                                    -
                                                                                                                                    -# Okapi BM25 ranking implementation (FTS4 only).
                                                                                                                                    -def bm25(raw_match_info, *args):
                                                                                                                                    -    """
                                                                                                                                    -    Usage:
                                                                                                                                    -
                                                                                                                                    -        # Format string *must* be pcnalx
                                                                                                                                    -        # Second parameter to bm25 specifies the index of the column, on
                                                                                                                                    -        # the table being queries.
                                                                                                                                    -        bm25(matchinfo(document_tbl, 'pcnalx'), 1) AS rank
                                                                                                                                    -    """
                                                                                                                                    -    match_info = _parse_match_info(raw_match_info)
                                                                                                                                    -    K = 1.2
                                                                                                                                    -    B = 0.75
                                                                                                                                    -    score = 0.0
                                                                                                                                    -
                                                                                                                                    -    P_O, C_O, N_O, A_O = range(4)  # Offsets into the matchinfo buffer.
                                                                                                                                    -    term_count = match_info[P_O]  # n
                                                                                                                                    -    col_count = match_info[C_O]
                                                                                                                                    -    total_docs = match_info[N_O]  # N
                                                                                                                                    -    L_O = A_O + col_count
                                                                                                                                    -    X_O = L_O + col_count
                                                                                                                                    -
                                                                                                                                    -    # Worked example of pcnalx for two columns and two phrases, 100 docs total.
                                                                                                                                    -    # {
                                                                                                                                    -    #   p  = 2
                                                                                                                                    -    #   c  = 2
                                                                                                                                    -    #   n  = 100
                                                                                                                                    -    #   a0 = 4   -- avg number of tokens for col0, e.g. title
                                                                                                                                    -    #   a1 = 40  -- avg number of tokens for col1, e.g. body
                                                                                                                                    -    #   l0 = 5   -- curr doc has 5 tokens in col0
                                                                                                                                    -    #   l1 = 30  -- curr doc has 30 tokens in col1
                                                                                                                                    -    #
                                                                                                                                    -    #   x000     -- hits this row for phrase0, col0
                                                                                                                                    -    #   x001     -- hits all rows for phrase0, col0
                                                                                                                                    -    #   x002     -- rows with phrase0 in col0 at least once
                                                                                                                                    -    #
                                                                                                                                    -    #   x010     -- hits this row for phrase0, col1
                                                                                                                                    -    #   x011     -- hits all rows for phrase0, col1
                                                                                                                                    -    #   x012     -- rows with phrase0 in col1 at least once
                                                                                                                                    -    #
                                                                                                                                    -    #   x100     -- hits this row for phrase1, col0
                                                                                                                                    -    #   x101     -- hits all rows for phrase1, col0
                                                                                                                                    -    #   x102     -- rows with phrase1 in col0 at least once
                                                                                                                                    -    #
                                                                                                                                    -    #   x110     -- hits this row for phrase1, col1
                                                                                                                                    -    #   x111     -- hits all rows for phrase1, col1
                                                                                                                                    -    #   x112     -- rows with phrase1 in col1 at least once
                                                                                                                                    -    # }
                                                                                                                                    -
                                                                                                                                    -    weights = get_weights(col_count, args)
                                                                                                                                    -
                                                                                                                                    -    for i in range(term_count):
                                                                                                                                    -        for j in range(col_count):
                                                                                                                                    -            weight = weights[j]
                                                                                                                                    -            if weight == 0:
                                                                                                                                    -                continue
                                                                                                                                    -
                                                                                                                                    -            x = X_O + (3 * (j + i * col_count))
                                                                                                                                    -            term_frequency = float(match_info[x])  # f(qi, D)
                                                                                                                                    -            docs_with_term = float(match_info[x + 2])  # n(qi)
                                                                                                                                    -
                                                                                                                                    -            # log( (N - n(qi) + 0.5) / (n(qi) + 0.5) )
                                                                                                                                    -            idf = math.log(
                                                                                                                                    -                    (total_docs - docs_with_term + 0.5) /
                                                                                                                                    -                    (docs_with_term + 0.5))
                                                                                                                                    -            if idf <= 0.0:
                                                                                                                                    -                idf = 1e-6
                                                                                                                                    -
                                                                                                                                    -            doc_length = float(match_info[L_O + j])  # |D|
                                                                                                                                    -            avg_length = float(match_info[A_O + j]) or 1.  # avgdl
                                                                                                                                    -            ratio = doc_length / avg_length
                                                                                                                                    -
                                                                                                                                    -            num = term_frequency * (K + 1.0)
                                                                                                                                    -            b_part = 1.0 - B + (B * ratio)
                                                                                                                                    -            denom = term_frequency + (K * b_part)
                                                                                                                                    -
                                                                                                                                    -            pc_score = idf * (num / denom)
                                                                                                                                    -            score += (pc_score * weight)
                                                                                                                                    -
                                                                                                                                    -    return -score
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    -def _json_contains(src_json, obj_json):
                                                                                                                                    -    stack = []
                                                                                                                                    -    try:
                                                                                                                                    -        stack.append((json.loads(obj_json), json.loads(src_json)))
                                                                                                                                    -    except:
                                                                                                                                    -        # Invalid JSON!
                                                                                                                                    -        return False
                                                                                                                                    -
                                                                                                                                    -    while stack:
                                                                                                                                    -        obj, src = stack.pop()
                                                                                                                                    -        if isinstance(src, dict):
                                                                                                                                    -            if isinstance(obj, dict):
                                                                                                                                    -                for key in obj:
                                                                                                                                    -                    if key not in src:
                                                                                                                                    -                        return False
                                                                                                                                    -                    stack.append((obj[key], src[key]))
                                                                                                                                    -            elif isinstance(obj, list):
                                                                                                                                    -                for item in obj:
                                                                                                                                    -                    if item not in src:
                                                                                                                                    -                        return False
                                                                                                                                    -            elif obj not in src:
                                                                                                                                    -                return False
                                                                                                                                    -        elif isinstance(src, list):
                                                                                                                                    -            if isinstance(obj, dict):
                                                                                                                                    -                return False
                                                                                                                                    -            elif isinstance(obj, list):
                                                                                                                                    -                try:
                                                                                                                                    -                    for i in range(len(obj)):
                                                                                                                                    -                        stack.append((obj[i], src[i]))
                                                                                                                                    -                except IndexError:
                                                                                                                                    -                    return False
                                                                                                                                    -            elif obj not in src:
                                                                                                                                    -                return False
                                                                                                                                    -        elif obj != src:
                                                                                                                                    -            return False
                                                                                                                                    -    return True
                                                                                                                                    -
                                                                                                                                    - -
                                                                                                                                    - -
                                                                                                                                    -
                                                                                                                                    - -
                                                                                                                                    - -
                                                                                                                                    -

                                                                                                                                    - © Copyright 2021 - present / Neuralmagic, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"). - -

                                                                                                                                    -
                                                                                                                                    - - - - Built with Sphinx using a - - theme - - provided by Read the Docs. - -
                                                                                                                                    -
                                                                                                                                    -
                                                                                                                                    - -
                                                                                                                                    - -
                                                                                                                                    - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/sparsify/_static/doctools.js b/sparsify/_static/doctools.js index 144884ea651..61ac9d266f9 100644 --- a/sparsify/_static/doctools.js +++ b/sparsify/_static/doctools.js @@ -29,9 +29,14 @@ if (!window.console || !console.firebug) { /** * small helper function to urldecode strings + * + * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent#Decoding_query_parameters_from_a_URL */ jQuery.urldecode = function(x) { - return decodeURIComponent(x).replace(/\+/g, ' '); + if (!x) { + return x + } + return decodeURIComponent(x.replace(/\+/g, ' ')); }; /** diff --git a/sparsify/_static/language_data.js b/sparsify/_static/language_data.js index 0e7dc7e9ef0..863704b310d 100644 --- a/sparsify/_static/language_data.js +++ b/sparsify/_static/language_data.js @@ -13,7 +13,8 @@ var stopwords = ["a","and","are","as","at","be","but","by","for","if","in","into","is","it","near","no","not","of","on","or","such","that","the","their","then","there","these","they","this","to","was","will","with"]; -/* Non-minified version JS is _stemmer.js if file is provided */ +/* Non-minified version is copied as a separate JS file, is available */ + /** * Porter Stemmer */ @@ -199,7 +200,6 @@ var Stemmer = function() { - var splitChars = (function() { var result = {}; var singles = [96, 180, 187, 191, 215, 247, 749, 885, 903, 907, 909, 930, 1014, 1648, diff --git a/sparsify/_static/pygments.css b/sparsify/_static/pygments.css index de7af262ffb..691aeb82d00 100644 --- a/sparsify/_static/pygments.css +++ b/sparsify/_static/pygments.css @@ -1,7 +1,7 @@ pre { line-height: 125%; } -td.linenos pre { color: #000000; background-color: #f0f0f0; padding-left: 5px; padding-right: 5px; } -span.linenos { color: #000000; background-color: #f0f0f0; padding-left: 5px; padding-right: 5px; } -td.linenos pre.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } +td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } +span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } +td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } .highlight .hll { background-color: #ffffcc } .highlight { background: #eeffcc; } diff --git a/sparsify/_static/searchtools.js b/sparsify/_static/searchtools.js index 6fc9e7f3338..1a90152eb0e 100644 --- a/sparsify/_static/searchtools.js +++ b/sparsify/_static/searchtools.js @@ -248,7 +248,7 @@ var Search = { // results left, load the summary and display it if (results.length) { var item = results.pop(); - var listItem = $('
                                                                                                                                  • '); + var listItem = $('
                                                                                                                                  • '); var requestUrl = ""; var linkUrl = ""; if (DOCUMENTATION_OPTIONS.BUILDER === 'dirhtml') { @@ -273,9 +273,9 @@ var Search = { if (item[3]) { listItem.append($(' (' + item[3] + ')')); Search.output.append(listItem); - listItem.slideDown(5, function() { + setTimeout(function() { displayNextItem(); - }); + }, 5); } else if (DOCUMENTATION_OPTIONS.HAS_SOURCE) { $.ajax({url: requestUrl, dataType: "text", @@ -285,16 +285,16 @@ var Search = { listItem.append(Search.makeSearchSummary(data, searchterms, hlterms)); } Search.output.append(listItem); - listItem.slideDown(5, function() { + setTimeout(function() { displayNextItem(); - }); + }, 5); }}); } else { // no source available, just display title Search.output.append(listItem); - listItem.slideDown(5, function() { + setTimeout(function() { displayNextItem(); - }); + }, 5); } } // search finished, update title and status message @@ -379,6 +379,13 @@ var Search = { return results; }, + /** + * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions + */ + escapeRegExp : function(string) { + return string.replace(/[.*+\-?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string + }, + /** * search for full-text terms in the index */ @@ -402,13 +409,14 @@ var Search = { ]; // add support for partial matches if (word.length > 2) { + var word_regex = this.escapeRegExp(word); for (var w in terms) { - if (w.match(word) && !terms[word]) { + if (w.match(word_regex) && !terms[word]) { _o.push({files: terms[w], score: Scorer.partialTerm}) } } for (var w in titleterms) { - if (w.match(word) && !titleterms[word]) { + if (w.match(word_regex) && !titleterms[word]) { _o.push({files: titleterms[w], score: Scorer.partialTitle}) } } diff --git a/sparsify/_static/underscore-1.12.0.js b/sparsify/_static/underscore-1.12.0.js new file mode 100644 index 00000000000..3af6352e613 --- /dev/null +++ b/sparsify/_static/underscore-1.12.0.js @@ -0,0 +1,2027 @@ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : + typeof define === 'function' && define.amd ? define('underscore', factory) : + (global = global || self, (function () { + var current = global._; + var exports = global._ = factory(); + exports.noConflict = function () { global._ = current; return exports; }; + }())); +}(this, (function () { + // Underscore.js 1.12.0 + // https://underscorejs.org + // (c) 2009-2020 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors + // Underscore may be freely distributed under the MIT license. + + // Current version. + var VERSION = '1.12.0'; + + // Establish the root object, `window` (`self`) in the browser, `global` + // on the server, or `this` in some virtual machines. We use `self` + // instead of `window` for `WebWorker` support. + var root = typeof self == 'object' && self.self === self && self || + typeof global == 'object' && global.global === global && global || + Function('return this')() || + {}; + + // Save bytes in the minified (but not gzipped) version: + var ArrayProto = Array.prototype, ObjProto = Object.prototype; + var SymbolProto = typeof Symbol !== 'undefined' ? Symbol.prototype : null; + + // Create quick reference variables for speed access to core prototypes. + var push = ArrayProto.push, + slice = ArrayProto.slice, + toString = ObjProto.toString, + hasOwnProperty = ObjProto.hasOwnProperty; + + // Modern feature detection. + var supportsArrayBuffer = typeof ArrayBuffer !== 'undefined', + supportsDataView = typeof DataView !== 'undefined'; + + // All **ECMAScript 5+** native function implementations that we hope to use + // are declared here. + var nativeIsArray = Array.isArray, + nativeKeys = Object.keys, + nativeCreate = Object.create, + nativeIsView = supportsArrayBuffer && ArrayBuffer.isView; + + // Create references to these builtin functions because we override them. + var _isNaN = isNaN, + _isFinite = isFinite; + + // Keys in IE < 9 that won't be iterated by `for key in ...` and thus missed. + var hasEnumBug = !{toString: null}.propertyIsEnumerable('toString'); + var nonEnumerableProps = ['valueOf', 'isPrototypeOf', 'toString', + 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString']; + + // The largest integer that can be represented exactly. + var MAX_ARRAY_INDEX = Math.pow(2, 53) - 1; + + // Some functions take a variable number of arguments, or a few expected + // arguments at the beginning and then a variable number of values to operate + // on. This helper accumulates all remaining arguments past the function’s + // argument length (or an explicit `startIndex`), into an array that becomes + // the last argument. Similar to ES6’s "rest parameter". + function restArguments(func, startIndex) { + startIndex = startIndex == null ? func.length - 1 : +startIndex; + return function() { + var length = Math.max(arguments.length - startIndex, 0), + rest = Array(length), + index = 0; + for (; index < length; index++) { + rest[index] = arguments[index + startIndex]; + } + switch (startIndex) { + case 0: return func.call(this, rest); + case 1: return func.call(this, arguments[0], rest); + case 2: return func.call(this, arguments[0], arguments[1], rest); + } + var args = Array(startIndex + 1); + for (index = 0; index < startIndex; index++) { + args[index] = arguments[index]; + } + args[startIndex] = rest; + return func.apply(this, args); + }; + } + + // Is a given variable an object? + function isObject(obj) { + var type = typeof obj; + return type === 'function' || type === 'object' && !!obj; + } + + // Is a given value equal to null? + function isNull(obj) { + return obj === null; + } + + // Is a given variable undefined? + function isUndefined(obj) { + return obj === void 0; + } + + // Is a given value a boolean? + function isBoolean(obj) { + return obj === true || obj === false || toString.call(obj) === '[object Boolean]'; + } + + // Is a given value a DOM element? + function isElement(obj) { + return !!(obj && obj.nodeType === 1); + } + + // Internal function for creating a `toString`-based type tester. + function tagTester(name) { + var tag = '[object ' + name + ']'; + return function(obj) { + return toString.call(obj) === tag; + }; + } + + var isString = tagTester('String'); + + var isNumber = tagTester('Number'); + + var isDate = tagTester('Date'); + + var isRegExp = tagTester('RegExp'); + + var isError = tagTester('Error'); + + var isSymbol = tagTester('Symbol'); + + var isArrayBuffer = tagTester('ArrayBuffer'); + + var isFunction = tagTester('Function'); + + // Optimize `isFunction` if appropriate. Work around some `typeof` bugs in old + // v8, IE 11 (#1621), Safari 8 (#1929), and PhantomJS (#2236). + var nodelist = root.document && root.document.childNodes; + if (typeof /./ != 'function' && typeof Int8Array != 'object' && typeof nodelist != 'function') { + isFunction = function(obj) { + return typeof obj == 'function' || false; + }; + } + + var isFunction$1 = isFunction; + + var hasObjectTag = tagTester('Object'); + + // In IE 10 - Edge 13, `DataView` has string tag `'[object Object]'`. + // In IE 11, the most common among them, this problem also applies to + // `Map`, `WeakMap` and `Set`. + var hasStringTagBug = ( + supportsDataView && hasObjectTag(new DataView(new ArrayBuffer(8))) + ), + isIE11 = (typeof Map !== 'undefined' && hasObjectTag(new Map)); + + var isDataView = tagTester('DataView'); + + // In IE 10 - Edge 13, we need a different heuristic + // to determine whether an object is a `DataView`. + function ie10IsDataView(obj) { + return obj != null && isFunction$1(obj.getInt8) && isArrayBuffer(obj.buffer); + } + + var isDataView$1 = (hasStringTagBug ? ie10IsDataView : isDataView); + + // Is a given value an array? + // Delegates to ECMA5's native `Array.isArray`. + var isArray = nativeIsArray || tagTester('Array'); + + // Internal function to check whether `key` is an own property name of `obj`. + function has(obj, key) { + return obj != null && hasOwnProperty.call(obj, key); + } + + var isArguments = tagTester('Arguments'); + + // Define a fallback version of the method in browsers (ahem, IE < 9), where + // there isn't any inspectable "Arguments" type. + (function() { + if (!isArguments(arguments)) { + isArguments = function(obj) { + return has(obj, 'callee'); + }; + } + }()); + + var isArguments$1 = isArguments; + + // Is a given object a finite number? + function isFinite$1(obj) { + return !isSymbol(obj) && _isFinite(obj) && !isNaN(parseFloat(obj)); + } + + // Is the given value `NaN`? + function isNaN$1(obj) { + return isNumber(obj) && _isNaN(obj); + } + + // Predicate-generating function. Often useful outside of Underscore. + function constant(value) { + return function() { + return value; + }; + } + + // Common internal logic for `isArrayLike` and `isBufferLike`. + function createSizePropertyCheck(getSizeProperty) { + return function(collection) { + var sizeProperty = getSizeProperty(collection); + return typeof sizeProperty == 'number' && sizeProperty >= 0 && sizeProperty <= MAX_ARRAY_INDEX; + } + } + + // Internal helper to generate a function to obtain property `key` from `obj`. + function shallowProperty(key) { + return function(obj) { + return obj == null ? void 0 : obj[key]; + }; + } + + // Internal helper to obtain the `byteLength` property of an object. + var getByteLength = shallowProperty('byteLength'); + + // Internal helper to determine whether we should spend extensive checks against + // `ArrayBuffer` et al. + var isBufferLike = createSizePropertyCheck(getByteLength); + + // Is a given value a typed array? + var typedArrayPattern = /\[object ((I|Ui)nt(8|16|32)|Float(32|64)|Uint8Clamped|Big(I|Ui)nt64)Array\]/; + function isTypedArray(obj) { + // `ArrayBuffer.isView` is the most future-proof, so use it when available. + // Otherwise, fall back on the above regular expression. + return nativeIsView ? (nativeIsView(obj) && !isDataView$1(obj)) : + isBufferLike(obj) && typedArrayPattern.test(toString.call(obj)); + } + + var isTypedArray$1 = supportsArrayBuffer ? isTypedArray : constant(false); + + // Internal helper to obtain the `length` property of an object. + var getLength = shallowProperty('length'); + + // Internal helper to create a simple lookup structure. + // `collectNonEnumProps` used to depend on `_.contains`, but this led to + // circular imports. `emulatedSet` is a one-off solution that only works for + // arrays of strings. + function emulatedSet(keys) { + var hash = {}; + for (var l = keys.length, i = 0; i < l; ++i) hash[keys[i]] = true; + return { + contains: function(key) { return hash[key]; }, + push: function(key) { + hash[key] = true; + return keys.push(key); + } + }; + } + + // Internal helper. Checks `keys` for the presence of keys in IE < 9 that won't + // be iterated by `for key in ...` and thus missed. Extends `keys` in place if + // needed. + function collectNonEnumProps(obj, keys) { + keys = emulatedSet(keys); + var nonEnumIdx = nonEnumerableProps.length; + var constructor = obj.constructor; + var proto = isFunction$1(constructor) && constructor.prototype || ObjProto; + + // Constructor is a special case. + var prop = 'constructor'; + if (has(obj, prop) && !keys.contains(prop)) keys.push(prop); + + while (nonEnumIdx--) { + prop = nonEnumerableProps[nonEnumIdx]; + if (prop in obj && obj[prop] !== proto[prop] && !keys.contains(prop)) { + keys.push(prop); + } + } + } + + // Retrieve the names of an object's own properties. + // Delegates to **ECMAScript 5**'s native `Object.keys`. + function keys(obj) { + if (!isObject(obj)) return []; + if (nativeKeys) return nativeKeys(obj); + var keys = []; + for (var key in obj) if (has(obj, key)) keys.push(key); + // Ahem, IE < 9. + if (hasEnumBug) collectNonEnumProps(obj, keys); + return keys; + } + + // Is a given array, string, or object empty? + // An "empty" object has no enumerable own-properties. + function isEmpty(obj) { + if (obj == null) return true; + // Skip the more expensive `toString`-based type checks if `obj` has no + // `.length`. + var length = getLength(obj); + if (typeof length == 'number' && ( + isArray(obj) || isString(obj) || isArguments$1(obj) + )) return length === 0; + return getLength(keys(obj)) === 0; + } + + // Returns whether an object has a given set of `key:value` pairs. + function isMatch(object, attrs) { + var _keys = keys(attrs), length = _keys.length; + if (object == null) return !length; + var obj = Object(object); + for (var i = 0; i < length; i++) { + var key = _keys[i]; + if (attrs[key] !== obj[key] || !(key in obj)) return false; + } + return true; + } + + // If Underscore is called as a function, it returns a wrapped object that can + // be used OO-style. This wrapper holds altered versions of all functions added + // through `_.mixin`. Wrapped objects may be chained. + function _(obj) { + if (obj instanceof _) return obj; + if (!(this instanceof _)) return new _(obj); + this._wrapped = obj; + } + + _.VERSION = VERSION; + + // Extracts the result from a wrapped and chained object. + _.prototype.value = function() { + return this._wrapped; + }; + + // Provide unwrapping proxies for some methods used in engine operations + // such as arithmetic and JSON stringification. + _.prototype.valueOf = _.prototype.toJSON = _.prototype.value; + + _.prototype.toString = function() { + return String(this._wrapped); + }; + + // Internal function to wrap or shallow-copy an ArrayBuffer, + // typed array or DataView to a new view, reusing the buffer. + function toBufferView(bufferSource) { + return new Uint8Array( + bufferSource.buffer || bufferSource, + bufferSource.byteOffset || 0, + getByteLength(bufferSource) + ); + } + + // We use this string twice, so give it a name for minification. + var tagDataView = '[object DataView]'; + + // Internal recursive comparison function for `_.isEqual`. + function eq(a, b, aStack, bStack) { + // Identical objects are equal. `0 === -0`, but they aren't identical. + // See the [Harmony `egal` proposal](https://wiki.ecmascript.org/doku.php?id=harmony:egal). + if (a === b) return a !== 0 || 1 / a === 1 / b; + // `null` or `undefined` only equal to itself (strict comparison). + if (a == null || b == null) return false; + // `NaN`s are equivalent, but non-reflexive. + if (a !== a) return b !== b; + // Exhaust primitive checks + var type = typeof a; + if (type !== 'function' && type !== 'object' && typeof b != 'object') return false; + return deepEq(a, b, aStack, bStack); + } + + // Internal recursive comparison function for `_.isEqual`. + function deepEq(a, b, aStack, bStack) { + // Unwrap any wrapped objects. + if (a instanceof _) a = a._wrapped; + if (b instanceof _) b = b._wrapped; + // Compare `[[Class]]` names. + var className = toString.call(a); + if (className !== toString.call(b)) return false; + // Work around a bug in IE 10 - Edge 13. + if (hasStringTagBug && className == '[object Object]' && isDataView$1(a)) { + if (!isDataView$1(b)) return false; + className = tagDataView; + } + switch (className) { + // These types are compared by value. + case '[object RegExp]': + // RegExps are coerced to strings for comparison (Note: '' + /a/i === '/a/i') + case '[object String]': + // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is + // equivalent to `new String("5")`. + return '' + a === '' + b; + case '[object Number]': + // `NaN`s are equivalent, but non-reflexive. + // Object(NaN) is equivalent to NaN. + if (+a !== +a) return +b !== +b; + // An `egal` comparison is performed for other numeric values. + return +a === 0 ? 1 / +a === 1 / b : +a === +b; + case '[object Date]': + case '[object Boolean]': + // Coerce dates and booleans to numeric primitive values. Dates are compared by their + // millisecond representations. Note that invalid dates with millisecond representations + // of `NaN` are not equivalent. + return +a === +b; + case '[object Symbol]': + return SymbolProto.valueOf.call(a) === SymbolProto.valueOf.call(b); + case '[object ArrayBuffer]': + case tagDataView: + // Coerce to typed array so we can fall through. + return deepEq(toBufferView(a), toBufferView(b), aStack, bStack); + } + + var areArrays = className === '[object Array]'; + if (!areArrays && isTypedArray$1(a)) { + var byteLength = getByteLength(a); + if (byteLength !== getByteLength(b)) return false; + if (a.buffer === b.buffer && a.byteOffset === b.byteOffset) return true; + areArrays = true; + } + if (!areArrays) { + if (typeof a != 'object' || typeof b != 'object') return false; + + // Objects with different constructors are not equivalent, but `Object`s or `Array`s + // from different frames are. + var aCtor = a.constructor, bCtor = b.constructor; + if (aCtor !== bCtor && !(isFunction$1(aCtor) && aCtor instanceof aCtor && + isFunction$1(bCtor) && bCtor instanceof bCtor) + && ('constructor' in a && 'constructor' in b)) { + return false; + } + } + // Assume equality for cyclic structures. The algorithm for detecting cyclic + // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`. + + // Initializing stack of traversed objects. + // It's done here since we only need them for objects and arrays comparison. + aStack = aStack || []; + bStack = bStack || []; + var length = aStack.length; + while (length--) { + // Linear search. Performance is inversely proportional to the number of + // unique nested structures. + if (aStack[length] === a) return bStack[length] === b; + } + + // Add the first object to the stack of traversed objects. + aStack.push(a); + bStack.push(b); + + // Recursively compare objects and arrays. + if (areArrays) { + // Compare array lengths to determine if a deep comparison is necessary. + length = a.length; + if (length !== b.length) return false; + // Deep compare the contents, ignoring non-numeric properties. + while (length--) { + if (!eq(a[length], b[length], aStack, bStack)) return false; + } + } else { + // Deep compare objects. + var _keys = keys(a), key; + length = _keys.length; + // Ensure that both objects contain the same number of properties before comparing deep equality. + if (keys(b).length !== length) return false; + while (length--) { + // Deep compare each member + key = _keys[length]; + if (!(has(b, key) && eq(a[key], b[key], aStack, bStack))) return false; + } + } + // Remove the first object from the stack of traversed objects. + aStack.pop(); + bStack.pop(); + return true; + } + + // Perform a deep comparison to check if two objects are equal. + function isEqual(a, b) { + return eq(a, b); + } + + // Retrieve all the enumerable property names of an object. + function allKeys(obj) { + if (!isObject(obj)) return []; + var keys = []; + for (var key in obj) keys.push(key); + // Ahem, IE < 9. + if (hasEnumBug) collectNonEnumProps(obj, keys); + return keys; + } + + // Since the regular `Object.prototype.toString` type tests don't work for + // some types in IE 11, we use a fingerprinting heuristic instead, based + // on the methods. It's not great, but it's the best we got. + // The fingerprint method lists are defined below. + function ie11fingerprint(methods) { + var length = getLength(methods); + return function(obj) { + if (obj == null) return false; + // `Map`, `WeakMap` and `Set` have no enumerable keys. + var keys = allKeys(obj); + if (getLength(keys)) return false; + for (var i = 0; i < length; i++) { + if (!isFunction$1(obj[methods[i]])) return false; + } + // If we are testing against `WeakMap`, we need to ensure that + // `obj` doesn't have a `forEach` method in order to distinguish + // it from a regular `Map`. + return methods !== weakMapMethods || !isFunction$1(obj[forEachName]); + }; + } + + // In the interest of compact minification, we write + // each string in the fingerprints only once. + var forEachName = 'forEach', + hasName = 'has', + commonInit = ['clear', 'delete'], + mapTail = ['get', hasName, 'set']; + + // `Map`, `WeakMap` and `Set` each have slightly different + // combinations of the above sublists. + var mapMethods = commonInit.concat(forEachName, mapTail), + weakMapMethods = commonInit.concat(mapTail), + setMethods = ['add'].concat(commonInit, forEachName, hasName); + + var isMap = isIE11 ? ie11fingerprint(mapMethods) : tagTester('Map'); + + var isWeakMap = isIE11 ? ie11fingerprint(weakMapMethods) : tagTester('WeakMap'); + + var isSet = isIE11 ? ie11fingerprint(setMethods) : tagTester('Set'); + + var isWeakSet = tagTester('WeakSet'); + + // Retrieve the values of an object's properties. + function values(obj) { + var _keys = keys(obj); + var length = _keys.length; + var values = Array(length); + for (var i = 0; i < length; i++) { + values[i] = obj[_keys[i]]; + } + return values; + } + + // Convert an object into a list of `[key, value]` pairs. + // The opposite of `_.object` with one argument. + function pairs(obj) { + var _keys = keys(obj); + var length = _keys.length; + var pairs = Array(length); + for (var i = 0; i < length; i++) { + pairs[i] = [_keys[i], obj[_keys[i]]]; + } + return pairs; + } + + // Invert the keys and values of an object. The values must be serializable. + function invert(obj) { + var result = {}; + var _keys = keys(obj); + for (var i = 0, length = _keys.length; i < length; i++) { + result[obj[_keys[i]]] = _keys[i]; + } + return result; + } + + // Return a sorted list of the function names available on the object. + function functions(obj) { + var names = []; + for (var key in obj) { + if (isFunction$1(obj[key])) names.push(key); + } + return names.sort(); + } + + // An internal function for creating assigner functions. + function createAssigner(keysFunc, defaults) { + return function(obj) { + var length = arguments.length; + if (defaults) obj = Object(obj); + if (length < 2 || obj == null) return obj; + for (var index = 1; index < length; index++) { + var source = arguments[index], + keys = keysFunc(source), + l = keys.length; + for (var i = 0; i < l; i++) { + var key = keys[i]; + if (!defaults || obj[key] === void 0) obj[key] = source[key]; + } + } + return obj; + }; + } + + // Extend a given object with all the properties in passed-in object(s). + var extend = createAssigner(allKeys); + + // Assigns a given object with all the own properties in the passed-in + // object(s). + // (https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) + var extendOwn = createAssigner(keys); + + // Fill in a given object with default properties. + var defaults = createAssigner(allKeys, true); + + // Create a naked function reference for surrogate-prototype-swapping. + function ctor() { + return function(){}; + } + + // An internal function for creating a new object that inherits from another. + function baseCreate(prototype) { + if (!isObject(prototype)) return {}; + if (nativeCreate) return nativeCreate(prototype); + var Ctor = ctor(); + Ctor.prototype = prototype; + var result = new Ctor; + Ctor.prototype = null; + return result; + } + + // Creates an object that inherits from the given prototype object. + // If additional properties are provided then they will be added to the + // created object. + function create(prototype, props) { + var result = baseCreate(prototype); + if (props) extendOwn(result, props); + return result; + } + + // Create a (shallow-cloned) duplicate of an object. + function clone(obj) { + if (!isObject(obj)) return obj; + return isArray(obj) ? obj.slice() : extend({}, obj); + } + + // Invokes `interceptor` with the `obj` and then returns `obj`. + // The primary purpose of this method is to "tap into" a method chain, in + // order to perform operations on intermediate results within the chain. + function tap(obj, interceptor) { + interceptor(obj); + return obj; + } + + // Normalize a (deep) property `path` to array. + // Like `_.iteratee`, this function can be customized. + function toPath(path) { + return isArray(path) ? path : [path]; + } + _.toPath = toPath; + + // Internal wrapper for `_.toPath` to enable minification. + // Similar to `cb` for `_.iteratee`. + function toPath$1(path) { + return _.toPath(path); + } + + // Internal function to obtain a nested property in `obj` along `path`. + function deepGet(obj, path) { + var length = path.length; + for (var i = 0; i < length; i++) { + if (obj == null) return void 0; + obj = obj[path[i]]; + } + return length ? obj : void 0; + } + + // Get the value of the (deep) property on `path` from `object`. + // If any property in `path` does not exist or if the value is + // `undefined`, return `defaultValue` instead. + // The `path` is normalized through `_.toPath`. + function get(object, path, defaultValue) { + var value = deepGet(object, toPath$1(path)); + return isUndefined(value) ? defaultValue : value; + } + + // Shortcut function for checking if an object has a given property directly on + // itself (in other words, not on a prototype). Unlike the internal `has` + // function, this public version can also traverse nested properties. + function has$1(obj, path) { + path = toPath$1(path); + var length = path.length; + for (var i = 0; i < length; i++) { + var key = path[i]; + if (!has(obj, key)) return false; + obj = obj[key]; + } + return !!length; + } + + // Keep the identity function around for default iteratees. + function identity(value) { + return value; + } + + // Returns a predicate for checking whether an object has a given set of + // `key:value` pairs. + function matcher(attrs) { + attrs = extendOwn({}, attrs); + return function(obj) { + return isMatch(obj, attrs); + }; + } + + // Creates a function that, when passed an object, will traverse that object’s + // properties down the given `path`, specified as an array of keys or indices. + function property(path) { + path = toPath$1(path); + return function(obj) { + return deepGet(obj, path); + }; + } + + // Internal function that returns an efficient (for current engines) version + // of the passed-in callback, to be repeatedly applied in other Underscore + // functions. + function optimizeCb(func, context, argCount) { + if (context === void 0) return func; + switch (argCount == null ? 3 : argCount) { + case 1: return function(value) { + return func.call(context, value); + }; + // The 2-argument case is omitted because we’re not using it. + case 3: return function(value, index, collection) { + return func.call(context, value, index, collection); + }; + case 4: return function(accumulator, value, index, collection) { + return func.call(context, accumulator, value, index, collection); + }; + } + return function() { + return func.apply(context, arguments); + }; + } + + // An internal function to generate callbacks that can be applied to each + // element in a collection, returning the desired result — either `_.identity`, + // an arbitrary callback, a property matcher, or a property accessor. + function baseIteratee(value, context, argCount) { + if (value == null) return identity; + if (isFunction$1(value)) return optimizeCb(value, context, argCount); + if (isObject(value) && !isArray(value)) return matcher(value); + return property(value); + } + + // External wrapper for our callback generator. Users may customize + // `_.iteratee` if they want additional predicate/iteratee shorthand styles. + // This abstraction hides the internal-only `argCount` argument. + function iteratee(value, context) { + return baseIteratee(value, context, Infinity); + } + _.iteratee = iteratee; + + // The function we call internally to generate a callback. It invokes + // `_.iteratee` if overridden, otherwise `baseIteratee`. + function cb(value, context, argCount) { + if (_.iteratee !== iteratee) return _.iteratee(value, context); + return baseIteratee(value, context, argCount); + } + + // Returns the results of applying the `iteratee` to each element of `obj`. + // In contrast to `_.map` it returns an object. + function mapObject(obj, iteratee, context) { + iteratee = cb(iteratee, context); + var _keys = keys(obj), + length = _keys.length, + results = {}; + for (var index = 0; index < length; index++) { + var currentKey = _keys[index]; + results[currentKey] = iteratee(obj[currentKey], currentKey, obj); + } + return results; + } + + // Predicate-generating function. Often useful outside of Underscore. + function noop(){} + + // Generates a function for a given object that returns a given property. + function propertyOf(obj) { + if (obj == null) return noop; + return function(path) { + return get(obj, path); + }; + } + + // Run a function **n** times. + function times(n, iteratee, context) { + var accum = Array(Math.max(0, n)); + iteratee = optimizeCb(iteratee, context, 1); + for (var i = 0; i < n; i++) accum[i] = iteratee(i); + return accum; + } + + // Return a random integer between `min` and `max` (inclusive). + function random(min, max) { + if (max == null) { + max = min; + min = 0; + } + return min + Math.floor(Math.random() * (max - min + 1)); + } + + // A (possibly faster) way to get the current timestamp as an integer. + var now = Date.now || function() { + return new Date().getTime(); + }; + + // Internal helper to generate functions for escaping and unescaping strings + // to/from HTML interpolation. + function createEscaper(map) { + var escaper = function(match) { + return map[match]; + }; + // Regexes for identifying a key that needs to be escaped. + var source = '(?:' + keys(map).join('|') + ')'; + var testRegexp = RegExp(source); + var replaceRegexp = RegExp(source, 'g'); + return function(string) { + string = string == null ? '' : '' + string; + return testRegexp.test(string) ? string.replace(replaceRegexp, escaper) : string; + }; + } + + // Internal list of HTML entities for escaping. + var escapeMap = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + "'": ''', + '`': '`' + }; + + // Function for escaping strings to HTML interpolation. + var _escape = createEscaper(escapeMap); + + // Internal list of HTML entities for unescaping. + var unescapeMap = invert(escapeMap); + + // Function for unescaping strings from HTML interpolation. + var _unescape = createEscaper(unescapeMap); + + // By default, Underscore uses ERB-style template delimiters. Change the + // following template settings to use alternative delimiters. + var templateSettings = _.templateSettings = { + evaluate: /<%([\s\S]+?)%>/g, + interpolate: /<%=([\s\S]+?)%>/g, + escape: /<%-([\s\S]+?)%>/g + }; + + // When customizing `_.templateSettings`, if you don't want to define an + // interpolation, evaluation or escaping regex, we need one that is + // guaranteed not to match. + var noMatch = /(.)^/; + + // Certain characters need to be escaped so that they can be put into a + // string literal. + var escapes = { + "'": "'", + '\\': '\\', + '\r': 'r', + '\n': 'n', + '\u2028': 'u2028', + '\u2029': 'u2029' + }; + + var escapeRegExp = /\\|'|\r|\n|\u2028|\u2029/g; + + function escapeChar(match) { + return '\\' + escapes[match]; + } + + // JavaScript micro-templating, similar to John Resig's implementation. + // Underscore templating handles arbitrary delimiters, preserves whitespace, + // and correctly escapes quotes within interpolated code. + // NB: `oldSettings` only exists for backwards compatibility. + function template(text, settings, oldSettings) { + if (!settings && oldSettings) settings = oldSettings; + settings = defaults({}, settings, _.templateSettings); + + // Combine delimiters into one regular expression via alternation. + var matcher = RegExp([ + (settings.escape || noMatch).source, + (settings.interpolate || noMatch).source, + (settings.evaluate || noMatch).source + ].join('|') + '|$', 'g'); + + // Compile the template source, escaping string literals appropriately. + var index = 0; + var source = "__p+='"; + text.replace(matcher, function(match, escape, interpolate, evaluate, offset) { + source += text.slice(index, offset).replace(escapeRegExp, escapeChar); + index = offset + match.length; + + if (escape) { + source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'"; + } else if (interpolate) { + source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'"; + } else if (evaluate) { + source += "';\n" + evaluate + "\n__p+='"; + } + + // Adobe VMs need the match returned to produce the correct offset. + return match; + }); + source += "';\n"; + + // If a variable is not specified, place data values in local scope. + if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n'; + + source = "var __t,__p='',__j=Array.prototype.join," + + "print=function(){__p+=__j.call(arguments,'');};\n" + + source + 'return __p;\n'; + + var render; + try { + render = new Function(settings.variable || 'obj', '_', source); + } catch (e) { + e.source = source; + throw e; + } + + var template = function(data) { + return render.call(this, data, _); + }; + + // Provide the compiled source as a convenience for precompilation. + var argument = settings.variable || 'obj'; + template.source = 'function(' + argument + '){\n' + source + '}'; + + return template; + } + + // Traverses the children of `obj` along `path`. If a child is a function, it + // is invoked with its parent as context. Returns the value of the final + // child, or `fallback` if any child is undefined. + function result(obj, path, fallback) { + path = toPath$1(path); + var length = path.length; + if (!length) { + return isFunction$1(fallback) ? fallback.call(obj) : fallback; + } + for (var i = 0; i < length; i++) { + var prop = obj == null ? void 0 : obj[path[i]]; + if (prop === void 0) { + prop = fallback; + i = length; // Ensure we don't continue iterating. + } + obj = isFunction$1(prop) ? prop.call(obj) : prop; + } + return obj; + } + + // Generate a unique integer id (unique within the entire client session). + // Useful for temporary DOM ids. + var idCounter = 0; + function uniqueId(prefix) { + var id = ++idCounter + ''; + return prefix ? prefix + id : id; + } + + // Start chaining a wrapped Underscore object. + function chain(obj) { + var instance = _(obj); + instance._chain = true; + return instance; + } + + // Internal function to execute `sourceFunc` bound to `context` with optional + // `args`. Determines whether to execute a function as a constructor or as a + // normal function. + function executeBound(sourceFunc, boundFunc, context, callingContext, args) { + if (!(callingContext instanceof boundFunc)) return sourceFunc.apply(context, args); + var self = baseCreate(sourceFunc.prototype); + var result = sourceFunc.apply(self, args); + if (isObject(result)) return result; + return self; + } + + // Partially apply a function by creating a version that has had some of its + // arguments pre-filled, without changing its dynamic `this` context. `_` acts + // as a placeholder by default, allowing any combination of arguments to be + // pre-filled. Set `_.partial.placeholder` for a custom placeholder argument. + var partial = restArguments(function(func, boundArgs) { + var placeholder = partial.placeholder; + var bound = function() { + var position = 0, length = boundArgs.length; + var args = Array(length); + for (var i = 0; i < length; i++) { + args[i] = boundArgs[i] === placeholder ? arguments[position++] : boundArgs[i]; + } + while (position < arguments.length) args.push(arguments[position++]); + return executeBound(func, bound, this, this, args); + }; + return bound; + }); + + partial.placeholder = _; + + // Create a function bound to a given object (assigning `this`, and arguments, + // optionally). + var bind = restArguments(function(func, context, args) { + if (!isFunction$1(func)) throw new TypeError('Bind must be called on a function'); + var bound = restArguments(function(callArgs) { + return executeBound(func, bound, context, this, args.concat(callArgs)); + }); + return bound; + }); + + // Internal helper for collection methods to determine whether a collection + // should be iterated as an array or as an object. + // Related: https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength + // Avoids a very nasty iOS 8 JIT bug on ARM-64. #2094 + var isArrayLike = createSizePropertyCheck(getLength); + + // Internal implementation of a recursive `flatten` function. + function flatten(input, depth, strict, output) { + output = output || []; + if (!depth && depth !== 0) { + depth = Infinity; + } else if (depth <= 0) { + return output.concat(input); + } + var idx = output.length; + for (var i = 0, length = getLength(input); i < length; i++) { + var value = input[i]; + if (isArrayLike(value) && (isArray(value) || isArguments$1(value))) { + // Flatten current level of array or arguments object. + if (depth > 1) { + flatten(value, depth - 1, strict, output); + idx = output.length; + } else { + var j = 0, len = value.length; + while (j < len) output[idx++] = value[j++]; + } + } else if (!strict) { + output[idx++] = value; + } + } + return output; + } + + // Bind a number of an object's methods to that object. Remaining arguments + // are the method names to be bound. Useful for ensuring that all callbacks + // defined on an object belong to it. + var bindAll = restArguments(function(obj, keys) { + keys = flatten(keys, false, false); + var index = keys.length; + if (index < 1) throw new Error('bindAll must be passed function names'); + while (index--) { + var key = keys[index]; + obj[key] = bind(obj[key], obj); + } + return obj; + }); + + // Memoize an expensive function by storing its results. + function memoize(func, hasher) { + var memoize = function(key) { + var cache = memoize.cache; + var address = '' + (hasher ? hasher.apply(this, arguments) : key); + if (!has(cache, address)) cache[address] = func.apply(this, arguments); + return cache[address]; + }; + memoize.cache = {}; + return memoize; + } + + // Delays a function for the given number of milliseconds, and then calls + // it with the arguments supplied. + var delay = restArguments(function(func, wait, args) { + return setTimeout(function() { + return func.apply(null, args); + }, wait); + }); + + // Defers a function, scheduling it to run after the current call stack has + // cleared. + var defer = partial(delay, _, 1); + + // Returns a function, that, when invoked, will only be triggered at most once + // during a given window of time. Normally, the throttled function will run + // as much as it can, without ever going more than once per `wait` duration; + // but if you'd like to disable the execution on the leading edge, pass + // `{leading: false}`. To disable execution on the trailing edge, ditto. + function throttle(func, wait, options) { + var timeout, context, args, result; + var previous = 0; + if (!options) options = {}; + + var later = function() { + previous = options.leading === false ? 0 : now(); + timeout = null; + result = func.apply(context, args); + if (!timeout) context = args = null; + }; + + var throttled = function() { + var _now = now(); + if (!previous && options.leading === false) previous = _now; + var remaining = wait - (_now - previous); + context = this; + args = arguments; + if (remaining <= 0 || remaining > wait) { + if (timeout) { + clearTimeout(timeout); + timeout = null; + } + previous = _now; + result = func.apply(context, args); + if (!timeout) context = args = null; + } else if (!timeout && options.trailing !== false) { + timeout = setTimeout(later, remaining); + } + return result; + }; + + throttled.cancel = function() { + clearTimeout(timeout); + previous = 0; + timeout = context = args = null; + }; + + return throttled; + } + + // When a sequence of calls of the returned function ends, the argument + // function is triggered. The end of a sequence is defined by the `wait` + // parameter. If `immediate` is passed, the argument function will be + // triggered at the beginning of the sequence instead of at the end. + function debounce(func, wait, immediate) { + var timeout, previous, args, result, context; + + var later = function() { + var passed = now() - previous; + if (wait > passed) { + timeout = setTimeout(later, wait - passed); + } else { + timeout = null; + if (!immediate) result = func.apply(context, args); + // This check is needed because `func` can recursively invoke `debounced`. + if (!timeout) args = context = null; + } + }; + + var debounced = restArguments(function(_args) { + context = this; + args = _args; + previous = now(); + if (!timeout) { + timeout = setTimeout(later, wait); + if (immediate) result = func.apply(context, args); + } + return result; + }); + + debounced.cancel = function() { + clearTimeout(timeout); + timeout = args = context = null; + }; + + return debounced; + } + + // Returns the first function passed as an argument to the second, + // allowing you to adjust arguments, run code before and after, and + // conditionally execute the original function. + function wrap(func, wrapper) { + return partial(wrapper, func); + } + + // Returns a negated version of the passed-in predicate. + function negate(predicate) { + return function() { + return !predicate.apply(this, arguments); + }; + } + + // Returns a function that is the composition of a list of functions, each + // consuming the return value of the function that follows. + function compose() { + var args = arguments; + var start = args.length - 1; + return function() { + var i = start; + var result = args[start].apply(this, arguments); + while (i--) result = args[i].call(this, result); + return result; + }; + } + + // Returns a function that will only be executed on and after the Nth call. + function after(times, func) { + return function() { + if (--times < 1) { + return func.apply(this, arguments); + } + }; + } + + // Returns a function that will only be executed up to (but not including) the + // Nth call. + function before(times, func) { + var memo; + return function() { + if (--times > 0) { + memo = func.apply(this, arguments); + } + if (times <= 1) func = null; + return memo; + }; + } + + // Returns a function that will be executed at most one time, no matter how + // often you call it. Useful for lazy initialization. + var once = partial(before, 2); + + // Returns the first key on an object that passes a truth test. + function findKey(obj, predicate, context) { + predicate = cb(predicate, context); + var _keys = keys(obj), key; + for (var i = 0, length = _keys.length; i < length; i++) { + key = _keys[i]; + if (predicate(obj[key], key, obj)) return key; + } + } + + // Internal function to generate `_.findIndex` and `_.findLastIndex`. + function createPredicateIndexFinder(dir) { + return function(array, predicate, context) { + predicate = cb(predicate, context); + var length = getLength(array); + var index = dir > 0 ? 0 : length - 1; + for (; index >= 0 && index < length; index += dir) { + if (predicate(array[index], index, array)) return index; + } + return -1; + }; + } + + // Returns the first index on an array-like that passes a truth test. + var findIndex = createPredicateIndexFinder(1); + + // Returns the last index on an array-like that passes a truth test. + var findLastIndex = createPredicateIndexFinder(-1); + + // Use a comparator function to figure out the smallest index at which + // an object should be inserted so as to maintain order. Uses binary search. + function sortedIndex(array, obj, iteratee, context) { + iteratee = cb(iteratee, context, 1); + var value = iteratee(obj); + var low = 0, high = getLength(array); + while (low < high) { + var mid = Math.floor((low + high) / 2); + if (iteratee(array[mid]) < value) low = mid + 1; else high = mid; + } + return low; + } + + // Internal function to generate the `_.indexOf` and `_.lastIndexOf` functions. + function createIndexFinder(dir, predicateFind, sortedIndex) { + return function(array, item, idx) { + var i = 0, length = getLength(array); + if (typeof idx == 'number') { + if (dir > 0) { + i = idx >= 0 ? idx : Math.max(idx + length, i); + } else { + length = idx >= 0 ? Math.min(idx + 1, length) : idx + length + 1; + } + } else if (sortedIndex && idx && length) { + idx = sortedIndex(array, item); + return array[idx] === item ? idx : -1; + } + if (item !== item) { + idx = predicateFind(slice.call(array, i, length), isNaN$1); + return idx >= 0 ? idx + i : -1; + } + for (idx = dir > 0 ? i : length - 1; idx >= 0 && idx < length; idx += dir) { + if (array[idx] === item) return idx; + } + return -1; + }; + } + + // Return the position of the first occurrence of an item in an array, + // or -1 if the item is not included in the array. + // If the array is large and already in sort order, pass `true` + // for **isSorted** to use binary search. + var indexOf = createIndexFinder(1, findIndex, sortedIndex); + + // Return the position of the last occurrence of an item in an array, + // or -1 if the item is not included in the array. + var lastIndexOf = createIndexFinder(-1, findLastIndex); + + // Return the first value which passes a truth test. + function find(obj, predicate, context) { + var keyFinder = isArrayLike(obj) ? findIndex : findKey; + var key = keyFinder(obj, predicate, context); + if (key !== void 0 && key !== -1) return obj[key]; + } + + // Convenience version of a common use case of `_.find`: getting the first + // object containing specific `key:value` pairs. + function findWhere(obj, attrs) { + return find(obj, matcher(attrs)); + } + + // The cornerstone for collection functions, an `each` + // implementation, aka `forEach`. + // Handles raw objects in addition to array-likes. Treats all + // sparse array-likes as if they were dense. + function each(obj, iteratee, context) { + iteratee = optimizeCb(iteratee, context); + var i, length; + if (isArrayLike(obj)) { + for (i = 0, length = obj.length; i < length; i++) { + iteratee(obj[i], i, obj); + } + } else { + var _keys = keys(obj); + for (i = 0, length = _keys.length; i < length; i++) { + iteratee(obj[_keys[i]], _keys[i], obj); + } + } + return obj; + } + + // Return the results of applying the iteratee to each element. + function map(obj, iteratee, context) { + iteratee = cb(iteratee, context); + var _keys = !isArrayLike(obj) && keys(obj), + length = (_keys || obj).length, + results = Array(length); + for (var index = 0; index < length; index++) { + var currentKey = _keys ? _keys[index] : index; + results[index] = iteratee(obj[currentKey], currentKey, obj); + } + return results; + } + + // Internal helper to create a reducing function, iterating left or right. + function createReduce(dir) { + // Wrap code that reassigns argument variables in a separate function than + // the one that accesses `arguments.length` to avoid a perf hit. (#1991) + var reducer = function(obj, iteratee, memo, initial) { + var _keys = !isArrayLike(obj) && keys(obj), + length = (_keys || obj).length, + index = dir > 0 ? 0 : length - 1; + if (!initial) { + memo = obj[_keys ? _keys[index] : index]; + index += dir; + } + for (; index >= 0 && index < length; index += dir) { + var currentKey = _keys ? _keys[index] : index; + memo = iteratee(memo, obj[currentKey], currentKey, obj); + } + return memo; + }; + + return function(obj, iteratee, memo, context) { + var initial = arguments.length >= 3; + return reducer(obj, optimizeCb(iteratee, context, 4), memo, initial); + }; + } + + // **Reduce** builds up a single result from a list of values, aka `inject`, + // or `foldl`. + var reduce = createReduce(1); + + // The right-associative version of reduce, also known as `foldr`. + var reduceRight = createReduce(-1); + + // Return all the elements that pass a truth test. + function filter(obj, predicate, context) { + var results = []; + predicate = cb(predicate, context); + each(obj, function(value, index, list) { + if (predicate(value, index, list)) results.push(value); + }); + return results; + } + + // Return all the elements for which a truth test fails. + function reject(obj, predicate, context) { + return filter(obj, negate(cb(predicate)), context); + } + + // Determine whether all of the elements pass a truth test. + function every(obj, predicate, context) { + predicate = cb(predicate, context); + var _keys = !isArrayLike(obj) && keys(obj), + length = (_keys || obj).length; + for (var index = 0; index < length; index++) { + var currentKey = _keys ? _keys[index] : index; + if (!predicate(obj[currentKey], currentKey, obj)) return false; + } + return true; + } + + // Determine if at least one element in the object passes a truth test. + function some(obj, predicate, context) { + predicate = cb(predicate, context); + var _keys = !isArrayLike(obj) && keys(obj), + length = (_keys || obj).length; + for (var index = 0; index < length; index++) { + var currentKey = _keys ? _keys[index] : index; + if (predicate(obj[currentKey], currentKey, obj)) return true; + } + return false; + } + + // Determine if the array or object contains a given item (using `===`). + function contains(obj, item, fromIndex, guard) { + if (!isArrayLike(obj)) obj = values(obj); + if (typeof fromIndex != 'number' || guard) fromIndex = 0; + return indexOf(obj, item, fromIndex) >= 0; + } + + // Invoke a method (with arguments) on every item in a collection. + var invoke = restArguments(function(obj, path, args) { + var contextPath, func; + if (isFunction$1(path)) { + func = path; + } else { + path = toPath$1(path); + contextPath = path.slice(0, -1); + path = path[path.length - 1]; + } + return map(obj, function(context) { + var method = func; + if (!method) { + if (contextPath && contextPath.length) { + context = deepGet(context, contextPath); + } + if (context == null) return void 0; + method = context[path]; + } + return method == null ? method : method.apply(context, args); + }); + }); + + // Convenience version of a common use case of `_.map`: fetching a property. + function pluck(obj, key) { + return map(obj, property(key)); + } + + // Convenience version of a common use case of `_.filter`: selecting only + // objects containing specific `key:value` pairs. + function where(obj, attrs) { + return filter(obj, matcher(attrs)); + } + + // Return the maximum element (or element-based computation). + function max(obj, iteratee, context) { + var result = -Infinity, lastComputed = -Infinity, + value, computed; + if (iteratee == null || typeof iteratee == 'number' && typeof obj[0] != 'object' && obj != null) { + obj = isArrayLike(obj) ? obj : values(obj); + for (var i = 0, length = obj.length; i < length; i++) { + value = obj[i]; + if (value != null && value > result) { + result = value; + } + } + } else { + iteratee = cb(iteratee, context); + each(obj, function(v, index, list) { + computed = iteratee(v, index, list); + if (computed > lastComputed || computed === -Infinity && result === -Infinity) { + result = v; + lastComputed = computed; + } + }); + } + return result; + } + + // Return the minimum element (or element-based computation). + function min(obj, iteratee, context) { + var result = Infinity, lastComputed = Infinity, + value, computed; + if (iteratee == null || typeof iteratee == 'number' && typeof obj[0] != 'object' && obj != null) { + obj = isArrayLike(obj) ? obj : values(obj); + for (var i = 0, length = obj.length; i < length; i++) { + value = obj[i]; + if (value != null && value < result) { + result = value; + } + } + } else { + iteratee = cb(iteratee, context); + each(obj, function(v, index, list) { + computed = iteratee(v, index, list); + if (computed < lastComputed || computed === Infinity && result === Infinity) { + result = v; + lastComputed = computed; + } + }); + } + return result; + } + + // Sample **n** random values from a collection using the modern version of the + // [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher–Yates_shuffle). + // If **n** is not specified, returns a single random element. + // The internal `guard` argument allows it to work with `_.map`. + function sample(obj, n, guard) { + if (n == null || guard) { + if (!isArrayLike(obj)) obj = values(obj); + return obj[random(obj.length - 1)]; + } + var sample = isArrayLike(obj) ? clone(obj) : values(obj); + var length = getLength(sample); + n = Math.max(Math.min(n, length), 0); + var last = length - 1; + for (var index = 0; index < n; index++) { + var rand = random(index, last); + var temp = sample[index]; + sample[index] = sample[rand]; + sample[rand] = temp; + } + return sample.slice(0, n); + } + + // Shuffle a collection. + function shuffle(obj) { + return sample(obj, Infinity); + } + + // Sort the object's values by a criterion produced by an iteratee. + function sortBy(obj, iteratee, context) { + var index = 0; + iteratee = cb(iteratee, context); + return pluck(map(obj, function(value, key, list) { + return { + value: value, + index: index++, + criteria: iteratee(value, key, list) + }; + }).sort(function(left, right) { + var a = left.criteria; + var b = right.criteria; + if (a !== b) { + if (a > b || a === void 0) return 1; + if (a < b || b === void 0) return -1; + } + return left.index - right.index; + }), 'value'); + } + + // An internal function used for aggregate "group by" operations. + function group(behavior, partition) { + return function(obj, iteratee, context) { + var result = partition ? [[], []] : {}; + iteratee = cb(iteratee, context); + each(obj, function(value, index) { + var key = iteratee(value, index, obj); + behavior(result, value, key); + }); + return result; + }; + } + + // Groups the object's values by a criterion. Pass either a string attribute + // to group by, or a function that returns the criterion. + var groupBy = group(function(result, value, key) { + if (has(result, key)) result[key].push(value); else result[key] = [value]; + }); + + // Indexes the object's values by a criterion, similar to `_.groupBy`, but for + // when you know that your index values will be unique. + var indexBy = group(function(result, value, key) { + result[key] = value; + }); + + // Counts instances of an object that group by a certain criterion. Pass + // either a string attribute to count by, or a function that returns the + // criterion. + var countBy = group(function(result, value, key) { + if (has(result, key)) result[key]++; else result[key] = 1; + }); + + // Split a collection into two arrays: one whose elements all pass the given + // truth test, and one whose elements all do not pass the truth test. + var partition = group(function(result, value, pass) { + result[pass ? 0 : 1].push(value); + }, true); + + // Safely create a real, live array from anything iterable. + var reStrSymbol = /[^\ud800-\udfff]|[\ud800-\udbff][\udc00-\udfff]|[\ud800-\udfff]/g; + function toArray(obj) { + if (!obj) return []; + if (isArray(obj)) return slice.call(obj); + if (isString(obj)) { + // Keep surrogate pair characters together. + return obj.match(reStrSymbol); + } + if (isArrayLike(obj)) return map(obj, identity); + return values(obj); + } + + // Return the number of elements in a collection. + function size(obj) { + if (obj == null) return 0; + return isArrayLike(obj) ? obj.length : keys(obj).length; + } + + // Internal `_.pick` helper function to determine whether `key` is an enumerable + // property name of `obj`. + function keyInObj(value, key, obj) { + return key in obj; + } + + // Return a copy of the object only containing the allowed properties. + var pick = restArguments(function(obj, keys) { + var result = {}, iteratee = keys[0]; + if (obj == null) return result; + if (isFunction$1(iteratee)) { + if (keys.length > 1) iteratee = optimizeCb(iteratee, keys[1]); + keys = allKeys(obj); + } else { + iteratee = keyInObj; + keys = flatten(keys, false, false); + obj = Object(obj); + } + for (var i = 0, length = keys.length; i < length; i++) { + var key = keys[i]; + var value = obj[key]; + if (iteratee(value, key, obj)) result[key] = value; + } + return result; + }); + + // Return a copy of the object without the disallowed properties. + var omit = restArguments(function(obj, keys) { + var iteratee = keys[0], context; + if (isFunction$1(iteratee)) { + iteratee = negate(iteratee); + if (keys.length > 1) context = keys[1]; + } else { + keys = map(flatten(keys, false, false), String); + iteratee = function(value, key) { + return !contains(keys, key); + }; + } + return pick(obj, iteratee, context); + }); + + // Returns everything but the last entry of the array. Especially useful on + // the arguments object. Passing **n** will return all the values in + // the array, excluding the last N. + function initial(array, n, guard) { + return slice.call(array, 0, Math.max(0, array.length - (n == null || guard ? 1 : n))); + } + + // Get the first element of an array. Passing **n** will return the first N + // values in the array. The **guard** check allows it to work with `_.map`. + function first(array, n, guard) { + if (array == null || array.length < 1) return n == null || guard ? void 0 : []; + if (n == null || guard) return array[0]; + return initial(array, array.length - n); + } + + // Returns everything but the first entry of the `array`. Especially useful on + // the `arguments` object. Passing an **n** will return the rest N values in the + // `array`. + function rest(array, n, guard) { + return slice.call(array, n == null || guard ? 1 : n); + } + + // Get the last element of an array. Passing **n** will return the last N + // values in the array. + function last(array, n, guard) { + if (array == null || array.length < 1) return n == null || guard ? void 0 : []; + if (n == null || guard) return array[array.length - 1]; + return rest(array, Math.max(0, array.length - n)); + } + + // Trim out all falsy values from an array. + function compact(array) { + return filter(array, Boolean); + } + + // Flatten out an array, either recursively (by default), or up to `depth`. + // Passing `true` or `false` as `depth` means `1` or `Infinity`, respectively. + function flatten$1(array, depth) { + return flatten(array, depth, false); + } + + // Take the difference between one array and a number of other arrays. + // Only the elements present in just the first array will remain. + var difference = restArguments(function(array, rest) { + rest = flatten(rest, true, true); + return filter(array, function(value){ + return !contains(rest, value); + }); + }); + + // Return a version of the array that does not contain the specified value(s). + var without = restArguments(function(array, otherArrays) { + return difference(array, otherArrays); + }); + + // Produce a duplicate-free version of the array. If the array has already + // been sorted, you have the option of using a faster algorithm. + // The faster algorithm will not work with an iteratee if the iteratee + // is not a one-to-one function, so providing an iteratee will disable + // the faster algorithm. + function uniq(array, isSorted, iteratee, context) { + if (!isBoolean(isSorted)) { + context = iteratee; + iteratee = isSorted; + isSorted = false; + } + if (iteratee != null) iteratee = cb(iteratee, context); + var result = []; + var seen = []; + for (var i = 0, length = getLength(array); i < length; i++) { + var value = array[i], + computed = iteratee ? iteratee(value, i, array) : value; + if (isSorted && !iteratee) { + if (!i || seen !== computed) result.push(value); + seen = computed; + } else if (iteratee) { + if (!contains(seen, computed)) { + seen.push(computed); + result.push(value); + } + } else if (!contains(result, value)) { + result.push(value); + } + } + return result; + } + + // Produce an array that contains the union: each distinct element from all of + // the passed-in arrays. + var union = restArguments(function(arrays) { + return uniq(flatten(arrays, true, true)); + }); + + // Produce an array that contains every item shared between all the + // passed-in arrays. + function intersection(array) { + var result = []; + var argsLength = arguments.length; + for (var i = 0, length = getLength(array); i < length; i++) { + var item = array[i]; + if (contains(result, item)) continue; + var j; + for (j = 1; j < argsLength; j++) { + if (!contains(arguments[j], item)) break; + } + if (j === argsLength) result.push(item); + } + return result; + } + + // Complement of zip. Unzip accepts an array of arrays and groups + // each array's elements on shared indices. + function unzip(array) { + var length = array && max(array, getLength).length || 0; + var result = Array(length); + + for (var index = 0; index < length; index++) { + result[index] = pluck(array, index); + } + return result; + } + + // Zip together multiple lists into a single array -- elements that share + // an index go together. + var zip = restArguments(unzip); + + // Converts lists into objects. Pass either a single array of `[key, value]` + // pairs, or two parallel arrays of the same length -- one of keys, and one of + // the corresponding values. Passing by pairs is the reverse of `_.pairs`. + function object(list, values) { + var result = {}; + for (var i = 0, length = getLength(list); i < length; i++) { + if (values) { + result[list[i]] = values[i]; + } else { + result[list[i][0]] = list[i][1]; + } + } + return result; + } + + // Generate an integer Array containing an arithmetic progression. A port of + // the native Python `range()` function. See + // [the Python documentation](https://docs.python.org/library/functions.html#range). + function range(start, stop, step) { + if (stop == null) { + stop = start || 0; + start = 0; + } + if (!step) { + step = stop < start ? -1 : 1; + } + + var length = Math.max(Math.ceil((stop - start) / step), 0); + var range = Array(length); + + for (var idx = 0; idx < length; idx++, start += step) { + range[idx] = start; + } + + return range; + } + + // Chunk a single array into multiple arrays, each containing `count` or fewer + // items. + function chunk(array, count) { + if (count == null || count < 1) return []; + var result = []; + var i = 0, length = array.length; + while (i < length) { + result.push(slice.call(array, i, i += count)); + } + return result; + } + + // Helper function to continue chaining intermediate results. + function chainResult(instance, obj) { + return instance._chain ? _(obj).chain() : obj; + } + + // Add your own custom functions to the Underscore object. + function mixin(obj) { + each(functions(obj), function(name) { + var func = _[name] = obj[name]; + _.prototype[name] = function() { + var args = [this._wrapped]; + push.apply(args, arguments); + return chainResult(this, func.apply(_, args)); + }; + }); + return _; + } + + // Add all mutator `Array` functions to the wrapper. + each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) { + var method = ArrayProto[name]; + _.prototype[name] = function() { + var obj = this._wrapped; + if (obj != null) { + method.apply(obj, arguments); + if ((name === 'shift' || name === 'splice') && obj.length === 0) { + delete obj[0]; + } + } + return chainResult(this, obj); + }; + }); + + // Add all accessor `Array` functions to the wrapper. + each(['concat', 'join', 'slice'], function(name) { + var method = ArrayProto[name]; + _.prototype[name] = function() { + var obj = this._wrapped; + if (obj != null) obj = method.apply(obj, arguments); + return chainResult(this, obj); + }; + }); + + // Named Exports + + var allExports = { + __proto__: null, + VERSION: VERSION, + restArguments: restArguments, + isObject: isObject, + isNull: isNull, + isUndefined: isUndefined, + isBoolean: isBoolean, + isElement: isElement, + isString: isString, + isNumber: isNumber, + isDate: isDate, + isRegExp: isRegExp, + isError: isError, + isSymbol: isSymbol, + isArrayBuffer: isArrayBuffer, + isDataView: isDataView$1, + isArray: isArray, + isFunction: isFunction$1, + isArguments: isArguments$1, + isFinite: isFinite$1, + isNaN: isNaN$1, + isTypedArray: isTypedArray$1, + isEmpty: isEmpty, + isMatch: isMatch, + isEqual: isEqual, + isMap: isMap, + isWeakMap: isWeakMap, + isSet: isSet, + isWeakSet: isWeakSet, + keys: keys, + allKeys: allKeys, + values: values, + pairs: pairs, + invert: invert, + functions: functions, + methods: functions, + extend: extend, + extendOwn: extendOwn, + assign: extendOwn, + defaults: defaults, + create: create, + clone: clone, + tap: tap, + get: get, + has: has$1, + mapObject: mapObject, + identity: identity, + constant: constant, + noop: noop, + toPath: toPath, + property: property, + propertyOf: propertyOf, + matcher: matcher, + matches: matcher, + times: times, + random: random, + now: now, + escape: _escape, + unescape: _unescape, + templateSettings: templateSettings, + template: template, + result: result, + uniqueId: uniqueId, + chain: chain, + iteratee: iteratee, + partial: partial, + bind: bind, + bindAll: bindAll, + memoize: memoize, + delay: delay, + defer: defer, + throttle: throttle, + debounce: debounce, + wrap: wrap, + negate: negate, + compose: compose, + after: after, + before: before, + once: once, + findKey: findKey, + findIndex: findIndex, + findLastIndex: findLastIndex, + sortedIndex: sortedIndex, + indexOf: indexOf, + lastIndexOf: lastIndexOf, + find: find, + detect: find, + findWhere: findWhere, + each: each, + forEach: each, + map: map, + collect: map, + reduce: reduce, + foldl: reduce, + inject: reduce, + reduceRight: reduceRight, + foldr: reduceRight, + filter: filter, + select: filter, + reject: reject, + every: every, + all: every, + some: some, + any: some, + contains: contains, + includes: contains, + include: contains, + invoke: invoke, + pluck: pluck, + where: where, + max: max, + min: min, + shuffle: shuffle, + sample: sample, + sortBy: sortBy, + groupBy: groupBy, + indexBy: indexBy, + countBy: countBy, + partition: partition, + toArray: toArray, + size: size, + pick: pick, + omit: omit, + first: first, + head: first, + take: first, + initial: initial, + last: last, + rest: rest, + tail: rest, + drop: rest, + compact: compact, + flatten: flatten$1, + without: without, + uniq: uniq, + unique: uniq, + union: union, + intersection: intersection, + difference: difference, + unzip: unzip, + transpose: unzip, + zip: zip, + object: object, + range: range, + chunk: chunk, + mixin: mixin, + 'default': _ + }; + + // Default Export + + // Add all of the Underscore functions to the wrapper object. + var _$1 = mixin(allExports); + // Legacy Node.js API. + _$1._ = _$1; + + return _$1; + +}))); +//# sourceMappingURL=underscore.js.map diff --git a/sparsify/_static/underscore.js b/sparsify/_static/underscore.js index 5b55f32beac..166240ef2dd 100644 --- a/sparsify/_static/underscore.js +++ b/sparsify/_static/underscore.js @@ -1,31 +1,6 @@ -// Underscore.js 1.3.1 -// (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc. -// Underscore is freely distributable under the MIT license. -// Portions of Underscore are inspired or borrowed from Prototype, -// Oliver Steele's Functional, and John Resig's Micro-Templating. -// For all details and documentation: -// http://documentcloud.github.com/underscore -(function(){function q(a,c,d){if(a===c)return a!==0||1/a==1/c;if(a==null||c==null)return a===c;if(a._chain)a=a._wrapped;if(c._chain)c=c._wrapped;if(a.isEqual&&b.isFunction(a.isEqual))return a.isEqual(c);if(c.isEqual&&b.isFunction(c.isEqual))return c.isEqual(a);var e=l.call(a);if(e!=l.call(c))return false;switch(e){case "[object String]":return a==String(c);case "[object Number]":return a!=+a?c!=+c:a==0?1/a==1/c:a==+c;case "[object Date]":case "[object Boolean]":return+a==+c;case "[object RegExp]":return a.source== -c.source&&a.global==c.global&&a.multiline==c.multiline&&a.ignoreCase==c.ignoreCase}if(typeof a!="object"||typeof c!="object")return false;for(var f=d.length;f--;)if(d[f]==a)return true;d.push(a);var f=0,g=true;if(e=="[object Array]"){if(f=a.length,g=f==c.length)for(;f--;)if(!(g=f in a==f in c&&q(a[f],c[f],d)))break}else{if("constructor"in a!="constructor"in c||a.constructor!=c.constructor)return false;for(var h in a)if(b.has(a,h)&&(f++,!(g=b.has(c,h)&&q(a[h],c[h],d))))break;if(g){for(h in c)if(b.has(c, -h)&&!f--)break;g=!f}}d.pop();return g}var r=this,G=r._,n={},k=Array.prototype,o=Object.prototype,i=k.slice,H=k.unshift,l=o.toString,I=o.hasOwnProperty,w=k.forEach,x=k.map,y=k.reduce,z=k.reduceRight,A=k.filter,B=k.every,C=k.some,p=k.indexOf,D=k.lastIndexOf,o=Array.isArray,J=Object.keys,s=Function.prototype.bind,b=function(a){return new m(a)};if(typeof exports!=="undefined"){if(typeof module!=="undefined"&&module.exports)exports=module.exports=b;exports._=b}else r._=b;b.VERSION="1.3.1";var j=b.each= -b.forEach=function(a,c,d){if(a!=null)if(w&&a.forEach===w)a.forEach(c,d);else if(a.length===+a.length)for(var e=0,f=a.length;e2;a== -null&&(a=[]);if(y&&a.reduce===y)return e&&(c=b.bind(c,e)),f?a.reduce(c,d):a.reduce(c);j(a,function(a,b,i){f?d=c.call(e,d,a,b,i):(d=a,f=true)});if(!f)throw new TypeError("Reduce of empty array with no initial value");return d};b.reduceRight=b.foldr=function(a,c,d,e){var f=arguments.length>2;a==null&&(a=[]);if(z&&a.reduceRight===z)return e&&(c=b.bind(c,e)),f?a.reduceRight(c,d):a.reduceRight(c);var g=b.toArray(a).reverse();e&&!f&&(c=b.bind(c,e));return f?b.reduce(g,c,d,e):b.reduce(g,c)};b.find=b.detect= -function(a,c,b){var e;E(a,function(a,g,h){if(c.call(b,a,g,h))return e=a,true});return e};b.filter=b.select=function(a,c,b){var e=[];if(a==null)return e;if(A&&a.filter===A)return a.filter(c,b);j(a,function(a,g,h){c.call(b,a,g,h)&&(e[e.length]=a)});return e};b.reject=function(a,c,b){var e=[];if(a==null)return e;j(a,function(a,g,h){c.call(b,a,g,h)||(e[e.length]=a)});return e};b.every=b.all=function(a,c,b){var e=true;if(a==null)return e;if(B&&a.every===B)return a.every(c,b);j(a,function(a,g,h){if(!(e= -e&&c.call(b,a,g,h)))return n});return e};var E=b.some=b.any=function(a,c,d){c||(c=b.identity);var e=false;if(a==null)return e;if(C&&a.some===C)return a.some(c,d);j(a,function(a,b,h){if(e||(e=c.call(d,a,b,h)))return n});return!!e};b.include=b.contains=function(a,c){var b=false;if(a==null)return b;return p&&a.indexOf===p?a.indexOf(c)!=-1:b=E(a,function(a){return a===c})};b.invoke=function(a,c){var d=i.call(arguments,2);return b.map(a,function(a){return(b.isFunction(c)?c||a:a[c]).apply(a,d)})};b.pluck= -function(a,c){return b.map(a,function(a){return a[c]})};b.max=function(a,c,d){if(!c&&b.isArray(a))return Math.max.apply(Math,a);if(!c&&b.isEmpty(a))return-Infinity;var e={computed:-Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b>=e.computed&&(e={value:a,computed:b})});return e.value};b.min=function(a,c,d){if(!c&&b.isArray(a))return Math.min.apply(Math,a);if(!c&&b.isEmpty(a))return Infinity;var e={computed:Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;bd?1:0}),"value")};b.groupBy=function(a,c){var d={},e=b.isFunction(c)?c:function(a){return a[c]};j(a,function(a,b){var c=e(a,b);(d[c]||(d[c]=[])).push(a)});return d};b.sortedIndex=function(a, -c,d){d||(d=b.identity);for(var e=0,f=a.length;e>1;d(a[g])=0})})};b.difference=function(a){var c=b.flatten(i.call(arguments,1));return b.filter(a,function(a){return!b.include(c,a)})};b.zip=function(){for(var a=i.call(arguments),c=b.max(b.pluck(a,"length")),d=Array(c),e=0;e=0;d--)b=[a[d].apply(this,b)];return b[0]}}; -b.after=function(a,b){return a<=0?b():function(){if(--a<1)return b.apply(this,arguments)}};b.keys=J||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var c=[],d;for(d in a)b.has(a,d)&&(c[c.length]=d);return c};b.values=function(a){return b.map(a,b.identity)};b.functions=b.methods=function(a){var c=[],d;for(d in a)b.isFunction(a[d])&&c.push(d);return c.sort()};b.extend=function(a){j(i.call(arguments,1),function(b){for(var d in b)a[d]=b[d]});return a};b.defaults=function(a){j(i.call(arguments, -1),function(b){for(var d in b)a[d]==null&&(a[d]=b[d])});return a};b.clone=function(a){return!b.isObject(a)?a:b.isArray(a)?a.slice():b.extend({},a)};b.tap=function(a,b){b(a);return a};b.isEqual=function(a,b){return q(a,b,[])};b.isEmpty=function(a){if(b.isArray(a)||b.isString(a))return a.length===0;for(var c in a)if(b.has(a,c))return false;return true};b.isElement=function(a){return!!(a&&a.nodeType==1)};b.isArray=o||function(a){return l.call(a)=="[object Array]"};b.isObject=function(a){return a===Object(a)}; -b.isArguments=function(a){return l.call(a)=="[object Arguments]"};if(!b.isArguments(arguments))b.isArguments=function(a){return!(!a||!b.has(a,"callee"))};b.isFunction=function(a){return l.call(a)=="[object Function]"};b.isString=function(a){return l.call(a)=="[object String]"};b.isNumber=function(a){return l.call(a)=="[object Number]"};b.isNaN=function(a){return a!==a};b.isBoolean=function(a){return a===true||a===false||l.call(a)=="[object Boolean]"};b.isDate=function(a){return l.call(a)=="[object Date]"}; -b.isRegExp=function(a){return l.call(a)=="[object RegExp]"};b.isNull=function(a){return a===null};b.isUndefined=function(a){return a===void 0};b.has=function(a,b){return I.call(a,b)};b.noConflict=function(){r._=G;return this};b.identity=function(a){return a};b.times=function(a,b,d){for(var e=0;e/g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")};b.mixin=function(a){j(b.functions(a), -function(c){K(c,b[c]=a[c])})};var L=0;b.uniqueId=function(a){var b=L++;return a?a+b:b};b.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var t=/.^/,u=function(a){return a.replace(/\\\\/g,"\\").replace(/\\'/g,"'")};b.template=function(a,c){var d=b.templateSettings,d="var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('"+a.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(d.escape||t,function(a,b){return"',_.escape("+ -u(b)+"),'"}).replace(d.interpolate||t,function(a,b){return"',"+u(b)+",'"}).replace(d.evaluate||t,function(a,b){return"');"+u(b).replace(/[\r\n\t]/g," ")+";__p.push('"}).replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t")+"');}return __p.join('');",e=new Function("obj","_",d);return c?e(c,b):function(a){return e.call(this,a,b)}};b.chain=function(a){return b(a).chain()};var m=function(a){this._wrapped=a};b.prototype=m.prototype;var v=function(a,c){return c?b(a).chain():a},K=function(a,c){m.prototype[a]= -function(){var a=i.call(arguments);H.call(a,this._wrapped);return v(c.apply(b,a),this._chain)}};b.mixin(b);j("pop,push,reverse,shift,sort,splice,unshift".split(","),function(a){var b=k[a];m.prototype[a]=function(){var d=this._wrapped;b.apply(d,arguments);var e=d.length;(a=="shift"||a=="splice")&&e===0&&delete d[0];return v(d,this._chain)}});j(["concat","join","slice"],function(a){var b=k[a];m.prototype[a]=function(){return v(b.apply(this._wrapped,arguments),this._chain)}});m.prototype.chain=function(){this._chain= -true;return this};m.prototype.value=function(){return this._wrapped}}).call(this); +!function(n,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define("underscore",r):(n=n||self,function(){var t=n._,e=n._=r();e.noConflict=function(){return n._=t,e}}())}(this,(function(){ +// Underscore.js 1.12.0 +// https://underscorejs.org +// (c) 2009-2020 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors +// Underscore may be freely distributed under the MIT license. +var n="1.12.0",r="object"==typeof self&&self.self===self&&self||"object"==typeof global&&global.global===global&&global||Function("return this")()||{},t=Array.prototype,e=Object.prototype,u="undefined"!=typeof Symbol?Symbol.prototype:null,o=t.push,i=t.slice,a=e.toString,f=e.hasOwnProperty,c="undefined"!=typeof ArrayBuffer,l="undefined"!=typeof DataView,s=Array.isArray,p=Object.keys,v=Object.create,h=c&&ArrayBuffer.isView,y=isNaN,g=isFinite,d=!{toString:null}.propertyIsEnumerable("toString"),b=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],m=Math.pow(2,53)-1;function j(n,r){return r=null==r?n.length-1:+r,function(){for(var t=Math.max(arguments.length-r,0),e=Array(t),u=0;u=0&&t<=m}}function $(n){return function(r){return null==r?void 0:r[n]}}var G=$("byteLength"),H=J(G),Q=/\[object ((I|Ui)nt(8|16|32)|Float(32|64)|Uint8Clamped|Big(I|Ui)nt64)Array\]/;var X=c?function(n){return h?h(n)&&!q(n):H(n)&&Q.test(a.call(n))}:K(!1),Y=$("length");function Z(n,r){r=function(n){for(var r={},t=n.length,e=0;e":">",'"':""","'":"'","`":"`"},Kn=Ln(Cn),Jn=Ln(_n(Cn)),$n=tn.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g},Gn=/(.)^/,Hn={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},Qn=/\\|'|\r|\n|\u2028|\u2029/g;function Xn(n){return"\\"+Hn[n]}var Yn=0;function Zn(n,r,t,e,u){if(!(e instanceof r))return n.apply(t,u);var o=Mn(n.prototype),i=n.apply(o,u);return _(i)?i:o}var nr=j((function(n,r){var t=nr.placeholder,e=function(){for(var u=0,o=r.length,i=Array(o),a=0;a1)er(a,r-1,t,e),u=e.length;else for(var f=0,c=a.length;f0&&(t=r.apply(this,arguments)),n<=1&&(r=null),t}}var cr=nr(fr,2);function lr(n,r,t){r=qn(r,t);for(var e,u=nn(n),o=0,i=u.length;o0?0:u-1;o>=0&&o0?a=o>=0?o:Math.max(o+f,a):f=o>=0?Math.min(o+1,f):o+f+1;else if(t&&o&&f)return e[o=t(e,u)]===u?o:-1;if(u!=u)return(o=r(i.call(e,a,f),C))>=0?o+a:-1;for(o=n>0?a:f-1;o>=0&&o0?0:i-1;for(u||(e=r[o?o[a]:a],a+=n);a>=0&&a=3;return r(n,Fn(t,u,4),e,o)}}var wr=_r(1),Ar=_r(-1);function xr(n,r,t){var e=[];return r=qn(r,t),mr(n,(function(n,t,u){r(n,t,u)&&e.push(n)})),e}function Sr(n,r,t){r=qn(r,t);for(var e=!tr(n)&&nn(n),u=(e||n).length,o=0;o=0}var Er=j((function(n,r,t){var e,u;return D(r)?u=r:(r=Nn(r),e=r.slice(0,-1),r=r[r.length-1]),jr(n,(function(n){var o=u;if(!o){if(e&&e.length&&(n=In(n,e)),null==n)return;o=n[r]}return null==o?o:o.apply(n,t)}))}));function Br(n,r){return jr(n,Rn(r))}function Nr(n,r,t){var e,u,o=-1/0,i=-1/0;if(null==r||"number"==typeof r&&"object"!=typeof n[0]&&null!=n)for(var a=0,f=(n=tr(n)?n:jn(n)).length;ao&&(o=e);else r=qn(r,t),mr(n,(function(n,t,e){((u=r(n,t,e))>i||u===-1/0&&o===-1/0)&&(o=n,i=u)}));return o}function Ir(n,r,t){if(null==r||t)return tr(n)||(n=jn(n)),n[Wn(n.length-1)];var e=tr(n)?En(n):jn(n),u=Y(e);r=Math.max(Math.min(r,u),0);for(var o=u-1,i=0;i1&&(e=Fn(e,r[1])),r=an(n)):(e=Pr,r=er(r,!1,!1),n=Object(n));for(var u=0,o=r.length;u1&&(t=r[1])):(r=jr(er(r,!1,!1),String),e=function(n,t){return!Mr(r,t)}),qr(n,e,t)}));function Wr(n,r,t){return i.call(n,0,Math.max(0,n.length-(null==r||t?1:r)))}function zr(n,r,t){return null==n||n.length<1?null==r||t?void 0:[]:null==r||t?n[0]:Wr(n,n.length-r)}function Lr(n,r,t){return i.call(n,null==r||t?1:r)}var Cr=j((function(n,r){return r=er(r,!0,!0),xr(n,(function(n){return!Mr(r,n)}))})),Kr=j((function(n,r){return Cr(n,r)}));function Jr(n,r,t,e){A(r)||(e=t,t=r,r=!1),null!=t&&(t=qn(t,e));for(var u=[],o=[],i=0,a=Y(n);ir?(e&&(clearTimeout(e),e=null),a=c,i=n.apply(u,o),e||(u=o=null)):e||!1===t.trailing||(e=setTimeout(f,l)),i};return c.cancel=function(){clearTimeout(e),a=0,e=u=o=null},c},debounce:function(n,r,t){var e,u,o=function(r,t){e=null,t&&(u=n.apply(r,t))},i=j((function(i){if(e&&clearTimeout(e),t){var a=!e;e=setTimeout(o,r),a&&(u=n.apply(this,i))}else e=or(o,r,this,i);return u}));return i.cancel=function(){clearTimeout(e),e=null},i},wrap:function(n,r){return nr(r,n)},negate:ar,compose:function(){var n=arguments,r=n.length-1;return function(){for(var t=r,e=n[r].apply(this,arguments);t--;)e=n[t].call(this,e);return e}},after:function(n,r){return function(){if(--n<1)return r.apply(this,arguments)}},before:fr,once:cr,findKey:lr,findIndex:pr,findLastIndex:vr,sortedIndex:hr,indexOf:gr,lastIndexOf:dr,find:br,detect:br,findWhere:function(n,r){return br(n,Dn(r))},each:mr,forEach:mr,map:jr,collect:jr,reduce:wr,foldl:wr,inject:wr,reduceRight:Ar,foldr:Ar,filter:xr,select:xr,reject:function(n,r,t){return xr(n,ar(qn(r)),t)},every:Sr,all:Sr,some:Or,any:Or,contains:Mr,includes:Mr,include:Mr,invoke:Er,pluck:Br,where:function(n,r){return xr(n,Dn(r))},max:Nr,min:function(n,r,t){var e,u,o=1/0,i=1/0;if(null==r||"number"==typeof r&&"object"!=typeof n[0]&&null!=n)for(var a=0,f=(n=tr(n)?n:jn(n)).length;ae||void 0===t)return 1;if(tsparsify.blueprints.code_samples.pytorch__integration module

                                                                                                                                    sparsify.blueprints.code_samples.pytorch__training module

                                                                                                                                    -sparsify.blueprints.code_samples.pytorch__training.train(working_dir: str, config_path: str, model: torch.nn.modules.module.Module, train_dataset: torch.utils.data.dataset.Dataset, val_dataset: torch.utils.data.dataset.Dataset, batch_size: int, optim_const: Callable[torch.nn.modules.module.Module, torch.optim.optimizer.Optimizer], loss: Union[sparseml.pytorch.utils.loss.LossWrapper, Callable[[Any, Any], torch.Tensor]], devices: str)[source]
                                                                                                                                    +sparsify.blueprints.code_samples.pytorch__training.train(working_dir: str, config_path: str, model: torch.nn.modules.module.Module, train_dataset: torch.utils.data.dataset.Dataset, val_dataset: torch.utils.data.dataset.Dataset, batch_size: int, optim_const: Callable[torch.nn.modules.module.Module, torch.optim.optimizer.Optimizer], loss: Union[sparseml.pytorch.utils.loss.LossWrapper, Callable[[Any, Any], torch.Tensor]], devices: str)[source]

                                                                                                                                    Dataset setup

                                                                                                                                    -sparsify.blueprints.code_samples.pytorch__training.train_setup()[source]
                                                                                                                                    +sparsify.blueprints.code_samples.pytorch__training.train_setup()[source]
                                                                                                                                diff --git a/sparsify/api/sparsify.blueprints.utils.html b/sparsify/api/sparsify.blueprints.utils.html index a4c0a972083..f468e19a5b5 100644 --- a/sparsify/api/sparsify.blueprints.utils.html +++ b/sparsify/api/sparsify.blueprints.utils.html @@ -222,7 +222,7 @@

                                                                                                                                Submodules
                                                                                                                                -exception sparsify.blueprints.utils.helpers.HTTPNotFoundError(*args: object)[source]
                                                                                                                                +exception sparsify.blueprints.utils.helpers.HTTPNotFoundError(*args: object)[source]

                                                                                                                                Bases: Exception

                                                                                                                                Expected error raised when a 404 should be encountered by the user

                                                                                                                              @@ -233,7 +233,7 @@

                                                                                                                              Submodules
                                                                                                                              -sparsify.blueprints.utils.projects.get_project_by_id(project_id: str)sparsify.models.projects.Project[source]
                                                                                                                              +sparsify.blueprints.utils.projects.get_project_by_id(project_id: str)sparsify.models.projects.Project[source]

                                                                                                                              Get a project by its project_id, with project model and project data joined.

                                                                                                                              Parameters
                                                                                                                              @@ -247,7 +247,7 @@

                                                                                                                              Submodules
                                                                                                                              -sparsify.blueprints.utils.projects.get_project_model_by_project_id(project_id: str, raise_not_found: bool = True)sparsify.models.projects_model.ProjectModel[source]
                                                                                                                              +sparsify.blueprints.utils.projects.get_project_model_by_project_id(project_id: str, raise_not_found: bool = True)sparsify.models.projects_model.ProjectModel[source]

                                                                                                                              Get a project model by its project_id

                                                                                                                              Parameters
                                                                                                                              @@ -269,7 +269,7 @@

                                                                                                                              Submodules
                                                                                                                              -sparsify.blueprints.utils.projects_benchmark.get_project_benchmark_by_ids(project_id: str, benchmark_id: str)sparsify.models.projects_benchmark.ProjectBenchmark[source]
                                                                                                                              +sparsify.blueprints.utils.projects_benchmark.get_project_benchmark_by_ids(project_id: str, benchmark_id: str)sparsify.models.projects_benchmark.ProjectBenchmark[source]

                                                                                                                              Get a project benchmark by its project_id and benchmark_id

                                                                                                                              Parameters
                                                                                                                              @@ -290,12 +290,12 @@

                                                                                                                              Submodules
                                                                                                                              -sparsify.blueprints.utils.projects_data.get_project_data_by_ids(project_id: str, data_id: str)sparsify.models.projects_data.ProjectData[source]
                                                                                                                              +sparsify.blueprints.utils.projects_data.get_project_data_by_ids(project_id: str, data_id: str)sparsify.models.projects_data.ProjectData[source]

                                                                                                                              -sparsify.blueprints.utils.projects_data.validate_model_data(data_path: str, model_path: str)[source]
                                                                                                                              +sparsify.blueprints.utils.projects_data.validate_model_data(data_path: str, model_path: str)[source]

                                                                                                                          @@ -304,65 +304,65 @@

                                                                                                                          Submodules
                                                                                                                          -class sparsify.blueprints.utils.projects_optimizations.OptimEpochs(training_epochs, start_epoch, stabilization_epochs, pruning_epochs, fine_tuning_epochs, end_epoch, pruning_start_epoch, pruning_end_epoch, pruning_update_frequency, fine_tuning_start_epoch)
                                                                                                                          +class sparsify.blueprints.utils.projects_optimizations.OptimEpochs(training_epochs, start_epoch, stabilization_epochs, pruning_epochs, fine_tuning_epochs, end_epoch, pruning_start_epoch, pruning_end_epoch, pruning_update_frequency, fine_tuning_start_epoch)

                                                                                                                          Bases: tuple

                                                                                                                          -property end_epoch
                                                                                                                          +property end_epoch

                                                                                                                          Alias for field number 5

                                                                                                                          -property fine_tuning_epochs
                                                                                                                          +property fine_tuning_epochs

                                                                                                                          Alias for field number 4

                                                                                                                          -property fine_tuning_start_epoch
                                                                                                                          +property fine_tuning_start_epoch

                                                                                                                          Alias for field number 9

                                                                                                                          -property pruning_end_epoch
                                                                                                                          +property pruning_end_epoch

                                                                                                                          Alias for field number 7

                                                                                                                          -property pruning_epochs
                                                                                                                          +property pruning_epochs

                                                                                                                          Alias for field number 3

                                                                                                                          -property pruning_start_epoch
                                                                                                                          +property pruning_start_epoch

                                                                                                                          Alias for field number 6

                                                                                                                          -property pruning_update_frequency
                                                                                                                          +property pruning_update_frequency

                                                                                                                          Alias for field number 8

                                                                                                                          -property stabilization_epochs
                                                                                                                          +property stabilization_epochs

                                                                                                                          Alias for field number 2

                                                                                                                          -property start_epoch
                                                                                                                          +property start_epoch

                                                                                                                          Alias for field number 1

                                                                                                                          -property training_epochs
                                                                                                                          +property training_epochs

                                                                                                                          Alias for field number 0

                                                                                                                          @@ -370,7 +370,7 @@

                                                                                                                          Submodules
                                                                                                                          -sparsify.blueprints.utils.projects_optimizations.create_config(project: sparsify.models.projects.Project, optim: sparsify.models.projects_optimizations.ProjectOptimization, framework: str) → str[source]
                                                                                                                          +sparsify.blueprints.utils.projects_optimizations.create_config(project: sparsify.models.projects.Project, optim: sparsify.models.projects_optimizations.ProjectOptimization, framework: str)str[source]

                                                                                                                          Creates a optimization config yaml for a given project and optimization

                                                                                                                          Parameters
                                                                                                                          @@ -385,7 +385,7 @@

                                                                                                                          Submodules
                                                                                                                          -sparsify.blueprints.utils.projects_optimizations.default_epochs_distribution(training_epochs: Union[None, int])sparsify.blueprints.utils.projects_optimizations.OptimEpochs[source]
                                                                                                                          +sparsify.blueprints.utils.projects_optimizations.default_epochs_distribution(training_epochs: Union[None, int])sparsify.blueprints.utils.projects_optimizations.OptimEpochs[source]

                                                                                                                          Create default epochs distribution for optimizing a model given a number of training epochs.

                                                                                                                          @@ -400,7 +400,7 @@

                                                                                                                          Submodules
                                                                                                                          -sparsify.blueprints.utils.projects_optimizations.default_pruning_settings()[source]
                                                                                                                          +sparsify.blueprints.utils.projects_optimizations.default_pruning_settings()[source]
                                                                                                                          Returns

                                                                                                                          the default pruning settings for optimizing a model

                                                                                                                          @@ -410,7 +410,7 @@

                                                                                                                          Submodules
                                                                                                                          -sparsify.blueprints.utils.projects_optimizations.get_profiles_by_id(profile_perf_id: Union[None, str], profile_loss_id: Union[None, str]) → Tuple[sparsify.models.projects_profiles.ProjectPerfProfile, sparsify.models.projects_profiles.ProjectLossProfile][source]
                                                                                                                          +sparsify.blueprints.utils.projects_optimizations.get_profiles_by_id(profile_perf_id: Union[None, str], profile_loss_id: Union[None, str])Tuple[sparsify.models.projects_profiles.ProjectPerfProfile, sparsify.models.projects_profiles.ProjectLossProfile][source]

                                                                                                                          Get a performance and loss profile by their ids. If not found will return None instead of raising not found.

                                                                                                                          @@ -428,7 +428,7 @@

                                                                                                                          Submodules
                                                                                                                          -sparsify.blueprints.utils.projects_optimizations.get_project_optimizer_by_ids(project_id: str, optim_id: str)sparsify.models.projects_optimizations.ProjectOptimization[source]
                                                                                                                          +sparsify.blueprints.utils.projects_optimizations.get_project_optimizer_by_ids(project_id: str, optim_id: str)sparsify.models.projects_optimizations.ProjectOptimization[source]

                                                                                                                          Get a project optimizer by its project_id and optim_id

                                                                                                                          Parameters
                                                                                                                          @@ -445,7 +445,7 @@

                                                                                                                          Submodules
                                                                                                                          -sparsify.blueprints.utils.projects_optimizations.optim_lr_sched_default_mods(training_init_lr: Optional[float], training_final_lr: Optional[float], start_epoch: Optional[float], start_fine_tuning_epoch: Optional[float], end_epoch: Optional[float]) → List[Dict[str, Any]][source]
                                                                                                                          +sparsify.blueprints.utils.projects_optimizations.optim_lr_sched_default_mods(training_init_lr: Optional[float], training_final_lr: Optional[float], start_epoch: Optional[float], start_fine_tuning_epoch: Optional[float], end_epoch: Optional[float])List[Dict[str, Any]][source]

                                                                                                                          Default modifiers for an LR schedule for pruning a model. If training_init_lr is set, adds a set LR modifier. If training_init_lr and training_final_lr are set, adds a step LR modifier.

                                                                                                                          @@ -467,7 +467,7 @@

                                                                                                                          Submodules
                                                                                                                          -sparsify.blueprints.utils.projects_optimizations.optim_lr_sched_updater(lr_sched: sparsify.models.projects_optimizations.ProjectOptimizationModifierLRSchedule, lr_mods: Union[None, List[Dict[str, Any]]] = None, global_start_epoch: Union[None, float] = None, global_end_epoch: Union[None, float] = None)[source]
                                                                                                                          +sparsify.blueprints.utils.projects_optimizations.optim_lr_sched_updater(lr_sched: sparsify.models.projects_optimizations.ProjectOptimizationModifierLRSchedule, lr_mods: Union[None, List[Dict[str, Any]]] = None, global_start_epoch: Union[None, float] = None, global_end_epoch: Union[None, float] = None)[source]

                                                                                                                          Update an LR schedule DB model. Will always update schedule level details from the contained lr_mods

                                                                                                                          @@ -486,7 +486,7 @@

                                                                                                                          Submodules
                                                                                                                          -sparsify.blueprints.utils.projects_optimizations.optim_pruning_updater(pruning: sparsify.models.projects_optimizations.ProjectOptimizationModifierPruning, start_epoch: Union[None, float] = None, end_epoch: Union[None, float] = None, update_frequency: Union[None, float] = None, pruning_settings: Optional[sparsify.blueprints.utils.projects_optimizations_pruning.PruningSettings] = None, mask_type: Optional[str] = None, sparsity: Union[None, float] = None, balance_perf_loss: Union[None, float] = None, filter_min_sparsity: Union[None, float] = None, filter_min_perf_gain: Union[None, float] = None, filter_min_recovery: Union[None, float] = None, nodes: Union[None, List[Dict[str, Any]]] = None, model: Union[None, sparsify.models.projects_model.ProjectModel] = None, profile_perf: Union[None, sparsify.models.projects_profiles.ProjectPerfProfile] = None, profile_loss: Union[None, sparsify.models.projects_profiles.ProjectLossProfile] = None, global_start_epoch: Union[None, float] = None, global_end_epoch: Union[None, float] = None)[source]
                                                                                                                          +sparsify.blueprints.utils.projects_optimizations.optim_pruning_updater(pruning: sparsify.models.projects_optimizations.ProjectOptimizationModifierPruning, start_epoch: Union[None, float] = None, end_epoch: Union[None, float] = None, update_frequency: Union[None, float] = None, pruning_settings: Optional[sparsify.blueprints.utils.projects_optimizations_pruning.PruningSettings] = None, mask_type: Optional[str] = None, sparsity: Union[None, float] = None, balance_perf_loss: Union[None, float] = None, filter_min_sparsity: Union[None, float] = None, filter_min_perf_gain: Union[None, float] = None, filter_min_recovery: Union[None, float] = None, nodes: Union[None, List[Dict[str, Any]]] = None, model: Union[None, sparsify.models.projects_model.ProjectModel] = None, profile_perf: Union[None, sparsify.models.projects_profiles.ProjectPerfProfile] = None, profile_loss: Union[None, sparsify.models.projects_profiles.ProjectLossProfile] = None, global_start_epoch: Union[None, float] = None, global_end_epoch: Union[None, float] = None)[source]

                                                                                                                          Update a pruning DB model

                                                                                                                          Parameters
                                                                                                                          @@ -524,7 +524,7 @@

                                                                                                                          Submodules
                                                                                                                          -sparsify.blueprints.utils.projects_optimizations.optim_trainable_default_nodes(default_trainable: bool, model_analysis: Dict, node_overrides: Union[None, List[Dict[str, Any]]] = None) → List[Dict[str, Any]][source]
                                                                                                                          +sparsify.blueprints.utils.projects_optimizations.optim_trainable_default_nodes(default_trainable: bool, model_analysis: Dict, node_overrides: Union[None, List[Dict[str, Any]]] = None)List[Dict[str, Any]][source]

                                                                                                                          Create the default trainable nodes for optimizing a model. Creates a node for all prunable nodes in the model with trainable set to default_trainable.

                                                                                                                          @@ -545,7 +545,7 @@

                                                                                                                          Submodules
                                                                                                                          -sparsify.blueprints.utils.projects_optimizations.optim_trainable_updater(trainable: sparsify.models.projects_optimizations.ProjectOptimizationModifierTrainable, analysis: Dict[str, List], start_epoch: Union[None, float] = None, end_epoch: Union[None, float] = None, nodes: Union[None, List[Dict[str, Any]]] = None, default_trainable: Union[None, bool] = None, global_start_epoch: Union[None, float] = None, global_end_epoch: Union[None, float] = None)[source]
                                                                                                                          +sparsify.blueprints.utils.projects_optimizations.optim_trainable_updater(trainable: sparsify.models.projects_optimizations.ProjectOptimizationModifierTrainable, analysis: Dict[str, List], start_epoch: Union[None, float] = None, end_epoch: Union[None, float] = None, nodes: Union[None, List[Dict[str, Any]]] = None, default_trainable: Union[None, bool] = None, global_start_epoch: Union[None, float] = None, global_end_epoch: Union[None, float] = None)[source]

                                                                                                                          Update a trainable DB model

                                                                                                                          Parameters
                                                                                                                          @@ -567,7 +567,7 @@

                                                                                                                          Submodules
                                                                                                                          -sparsify.blueprints.utils.projects_optimizations.optim_updater(optim: sparsify.models.projects_optimizations.ProjectOptimization, name: Optional[str] = None, profile_perf: Union[None, sparsify.models.projects_profiles.ProjectPerfProfile] = - 1, profile_loss: Union[None, sparsify.models.projects_profiles.ProjectLossProfile] = - 1, start_epoch: Union[None, float] = None, end_epoch: Union[None, float] = None, mod_start_epoch: Union[None, float] = None, mod_end_epoch: Union[None, float] = None)[source]
                                                                                                                          +sparsify.blueprints.utils.projects_optimizations.optim_updater(optim: sparsify.models.projects_optimizations.ProjectOptimization, name: Optional[str] = None, profile_perf: Union[None, sparsify.models.projects_profiles.ProjectPerfProfile] = - 1, profile_loss: Union[None, sparsify.models.projects_profiles.ProjectLossProfile] = - 1, start_epoch: Union[None, float] = None, end_epoch: Union[None, float] = None, mod_start_epoch: Union[None, float] = None, mod_end_epoch: Union[None, float] = None)[source]

                                                                                                                          Update an optim DB model

                                                                                                                          Parameters
                                                                                                                          @@ -589,7 +589,7 @@

                                                                                                                          Submodules
                                                                                                                          -sparsify.blueprints.utils.projects_optimizations.optim_validate_and_get_project_by_id(project_id: str)sparsify.models.projects.Project[source]
                                                                                                                          +sparsify.blueprints.utils.projects_optimizations.optim_validate_and_get_project_by_id(project_id: str)sparsify.models.projects.Project[source]

                                                                                                                          Get a project by project id and validate that it is setup correctly for optims. Raises not found errors for no project and validation errors for no project model, and no project analysis.

                                                                                                                          @@ -605,12 +605,12 @@

                                                                                                                          Submodules
                                                                                                                          -sparsify.blueprints.utils.projects_optimizations.sparse_training_available(project: sparsify.models.projects.Project)[source]
                                                                                                                          +sparsify.blueprints.utils.projects_optimizations.sparse_training_available(project: sparsify.models.projects.Project)[source]

                                                                                                                          -sparsify.blueprints.utils.projects_optimizations.validate_pruning_nodes(project: sparsify.models.projects.Project, nodes: List[Dict[str, Any]])[source]
                                                                                                                          +sparsify.blueprints.utils.projects_optimizations.validate_pruning_nodes(project: sparsify.models.projects.Project, nodes: List[Dict[str, Any]])[source]

                                                                                                                          Validate a list of given nodes are prunable in the model. Raises a validation error if nodes are set that are not prunable.

                                                                                                                          @@ -630,7 +630,7 @@

                                                                                                                          Submodules
                                                                                                                          -class sparsify.blueprints.utils.projects_optimizations_pruning.PruningModelEvaluator(model_analysis: Dict, perf_analysis: Union[None, Dict], loss_analysis: Union[None, Dict])[source]
                                                                                                                          +class sparsify.blueprints.utils.projects_optimizations_pruning.PruningModelEvaluator(model_analysis: Dict, perf_analysis: Union[None, Dict], loss_analysis: Union[None, Dict])[source]

                                                                                                                          Bases: object

                                                                                                                          Evaluator for a model for pruning. Able to estimate the effect of pruning on a model and each prunable node in a model @@ -646,17 +646,17 @@

                                                                                                                          Submodules
                                                                                                                          -EVAL_SENSITIVITY_SPARSITY = 0.95
                                                                                                                          +EVAL_SENSITIVITY_SPARSITY = 0.95

                                                                                                                          -MAX_NODE_SPARSITY = 0.95
                                                                                                                          +MAX_NODE_SPARSITY = 0.95
                                                                                                                          -apply_node_overrides(node_overrides: List[Dict[str, Any]])[source]
                                                                                                                          +apply_node_overrides(node_overrides: List[Dict[str, Any]])[source]

                                                                                                                          Apply any node override sparsity levels to the current evaluated nodes. Must be called after eval_pruning if eval_pruning is invoked at all to have any effect.

                                                                                                                          @@ -669,7 +669,7 @@

                                                                                                                          Submodules
                                                                                                                          -eval_baseline(baseline_sparsity: float)[source]
                                                                                                                          +eval_baseline(baseline_sparsity: float)[source]

                                                                                                                          Evaluate the baseline (no performance data, only loss) recommended sparsities to assign for each node to best maximize recovery.

                                                                                                                          @@ -681,7 +681,7 @@

                                                                                                                          Submodules
                                                                                                                          -eval_pruning(settings: sparsify.blueprints.utils.projects_optimizations_pruning.PruningSettings)[source]
                                                                                                                          +eval_pruning(settings: sparsify.blueprints.utils.projects_optimizations_pruning.PruningSettings)[source]

                                                                                                                          Evaluate the model to assign the evaluate sparsity levels for each node in the model given the input pruning settings.

                                                                                                                          @@ -693,7 +693,7 @@

                                                                                                                          Submodules
                                                                                                                          -to_dict_values() → Tuple[List[Dict[str, Any]], Dict[str, Any]][source]
                                                                                                                          +to_dict_values()Tuple[List[Dict[str, Any]], Dict[str, Any]][source]

                                                                                                                          Create the dictionary values containing the recommended sparsity levels for pruning and their estimated times. eval_baseline and (eval_pruning and/or apply_node_overrides) @@ -709,41 +709,41 @@

                                                                                                                          Submodules
                                                                                                                          -class sparsify.blueprints.utils.projects_optimizations_pruning.PruningSettings(mask_type, sparsity, balance_perf_loss, filter_min_sparsity, filter_min_perf_gain, filter_min_recovery)
                                                                                                                          +class sparsify.blueprints.utils.projects_optimizations_pruning.PruningSettings(mask_type, sparsity, balance_perf_loss, filter_min_sparsity, filter_min_perf_gain, filter_min_recovery)

                                                                                                                          Bases: tuple

                                                                                                                          -property balance_perf_loss
                                                                                                                          +property balance_perf_loss

                                                                                                                          Alias for field number 2

                                                                                                                          -property filter_min_perf_gain
                                                                                                                          +property filter_min_perf_gain

                                                                                                                          Alias for field number 4

                                                                                                                          -property filter_min_recovery
                                                                                                                          +property filter_min_recovery

                                                                                                                          Alias for field number 5

                                                                                                                          -property filter_min_sparsity
                                                                                                                          +property filter_min_sparsity

                                                                                                                          Alias for field number 3

                                                                                                                          -property mask_type
                                                                                                                          +property mask_type

                                                                                                                          Alias for field number 0

                                                                                                                          -property sparsity
                                                                                                                          +property sparsity

                                                                                                                          Alias for field number 1

                                                                                                                          diff --git a/sparsify/api/sparsify.html b/sparsify/api/sparsify.html index 4dbadd236e7..e8d20609eb0 100644 --- a/sparsify/api/sparsify.html +++ b/sparsify/api/sparsify.html @@ -293,12 +293,12 @@

                                                                                                                          Submodules

                                                                                                                          sparsify.app module

                                                                                                                          -sparsify.app.main()[source]
                                                                                                                          +sparsify.app.main()[source]
                                                                                                                          -sparsify.app.run(working_dir: str, host: str, port: int, debug: bool, logging_level: str, ui_path: Optional[str])[source]
                                                                                                                          +sparsify.app.run(working_dir: str, host: str, port: int, debug: bool, logging_level: str, ui_path: Optional[str])[source]

                                                                                                                        @@ -307,7 +307,7 @@

                                                                                                                        Submodules
                                                                                                                        -sparsify.log.get_main_logger() → logging.Logger[source]
                                                                                                                        +sparsify.log.get_main_logger()logging.Logger[source]
                                                                                                                        Returns

                                                                                                                        a main logger that can be used in external scripts for logging @@ -318,7 +318,7 @@

                                                                                                                        Submodules
                                                                                                                        -sparsify.log.get_root_logger() → logging.Logger[source]
                                                                                                                        +sparsify.log.get_root_logger()logging.Logger[source]
                                                                                                                        Returns

                                                                                                                        the logger used for the sparsify root package that all @@ -329,7 +329,7 @@

                                                                                                                        Submodules
                                                                                                                        -sparsify.log.set_logging_level(level: int)[source]
                                                                                                                        +sparsify.log.set_logging_level(level: int)[source]

                                                                                                                        Set the logging level for the MAIN and ROOT loggers along with all loggers created in the sparsify namespace

                                                                                                                        diff --git a/sparsify/api/sparsify.models.html b/sparsify/api/sparsify.models.html index 1f0aa68a6ec..9e042949060 100644 --- a/sparsify/api/sparsify.models.html +++ b/sparsify/api/sparsify.models.html @@ -217,56 +217,56 @@

                                                                                                                        Submodules
                                                                                                                        -class sparsify.models.base.BaseCreatedModifiedModel(*args, **kwargs)[source]
                                                                                                                        +class sparsify.models.base.BaseCreatedModifiedModel(*args, **kwargs)[source]

                                                                                                                        Bases: sparsify.models.base.BaseModel

                                                                                                                        Base peewee model that includes created and modified timestamp functionality

                                                                                                                        -DoesNotExist
                                                                                                                        +DoesNotExist

                                                                                                                        alias of sparsify.models.base.BaseCreatedModifiedModelDoesNotExist

                                                                                                                        -created = <DateTimeField: BaseCreatedModifiedModel.created>
                                                                                                                        +created = <DateTimeField: BaseCreatedModifiedModel.created>
                                                                                                                        -id = <AutoField: BaseCreatedModifiedModel.id>
                                                                                                                        +id = <AutoField: BaseCreatedModifiedModel.id>
                                                                                                                        -modified = <DateTimeField: BaseCreatedModifiedModel.modified>
                                                                                                                        +modified = <DateTimeField: BaseCreatedModifiedModel.modified>
                                                                                                                        -save(*args, **kwargs)[source]
                                                                                                                        +save(*args, **kwargs)[source]

                                                                                                                        -class sparsify.models.base.BaseModel(*args, **kwargs)[source]
                                                                                                                        +class sparsify.models.base.BaseModel(*args, **kwargs)[source]

                                                                                                                        Bases: peewee.Model

                                                                                                                        Base peewee model all DB models must extend from

                                                                                                                        -DoesNotExist
                                                                                                                        +DoesNotExist

                                                                                                                        alias of sparsify.models.base.BaseModelDoesNotExist

                                                                                                                        -id = <AutoField: BaseModel.id>
                                                                                                                        +id = <AutoField: BaseModel.id>
                                                                                                                        -refresh()[source]
                                                                                                                        +refresh()[source]

                                                                                                                        Refresh the data for the model instance from the DB

                                                                                                                        @@ -274,55 +274,55 @@

                                                                                                                        Submodules
                                                                                                                        -class sparsify.models.base.CSVField(null=False, index=False, unique=False, column_name=None, default=None, primary_key=False, constraints=None, sequence=None, collation=None, unindexed=False, choices=None, help_text=None, verbose_name=None, index_type=None, db_column=None, _hidden=False)[source]
                                                                                                                        +class sparsify.models.base.CSVField(null=False, index=False, unique=False, column_name=None, default=None, primary_key=False, constraints=None, sequence=None, collation=None, unindexed=False, choices=None, help_text=None, verbose_name=None, index_type=None, db_column=None, _hidden=False)[source]

                                                                                                                        Bases: peewee.TextField

                                                                                                                        CSV field for handling lists of strings in a peewee database

                                                                                                                        -db_value(value)[source]
                                                                                                                        +db_value(value)[source]
                                                                                                                        -python_value(value)[source]
                                                                                                                        +python_value(value)[source]

                                                                                                                        -class sparsify.models.base.CSVFloatField(null=False, index=False, unique=False, column_name=None, default=None, primary_key=False, constraints=None, sequence=None, collation=None, unindexed=False, choices=None, help_text=None, verbose_name=None, index_type=None, db_column=None, _hidden=False)[source]
                                                                                                                        +class sparsify.models.base.CSVFloatField(null=False, index=False, unique=False, column_name=None, default=None, primary_key=False, constraints=None, sequence=None, collation=None, unindexed=False, choices=None, help_text=None, verbose_name=None, index_type=None, db_column=None, _hidden=False)[source]

                                                                                                                        Bases: sparsify.models.base.CSVField

                                                                                                                        CSV field for handling lists of floats in a peewee database

                                                                                                                        -python_value(value)[source]
                                                                                                                        +python_value(value)[source]
                                                                                                                        -class sparsify.models.base.CSVIntField(null=False, index=False, unique=False, column_name=None, default=None, primary_key=False, constraints=None, sequence=None, collation=None, unindexed=False, choices=None, help_text=None, verbose_name=None, index_type=None, db_column=None, _hidden=False)[source]
                                                                                                                        +class sparsify.models.base.CSVIntField(null=False, index=False, unique=False, column_name=None, default=None, primary_key=False, constraints=None, sequence=None, collation=None, unindexed=False, choices=None, help_text=None, verbose_name=None, index_type=None, db_column=None, _hidden=False)[source]

                                                                                                                        Bases: sparsify.models.base.CSVField

                                                                                                                        CSV field for handling lists of integers in a peewee database

                                                                                                                        -python_value(value)[source]
                                                                                                                        +python_value(value)[source]
                                                                                                                        -class sparsify.models.base.FileStorage[source]
                                                                                                                        +class sparsify.models.base.FileStorage[source]

                                                                                                                        Bases: object

                                                                                                                        Class for handling local file storage and the path that is located at. Used for storing large files that would not be good in the DB such as model and data files.

                                                                                                                        -init(root_path: str)[source]
                                                                                                                        +init(root_path: str)[source]

                                                                                                                        Initialize the file storage class for a given path

                                                                                                                        Parameters
                                                                                                                        @@ -334,7 +334,7 @@

                                                                                                                        Submodules
                                                                                                                        -property root_path
                                                                                                                        +property root_path

                                                                                                                        the root path on the local file system for where to store files

                                                                                                                        Type
                                                                                                                        @@ -347,17 +347,17 @@

                                                                                                                        Submodules
                                                                                                                        -class sparsify.models.base.ListObjField(json_dumps=None, json_loads=None, **kwargs)[source]
                                                                                                                        +class sparsify.models.base.ListObjField(json_dumps=None, json_loads=None, **kwargs)[source]

                                                                                                                        Bases: playhouse.sqlite_ext.JSONField

                                                                                                                        Field for handling lists of objects in a peewee database

                                                                                                                        -db_value(value)[source]
                                                                                                                        +db_value(value)[source]
                                                                                                                        -python_value(value)[source]
                                                                                                                        +python_value(value)[source]

                                                                                                                        @@ -368,158 +368,158 @@

                                                                                                                        Submodules
                                                                                                                        -class sparsify.models.jobs.Job(*args, **kwargs)[source]
                                                                                                                        +class sparsify.models.jobs.Job(*args, **kwargs)[source]

                                                                                                                        Bases: sparsify.models.base.BaseModel

                                                                                                                        DB model for a project’s job.

                                                                                                                        -DoesNotExist
                                                                                                                        +DoesNotExist

                                                                                                                        alias of sparsify.models.jobs.JobDoesNotExist

                                                                                                                        -baseprojectprofile_set
                                                                                                                        +baseprojectprofile_set
                                                                                                                        -created = <DateTimeField: Job.created>
                                                                                                                        +created = <DateTimeField: Job.created>
                                                                                                                        -error = <TextField: Job.error>
                                                                                                                        +error = <TextField: Job.error>
                                                                                                                        -job_id = <CharField: Job.job_id>
                                                                                                                        +job_id = <CharField: Job.job_id>
                                                                                                                        -modified = <DateTimeField: Job.modified>
                                                                                                                        +modified = <DateTimeField: Job.modified>
                                                                                                                        -progress = <JSONField: Job.progress>
                                                                                                                        +progress = <JSONField: Job.progress>
                                                                                                                        -project_id = <CharField: Job.project_id>
                                                                                                                        +project_id = <CharField: Job.project_id>
                                                                                                                        -projectbenchmark_set
                                                                                                                        +projectbenchmark_set
                                                                                                                        -projectdata_set
                                                                                                                        +projectdata_set
                                                                                                                        -projectlossprofile_set
                                                                                                                        +projectlossprofile_set
                                                                                                                        -projectmodel_set
                                                                                                                        +projectmodel_set
                                                                                                                        -projectperfprofile_set
                                                                                                                        +projectperfprofile_set
                                                                                                                        -save(*args, **kwargs)[source]
                                                                                                                        +save(*args, **kwargs)[source]

                                                                                                                        Override for peewee save function to update the modified date

                                                                                                                        -status = <JobStatusField: Job.status>
                                                                                                                        +status = <JobStatusField: Job.status>
                                                                                                                        -type_ = <CharField: Job.type_>
                                                                                                                        +type_ = <CharField: Job.type_>
                                                                                                                        -worker_ack = <BooleanField: Job.worker_ack>
                                                                                                                        +worker_ack = <BooleanField: Job.worker_ack>
                                                                                                                        -worker_args = <JSONField: Job.worker_args>
                                                                                                                        +worker_args = <JSONField: Job.worker_args>

                                                                                                                        -class sparsify.models.jobs.JobStatus(value)[source]
                                                                                                                        +class sparsify.models.jobs.JobStatus(value)[source]

                                                                                                                        Bases: enum.Enum

                                                                                                                        Enumerator class for tracking the status of jobs

                                                                                                                        -canceled = 'canceled'
                                                                                                                        +canceled = 'canceled'
                                                                                                                        -canceling = 'canceling'
                                                                                                                        +canceling = 'canceling'
                                                                                                                        -completed = 'completed'
                                                                                                                        +completed = 'completed'
                                                                                                                        -error = 'error'
                                                                                                                        +error = 'error'
                                                                                                                        -pending = 'pending'
                                                                                                                        +pending = 'pending'
                                                                                                                        -started = 'started'
                                                                                                                        +started = 'started'
                                                                                                                        -class sparsify.models.jobs.JobStatusField(null=False, index=False, unique=False, column_name=None, default=None, primary_key=False, constraints=None, sequence=None, collation=None, unindexed=False, choices=None, help_text=None, verbose_name=None, index_type=None, db_column=None, _hidden=False)[source]
                                                                                                                        +class sparsify.models.jobs.JobStatusField(null=False, index=False, unique=False, column_name=None, default=None, primary_key=False, constraints=None, sequence=None, collation=None, unindexed=False, choices=None, help_text=None, verbose_name=None, index_type=None, db_column=None, _hidden=False)[source]

                                                                                                                        Bases: peewee.Field

                                                                                                                        peewee DB field for saving and loading JobStatus from the database

                                                                                                                        -db_value(value: sparsify.models.jobs.JobStatus)[source]
                                                                                                                        +db_value(value: sparsify.models.jobs.JobStatus)[source]
                                                                                                                        -field_type = 'VARCHAR'
                                                                                                                        +field_type = 'VARCHAR'
                                                                                                                        -python_value(value: str)[source]
                                                                                                                        +python_value(value: str)[source]
                                                                                                                        @@ -530,34 +530,34 @@

                                                                                                                        Submodules
                                                                                                                        -class sparsify.models.projects.BaseProjectModel(*args, **kwargs)[source]
                                                                                                                        +class sparsify.models.projects.BaseProjectModel(*args, **kwargs)[source]

                                                                                                                        Bases: sparsify.models.base.BaseModel

                                                                                                                        -DoesNotExist
                                                                                                                        +DoesNotExist

                                                                                                                        alias of sparsify.models.projects.BaseProjectModelDoesNotExist

                                                                                                                        -abstract delete_filesystem()[source]
                                                                                                                        +abstract delete_filesystem()[source]

                                                                                                                        Delete the state from the local file system

                                                                                                                        -id = <AutoField: BaseProjectModel.id>
                                                                                                                        +id = <AutoField: BaseProjectModel.id>
                                                                                                                        -abstract setup_filesystem()[source]
                                                                                                                        +abstract setup_filesystem()[source]

                                                                                                                        Setup the local file system so that it can be used with the data

                                                                                                                        -abstract validate_filesystem()[source]
                                                                                                                        +abstract validate_filesystem()[source]

                                                                                                                        Validate that the local file system and expected files are correct and exist

                                                                                                                        @@ -565,46 +565,46 @@

                                                                                                                        Submodules
                                                                                                                        -class sparsify.models.projects.Project(*args, **kwargs)[source]
                                                                                                                        +class sparsify.models.projects.Project(*args, **kwargs)[source]

                                                                                                                        Bases: sparsify.models.projects.BaseProjectModel

                                                                                                                        DB model for a project’s data file. A project may have multiple data files stored in the DB.

                                                                                                                        -DoesNotExist
                                                                                                                        +DoesNotExist

                                                                                                                        alias of sparsify.models.projects.ProjectDoesNotExist

                                                                                                                        -benchmarks
                                                                                                                        +benchmarks
                                                                                                                        -created = <DateTimeField: Project.created>
                                                                                                                        +created = <DateTimeField: Project.created>
                                                                                                                        -data
                                                                                                                        +data
                                                                                                                        -delete_filesystem()[source]
                                                                                                                        +delete_filesystem()[source]

                                                                                                                        Delete the folder from the local file system containing all of the files for the project

                                                                                                                        -description = <TextField: Project.description>
                                                                                                                        +description = <TextField: Project.description>
                                                                                                                        -property dir_path
                                                                                                                        +property dir_path

                                                                                                                        the local directory path for where project’s files are stored

                                                                                                                        Type
                                                                                                                        @@ -615,81 +615,81 @@

                                                                                                                        Submodules
                                                                                                                        -property dir_size
                                                                                                                        +property dir_size

                                                                                                                        Size of the folder on the local file system containing all of the files for the project

                                                                                                                        -models
                                                                                                                        +models
                                                                                                                        -modified = <DateTimeField: Project.modified>
                                                                                                                        +modified = <DateTimeField: Project.modified>
                                                                                                                        -name = <TextField: Project.name>
                                                                                                                        +name = <TextField: Project.name>
                                                                                                                        -optims
                                                                                                                        +optims
                                                                                                                        -profiles_loss
                                                                                                                        +profiles_loss
                                                                                                                        -profiles_perf
                                                                                                                        +profiles_perf
                                                                                                                        -project_id = <CharField: Project.project_id>
                                                                                                                        +project_id = <CharField: Project.project_id>
                                                                                                                        -save(*args, **kwargs)[source]
                                                                                                                        +save(*args, **kwargs)[source]

                                                                                                                        Override for peewee save function to update the modified date

                                                                                                                        -setup_filesystem()[source]
                                                                                                                        +setup_filesystem()[source]

                                                                                                                        Setup the local file system so that it can be used with the data

                                                                                                                        -training_epochs = <IntegerField: Project.training_epochs>
                                                                                                                        +training_epochs = <IntegerField: Project.training_epochs>
                                                                                                                        -training_lr_final = <FloatField: Project.training_lr_final>
                                                                                                                        +training_lr_final = <FloatField: Project.training_lr_final>
                                                                                                                        -training_lr_init = <FloatField: Project.training_lr_init>
                                                                                                                        +training_lr_init = <FloatField: Project.training_lr_init>
                                                                                                                        -training_optimizer = <TextField: Project.training_optimizer>
                                                                                                                        +training_optimizer = <TextField: Project.training_optimizer>
                                                                                                                        -validate_filesystem()[source]
                                                                                                                        +validate_filesystem()[source]

                                                                                                                        Validate that the local file system and expected files are correct and exist

                                                                                                                        @@ -701,93 +701,93 @@

                                                                                                                        Submodules
                                                                                                                        -class sparsify.models.projects_benchmark.ProjectBenchmark(*args, **kwargs)[source]
                                                                                                                        +class sparsify.models.projects_benchmark.ProjectBenchmark(*args, **kwargs)[source]

                                                                                                                        Bases: sparsify.models.base.BaseCreatedModifiedModel

                                                                                                                        DB model for a project’s benchmark

                                                                                                                        -DoesNotExist
                                                                                                                        +DoesNotExist

                                                                                                                        alias of sparsify.models.projects_benchmark.ProjectBenchmarkDoesNotExist

                                                                                                                        -batch_sizes = <JSONField: ProjectBenchmark.batch_sizes>
                                                                                                                        +batch_sizes = <JSONField: ProjectBenchmark.batch_sizes>
                                                                                                                        -benchmark_id = <CharField: ProjectBenchmark.benchmark_id>
                                                                                                                        +benchmark_id = <CharField: ProjectBenchmark.benchmark_id>
                                                                                                                        -core_counts = <JSONField: ProjectBenchmark.core_counts>
                                                                                                                        +core_counts = <JSONField: ProjectBenchmark.core_counts>
                                                                                                                        -created = <DateTimeField: ProjectBenchmark.created>
                                                                                                                        +created = <DateTimeField: ProjectBenchmark.created>
                                                                                                                        -inference_models = <ListObjField: ProjectBenchmark.inference_models>
                                                                                                                        +inference_models = <ListObjField: ProjectBenchmark.inference_models>
                                                                                                                        -instruction_sets = <JSONField: ProjectBenchmark.instruction_sets>
                                                                                                                        +instruction_sets = <JSONField: ProjectBenchmark.instruction_sets>
                                                                                                                        -iterations_per_check = <IntegerField: ProjectBenchmark.iterations_per_check>
                                                                                                                        +iterations_per_check = <IntegerField: ProjectBenchmark.iterations_per_check>
                                                                                                                        -job = <ForeignKeyField: ProjectBenchmark.job>
                                                                                                                        +job = <ForeignKeyField: ProjectBenchmark.job>
                                                                                                                        -job_id = <ForeignKeyField: ProjectBenchmark.job>
                                                                                                                        +job_id = <ForeignKeyField: ProjectBenchmark.job>
                                                                                                                        -modified = <DateTimeField: ProjectBenchmark.modified>
                                                                                                                        +modified = <DateTimeField: ProjectBenchmark.modified>
                                                                                                                        -name = <TextField: ProjectBenchmark.name>
                                                                                                                        +name = <TextField: ProjectBenchmark.name>
                                                                                                                        -project = <ForeignKeyField: ProjectBenchmark.project>
                                                                                                                        +project = <ForeignKeyField: ProjectBenchmark.project>
                                                                                                                        -project_id = <ForeignKeyField: ProjectBenchmark.project>
                                                                                                                        +project_id = <ForeignKeyField: ProjectBenchmark.project>
                                                                                                                        -result = <JSONField: ProjectBenchmark.result>
                                                                                                                        +result = <JSONField: ProjectBenchmark.result>
                                                                                                                        -source = <TextField: ProjectBenchmark.source>
                                                                                                                        +source = <TextField: ProjectBenchmark.source>
                                                                                                                        -warmup_iterations_per_check = <IntegerField: ProjectBenchmark.warmup_iterations_per_check>
                                                                                                                        +warmup_iterations_per_check = <IntegerField: ProjectBenchmark.warmup_iterations_per_check>

                                                                                                                        @@ -798,35 +798,35 @@

                                                                                                                        Submodules
                                                                                                                        -class sparsify.models.projects_data.ProjectData(*args, **kwargs)[source]
                                                                                                                        +class sparsify.models.projects_data.ProjectData(*args, **kwargs)[source]

                                                                                                                        Bases: sparsify.models.projects.BaseProjectModel

                                                                                                                        DB model for a project’s data file. A project may have multiple data files stored in the DB.

                                                                                                                        -DoesNotExist
                                                                                                                        +DoesNotExist

                                                                                                                        alias of sparsify.models.projects_data.ProjectDataDoesNotExist

                                                                                                                        -created = <DateTimeField: ProjectData.created>
                                                                                                                        +created = <DateTimeField: ProjectData.created>
                                                                                                                        -data_id = <CharField: ProjectData.data_id>
                                                                                                                        +data_id = <CharField: ProjectData.data_id>
                                                                                                                        -delete_filesystem()[source]
                                                                                                                        +delete_filesystem()[source]

                                                                                                                        Delete the data file from the local file system

                                                                                                                        -property dir_path
                                                                                                                        +property dir_path

                                                                                                                        the local directory path for where the data is stored

                                                                                                                        Type
                                                                                                                        @@ -837,12 +837,12 @@

                                                                                                                        Submodules
                                                                                                                        -file = <TextField: ProjectData.file>
                                                                                                                        +file = <TextField: ProjectData.file>

                                                                                                                        -property file_path
                                                                                                                        +property file_path

                                                                                                                        the local file path to the data file

                                                                                                                        Type
                                                                                                                        @@ -853,38 +853,38 @@

                                                                                                                        Submodules
                                                                                                                        -job = <ForeignKeyField: ProjectData.job>
                                                                                                                        +job = <ForeignKeyField: ProjectData.job>

                                                                                                                        -job_id = <ForeignKeyField: ProjectData.job>
                                                                                                                        +job_id = <ForeignKeyField: ProjectData.job>
                                                                                                                        -project = <ForeignKeyField: ProjectData.project>
                                                                                                                        +project = <ForeignKeyField: ProjectData.project>
                                                                                                                        -project_id = <ForeignKeyField: ProjectData.project>
                                                                                                                        +project_id = <ForeignKeyField: ProjectData.project>
                                                                                                                        -setup_filesystem()[source]
                                                                                                                        +setup_filesystem()[source]

                                                                                                                        Setup the local file system so that it can be used with the data

                                                                                                                        -source = <TextField: ProjectData.source>
                                                                                                                        +source = <TextField: ProjectData.source>
                                                                                                                        -validate_filesystem()[source]
                                                                                                                        +validate_filesystem()[source]

                                                                                                                        Validate that the local file system and expected files are correct and exist

                                                                                                                        @@ -896,35 +896,35 @@

                                                                                                                        Submodules
                                                                                                                        -class sparsify.models.projects_model.ProjectModel(*args, **kwargs)[source]
                                                                                                                        +class sparsify.models.projects_model.ProjectModel(*args, **kwargs)[source]

                                                                                                                        Bases: sparsify.models.projects.BaseProjectModel

                                                                                                                        DB model for a project’s model file. A project must have only one model file stored in the DB.

                                                                                                                        -DoesNotExist
                                                                                                                        +DoesNotExist

                                                                                                                        alias of sparsify.models.projects_model.ProjectModelDoesNotExist

                                                                                                                        -analysis = <JSONField: ProjectModel.analysis>
                                                                                                                        +analysis = <JSONField: ProjectModel.analysis>
                                                                                                                        -created = <DateTimeField: ProjectModel.created>
                                                                                                                        +created = <DateTimeField: ProjectModel.created>
                                                                                                                        -delete_filesystem()[source]
                                                                                                                        +delete_filesystem()[source]

                                                                                                                        Delete the model file from the local file system

                                                                                                                        -property dir_path
                                                                                                                        +property dir_path

                                                                                                                        the local directory path for where the model file is stored

                                                                                                                        Type
                                                                                                                        @@ -935,12 +935,12 @@

                                                                                                                        Submodules
                                                                                                                        -file = <TextField: ProjectModel.file>
                                                                                                                        +file = <TextField: ProjectModel.file>

                                                                                                                        -property file_path
                                                                                                                        +property file_path

                                                                                                                        the local file path to the data file

                                                                                                                        Type
                                                                                                                        @@ -951,43 +951,43 @@

                                                                                                                        Submodules
                                                                                                                        -job = <ForeignKeyField: ProjectModel.job>
                                                                                                                        +job = <ForeignKeyField: ProjectModel.job>

                                                                                                                        -job_id = <ForeignKeyField: ProjectModel.job>
                                                                                                                        +job_id = <ForeignKeyField: ProjectModel.job>
                                                                                                                        -model_id = <CharField: ProjectModel.model_id>
                                                                                                                        +model_id = <CharField: ProjectModel.model_id>
                                                                                                                        -project = <ForeignKeyField: ProjectModel.project>
                                                                                                                        +project = <ForeignKeyField: ProjectModel.project>
                                                                                                                        -project_id = <ForeignKeyField: ProjectModel.project>
                                                                                                                        +project_id = <ForeignKeyField: ProjectModel.project>
                                                                                                                        -setup_filesystem()[source]
                                                                                                                        +setup_filesystem()[source]

                                                                                                                        Setup the local file system so that it can be used with the data

                                                                                                                        -source = <TextField: ProjectModel.source>
                                                                                                                        +source = <TextField: ProjectModel.source>
                                                                                                                        -validate_filesystem()[source]
                                                                                                                        +validate_filesystem()[source]

                                                                                                                        Validate that the local file system and expected files are correct and exist

                                                                                                                        @@ -999,496 +999,496 @@

                                                                                                                        Submodules
                                                                                                                        -class sparsify.models.projects_optimizations.ProjectOptimization(*args, **kwargs)[source]
                                                                                                                        +class sparsify.models.projects_optimizations.ProjectOptimization(*args, **kwargs)[source]

                                                                                                                        Bases: sparsify.models.base.BaseCreatedModifiedModel

                                                                                                                        DB model for a project’s optimization (stores modifier settings). A project may have multiple optimizations stored in the DB.

                                                                                                                        -DoesNotExist
                                                                                                                        +DoesNotExist

                                                                                                                        alias of sparsify.models.projects_optimizations.ProjectOptimizationDoesNotExist

                                                                                                                        -created = <DateTimeField: ProjectOptimization.created>
                                                                                                                        +created = <DateTimeField: ProjectOptimization.created>
                                                                                                                        -end_epoch = <FloatField: ProjectOptimization.end_epoch>
                                                                                                                        +end_epoch = <FloatField: ProjectOptimization.end_epoch>
                                                                                                                        -lr_schedule_modifiers
                                                                                                                        +lr_schedule_modifiers
                                                                                                                        -modified = <DateTimeField: ProjectOptimization.modified>
                                                                                                                        +modified = <DateTimeField: ProjectOptimization.modified>
                                                                                                                        -name = <TextField: ProjectOptimization.name>
                                                                                                                        +name = <TextField: ProjectOptimization.name>
                                                                                                                        -notes = <TextField: ProjectOptimization.notes>
                                                                                                                        +notes = <TextField: ProjectOptimization.notes>
                                                                                                                        -optim_id = <CharField: ProjectOptimization.optim_id>
                                                                                                                        +optim_id = <CharField: ProjectOptimization.optim_id>
                                                                                                                        -profile_loss = <ForeignKeyField: ProjectOptimization.profile_loss>
                                                                                                                        +profile_loss = <ForeignKeyField: ProjectOptimization.profile_loss>
                                                                                                                        -profile_loss_id = <ForeignKeyField: ProjectOptimization.profile_loss>
                                                                                                                        +profile_loss_id = <ForeignKeyField: ProjectOptimization.profile_loss>
                                                                                                                        -profile_perf = <ForeignKeyField: ProjectOptimization.profile_perf>
                                                                                                                        +profile_perf = <ForeignKeyField: ProjectOptimization.profile_perf>
                                                                                                                        -profile_perf_id = <ForeignKeyField: ProjectOptimization.profile_perf>
                                                                                                                        +profile_perf_id = <ForeignKeyField: ProjectOptimization.profile_perf>
                                                                                                                        -project = <ForeignKeyField: ProjectOptimization.project>
                                                                                                                        +project = <ForeignKeyField: ProjectOptimization.project>
                                                                                                                        -project_id = <ForeignKeyField: ProjectOptimization.project>
                                                                                                                        +project_id = <ForeignKeyField: ProjectOptimization.project>
                                                                                                                        -pruning_modifiers
                                                                                                                        +pruning_modifiers
                                                                                                                        -quantization_modifiers
                                                                                                                        +quantization_modifiers
                                                                                                                        -start_epoch = <FloatField: ProjectOptimization.start_epoch>
                                                                                                                        +start_epoch = <FloatField: ProjectOptimization.start_epoch>
                                                                                                                        -trainable_modifiers
                                                                                                                        +trainable_modifiers

                                                                                                                        -class sparsify.models.projects_optimizations.ProjectOptimizationModifierLRSchedule(*args, **kwargs)[source]
                                                                                                                        +class sparsify.models.projects_optimizations.ProjectOptimizationModifierLRSchedule(*args, **kwargs)[source]

                                                                                                                        Bases: sparsify.models.base.BaseCreatedModifiedModel

                                                                                                                        DB model for a project’s learning rate schedule modifier.

                                                                                                                        -DoesNotExist
                                                                                                                        +DoesNotExist

                                                                                                                        alias of sparsify.models.projects_optimizations.ProjectOptimizationModifierLRScheduleDoesNotExist

                                                                                                                        -created = <DateTimeField: ProjectOptimizationModifierLRSchedule.created>
                                                                                                                        +created = <DateTimeField: ProjectOptimizationModifierLRSchedule.created>
                                                                                                                        -end_epoch = <FloatField: ProjectOptimizationModifierLRSchedule.end_epoch>
                                                                                                                        +end_epoch = <FloatField: ProjectOptimizationModifierLRSchedule.end_epoch>
                                                                                                                        -final_lr = <FloatField: ProjectOptimizationModifierLRSchedule.final_lr>
                                                                                                                        +final_lr = <FloatField: ProjectOptimizationModifierLRSchedule.final_lr>
                                                                                                                        -init_lr = <FloatField: ProjectOptimizationModifierLRSchedule.init_lr>
                                                                                                                        +init_lr = <FloatField: ProjectOptimizationModifierLRSchedule.init_lr>
                                                                                                                        -lr_mods = <ListObjField: ProjectOptimizationModifierLRSchedule.lr_mods>
                                                                                                                        +lr_mods = <ListObjField: ProjectOptimizationModifierLRSchedule.lr_mods>
                                                                                                                        -modified = <DateTimeField: ProjectOptimizationModifierLRSchedule.modified>
                                                                                                                        +modified = <DateTimeField: ProjectOptimizationModifierLRSchedule.modified>
                                                                                                                        -modifier_id = <CharField: ProjectOptimizationModifierLRSchedule.modifier_id>
                                                                                                                        +modifier_id = <CharField: ProjectOptimizationModifierLRSchedule.modifier_id>
                                                                                                                        -optim = <ForeignKeyField: ProjectOptimizationModifierLRSchedule.optim>
                                                                                                                        +optim = <ForeignKeyField: ProjectOptimizationModifierLRSchedule.optim>
                                                                                                                        -optim_id = <ForeignKeyField: ProjectOptimizationModifierLRSchedule.optim>
                                                                                                                        +optim_id = <ForeignKeyField: ProjectOptimizationModifierLRSchedule.optim>
                                                                                                                        -start_epoch = <FloatField: ProjectOptimizationModifierLRSchedule.start_epoch>
                                                                                                                        +start_epoch = <FloatField: ProjectOptimizationModifierLRSchedule.start_epoch>
                                                                                                                        -class sparsify.models.projects_optimizations.ProjectOptimizationModifierPruning(*args, **kwargs)[source]
                                                                                                                        +class sparsify.models.projects_optimizations.ProjectOptimizationModifierPruning(*args, **kwargs)[source]

                                                                                                                        Bases: sparsify.models.base.BaseCreatedModifiedModel

                                                                                                                        DB model for a project’s optimization pruning modifier.

                                                                                                                        -DoesNotExist
                                                                                                                        +DoesNotExist

                                                                                                                        alias of sparsify.models.projects_optimizations.ProjectOptimizationModifierPruningDoesNotExist

                                                                                                                        -balance_perf_loss = <FloatField: ProjectOptimizationModifierPruning.balance_perf_loss>
                                                                                                                        +balance_perf_loss = <FloatField: ProjectOptimizationModifierPruning.balance_perf_loss>
                                                                                                                        -compression = <FloatField: ProjectOptimizationModifierPruning.compression>
                                                                                                                        +compression = <FloatField: ProjectOptimizationModifierPruning.compression>
                                                                                                                        -created = <DateTimeField: ProjectOptimizationModifierPruning.created>
                                                                                                                        +created = <DateTimeField: ProjectOptimizationModifierPruning.created>
                                                                                                                        -end_epoch = <FloatField: ProjectOptimizationModifierPruning.end_epoch>
                                                                                                                        +end_epoch = <FloatField: ProjectOptimizationModifierPruning.end_epoch>
                                                                                                                        -est_loss_sensitivity = <FloatField: ProjectOptimizationModifierPruning.est_loss_sensitivity>
                                                                                                                        +est_loss_sensitivity = <FloatField: ProjectOptimizationModifierPruning.est_loss_sensitivity>
                                                                                                                        -est_perf_sensitivity = <FloatField: ProjectOptimizationModifierPruning.est_perf_sensitivity>
                                                                                                                        +est_perf_sensitivity = <FloatField: ProjectOptimizationModifierPruning.est_perf_sensitivity>
                                                                                                                        -est_recovery = <FloatField: ProjectOptimizationModifierPruning.est_recovery>
                                                                                                                        +est_recovery = <FloatField: ProjectOptimizationModifierPruning.est_recovery>
                                                                                                                        -est_time = <FloatField: ProjectOptimizationModifierPruning.est_time>
                                                                                                                        +est_time = <FloatField: ProjectOptimizationModifierPruning.est_time>
                                                                                                                        -est_time_baseline = <FloatField: ProjectOptimizationModifierPruning.est_time_baseline>
                                                                                                                        +est_time_baseline = <FloatField: ProjectOptimizationModifierPruning.est_time_baseline>
                                                                                                                        -est_time_gain = <FloatField: ProjectOptimizationModifierPruning.est_time_gain>
                                                                                                                        +est_time_gain = <FloatField: ProjectOptimizationModifierPruning.est_time_gain>
                                                                                                                        -filter_min_perf_gain = <FloatField: ProjectOptimizationModifierPruning.filter_min_perf_gain>
                                                                                                                        +filter_min_perf_gain = <FloatField: ProjectOptimizationModifierPruning.filter_min_perf_gain>
                                                                                                                        -filter_min_recovery = <FloatField: ProjectOptimizationModifierPruning.filter_min_recovery>
                                                                                                                        +filter_min_recovery = <FloatField: ProjectOptimizationModifierPruning.filter_min_recovery>
                                                                                                                        -filter_min_sparsity = <FloatField: ProjectOptimizationModifierPruning.filter_min_sparsity>
                                                                                                                        +filter_min_sparsity = <FloatField: ProjectOptimizationModifierPruning.filter_min_sparsity>
                                                                                                                        -flops = <FloatField: ProjectOptimizationModifierPruning.flops>
                                                                                                                        +flops = <FloatField: ProjectOptimizationModifierPruning.flops>
                                                                                                                        -flops_baseline = <FloatField: ProjectOptimizationModifierPruning.flops_baseline>
                                                                                                                        +flops_baseline = <FloatField: ProjectOptimizationModifierPruning.flops_baseline>
                                                                                                                        -flops_gain = <FloatField: ProjectOptimizationModifierPruning.flops_gain>
                                                                                                                        +flops_gain = <FloatField: ProjectOptimizationModifierPruning.flops_gain>
                                                                                                                        -mask_type = <TextField: ProjectOptimizationModifierPruning.mask_type>
                                                                                                                        +mask_type = <TextField: ProjectOptimizationModifierPruning.mask_type>
                                                                                                                        -modified = <DateTimeField: ProjectOptimizationModifierPruning.modified>
                                                                                                                        +modified = <DateTimeField: ProjectOptimizationModifierPruning.modified>
                                                                                                                        -modifier_id = <CharField: ProjectOptimizationModifierPruning.modifier_id>
                                                                                                                        +modifier_id = <CharField: ProjectOptimizationModifierPruning.modifier_id>
                                                                                                                        -nodes = <ListObjField: ProjectOptimizationModifierPruning.nodes>
                                                                                                                        +nodes = <ListObjField: ProjectOptimizationModifierPruning.nodes>
                                                                                                                        -optim = <ForeignKeyField: ProjectOptimizationModifierPruning.optim>
                                                                                                                        +optim = <ForeignKeyField: ProjectOptimizationModifierPruning.optim>
                                                                                                                        -optim_id = <ForeignKeyField: ProjectOptimizationModifierPruning.optim>
                                                                                                                        +optim_id = <ForeignKeyField: ProjectOptimizationModifierPruning.optim>
                                                                                                                        -params = <FloatField: ProjectOptimizationModifierPruning.params>
                                                                                                                        +params = <FloatField: ProjectOptimizationModifierPruning.params>
                                                                                                                        -params_baseline = <FloatField: ProjectOptimizationModifierPruning.params_baseline>
                                                                                                                        +params_baseline = <FloatField: ProjectOptimizationModifierPruning.params_baseline>
                                                                                                                        -sparsity = <FloatField: ProjectOptimizationModifierPruning.sparsity>
                                                                                                                        +sparsity = <FloatField: ProjectOptimizationModifierPruning.sparsity>
                                                                                                                        -start_epoch = <FloatField: ProjectOptimizationModifierPruning.start_epoch>
                                                                                                                        +start_epoch = <FloatField: ProjectOptimizationModifierPruning.start_epoch>
                                                                                                                        -update_frequency = <FloatField: ProjectOptimizationModifierPruning.update_frequency>
                                                                                                                        +update_frequency = <FloatField: ProjectOptimizationModifierPruning.update_frequency>
                                                                                                                        -class sparsify.models.projects_optimizations.ProjectOptimizationModifierQuantization(*args, **kwargs)[source]
                                                                                                                        +class sparsify.models.projects_optimizations.ProjectOptimizationModifierQuantization(*args, **kwargs)[source]

                                                                                                                        Bases: sparsify.models.base.BaseCreatedModifiedModel

                                                                                                                        DB model for a project’s optimization quantization modifier.

                                                                                                                        -DoesNotExist
                                                                                                                        +DoesNotExist

                                                                                                                        alias of sparsify.models.projects_optimizations.ProjectOptimizationModifierQuantizationDoesNotExist

                                                                                                                        -balance_perf_loss = <FloatField: ProjectOptimizationModifierQuantization.balance_perf_loss>
                                                                                                                        +balance_perf_loss = <FloatField: ProjectOptimizationModifierQuantization.balance_perf_loss>
                                                                                                                        -compression = <FloatField: ProjectOptimizationModifierQuantization.compression>
                                                                                                                        +compression = <FloatField: ProjectOptimizationModifierQuantization.compression>
                                                                                                                        -created = <DateTimeField: ProjectOptimizationModifierQuantization.created>
                                                                                                                        +created = <DateTimeField: ProjectOptimizationModifierQuantization.created>
                                                                                                                        -end_epoch = <FloatField: ProjectOptimizationModifierQuantization.end_epoch>
                                                                                                                        +end_epoch = <FloatField: ProjectOptimizationModifierQuantization.end_epoch>
                                                                                                                        -est_loss_sensitivity = <FloatField: ProjectOptimizationModifierQuantization.est_loss_sensitivity>
                                                                                                                        +est_loss_sensitivity = <FloatField: ProjectOptimizationModifierQuantization.est_loss_sensitivity>
                                                                                                                        -est_perf_sensitivity = <FloatField: ProjectOptimizationModifierQuantization.est_perf_sensitivity>
                                                                                                                        +est_perf_sensitivity = <FloatField: ProjectOptimizationModifierQuantization.est_perf_sensitivity>
                                                                                                                        -est_recovery = <FloatField: ProjectOptimizationModifierQuantization.est_recovery>
                                                                                                                        +est_recovery = <FloatField: ProjectOptimizationModifierQuantization.est_recovery>
                                                                                                                        -est_time = <FloatField: ProjectOptimizationModifierQuantization.est_time>
                                                                                                                        +est_time = <FloatField: ProjectOptimizationModifierQuantization.est_time>
                                                                                                                        -est_time_baseline = <FloatField: ProjectOptimizationModifierQuantization.est_time_baseline>
                                                                                                                        +est_time_baseline = <FloatField: ProjectOptimizationModifierQuantization.est_time_baseline>
                                                                                                                        -est_time_gain = <FloatField: ProjectOptimizationModifierQuantization.est_time_gain>
                                                                                                                        +est_time_gain = <FloatField: ProjectOptimizationModifierQuantization.est_time_gain>
                                                                                                                        -filter_min_perf_gain = <FloatField: ProjectOptimizationModifierQuantization.filter_min_perf_gain>
                                                                                                                        +filter_min_perf_gain = <FloatField: ProjectOptimizationModifierQuantization.filter_min_perf_gain>
                                                                                                                        -filter_min_recovery = <FloatField: ProjectOptimizationModifierQuantization.filter_min_recovery>
                                                                                                                        +filter_min_recovery = <FloatField: ProjectOptimizationModifierQuantization.filter_min_recovery>
                                                                                                                        -flops = <FloatField: ProjectOptimizationModifierQuantization.flops>
                                                                                                                        +flops = <FloatField: ProjectOptimizationModifierQuantization.flops>
                                                                                                                        -flops_baseline = <FloatField: ProjectOptimizationModifierQuantization.flops_baseline>
                                                                                                                        +flops_baseline = <FloatField: ProjectOptimizationModifierQuantization.flops_baseline>
                                                                                                                        -flops_gain = <FloatField: ProjectOptimizationModifierQuantization.flops_gain>
                                                                                                                        +flops_gain = <FloatField: ProjectOptimizationModifierQuantization.flops_gain>
                                                                                                                        -level = <TextField: ProjectOptimizationModifierQuantization.level>
                                                                                                                        +level = <TextField: ProjectOptimizationModifierQuantization.level>
                                                                                                                        -modified = <DateTimeField: ProjectOptimizationModifierQuantization.modified>
                                                                                                                        +modified = <DateTimeField: ProjectOptimizationModifierQuantization.modified>
                                                                                                                        -modifier_id = <CharField: ProjectOptimizationModifierQuantization.modifier_id>
                                                                                                                        +modifier_id = <CharField: ProjectOptimizationModifierQuantization.modifier_id>
                                                                                                                        -nodes = <ListObjField: ProjectOptimizationModifierQuantization.nodes>
                                                                                                                        +nodes = <ListObjField: ProjectOptimizationModifierQuantization.nodes>
                                                                                                                        -optim = <ForeignKeyField: ProjectOptimizationModifierQuantization.optim>
                                                                                                                        +optim = <ForeignKeyField: ProjectOptimizationModifierQuantization.optim>
                                                                                                                        -optim_id = <ForeignKeyField: ProjectOptimizationModifierQuantization.optim>
                                                                                                                        +optim_id = <ForeignKeyField: ProjectOptimizationModifierQuantization.optim>
                                                                                                                        -params = <FloatField: ProjectOptimizationModifierQuantization.params>
                                                                                                                        +params = <FloatField: ProjectOptimizationModifierQuantization.params>
                                                                                                                        -params_baseline = <FloatField: ProjectOptimizationModifierQuantization.params_baseline>
                                                                                                                        +params_baseline = <FloatField: ProjectOptimizationModifierQuantization.params_baseline>
                                                                                                                        -start_epoch = <FloatField: ProjectOptimizationModifierQuantization.start_epoch>
                                                                                                                        +start_epoch = <FloatField: ProjectOptimizationModifierQuantization.start_epoch>
                                                                                                                        -class sparsify.models.projects_optimizations.ProjectOptimizationModifierTrainable(*args, **kwargs)[source]
                                                                                                                        +class sparsify.models.projects_optimizations.ProjectOptimizationModifierTrainable(*args, **kwargs)[source]

                                                                                                                        Bases: sparsify.models.base.BaseCreatedModifiedModel

                                                                                                                        DB model for a project’s optimization trainable modifier.

                                                                                                                        -DoesNotExist
                                                                                                                        +DoesNotExist

                                                                                                                        alias of sparsify.models.projects_optimizations.ProjectOptimizationModifierTrainableDoesNotExist

                                                                                                                        -created = <DateTimeField: ProjectOptimizationModifierTrainable.created>
                                                                                                                        +created = <DateTimeField: ProjectOptimizationModifierTrainable.created>
                                                                                                                        -end_epoch = <FloatField: ProjectOptimizationModifierTrainable.end_epoch>
                                                                                                                        +end_epoch = <FloatField: ProjectOptimizationModifierTrainable.end_epoch>
                                                                                                                        -modified = <DateTimeField: ProjectOptimizationModifierTrainable.modified>
                                                                                                                        +modified = <DateTimeField: ProjectOptimizationModifierTrainable.modified>
                                                                                                                        -modifier_id = <CharField: ProjectOptimizationModifierTrainable.modifier_id>
                                                                                                                        +modifier_id = <CharField: ProjectOptimizationModifierTrainable.modifier_id>
                                                                                                                        -nodes = <ListObjField: ProjectOptimizationModifierTrainable.nodes>
                                                                                                                        +nodes = <ListObjField: ProjectOptimizationModifierTrainable.nodes>
                                                                                                                        -optim = <ForeignKeyField: ProjectOptimizationModifierTrainable.optim>
                                                                                                                        +optim = <ForeignKeyField: ProjectOptimizationModifierTrainable.optim>
                                                                                                                        -optim_id = <ForeignKeyField: ProjectOptimizationModifierTrainable.optim>
                                                                                                                        +optim_id = <ForeignKeyField: ProjectOptimizationModifierTrainable.optim>
                                                                                                                        -start_epoch = <FloatField: ProjectOptimizationModifierTrainable.start_epoch>
                                                                                                                        +start_epoch = <FloatField: ProjectOptimizationModifierTrainable.start_epoch>
                                                                                                                        @@ -1499,236 +1499,236 @@

                                                                                                                        Submodules
                                                                                                                        -class sparsify.models.projects_profiles.BaseProjectProfile(*args, **kwargs)[source]
                                                                                                                        +class sparsify.models.projects_profiles.BaseProjectProfile(*args, **kwargs)[source]

                                                                                                                        Bases: sparsify.models.base.BaseModel

                                                                                                                        Base DB model for project’s profiles such as loss and perf

                                                                                                                        -DoesNotExist
                                                                                                                        +DoesNotExist

                                                                                                                        alias of sparsify.models.projects_profiles.BaseProjectProfileDoesNotExist

                                                                                                                        -analysis = <JSONField: BaseProjectProfile.analysis>
                                                                                                                        +analysis = <JSONField: BaseProjectProfile.analysis>
                                                                                                                        -created = <DateTimeField: BaseProjectProfile.created>
                                                                                                                        +created = <DateTimeField: BaseProjectProfile.created>
                                                                                                                        -job = <ForeignKeyField: BaseProjectProfile.job>
                                                                                                                        +job = <ForeignKeyField: BaseProjectProfile.job>
                                                                                                                        -job_id = <ForeignKeyField: BaseProjectProfile.job>
                                                                                                                        +job_id = <ForeignKeyField: BaseProjectProfile.job>
                                                                                                                        -name = <TextField: BaseProjectProfile.name>
                                                                                                                        +name = <TextField: BaseProjectProfile.name>
                                                                                                                        -profile_id = <CharField: BaseProjectProfile.profile_id>
                                                                                                                        +profile_id = <CharField: BaseProjectProfile.profile_id>
                                                                                                                        -source = <TextField: BaseProjectProfile.source>
                                                                                                                        +source = <TextField: BaseProjectProfile.source>

                                                                                                                        -class sparsify.models.projects_profiles.ProjectLossProfile(*args, **kwargs)[source]
                                                                                                                        +class sparsify.models.projects_profiles.ProjectLossProfile(*args, **kwargs)[source]

                                                                                                                        Bases: sparsify.models.projects_profiles.BaseProjectProfile

                                                                                                                        DB model for a project’s loss profile. A project may have multiple loss profiles stored in the DB.

                                                                                                                        -DoesNotExist
                                                                                                                        +DoesNotExist

                                                                                                                        alias of sparsify.models.projects_profiles.ProjectLossProfileDoesNotExist

                                                                                                                        -analysis = <JSONField: ProjectLossProfile.analysis>
                                                                                                                        +analysis = <JSONField: ProjectLossProfile.analysis>
                                                                                                                        -created = <DateTimeField: ProjectLossProfile.created>
                                                                                                                        +created = <DateTimeField: ProjectLossProfile.created>
                                                                                                                        -job = <ForeignKeyField: ProjectLossProfile.job>
                                                                                                                        +job = <ForeignKeyField: ProjectLossProfile.job>
                                                                                                                        -job_id = <ForeignKeyField: ProjectLossProfile.job>
                                                                                                                        +job_id = <ForeignKeyField: ProjectLossProfile.job>
                                                                                                                        -name = <TextField: ProjectLossProfile.name>
                                                                                                                        +name = <TextField: ProjectLossProfile.name>
                                                                                                                        -profile_id = <CharField: ProjectLossProfile.profile_id>
                                                                                                                        +profile_id = <CharField: ProjectLossProfile.profile_id>
                                                                                                                        -project = <ForeignKeyField: ProjectLossProfile.project>
                                                                                                                        +project = <ForeignKeyField: ProjectLossProfile.project>
                                                                                                                        -project_id = <ForeignKeyField: ProjectLossProfile.project>
                                                                                                                        +project_id = <ForeignKeyField: ProjectLossProfile.project>
                                                                                                                        -projectoptimization_set
                                                                                                                        +projectoptimization_set
                                                                                                                        -pruning_estimation_type = <TextField: ProjectLossProfile.pruning_estimation_type>
                                                                                                                        +pruning_estimation_type = <TextField: ProjectLossProfile.pruning_estimation_type>
                                                                                                                        -pruning_estimations = <BooleanField: ProjectLossProfile.pruning_estimations>
                                                                                                                        +pruning_estimations = <BooleanField: ProjectLossProfile.pruning_estimations>
                                                                                                                        -pruning_structure = <TextField: ProjectLossProfile.pruning_structure>
                                                                                                                        +pruning_structure = <TextField: ProjectLossProfile.pruning_structure>
                                                                                                                        -quantized_estimation_type = <TextField: ProjectLossProfile.quantized_estimation_type>
                                                                                                                        +quantized_estimation_type = <TextField: ProjectLossProfile.quantized_estimation_type>
                                                                                                                        -quantized_estimations = <BooleanField: ProjectLossProfile.quantized_estimations>
                                                                                                                        +quantized_estimations = <BooleanField: ProjectLossProfile.quantized_estimations>
                                                                                                                        -source = <TextField: ProjectLossProfile.source>
                                                                                                                        +source = <TextField: ProjectLossProfile.source>
                                                                                                                        -class sparsify.models.projects_profiles.ProjectPerfProfile(*args, **kwargs)[source]
                                                                                                                        +class sparsify.models.projects_profiles.ProjectPerfProfile(*args, **kwargs)[source]

                                                                                                                        Bases: sparsify.models.projects_profiles.BaseProjectProfile

                                                                                                                        DB model for a project’s performance profile. A project may have multiple perf profiles stored in the DB

                                                                                                                        -DoesNotExist
                                                                                                                        +DoesNotExist

                                                                                                                        alias of sparsify.models.projects_profiles.ProjectPerfProfileDoesNotExist

                                                                                                                        -analysis = <JSONField: ProjectPerfProfile.analysis>
                                                                                                                        +analysis = <JSONField: ProjectPerfProfile.analysis>
                                                                                                                        -batch_size = <IntegerField: ProjectPerfProfile.batch_size>
                                                                                                                        +batch_size = <IntegerField: ProjectPerfProfile.batch_size>
                                                                                                                        -core_count = <IntegerField: ProjectPerfProfile.core_count>
                                                                                                                        +core_count = <IntegerField: ProjectPerfProfile.core_count>
                                                                                                                        -created = <DateTimeField: ProjectPerfProfile.created>
                                                                                                                        +created = <DateTimeField: ProjectPerfProfile.created>
                                                                                                                        -instruction_sets = <CSVField: ProjectPerfProfile.instruction_sets>
                                                                                                                        +instruction_sets = <CSVField: ProjectPerfProfile.instruction_sets>
                                                                                                                        -iterations_per_check = <IntegerField: ProjectPerfProfile.iterations_per_check>
                                                                                                                        +iterations_per_check = <IntegerField: ProjectPerfProfile.iterations_per_check>
                                                                                                                        -job = <ForeignKeyField: ProjectPerfProfile.job>
                                                                                                                        +job = <ForeignKeyField: ProjectPerfProfile.job>
                                                                                                                        -job_id = <ForeignKeyField: ProjectPerfProfile.job>
                                                                                                                        +job_id = <ForeignKeyField: ProjectPerfProfile.job>
                                                                                                                        -name = <TextField: ProjectPerfProfile.name>
                                                                                                                        +name = <TextField: ProjectPerfProfile.name>
                                                                                                                        -profile_id = <CharField: ProjectPerfProfile.profile_id>
                                                                                                                        +profile_id = <CharField: ProjectPerfProfile.profile_id>
                                                                                                                        -project = <ForeignKeyField: ProjectPerfProfile.project>
                                                                                                                        +project = <ForeignKeyField: ProjectPerfProfile.project>
                                                                                                                        -project_id = <ForeignKeyField: ProjectPerfProfile.project>
                                                                                                                        +project_id = <ForeignKeyField: ProjectPerfProfile.project>
                                                                                                                        -projectoptimization_set
                                                                                                                        +projectoptimization_set
                                                                                                                        -pruning_estimations = <BooleanField: ProjectPerfProfile.pruning_estimations>
                                                                                                                        +pruning_estimations = <BooleanField: ProjectPerfProfile.pruning_estimations>
                                                                                                                        -quantized_estimations = <BooleanField: ProjectPerfProfile.quantized_estimations>
                                                                                                                        +quantized_estimations = <BooleanField: ProjectPerfProfile.quantized_estimations>
                                                                                                                        -source = <TextField: ProjectPerfProfile.source>
                                                                                                                        +source = <TextField: ProjectPerfProfile.source>
                                                                                                                        -warmup_iterations_per_check = <IntegerField: ProjectPerfProfile.warmup_iterations_per_check>
                                                                                                                        +warmup_iterations_per_check = <IntegerField: ProjectPerfProfile.warmup_iterations_per_check>
                                                                                                                        @@ -1738,7 +1738,7 @@

                                                                                                                        Submodules

                                                                                                                        sparsify.models.utils module

                                                                                                                        -sparsify.models.utils.database_setup(working_dir: str, app: Optional[flask.app.Flask] = None)[source]
                                                                                                                        +sparsify.models.utils.database_setup(working_dir: str, app: Optional[flask.app.Flask] = None)[source]

                                                                                                                    diff --git a/sparsify/api/sparsify.schemas.html b/sparsify/api/sparsify.schemas.html index 08ffd2d704c..37dc61415be 100644 --- a/sparsify/api/sparsify.schemas.html +++ b/sparsify/api/sparsify.schemas.html @@ -219,12 +219,12 @@

                                                                                                                    Submodules
                                                                                                                    -class sparsify.schemas.errors.ErrorSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.errors.ErrorSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Error schema to return in the event of an error encountered while running the app

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>

                                                                                                                    @@ -235,7 +235,7 @@

                                                                                                                    Submodules
                                                                                                                    -class sparsify.schemas.helpers.EnumField(enum_class: Any, *args, **kwargs)[source]
                                                                                                                    +class sparsify.schemas.helpers.EnumField(enum_class: Any, *args, **kwargs)[source]

                                                                                                                    Bases: marshmallow.fields.String

                                                                                                                    Custom schema field for handling serializing and deserializing enums

                                                                                                                    @@ -249,7 +249,7 @@

                                                                                                                    Submodules
                                                                                                                    -deserialize(value: Any, attr: Optional[str] = None, data: Optional[Mapping[str, Any]] = None, **kwargs)[source]
                                                                                                                    +deserialize(value: Any, attr: Optional[str] = None, data: Optional[Mapping[str, Any]] = None, **kwargs)[source]

                                                                                                                    Deserialize value.

                                                                                                                    Parameters
                                                                                                                    @@ -271,7 +271,7 @@

                                                                                                                    Submodules
                                                                                                                    -sparsify.schemas.helpers.data_dump_and_validation(schema: marshmallow.schema.Schema, data: Any) → Dict[source]
                                                                                                                    +sparsify.schemas.helpers.data_dump_and_validation(schema: marshmallow.schema.Schema, data: Any)Dict[source]

                                                                                                                    Use a marshmallow schema to dump and validate input data

                                                                                                                    Parameters
                                                                                                                    @@ -292,60 +292,60 @@

                                                                                                                    Submodules
                                                                                                                    -class sparsify.schemas.jobs.JobProgressSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.jobs.JobProgressSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for the progress of a Job object, used in the workers to report progress

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>

                                                                                                                    -class sparsify.schemas.jobs.JobSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.jobs.JobSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for a job object as stored in the DB and returned in the server routes

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.jobs.ResponseJobSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.jobs.ResponseJobSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for returning a response with a single job

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.jobs.ResponseJobsSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.jobs.ResponseJobsSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for returning a response with multiple jobs

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.jobs.SearchJobsSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.jobs.SearchJobsSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Expected schema to use for querying jobs

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    @@ -356,108 +356,108 @@

                                                                                                                    Submodules
                                                                                                                    -class sparsify.schemas.model_repo.ModelRepoArchitectureSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.model_repo.ModelRepoArchitectureSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for a model repo architecture

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>

                                                                                                                    -class sparsify.schemas.model_repo.ModelRepoDatasetSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.model_repo.ModelRepoDatasetSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for a model repo dataset

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.model_repo.ModelRepoDomainSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.model_repo.ModelRepoDomainSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for a model repo domain

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.model_repo.ModelRepoModelDescSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.model_repo.ModelRepoModelDescSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for a model repo desc

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.model_repo.ModelRepoModelMetricSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.model_repo.ModelRepoModelMetricSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for reporting a metric for a model repo model

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.model_repo.ModelRepoModelPerfSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.model_repo.ModelRepoModelPerfSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for reporting the performance for a model repo model

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.model_repo.ModelRepoModelSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.model_repo.ModelRepoModelSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for a model repo model

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.model_repo.ResponseModelRepoModels(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.model_repo.ResponseModelRepoModels(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for the response for searching for models in the model repo

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.model_repo.SearchModelRepoModels(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.model_repo.SearchModelRepoModels(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for searching and filtering models in the model repo

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    @@ -468,110 +468,110 @@

                                                                                                                    Submodules
                                                                                                                    -class sparsify.schemas.projects.CreateUpdateProjectSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects.CreateUpdateProjectSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Expected schema to use for creating or updating a project

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>

                                                                                                                    -class sparsify.schemas.projects.DeleteProjectSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects.DeleteProjectSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Expected schema to use for deleting a project

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects.ProjectExtSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects.ProjectExtSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: sparsify.schemas.projects.ProjectSchema

                                                                                                                    Schema for a project object including model and data as stored in the DB and returned in the server routes

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects.ProjectSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects.ProjectSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for a project object as stored in the DB and returned in the server routes

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects.ResponseProjectDeletedSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects.ResponseProjectDeletedSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for returning a response after deleting a project

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects.ResponseProjectExtSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects.ResponseProjectExtSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for returning a response with a single project and its associated model and data

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects.ResponseProjectSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects.ResponseProjectSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for returning a response with a single project

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects.ResponseProjectsSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects.ResponseProjectsSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for returning a response with multiple project

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects.SearchProjectsSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects.SearchProjectsSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Expected schema to use for querying projects

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    @@ -582,97 +582,97 @@

                                                                                                                    Submodules
                                                                                                                    -class sparsify.schemas.projects_benchmarks.CreateProjectBenchmarkSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_benchmarks.CreateProjectBenchmarkSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Expected schema to use for creating a project benchmark

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>

                                                                                                                    -class sparsify.schemas.projects_benchmarks.ProjectBenchmarkResultSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_benchmarks.ProjectBenchmarkResultSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for a project benchmark object’s metadata as stored in the DB

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_benchmarks.ProjectBenchmarkResultsSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_benchmarks.ProjectBenchmarkResultsSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for a project benchmark object’s measured results as stored in the DB

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_benchmarks.ProjectBenchmarkSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_benchmarks.ProjectBenchmarkSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for a project benchmark object (metadata and result) as stored in the DB and returned in the server routes

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_benchmarks.ResponseProjectBenchmarkDeletedSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_benchmarks.ResponseProjectBenchmarkDeletedSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Expected schema to use for deleting a project benchmark

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_benchmarks.ResponseProjectBenchmarkSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_benchmarks.ResponseProjectBenchmarkSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for returning a response containing a benchmark project

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_benchmarks.ResponseProjectBenchmarksSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_benchmarks.ResponseProjectBenchmarksSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for returning a response containing multiple benchmark projects

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_benchmarks.SearchProjectBenchmarksSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_benchmarks.SearchProjectBenchmarksSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema to use for querying project benchmarks

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    @@ -683,86 +683,86 @@

                                                                                                                    Submodules
                                                                                                                    -class sparsify.schemas.projects_data.CreateUpdateProjectDataSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_data.CreateUpdateProjectDataSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for creating a data file for a project

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>

                                                                                                                    -class sparsify.schemas.projects_data.ProjectDataSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_data.ProjectDataSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for a project data object as stored in the DB and returned in the server routes

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_data.ResponseProjectDataDeletedSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_data.ResponseProjectDataDeletedSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for returning a response after deleting a project’s data object and file

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_data.ResponseProjectDataSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_data.ResponseProjectDataSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for returning a response with all of the project’s data objects

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_data.ResponseProjectDataSingleSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_data.ResponseProjectDataSingleSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for returning a response with a project’s data object

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_data.SearchProjectDataSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_data.SearchProjectDataSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema to use for querying project data

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_data.SetProjectDataFromSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_data.SetProjectDataFromSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Expected schema to use for setting a project’s data for upload from path or upload from url

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    @@ -773,96 +773,96 @@

                                                                                                                    Submodules
                                                                                                                    -class sparsify.schemas.projects_model.CreateUpdateProjectModelSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_model.CreateUpdateProjectModelSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for creating a model for a project

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>

                                                                                                                    -class sparsify.schemas.projects_model.DeleteProjectModelSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_model.DeleteProjectModelSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for deleting a project’s model

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_model.ProjectModelAnalysisSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_model.ProjectModelAnalysisSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for the analysis of a project’s model and all the nodes contained

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_model.ProjectModelSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_model.ProjectModelSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for a project model object as stored in the DB an returned in server routes

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_model.ResponseProjectModelAnalysisSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_model.ResponseProjectModelAnalysisSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for returning a response with a project model’s analysis

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_model.ResponseProjectModelDeletedSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_model.ResponseProjectModelDeletedSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for returning a response on deletion of a project’s model

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_model.ResponseProjectModelSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_model.ResponseProjectModelSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for returning a response with a single project model

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_model.SetProjectModelFromSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_model.SetProjectModelFromSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for setting a project’s model from some loadable uri

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    @@ -873,362 +873,362 @@

                                                                                                                    Submodules
                                                                                                                    -class sparsify.schemas.projects_optimizations.CreateProjectOptimizationSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_optimizations.CreateProjectOptimizationSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: sparsify.schemas.projects_optimizations.GetProjectOptimizationBestEstimatedResultsSchema

                                                                                                                    Schema to use for creating a project optimization

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>

                                                                                                                    -class sparsify.schemas.projects_optimizations.CreateUpdateProjectOptimizationModifiersLRScheduleSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_optimizations.CreateUpdateProjectOptimizationModifiersLRScheduleSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema to use for creating or updating a project optimization lr schedule modifier

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_optimizations.CreateUpdateProjectOptimizationModifiersPruningSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_optimizations.CreateUpdateProjectOptimizationModifiersPruningSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema to use for creating or updating a project optimization pruning modifier

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_optimizations.CreateUpdateProjectOptimizationModifiersQuantizationSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_optimizations.CreateUpdateProjectOptimizationModifiersQuantizationSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema to use for creating or updating a project optimization quantization modifier

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_optimizations.CreateUpdateProjectOptimizationModifiersTrainableSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_optimizations.CreateUpdateProjectOptimizationModifiersTrainableSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema to use for creating or updating a project optimization trainable modifier

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_optimizations.GetProjectOptimizationBestEstimatedResultsSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_optimizations.GetProjectOptimizationBestEstimatedResultsSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema to use for getting a projects best estimated optimization results

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_optimizations.ProjectAvailableModelModificationsSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_optimizations.ProjectAvailableModelModificationsSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for the available modifiers for a project

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_optimizations.ProjectOptimizationModifierLRExponentialArgsSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_optimizations.ProjectOptimizationModifierLRExponentialArgsSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for the args for an exponential LR modifier

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_optimizations.ProjectOptimizationModifierLRMultiStepArgsSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_optimizations.ProjectOptimizationModifierLRMultiStepArgsSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for the args for a multi step LR modifier

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_optimizations.ProjectOptimizationModifierLRScheduleSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_optimizations.ProjectOptimizationModifierLRScheduleSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for an LR schedule modifier including metadata and settings

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_optimizations.ProjectOptimizationModifierLRSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_optimizations.ProjectOptimizationModifierLRSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for an LR modifier

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_optimizations.ProjectOptimizationModifierLRSetArgsSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_optimizations.ProjectOptimizationModifierLRSetArgsSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for the args for a set LR modifier

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_optimizations.ProjectOptimizationModifierLRStepArgsSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_optimizations.ProjectOptimizationModifierLRStepArgsSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for the args for a step LR modifier

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_optimizations.ProjectOptimizationModifierPruningNodeSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_optimizations.ProjectOptimizationModifierPruningNodeSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: sparsify.schemas.projects_optimizations.ProjectOptimizationModifierPruningNodeMetadataSchema, sparsify.schemas.projects_optimizations.ProjectOptimizationModifierEstimationsSchema

                                                                                                                    Schema for a pruning node containing metadata and estimated values

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_optimizations.ProjectOptimizationModifierPruningSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_optimizations.ProjectOptimizationModifierPruningSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: sparsify.schemas.projects_optimizations.ProjectOptimizationModifierEstimationsSchema

                                                                                                                    Schema for a pruning modifier including metadata, settings, and estimated values

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_optimizations.ProjectOptimizationModifierQuantizationNodeSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_optimizations.ProjectOptimizationModifierQuantizationNodeSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for a quantization node containing metadata

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_optimizations.ProjectOptimizationModifierQuantizationSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_optimizations.ProjectOptimizationModifierQuantizationSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for a quantization modifier including metadata, settings, and estimated values

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_optimizations.ProjectOptimizationModifierTrainableNodeSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_optimizations.ProjectOptimizationModifierTrainableNodeSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for a trainable node containing metadata

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_optimizations.ProjectOptimizationModifierTrainableSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_optimizations.ProjectOptimizationModifierTrainableSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for a trainable modifier containing metadata and settings

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_optimizations.ProjectOptimizationSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_optimizations.ProjectOptimizationSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for a project optimization containing metadata and modifiers

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_optimizations.ResponseProjectOptimizationDeletedSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_optimizations.ResponseProjectOptimizationDeletedSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for returning the results of deleting a project optimization

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_optimizations.ResponseProjectOptimizationFrameworksAvailableSamplesSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_optimizations.ResponseProjectOptimizationFrameworksAvailableSamplesSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for returning the available code samples for a framework for project optimization

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_optimizations.ResponseProjectOptimizationFrameworksAvailableSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_optimizations.ResponseProjectOptimizationFrameworksAvailableSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for returning the available frameworks for project optimization

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_optimizations.ResponseProjectOptimizationModifierDeletedSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_optimizations.ResponseProjectOptimizationModifierDeletedSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for returning the results of deleting a project optimization modifier

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_optimizations.ResponseProjectOptimizationModifiersAvailable(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_optimizations.ResponseProjectOptimizationModifiersAvailable(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for returning the available modifiers for project optimization

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_optimizations.ResponseProjectOptimizationModifiersBestEstimated(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_optimizations.ResponseProjectOptimizationModifiersBestEstimated(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: sparsify.schemas.projects_optimizations.ProjectOptimizationModifierEstimationsSchema

                                                                                                                    Schema for returning the best estimated results for project optimization

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_optimizations.ResponseProjectOptimizationSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_optimizations.ResponseProjectOptimizationSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for returning a project optimization

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_optimizations.ResponseProjectOptimizationsSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_optimizations.ResponseProjectOptimizationsSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for returning multiple project optimizations

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_optimizations.SearchProjectOptimizationsSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_optimizations.SearchProjectOptimizationsSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema to use for querying project optimizations

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_optimizations.UpdateProjectOptimizationSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_optimizations.UpdateProjectOptimizationSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema to use for updating a project optimization

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    @@ -1239,263 +1239,263 @@

                                                                                                                    Submodules
                                                                                                                    -class sparsify.schemas.projects_profiles.CreateProjectLossProfileSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_profiles.CreateProjectLossProfileSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Expected schema to use for creating a loss profile for a project

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>

                                                                                                                    -class sparsify.schemas.projects_profiles.CreateProjectPerfProfileSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_profiles.CreateProjectPerfProfileSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Expected schema to use for creating a performance profile for a project

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_profiles.ProjectLossProfileSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_profiles.ProjectLossProfileSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: sparsify.schemas.projects_profiles.ProjectProfileSchema

                                                                                                                    Schema for a projects loss profile object as stored in the DB and returned in the server routes

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_profiles.ProjectPerfProfileSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_profiles.ProjectPerfProfileSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: sparsify.schemas.projects_profiles.ProjectProfileSchema

                                                                                                                    Schema for a projects performance profile object as stored in the DB and returned in the server routes

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_profiles.ProjectProfileAnalysisSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_profiles.ProjectProfileAnalysisSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for an analysis for a profiles model and all ops in it. Includes baseline measurements, pruning measurements, and quantization measurements

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_profiles.ProjectProfileMeasurementSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_profiles.ProjectProfileMeasurementSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for a profile measurement

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_profiles.ProjectProfileMeasurementsSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_profiles.ProjectProfileMeasurementsSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for profile measurements including baseline

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_profiles.ProjectProfileModelOpsBaselineMeasurementsSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_profiles.ProjectProfileModelOpsBaselineMeasurementsSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for baseline measurements for a profiles model and all ops in it

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_profiles.ProjectProfileModelOpsMeasurementsSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_profiles.ProjectProfileModelOpsMeasurementsSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for measurements for a profiles model and all ops in it

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_profiles.ProjectProfileOpBaselineMeasurementSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_profiles.ProjectProfileOpBaselineMeasurementSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: sparsify.schemas.projects_profiles.ProjectProfileMeasurementSchema, sparsify.schemas.projects_profiles.ProjectProfileOpSchema

                                                                                                                    Schema for baseline measurements for a profiles op or node in a model

                                                                                                                    -dump_fields: typing.Dict[str, ma_fields.Field]
                                                                                                                    +dump_fields: typing.Dict[str, ma_fields.Field]
                                                                                                                    -fields: typing.Dict[str, ma_fields.Field]
                                                                                                                    +fields: typing.Dict[str, ma_fields.Field]

                                                                                                                    Dictionary mapping field_names -> Field objects

                                                                                                                    -load_fields: typing.Dict[str, ma_fields.Field]
                                                                                                                    +load_fields: typing.Dict[str, ma_fields.Field]
                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_profiles.ProjectProfileOpMeasurementsSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_profiles.ProjectProfileOpMeasurementsSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: sparsify.schemas.projects_profiles.ProjectProfileMeasurementsSchema, sparsify.schemas.projects_profiles.ProjectProfileOpSchema

                                                                                                                    Schema for measurements for a profile op or node in a model

                                                                                                                    -dump_fields: typing.Dict[str, ma_fields.Field]
                                                                                                                    +dump_fields: typing.Dict[str, ma_fields.Field]
                                                                                                                    -fields: typing.Dict[str, ma_fields.Field]
                                                                                                                    +fields: typing.Dict[str, ma_fields.Field]

                                                                                                                    Dictionary mapping field_names -> Field objects

                                                                                                                    -load_fields: typing.Dict[str, ma_fields.Field]
                                                                                                                    +load_fields: typing.Dict[str, ma_fields.Field]
                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_profiles.ProjectProfileOpSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_profiles.ProjectProfileOpSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for a profile op or node in a model

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_profiles.ProjectProfileSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_profiles.ProjectProfileSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Base schema for a projects profile such as loss or perf

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_profiles.ResponseProjectLossProfileSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_profiles.ResponseProjectLossProfileSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for returning a response with a single loss profile

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_profiles.ResponseProjectLossProfilesSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_profiles.ResponseProjectLossProfilesSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for returning a response with multiple loss profiles

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_profiles.ResponseProjectPerfProfileSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_profiles.ResponseProjectPerfProfileSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for returning a response with a single performance profile

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_profiles.ResponseProjectPerfProfilesSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_profiles.ResponseProjectPerfProfilesSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for returning a response with a multiple performance profiles

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_profiles.ResponseProjectProfileDeletedSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_profiles.ResponseProjectProfileDeletedSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for returning a response after deleting a profile

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.projects_profiles.SearchProjectProfilesSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.projects_profiles.SearchProjectProfilesSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Expected schema to use for querying project profiles

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    @@ -1506,35 +1506,35 @@

                                                                                                                    Submodules
                                                                                                                    -class sparsify.schemas.system.ResponseSystemInfo(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.system.ResponseSystemInfo(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for returning a response with the system info

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>

                                                                                                                    -class sparsify.schemas.system.SystemInfo(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.system.SystemInfo(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    Schema for the system info the server is currently running on

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    -class sparsify.schemas.system.VersionInfoSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]
                                                                                                                    +class sparsify.schemas.system.VersionInfoSchema(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]

                                                                                                                    Bases: marshmallow.schema.Schema

                                                                                                                    -opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    +opts: SchemaOpts = <marshmallow.schema.SchemaOpts object>
                                                                                                                    diff --git a/sparsify/api/sparsify.utils.html b/sparsify/api/sparsify.utils.html index bd542b32f33..d686d2f64f9 100644 --- a/sparsify/api/sparsify.utils.html +++ b/sparsify/api/sparsify.utils.html @@ -209,7 +209,7 @@

                                                                                                                    Submodules
                                                                                                                    -sparsify.utils.system.available_ml_engines() → List[str][source]
                                                                                                                    +sparsify.utils.system.available_ml_engines()List[str][source]
                                                                                                                    Returns

                                                                                                                    List of available inference providers on current system. Potential values @@ -220,7 +220,7 @@

                                                                                                                    Submodules
                                                                                                                    -sparsify.utils.system.get_ml_sys_info() → Dict[str, Any][source]
                                                                                                                    +sparsify.utils.system.get_ml_sys_info()Dict[str, Any][source]
                                                                                                                    Returns

                                                                                                                    a dictionary containing info for the system and ML engines on the system. @@ -231,7 +231,7 @@

                                                                                                                    Submodules
                                                                                                                    -sparsify.utils.system.ml_engines_errors() → Dict[str, Exception][source]
                                                                                                                    +sparsify.utils.system.ml_engines_errors()Dict[str, Exception][source]
                                                                                                                    Returns

                                                                                                                    a dictionary containing any errors encountered when importing ML engines diff --git a/sparsify/api/sparsify.workers.html b/sparsify/api/sparsify.workers.html index 385b9e1a824..0a10490f4c6 100644 --- a/sparsify/api/sparsify.workers.html +++ b/sparsify/api/sparsify.workers.html @@ -213,7 +213,7 @@

                                                                                                                    Submodules
                                                                                                                    -class sparsify.workers.base.JobWorker(job_id: str, project_id: str)[source]
                                                                                                                    +class sparsify.workers.base.JobWorker(job_id: str, project_id: str)[source]

                                                                                                                    Bases: object

                                                                                                                    The base job worker instance all job workers must extend

                                                                                                                    @@ -226,7 +226,7 @@

                                                                                                                    Submodules
                                                                                                                    -abstract classmethod format_args(**kwargs) → Dict[str, Any][source]
                                                                                                                    +abstract classmethod format_args(**kwargs)Dict[str, Any][source]

                                                                                                                    Format a given args into proper args to be stored for later use in the constructor for the job worker.

                                                                                                                    @@ -241,7 +241,7 @@

                                                                                                                    Submodules
                                                                                                                    -classmethod get_type() → str[source]
                                                                                                                    +classmethod get_type()str[source]
                                                                                                                    Returns

                                                                                                                    the type of job worker

                                                                                                                    @@ -251,7 +251,7 @@

                                                                                                                    Submodules
                                                                                                                    -property job_id
                                                                                                                    +property job_id

                                                                                                                    the id of the job the worker is being run for

                                                                                                                    Type
                                                                                                                    @@ -262,7 +262,7 @@

                                                                                                                    Submodules
                                                                                                                    -property project_id
                                                                                                                    +property project_id

                                                                                                                    the id of the project the job belongs to

                                                                                                                    Type
                                                                                                                    @@ -273,7 +273,7 @@

                                                                                                                    Submodules
                                                                                                                    -abstract run() → Iterator[Dict[str, Any]][source]
                                                                                                                    +abstract run()Iterator[Dict[str, Any]][source]

                                                                                                                    Perform the work for the job. Must be implemented as an iterator that returns a dictionary containing the progress object on each progress step.

                                                                                                                    @@ -288,18 +288,18 @@

                                                                                                                    Submodules
                                                                                                                    -class sparsify.workers.base.JobWorkerRegistry(name, bases, attrs)[source]
                                                                                                                    +class sparsify.workers.base.JobWorkerRegistry(name, bases, attrs)[source]

                                                                                                                    Bases: type

                                                                                                                    Registry class for handling and storing BaseJobWorker sub class instances. All subclasses are added to the the REGISTRY property

                                                                                                                    -REGISTRY = {'BaseProfileJobWorker': <class 'sparsify.workers.projects_profiles.BaseProfileJobWorker'>, 'CreateBenchmarkJobWorker': <class 'sparsify.workers.projects_benchmark.CreateBenchmarkJobWorker'>, 'CreateLossProfileJobWorker': <class 'sparsify.workers.projects_profiles.CreateLossProfileJobWorker'>, 'CreatePerfProfileJobWorker': <class 'sparsify.workers.projects_profiles.CreatePerfProfileJobWorker'>, 'DataFromPathJobWorker': <class 'sparsify.workers.projects_data.DataFromPathJobWorker'>, 'DataFromRepoJobWorker': <class 'sparsify.workers.projects_data.DataFromRepoJobWorker'>, 'JobWorker': <class 'sparsify.workers.base.JobWorker'>, 'ModelFromPathJobWorker': <class 'sparsify.workers.projects_model.ModelFromPathJobWorker'>, 'ModelFromRepoJobWorker': <class 'sparsify.workers.projects_model.ModelFromRepoJobWorker'>, '_DataLoaderJobWorker': <class 'sparsify.workers.projects_data._DataLoaderJobWorker'>, '_ModelLoaderJobWorker': <class 'sparsify.workers.projects_model._ModelLoaderJobWorker'>}
                                                                                                                    +REGISTRY = {'BaseProfileJobWorker': <class 'sparsify.workers.projects_profiles.BaseProfileJobWorker'>, 'CreateBenchmarkJobWorker': <class 'sparsify.workers.projects_benchmark.CreateBenchmarkJobWorker'>, 'CreateLossProfileJobWorker': <class 'sparsify.workers.projects_profiles.CreateLossProfileJobWorker'>, 'CreatePerfProfileJobWorker': <class 'sparsify.workers.projects_profiles.CreatePerfProfileJobWorker'>, 'DataFromPathJobWorker': <class 'sparsify.workers.projects_data.DataFromPathJobWorker'>, 'DataFromRepoJobWorker': <class 'sparsify.workers.projects_data.DataFromRepoJobWorker'>, 'JobWorker': <class 'sparsify.workers.base.JobWorker'>, 'ModelFromPathJobWorker': <class 'sparsify.workers.projects_model.ModelFromPathJobWorker'>, 'ModelFromRepoJobWorker': <class 'sparsify.workers.projects_model.ModelFromRepoJobWorker'>, '_DataLoaderJobWorker': <class 'sparsify.workers.projects_data._DataLoaderJobWorker'>, '_ModelLoaderJobWorker': <class 'sparsify.workers.projects_model._ModelLoaderJobWorker'>}
                                                                                                                    -static create_worker(job)[source]
                                                                                                                    +static create_worker(job)[source]

                                                                                                                    @@ -310,21 +310,21 @@

                                                                                                                    Submodules
                                                                                                                    -exception sparsify.workers.manager.JobCancelationFailureError(*args: object)[source]
                                                                                                                    +exception sparsify.workers.manager.JobCancelationFailureError(*args: object)[source]

                                                                                                                    Bases: Exception

                                                                                                                    Error raised if a job could not be canceled

                                                                                                                    -exception sparsify.workers.manager.JobNotFoundError(*args: object)[source]
                                                                                                                    +exception sparsify.workers.manager.JobNotFoundError(*args: object)[source]

                                                                                                                    Bases: Exception

                                                                                                                    Error raised if a job is not found in the database

                                                                                                                    -class sparsify.workers.manager.JobWorkerManager(*args, **kwargs)[source]
                                                                                                                    +class sparsify.workers.manager.JobWorkerManager(*args, **kwargs)[source]

                                                                                                                    Bases: object

                                                                                                                    Manager class for handling running job workers in the background. Only one job worker can run at once. @@ -337,7 +337,7 @@

                                                                                                                    Submodules
                                                                                                                    -cancel_job(job_id: str)[source]
                                                                                                                    +cancel_job(job_id: str)[source]

                                                                                                                    Cancel a job with the given job_id so it won’t be run.

                                                                                                                    Parameters
                                                                                                                    @@ -354,7 +354,7 @@

                                                                                                                    Submodules
                                                                                                                    -refresh()[source]
                                                                                                                    +refresh()[source]

                                                                                                                    Refresh the available jobs and put any pending ones since last refresh onto the ThreadPoolExecutor.

                                                                                                                    Otherwise will exit out without doing anything and @@ -363,13 +363,13 @@

                                                                                                                    Submodules
                                                                                                                    -shutdown()[source]
                                                                                                                    +shutdown()[source]

                                                                                                                    Shutdown the JobWorkerManager to stop processing any background jobs

                                                                                                                    -start()[source]
                                                                                                                    +start()[source]

                                                                                                                    Start the JobWorkerManager to begin processing any background jobs present

                                                                                                                    @@ -381,7 +381,7 @@

                                                                                                                    Submodules
                                                                                                                    -class sparsify.workers.projects_benchmark.CreateBenchmarkJobWorker(job_id: str, project_id: str, model_id: str, benchmark_id: str, core_counts: List[int], batch_sizes: List[int], instruction_sets: List[str], inference_models: List[Dict[str, Optional[str]]], warmup_iterations_per_check: int, iterations_per_check: int)[source]
                                                                                                                    +class sparsify.workers.projects_benchmark.CreateBenchmarkJobWorker(job_id: str, project_id: str, model_id: str, benchmark_id: str, core_counts: List[int], batch_sizes: List[int], instruction_sets: List[str], inference_models: List[Dict[str, Optional[str]]], warmup_iterations_per_check: int, iterations_per_check: int)[source]

                                                                                                                    Bases: sparsify.workers.base.JobWorker

                                                                                                                    A job worker for running and saving a benchmark for a given project and configuration.

                                                                                                                    @@ -410,7 +410,7 @@

                                                                                                                    Submodules
                                                                                                                    -property batch_sizes
                                                                                                                    +property batch_sizes

                                                                                                                    list of batch sizes to use for benchmarking

                                                                                                                    Type
                                                                                                                    @@ -421,7 +421,7 @@

                                                                                                                    Submodules
                                                                                                                    -property benchmark_id
                                                                                                                    +property benchmark_id

                                                                                                                    id of the benchmark

                                                                                                                    Type
                                                                                                                    @@ -432,7 +432,7 @@

                                                                                                                    Submodules
                                                                                                                    -property core_counts
                                                                                                                    +property core_counts

                                                                                                                    list of core count to run on for benchmarking. -1 will use the maximum cores available

                                                                                                                    @@ -444,7 +444,7 @@

                                                                                                                    Submodules
                                                                                                                    -classmethod format_args(model_id: str, benchmark_id: str, core_counts: List[int], batch_sizes: List[int], instruction_sets: List[str], inference_models: List[Dict[str, Optional[str]]], warmup_iterations_per_check: int, iterations_per_check: int)[source]
                                                                                                                    +classmethod format_args(model_id: str, benchmark_id: str, core_counts: List[int], batch_sizes: List[int], instruction_sets: List[str], inference_models: List[Dict[str, Optional[str]]], warmup_iterations_per_check: int, iterations_per_check: int)[source]

                                                                                                                    Format a given args into proper args to be stored for later use in the constructor for the job worker.

                                                                                                                    @@ -472,7 +472,7 @@

                                                                                                                    Submodules
                                                                                                                    -property inference_models
                                                                                                                    +property inference_models

                                                                                                                    list of inference model to use for comparison with fields inference_engine and inference_model_optimization

                                                                                                                    @@ -484,7 +484,7 @@

                                                                                                                    Submodules
                                                                                                                    -property instruction_sets
                                                                                                                    +property instruction_sets

                                                                                                                    list of instruction sets

                                                                                                                    Type
                                                                                                                    @@ -495,7 +495,7 @@

                                                                                                                    Submodules
                                                                                                                    -property iterations_per_check
                                                                                                                    +property iterations_per_check

                                                                                                                    the number of iterations to run for each performance check / timing

                                                                                                                    Type
                                                                                                                    @@ -506,7 +506,7 @@

                                                                                                                    Submodules
                                                                                                                    -property model_id
                                                                                                                    +property model_id

                                                                                                                    id of the model to run the loss profile for

                                                                                                                    Type
                                                                                                                    @@ -517,7 +517,7 @@

                                                                                                                    Submodules
                                                                                                                    -run() → Iterator[Dict[str, Any]][source]
                                                                                                                    +run()Iterator[Dict[str, Any]][source]

                                                                                                                    Perform the work for the job. Runs and saves the appropriate benchmark based on the configuration

                                                                                                                    @@ -529,7 +529,7 @@

                                                                                                                    Submodules
                                                                                                                    -property warmup_iterations_per_check
                                                                                                                    +property warmup_iterations_per_check

                                                                                                                    the number of warmup iterations to run for before checking performance / timing

                                                                                                                    @@ -547,7 +547,7 @@

                                                                                                                    Submodules
                                                                                                                    -class sparsify.workers.projects_data.DataFromPathJobWorker(job_id: str, project_id: str, data_id: str, uri: str)[source]
                                                                                                                    +class sparsify.workers.projects_data.DataFromPathJobWorker(job_id: str, project_id: str, data_id: str, uri: str)[source]

                                                                                                                    Bases: sparsify.workers.projects_data._DataLoaderJobWorker

                                                                                                                    A job worker for retrieving .npz data files from a given uri. The uri can be either a local file path or a public url.

                                                                                                                    @@ -563,7 +563,7 @@

                                                                                                                    Submodules
                                                                                                                    -run() → Iterator[Dict[str, Any]][source]
                                                                                                                    +run()Iterator[Dict[str, Any]][source]

                                                                                                                    Perform the work for the job. Downloads the data files from a public url if the uri is a public url. Copies the data if the uri is accessible through the local file system. @@ -579,7 +579,7 @@

                                                                                                                    Submodules
                                                                                                                    -class sparsify.workers.projects_data.DataFromRepoJobWorker(job_id: str, project_id: str, data_id: str, uri: str)[source]
                                                                                                                    +class sparsify.workers.projects_data.DataFromRepoJobWorker(job_id: str, project_id: str, data_id: str, uri: str)[source]

                                                                                                                    Bases: sparsify.workers.projects_data._DataLoaderJobWorker

                                                                                                                    A job worker for retrieving .npz data files from a given uri. The uri can be either a local file path or a public url.

                                                                                                                    @@ -595,7 +595,7 @@

                                                                                                                    Submodules
                                                                                                                    -run() → Iterator[Dict[str, Any]][source]
                                                                                                                    +run()Iterator[Dict[str, Any]][source]

                                                                                                                    Perform the work for the job.

                                                                                                                    Returns
                                                                                                                    @@ -612,7 +612,7 @@

                                                                                                                    Submodules
                                                                                                                    -class sparsify.workers.projects_model.ModelFromPathJobWorker(job_id: str, project_id: str, model_id: str, uri: str)[source]
                                                                                                                    +class sparsify.workers.projects_model.ModelFromPathJobWorker(job_id: str, project_id: str, model_id: str, uri: str)[source]

                                                                                                                    Bases: sparsify.workers.projects_model._ModelLoaderJobWorker

                                                                                                                    A job worker for retrieving a model (currently ONNX) from a given uri. The uri can be either a local file path or a public url.

                                                                                                                    @@ -628,7 +628,7 @@

                                                                                                                    Submodules
                                                                                                                    -run() → Iterator[Dict[str, Any]][source]
                                                                                                                    +run()Iterator[Dict[str, Any]][source]

                                                                                                                    Perform the work for the job. Downloads the model from a public url if the uri is a public url. Copies the model if the uri is accessible through the local file system.

                                                                                                                    @@ -643,7 +643,7 @@

                                                                                                                    Submodules
                                                                                                                    -class sparsify.workers.projects_model.ModelFromRepoJobWorker(job_id: str, project_id: str, model_id: str, uri: str)[source]
                                                                                                                    +class sparsify.workers.projects_model.ModelFromRepoJobWorker(job_id: str, project_id: str, model_id: str, uri: str)[source]

                                                                                                                    Bases: sparsify.workers.projects_model._ModelLoaderJobWorker

                                                                                                                    A job worker for retrieving a model (currently ONNX) from a given uri from within the Neural Magic model repo.

                                                                                                                    @@ -659,7 +659,7 @@

                                                                                                                    Submodules
                                                                                                                    -run() → Iterator[Dict[str, Any]][source]
                                                                                                                    +run()Iterator[Dict[str, Any]][source]

                                                                                                                    Perform the work for the job. Downloads the model from the model repo.

                                                                                                                    @@ -677,7 +677,7 @@

                                                                                                                    Submodules
                                                                                                                    -class sparsify.workers.projects_profiles.CreateLossProfileJobWorker(job_id: str, project_id: str, model_id: str, profile_id: str, pruning_estimations: bool, pruning_estimation_type: str, pruning_structure: str, quantized_estimations: bool)[source]
                                                                                                                    +class sparsify.workers.projects_profiles.CreateLossProfileJobWorker(job_id: str, project_id: str, model_id: str, profile_id: str, pruning_estimations: bool, pruning_estimation_type: str, pruning_structure: str, quantized_estimations: bool)[source]

                                                                                                                    Bases: sparsify.workers.projects_profiles.BaseProfileJobWorker

                                                                                                                    A job worker for running and saving a loss profile for a given project and configuration.

                                                                                                                    @@ -698,7 +698,7 @@

                                                                                                                    Submodules
                                                                                                                    -classmethod format_args(model_id: str, profile_id: str, pruning_estimations: bool, pruning_estimation_type: str, pruning_structure: str, quantized_estimations: bool, **kwargs) → Union[None, Dict[str, Any]][source]
                                                                                                                    +classmethod format_args(model_id: str, profile_id: str, pruning_estimations: bool, pruning_estimation_type: str, pruning_structure: str, quantized_estimations: bool, **kwargs)Union[None, Dict[str, Any]][source]

                                                                                                                    Format a given args into proper args to be stored for later use in the constructor for the job worker.

                                                                                                                    @@ -722,7 +722,7 @@

                                                                                                                    Submodules
                                                                                                                    -property model_id
                                                                                                                    +property model_id

                                                                                                                    id of the model to run the loss profile for

                                                                                                                    Type
                                                                                                                    @@ -733,7 +733,7 @@

                                                                                                                    Submodules
                                                                                                                    -property profile_id
                                                                                                                    +property profile_id

                                                                                                                    the profile id of the loss profile that should be updated

                                                                                                                    Type
                                                                                                                    @@ -744,7 +744,7 @@

                                                                                                                    Submodules
                                                                                                                    -property pruning_estimation_type
                                                                                                                    +property pruning_estimation_type

                                                                                                                    loss analysis type to run, weight_magnitude or one_shot

                                                                                                                    @@ -756,7 +756,7 @@

                                                                                                                    Submodules
                                                                                                                    -property pruning_estimations
                                                                                                                    +property pruning_estimations

                                                                                                                    True to include pruning profile information

                                                                                                                    Type
                                                                                                                    @@ -767,7 +767,7 @@

                                                                                                                    Submodules
                                                                                                                    -property pruning_structure
                                                                                                                    +property pruning_structure

                                                                                                                    type of pruning to use, (unstructured, block_4…)

                                                                                                                    Type
                                                                                                                    @@ -778,7 +778,7 @@

                                                                                                                    Submodules
                                                                                                                    -property quantized_estimations
                                                                                                                    +property quantized_estimations

                                                                                                                    True to include quantized information in the profile, False otherwise

                                                                                                                    @@ -790,7 +790,7 @@

                                                                                                                    Submodules
                                                                                                                    -run() → Iterator[Dict[str, Any]][source]
                                                                                                                    +run()Iterator[Dict[str, Any]][source]

                                                                                                                    Perform the work for the job. Runs and saves the appropriate loss profile based on the configuration

                                                                                                                    @@ -804,7 +804,7 @@

                                                                                                                    Submodules
                                                                                                                    -class sparsify.workers.projects_profiles.CreatePerfProfileJobWorker(job_id: str, project_id: str, model_id: str, profile_id: str, batch_size: int, core_count: int, pruning_estimations: bool, quantized_estimations: bool, iterations_per_check: int, warmup_iterations_per_check: int)[source]
                                                                                                                    +class sparsify.workers.projects_profiles.CreatePerfProfileJobWorker(job_id: str, project_id: str, model_id: str, profile_id: str, batch_size: int, core_count: int, pruning_estimations: bool, quantized_estimations: bool, iterations_per_check: int, warmup_iterations_per_check: int)[source]

                                                                                                                    Bases: sparsify.workers.projects_profiles.BaseProfileJobWorker

                                                                                                                    A job worker for running and saving a perf profile for a given project and configuration.

                                                                                                                    @@ -829,7 +829,7 @@

                                                                                                                    Submodules
                                                                                                                    -property batch_size
                                                                                                                    +property batch_size

                                                                                                                    batch size to use for perf analysis

                                                                                                                    Type
                                                                                                                    @@ -840,7 +840,7 @@

                                                                                                                    Submodules
                                                                                                                    -property core_count
                                                                                                                    +property core_count

                                                                                                                    number of cores to run on for perf analysis. -1 will use the maximum cores available

                                                                                                                    @@ -852,7 +852,7 @@

                                                                                                                    Submodules
                                                                                                                    -classmethod format_args(model_id: str, profile_id: str, batch_size: int, core_count: int, pruning_estimations: bool, quantized_estimations: bool, iterations_per_check: int, warmup_iterations_per_check: int, **kwargs) → Union[None, Dict[str, Any]][source]
                                                                                                                    +classmethod format_args(model_id: str, profile_id: str, batch_size: int, core_count: int, pruning_estimations: bool, quantized_estimations: bool, iterations_per_check: int, warmup_iterations_per_check: int, **kwargs)Union[None, Dict[str, Any]][source]

                                                                                                                    Format a given args into proper args to be stored for later use in the constructor for the job worker.

                                                                                                                    @@ -879,7 +879,7 @@

                                                                                                                    Submodules
                                                                                                                    -property iterations_per_check
                                                                                                                    +property iterations_per_check

                                                                                                                    number of iterations of the batch size to run for each measurement check

                                                                                                                    @@ -891,7 +891,7 @@

                                                                                                                    Submodules
                                                                                                                    -property pruning_estimations
                                                                                                                    +property pruning_estimations

                                                                                                                    True to include pruning profile information

                                                                                                                    Type
                                                                                                                    @@ -902,7 +902,7 @@

                                                                                                                    Submodules
                                                                                                                    -property quantized_estimations
                                                                                                                    +property quantized_estimations

                                                                                                                    True to include quantized information in the profile, False otherwise

                                                                                                                    @@ -914,7 +914,7 @@

                                                                                                                    Submodules
                                                                                                                    -run() → Iterator[Dict[str, Any]][source]
                                                                                                                    +run()Iterator[Dict[str, Any]][source]

                                                                                                                    Perform the work for the job. Runs and saves the appropriate perf profile based on the configuration

                                                                                                                    @@ -926,7 +926,7 @@

                                                                                                                    Submodules
                                                                                                                    -property warmup_iterations_per_check
                                                                                                                    +property warmup_iterations_per_check

                                                                                                                    number of warmup iterations of the batch size to run before each measurement check

                                                                                                                    diff --git a/sparsify/searchindex.js b/sparsify/searchindex.js index d98cd49217b..7f603b02882 100644 --- a/sparsify/searchindex.js +++ b/sparsify/searchindex.js @@ -1 +1 @@ -Search.setIndex({docnames:["api/modules","api/sparsify","api/sparsify.blueprints","api/sparsify.blueprints.code_samples","api/sparsify.blueprints.utils","api/sparsify.models","api/sparsify.schemas","api/sparsify.utils","api/sparsify.workers","index","installation","quicktour","userguide/01-intro","userguide/02-install-sparsify","userguide/03-sparsify-overview","userguide/04-analyze","userguide/04a-profiling-your-model","userguide/04b-reviewing-performance-profiles","userguide/04c-reviewing-loss-profiles","userguide/05-optimize","userguide/05a-benchmark","userguide/06-integrate","userguide/06a-optimize-config","userguide/07-settings","userguide/08-key-terms","userguide/index"],envversion:{"sphinx.domains.c":2,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":3,"sphinx.domains.index":1,"sphinx.domains.javascript":2,"sphinx.domains.math":2,"sphinx.domains.python":2,"sphinx.domains.rst":2,"sphinx.domains.std":1,"sphinx.ext.intersphinx":1,"sphinx.ext.viewcode":1,sphinx:56},filenames:["api/modules.rst","api/sparsify.rst","api/sparsify.blueprints.rst","api/sparsify.blueprints.code_samples.rst","api/sparsify.blueprints.utils.rst","api/sparsify.models.rst","api/sparsify.schemas.rst","api/sparsify.utils.rst","api/sparsify.workers.rst","index.rst","installation.md","quicktour.md","userguide/01-intro.md","userguide/02-install-sparsify.md","userguide/03-sparsify-overview.md","userguide/04-analyze.md","userguide/04a-profiling-your-model.md","userguide/04b-reviewing-performance-profiles.md","userguide/04c-reviewing-loss-profiles.md","userguide/05-optimize.md","userguide/05a-benchmark.md","userguide/06-integrate.md","userguide/06a-optimize-config.md","userguide/07-settings.md","userguide/08-key-terms.md","userguide/index.rst"],objects:{"":{sparsify:[1,0,0,"-"]},"sparsify.app":{main:[1,1,1,""],run:[1,1,1,""]},"sparsify.blueprints":{code_samples:[3,0,0,"-"],errors:[2,0,0,"-"],jobs:[2,0,0,"-"],model_repo:[2,0,0,"-"],projects:[2,0,0,"-"],projects_benchmarks:[2,0,0,"-"],projects_data:[2,0,0,"-"],projects_model:[2,0,0,"-"],projects_optimizations:[2,0,0,"-"],projects_profiles:[2,0,0,"-"],system:[2,0,0,"-"],ui:[2,0,0,"-"],utils:[4,0,0,"-"]},"sparsify.blueprints.code_samples":{pytorch__training:[3,0,0,"-"]},"sparsify.blueprints.code_samples.pytorch__training":{train:[3,1,1,""],train_setup:[3,1,1,""]},"sparsify.blueprints.utils":{helpers:[4,0,0,"-"],projects:[4,0,0,"-"],projects_benchmark:[4,0,0,"-"],projects_data:[4,0,0,"-"],projects_optimizations:[4,0,0,"-"],projects_optimizations_pruning:[4,0,0,"-"]},"sparsify.blueprints.utils.helpers":{HTTPNotFoundError:[4,2,1,""]},"sparsify.blueprints.utils.projects":{get_project_by_id:[4,1,1,""],get_project_model_by_project_id:[4,1,1,""]},"sparsify.blueprints.utils.projects_benchmark":{get_project_benchmark_by_ids:[4,1,1,""]},"sparsify.blueprints.utils.projects_data":{get_project_data_by_ids:[4,1,1,""],validate_model_data:[4,1,1,""]},"sparsify.blueprints.utils.projects_optimizations":{OptimEpochs:[4,3,1,""],create_config:[4,1,1,""],default_epochs_distribution:[4,1,1,""],default_pruning_settings:[4,1,1,""],get_profiles_by_id:[4,1,1,""],get_project_optimizer_by_ids:[4,1,1,""],optim_lr_sched_default_mods:[4,1,1,""],optim_lr_sched_updater:[4,1,1,""],optim_pruning_updater:[4,1,1,""],optim_trainable_default_nodes:[4,1,1,""],optim_trainable_updater:[4,1,1,""],optim_updater:[4,1,1,""],optim_validate_and_get_project_by_id:[4,1,1,""],sparse_training_available:[4,1,1,""],validate_pruning_nodes:[4,1,1,""]},"sparsify.blueprints.utils.projects_optimizations.OptimEpochs":{end_epoch:[4,4,1,""],fine_tuning_epochs:[4,4,1,""],fine_tuning_start_epoch:[4,4,1,""],pruning_end_epoch:[4,4,1,""],pruning_epochs:[4,4,1,""],pruning_start_epoch:[4,4,1,""],pruning_update_frequency:[4,4,1,""],stabilization_epochs:[4,4,1,""],start_epoch:[4,4,1,""],training_epochs:[4,4,1,""]},"sparsify.blueprints.utils.projects_optimizations_pruning":{PruningModelEvaluator:[4,3,1,""],PruningSettings:[4,3,1,""]},"sparsify.blueprints.utils.projects_optimizations_pruning.PruningModelEvaluator":{EVAL_SENSITIVITY_SPARSITY:[4,5,1,""],MAX_NODE_SPARSITY:[4,5,1,""],apply_node_overrides:[4,4,1,""],eval_baseline:[4,4,1,""],eval_pruning:[4,4,1,""],to_dict_values:[4,4,1,""]},"sparsify.blueprints.utils.projects_optimizations_pruning.PruningSettings":{balance_perf_loss:[4,4,1,""],filter_min_perf_gain:[4,4,1,""],filter_min_recovery:[4,4,1,""],filter_min_sparsity:[4,4,1,""],mask_type:[4,4,1,""],sparsity:[4,4,1,""]},"sparsify.log":{get_main_logger:[1,1,1,""],get_root_logger:[1,1,1,""],set_logging_level:[1,1,1,""]},"sparsify.models":{base:[5,0,0,"-"],jobs:[5,0,0,"-"],projects:[5,0,0,"-"],projects_benchmark:[5,0,0,"-"],projects_data:[5,0,0,"-"],projects_model:[5,0,0,"-"],projects_optimizations:[5,0,0,"-"],projects_profiles:[5,0,0,"-"],utils:[5,0,0,"-"]},"sparsify.models.base":{BaseCreatedModifiedModel:[5,3,1,""],BaseModel:[5,3,1,""],CSVField:[5,3,1,""],CSVFloatField:[5,3,1,""],CSVIntField:[5,3,1,""],FileStorage:[5,3,1,""],ListObjField:[5,3,1,""]},"sparsify.models.base.BaseCreatedModifiedModel":{DoesNotExist:[5,5,1,""],created:[5,5,1,""],id:[5,5,1,""],modified:[5,5,1,""],save:[5,4,1,""]},"sparsify.models.base.BaseModel":{DoesNotExist:[5,5,1,""],id:[5,5,1,""],refresh:[5,4,1,""]},"sparsify.models.base.CSVField":{db_value:[5,4,1,""],python_value:[5,4,1,""]},"sparsify.models.base.CSVFloatField":{python_value:[5,4,1,""]},"sparsify.models.base.CSVIntField":{python_value:[5,4,1,""]},"sparsify.models.base.FileStorage":{init:[5,4,1,""],root_path:[5,4,1,""]},"sparsify.models.base.ListObjField":{db_value:[5,4,1,""],python_value:[5,4,1,""]},"sparsify.models.jobs":{Job:[5,3,1,""],JobStatus:[5,3,1,""],JobStatusField:[5,3,1,""]},"sparsify.models.jobs.Job":{DoesNotExist:[5,5,1,""],baseprojectprofile_set:[5,5,1,""],created:[5,5,1,""],error:[5,5,1,""],job_id:[5,5,1,""],modified:[5,5,1,""],progress:[5,5,1,""],project_id:[5,5,1,""],projectbenchmark_set:[5,5,1,""],projectdata_set:[5,5,1,""],projectlossprofile_set:[5,5,1,""],projectmodel_set:[5,5,1,""],projectperfprofile_set:[5,5,1,""],save:[5,4,1,""],status:[5,5,1,""],type_:[5,5,1,""],worker_ack:[5,5,1,""],worker_args:[5,5,1,""]},"sparsify.models.jobs.JobStatus":{canceled:[5,5,1,""],canceling:[5,5,1,""],completed:[5,5,1,""],error:[5,5,1,""],pending:[5,5,1,""],started:[5,5,1,""]},"sparsify.models.jobs.JobStatusField":{db_value:[5,4,1,""],field_type:[5,5,1,""],python_value:[5,4,1,""]},"sparsify.models.projects":{BaseProjectModel:[5,3,1,""],Project:[5,3,1,""]},"sparsify.models.projects.BaseProjectModel":{DoesNotExist:[5,5,1,""],delete_filesystem:[5,4,1,""],id:[5,5,1,""],setup_filesystem:[5,4,1,""],validate_filesystem:[5,4,1,""]},"sparsify.models.projects.Project":{DoesNotExist:[5,5,1,""],benchmarks:[5,5,1,""],created:[5,5,1,""],data:[5,5,1,""],delete_filesystem:[5,4,1,""],description:[5,5,1,""],dir_path:[5,4,1,""],dir_size:[5,4,1,""],models:[5,5,1,""],modified:[5,5,1,""],name:[5,5,1,""],optims:[5,5,1,""],profiles_loss:[5,5,1,""],profiles_perf:[5,5,1,""],project_id:[5,5,1,""],save:[5,4,1,""],setup_filesystem:[5,4,1,""],training_epochs:[5,5,1,""],training_lr_final:[5,5,1,""],training_lr_init:[5,5,1,""],training_optimizer:[5,5,1,""],validate_filesystem:[5,4,1,""]},"sparsify.models.projects_benchmark":{ProjectBenchmark:[5,3,1,""]},"sparsify.models.projects_benchmark.ProjectBenchmark":{DoesNotExist:[5,5,1,""],batch_sizes:[5,5,1,""],benchmark_id:[5,5,1,""],core_counts:[5,5,1,""],created:[5,5,1,""],inference_models:[5,5,1,""],instruction_sets:[5,5,1,""],iterations_per_check:[5,5,1,""],job:[5,5,1,""],job_id:[5,5,1,""],modified:[5,5,1,""],name:[5,5,1,""],project:[5,5,1,""],project_id:[5,5,1,""],result:[5,5,1,""],source:[5,5,1,""],warmup_iterations_per_check:[5,5,1,""]},"sparsify.models.projects_data":{ProjectData:[5,3,1,""]},"sparsify.models.projects_data.ProjectData":{DoesNotExist:[5,5,1,""],created:[5,5,1,""],data_id:[5,5,1,""],delete_filesystem:[5,4,1,""],dir_path:[5,4,1,""],file:[5,5,1,""],file_path:[5,4,1,""],job:[5,5,1,""],job_id:[5,5,1,""],project:[5,5,1,""],project_id:[5,5,1,""],setup_filesystem:[5,4,1,""],source:[5,5,1,""],validate_filesystem:[5,4,1,""]},"sparsify.models.projects_model":{ProjectModel:[5,3,1,""]},"sparsify.models.projects_model.ProjectModel":{DoesNotExist:[5,5,1,""],analysis:[5,5,1,""],created:[5,5,1,""],delete_filesystem:[5,4,1,""],dir_path:[5,4,1,""],file:[5,5,1,""],file_path:[5,4,1,""],job:[5,5,1,""],job_id:[5,5,1,""],model_id:[5,5,1,""],project:[5,5,1,""],project_id:[5,5,1,""],setup_filesystem:[5,4,1,""],source:[5,5,1,""],validate_filesystem:[5,4,1,""]},"sparsify.models.projects_optimizations":{ProjectOptimization:[5,3,1,""],ProjectOptimizationModifierLRSchedule:[5,3,1,""],ProjectOptimizationModifierPruning:[5,3,1,""],ProjectOptimizationModifierQuantization:[5,3,1,""],ProjectOptimizationModifierTrainable:[5,3,1,""]},"sparsify.models.projects_optimizations.ProjectOptimization":{DoesNotExist:[5,5,1,""],created:[5,5,1,""],end_epoch:[5,5,1,""],lr_schedule_modifiers:[5,5,1,""],modified:[5,5,1,""],name:[5,5,1,""],notes:[5,5,1,""],optim_id:[5,5,1,""],profile_loss:[5,5,1,""],profile_loss_id:[5,5,1,""],profile_perf:[5,5,1,""],profile_perf_id:[5,5,1,""],project:[5,5,1,""],project_id:[5,5,1,""],pruning_modifiers:[5,5,1,""],quantization_modifiers:[5,5,1,""],start_epoch:[5,5,1,""],trainable_modifiers:[5,5,1,""]},"sparsify.models.projects_optimizations.ProjectOptimizationModifierLRSchedule":{DoesNotExist:[5,5,1,""],created:[5,5,1,""],end_epoch:[5,5,1,""],final_lr:[5,5,1,""],init_lr:[5,5,1,""],lr_mods:[5,5,1,""],modified:[5,5,1,""],modifier_id:[5,5,1,""],optim:[5,5,1,""],optim_id:[5,5,1,""],start_epoch:[5,5,1,""]},"sparsify.models.projects_optimizations.ProjectOptimizationModifierPruning":{DoesNotExist:[5,5,1,""],balance_perf_loss:[5,5,1,""],compression:[5,5,1,""],created:[5,5,1,""],end_epoch:[5,5,1,""],est_loss_sensitivity:[5,5,1,""],est_perf_sensitivity:[5,5,1,""],est_recovery:[5,5,1,""],est_time:[5,5,1,""],est_time_baseline:[5,5,1,""],est_time_gain:[5,5,1,""],filter_min_perf_gain:[5,5,1,""],filter_min_recovery:[5,5,1,""],filter_min_sparsity:[5,5,1,""],flops:[5,5,1,""],flops_baseline:[5,5,1,""],flops_gain:[5,5,1,""],mask_type:[5,5,1,""],modified:[5,5,1,""],modifier_id:[5,5,1,""],nodes:[5,5,1,""],optim:[5,5,1,""],optim_id:[5,5,1,""],params:[5,5,1,""],params_baseline:[5,5,1,""],sparsity:[5,5,1,""],start_epoch:[5,5,1,""],update_frequency:[5,5,1,""]},"sparsify.models.projects_optimizations.ProjectOptimizationModifierQuantization":{DoesNotExist:[5,5,1,""],balance_perf_loss:[5,5,1,""],compression:[5,5,1,""],created:[5,5,1,""],end_epoch:[5,5,1,""],est_loss_sensitivity:[5,5,1,""],est_perf_sensitivity:[5,5,1,""],est_recovery:[5,5,1,""],est_time:[5,5,1,""],est_time_baseline:[5,5,1,""],est_time_gain:[5,5,1,""],filter_min_perf_gain:[5,5,1,""],filter_min_recovery:[5,5,1,""],flops:[5,5,1,""],flops_baseline:[5,5,1,""],flops_gain:[5,5,1,""],level:[5,5,1,""],modified:[5,5,1,""],modifier_id:[5,5,1,""],nodes:[5,5,1,""],optim:[5,5,1,""],optim_id:[5,5,1,""],params:[5,5,1,""],params_baseline:[5,5,1,""],start_epoch:[5,5,1,""]},"sparsify.models.projects_optimizations.ProjectOptimizationModifierTrainable":{DoesNotExist:[5,5,1,""],created:[5,5,1,""],end_epoch:[5,5,1,""],modified:[5,5,1,""],modifier_id:[5,5,1,""],nodes:[5,5,1,""],optim:[5,5,1,""],optim_id:[5,5,1,""],start_epoch:[5,5,1,""]},"sparsify.models.projects_profiles":{BaseProjectProfile:[5,3,1,""],ProjectLossProfile:[5,3,1,""],ProjectPerfProfile:[5,3,1,""]},"sparsify.models.projects_profiles.BaseProjectProfile":{DoesNotExist:[5,5,1,""],analysis:[5,5,1,""],created:[5,5,1,""],job:[5,5,1,""],job_id:[5,5,1,""],name:[5,5,1,""],profile_id:[5,5,1,""],source:[5,5,1,""]},"sparsify.models.projects_profiles.ProjectLossProfile":{DoesNotExist:[5,5,1,""],analysis:[5,5,1,""],created:[5,5,1,""],job:[5,5,1,""],job_id:[5,5,1,""],name:[5,5,1,""],profile_id:[5,5,1,""],project:[5,5,1,""],project_id:[5,5,1,""],projectoptimization_set:[5,5,1,""],pruning_estimation_type:[5,5,1,""],pruning_estimations:[5,5,1,""],pruning_structure:[5,5,1,""],quantized_estimation_type:[5,5,1,""],quantized_estimations:[5,5,1,""],source:[5,5,1,""]},"sparsify.models.projects_profiles.ProjectPerfProfile":{DoesNotExist:[5,5,1,""],analysis:[5,5,1,""],batch_size:[5,5,1,""],core_count:[5,5,1,""],created:[5,5,1,""],instruction_sets:[5,5,1,""],iterations_per_check:[5,5,1,""],job:[5,5,1,""],job_id:[5,5,1,""],name:[5,5,1,""],profile_id:[5,5,1,""],project:[5,5,1,""],project_id:[5,5,1,""],projectoptimization_set:[5,5,1,""],pruning_estimations:[5,5,1,""],quantized_estimations:[5,5,1,""],source:[5,5,1,""],warmup_iterations_per_check:[5,5,1,""]},"sparsify.models.utils":{database_setup:[5,1,1,""]},"sparsify.schemas":{errors:[6,0,0,"-"],helpers:[6,0,0,"-"],jobs:[6,0,0,"-"],model_repo:[6,0,0,"-"],projects:[6,0,0,"-"],projects_benchmarks:[6,0,0,"-"],projects_data:[6,0,0,"-"],projects_model:[6,0,0,"-"],projects_optimizations:[6,0,0,"-"],projects_profiles:[6,0,0,"-"],system:[6,0,0,"-"]},"sparsify.schemas.errors":{ErrorSchema:[6,3,1,""]},"sparsify.schemas.errors.ErrorSchema":{opts:[6,5,1,""]},"sparsify.schemas.helpers":{EnumField:[6,3,1,""],data_dump_and_validation:[6,1,1,""]},"sparsify.schemas.helpers.EnumField":{deserialize:[6,4,1,""]},"sparsify.schemas.jobs":{JobProgressSchema:[6,3,1,""],JobSchema:[6,3,1,""],ResponseJobSchema:[6,3,1,""],ResponseJobsSchema:[6,3,1,""],SearchJobsSchema:[6,3,1,""]},"sparsify.schemas.jobs.JobProgressSchema":{opts:[6,5,1,""]},"sparsify.schemas.jobs.JobSchema":{opts:[6,5,1,""]},"sparsify.schemas.jobs.ResponseJobSchema":{opts:[6,5,1,""]},"sparsify.schemas.jobs.ResponseJobsSchema":{opts:[6,5,1,""]},"sparsify.schemas.jobs.SearchJobsSchema":{opts:[6,5,1,""]},"sparsify.schemas.model_repo":{ModelRepoArchitectureSchema:[6,3,1,""],ModelRepoDatasetSchema:[6,3,1,""],ModelRepoDomainSchema:[6,3,1,""],ModelRepoModelDescSchema:[6,3,1,""],ModelRepoModelMetricSchema:[6,3,1,""],ModelRepoModelPerfSchema:[6,3,1,""],ModelRepoModelSchema:[6,3,1,""],ResponseModelRepoModels:[6,3,1,""],SearchModelRepoModels:[6,3,1,""]},"sparsify.schemas.model_repo.ModelRepoArchitectureSchema":{opts:[6,5,1,""]},"sparsify.schemas.model_repo.ModelRepoDatasetSchema":{opts:[6,5,1,""]},"sparsify.schemas.model_repo.ModelRepoDomainSchema":{opts:[6,5,1,""]},"sparsify.schemas.model_repo.ModelRepoModelDescSchema":{opts:[6,5,1,""]},"sparsify.schemas.model_repo.ModelRepoModelMetricSchema":{opts:[6,5,1,""]},"sparsify.schemas.model_repo.ModelRepoModelPerfSchema":{opts:[6,5,1,""]},"sparsify.schemas.model_repo.ModelRepoModelSchema":{opts:[6,5,1,""]},"sparsify.schemas.model_repo.ResponseModelRepoModels":{opts:[6,5,1,""]},"sparsify.schemas.model_repo.SearchModelRepoModels":{opts:[6,5,1,""]},"sparsify.schemas.projects":{CreateUpdateProjectSchema:[6,3,1,""],DeleteProjectSchema:[6,3,1,""],ProjectExtSchema:[6,3,1,""],ProjectSchema:[6,3,1,""],ResponseProjectDeletedSchema:[6,3,1,""],ResponseProjectExtSchema:[6,3,1,""],ResponseProjectSchema:[6,3,1,""],ResponseProjectsSchema:[6,3,1,""],SearchProjectsSchema:[6,3,1,""]},"sparsify.schemas.projects.CreateUpdateProjectSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects.DeleteProjectSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects.ProjectExtSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects.ProjectSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects.ResponseProjectDeletedSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects.ResponseProjectExtSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects.ResponseProjectSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects.ResponseProjectsSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects.SearchProjectsSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_benchmarks":{CreateProjectBenchmarkSchema:[6,3,1,""],ProjectBenchmarkResultSchema:[6,3,1,""],ProjectBenchmarkResultsSchema:[6,3,1,""],ProjectBenchmarkSchema:[6,3,1,""],ResponseProjectBenchmarkDeletedSchema:[6,3,1,""],ResponseProjectBenchmarkSchema:[6,3,1,""],ResponseProjectBenchmarksSchema:[6,3,1,""],SearchProjectBenchmarksSchema:[6,3,1,""]},"sparsify.schemas.projects_benchmarks.CreateProjectBenchmarkSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_benchmarks.ProjectBenchmarkResultSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_benchmarks.ProjectBenchmarkResultsSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_benchmarks.ProjectBenchmarkSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_benchmarks.ResponseProjectBenchmarkDeletedSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_benchmarks.ResponseProjectBenchmarkSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_benchmarks.ResponseProjectBenchmarksSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_benchmarks.SearchProjectBenchmarksSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_data":{CreateUpdateProjectDataSchema:[6,3,1,""],ProjectDataSchema:[6,3,1,""],ResponseProjectDataDeletedSchema:[6,3,1,""],ResponseProjectDataSchema:[6,3,1,""],ResponseProjectDataSingleSchema:[6,3,1,""],SearchProjectDataSchema:[6,3,1,""],SetProjectDataFromSchema:[6,3,1,""]},"sparsify.schemas.projects_data.CreateUpdateProjectDataSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_data.ProjectDataSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_data.ResponseProjectDataDeletedSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_data.ResponseProjectDataSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_data.ResponseProjectDataSingleSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_data.SearchProjectDataSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_data.SetProjectDataFromSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_model":{CreateUpdateProjectModelSchema:[6,3,1,""],DeleteProjectModelSchema:[6,3,1,""],ProjectModelAnalysisSchema:[6,3,1,""],ProjectModelSchema:[6,3,1,""],ResponseProjectModelAnalysisSchema:[6,3,1,""],ResponseProjectModelDeletedSchema:[6,3,1,""],ResponseProjectModelSchema:[6,3,1,""],SetProjectModelFromSchema:[6,3,1,""]},"sparsify.schemas.projects_model.CreateUpdateProjectModelSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_model.DeleteProjectModelSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_model.ProjectModelAnalysisSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_model.ProjectModelSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_model.ResponseProjectModelAnalysisSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_model.ResponseProjectModelDeletedSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_model.ResponseProjectModelSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_model.SetProjectModelFromSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations":{CreateProjectOptimizationSchema:[6,3,1,""],CreateUpdateProjectOptimizationModifiersLRScheduleSchema:[6,3,1,""],CreateUpdateProjectOptimizationModifiersPruningSchema:[6,3,1,""],CreateUpdateProjectOptimizationModifiersQuantizationSchema:[6,3,1,""],CreateUpdateProjectOptimizationModifiersTrainableSchema:[6,3,1,""],GetProjectOptimizationBestEstimatedResultsSchema:[6,3,1,""],ProjectAvailableModelModificationsSchema:[6,3,1,""],ProjectOptimizationModifierLRExponentialArgsSchema:[6,3,1,""],ProjectOptimizationModifierLRMultiStepArgsSchema:[6,3,1,""],ProjectOptimizationModifierLRScheduleSchema:[6,3,1,""],ProjectOptimizationModifierLRSchema:[6,3,1,""],ProjectOptimizationModifierLRSetArgsSchema:[6,3,1,""],ProjectOptimizationModifierLRStepArgsSchema:[6,3,1,""],ProjectOptimizationModifierPruningNodeSchema:[6,3,1,""],ProjectOptimizationModifierPruningSchema:[6,3,1,""],ProjectOptimizationModifierQuantizationNodeSchema:[6,3,1,""],ProjectOptimizationModifierQuantizationSchema:[6,3,1,""],ProjectOptimizationModifierTrainableNodeSchema:[6,3,1,""],ProjectOptimizationModifierTrainableSchema:[6,3,1,""],ProjectOptimizationSchema:[6,3,1,""],ResponseProjectOptimizationDeletedSchema:[6,3,1,""],ResponseProjectOptimizationFrameworksAvailableSamplesSchema:[6,3,1,""],ResponseProjectOptimizationFrameworksAvailableSchema:[6,3,1,""],ResponseProjectOptimizationModifierDeletedSchema:[6,3,1,""],ResponseProjectOptimizationModifiersAvailable:[6,3,1,""],ResponseProjectOptimizationModifiersBestEstimated:[6,3,1,""],ResponseProjectOptimizationSchema:[6,3,1,""],ResponseProjectOptimizationsSchema:[6,3,1,""],SearchProjectOptimizationsSchema:[6,3,1,""],UpdateProjectOptimizationSchema:[6,3,1,""]},"sparsify.schemas.projects_optimizations.CreateProjectOptimizationSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.CreateUpdateProjectOptimizationModifiersLRScheduleSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.CreateUpdateProjectOptimizationModifiersPruningSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.CreateUpdateProjectOptimizationModifiersQuantizationSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.CreateUpdateProjectOptimizationModifiersTrainableSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.GetProjectOptimizationBestEstimatedResultsSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.ProjectAvailableModelModificationsSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.ProjectOptimizationModifierLRExponentialArgsSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.ProjectOptimizationModifierLRMultiStepArgsSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.ProjectOptimizationModifierLRScheduleSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.ProjectOptimizationModifierLRSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.ProjectOptimizationModifierLRSetArgsSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.ProjectOptimizationModifierLRStepArgsSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.ProjectOptimizationModifierPruningNodeSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.ProjectOptimizationModifierPruningSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.ProjectOptimizationModifierQuantizationNodeSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.ProjectOptimizationModifierQuantizationSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.ProjectOptimizationModifierTrainableNodeSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.ProjectOptimizationModifierTrainableSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.ProjectOptimizationSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.ResponseProjectOptimizationDeletedSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.ResponseProjectOptimizationFrameworksAvailableSamplesSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.ResponseProjectOptimizationFrameworksAvailableSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.ResponseProjectOptimizationModifierDeletedSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.ResponseProjectOptimizationModifiersAvailable":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.ResponseProjectOptimizationModifiersBestEstimated":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.ResponseProjectOptimizationSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.ResponseProjectOptimizationsSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.SearchProjectOptimizationsSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.UpdateProjectOptimizationSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_profiles":{CreateProjectLossProfileSchema:[6,3,1,""],CreateProjectPerfProfileSchema:[6,3,1,""],ProjectLossProfileSchema:[6,3,1,""],ProjectPerfProfileSchema:[6,3,1,""],ProjectProfileAnalysisSchema:[6,3,1,""],ProjectProfileMeasurementSchema:[6,3,1,""],ProjectProfileMeasurementsSchema:[6,3,1,""],ProjectProfileModelOpsBaselineMeasurementsSchema:[6,3,1,""],ProjectProfileModelOpsMeasurementsSchema:[6,3,1,""],ProjectProfileOpBaselineMeasurementSchema:[6,3,1,""],ProjectProfileOpMeasurementsSchema:[6,3,1,""],ProjectProfileOpSchema:[6,3,1,""],ProjectProfileSchema:[6,3,1,""],ResponseProjectLossProfileSchema:[6,3,1,""],ResponseProjectLossProfilesSchema:[6,3,1,""],ResponseProjectPerfProfileSchema:[6,3,1,""],ResponseProjectPerfProfilesSchema:[6,3,1,""],ResponseProjectProfileDeletedSchema:[6,3,1,""],SearchProjectProfilesSchema:[6,3,1,""]},"sparsify.schemas.projects_profiles.CreateProjectLossProfileSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_profiles.CreateProjectPerfProfileSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_profiles.ProjectLossProfileSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_profiles.ProjectPerfProfileSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_profiles.ProjectProfileAnalysisSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_profiles.ProjectProfileMeasurementSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_profiles.ProjectProfileMeasurementsSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_profiles.ProjectProfileModelOpsBaselineMeasurementsSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_profiles.ProjectProfileModelOpsMeasurementsSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_profiles.ProjectProfileOpBaselineMeasurementSchema":{dump_fields:[6,5,1,""],fields:[6,5,1,""],load_fields:[6,5,1,""],opts:[6,5,1,""]},"sparsify.schemas.projects_profiles.ProjectProfileOpMeasurementsSchema":{dump_fields:[6,5,1,""],fields:[6,5,1,""],load_fields:[6,5,1,""],opts:[6,5,1,""]},"sparsify.schemas.projects_profiles.ProjectProfileOpSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_profiles.ProjectProfileSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_profiles.ResponseProjectLossProfileSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_profiles.ResponseProjectLossProfilesSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_profiles.ResponseProjectPerfProfileSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_profiles.ResponseProjectPerfProfilesSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_profiles.ResponseProjectProfileDeletedSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_profiles.SearchProjectProfilesSchema":{opts:[6,5,1,""]},"sparsify.schemas.system":{ResponseSystemInfo:[6,3,1,""],SystemInfo:[6,3,1,""],VersionInfoSchema:[6,3,1,""]},"sparsify.schemas.system.ResponseSystemInfo":{opts:[6,5,1,""]},"sparsify.schemas.system.SystemInfo":{opts:[6,5,1,""]},"sparsify.schemas.system.VersionInfoSchema":{opts:[6,5,1,""]},"sparsify.utils":{system:[7,0,0,"-"]},"sparsify.utils.system":{available_ml_engines:[7,1,1,""],get_ml_sys_info:[7,1,1,""],ml_engines_errors:[7,1,1,""]},"sparsify.workers":{base:[8,0,0,"-"],manager:[8,0,0,"-"],projects_benchmark:[8,0,0,"-"],projects_data:[8,0,0,"-"],projects_model:[8,0,0,"-"],projects_profiles:[8,0,0,"-"]},"sparsify.workers.base":{JobWorker:[8,3,1,""],JobWorkerRegistry:[8,3,1,""]},"sparsify.workers.base.JobWorker":{format_args:[8,4,1,""],get_type:[8,4,1,""],job_id:[8,4,1,""],project_id:[8,4,1,""],run:[8,4,1,""]},"sparsify.workers.base.JobWorkerRegistry":{REGISTRY:[8,5,1,""],create_worker:[8,4,1,""]},"sparsify.workers.manager":{JobCancelationFailureError:[8,2,1,""],JobNotFoundError:[8,2,1,""],JobWorkerManager:[8,3,1,""]},"sparsify.workers.manager.JobWorkerManager":{cancel_job:[8,4,1,""],refresh:[8,4,1,""],shutdown:[8,4,1,""],start:[8,4,1,""]},"sparsify.workers.projects_benchmark":{CreateBenchmarkJobWorker:[8,3,1,""]},"sparsify.workers.projects_benchmark.CreateBenchmarkJobWorker":{batch_sizes:[8,4,1,""],benchmark_id:[8,4,1,""],core_counts:[8,4,1,""],format_args:[8,4,1,""],inference_models:[8,4,1,""],instruction_sets:[8,4,1,""],iterations_per_check:[8,4,1,""],model_id:[8,4,1,""],run:[8,4,1,""],warmup_iterations_per_check:[8,4,1,""]},"sparsify.workers.projects_data":{DataFromPathJobWorker:[8,3,1,""],DataFromRepoJobWorker:[8,3,1,""]},"sparsify.workers.projects_data.DataFromPathJobWorker":{run:[8,4,1,""]},"sparsify.workers.projects_data.DataFromRepoJobWorker":{run:[8,4,1,""]},"sparsify.workers.projects_model":{ModelFromPathJobWorker:[8,3,1,""],ModelFromRepoJobWorker:[8,3,1,""]},"sparsify.workers.projects_model.ModelFromPathJobWorker":{run:[8,4,1,""]},"sparsify.workers.projects_model.ModelFromRepoJobWorker":{run:[8,4,1,""]},"sparsify.workers.projects_profiles":{CreateLossProfileJobWorker:[8,3,1,""],CreatePerfProfileJobWorker:[8,3,1,""]},"sparsify.workers.projects_profiles.CreateLossProfileJobWorker":{format_args:[8,4,1,""],model_id:[8,4,1,""],profile_id:[8,4,1,""],pruning_estimation_type:[8,4,1,""],pruning_estimations:[8,4,1,""],pruning_structure:[8,4,1,""],quantized_estimations:[8,4,1,""],run:[8,4,1,""]},"sparsify.workers.projects_profiles.CreatePerfProfileJobWorker":{batch_size:[8,4,1,""],core_count:[8,4,1,""],format_args:[8,4,1,""],iterations_per_check:[8,4,1,""],pruning_estimations:[8,4,1,""],quantized_estimations:[8,4,1,""],run:[8,4,1,""],warmup_iterations_per_check:[8,4,1,""]},sparsify:{app:[1,0,0,"-"],blueprints:[2,0,0,"-"],log:[1,0,0,"-"],models:[5,0,0,"-"],schemas:[6,0,0,"-"],utils:[7,0,0,"-"],workers:[8,0,0,"-"]}},objnames:{"0":["py","module","Python module"],"1":["py","function","Python function"],"2":["py","exception","Python exception"],"3":["py","class","Python class"],"4":["py","method","Python method"],"5":["py","attribute","Python attribute"]},objtypes:{"0":"py:module","1":"py:function","2":"py:exception","3":"py:class","4":"py:method","5":"py:attribute"},terms:{"100":4,"404":4,"5543":11,"abstract":[5,8],"case":[15,16,19,24],"class":[4,5,6,8],"default":[4,5,11,16,17],"enum":[5,6],"export":[9,14,15,21,22,24,25],"final":[4,9,12,19],"float":[4,5,16,17,24],"function":[4,5,7],"import":[7,18],"int":[1,3,4,8],"long":[17,24],"new":[4,9,14,16,20,25],"null":5,"public":[8,11],"return":[1,4,5,6,7,8,15,16,22],"static":8,"true":[4,8],"try":[18,22],"while":[6,9,14,17,19,24],Adding:[9,16,25],And:[15,24],For:[9,11,14,15,16,17,18,19,20,22,24],One:24,Such:7,The:[6,8,9,11,13,15,16,17,18,19,20,21,22,24],Then:[16,17,18,20,22],There:[18,19],These:[16,19,21],Use:[6,12,14],Used:5,Using:20,Will:4,_dataloaderjobwork:8,_hidden:5,_modelloaderjobwork:8,abl:4,about:[9,13,17,18,25],acceler:12,accept:[11,15,22],access:[8,11,19,23],accordingli:21,accuraci:[9,12,19,24],achiev:[9,12,17,24],across:[17,19,24],activ:[9,14,19,24],add:[4,17,18,19,20],added:8,addit:[8,11,14,16,19,24,25],addition:[9,11],address:11,adjust:19,advanc:12,affect:[14,15,16,17,18,19,24],after:[4,6,8,11,14,18,19,20,21,22,24],again:[14,20],algorithm:[11,14,15],alia:[4,5],all:[1,4,5,6,8,9,12,16,17,19,20,22,24],allow:[8,11,23],along:[1,11],alpha:12,alphanumer:15,alreadi:[18,19,20],also:[16,17,18,20,24],altern:9,alwai:[4,17],amount:24,analysi:[4,5,6,8,11,13,14,15,24],analyz:[9,12,13,19,25],ani:[3,4,6,7,8,12,14,15,16,21,23,24],anoth:20,anyth:[6,8],anywher:15,api:[2,9],app:[0,5,6,9],appear:17,appli:[4,9,14,16,17,19,24],applic:2,apply_node_overrid:4,approach:9,appropri:[8,20],approxim:[16,18,24],architect:17,architectur:[6,16,18,24],area:[13,17],arg:[4,5,6,8],argument:6,artifici:15,assign:4,associ:6,attr:[6,8],attribut:[6,24],autofield:5,automat:[4,9,14,15,19],automl:11,avail:[6,7,8,11,13,17,24],available_ml_engin:7,averag:[18,19,20,24],avoid:12,avx2:24,avx512:24,awai:24,awar:11,back:[15,16,17],background:8,balanc:19,balance_perf_loss:[4,5],bar:[13,14,15,17,18,23],base:[0,1,4,6,7,15,17,20,21],basecreatedmodifiedmodel:5,basecreatedmodifiedmodeldoesnotexist:5,basejobwork:8,baselin:[4,6,9,11,17,18,20,24],baseline_spars:4,basemodel:5,basemodeldoesnotexist:5,baseprofilejobwork:8,baseprojectmodel:5,baseprojectmodeldoesnotexist:5,baseprojectprofil:5,baseprojectprofile_set:5,baseprojectprofiledoesnotexist:5,basi:[17,19],basic:12,batch:[8,15,16,17,20,24],batch_siz:[3,5,8],batchnorm:24,becaus:[16,18],been:24,befor:[4,8,15,24],begin:[8,11,12,14,15,24],being:[8,16],belong:8,below:[11,19,20],benchmark:[1,2,4,5,6,8,9,12,14,16,19,24,25],benchmark_id:[4,5,8],best:[4,6,9,11,12,19],better:[9,11,17,19,24],between:[9,12,18,19],bit:24,black:13,block_4:8,blog:9,blueprint:[0,1],bool:[1,4,6,8],booleanfield:5,both:[11,16,17],bottom:11,brows:[11,15],browser:[11,15],bug:[9,12],build:9,busi:[20,22],button:[11,13,19,20,21,23],call:4,callabl:3,can:[1,5,8,9,11,14,15,16,17,18,19,20,21,22,23,24,25],cancel:[5,8,15],cancel_job:8,cannot:11,chanc:[18,19,24],chang:[14,15,16,17,19,20,21,23],charact:15,charfield:5,check:[8,10,11,12,20],choic:[5,19],choos:[11,21],chronolog:20,classif:16,classmethod:8,click:[11,15,16,17,18,19,20,21,23],clipboard:22,close:[19,24],code:[1,6,8,9,11,14,19,21,24,25],code_sampl:[1,2],collat:5,color:14,column_nam:5,combin:[9,12],come:17,command:[11,13,15],common:[11,16],compar:[9,19,24,25],comparison:[8,20],compat:13,complet:[5,8,11,15,16,18,24],compress:[5,12,14,18],comput:[15,17,24],concept:[9,22,23,25],condit:20,confid:[18,19,24],config:[4,9,21,25],config_path:3,configur:[8,11,14,15,19,21,22],confirm:11,consid:16,consider:16,consist:[1,17,18,19],consol:11,constant:17,constraint:5,constructor:8,consult:15,contain:[4,5,6,7,8,9,12],content:[0,9],context:6,continu:[11,15,16,17,18,19,20,24],contribut:[15,24],control:[19,22,24],conv:24,convers:17,convert:11,convolut:[17,24],copi:[8,11,22],core:[7,8,15,16,17,20,24],core_count:[5,8],correct:5,correctli:[4,9,11],correl:18,correspond:[18,19,21],cost:24,could:8,count:[8,9,16,17,20,24,25],cpu:[9,16,17,20,24],creat:[1,4,5,6,9,11,13,14,19,20,25],create_config:4,create_work:8,createbenchmarkjobwork:8,createlossprofilejobwork:8,createperfprofilejobwork:8,createprojectbenchmarkschema:6,createprojectlossprofileschema:6,createprojectoptimizationschema:6,createprojectperfprofileschema:6,createupdateprojectdataschema:6,createupdateprojectmodelschema:6,createupdateprojectoptimizationmodifierslrscheduleschema:6,createupdateprojectoptimizationmodifierspruningschema:6,createupdateprojectoptimizationmodifiersquantizationschema:6,createupdateprojectoptimizationmodifierstrainableschema:6,createupdateprojectschema:6,creation:11,criteria:[20,22],csv:5,csvfield:5,csvfloatfield:5,csvintfield:5,current:[4,6,7,8,11,12,14,15,17,18,19,21,24],custom:[6,19],cut:[15,24],data:[2,3,4,5,6,8,15,24],data_dump_and_valid:6,data_id:[4,5,8],data_path:4,databas:[5,6,8],database_setup:5,datafrompathjobwork:8,datafromrepojobwork:8,dataset:[3,6,9],date:5,datetimefield:5,db_column:5,db_valu:5,debian:10,debug:1,deep:[9,12],deeper:[13,17],deepspars:[7,9,13,15,17,24],default_epochs_distribut:4,default_pruning_set:4,default_train:4,defin:[17,18,24],degre:11,delet:[5,6,23],delete_filesystem:5,deleteprojectmodelschema:6,deleteprojectschema:6,dens:17,depend:[16,17,20],deploi:[9,12,16],deploy:[12,16],depth:[10,11,24],desc:6,describ:[16,19,20,22],descript:[5,15,21],deseri:6,desir:11,detail:[4,12,13,14,16,19,24],detect:16,determin:[15,16,17,19,20,24],dev:9,devic:3,dialog:[15,16,17,18,19,23],dict:[4,6,7,8],dictionari:[4,6,7,8],did:[18,22,24],differ:[11,17,19,20,22],differenti:15,dir_path:5,dir_siz:5,direct:9,directori:5,disabl:[16,20],discuss:12,disk:22,displai:[11,15,16,17,19,20,23,24,25],distribut:4,doc:9,document:[9,11,15],doe:[15,24],doesnotexist:5,doing:[8,20],domain:[6,16],done:[18,19,24],down:[17,20],download:[8,9,11],drag:15,dramat:24,drill:17,driven:9,drop:20,dump:6,dump_field:6,dump_onli:6,duplic:12,dure:[13,14,15,18,19,21,22,24],each:[4,8,14,16,17,18,19,24],easi:[9,11,12],easili:[9,11,15],ecosystem:15,edit:[9,11,19,23],editor:19,effect:[4,9,11,14,15,16,17,18],effici:17,either:[8,11,15,17,20],emgin:15,emploi:24,empti:15,enabl:[9,11,14,15,17,20,24],encod:[9,22],encompass:9,encount:[4,6,7],end:[4,9,15,19,24],end_epoch:[4,5],engin:[7,9,12,13,17,24,25],ensur:13,enter:[11,15,16,17,18,19,23],entir:[17,18],entri:11,enum_class:6,enumer:5,enumfield:6,environ:[10,11,12],epoch:[4,19,24],equat:17,error:[0,1,4,5,7,8,12],errorschema:6,est_loss_sensit:5,est_perf_sensit:5,est_recoveri:5,est_tim:5,est_time_baselin:5,est_time_gain:5,establish:19,estim:[4,6,11,14,15,17,18,19,20,24],etc:[4,7],eval_baselin:4,eval_prun:4,eval_sensitivity_spars:4,evalu:4,even:17,event:6,eventu:16,everi:19,everyth:9,exact:18,examin:20,exampl:[9,12,14,15,16,17,18,19,20,22,24],except:[4,7,8],exchang:[15,24],exclud:6,execut:[16,24],exist:[5,9,12,14,20,21,25],exit:8,expect:[4,5,6,19],experi:[10,12],explor:[21,22],exponenti:6,extend:[5,8],extens:17,extern:1,extract:8,factor:17,fals:[4,5,6,8],fast:[9,16,17,24],faster:[9,14,17,19,24],fastest:17,featur:[9,12,15,22,23,25],fed:24,feedback:[9,19,25],few:[9,11],fewer:[17,18,24],fft:9,field:[4,5,6,8,11,15],field_nam:6,field_typ:5,file:[1,2,5,6,8,9,11,12,14,15,19,21,25],file_path:5,filestorag:5,fill:11,filter:[6,19],filter_min_perf_gain:[4,5],filter_min_recoveri:[4,5],filter_min_spars:[4,5],final_lr:5,find:11,fine:[4,19],fine_tuning_epoch:4,fine_tuning_start_epoch:4,finish:11,five:14,fix:20,flask:[2,4,5,6],floatfield:5,flop:[5,16,17,19,24],flops_baselin:5,flops_gain:5,flow:[9,11,14,21,22,24],focus:[11,24],folder:5,follow:[11,12,13,15,17,18,19,24],footprint:9,foreignkeyfield:5,format:[1,8,9,11,15,22],format_arg:8,found:[4,8,9],framework:[4,6,11,12,17,21],frequenc:19,from:[1,4,5,6,8,9,10,11,12,15,16,17,18,19,20,23,24,25],full:9,further:[11,15,16,18],futur:[11,14,18,19,24],gemm:24,gener:[4,9,14,16,17,19,21,22,23,24],get:[4,6,13,14,15,17,19,20],get_main_logg:1,get_ml_sys_info:7,get_profiles_by_id:4,get_project_benchmark_by_id:4,get_project_by_id:4,get_project_data_by_id:4,get_project_model_by_project_id:4,get_project_optimizer_by_id:4,get_root_logg:1,get_typ:8,getprojectoptimizationbestestimatedresultsschema:6,github:[9,12],give:[9,19],given:[4,5,8,11,24],global_end_epoch:4,global_start_epoch:4,globalaveragepool:24,goal:[12,14,15,19,21],going:[15,17,24],good:5,gpu:9,grai:16,grain:19,graph:[17,18,19,20,24],greater:[4,19,24],guid:[9,10,15],handl:[1,2,5,6,8],happen:[11,19],has:[17,18,24],have:[4,5,11,18,20,24],held:17,help:[9,17,19,25],help_text:5,helper:[0,1,2],here:[20,24],higher:[19,24],home:11,host:[1,9,11],how:[9,14,15,16,17,18,19,21,24],howev:19,http:11,httpnotfounderror:4,icon:[17,18,19],identifi:[16,17,18],ids:4,imag:16,implement:[8,9,24],improv:[9,12,14],includ:[5,6,7,8,9,12,14,17,18,21,22,23,24],inclus:11,increas:17,increasingli:19,independ:24,index:5,index_typ:5,indic:[14,16,17,18,19,20,24],individu:24,induc:9,industri:[9,12],infer:[7,8,9,11,14,15,16,17,24,25],inference_engin:8,inference_model:[5,8],inference_model_optim:8,info:[1,4,6,7],inform:[8,9,11,12,14,15,16,17,18,19,20,22,23,24,25],init:5,init_lr:5,initi:[4,5,13,19,21],input:[4,6,16,24],insight:[9,12],instal:[9,11,12,25],instanc:[5,8],instant:19,instead:[4,17,19],instruct:[7,8,15,17,24],instruction_set:[5,8],integ:5,integerfield:5,integr:[9,11,12,13,19,20,22,25],intellig:15,intens:[17,24],interact:11,intern:24,invalid:6,invok:4,involv:14,issu:12,item:[17,24],iter:8,iterations_per_check:[5,8],its:[4,6,11],job:[0,1,8],job_id:[5,8],jobcancelationfailureerror:8,jobdoesnotexist:5,jobnotfounderror:8,jobprogressschema:6,jobschema:6,jobstatu:5,jobstatusfield:5,jobwork:8,jobworkermanag:8,jobworkerregistri:8,join:4,json_dump:5,json_load:5,jsonfield:5,just:[15,16],keep:10,kei:[6,9,22,23,25],keyword:6,know:[15,24],kwarg:[5,6,8],lai:19,larg:[5,16],larger:[17,24],last:[8,18],latenc:16,later:[8,19],latest:[12,14,19,24],launch:[8,9,11,25],layer:[9,14,15,16,19,24,25],learn:[5,12,14,22,24,25],least:18,left:[11,13,15,19,23],less:[4,19],level:[1,4,5,9,19],light:12,like:16,limit:[9,11,17],line:[9,11],linux:10,list:[4,5,7,8,13,14,15,17,18,19,24],listobjfield:5,load:[5,6,9,11,15,17],load_field:6,load_onli:6,loadabl:6,local:[5,8,9,11,15],locat:[5,11],log:[0,9,24],logger:1,logging_level:1,longer:[17,24],look:[15,16,17,24],loss:[2,3,4,5,6,8,9,11,12,14,15,16,17,19,24,25],loss_analysi:4,losswrapp:3,low:24,lower:[11,22],lr_mod:[4,5],lr_sched:4,lr_schedule_modifi:5,ma_field:6,machin:[11,24],magic:[8,9,12,13,17,24],mai:[5,11,12,16,17,18,20,24],main:[1,11],maintain:12,major:17,make:[2,14,18,19,23,24],manag:[0,1,24],mani:[6,14,16,18,24],map:6,mark:8,marshmallow:6,mask_typ:[4,5],matter:4,max_node_spars:4,max_work:8,maxim:[4,13],maximum:8,maxpool:24,mean:24,measur:[6,8,14,16,17,18,19,20,24],memori:24,mention:[22,23],menu:20,messag:[12,16],metadata:[6,24],method:11,metric:[4,6,9,11,16,20],might:[14,16,17,18,20],millisecond:[17,24],minim:[14,21],minimum:19,minut:9,miss:6,ml_engines_error:7,mod:4,mod_end_epoch:4,mod_start_epoch:4,modal:11,model:[0,1,2,3,4,6,8,9,12,13,14,15,20,21,22,24,25],model_analysi:4,model_id:[5,8],model_path:4,model_repo:[0,1],modelfrompathjobwork:8,modelfromrepojobwork:8,modelrepoarchitectureschema:6,modelrepodatasetschema:6,modelrepodomainschema:6,modelrepomodeldescschema:6,modelrepomodelmetricschema:6,modelrepomodelperfschema:6,modelrepomodelschema:6,modif:19,modifi:[2,4,5,6,14,21,22,24,25],modifier_id:5,modul:[0,9],more:[11,13,17,18,19,24],most:[11,17,18,20],move:[11,19],much:[11,15,16,18,19,24],multi:6,multipl:[5,6,13,15,16,19,20],must:[4,5,8,11,19],name:[4,5,8,15,16,17,18,24],namespac:1,natur:9,navig:[11,13,14,15,17,18,23],nearli:9,need:[9,11,12,14,15,19,21],nest:5,network:[1,9,11,12,15,18,24],neural:[1,8,9,12,13,15,17,24],next:[8,12,13,14,15,16,17,18,19,20,21,22,23,24],nightli:9,node:[4,5,6,17,24],node_overrid:4,none:[4,5,6,8],note:[5,11,15,16,17,18,19,20],notic:[9,19],npz:8,number:[4,7,8,16,18,19,24],numer:16,object:[4,5,6,8,16],occur:[6,9,19],offici:9,offlin:16,often:19,oldest:8,onc:[8,11,14,15,19],one:[5,8,11,15,19,24],one_shot:8,ones:8,onli:[4,5,6,8,9,11,15,19],onlin:16,onnx:[7,8,11,14,15,17,20,24],onscreen:12,onto:8,open:[9,11,14,19,24,25],oper:[9,12,16,17,24],ops:[6,24],opt:[6,16],optim:[1,2,3,4,5,6,9,12,13,15,16,17,18,20,21,24,25],optim_const:3,optim_id:[4,5],optim_lr_sched_default_mod:4,optim_lr_sched_updat:4,optim_pruning_updat:4,optim_trainable_default_nod:4,optim_trainable_updat:4,optim_updat:4,optim_validate_and_get_project_by_id:4,optimepoch:4,option:[1,4,5,6,8,11,12,13,14,16,17,19,20],order:[10,20,24],origin:[4,11,15,17,18,19,20,23,24],ort:[17,24],ort_cpu:7,ort_gpu:7,other:[1,17,19,24],otherwis:[4,8,19],out:[8,10,11,15,16,19,24],over:9,overprecis:9,overrid:[4,5,22],overview:[13,25],own:10,packag:[0,9,11],page:[11,13,15],parallel:8,param:[5,9,19,24,25],paramet:[1,4,5,6,8,14,16,18,24],parameter:9,params_baselin:5,part:[15,21,24],partial:6,pass:[6,15,24],path:[5,6,8,11,12,15],peewe:5,pend:[5,8],per:[16,17,19,24],percentag:[17,24],perf:[4,5,6,8],perf_analysi:4,perform:[2,4,5,6,8,9,11,12,13,14,15,16,18,19,24,25],perhap:22,pip:[10,13],pipelin:11,place:[11,19],plan:12,platform:21,playhous:5,pleas:12,plu:9,point:[8,11,16,17,24],pool:24,popup:11,port:[1,11],portion:[1,17],possibl:[17,19,24],post:12,potenti:[7,9,12,14,17],practic:14,practition:[9,12],present:[8,24],preset:19,previou:15,primary_kei:5,problem:17,procedur:15,process:[8,9,12,19,21,22,24],product:[9,12],profil:[2,4,5,6,8,9,11,14,15,19,24,25],profile_id:[5,8],profile_loss:[4,5],profile_loss_id:[4,5],profile_perf:[4,5],profile_perf_id:[4,5],profiles_loss:5,profiles_perf:5,program:24,progress:[5,6,8],project:[0,1,8,9,14,16,17,18,22,23,24,25],project_data:8,project_id:[4,5,8],projectavailablemodelmodificationsschema:6,projectbenchmark:[4,5],projectbenchmark_set:5,projectbenchmarkdoesnotexist:5,projectbenchmarkresultschema:6,projectbenchmarkresultsschema:6,projectbenchmarkschema:6,projectdata:[4,5],projectdata_set:5,projectdatadoesnotexist:5,projectdataschema:6,projectdoesnotexist:5,projectextschema:6,projectlossprofil:[4,5],projectlossprofile_set:5,projectlossprofiledoesnotexist:5,projectlossprofileschema:6,projectmodel:[4,5],projectmodel_set:5,projectmodelanalysisschema:6,projectmodeldoesnotexist:5,projectmodelschema:6,projectoptim:[4,5],projectoptimization_set:5,projectoptimizationdoesnotexist:5,projectoptimizationmodifierestimationsschema:6,projectoptimizationmodifierlrexponentialargsschema:6,projectoptimizationmodifierlrmultistepargsschema:6,projectoptimizationmodifierlrschedul:[4,5],projectoptimizationmodifierlrscheduledoesnotexist:5,projectoptimizationmodifierlrscheduleschema:6,projectoptimizationmodifierlrschema:6,projectoptimizationmodifierlrsetargsschema:6,projectoptimizationmodifierlrstepargsschema:6,projectoptimizationmodifierprun:[4,5],projectoptimizationmodifierpruningdoesnotexist:5,projectoptimizationmodifierpruningnodemetadataschema:6,projectoptimizationmodifierpruningnodeschema:6,projectoptimizationmodifierpruningschema:6,projectoptimizationmodifierquant:5,projectoptimizationmodifierquantizationdoesnotexist:5,projectoptimizationmodifierquantizationnodeschema:6,projectoptimizationmodifierquantizationschema:6,projectoptimizationmodifiertrain:[4,5],projectoptimizationmodifiertrainabledoesnotexist:5,projectoptimizationmodifiertrainablenodeschema:6,projectoptimizationmodifiertrainableschema:6,projectoptimizationschema:6,projectperfprofil:[4,5],projectperfprofile_set:5,projectperfprofiledoesnotexist:5,projectperfprofileschema:6,projectprofileanalysisschema:6,projectprofilemeasurementschema:6,projectprofilemeasurementsschema:6,projectprofilemodelopsbaselinemeasurementsschema:6,projectprofilemodelopsmeasurementsschema:6,projectprofileopbaselinemeasurementschema:6,projectprofileopmeasurementsschema:6,projectprofileopschema:6,projectprofileschema:6,projects_benchmark:[0,1],projects_data:[0,1],projects_model:[0,1,4],projects_optim:[0,1],projects_optimizations_prun:[1,2],projects_profil:[0,1,4],projectschema:6,proper:[8,11],properli:11,properti:[4,5,8],provid:[4,7,11,12,14,16,17,18,19,22],prunabl:[4,18],prune:[4,5,6,8,9,14,16,17,18,22,24,25],pruning_end_epoch:4,pruning_epoch:4,pruning_estim:[5,8],pruning_estimation_typ:[5,8],pruning_modifi:5,pruning_set:4,pruning_start_epoch:4,pruning_structur:[5,8],pruning_update_frequ:4,pruningmodelevalu:4,pruningset:4,put:[8,14],pypi:9,python:10,python_valu:5,pytorch:[3,15,17,21],pytorch__integr:[1,2],pytorch__train:[1,2],quantiz:[5,6,8,9,14,18,19,24],quantization_modifi:5,quantized_estim:[5,8],quantized_estimation_typ:5,queri:6,quick:9,quickli:[14,16],rais:[4,6,8],raise_not_found:4,ran:[17,19,20,24],rang:[18,19,24],rapidli:[9,12],rate:[5,22,24,25],rather:[14,15,19,20,24],raw:6,read:11,readi:[16,17,18,19],real:16,recent:20,recip:9,recommend:[4,10],recov:[9,18,19,22,24],recoveri:[4,9,11,18,19,24],redistribut:19,reduc:[18,24],reduct:[18,24],redund:[9,18],refer:15,referenc:16,reflect:23,refresh:[5,8],registri:8,rel:[18,19],relat:[2,6,8],releas:[11,12,18],relev:24,relu:24,remot:[11,15],remov:[9,19,24,25],repo:[2,6,8],report:6,repositori:[9,10,11],repres:[17,19],reproduc:12,request:[2,9,12],requir:[6,11,12,16,19,24],research:[9,12],respond:[14,18,24],respons:6,responsejobschema:6,responsejobsschema:6,responsemodelrepomodel:6,responseprojectbenchmarkdeletedschema:6,responseprojectbenchmarkschema:6,responseprojectbenchmarksschema:6,responseprojectdatadeletedschema:6,responseprojectdataschema:6,responseprojectdatasingleschema:6,responseprojectdeletedschema:6,responseprojectextschema:6,responseprojectlossprofileschema:6,responseprojectlossprofilesschema:6,responseprojectmodelanalysisschema:6,responseprojectmodeldeletedschema:6,responseprojectmodelschema:6,responseprojectoptimizationdeletedschema:6,responseprojectoptimizationframeworksavailablesamplesschema:6,responseprojectoptimizationframeworksavailableschema:6,responseprojectoptimizationmodifierdeletedschema:6,responseprojectoptimizationmodifiersavail:6,responseprojectoptimizationmodifiersbestestim:6,responseprojectoptimizationschema:6,responseprojectoptimizationsschema:6,responseprojectperfprofileschema:6,responseprojectperfprofilesschema:6,responseprojectprofiledeletedschema:6,responseprojectschema:6,responseprojectsschema:6,responsesysteminfo:6,restructur:24,result:[4,5,6,9,11,15,18,19,20,22,25],retain:16,retrain:[11,14,17,18,19,24],retriev:[4,8],review:[9,14,16,22,23,25],rewrit:21,right:[11,13,19,20],root:[1,5],root_path:5,rough:18,rout:[2,6],rule:11,run:[1,6,8,9,11,13,14,15,16,17,18,22,24,25],runtim:[17,20,24],same:[9,15,20],sampl:[5,6,11,24],satisfi:[14,19],save:[5,8,19,22,23],scale:[9,12,20],scenario:20,schedul:[4,5,6,19,24],schema:[0,1],schemaopt:6,scheme:16,screen:[9,11,15,17,19,21,25],screenshot:12,script:[1,11],scroll:19,search:6,searchjobsschema:6,searchmodelrepomodel:6,searchprojectbenchmarksschema:6,searchprojectdataschema:6,searchprojectoptimizationsschema:6,searchprojectprofilesschema:6,searchprojectsschema:6,second:[16,17,24],section:[14,17,18,19,23],see:[11,16,17,18,19,20,24],select:[11,15,16,17,19,20,24],sens:19,sensit:[9,11,14,24,25],separ:[11,24],sequenc:[5,6,24],sequenti:24,serial:6,serv:2,server:[1,2,5,6,8,11,15],set:[1,4,5,6,7,8,9,11,14,15,17,18,19,20,22,24,25],set_logging_level:1,setprojectdatafromschema:6,setprojectmodelfromschema:6,setup:[1,2,3,4,5,16,17,18,24],setup_filesystem:5,sever:15,share:12,shot:11,should:[4,8,16,19,22,24],show:[9,11,14,16,17,18,19,20,24],shown:[11,17],shuffl:[17,24],shutdown:8,side:15,signific:[17,18],significantli:[9,18,24],simpl:[9,14],simpli:[15,24],simplifi:[9,12],sinc:8,singl:[6,9,13,24,25],size:[5,8,9,12,15,16,17,18,20,24],slide:[9,12],slider:19,smaller:[9,14,17,24],smallest:24,softmax:24,softwar:12,some:[6,11],sort:20,sourc:[1,3,4,5,6,7,8,15],space:15,spars:[9,14,17,19],sparse_training_avail:4,sparseml:[3,9,11,15,21],sparsezoo:9,sparsif:[11,24],sparsifi:[10,11,15,16,17,18,21,22,23,24,25],sparsiti:[4,5,9,19,22,24],special:15,specif:[4,6,17,20,24],specifi:[11,18,19,20,24],speed:[9,11,12,17],speedup:[17,19,24],spent:17,sqlite_ext:5,stabil:19,stabilization_epoch:4,stabl:9,stage:19,standard:1,start:[4,5,8,9,11,15,19,20,24,25],start_epoch:[4,5],start_fine_tuning_epoch:4,state:5,statu:5,step:[4,6,8,12,13,14,16,17,18,19,20,21,22,23,24],stop:8,storag:5,store:[5,6,8],str:[1,3,4,5,6,7,8],string:[5,6],sub:8,subclass:8,subgraph:17,submit:12,submodul:[0,9],subpackag:[0,9],subsequ:8,substitut:11,suggest:12,suit:[9,12],summari:[9,12,24,25],support:[9,12],sure:12,system:[0,1,5,8,10,11,16,19,22,24],systeminfo:6,tabl:19,take:[9,16,17,19,24],taken:19,tar:8,target:[11,16],techniqu:[9,12,14,19,24],tell:24,tensor:3,tensorflow:[15,17,21],tensorflow__integr:[1,2],term:[9,22,23,25],termin:11,test:10,textfield:5,than:[4,14,15,19,20,24],thei:[14,16,20,24],theoret:[16,17,24],therefor:[11,16,17],thi:[4,8,9,10,11,14,15,16,17,18,19,20,21,22,23,24,25],those:[11,17,18,19,24],thread:24,threadpoolexecutor:8,three:[14,17,18,19,20,23],through:[8,11,17,19,24],throughout:[15,16,19,22,23],throughput:[16,17],tied:[17,19],time:[4,8,14,15,16,17,19,24],timestamp:5,to_dict_valu:4,took:[17,24],tool:[9,12,24],tooltip:19,top:[9,19],torch:3,total:[18,24],tour:[9,10],track:5,train:[3,4,9,11,14,21,22,23,24,25],train_dataset:3,train_setup:3,trainabl:[4,5,6],trainable_modifi:5,training_epoch:[4,5],training_final_lr:4,training_init_lr:4,training_lr_fin:5,training_lr_init:5,training_optim:5,transfer:[14,19],tune:[4,19],tupl:4,twice:19,two:[17,18,19,20],type:[5,6,8,11,13,17,18,19,24],type_:5,typic:24,ui_path:1,ultim:9,under:[8,11],understand:15,unindex:5,union:[3,4,6,8],uniqu:[5,15,24],unknown:6,unspecifi:15,unstructur:8,unsur:16,updat:[4,5,6,8,19],update_frequ:[4,5],updateprojectoptimizationschema:6,upload:[6,11,14,15],upper:[11,13],uri:[6,8],url:[6,8,11,15],use:[4,6,8,9,11,12,15,16,19,20,22,24],used:[1,5,6,11,12,15,16,17,18,19,20,22,24],user:[4,9,10,12,24],uses:24,using:[9,10,11,12,14,15,19,20,24],util:[0,1,2,3,17,24],val_dataset:3,valid:[4,5,6,7],validate_filesystem:5,validate_model_data:4,validate_pruning_nod:4,validationerror:6,valu:[4,5,6,7,14,17,18,19,20,22,24],valuabl:[15,24],varchar:5,vari:17,variou:[16,17,24],verbose_nam:5,veri:18,version:[12,14,15,20],versioninfoschema:6,via:9,view:[16,24],virtual:10,visit:11,visual:[9,12,17,19],vnni:24,wai:[12,15,16,17,19,24],want:[14,15,16,17,18,19,20,24],warmup:8,warmup_iterations_per_check:[5,8],web:11,websit:9,week:9,weight:[17,18,24],weight_magnitud:8,welcom:[9,25],well:[16,17,18,24],went:17,were:[17,18,24],what:[4,17,19,24],when:[4,7,9,14,15,16,17,18,19,24],where:[5,9,11,17,24],which:[13,15,16,17,18,19,20,24],who:[9,12],width:24,window:11,winograd:9,within:[8,24],without:[8,14,16,17,24],won:8,work:[5,6,8,14,21],worker:[0,1,6],worker_ack:5,worker_arg:5,workflow:[9,11,14],working_dir:[1,3,5],would:[5,17,18,22],yaml:4,yet:20,yml:[14,21,22],you:[9,11,12,14,15,16,17,18,19,20,21,22,23,24,25],your:[9,10,11,12,13,14,15,17,18,19,20,21,22,23,24],zero:18},titles:["sparsify","sparsify package","sparsify.blueprints package","sparsify.blueprints.code_samples package","sparsify.blueprints.utils package","sparsify.models package","sparsify.schemas package","sparsify.utils package","sparsify.workers package","Sparsify 0.1","Installation","Quick Tour","Welcome to Sparsify","Installing and Launching Sparsify","Sparsify Overview","Analyze","Profiling Your Model","Reviewing Performance Profiles","Reviewing Loss Profiles","Optimize","Benchmarking","Integrate","Optimization Config File and Code for Optimization","Settings","Key Concepts/Features/Terms","User Guide"],titleterms:{"export":[11,19],"new":[11,13,15,17,18],Adding:[17,18],about:12,addit:13,analyz:[11,14,15],app:1,base:[5,8],benchmark:20,blueprint:[2,3,4],can:13,code:22,code_sampl:3,compar:20,concept:24,config:22,content:[1,2,3,4,5,6,7,8],count:18,creat:15,displai:13,engin:20,error:[2,6],exist:[13,15],featur:24,feedback:12,file:22,from:13,guid:[12,25],help:12,helper:[4,6],histori:9,infer:20,inform:13,instal:[10,13],integr:[14,21],job:[2,5,6],kei:24,launch:13,layer:[17,18],learn:[9,19],log:1,loss:18,manag:8,model:[5,11,16,17,18,19],model_repo:[2,6],modifi:19,modul:[1,2,3,4,5,6,7,8],more:9,open:[13,15],optim:[11,14,19,22],overview:[9,14],packag:[1,2,3,4,5,6,7,8],param:18,perform:17,profil:[16,17,18],project:[2,4,5,6,11,13,15],projects_benchmark:[2,4,5,6,8],projects_data:[2,4,5,6,8],projects_model:[2,5,6,8],projects_optim:[2,4,5,6],projects_optimizations_prun:4,projects_profil:[2,5,6,8],prune:19,pytorch__integr:3,pytorch__train:3,quick:11,rate:19,recip:11,releas:9,remov:20,resourc:9,result:17,review:[17,18],run:[19,20],schema:6,screen:13,sensit:18,set:23,singl:20,sparsif:9,sparsifi:[0,1,2,3,4,5,6,7,8,9,12,13,14,19],start:13,submodul:[1,2,3,4,5,6,7,8],subpackag:[1,2],summari:[17,18,19],system:[2,6,7],tensorflow__integr:3,term:24,thi:12,tour:11,train:19,user:25,util:[4,5,7],welcom:12,worker:8,you:13,your:16}}) \ No newline at end of file +Search.setIndex({docnames:["api/modules","api/sparsify","api/sparsify.blueprints","api/sparsify.blueprints.code_samples","api/sparsify.blueprints.utils","api/sparsify.models","api/sparsify.schemas","api/sparsify.utils","api/sparsify.workers","index","installation","quicktour","userguide/01-intro","userguide/02-install-sparsify","userguide/03-sparsify-overview","userguide/04-analyze","userguide/04a-profiling-your-model","userguide/04b-reviewing-performance-profiles","userguide/04c-reviewing-loss-profiles","userguide/05-optimize","userguide/05a-benchmark","userguide/06-integrate","userguide/06a-optimize-config","userguide/07-settings","userguide/08-key-terms","userguide/index"],envversion:{"sphinx.domains.c":2,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":3,"sphinx.domains.index":1,"sphinx.domains.javascript":2,"sphinx.domains.math":2,"sphinx.domains.python":2,"sphinx.domains.rst":2,"sphinx.domains.std":2,"sphinx.ext.intersphinx":1,"sphinx.ext.viewcode":1,sphinx:56},filenames:["api/modules.rst","api/sparsify.rst","api/sparsify.blueprints.rst","api/sparsify.blueprints.code_samples.rst","api/sparsify.blueprints.utils.rst","api/sparsify.models.rst","api/sparsify.schemas.rst","api/sparsify.utils.rst","api/sparsify.workers.rst","index.rst","installation.md","quicktour.md","userguide/01-intro.md","userguide/02-install-sparsify.md","userguide/03-sparsify-overview.md","userguide/04-analyze.md","userguide/04a-profiling-your-model.md","userguide/04b-reviewing-performance-profiles.md","userguide/04c-reviewing-loss-profiles.md","userguide/05-optimize.md","userguide/05a-benchmark.md","userguide/06-integrate.md","userguide/06a-optimize-config.md","userguide/07-settings.md","userguide/08-key-terms.md","userguide/index.rst"],objects:{"":{sparsify:[1,0,0,"-"]},"sparsify.app":{main:[1,1,1,""],run:[1,1,1,""]},"sparsify.blueprints":{code_samples:[3,0,0,"-"],errors:[2,0,0,"-"],jobs:[2,0,0,"-"],model_repo:[2,0,0,"-"],projects:[2,0,0,"-"],projects_benchmarks:[2,0,0,"-"],projects_data:[2,0,0,"-"],projects_model:[2,0,0,"-"],projects_optimizations:[2,0,0,"-"],projects_profiles:[2,0,0,"-"],system:[2,0,0,"-"],ui:[2,0,0,"-"],utils:[4,0,0,"-"]},"sparsify.blueprints.code_samples":{pytorch__training:[3,0,0,"-"]},"sparsify.blueprints.code_samples.pytorch__training":{train:[3,1,1,""],train_setup:[3,1,1,""]},"sparsify.blueprints.utils":{helpers:[4,0,0,"-"],projects:[4,0,0,"-"],projects_benchmark:[4,0,0,"-"],projects_data:[4,0,0,"-"],projects_optimizations:[4,0,0,"-"],projects_optimizations_pruning:[4,0,0,"-"]},"sparsify.blueprints.utils.helpers":{HTTPNotFoundError:[4,2,1,""]},"sparsify.blueprints.utils.projects":{get_project_by_id:[4,1,1,""],get_project_model_by_project_id:[4,1,1,""]},"sparsify.blueprints.utils.projects_benchmark":{get_project_benchmark_by_ids:[4,1,1,""]},"sparsify.blueprints.utils.projects_data":{get_project_data_by_ids:[4,1,1,""],validate_model_data:[4,1,1,""]},"sparsify.blueprints.utils.projects_optimizations":{OptimEpochs:[4,3,1,""],create_config:[4,1,1,""],default_epochs_distribution:[4,1,1,""],default_pruning_settings:[4,1,1,""],get_profiles_by_id:[4,1,1,""],get_project_optimizer_by_ids:[4,1,1,""],optim_lr_sched_default_mods:[4,1,1,""],optim_lr_sched_updater:[4,1,1,""],optim_pruning_updater:[4,1,1,""],optim_trainable_default_nodes:[4,1,1,""],optim_trainable_updater:[4,1,1,""],optim_updater:[4,1,1,""],optim_validate_and_get_project_by_id:[4,1,1,""],sparse_training_available:[4,1,1,""],validate_pruning_nodes:[4,1,1,""]},"sparsify.blueprints.utils.projects_optimizations.OptimEpochs":{end_epoch:[4,4,1,""],fine_tuning_epochs:[4,4,1,""],fine_tuning_start_epoch:[4,4,1,""],pruning_end_epoch:[4,4,1,""],pruning_epochs:[4,4,1,""],pruning_start_epoch:[4,4,1,""],pruning_update_frequency:[4,4,1,""],stabilization_epochs:[4,4,1,""],start_epoch:[4,4,1,""],training_epochs:[4,4,1,""]},"sparsify.blueprints.utils.projects_optimizations_pruning":{PruningModelEvaluator:[4,3,1,""],PruningSettings:[4,3,1,""]},"sparsify.blueprints.utils.projects_optimizations_pruning.PruningModelEvaluator":{EVAL_SENSITIVITY_SPARSITY:[4,5,1,""],MAX_NODE_SPARSITY:[4,5,1,""],apply_node_overrides:[4,4,1,""],eval_baseline:[4,4,1,""],eval_pruning:[4,4,1,""],to_dict_values:[4,4,1,""]},"sparsify.blueprints.utils.projects_optimizations_pruning.PruningSettings":{balance_perf_loss:[4,4,1,""],filter_min_perf_gain:[4,4,1,""],filter_min_recovery:[4,4,1,""],filter_min_sparsity:[4,4,1,""],mask_type:[4,4,1,""],sparsity:[4,4,1,""]},"sparsify.log":{get_main_logger:[1,1,1,""],get_root_logger:[1,1,1,""],set_logging_level:[1,1,1,""]},"sparsify.models":{base:[5,0,0,"-"],jobs:[5,0,0,"-"],projects:[5,0,0,"-"],projects_benchmark:[5,0,0,"-"],projects_data:[5,0,0,"-"],projects_model:[5,0,0,"-"],projects_optimizations:[5,0,0,"-"],projects_profiles:[5,0,0,"-"],utils:[5,0,0,"-"]},"sparsify.models.base":{BaseCreatedModifiedModel:[5,3,1,""],BaseModel:[5,3,1,""],CSVField:[5,3,1,""],CSVFloatField:[5,3,1,""],CSVIntField:[5,3,1,""],FileStorage:[5,3,1,""],ListObjField:[5,3,1,""]},"sparsify.models.base.BaseCreatedModifiedModel":{DoesNotExist:[5,5,1,""],created:[5,5,1,""],id:[5,5,1,""],modified:[5,5,1,""],save:[5,4,1,""]},"sparsify.models.base.BaseModel":{DoesNotExist:[5,5,1,""],id:[5,5,1,""],refresh:[5,4,1,""]},"sparsify.models.base.CSVField":{db_value:[5,4,1,""],python_value:[5,4,1,""]},"sparsify.models.base.CSVFloatField":{python_value:[5,4,1,""]},"sparsify.models.base.CSVIntField":{python_value:[5,4,1,""]},"sparsify.models.base.FileStorage":{init:[5,4,1,""],root_path:[5,4,1,""]},"sparsify.models.base.ListObjField":{db_value:[5,4,1,""],python_value:[5,4,1,""]},"sparsify.models.jobs":{Job:[5,3,1,""],JobStatus:[5,3,1,""],JobStatusField:[5,3,1,""]},"sparsify.models.jobs.Job":{DoesNotExist:[5,5,1,""],baseprojectprofile_set:[5,5,1,""],created:[5,5,1,""],error:[5,5,1,""],job_id:[5,5,1,""],modified:[5,5,1,""],progress:[5,5,1,""],project_id:[5,5,1,""],projectbenchmark_set:[5,5,1,""],projectdata_set:[5,5,1,""],projectlossprofile_set:[5,5,1,""],projectmodel_set:[5,5,1,""],projectperfprofile_set:[5,5,1,""],save:[5,4,1,""],status:[5,5,1,""],type_:[5,5,1,""],worker_ack:[5,5,1,""],worker_args:[5,5,1,""]},"sparsify.models.jobs.JobStatus":{canceled:[5,5,1,""],canceling:[5,5,1,""],completed:[5,5,1,""],error:[5,5,1,""],pending:[5,5,1,""],started:[5,5,1,""]},"sparsify.models.jobs.JobStatusField":{db_value:[5,4,1,""],field_type:[5,5,1,""],python_value:[5,4,1,""]},"sparsify.models.projects":{BaseProjectModel:[5,3,1,""],Project:[5,3,1,""]},"sparsify.models.projects.BaseProjectModel":{DoesNotExist:[5,5,1,""],delete_filesystem:[5,4,1,""],id:[5,5,1,""],setup_filesystem:[5,4,1,""],validate_filesystem:[5,4,1,""]},"sparsify.models.projects.Project":{DoesNotExist:[5,5,1,""],benchmarks:[5,5,1,""],created:[5,5,1,""],data:[5,5,1,""],delete_filesystem:[5,4,1,""],description:[5,5,1,""],dir_path:[5,4,1,""],dir_size:[5,4,1,""],models:[5,5,1,""],modified:[5,5,1,""],name:[5,5,1,""],optims:[5,5,1,""],profiles_loss:[5,5,1,""],profiles_perf:[5,5,1,""],project_id:[5,5,1,""],save:[5,4,1,""],setup_filesystem:[5,4,1,""],training_epochs:[5,5,1,""],training_lr_final:[5,5,1,""],training_lr_init:[5,5,1,""],training_optimizer:[5,5,1,""],validate_filesystem:[5,4,1,""]},"sparsify.models.projects_benchmark":{ProjectBenchmark:[5,3,1,""]},"sparsify.models.projects_benchmark.ProjectBenchmark":{DoesNotExist:[5,5,1,""],batch_sizes:[5,5,1,""],benchmark_id:[5,5,1,""],core_counts:[5,5,1,""],created:[5,5,1,""],inference_models:[5,5,1,""],instruction_sets:[5,5,1,""],iterations_per_check:[5,5,1,""],job:[5,5,1,""],job_id:[5,5,1,""],modified:[5,5,1,""],name:[5,5,1,""],project:[5,5,1,""],project_id:[5,5,1,""],result:[5,5,1,""],source:[5,5,1,""],warmup_iterations_per_check:[5,5,1,""]},"sparsify.models.projects_data":{ProjectData:[5,3,1,""]},"sparsify.models.projects_data.ProjectData":{DoesNotExist:[5,5,1,""],created:[5,5,1,""],data_id:[5,5,1,""],delete_filesystem:[5,4,1,""],dir_path:[5,4,1,""],file:[5,5,1,""],file_path:[5,4,1,""],job:[5,5,1,""],job_id:[5,5,1,""],project:[5,5,1,""],project_id:[5,5,1,""],setup_filesystem:[5,4,1,""],source:[5,5,1,""],validate_filesystem:[5,4,1,""]},"sparsify.models.projects_model":{ProjectModel:[5,3,1,""]},"sparsify.models.projects_model.ProjectModel":{DoesNotExist:[5,5,1,""],analysis:[5,5,1,""],created:[5,5,1,""],delete_filesystem:[5,4,1,""],dir_path:[5,4,1,""],file:[5,5,1,""],file_path:[5,4,1,""],job:[5,5,1,""],job_id:[5,5,1,""],model_id:[5,5,1,""],project:[5,5,1,""],project_id:[5,5,1,""],setup_filesystem:[5,4,1,""],source:[5,5,1,""],validate_filesystem:[5,4,1,""]},"sparsify.models.projects_optimizations":{ProjectOptimization:[5,3,1,""],ProjectOptimizationModifierLRSchedule:[5,3,1,""],ProjectOptimizationModifierPruning:[5,3,1,""],ProjectOptimizationModifierQuantization:[5,3,1,""],ProjectOptimizationModifierTrainable:[5,3,1,""]},"sparsify.models.projects_optimizations.ProjectOptimization":{DoesNotExist:[5,5,1,""],created:[5,5,1,""],end_epoch:[5,5,1,""],lr_schedule_modifiers:[5,5,1,""],modified:[5,5,1,""],name:[5,5,1,""],notes:[5,5,1,""],optim_id:[5,5,1,""],profile_loss:[5,5,1,""],profile_loss_id:[5,5,1,""],profile_perf:[5,5,1,""],profile_perf_id:[5,5,1,""],project:[5,5,1,""],project_id:[5,5,1,""],pruning_modifiers:[5,5,1,""],quantization_modifiers:[5,5,1,""],start_epoch:[5,5,1,""],trainable_modifiers:[5,5,1,""]},"sparsify.models.projects_optimizations.ProjectOptimizationModifierLRSchedule":{DoesNotExist:[5,5,1,""],created:[5,5,1,""],end_epoch:[5,5,1,""],final_lr:[5,5,1,""],init_lr:[5,5,1,""],lr_mods:[5,5,1,""],modified:[5,5,1,""],modifier_id:[5,5,1,""],optim:[5,5,1,""],optim_id:[5,5,1,""],start_epoch:[5,5,1,""]},"sparsify.models.projects_optimizations.ProjectOptimizationModifierPruning":{DoesNotExist:[5,5,1,""],balance_perf_loss:[5,5,1,""],compression:[5,5,1,""],created:[5,5,1,""],end_epoch:[5,5,1,""],est_loss_sensitivity:[5,5,1,""],est_perf_sensitivity:[5,5,1,""],est_recovery:[5,5,1,""],est_time:[5,5,1,""],est_time_baseline:[5,5,1,""],est_time_gain:[5,5,1,""],filter_min_perf_gain:[5,5,1,""],filter_min_recovery:[5,5,1,""],filter_min_sparsity:[5,5,1,""],flops:[5,5,1,""],flops_baseline:[5,5,1,""],flops_gain:[5,5,1,""],mask_type:[5,5,1,""],modified:[5,5,1,""],modifier_id:[5,5,1,""],nodes:[5,5,1,""],optim:[5,5,1,""],optim_id:[5,5,1,""],params:[5,5,1,""],params_baseline:[5,5,1,""],sparsity:[5,5,1,""],start_epoch:[5,5,1,""],update_frequency:[5,5,1,""]},"sparsify.models.projects_optimizations.ProjectOptimizationModifierQuantization":{DoesNotExist:[5,5,1,""],balance_perf_loss:[5,5,1,""],compression:[5,5,1,""],created:[5,5,1,""],end_epoch:[5,5,1,""],est_loss_sensitivity:[5,5,1,""],est_perf_sensitivity:[5,5,1,""],est_recovery:[5,5,1,""],est_time:[5,5,1,""],est_time_baseline:[5,5,1,""],est_time_gain:[5,5,1,""],filter_min_perf_gain:[5,5,1,""],filter_min_recovery:[5,5,1,""],flops:[5,5,1,""],flops_baseline:[5,5,1,""],flops_gain:[5,5,1,""],level:[5,5,1,""],modified:[5,5,1,""],modifier_id:[5,5,1,""],nodes:[5,5,1,""],optim:[5,5,1,""],optim_id:[5,5,1,""],params:[5,5,1,""],params_baseline:[5,5,1,""],start_epoch:[5,5,1,""]},"sparsify.models.projects_optimizations.ProjectOptimizationModifierTrainable":{DoesNotExist:[5,5,1,""],created:[5,5,1,""],end_epoch:[5,5,1,""],modified:[5,5,1,""],modifier_id:[5,5,1,""],nodes:[5,5,1,""],optim:[5,5,1,""],optim_id:[5,5,1,""],start_epoch:[5,5,1,""]},"sparsify.models.projects_profiles":{BaseProjectProfile:[5,3,1,""],ProjectLossProfile:[5,3,1,""],ProjectPerfProfile:[5,3,1,""]},"sparsify.models.projects_profiles.BaseProjectProfile":{DoesNotExist:[5,5,1,""],analysis:[5,5,1,""],created:[5,5,1,""],job:[5,5,1,""],job_id:[5,5,1,""],name:[5,5,1,""],profile_id:[5,5,1,""],source:[5,5,1,""]},"sparsify.models.projects_profiles.ProjectLossProfile":{DoesNotExist:[5,5,1,""],analysis:[5,5,1,""],created:[5,5,1,""],job:[5,5,1,""],job_id:[5,5,1,""],name:[5,5,1,""],profile_id:[5,5,1,""],project:[5,5,1,""],project_id:[5,5,1,""],projectoptimization_set:[5,5,1,""],pruning_estimation_type:[5,5,1,""],pruning_estimations:[5,5,1,""],pruning_structure:[5,5,1,""],quantized_estimation_type:[5,5,1,""],quantized_estimations:[5,5,1,""],source:[5,5,1,""]},"sparsify.models.projects_profiles.ProjectPerfProfile":{DoesNotExist:[5,5,1,""],analysis:[5,5,1,""],batch_size:[5,5,1,""],core_count:[5,5,1,""],created:[5,5,1,""],instruction_sets:[5,5,1,""],iterations_per_check:[5,5,1,""],job:[5,5,1,""],job_id:[5,5,1,""],name:[5,5,1,""],profile_id:[5,5,1,""],project:[5,5,1,""],project_id:[5,5,1,""],projectoptimization_set:[5,5,1,""],pruning_estimations:[5,5,1,""],quantized_estimations:[5,5,1,""],source:[5,5,1,""],warmup_iterations_per_check:[5,5,1,""]},"sparsify.models.utils":{database_setup:[5,1,1,""]},"sparsify.schemas":{errors:[6,0,0,"-"],helpers:[6,0,0,"-"],jobs:[6,0,0,"-"],model_repo:[6,0,0,"-"],projects:[6,0,0,"-"],projects_benchmarks:[6,0,0,"-"],projects_data:[6,0,0,"-"],projects_model:[6,0,0,"-"],projects_optimizations:[6,0,0,"-"],projects_profiles:[6,0,0,"-"],system:[6,0,0,"-"]},"sparsify.schemas.errors":{ErrorSchema:[6,3,1,""]},"sparsify.schemas.errors.ErrorSchema":{opts:[6,5,1,""]},"sparsify.schemas.helpers":{EnumField:[6,3,1,""],data_dump_and_validation:[6,1,1,""]},"sparsify.schemas.helpers.EnumField":{deserialize:[6,4,1,""]},"sparsify.schemas.jobs":{JobProgressSchema:[6,3,1,""],JobSchema:[6,3,1,""],ResponseJobSchema:[6,3,1,""],ResponseJobsSchema:[6,3,1,""],SearchJobsSchema:[6,3,1,""]},"sparsify.schemas.jobs.JobProgressSchema":{opts:[6,5,1,""]},"sparsify.schemas.jobs.JobSchema":{opts:[6,5,1,""]},"sparsify.schemas.jobs.ResponseJobSchema":{opts:[6,5,1,""]},"sparsify.schemas.jobs.ResponseJobsSchema":{opts:[6,5,1,""]},"sparsify.schemas.jobs.SearchJobsSchema":{opts:[6,5,1,""]},"sparsify.schemas.model_repo":{ModelRepoArchitectureSchema:[6,3,1,""],ModelRepoDatasetSchema:[6,3,1,""],ModelRepoDomainSchema:[6,3,1,""],ModelRepoModelDescSchema:[6,3,1,""],ModelRepoModelMetricSchema:[6,3,1,""],ModelRepoModelPerfSchema:[6,3,1,""],ModelRepoModelSchema:[6,3,1,""],ResponseModelRepoModels:[6,3,1,""],SearchModelRepoModels:[6,3,1,""]},"sparsify.schemas.model_repo.ModelRepoArchitectureSchema":{opts:[6,5,1,""]},"sparsify.schemas.model_repo.ModelRepoDatasetSchema":{opts:[6,5,1,""]},"sparsify.schemas.model_repo.ModelRepoDomainSchema":{opts:[6,5,1,""]},"sparsify.schemas.model_repo.ModelRepoModelDescSchema":{opts:[6,5,1,""]},"sparsify.schemas.model_repo.ModelRepoModelMetricSchema":{opts:[6,5,1,""]},"sparsify.schemas.model_repo.ModelRepoModelPerfSchema":{opts:[6,5,1,""]},"sparsify.schemas.model_repo.ModelRepoModelSchema":{opts:[6,5,1,""]},"sparsify.schemas.model_repo.ResponseModelRepoModels":{opts:[6,5,1,""]},"sparsify.schemas.model_repo.SearchModelRepoModels":{opts:[6,5,1,""]},"sparsify.schemas.projects":{CreateUpdateProjectSchema:[6,3,1,""],DeleteProjectSchema:[6,3,1,""],ProjectExtSchema:[6,3,1,""],ProjectSchema:[6,3,1,""],ResponseProjectDeletedSchema:[6,3,1,""],ResponseProjectExtSchema:[6,3,1,""],ResponseProjectSchema:[6,3,1,""],ResponseProjectsSchema:[6,3,1,""],SearchProjectsSchema:[6,3,1,""]},"sparsify.schemas.projects.CreateUpdateProjectSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects.DeleteProjectSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects.ProjectExtSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects.ProjectSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects.ResponseProjectDeletedSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects.ResponseProjectExtSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects.ResponseProjectSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects.ResponseProjectsSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects.SearchProjectsSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_benchmarks":{CreateProjectBenchmarkSchema:[6,3,1,""],ProjectBenchmarkResultSchema:[6,3,1,""],ProjectBenchmarkResultsSchema:[6,3,1,""],ProjectBenchmarkSchema:[6,3,1,""],ResponseProjectBenchmarkDeletedSchema:[6,3,1,""],ResponseProjectBenchmarkSchema:[6,3,1,""],ResponseProjectBenchmarksSchema:[6,3,1,""],SearchProjectBenchmarksSchema:[6,3,1,""]},"sparsify.schemas.projects_benchmarks.CreateProjectBenchmarkSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_benchmarks.ProjectBenchmarkResultSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_benchmarks.ProjectBenchmarkResultsSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_benchmarks.ProjectBenchmarkSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_benchmarks.ResponseProjectBenchmarkDeletedSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_benchmarks.ResponseProjectBenchmarkSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_benchmarks.ResponseProjectBenchmarksSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_benchmarks.SearchProjectBenchmarksSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_data":{CreateUpdateProjectDataSchema:[6,3,1,""],ProjectDataSchema:[6,3,1,""],ResponseProjectDataDeletedSchema:[6,3,1,""],ResponseProjectDataSchema:[6,3,1,""],ResponseProjectDataSingleSchema:[6,3,1,""],SearchProjectDataSchema:[6,3,1,""],SetProjectDataFromSchema:[6,3,1,""]},"sparsify.schemas.projects_data.CreateUpdateProjectDataSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_data.ProjectDataSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_data.ResponseProjectDataDeletedSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_data.ResponseProjectDataSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_data.ResponseProjectDataSingleSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_data.SearchProjectDataSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_data.SetProjectDataFromSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_model":{CreateUpdateProjectModelSchema:[6,3,1,""],DeleteProjectModelSchema:[6,3,1,""],ProjectModelAnalysisSchema:[6,3,1,""],ProjectModelSchema:[6,3,1,""],ResponseProjectModelAnalysisSchema:[6,3,1,""],ResponseProjectModelDeletedSchema:[6,3,1,""],ResponseProjectModelSchema:[6,3,1,""],SetProjectModelFromSchema:[6,3,1,""]},"sparsify.schemas.projects_model.CreateUpdateProjectModelSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_model.DeleteProjectModelSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_model.ProjectModelAnalysisSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_model.ProjectModelSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_model.ResponseProjectModelAnalysisSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_model.ResponseProjectModelDeletedSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_model.ResponseProjectModelSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_model.SetProjectModelFromSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations":{CreateProjectOptimizationSchema:[6,3,1,""],CreateUpdateProjectOptimizationModifiersLRScheduleSchema:[6,3,1,""],CreateUpdateProjectOptimizationModifiersPruningSchema:[6,3,1,""],CreateUpdateProjectOptimizationModifiersQuantizationSchema:[6,3,1,""],CreateUpdateProjectOptimizationModifiersTrainableSchema:[6,3,1,""],GetProjectOptimizationBestEstimatedResultsSchema:[6,3,1,""],ProjectAvailableModelModificationsSchema:[6,3,1,""],ProjectOptimizationModifierLRExponentialArgsSchema:[6,3,1,""],ProjectOptimizationModifierLRMultiStepArgsSchema:[6,3,1,""],ProjectOptimizationModifierLRScheduleSchema:[6,3,1,""],ProjectOptimizationModifierLRSchema:[6,3,1,""],ProjectOptimizationModifierLRSetArgsSchema:[6,3,1,""],ProjectOptimizationModifierLRStepArgsSchema:[6,3,1,""],ProjectOptimizationModifierPruningNodeSchema:[6,3,1,""],ProjectOptimizationModifierPruningSchema:[6,3,1,""],ProjectOptimizationModifierQuantizationNodeSchema:[6,3,1,""],ProjectOptimizationModifierQuantizationSchema:[6,3,1,""],ProjectOptimizationModifierTrainableNodeSchema:[6,3,1,""],ProjectOptimizationModifierTrainableSchema:[6,3,1,""],ProjectOptimizationSchema:[6,3,1,""],ResponseProjectOptimizationDeletedSchema:[6,3,1,""],ResponseProjectOptimizationFrameworksAvailableSamplesSchema:[6,3,1,""],ResponseProjectOptimizationFrameworksAvailableSchema:[6,3,1,""],ResponseProjectOptimizationModifierDeletedSchema:[6,3,1,""],ResponseProjectOptimizationModifiersAvailable:[6,3,1,""],ResponseProjectOptimizationModifiersBestEstimated:[6,3,1,""],ResponseProjectOptimizationSchema:[6,3,1,""],ResponseProjectOptimizationsSchema:[6,3,1,""],SearchProjectOptimizationsSchema:[6,3,1,""],UpdateProjectOptimizationSchema:[6,3,1,""]},"sparsify.schemas.projects_optimizations.CreateProjectOptimizationSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.CreateUpdateProjectOptimizationModifiersLRScheduleSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.CreateUpdateProjectOptimizationModifiersPruningSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.CreateUpdateProjectOptimizationModifiersQuantizationSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.CreateUpdateProjectOptimizationModifiersTrainableSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.GetProjectOptimizationBestEstimatedResultsSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.ProjectAvailableModelModificationsSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.ProjectOptimizationModifierLRExponentialArgsSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.ProjectOptimizationModifierLRMultiStepArgsSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.ProjectOptimizationModifierLRScheduleSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.ProjectOptimizationModifierLRSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.ProjectOptimizationModifierLRSetArgsSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.ProjectOptimizationModifierLRStepArgsSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.ProjectOptimizationModifierPruningNodeSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.ProjectOptimizationModifierPruningSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.ProjectOptimizationModifierQuantizationNodeSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.ProjectOptimizationModifierQuantizationSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.ProjectOptimizationModifierTrainableNodeSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.ProjectOptimizationModifierTrainableSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.ProjectOptimizationSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.ResponseProjectOptimizationDeletedSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.ResponseProjectOptimizationFrameworksAvailableSamplesSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.ResponseProjectOptimizationFrameworksAvailableSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.ResponseProjectOptimizationModifierDeletedSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.ResponseProjectOptimizationModifiersAvailable":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.ResponseProjectOptimizationModifiersBestEstimated":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.ResponseProjectOptimizationSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.ResponseProjectOptimizationsSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.SearchProjectOptimizationsSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_optimizations.UpdateProjectOptimizationSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_profiles":{CreateProjectLossProfileSchema:[6,3,1,""],CreateProjectPerfProfileSchema:[6,3,1,""],ProjectLossProfileSchema:[6,3,1,""],ProjectPerfProfileSchema:[6,3,1,""],ProjectProfileAnalysisSchema:[6,3,1,""],ProjectProfileMeasurementSchema:[6,3,1,""],ProjectProfileMeasurementsSchema:[6,3,1,""],ProjectProfileModelOpsBaselineMeasurementsSchema:[6,3,1,""],ProjectProfileModelOpsMeasurementsSchema:[6,3,1,""],ProjectProfileOpBaselineMeasurementSchema:[6,3,1,""],ProjectProfileOpMeasurementsSchema:[6,3,1,""],ProjectProfileOpSchema:[6,3,1,""],ProjectProfileSchema:[6,3,1,""],ResponseProjectLossProfileSchema:[6,3,1,""],ResponseProjectLossProfilesSchema:[6,3,1,""],ResponseProjectPerfProfileSchema:[6,3,1,""],ResponseProjectPerfProfilesSchema:[6,3,1,""],ResponseProjectProfileDeletedSchema:[6,3,1,""],SearchProjectProfilesSchema:[6,3,1,""]},"sparsify.schemas.projects_profiles.CreateProjectLossProfileSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_profiles.CreateProjectPerfProfileSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_profiles.ProjectLossProfileSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_profiles.ProjectPerfProfileSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_profiles.ProjectProfileAnalysisSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_profiles.ProjectProfileMeasurementSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_profiles.ProjectProfileMeasurementsSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_profiles.ProjectProfileModelOpsBaselineMeasurementsSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_profiles.ProjectProfileModelOpsMeasurementsSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_profiles.ProjectProfileOpBaselineMeasurementSchema":{dump_fields:[6,5,1,""],fields:[6,5,1,""],load_fields:[6,5,1,""],opts:[6,5,1,""]},"sparsify.schemas.projects_profiles.ProjectProfileOpMeasurementsSchema":{dump_fields:[6,5,1,""],fields:[6,5,1,""],load_fields:[6,5,1,""],opts:[6,5,1,""]},"sparsify.schemas.projects_profiles.ProjectProfileOpSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_profiles.ProjectProfileSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_profiles.ResponseProjectLossProfileSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_profiles.ResponseProjectLossProfilesSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_profiles.ResponseProjectPerfProfileSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_profiles.ResponseProjectPerfProfilesSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_profiles.ResponseProjectProfileDeletedSchema":{opts:[6,5,1,""]},"sparsify.schemas.projects_profiles.SearchProjectProfilesSchema":{opts:[6,5,1,""]},"sparsify.schemas.system":{ResponseSystemInfo:[6,3,1,""],SystemInfo:[6,3,1,""],VersionInfoSchema:[6,3,1,""]},"sparsify.schemas.system.ResponseSystemInfo":{opts:[6,5,1,""]},"sparsify.schemas.system.SystemInfo":{opts:[6,5,1,""]},"sparsify.schemas.system.VersionInfoSchema":{opts:[6,5,1,""]},"sparsify.utils":{system:[7,0,0,"-"]},"sparsify.utils.system":{available_ml_engines:[7,1,1,""],get_ml_sys_info:[7,1,1,""],ml_engines_errors:[7,1,1,""]},"sparsify.workers":{base:[8,0,0,"-"],manager:[8,0,0,"-"],projects_benchmark:[8,0,0,"-"],projects_data:[8,0,0,"-"],projects_model:[8,0,0,"-"],projects_profiles:[8,0,0,"-"]},"sparsify.workers.base":{JobWorker:[8,3,1,""],JobWorkerRegistry:[8,3,1,""]},"sparsify.workers.base.JobWorker":{format_args:[8,4,1,""],get_type:[8,4,1,""],job_id:[8,4,1,""],project_id:[8,4,1,""],run:[8,4,1,""]},"sparsify.workers.base.JobWorkerRegistry":{REGISTRY:[8,5,1,""],create_worker:[8,4,1,""]},"sparsify.workers.manager":{JobCancelationFailureError:[8,2,1,""],JobNotFoundError:[8,2,1,""],JobWorkerManager:[8,3,1,""]},"sparsify.workers.manager.JobWorkerManager":{cancel_job:[8,4,1,""],refresh:[8,4,1,""],shutdown:[8,4,1,""],start:[8,4,1,""]},"sparsify.workers.projects_benchmark":{CreateBenchmarkJobWorker:[8,3,1,""]},"sparsify.workers.projects_benchmark.CreateBenchmarkJobWorker":{batch_sizes:[8,4,1,""],benchmark_id:[8,4,1,""],core_counts:[8,4,1,""],format_args:[8,4,1,""],inference_models:[8,4,1,""],instruction_sets:[8,4,1,""],iterations_per_check:[8,4,1,""],model_id:[8,4,1,""],run:[8,4,1,""],warmup_iterations_per_check:[8,4,1,""]},"sparsify.workers.projects_data":{DataFromPathJobWorker:[8,3,1,""],DataFromRepoJobWorker:[8,3,1,""]},"sparsify.workers.projects_data.DataFromPathJobWorker":{run:[8,4,1,""]},"sparsify.workers.projects_data.DataFromRepoJobWorker":{run:[8,4,1,""]},"sparsify.workers.projects_model":{ModelFromPathJobWorker:[8,3,1,""],ModelFromRepoJobWorker:[8,3,1,""]},"sparsify.workers.projects_model.ModelFromPathJobWorker":{run:[8,4,1,""]},"sparsify.workers.projects_model.ModelFromRepoJobWorker":{run:[8,4,1,""]},"sparsify.workers.projects_profiles":{CreateLossProfileJobWorker:[8,3,1,""],CreatePerfProfileJobWorker:[8,3,1,""]},"sparsify.workers.projects_profiles.CreateLossProfileJobWorker":{format_args:[8,4,1,""],model_id:[8,4,1,""],profile_id:[8,4,1,""],pruning_estimation_type:[8,4,1,""],pruning_estimations:[8,4,1,""],pruning_structure:[8,4,1,""],quantized_estimations:[8,4,1,""],run:[8,4,1,""]},"sparsify.workers.projects_profiles.CreatePerfProfileJobWorker":{batch_size:[8,4,1,""],core_count:[8,4,1,""],format_args:[8,4,1,""],iterations_per_check:[8,4,1,""],pruning_estimations:[8,4,1,""],quantized_estimations:[8,4,1,""],run:[8,4,1,""],warmup_iterations_per_check:[8,4,1,""]},sparsify:{app:[1,0,0,"-"],blueprints:[2,0,0,"-"],log:[1,0,0,"-"],models:[5,0,0,"-"],schemas:[6,0,0,"-"],utils:[7,0,0,"-"],workers:[8,0,0,"-"]}},objnames:{"0":["py","module","Python module"],"1":["py","function","Python function"],"2":["py","exception","Python exception"],"3":["py","class","Python class"],"4":["py","method","Python method"],"5":["py","attribute","Python attribute"]},objtypes:{"0":"py:module","1":"py:function","2":"py:exception","3":"py:class","4":"py:method","5":"py:attribute"},terms:{"100":4,"404":4,"5543":11,"abstract":[5,8],"case":[15,16,19,24],"class":[4,5,6,8],"default":[4,5,11,16,17],"enum":[5,6],"export":[9,14,15,21,22,24,25],"final":[4,9,12,19],"float":[4,5,16,17,24],"function":[4,5,7],"import":[7,18],"int":[1,3,4,8],"long":[17,24],"new":[4,9,14,16,20,25],"null":5,"public":[8,11],"return":[1,4,5,6,7,8,15,16,22],"static":8,"true":[4,8],"try":[18,22],"while":[6,9,14,17,19,24],Adding:[9,16,25],And:[15,24],For:[9,11,14,15,16,17,18,19,20,22,24],One:24,Such:7,The:[6,8,9,11,13,15,16,17,18,19,20,21,22,24],Then:[16,17,18,20,22],There:[18,19],These:[16,19,21],Use:[6,12,14],Used:5,Using:20,Will:4,_dataloaderjobwork:8,_hidden:5,_modelloaderjobwork:8,abl:4,about:[9,13,17,18,25],acceler:12,accept:[11,15,22],access:[8,11,19,23],accordingli:21,accuraci:[9,12,19,24],achiev:[9,12,17,24],across:[17,19,24],activ:[9,14,19,24],add:[4,17,18,19,20],added:8,addit:[8,11,14,16,19,24,25],addition:[9,11],address:11,adjust:19,advanc:12,affect:[14,15,16,17,18,19,24],after:[4,6,8,11,14,18,19,20,21,22,24],again:[14,20],algorithm:[11,14,15],alia:[4,5],all:[1,4,5,6,8,9,12,16,17,19,20,22,24],allow:[8,11,23],along:[1,11],alpha:12,alphanumer:15,alreadi:[18,19,20],also:[16,17,18,20,24],altern:9,alwai:[4,17],amount:24,analysi:[4,5,6,8,11,13,14,15,24],analyz:[9,12,13,19,25],ani:[3,4,6,7,8,12,14,15,16,21,23,24],anoth:20,anyth:[6,8],anywher:15,api:[2,9],app:[0,5,6,9],appear:17,appli:[4,9,14,16,17,19,24],applic:2,apply_node_overrid:4,approach:9,appropri:[8,20],approxim:[16,18,24],architect:17,architectur:[6,16,18,24],area:[13,17],arg:[4,5,6,8],argument:6,artifici:15,assign:4,associ:6,attr:[6,8],attribut:[6,24],autofield:5,automat:[4,9,14,15,19],automl:11,avail:[6,7,8,11,13,17,24],available_ml_engin:7,averag:[18,19,20,24],avoid:12,avx2:24,avx512:24,awai:24,awar:11,back:[15,16,17],background:8,balanc:19,balance_perf_loss:[4,5],bar:[13,14,15,17,18,23],base:[0,1,4,6,7,15,17,20,21],basecreatedmodifiedmodel:5,basecreatedmodifiedmodeldoesnotexist:5,basejobwork:8,baselin:[4,6,9,11,17,18,20,24],baseline_spars:4,basemodel:5,basemodeldoesnotexist:5,baseprofilejobwork:8,baseprojectmodel:5,baseprojectmodeldoesnotexist:5,baseprojectprofil:5,baseprojectprofile_set:5,baseprojectprofiledoesnotexist:5,basi:[17,19],basic:12,batch:[8,15,16,17,20,24],batch_siz:[3,5,8],batchnorm:24,becaus:[16,18],been:24,befor:[4,8,15,24],begin:[8,11,12,14,15,24],being:[8,16],belong:8,below:[11,19,20],benchmark:[1,2,4,5,6,8,9,12,14,16,19,24,25],benchmark_id:[4,5,8],best:[4,6,9,11,12,19],better:[9,11,17,19,24],between:[9,12,18,19],bit:24,black:13,block_4:8,blog:9,blueprint:[0,1],bool:[1,4,6,8],booleanfield:5,both:[11,16,17],bottom:11,brows:[11,15],browser:[11,15],bug:[9,12],build:9,busi:[20,22],button:[11,13,19,20,21,23],call:4,callabl:3,can:[1,5,8,9,11,14,15,16,17,18,19,20,21,22,23,24,25],cancel:[5,8,15],cancel_job:8,cannot:11,chanc:[18,19,24],chang:[14,15,16,17,19,20,21,23],charact:15,charfield:5,check:[8,10,11,12,20],choic:[5,19],choos:[11,21],chronolog:20,classif:16,classmethod:8,click:[11,15,16,17,18,19,20,21,23],clipboard:22,close:[19,24],code:[1,6,8,9,11,14,19,21,24,25],code_sampl:[1,2],collat:5,color:14,column_nam:5,combin:[9,12],come:17,command:[11,13,15],common:[11,16],compar:[9,19,24,25],comparison:[8,20],compat:13,complet:[5,8,11,15,16,18,24],compress:[5,12,14,18],comput:[15,17,24],concept:[9,22,23,25],condit:20,confid:[18,19,24],config:[4,9,21,25],config_path:3,configur:[8,11,14,15,19,21,22],confirm:11,consid:16,consider:16,consist:[1,17,18,19],consol:11,constant:17,constraint:5,constructor:8,consult:15,contain:[4,5,6,7,8,9,12],content:[0,9],context:6,continu:[11,15,16,17,18,19,20,24],contribut:[15,24],control:[19,22,24],conv:24,convers:17,convert:11,convolut:[17,24],copi:[8,11,22],core:[7,8,15,16,17,20,24],core_count:[5,8],correct:5,correctli:[4,9,11],correl:18,correspond:[18,19,21],cost:24,could:8,count:[8,9,16,17,20,24,25],cpu:[9,16,17,20,24],creat:[1,4,5,6,9,11,13,14,19,20,25],create_config:4,create_work:8,createbenchmarkjobwork:8,createlossprofilejobwork:8,createperfprofilejobwork:8,createprojectbenchmarkschema:6,createprojectlossprofileschema:6,createprojectoptimizationschema:6,createprojectperfprofileschema:6,createupdateprojectdataschema:6,createupdateprojectmodelschema:6,createupdateprojectoptimizationmodifierslrscheduleschema:6,createupdateprojectoptimizationmodifierspruningschema:6,createupdateprojectoptimizationmodifiersquantizationschema:6,createupdateprojectoptimizationmodifierstrainableschema:6,createupdateprojectschema:6,creation:11,criteria:[20,22],csv:5,csvfield:5,csvfloatfield:5,csvintfield:5,current:[4,6,7,8,11,12,14,15,17,18,19,21,24],custom:[6,19],cut:[15,24],data:[2,3,4,5,6,8,15,24],data_dump_and_valid:6,data_id:[4,5,8],data_path:4,databas:[5,6,8],database_setup:5,datafrompathjobwork:8,datafromrepojobwork:8,dataset:[3,6,9],date:5,datetimefield:5,db_column:5,db_valu:5,debian:10,debug:1,deep:[9,12],deeper:[13,17],deepspars:[7,9,13,15,17,24],default_epochs_distribut:4,default_pruning_set:4,default_train:4,defin:[17,18,24],degre:11,delet:[5,6,23],delete_filesystem:5,deleteprojectmodelschema:6,deleteprojectschema:6,dens:17,depend:[16,17,20],deploi:[9,12,16],deploy:[12,16],depth:[10,11,24],desc:6,describ:[16,19,20,22],descript:[5,15,21],deseri:6,desir:11,detail:[4,12,13,14,16,19,24],detect:16,determin:[15,16,17,19,20,24],dev:9,devic:3,dialog:[15,16,17,18,19,23],dict:[4,6,7,8],dictionari:[4,6,7,8],did:[18,22,24],differ:[11,17,19,20,22],differenti:15,dir_path:5,dir_siz:5,direct:9,directori:5,disabl:[16,20],discuss:12,disk:22,displai:[11,15,16,17,19,20,23,24,25],distribut:4,doc:9,document:[9,11,15],doe:[15,24],doesnotexist:5,doing:[8,20],domain:[6,16],done:[18,19,24],down:[17,20],download:[8,9,11],drag:15,dramat:24,drill:17,driven:9,drop:20,dump:6,dump_field:6,dump_onli:6,duplic:12,dure:[13,14,15,18,19,21,22,24],each:[4,8,14,16,17,18,19,24],easi:[9,11,12],easili:[9,11,15],ecosystem:15,edit:[9,11,19,23],editor:19,effect:[4,9,11,14,15,16,17,18],effici:17,either:[8,11,15,17,20],emgin:15,emploi:24,empti:15,enabl:[9,11,14,15,17,20,24],encod:[9,22],encompass:9,encount:[4,6,7],end:[4,9,15,19,24],end_epoch:[4,5],engin:[7,9,12,13,17,24,25],ensur:13,enter:[11,15,16,17,18,19,23],entir:[17,18],entri:11,enum_class:6,enumer:5,enumfield:6,environ:[10,11,12],epoch:[4,19,24],equat:17,error:[0,1,4,5,7,8,12],errorschema:6,est_loss_sensit:5,est_perf_sensit:5,est_recoveri:5,est_tim:5,est_time_baselin:5,est_time_gain:5,establish:19,estim:[4,6,11,14,15,17,18,19,20,24],etc:[4,7],eval_baselin:4,eval_prun:4,eval_sensitivity_spars:4,evalu:4,even:17,event:6,eventu:16,everi:19,everyth:9,exact:18,examin:20,exampl:[9,12,14,15,16,17,18,19,20,22,24],except:[4,7,8],exchang:[15,24],exclud:6,execut:[16,24],exist:[5,9,12,14,20,21,25],exit:8,expect:[4,5,6,19],experi:[10,12],explor:[21,22],exponenti:6,extend:[5,8],extens:17,extern:1,extract:8,factor:17,fals:[4,5,6,8],fast:[9,16,17,24],faster:[9,14,17,19,24],fastest:17,featur:[9,12,15,22,23,25],fed:24,feedback:[9,19,25],few:[9,11],fewer:[17,18,24],fft:9,field:[4,5,6,8,11,15],field_nam:6,field_typ:5,file:[1,2,5,6,8,9,11,12,14,15,19,21,25],file_path:5,filestorag:5,fill:11,filter:[6,19],filter_min_perf_gain:[4,5],filter_min_recoveri:[4,5],filter_min_spars:[4,5],final_lr:5,find:11,fine:[4,19],fine_tuning_epoch:4,fine_tuning_start_epoch:4,finish:11,five:14,fix:20,flask:[2,4,5,6],floatfield:5,flop:[5,16,17,19,24],flops_baselin:5,flops_gain:5,flow:[9,11,14,21,22,24],focus:[11,24],folder:5,follow:[11,12,13,15,17,18,19,24],footprint:9,foreignkeyfield:5,format:[1,8,9,11,15,22],format_arg:8,found:[4,8,9],framework:[4,6,11,12,17,21],frequenc:19,from:[1,4,5,6,8,9,10,11,12,15,16,17,18,19,20,23,24,25],full:9,further:[11,15,16,18],futur:[11,14,18,19,24],gemm:24,gener:[4,9,14,16,17,19,21,22,23,24],get:[4,6,13,14,15,17,19,20],get_main_logg:1,get_ml_sys_info:7,get_profiles_by_id:4,get_project_benchmark_by_id:4,get_project_by_id:4,get_project_data_by_id:4,get_project_model_by_project_id:4,get_project_optimizer_by_id:4,get_root_logg:1,get_typ:8,getprojectoptimizationbestestimatedresultsschema:6,github:[9,12],give:[9,19],given:[4,5,8,11,24],global_end_epoch:4,global_start_epoch:4,globalaveragepool:24,goal:[12,14,15,19,21],going:[15,17,24],good:5,gpu:9,grai:16,grain:19,graph:[17,18,19,20,24],greater:[4,19,24],guid:[9,10,15],handl:[1,2,5,6,8],happen:[11,19],has:[17,18,24],have:[4,5,11,18,20,24],held:17,help:[9,17,19,25],help_text:5,helper:[0,1,2],here:[20,24],higher:[19,24],home:11,host:[1,9,11],how:[9,14,15,16,17,18,19,21,24],howev:19,http:11,httpnotfounderror:4,icon:[17,18,19],identifi:[16,17,18],ids:4,imag:16,implement:[8,9,24],improv:[9,12,14],includ:[5,6,7,8,9,12,14,17,18,21,22,23,24],inclus:11,increas:17,increasingli:19,independ:24,index:5,index_typ:5,indic:[14,16,17,18,19,20,24],individu:24,induc:9,industri:[9,12],infer:[7,8,9,11,14,15,16,17,24,25],inference_engin:8,inference_model:[5,8],inference_model_optim:8,info:[1,4,6,7],inform:[8,9,11,12,14,15,16,17,18,19,20,22,23,24,25],init:5,init_lr:5,initi:[4,5,13,19,21],input:[4,6,16,24],insight:[9,12],instal:[9,11,12,25],instanc:[5,8],instant:19,instead:[4,17,19],instruct:[7,8,15,17,24],instruction_set:[5,8],integ:5,integerfield:5,integr:[9,11,12,13,19,20,22,25],intellig:15,intens:[17,24],interact:11,intern:24,invalid:6,invok:4,involv:14,issu:12,item:[17,24],iter:8,iterations_per_check:[5,8],its:[4,6,11],job:[0,1,8],job_id:[5,8],jobcancelationfailureerror:8,jobdoesnotexist:5,jobnotfounderror:8,jobprogressschema:6,jobschema:6,jobstatu:5,jobstatusfield:5,jobwork:8,jobworkermanag:8,jobworkerregistri:8,join:4,json_dump:5,json_load:5,jsonfield:5,just:[15,16],keep:10,kei:[6,9,22,23,25],keyword:6,know:[15,24],kwarg:[5,6,8],lai:19,larg:[5,16],larger:[17,24],last:[8,18],latenc:16,later:[8,19],latest:[12,14,19,24],launch:[8,9,11,25],layer:[9,14,15,16,19,24,25],learn:[5,12,14,22,24,25],least:18,left:[11,13,15,19,23],less:[4,19],level:[1,4,5,9,19],light:12,like:16,limit:[9,11,17],line:[9,11],linux:10,list:[4,5,7,8,13,14,15,17,18,19,24],listobjfield:5,load:[5,6,9,11,15,17],load_field:6,load_onli:6,loadabl:6,local:[5,8,9,11,15],locat:[5,11],log:[0,9,24],logger:1,logging_level:1,longer:[17,24],look:[15,16,17,24],loss:[2,3,4,5,6,8,9,11,12,14,15,16,17,19,24,25],loss_analysi:4,losswrapp:3,low:24,lower:[11,22],lr_mod:[4,5],lr_sched:4,lr_schedule_modifi:5,ma_field:6,machin:[11,24],magic:[8,9,12,13,17,24],mai:[5,11,12,16,17,18,20,24],main:[1,11],maintain:12,major:17,make:[2,14,18,19,23,24],manag:[0,1,24],mani:[6,14,16,18,24],map:6,mark:8,marshmallow:6,mask_typ:[4,5],matter:4,max_node_spars:4,max_work:8,maxim:[4,13],maximum:8,maxpool:24,mean:24,measur:[6,8,14,16,17,18,19,20,24],memori:24,mention:[22,23],menu:20,messag:[12,16],metadata:[6,24],method:11,metric:[4,6,9,11,16,20],might:[14,16,17,18,20],millisecond:[17,24],minim:[14,21],minimum:19,minut:9,miss:6,ml_engines_error:7,mod:4,mod_end_epoch:4,mod_start_epoch:4,modal:11,model:[0,1,2,3,4,6,8,9,12,13,14,15,20,21,22,24,25],model_analysi:4,model_id:[5,8],model_path:4,model_repo:[0,1],modelfrompathjobwork:8,modelfromrepojobwork:8,modelrepoarchitectureschema:6,modelrepodatasetschema:6,modelrepodomainschema:6,modelrepomodeldescschema:6,modelrepomodelmetricschema:6,modelrepomodelperfschema:6,modelrepomodelschema:6,modif:19,modifi:[2,4,5,6,14,21,22,24,25],modifier_id:5,modul:[0,9],more:[11,13,17,18,19,24],most:[11,17,18,20],move:[11,19],much:[11,15,16,18,19,24],multi:6,multipl:[5,6,13,15,16,19,20],must:[4,5,8,11,19],name:[4,5,8,15,16,17,18,24],namespac:1,natur:9,navig:[11,13,14,15,17,18,23],nearli:9,need:[9,11,12,14,15,19,21],nest:5,network:[1,9,11,12,15,18,24],neural:[1,8,9,12,13,15,17,24],next:[8,12,13,14,15,16,17,18,19,20,21,22,23,24],nightli:9,node:[4,5,6,17,24],node_overrid:4,none:[4,5,6,8],note:[5,11,15,16,17,18,19,20],notic:[9,19],npz:8,number:[4,7,8,16,18,19,24],numer:16,object:[4,5,6,8,16],occur:[6,9,19],offici:9,offlin:16,often:19,oldest:8,onc:[8,11,14,15,19],one:[5,8,11,15,19,24],one_shot:8,ones:8,onli:[4,5,6,8,9,11,15,19],onlin:16,onnx:[7,8,11,14,15,17,20,24],onscreen:12,onto:8,open:[9,11,14,19,24,25],oper:[9,12,16,17,24],ops:[6,24],opt:[6,16],optim:[1,2,3,4,5,6,9,12,13,15,16,17,18,20,21,24,25],optim_const:3,optim_id:[4,5],optim_lr_sched_default_mod:4,optim_lr_sched_updat:4,optim_pruning_updat:4,optim_trainable_default_nod:4,optim_trainable_updat:4,optim_updat:4,optim_validate_and_get_project_by_id:4,optimepoch:4,option:[1,4,5,6,8,11,12,13,14,16,17,19,20],order:[10,20,24],origin:[4,11,15,17,18,19,20,23,24],ort:[17,24],ort_cpu:7,ort_gpu:7,other:[1,17,19,24],otherwis:[4,8,19],out:[8,10,11,15,16,19,24],over:9,overprecis:9,overrid:[4,5,22],overview:[13,25],own:10,packag:[0,9,11],page:[11,13,15],parallel:8,param:[5,9,19,24,25],paramet:[1,4,5,6,8,14,16,18,24],parameter:9,params_baselin:5,part:[15,21,24],partial:6,pass:[6,15,24],path:[5,6,8,11,12,15],peewe:5,pend:[5,8],per:[16,17,19,24],percentag:[17,24],perf:[4,5,6,8],perf_analysi:4,perform:[2,4,5,6,8,9,11,12,13,14,15,16,18,19,24,25],perhap:22,pip:[10,13],pipelin:11,place:[11,19],plan:12,platform:21,playhous:5,pleas:12,plu:9,point:[8,11,16,17,24],pool:24,popup:11,port:[1,11],portion:[1,17],possibl:[17,19,24],post:12,potenti:[7,9,12,14,17],practic:14,practition:[9,12],present:[8,24],preset:19,previou:15,primary_kei:5,problem:17,procedur:15,process:[8,9,12,19,21,22,24],product:[9,12],profil:[2,4,5,6,8,9,11,14,15,19,24,25],profile_id:[5,8],profile_loss:[4,5],profile_loss_id:[4,5],profile_perf:[4,5],profile_perf_id:[4,5],profiles_loss:5,profiles_perf:5,program:24,progress:[5,6,8],project:[0,1,8,9,14,16,17,18,22,23,24,25],project_data:8,project_id:[4,5,8],projectavailablemodelmodificationsschema:6,projectbenchmark:[4,5],projectbenchmark_set:5,projectbenchmarkdoesnotexist:5,projectbenchmarkresultschema:6,projectbenchmarkresultsschema:6,projectbenchmarkschema:6,projectdata:[4,5],projectdata_set:5,projectdatadoesnotexist:5,projectdataschema:6,projectdoesnotexist:5,projectextschema:6,projectlossprofil:[4,5],projectlossprofile_set:5,projectlossprofiledoesnotexist:5,projectlossprofileschema:6,projectmodel:[4,5],projectmodel_set:5,projectmodelanalysisschema:6,projectmodeldoesnotexist:5,projectmodelschema:6,projectoptim:[4,5],projectoptimization_set:5,projectoptimizationdoesnotexist:5,projectoptimizationmodifierestimationsschema:6,projectoptimizationmodifierlrexponentialargsschema:6,projectoptimizationmodifierlrmultistepargsschema:6,projectoptimizationmodifierlrschedul:[4,5],projectoptimizationmodifierlrscheduledoesnotexist:5,projectoptimizationmodifierlrscheduleschema:6,projectoptimizationmodifierlrschema:6,projectoptimizationmodifierlrsetargsschema:6,projectoptimizationmodifierlrstepargsschema:6,projectoptimizationmodifierprun:[4,5],projectoptimizationmodifierpruningdoesnotexist:5,projectoptimizationmodifierpruningnodemetadataschema:6,projectoptimizationmodifierpruningnodeschema:6,projectoptimizationmodifierpruningschema:6,projectoptimizationmodifierquant:5,projectoptimizationmodifierquantizationdoesnotexist:5,projectoptimizationmodifierquantizationnodeschema:6,projectoptimizationmodifierquantizationschema:6,projectoptimizationmodifiertrain:[4,5],projectoptimizationmodifiertrainabledoesnotexist:5,projectoptimizationmodifiertrainablenodeschema:6,projectoptimizationmodifiertrainableschema:6,projectoptimizationschema:6,projectperfprofil:[4,5],projectperfprofile_set:5,projectperfprofiledoesnotexist:5,projectperfprofileschema:6,projectprofileanalysisschema:6,projectprofilemeasurementschema:6,projectprofilemeasurementsschema:6,projectprofilemodelopsbaselinemeasurementsschema:6,projectprofilemodelopsmeasurementsschema:6,projectprofileopbaselinemeasurementschema:6,projectprofileopmeasurementsschema:6,projectprofileopschema:6,projectprofileschema:6,projects_benchmark:[0,1],projects_data:[0,1],projects_model:[0,1,4],projects_optim:[0,1],projects_optimizations_prun:[1,2],projects_profil:[0,1,4],projectschema:6,proper:[8,11],properli:11,properti:[4,5,8],provid:[4,7,11,12,14,16,17,18,19,22],prunabl:[4,18],prune:[4,5,6,8,9,14,16,17,18,22,24,25],pruning_end_epoch:4,pruning_epoch:4,pruning_estim:[5,8],pruning_estimation_typ:[5,8],pruning_modifi:5,pruning_set:4,pruning_start_epoch:4,pruning_structur:[5,8],pruning_update_frequ:4,pruningmodelevalu:4,pruningset:4,put:[8,14],pypi:9,python:10,python_valu:5,pytorch:[3,15,17,21],pytorch__integr:[1,2],pytorch__train:[1,2],quantiz:[5,6,8,9,14,18,19,24],quantization_modifi:5,quantized_estim:[5,8],quantized_estimation_typ:5,queri:6,quick:9,quickli:[14,16],rais:[4,6,8],raise_not_found:4,ran:[17,19,20,24],rang:[18,19,24],rapidli:[9,12],rate:[5,22,24,25],rather:[14,15,19,20,24],raw:6,read:11,readi:[16,17,18,19],real:16,recent:20,recip:9,recommend:[4,10],recov:[9,18,19,22,24],recoveri:[4,9,11,18,19,24],redistribut:19,reduc:[18,24],reduct:[18,24],redund:[9,18],refer:15,referenc:16,reflect:23,refresh:[5,8],registri:8,rel:[18,19],relat:[2,6,8],releas:[11,12,18],relev:24,relu:24,remot:[11,15],remov:[9,19,24,25],repo:[2,6,8],report:6,repositori:[9,10,11],repres:[17,19],reproduc:12,request:[2,9,12],requir:[6,11,12,16,19,24],research:[9,12],respond:[14,18,24],respons:6,responsejobschema:6,responsejobsschema:6,responsemodelrepomodel:6,responseprojectbenchmarkdeletedschema:6,responseprojectbenchmarkschema:6,responseprojectbenchmarksschema:6,responseprojectdatadeletedschema:6,responseprojectdataschema:6,responseprojectdatasingleschema:6,responseprojectdeletedschema:6,responseprojectextschema:6,responseprojectlossprofileschema:6,responseprojectlossprofilesschema:6,responseprojectmodelanalysisschema:6,responseprojectmodeldeletedschema:6,responseprojectmodelschema:6,responseprojectoptimizationdeletedschema:6,responseprojectoptimizationframeworksavailablesamplesschema:6,responseprojectoptimizationframeworksavailableschema:6,responseprojectoptimizationmodifierdeletedschema:6,responseprojectoptimizationmodifiersavail:6,responseprojectoptimizationmodifiersbestestim:6,responseprojectoptimizationschema:6,responseprojectoptimizationsschema:6,responseprojectperfprofileschema:6,responseprojectperfprofilesschema:6,responseprojectprofiledeletedschema:6,responseprojectschema:6,responseprojectsschema:6,responsesysteminfo:6,restructur:24,result:[4,5,6,9,11,15,18,19,20,22,25],retain:16,retrain:[11,14,17,18,19,24],retriev:[4,8],review:[9,14,16,22,23,25],rewrit:21,right:[11,13,19,20],root:[1,5],root_path:5,rough:18,rout:[2,6],rule:11,run:[1,6,8,9,11,13,14,15,16,17,18,22,24,25],runtim:[17,20,24],same:[9,15,20],sampl:[5,6,11,24],satisfi:[14,19],save:[5,8,19,22,23],scale:[9,12,20],scenario:20,schedul:[4,5,6,19,24],schema:[0,1],schemaopt:6,scheme:16,screen:[9,11,15,17,19,21,25],screenshot:12,script:[1,11],scroll:19,search:6,searchjobsschema:6,searchmodelrepomodel:6,searchprojectbenchmarksschema:6,searchprojectdataschema:6,searchprojectoptimizationsschema:6,searchprojectprofilesschema:6,searchprojectsschema:6,second:[16,17,24],section:[14,17,18,19,23],see:[11,16,17,18,19,20,24],select:[11,15,16,17,19,20,24],sens:19,sensit:[9,11,14,24,25],separ:[11,24],sequenc:[5,6,24],sequenti:24,serial:6,serv:2,server:[1,2,5,6,8,11,15],set:[1,4,5,6,7,8,9,11,14,15,17,18,19,20,22,24,25],set_logging_level:1,setprojectdatafromschema:6,setprojectmodelfromschema:6,setup:[1,2,3,4,5,16,17,18,24],setup_filesystem:5,sever:15,share:12,shot:11,should:[4,8,16,19,22,24],show:[9,11,14,16,17,18,19,20,24],shown:[11,17],shuffl:[17,24],shutdown:8,side:15,signific:[17,18],significantli:[9,18,24],simpl:[9,14],simpli:[15,24],simplifi:[9,12],sinc:8,singl:[6,9,13,24,25],size:[5,8,9,12,15,16,17,18,20,24],slide:[9,12],slider:19,smaller:[9,14,17,24],smallest:24,softmax:24,softwar:12,some:[6,11],sort:20,sourc:[1,3,4,5,6,7,8,15],space:15,spars:[9,14,17,19],sparse_training_avail:4,sparseml:[3,9,11,15,21],sparsezoo:9,sparsif:[11,24],sparsifi:[10,11,15,16,17,18,21,22,23,24,25],sparsiti:[4,5,9,19,22,24],special:15,specif:[4,6,17,20,24],specifi:[11,18,19,20,24],speed:[9,11,12,17],speedup:[17,19,24],spent:17,sqlite_ext:5,stabil:19,stabilization_epoch:4,stabl:9,stage:19,standard:1,start:[4,5,8,9,11,15,19,20,24,25],start_epoch:[4,5],start_fine_tuning_epoch:4,state:5,statu:5,step:[4,6,8,12,13,14,16,17,18,19,20,21,22,23,24],stop:8,storag:5,store:[5,6,8],str:[1,3,4,5,6,7,8],string:[5,6],sub:8,subclass:8,subgraph:17,submit:12,submodul:[0,9],subpackag:[0,9],subsequ:8,substitut:11,suggest:12,suit:[9,12],summari:[9,12,24,25],support:[9,12],sure:12,system:[0,1,5,8,10,11,16,19,22,24],systeminfo:6,tabl:19,take:[9,16,17,19,24],taken:19,tar:8,target:[11,16],techniqu:[9,12,14,19,24],tell:24,tensor:3,tensorflow:[15,17,21],tensorflow__integr:[1,2],term:[9,22,23,25],termin:11,test:10,textfield:5,than:[4,14,15,19,20,24],thei:[14,16,20,24],theoret:[16,17,24],therefor:[11,16,17],thi:[4,8,9,10,11,14,15,16,17,18,19,20,21,22,23,24,25],those:[11,17,18,19,24],thread:24,threadpoolexecutor:8,three:[14,17,18,19,20,23],through:[8,11,17,19,24],throughout:[15,16,19,22,23],throughput:[16,17],tied:[17,19],time:[4,8,14,15,16,17,19,24],timestamp:5,to_dict_valu:4,took:[17,24],tool:[9,12,24],tooltip:19,top:[9,19],torch:3,total:[18,24],tour:[9,10],track:5,train:[3,4,9,11,14,21,22,23,24,25],train_dataset:3,train_setup:3,trainabl:[4,5,6],trainable_modifi:5,training_epoch:[4,5],training_final_lr:4,training_init_lr:4,training_lr_fin:5,training_lr_init:5,training_optim:5,transfer:[14,19],tune:[4,19],tupl:4,twice:19,two:[17,18,19,20],type:[5,6,8,11,13,17,18,19,24],type_:5,typic:24,ui_path:1,ultim:9,under:[8,11],understand:15,unindex:5,union:[3,4,6,8],uniqu:[5,15,24],unknown:6,unspecifi:15,unstructur:8,unsur:16,updat:[4,5,6,8,19],update_frequ:[4,5],updateprojectoptimizationschema:6,upload:[6,11,14,15],upper:[11,13],uri:[6,8],url:[6,8,11,15],use:[4,6,8,9,11,12,15,16,19,20,22,24],used:[1,5,6,11,12,15,16,17,18,19,20,22,24],user:[4,9,10,12,24],uses:24,using:[9,10,11,12,14,15,19,20,24],util:[0,1,2,3,17,24],val_dataset:3,valid:[4,5,6,7],validate_filesystem:5,validate_model_data:4,validate_pruning_nod:4,validationerror:6,valu:[4,5,6,7,14,17,18,19,20,22,24],valuabl:[15,24],varchar:5,vari:17,variou:[16,17,24],verbose_nam:5,veri:18,version:[12,14,15,20],versioninfoschema:6,via:9,view:[16,24],virtual:10,visit:11,visual:[9,12,17,19],vnni:24,wai:[12,15,16,17,19,24],want:[14,15,16,17,18,19,20,24],warmup:8,warmup_iterations_per_check:[5,8],web:11,websit:9,week:9,weight:[17,18,24],weight_magnitud:8,welcom:[9,25],well:[16,17,18,24],went:17,were:[17,18,24],what:[4,17,19,24],when:[4,7,9,14,15,16,17,18,19,24],where:[5,9,11,17,24],which:[13,15,16,17,18,19,20,24],who:[9,12],width:24,window:11,winograd:9,within:[8,24],without:[8,14,16,17,24],won:8,work:[5,6,8,14,21],worker:[0,1,6],worker_ack:5,worker_arg:5,workflow:[9,11,14],working_dir:[1,3,5],would:[5,17,18,22],yaml:4,yet:20,yml:[14,21,22],you:[9,11,12,14,15,16,17,18,19,20,21,22,23,24,25],your:[9,10,11,12,13,14,15,17,18,19,20,21,22,23,24],zero:18},titles:["sparsify","sparsify package","sparsify.blueprints package","sparsify.blueprints.code_samples package","sparsify.blueprints.utils package","sparsify.models package","sparsify.schemas package","sparsify.utils package","sparsify.workers package","Sparsify 0.1","Installation","Quick Tour","Welcome to Sparsify","Installing and Launching Sparsify","Sparsify Overview","Analyze","Profiling Your Model","Reviewing Performance Profiles","Reviewing Loss Profiles","Optimize","Benchmarking","Integrate","Optimization Config File and Code for Optimization","Settings","Key Concepts/Features/Terms","User Guide"],titleterms:{"export":[11,19],"new":[11,13,15,17,18],Adding:[17,18],about:12,addit:13,analyz:[11,14,15],app:1,base:[5,8],benchmark:20,blueprint:[2,3,4],can:13,code:22,code_sampl:3,compar:20,concept:24,config:22,content:[1,2,3,4,5,6,7,8],count:18,creat:15,displai:13,engin:20,error:[2,6],exist:[13,15],featur:24,feedback:12,file:22,from:13,guid:[12,25],help:12,helper:[4,6],histori:9,infer:20,inform:13,instal:[10,13],integr:[14,21],job:[2,5,6],kei:24,launch:13,layer:[17,18],learn:[9,19],log:1,loss:18,manag:8,model:[5,11,16,17,18,19],model_repo:[2,6],modifi:19,modul:[1,2,3,4,5,6,7,8],more:9,open:[13,15],optim:[11,14,19,22],overview:[9,14],packag:[1,2,3,4,5,6,7,8],param:18,perform:17,profil:[16,17,18],project:[2,4,5,6,11,13,15],projects_benchmark:[2,4,5,6,8],projects_data:[2,4,5,6,8],projects_model:[2,5,6,8],projects_optim:[2,4,5,6],projects_optimizations_prun:4,projects_profil:[2,5,6,8],prune:19,pytorch__integr:3,pytorch__train:3,quick:11,rate:19,recip:11,releas:9,remov:20,resourc:9,result:17,review:[17,18],run:[19,20],schema:6,screen:13,sensit:18,set:23,singl:20,sparsif:9,sparsifi:[0,1,2,3,4,5,6,7,8,9,12,13,14,19],start:13,submodul:[1,2,3,4,5,6,7,8],subpackag:[1,2],summari:[17,18,19],system:[2,6,7],tensorflow__integr:3,term:24,thi:12,tour:11,train:19,user:25,util:[4,5,7],welcom:12,worker:8,you:13,your:16}}) \ No newline at end of file